Few-shot nedir, neden işe yarar?
Few-shot prompting LLM'e görev örneklerini prompt içinde göstererek davranışı yönlendirme tekniği. Zero-shot'tan (örnek vermeden) daha tutarlı, fine-tuning'den (model retraining) daha esnek. AIOR projelerinde few-shot, output format kontrolü ve domain-specific terminology için sıkça kullanılan teknik.Kaç örnek yeterli?
Pratik kural: 2-5 örnek. Daha azı (1-2) format belirler; daha fazlası (5+) tutarlılık artırır ama token maliyeti yükselir, marginal fayda azalır. AIOR projelerinde 3 örnek ortalama; complex format'lar için 5'e çıkıyoruz.Örnek seçim kriterleri
Yanlış örnekler modeli yanlış yönlendirir. AIOR'ın örnek seçim disiplini:- Diversity — örnekler farklı senaryoları kapsamalı (basit, kompleks, edge case).
- Representative — gerçek production input'larına benzer.
- Format consistency — output yapısı her örnekte aynı.
- Negative example yok — "böyle yapma" örnekleri model'i karıştırır.
- Recent and relevant — eski ya da konu dışı örnekler kullanılmaz.
Sıralama önemli mi?
Evet. LLM'ler son örnekleri daha güçlü hatırlar (recency bias). AIOR'ın strategy'si: kompleks ya da kritik örnek listenin sonunda. Ancak bazı modellerde middle örnekler daha az etkili (lost-in-the-middle); test ile doğrulanmalı.Few-shot format şablonu
Standart yapı:
Code:
Aşağıdaki örnekleri inceleyin, aynı şekilde devam edin:
Input: "Şifremi unuttum"
Output: {"intent": "password_reset", "urgency": "medium"}
Input: "Sunucum çöktü acil yardım"
Output: {"intent": "incident", "urgency": "high"}
Input: "Hosting paketleri hakkında bilgi"
Output: {"intent": "sales_inquiry", "urgency": "low"}
Input: "[kullanıcı sorgusu buraya]"
Output:
Modelin "Output:" sonrası tamamlaması beklenir. AIOR projelerinde bu pattern stable sonuç veriyor.
Dynamic few-shot — RAG ile birleşimi
Statik örnekler tüm input'lar için optimal olmayabilir. Dynamic few-shot pattern'i: kullanıcı sorgusu geldiğinde, semantically benzer geçmiş örnekleri vector database'den çeker, prompt'a inject eder.Pratik akış:
- Kullanıcı sorgusu vektörlendir.
- Vector DB'den en benzer 3-5 example sorgu+ideal-output bul.
- Bu örnekleri few-shot olarak prompt'a ekle.
- LLM'i çağır.
AIOR'da bu pattern'i complex domain'lerde (hukuki sorgular, tıbbi support) kullanıyoruz. Pgvector veya Pinecone vector store olarak.
Chain-of-Thought ile birlikte
Few-shot + Chain-of-Thought (CoT) reasoning içeren görevlerde güçlü. Örneklerde sadece input/output değil, ara reasoning adımları da göster:
Code:
Input: "Üç ürün 10$, 15$, 25$. Toplam KDV %20 dahil ne kadar?"
Reasoning: "Toplam vergi öncesi: 10+15+25 = 50. KDV: 50 × 0.20 = 10. Toplam: 60."
Output: 60$
Bu pattern matematik, mantık ve multi-step task'larda doğruluğu önemli ölçüde artırıyor.
Few-shot vs Fine-tuning
Ne zaman hangisi?- Few-shot — task değişken, örnekler güncellenebilir olmalı, prototip aşaması.
- Fine-tuning — task sabit, yüksek throughput, latency önemli (system prompt kısalır), token maliyeti azaltılmak isteniyor.
AIOR olarak production'da yüksek volume ve sabit task ise fine-tuning değerlendiriyoruz; daha esnek senaryolarda few-shot'ta kalıyoruz.
Test ve doğrulama
Few-shot prompt değişikliği A/B test edilmeli. AIOR'da prompt versiyonları gold-set ile değerlendiriyoruz — 50-100 manuel onaylanmış input/output pair. Yeni prompt eski'sine göre yüzde kaç doğru çalışıyor?Token maliyeti optimizasyonu
Few-shot örnekleri her API call'da gönderilir; modern LLM provider'larında prompt caching ile bu maliyet düşürülebilir. AIOR olarak Anthropic Claude'un cache özelliği ile system prompt + few-shot örnekleri cache'liyoruz, %50-90 cost reduction sağlıyor.Yaygın hatalar
- Örneklerde inconsistent format — model hangi format'ı izleyeceğini bilmez.
- Örnek sayısının fazla olması — context bloat, maliyet artar.
- Edge case'lerin olmaması — model normal input'larda iyi, edge'lerde kötü.
- Örneklerin outdated olması — domain değişti ama örnekler güncellenmedi.
- Negation içeren örnekler — model confusing sinyal alır.
Sonuç
Few-shot prompting 2026'da LLM uygulamalarının üretkenlik aracı. Doğru örnek seçimi, dinamik retrieval kombinasyonu ve disiplinli test ile model davranışı tutarlı hâle gelir. AIOR olarak müşteri LLM projelerinde few-shot pattern'leri standart paket olarak teslim ediyoruz. Sizin tarafınızda dynamic few-shot kullanıyor musunuz, yoksa hâlâ statik örnek mi?What is few-shot and why does it work?
Few-shot prompting is a technique to guide LLM behaviour by showing task examples inside the prompt. More consistent than zero-shot (no examples), more flexible than fine-tuning (model retraining). On AIOR projects, few-shot is frequently used for output format control and domain-specific terminology.How many examples are enough?
Practical rule: 2-5 examples. Fewer (1-2) sets format; more (5+) increases consistency but token cost rises with diminishing returns. On AIOR projects, 3 examples is average; we go to 5 for complex formats.Example selection criteria
Wrong examples mislead the model. AIOR's discipline:- Diversity — examples cover different scenarios (simple, complex, edge case).
- Representative — similar to real production inputs.
- Format consistency — output structure identical across examples.
- No negative examples — "don't do this" examples confuse the model.
- Recent and relevant — outdated or off-topic examples aren't used.
Does order matter?
Yes. LLMs remember recent examples more strongly (recency bias). AIOR's strategy: complex or critical examples at the end of the list. But some models have a "lost-in-the-middle" effect; verify with tests.Few-shot format template
Standard structure:
Code:
Examine the following examples and continue in the same way:
Input: "I forgot my password"
Output: {"intent": "password_reset", "urgency": "medium"}
Input: "My server is down, urgent help"
Output: {"intent": "incident", "urgency": "high"}
Input: "Tell me about hosting packages"
Output: {"intent": "sales_inquiry", "urgency": "low"}
Input: "[user query here]"
Output:
The model is expected to complete after "Output:". This pattern gives stable results on AIOR projects.
Dynamic few-shot — combined with RAG
Static examples may not be optimal for all inputs. Dynamic few-shot pattern: when a user query arrives, semantically similar past examples are fetched from a vector database and injected into the prompt.Practical flow:
- Vectorise the user query.
- Retrieve the 3-5 most similar example query+ideal-output pairs from the vector DB.
- Inject these examples as few-shot into the prompt.
- Call the LLM.
We use this pattern in complex domains (legal queries, medical support). Pgvector or Pinecone as vector store.
Combined with Chain-of-Thought
Few-shot + Chain-of-Thought (CoT) is powerful on reasoning tasks. Show intermediate reasoning steps in examples, not just input/output:
Code:
Input: "Three products are $10, $15, $25. What's the total including 20% VAT?"
Reasoning: "Subtotal: 10+15+25 = 50. VAT: 50 × 0.20 = 10. Total: 60."
Output: $60
This pattern significantly improves accuracy on math, logic, and multi-step tasks.
Few-shot vs Fine-tuning
When to use which?- Few-shot — variable tasks, examples need to be updatable, prototype stage.
- Fine-tuning — stable task, high throughput, latency matters (system prompt shortens), token cost needs to drop.
For production with high volume and stable tasks, AIOR evaluates fine-tuning; for more flexible scenarios, we stay on few-shot.
Test and validation
Few-shot prompt changes should be A/B tested. AIOR evaluates prompt versions with a gold set — 50-100 manually approved input/output pairs. What percentage of the new prompt scores right vs the old?Token cost optimisation
Few-shot examples are sent on every API call; modern LLM providers' prompt caching can reduce this cost. We use Anthropic Claude's cache feature for system prompt + few-shot examples, achieving 50-90% cost reduction.Common mistakes
- Inconsistent format across examples — the model can't tell which format to follow.
- Too many examples — context bloat, increased cost.
- No edge cases — model good on normal inputs, bad on edges.
- Outdated examples — domain changed but examples didn't.
- Examples with negation — confusing signal to the model.