AI-Prompt-Development/zero-shot-few-shot-examples
关于
Practical zero-shot and few-shot prompting examples across 20+ task types
人工智能与机器学习实测星标增长
- 24小时
- 0
- 7天
- 正在收集历史
- 15天
- 正在收集历史
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文Zero-Shot and Few-Shot Examples
Practical examples of zero-shot and few-shot prompting across 20+ task types.
Zero-Shot vs Few-Shot
| Approach | Examples Provided | Best For | Token Cost |
|---|---|---|---|
| Zero-shot | 0 | Simple tasks, common formats | Low |
| One-shot | 1 | Unusual formats, style transfer | Medium |
| Few-shot (2-5) | 2-5 | Classification, extraction | Medium-High |
| Many-shot (5+) | 5+ | Complex patterns, edge cases | High |
Rule of thumb: Start zero-shot. Add examples only if output quality is insufficient.
Zero-Shot Examples
Classification
Classify the following support ticket as: Billing / Technical / Account / General
Ticket: "I was charged twice for my subscription this month."
Category:
Entity Extraction
Extract all person names, organizations, and dates from the following text.
Format as JSON.
Text: "Apple CEO Tim Cook announced on March 15 that the company would partner with OpenAI."
Translation
Translate to Spanish:
"The quarterly report shows a 23% increase in revenue compared to last year."
Sentiment Analysis
Analyze the sentiment of this review. Output: Positive / Neutral / Negative / Mixed
Review: "The product looks great but shipping took 3 weeks and the box was damaged."
Summarization
Summarize in 2 sentences:
{long_text}
One-Shot Examples
Custom Format Output
Convert the input to the output format shown in the example.
EXAMPLE INPUT:
Name: John Smith
Email: [email protected]
Phone: +1-555-0123
EXAMPLE OUTPUT:
{
"contact": {
"name": "John Smith",
"email": "[email protected]",
"phone": "+15550123"
}
}
INPUT:
Name: {name}
Email: {email}
Phone: {phone}
OUTPUT:
Writing Style Transfer
Rewrite the text to match the style of the example.
ORIGINAL STYLE:
"The implementation of the aforementioned functionality necessitates careful consideration of the architectural constraints."
TARGET STYLE (simple, direct):
"Building this feature requires thinking carefully about the architecture."
NOW REWRITE:
{text_to_rewrite}
Few-Shot Examples
Sentiment Classification (3-shot)
Classify sentiment as Positive, Negative, or Neutral.
Text: "I love how fast the app is!" → Positive
Text: "It crashed twice today." → Negative
Text: "The update changed the UI." → Neutral
Text: "Best customer support I've ever experienced!" → Positive
Text: {new_text} →
Named Entity Recognition (3-shot)
Extract entities. Format: [ENTITY_TYPE: entity_text]
Text: "Elon Musk founded SpaceX in 2002."
Entities: [PERSON: Elon Musk] [ORGANIZATION: SpaceX] [DATE: 2002]
Text: "Apple released the iPhone 15 in California."
Entities: [ORGANIZATION: Apple] [PRODUCT: iPhone 15] [LOCATION: California]
Text: "Marie Curie won the Nobel Prize in 1903."
Entities: [PERSON: Marie Curie] [AWARD: Nobel Prize] [DATE: 1903]
Text: {input_text}
Entities:
Code Generation (2-shot)
Write a Python function based on the description.
Description: Return the larger of two numbers.
Code:
def max_of_two(a, b):
return a if a > b else b
Description: Check if a string is a palindrome.
Code:
def is_palindrome(s):
s = s.lower().replace(" ", "")
return s == s[::-1]
Description: {description}
Code:
When Few-Shot Fails
Problem: Examples leak into the output. Fix: Use clear delimiters between examples and the actual input.
Problem: Model copies example format too rigidly. Fix: Vary the examples slightly to show the pattern, not just one format.
Problem: Too many examples slow the model down. Fix: 3-5 examples is usually optimal. More rarely helps.
Problem: Examples don't cover edge cases. Fix: Include at least one edge case example (empty input, unusual format, etc.).
Multilingual
TR: Sıfır atış ve birkaç atış, örnek sayısına göre farklı LLM yönlendirme teknikleridir. DE: Zero-Shot und Few-Shot sind Prompting-Techniken, die sich nach der Anzahl der Beispiele unterscheiden. FR: Zero-shot et few-shot sont des techniques de prompting basées sur le nombre d'exemples fournis. ES: Zero-shot y few-shot son técnicas de prompting que difieren en el número de ejemplos proporcionados. ZH: 零样本和少样本是根据提供示例数量区分的提示技术。 RU: Zero-shot и few-shot — техники промптинга, различающиеся количеством примеров. JA: ゼロショットとフューショットは、提供される例の数で区別されるプロンプト技術です。 KO: 제로샷과 퓨샷은 제공되는 예제 수에 따라 구분되는 프롬프팅 기술입니다.
License
MIT — Free to use, modify, and distribute.
Keywords
zero-shot prompting few-shot prompting one-shot learning in-context learning
prompt examples LLM few-shot zero-shot classification few-shot NLP
prompt template examples AI task examples GPT few-shot Claude zero-shot
sıfır atış öğrenme Zero-Shot Lernen apprentissage zero-shot aprendizaje zero-shot
零样本学习 обучение без примеров ゼロショット学習 제로샷 학습
探索相关项目
加载中…