Skip to main content

Menu

LEVEL 0
0/5 XP
HomeAboutTopicsPricingMy VaultStatsPractice TestsCertifications

Categories

🎓 Certifications
🤖 Artificial Intelligence
☁️ Cloud and Infrastructure
💾 Data and Databases
💼 Professional Skills
🎯 Programming and Development
🔒 Security and Networking
📚 Specialized Topics
CheatGrid
HomeAboutTopicsPricingMy VaultStatsPractice TestsCertifications
LVLEVEL 0
0/5 XP
GitHub
© 2026 CheatGrid™. All rights reserved.
Privacy PolicyTerms of UseAboutContact

In-context Learning Cheat Sheet

In-context Learning Cheat Sheet

Back to Generative AI
Updated 2026-05-28
Next Topic: Knowledge Distillation Cheat Sheet

In-context learning (ICL) allows large language models to adapt to new tasks by embedding demonstrations directly within the input prompt, eliminating the need for parameter updates or fine-tuning. This paradigm enables models to learn from examples at inference time, making it a cornerstone technique for prompt engineering and rapid task adaptation. Unlike traditional training, ICL leverages the model's pre-existing knowledge to generalize from a small number of contextual examples—and as context windows have expanded into the millions of tokens, the many-shot regime now approaches fine-tuning performance without any weight updates. The effectiveness of ICL depends critically on example selection, ordering, formatting, and reasoning structure—subtle variations can dramatically impact model performance, making prompt design as consequential as model architecture itself. Theoretically, ICL is understood as an implicit Bayesian inference process, where the model selects or approximates a task-solving function from its pre-training distribution given the provided demonstrations.

What This Cheat Sheet Covers

This topic spans 13 focused tables and 121 indexed concepts. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.

Table 1: Core ICL ApproachesTable 2: Example Selection StrategiesTable 3: Example Ordering and PositioningTable 4: Reasoning Enhancement TechniquesTable 5: Advanced Prompting PatternsTable 6: Context and Format ControlTable 7: Retrieval-Augmented ICLTable 8: Calibration and Bias MitigationTable 9: Context Engineering StrategiesTable 10: Evaluation and Quality ControlTable 11: Instruction Tuning vs. In-Context LearningTable 12: Multimodal ICLTable 13: Common Pitfalls and Best Practices

Table 1: Core ICL Approaches

The foundational shot-count spectrum of ICL—from no examples to thousands—determines the trade-off between annotation cost, prompt length, and task performance; knowing when each regime is appropriate is the starting point for any ICL practitioner.

TechniqueExampleDescription
Few-shot prompting
"Happy" → Positive
"Terrible" → Negative
"Excited" → Positive
"Amazing" →
• Includes 2–10 labeled examples in the prompt to guide the model's understanding of the task
• the standard ICL approach for most applications.
Zero-shot prompting
Classify: "I loved this movie!" → Sentiment:
• Direct task instruction without any demonstrations
• relies entirely on the model's pre-training knowledge and instruction-following capability.
One-shot prompting
Q: "What is 2+2?" A: "4"
Q: "What is 5+3?" A:
• Provides exactly one example to demonstrate the desired input-output pattern
• useful when task format is novel but the pattern is simple.
Many-shot prompting
Hundreds to thousands of examples within extended context windows (e.g., 100K+ tokens)
• Leverages extremely long context windows to provide dozens or hundreds of demonstrations
• approaches fine-tuning performance without weight updates and overrides pre-training biases
• gains plateau around 50–70 examples per class for classification; open-ended generation tasks see minimal improvement.

More in Generative AI

  • Hugging Face Transformers Cheat Sheet
  • Knowledge Distillation Cheat Sheet
  • Advanced RAG Patterns and Optimization Cheat Sheet
  • ColBERT and Late Interaction Retrieval Cheat Sheet
  • LlamaIndex Cheat Sheet
  • pgvector for Postgres Vector Search Cheat Sheet
View all 95 topics in Generative AI