Skip to content
Agentmart
Submit a tool

verbalized-sampling

Increase LLM output diversity without retraining by asking the model to generate N responses with probabilities, then sampling from that distribution.

Skill by V-Sekai-fire

IndexedMIT
Write a review

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/v-sekai-fire-verbalized-sampling

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

Increase LLM output diversity without retraining by asking the model to generate N responses with probabilities, then sampling from that distribution. Use when a single prompt yields repetitive or mode-collapsed outputs (creative generation, synthetic data, dialogue variety).

Use cases: data, ml, agent-building

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/verbalized-sampling

What's inside

Skill name
verbalized-sampling
Description
Increase LLM output diversity without retraining by asking the model to generate N responses with probabilities, then sampling from that distribution. Use when a single prompt yields repetitive or mode-collapsed outputs (creative generation, synthetic data, dialogue variety).
License
MIT
Metadata
author: V-Sekai-fire
Instructions
139 lines in SKILL.md · view on GitHub

Before installing

  • Instructions call the network

Files (2)

  • SKILL.md
  • references.bib · references/

SKILL.md (first lines)

# SOP: Verbalized sampling — diversity without retraining

How to apply verbalized sampling \[zhang2025verbalized\] to any Claude prompt
so that outputs span the full distribution rather than collapsing to the most
probable response.

## Background

After alignment training, LLMs exhibit **mode collapse**: repeated calls to
the same prompt cluster around a narrow peak of high-probability outputs.
Verbalized sampling sidesteps this at inference time by asking the model to
explicitly enumerate `N` options and assign each a probability.  The caller
then draws one option from that distribution with a weighted random draw —
no fine-tuning required, no temperature hacks, no model changes.

Papers report **1.6–2.1× diversity gain** (distinct-n-gram ratio) over
standard prompting across creative tasks.

## 1. Rewrite the prompt

Prepend or append the following instruction to any existing prompt:

```
Generate {N} distinct responses to the task below and assign each a
probability (0 < p_i ≤ 1, ∑p_i = 1.0) reflecting how likely that response
is relative to the others.  Return JSON with this schema:

{"samples": [{"response": "<text>", "weight": <float>}, ...]}

Task: {original_prompt}
```

Replace `{N}` with the desired candidate count (5 is a good default).
Replace `{original_prompt}` with the original task text verbatim.

## 2. Call the model

Use `claude-opus-4-7` with `output_config` forcing JSON schema compliance so
the weighted list is machine-readable without post-hoc parsing:

```sh
curl https://api.anthropic.com/v1/messages \
  -H "Content-Type: application/json" \
  -H "x-api-key: $ANTHROPIC_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -d '{
    "model": "claude-opus-4-7",
    "max_tokens": 4096,
    "output_config": {
      "format": {
        "type": "json_schema",
        "schema": {
          "type": "object",
          "properties": {
            "samples": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "response": {"type": "string"},
                  "weight":   {"type": "number"}
                },
                "required": ["response", "weight"],
                "additionalProperties": false
              }
            }
          },
          "required": ["samples"],
          "additionalProperties": false
        }
      }
    },
    "messages": [{"role": "user", "content": "<verbalized prompt from step 1>"}]
  }'
```

Cache the system prompt if it is large and stable — add
`"cache_control": {"type": "ephemeral"}` to the last system text block.

## 3. Sample from the distribution

Parse `samples`, normalise weights in case they do not sum exactly to 1.0,
then draw one entry:

```python
import json, random

data   = json.loads(api_response_text)   # text block from response
items  = data["samples"]
total  = sum(s["weight"] for s in items)
probs  = [s["weight"] / total for s in items]
chosen = random.choices(items, weights=probs, k=1)[0]["response"]
print(chosen)
```

For batch synthetic-data generation, repeat step 2–3 `M` times; each call
independently samples a different region of the distribution.

## 4. Measure diversity (optional gate)

Compare verbalized-sampling outputs against standard outputs using
distinct-n-gram ratio.  Expect ≥1.5× improvement on creative tasks:

```python
from collections import Counter

def distinct_ngrams(texts, n=2):
    all_ng, uniq_ng = 0, set()
    for t in texts:
        toks = t.split()
        ngs  = [tuple(toks[i:i+n]) for i in range(len(toks)-n+1)]
        all_ng  += len(ngs)
        uniq_ng |= set(ngs)
    return len(uniq_ng) / max(all_ng, 1)

baseline  = distinct_ngrams(standard_outputs)
verbalized = distinct_ngrams(verbalized_outputs)
print(f"diversity ratio: {verbalized/baseline:.2f}x")   # target ≥ 1.5
```

From V-Sekai-fire/contract-multiplayer-fabric-skills, MIT.

More from V-Sekai-fire/contract-multiplayer-fabric-skills

Signals

Stars
0
Forks
0
Open issues
0
Last commit (this folder)
Apr 20, 2026 (6 months ago)

From GitHub (fetched Oct 24, 2026).

Details

License
MIT
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from V-Sekai-fire

Cite this page

verbalized-sampling skill. Agent Mart. https://agentmart.dev/skills/v-sekai-fire-verbalized-sampling (last updated 2026-10-24)