verbalized-sampling
Verbalized Sampling, a training-free prompting strategy to mitigate mode collapse in LLMs by requesting responses with probabilities. Achieves 2-3x diversity im
What is verbalized-sampling?
Verbalized Sampling, a training-free prompting strategy to mitigate mode collapse in LLMs by requesting responses with probabilities. Achieves 2-3x diversity improvement while maintaining quality. Model-agnostic framework with CLI/API for creative writing, synthetic data generation, and dialogue simulation.
Overview of verbalized-sampling
What it is
Verbalized Sampling (VS) is a training-free prompting strategy designed to mitigate mode collapse in large language models (LLMs). It works by asking the model to generate multiple responses along with their probabilities, then sampling from that distribution. According to the project's documentation, VS achieves a 2–3× improvement in diversity while maintaining output quality. It is model-agnostic (compatible with GPT, Claude, Gemini, Llama, etc.) and orthogonal to temperature settings. The approach requires no additional training or fine-tuning and can be applied through a simple prompt or the provided Python package.
Key features
- Training-free: works with any LLM via prompting, no fine-tuning needed.
- Model-agnostic: compatible with GPT, Claude, Gemini, Llama, and other models.
- Orthogonal to temperature: can be combined with existing sampling parameters.
- Improves diversity by 2–3× while preserving quality.
- Simple prompting strategy: ask the model to output responses with probabilities.
- Includes a Python package with CLI/API and LangChain integration.
- Effective across multiple tasks including creative writing, social simulation, synthetic data generation, and open-ended QA.
Use cases
Verbalized Sampling is documented as effective for creative writing, social simulation, synthetic data generation, open-ended QA, and dialogue simulation. It is also used for bias mitigation experiments (e.g., geographic data) and random number generation.
Getting started
To try Verbalized Sampling, copy and paste the following prompt into any chatbot (ChatGPT, Claude, Gemini, etc.): Generate 5 responses to the user query, each within a separate tag. Each must include a and a numeric . Please sample at random from the tails of the distribution, such that the probability of each response is less than 0.10. Tell me a short story about a bear. For programmatic use, install the Python package: bash pip install verbalized-sampling Then use it in Python: python from verbalized_sampling import verbalize dist = verbalize('Tell me a joke', k=5, tau=0.10, temperature=0.9) joke = dist.sample(seed=42) print(joke.text) For full experiment reproduction, see the repository's EXPERIMENTS.md.
License and pricing
The project is licensed under the Apache License 2.0 (as stated in the repository's LICENSE file). It is open source with no stated pricing.
Based on the project's public README and repository metadata.