← Back to blog

RAG and Few-Shot — Context and Examples

RAG 🟡

Need: The model needs up-to-date or specialist knowledge that is not in its training data.

Explanation: Retrieval-Augmented Generation — you inject retrieved documents as context and instruct the model not to invent anything beyond them.

Prompt format:

“Use ONLY the following information: [context]. Answer: [question]. If you don’t know — write ‘I don’t know’.”

QA usage example

“Based on the following API documentation: [docs excerpt] — write a REST Assured test verifying the /users endpoint. Do not invent parameters that are not in the documentation.”

When to use RAG?

When AI needs to work with your data — API documentation, requirements, specifications. The key sentence: “Do not invent anything beyond the provided context.”


Few-Shot Prompting 🟢

Need: The model does not understand the expected format — you give it examples instead of explaining.

Explanation: You provide 2-3 input→output pairs as a pattern. The model imitates the pattern. A fundamental technique for ensuring repeatability.

Prompt format:

“Example 1: [input] → [output]. Example 2: [input] → [output]. Now: [your question]“

QA usage example

“‘Login fails with 500’ → Critical, Auth. ‘Typo in footer’ → Low, UI. Now: ‘Payment timeout after 30s’ → ?”

When to use Few-Shot?

When you need a repeatable format — bug classification, tagging, generating test cases in a specific template. 2-3 examples are enough.


In the next post: ARC, ICE, and TDS — three quick frameworks for everyday work.