Few-Shot Example Selector
Rank, diversify and pack demonstrations into a prompt budget — entirely offline.
Task query
1 line · 33 charsExample pool
4 pairs · jsonlSelected examples
3/4 · ≈74 tokens{"input":"How do I reset my password?","output":"Open Settings and choose Reset password."}
{"input":"Where can I see my invoices?","output":"Billing → Invoices lists every invoice."}
{"input":"How do I cancel my plan?","output":"Go to Billing → Plan and choose Cancel."}| # | Input | BM25 | Tokens | State |
|---|---|---|---|---|
| 3 | How do I cancel my plan? | 2.314 | ≈24 | selected |
| 2 | Where can I see my invoices? | 1.634 | ≈25 | selected |
| 1 | How do I reset my password? | 1.133 | ≈25 | selected |
| 4 | Why was I charged twice? | 0.112 | ≈32 | excluded |
≈74 of 200 tokens used; 126 left. Estimates use the chars/4 heuristic, not a tokenizer.
Details
Paste a query and a pool of input/output pairs; the selector scores every pair with BM25 over an inverted index, normalizes relevance, applies greedy MMR diversity, and packs the winners under a token budget. Scores, matched terms and per-example estimates stay visible so you can audit why each demonstration was chosen. Everything runs locally: no embeddings, network calls or persisted prompt data.
More examples
JSONL pool
Each line becomes a candidate demonstration scored against the task query.
Separator format
Blocks separated by --- are parsed as input/output pairs when JSON is inconvenient.
Prompt block
The prompt serializer numbers examples and leaves a final query slot for the model.
Examples
JSONL pool
{"input":"How do I reset my password?","output":"Open Settings and choose Reset password."}
{"input":"Where are my invoices?","output":"Billing → Invoices."}Each line becomes a candidate demonstration scored against the task query.
Separator format
Summarize the release
Short summary text
---
Translate the welcome email
Translated email textBlocks separated by --- are parsed as input/output pairs when JSON is inconvenient.
Prompt block
Example 1:
Input: How do I reset my password?
Output: Open Settings and choose Reset password.
Input: <your query>
Output:The prompt serializer numbers examples and leaves a final query slot for the model.
About this tool
Paste a query and a pool of input/output pairs; the selector scores every pair with BM25 over an inverted index, normalizes relevance, applies greedy MMR diversity, and packs the winners under a token budget. Scores, matched terms and per-example estimates stay visible so you can audit why each demonstration was chosen. Everything runs locally: no embeddings, network calls or persisted prompt data.
What this tool does not do
- Processes only the inputs provided in this session without connecting to external accounts or background servers.
- Runs entirely in the current browser tab; nothing is synced across devices or backed up to a server.
How to use this tool
Paste candidate example pairs
Provide input/output demonstrations as JSONL or --- separated blocks.
Enter query, MMR, and token cap
Tune diversity vs BM25 relevance and set your maximum prompt token budget.
Copy packed shots
Export selected demonstrations as formatted prompt text or JSONL.
Use cases
JSONL pool
Each line becomes a candidate demonstration scored against the task query.
Separator format
Blocks separated by --- are parsed as input/output pairs when JSON is inconvenient.
Prompt block
The prompt serializer numbers examples and leaves a final query slot for the model.
Common mistakes
Mistake:What does the MMR (Maximal Marginal Relevance) slider control?
Fix:Pure relevance can pick three nearly identical examples; MMR penalizes candidates that overlap heavily with already-selected shots, balancing query relevance against coverage diversity.
Mistake:How accurate is the token budget cap?
Fix:Packing uses a fast deterministic character-to-token heuristic so you stay comfortably within prompt budgets offline; leave a small margin if your target model uses dense non-Latin scripts.
Frequently asked questions
How does BM25 select few-shot examples without calling an embedding API?
It tokenizes your candidate pool into an in-memory inverted index and scores term overlap weighted by inverse document frequency and length normalization, finding lexically similar demonstrations in milliseconds.
What does the MMR (Maximal Marginal Relevance) slider control?
Pure relevance can pick three nearly identical examples; MMR penalizes candidates that overlap heavily with already-selected shots, balancing query relevance against coverage diversity.
How accurate is the token budget cap?
Packing uses a fast deterministic character-to-token heuristic so you stay comfortably within prompt budgets offline; leave a small margin if your target model uses dense non-Latin scripts.
Are my prompt pools uploaded or cached on a server?
No. Indexing, ranking, and JSONL/prompt formatting run locally in your browser.
Related tools
Agent Tool Flowchart Builder
Design agentic tool-call DAGs with decision branches and bounded loops. Validates reachability, cycle handling, and emits clean Mermaid flowcharts — fully in your browser.
AI Agent Memory & Buffer Simulator
Compare sliding window, summary buffer, and vector memory strategies
AI API Client SDK Generator
Generate typed API client SDK files from OpenAPI specifications or cURL requests
AI Code Explainer
Explain code snippets with grounded cloud AI
AI Code Security Auditor
Scan source code for high-confidence OWASP Top 10 vulnerabilities
AI Code Translator
Translate code into idiomatic implementations in another language