What is the difference between zero-shot and few-shot prompting, and when would you use each?
What the interviewer wants to hear
- Zero-shot gives only instructions; few-shot adds worked examples
- Examples show format, tone and edge cases better than rules
- Few-shot costs more tokens on every request
- Examples should be diverse and representative to avoid copying bias
- Measure both on an eval set rather than guessing
Model answer
Zero-shot prompting gives the model only instructions, like "classify this ticket as billing, technical or other". Few-shot prompting adds a handful of worked examples of input and correct output. I start zero-shot because strong models follow clear instructions well and it keeps prompts short and cheap. I add examples when the output format is unusual, when the boundary between categories is subtle, or when I need a specific tone, because examples often show these better than rules. The examples must be varied and representative; if they all have the same label or length, the model copies that pattern. Since examples add tokens to every call, I compare both versions on a small eval set and keep the cheaper one if quality is equal.
Can you answer it under time pressure?
Take a timed easy round and get scored on every answer.
More easy AI Engineer (LLM & Generative AI) questions
- Explain retrieval-augmented generation (RAG) to a new team member. Why do we use it?
- What are embeddings, and what can you build with them besides RAG?
- Why do LLMs hallucinate, and what simple steps reduce it in an application?
- How do tokens affect the cost and speed of an LLM application?
- What do temperature and top-p control, and how would you set them for different tasks?
- What is an LLM agent, and how is it different from a single LLM call?
- How does vector search work, and why is it useful for an AI application?
- Your app starts getting rate-limit errors from the LLM API. How do you handle them?
- How do you protect personal data when building a feature on a hosted LLM API?