Skip to content
Preptima

Generative AI & Large Language Models interview questions

Prompting and structured output, context and tokens, adaptation, evaluation, inference economics, injection defence, and running LLM features in production.

21 published across 7 topics.

Generative AI and LLM fundamentals57 short answers on one page, for revising rather than studying.

Prompt design that survives a model upgrade, schema-constrained output, few-shot choices, and getting parseable results without a retry loop.

mediumConceptScenario

How do you write prompts that survive a model upgrade?

Pin the model version, keep the prompt to stable intent and a schema, and record every model-specific workaround as dated, deletable debt. The durable artefacts are the output schema and the eval set - they are what tells you whether the new model is better before you ship it.

4 minmid, senior, staff
mediumConceptDesign

What belongs in the system prompt, and what belongs in the user turn?

The system prompt holds what is identical on every request - role, policy, output contract, tool schemas, examples. Anything varying by user or request, retrieved documents included, belongs in the turns below, to keep the cached prefix stable and untrusted text away from system authority.

4 minmid, senior, staff
All 3 in Prompting & Structured Output

Tokens versus characters, context-window budgeting, truncation and compaction strategies, prompt caching, and how long context degrades.

hardDesignScenario

How would you budget the context window for a chat feature backed by retrieval?

Subtract the answer reservation and the fixed prompt first, give retrieval a token allowance rather than a passage count, and let conversation history have what remains under an explicit eviction policy - because history is the only term that grows every turn while everything else stays flat.

5 minmid, senior, staff
mediumScenarioDesign

Before we build this, how do you estimate what the LLM feature will cost to run?

Write down requests per day, input tokens per request and expected output tokens, multiply by the provider's per-million rates, then test each assumption. Output tokens cost several times input, retries and agent loops multiply the input, and a cached prefix rewrites the arithmetic.

5 minmid, senior, staff
All 3 in Context & Tokenisation

When to fine-tune rather than prompt or retrieve, LoRA and parameter-efficient methods, dataset curation, and evaluating whether it helped.

hardScenarioDesign

You have fine-tuned a model for a task. How do you prove it helped?

Compare it against a genuinely strong prompted baseline on a held-out set drawn from real traffic, using the task metric your product cares about, and run a broad regression set alongside to catch capability lost elsewhere. Falling training loss is evidence that training worked, not that the product improved.

5 minmid, senior, staff
mediumConceptDesign

How do you decide between prompting, retrieval and fine-tuning?

Ask what is missing. If the answer changes when your documents change, you need retrieval; if the model knows enough but will not behave, format or specialise the way you need, you fine-tune. Prompting comes first either way because it costs an afternoon and tells you which of the other two you actually need.

5 minmid, senior, staff
All 3 in Fine-tuning & Adaptation

Building an offline eval set, LLM-as-judge and its failure modes, regression suites for prompts, and measuring hallucination honestly.

All 3 in Evaluation & Guardrails

Token economics, streaming and time-to-first-token, batching and KV cache, quantisation trade-offs, and routing between models.

hardDesignScenario

Do you use one large model, or a smaller model with retrieval? How do you decide?

Decide from the task. For grounded work over your own corpus, quality is set by what reaches the context, so retrieval dominates model size and a smaller model usually suffices. Keep the larger model for long multi-step reasoning, and treat routing as a second system to evaluate and monitor.

4 minmid, senior, staff
All 3 in Inference, Cost & Latency

Indirect prompt injection, data exfiltration through tools, sandboxing an agent's capabilities, PII handling, and what a guardrail cannot do.

mediumConceptDesignScenario

How do you handle personal data in prompts, logs and traces for an LLM feature?

Decide what may cross the provider boundary and redact before it does, checking the provider's retention and training-use terms rather than assuming them. Then treat the debugging trace as a second copy of user data, with its own retention, access control and deletion obligations.

5 minmid, senior, staff
All 3 in Safety & Prompt Injection

Versioning prompts as artefacts, canarying a model change, tracing and cost observability, and surviving a provider deprecation.

mediumConceptDesign

How do you ship a change to a production prompt safely?

Treat the prompt as a versioned artefact under review, run your eval set in CI against a pinned model version, canary on a slice of traffic with the version recorded per request, and keep rollback a config change rather than a deploy. Pinning is what makes a regression attributable to your edit.

4 minmid, senior, staff
mediumConceptDesign

What do you instrument and alert on for an LLM feature running in production?

Trace every request with prompt and model versions, token counts and cost, then add sampled groundedness grading, refusal and retry rates, validation failures and implicit user signals. Alert on countable rates, because an averaged quality score moves too little and too late to page anyone.

5 minmid, senior, staff
All 3 in LLMOps & Deployment