Prompt Engineering Interview Questions
Prompt anatomy, few-shot design, structured output and prompt evaluation.
What makes a good prompt?
A clear role, a specific task, the context the model needs, the output format, and constraints. Each part removes a guess the model would otherwise make.
Key Points:
- Show an example of the output you want.
When should you use few-shot prompting?
When the task has a specific style, label set or format that is easier to show than describe. Use diverse, representative examples.
Key Points:
- Too many similar examples can bias the output.
How do you evaluate a prompt?
Build a small test set with expected outputs, run prompt versions against it, and score with exact-match, rubric or LLM-as-judge checks. Track regressions when you change the prompt.
Key Points:
- Version prompts like code.
What is a system prompt?
The system prompt is the set of instructions given to the model before the conversation, defining its role, rules, tone and output format. It applies to every turn, while user messages carry the individual requests.
Key Points:
- Put stable behaviour (persona, constraints, format) in the system prompt.
- It is guidance, not a security boundary — users can try to override it.
What is chain-of-thought prompting?
Chain-of-thought prompting asks the model to reason step by step before giving its final answer. Writing out intermediate steps improves accuracy on maths, logic and multi-step problems.
Key Points:
- Can be triggered with 'think step by step' or with worked examples.
- Adds tokens, latency and cost — skip it for simple lookups.
- Ask for the final answer in a separate, clearly marked section so it is easy to parse.
How do you get reliable structured output such as JSON?
Specify the exact schema, show an example, and ask for JSON only. Where available, use the provider's structured-output or tool-calling features, which constrain the response to your schema. Always validate the output in code and retry or repair on failure.
Key Points:
- Low temperature makes formatting more consistent.
- Libraries like Pydantic make validation simple in Python.
What is prompt chaining?
Prompt chaining breaks a complex task into a sequence of smaller prompts, where each step's output feeds the next — for example extract facts, then analyse them, then write the summary.
Key Points:
- Each step is simpler, more reliable and easier to debug.
- You can validate or branch between steps and use different models per step.
How do you reduce hallucinations through prompting?
Ground the model in supplied context and tell it to answer only from that context, give it explicit permission to say 'I don't know', ask it to quote or cite the supporting text, and keep temperature low for factual tasks.
Key Points:
- Prompting reduces hallucinations but cannot eliminate them.
- Combine with RAG and automated checks for anything important.
Does role prompting help?
Role prompting assigns the model a persona, such as 'You are a senior data engineer'. It helps set tone, vocabulary and the level of detail, but it does not give the model knowledge it lacks.
Key Points:
- Clear task instructions and examples usually matter more than the role.
- Most useful for style and audience, e.g. 'explain to a beginner'.
Why use delimiters or XML tags in prompts?
Delimiters such as triple quotes or tags like <document> and <instructions> clearly separate instructions from data. This helps the model know what to act on versus what to read, and makes long prompts easier to maintain.
Key Points:
- Reduces the chance of the model treating pasted content as instructions.
- Also makes it easy to ask for output inside a tag and parse it.
How do you handle long documents in a prompt?
Put the long document first and the question at the end, label it clearly, and ask the model to pull out relevant quotes before answering. If the document exceeds the context window, chunk it and use RAG or a map-reduce summarise-then-combine approach.
Key Points:
- Details in the middle of very long inputs are the easiest to miss.
- Only include the sections the task actually needs.
How do you version and manage prompts in production?
Treat prompts as code: store them in version control or a prompt registry, attach an evaluation set, and run regression tests before every change. Log which prompt version produced each response so issues can be traced and rolled back.
Key Points:
- Pin the model version too — a model upgrade can change prompt behaviour.
- Use A/B tests or shadow traffic for risky changes.
How do you write prompts that work across different models?
Keep instructions explicit and unambiguous, rely on clear structure rather than model-specific tricks, and specify the output format precisely. Then test the same prompt on an eval set for each model, because behaviour differs.
Key Points:
- Expect to keep small per-model adjustments.
- An abstraction layer in code makes swapping models easier.