verbalized-sampling  by CHATS-lab

Enhance LLM diversity with training-free verbalized sampling

Created 1 year ago
766 stars

Top 45.1% on SourcePulse

GitHubView on GitHub
Project Summary

Verbalized Sampling is a training-free prompting strategy designed to mitigate mode collapse and significantly enhance Large Language Model (LLM) response diversity by 2-3x, while preserving output quality. This model-agnostic framework is ideal for users engaged in creative writing, synthetic data generation, and dialogue simulation, offering a straightforward method to unlock richer, more varied LLM outputs.

How It Works

The core approach involves prompting LLMs to generate multiple candidate responses, each accompanied by its estimated probability. The system then samples from this distribution, specifically targeting lower-probability responses (below 0.10), to encourage diversity. This method is training-free, meaning it can be applied to any LLM via prompting without requiring model fine-tuning. It is also orthogonal to the temperature parameter and effective across a wide range of tasks.

Quick Start & Requirements

Highlighted Details

  • Achieves 2-3x improvement in LLM response diversity.
  • Training-free and model-agnostic, compatible with GPT, Claude, Gemini, Llama, and others.
  • Orthogonal to temperature settings, offering an alternative control for output variation.
  • Effective for creative writing, social simulation, synthetic data generation, and open-ended QA.
  • Includes a Python package with CLI/API functionality and LangChain integration.

Maintenance & Community

The project provides links to its paper and blog, indicating active development and research. Specific community channels (e.g., Discord, Slack) or notable contributors are not detailed in the provided README.

Licensing & Compatibility

This project is licensed under the Apache License 2.0, which is permissive for commercial use and integration into closed-source projects.

Limitations & Caveats

The README suggests optimal performance with advanced LLMs such as GPT-5, Claude 4 Opus, and Gemini 2.5 Pro, implying that results may vary with less capable models. The prompt examples require specific response formatting (e.g., <response>, <text>, <probability>), which may necessitate careful handling to ensure correct interpretation by the target LLM.

Health Check
Last Commit

4 months ago

Responsiveness

Inactive

Pull Requests (30d)
0
Issues (30d)
0
Star History
18 stars in the last 30 days

Explore Similar Projects

Starred by Junyang Lin Junyang Lin(Core Maintainer at Alibaba Qwen), Shizhe Diao Shizhe Diao(Author of LMFlow; Research Scientist at NVIDIA), and
1 more.

LMaaS-Papers by txsun1997

0%
545
Curated list of LMaaS research papers
Created 3 years ago
Updated 2 years ago
Feedback? Help us improve.