# Few-Shot उदाहरण — Prompt Engineering

Source: https://www.geekswithgeeks.com/hi/prompt-engineering/c-fewshot

> कुछ उदाहरणों से मॉडल को पैटर्न दिखाएँ।

## सिर्फ़ बताएँ नहीं, दिखाएँ

**Zero-shot** prompting सिर्फ़ निर्देश देती है। **Few-shot** prompting कुछ इनपुट-आउटपुट **उदाहरण** जोड़ती है ताकि मॉडल पैटर्न की नक़ल करे: label समूह, लहजा, format, किनारे के मामलों की सँभाल। अच्छे उदाहरण **प्रतिनिधि**, **विविध** (एक पेचीदा मामला शामिल करें), आपस में **संगत** और सही होते हैं, और अनजाने पक्षपात के बिना क्रमित (जैसे सारे "positive" पहले नहीं)। तीन से आठ उदाहरण आम हैं। उदाहरण हर call पर tokens ख़र्च करते हैं, इसलिए उन्हें छोटा रखें, और परखें कि हर एक वाक़ई मदद करता है। मॉडल उदाहरणों की अति-नक़ल कर सकते हैं, इसलिए ऐसे असामान्य ब्योरों से बचें जिनका दोहराव नहीं चाहिए।

## Few-shot prompt बनाना, चलाकर

मैंने यह सादा-Python (सिर्फ़ standard library) उदाहरण चलाया। Function निर्देश, तीन labelled उदाहरण और नया पाठ जोड़ती है, `Label:` पर समाप्त होती है ताकि मॉडल label पूरा करे।

```python
examples = [
    ("The delivery was fast and the box was perfect.", "positive"),
    ("It stopped working after two days.", "negative"),
    ("It arrived on Tuesday.", "neutral"),
]

def few_shot(text):
    lines = ["Classify the sentiment as positive, negative or neutral.", ""]
    for t, label in examples:
        lines += [f"Text: {t}", f"Label: {label}", ""]
    lines += [f"Text: {text}", "Label:"]
    return "\n".join(lines)

print(few_shot("The screen cracked on day one."))

```

Output:

```
Classify the sentiment as positive, negative or neutral.

Text: The delivery was fast and the box was perfect.
Label: positive

Text: It stopped working after two days.
Label: negative

Text: It arrived on Tuesday.
Label: neutral

Text: The screen cracked on day one.
Label:
```

## एक कठिन उदाहरण शामिल करें

"It arrived on Tuesday" को positive समझा जा सकता हो, तो neutral labelled उदाहरण दस आसान मामलों से बेहतर सीमा सिखाता है।

**Quiz:** Few-shot prompting क्या जोड़ती है?

- [ ] स्वचालित fine-tuning
- [ ] ज़्यादा मॉडल parameters
- [ ] तेज़ GPU
- [x] इनपुट-आउटपुट उदाहरण जो वांछित पैटर्न दिखाते हैं

*Answer:* इनपुट-आउटपुट उदाहरण जो वांछित पैटर्न दिखाते हैं. उदाहरण मॉडल को बिना पुनः प्रशिक्षण के format और labels समझने देते हैं।
