PrepStack › AI › LLMOps & Evaluation
LLMOps & Evaluation interview cheat sheet
Evals, observability, guardrails, latency, cost, reliability and serving
LLMOps interviews check whether you can take an LLM feature from a demo to a reliable, measurable, affordable product. Expect questions on how you evaluate quality (golden sets, LLM-as-a-judge, CI regression gates), how you trace and monitor production, how you defend against prompt injection and PII leaks, and how you cut latency and cost with caching, routing and self-hosting. The Python demos use only the standard library and fake models, so you can see the mechanics without API keys. Read the 15-minute revision first, then switch to Quiz mode.
15-minute revision
- LLMOps = MLOps adapted to foundation models: you mostly *use* a model through prompts, RAG and tools, so the work shifts from training pipelines to evals, prompt versioning, tracing, guardrails, cost and latency.
- Evaluate offline (golden dataset before release, run in CI) and online (sampled production traffic, user feedback, A/B tests). You need both.
- Reference-based metrics compare to a known answer (exact match, F1, semantic similarity). Reference-free metrics judge the output alone or against the context (faithfulness, toxicity, relevance).
- LLM-as-a-judge scales grading but has biases: position, verbosity, self-preference. Mitigate with clear rubrics, swapping order, low temperature, a different judge model and checking agreement with humans.
- Pointwise = score one answer on a scale. Pairwise = pick the better of two. Pairwise is more stable for comparing versions; pointwise gives absolute numbers to track and gate on.
- RAG quality splits into retrieval (context precision/recall) and generation (faithfulness to context, answer relevance). A faithful answer can still be wrong if retrieval was wrong.
- Latency: TTFT (time to first token) drives perceived speed, TPOT (time per output token) drives total time. Track p50/p95/p99, never only the mean.
- Trace every request: prompt version, model, tokens, cost, latency, retrieved docs, tool calls. OpenTelemetry GenAI conventions (
gen_ai.*attributes) standardise this; Langfuse, Phoenix and LangSmith store and visualise it. - Treat prompts like code: versioned, immutable, reviewed, evaluated, labelled (
production/staging) and rolled back by moving a label. - Guardrails check input (injection, PII, off-topic) and output (schema, toxicity, PII, groundedness). OWASP LLM01:2025 is prompt injection; there is no complete fix, so limit what the model can do.
- Caching: exact (hash of the prompt), semantic (embedding similarity over a threshold, risk of wrong hits) and provider prompt caching (reuses the processed shared prefix, cheaper and faster input tokens).
- Cost = input tokens × price + output tokens × price (output is usually several times pricier). Cut it with smaller models, routing, caching, shorter prompts,
max_tokenslimits and batch APIs. - Reliability: timeouts, retries with exponential backoff + jitter only on transient errors (429, 5xx, timeouts), fallback models, circuit breakers, and a graceful degraded answer.
- A gateway (e.g. LiteLLM) gives one API over many providers plus keys, budgets, rate limits, fallbacks and logging.
- Self-hosting: vLLM (PagedAttention + continuous batching), Ollama (easy local), TGI (now in maintenance mode). Batching raises throughput but can hurt per-request latency.
- EU AI Act: in force since Aug 2024; prohibitions from Feb 2025, general-purpose AI model duties from Aug 2025, transparency (Article 50) duties from Aug 2026; most high-risk rules were pushed to Dec 2027 / Aug 2028.
Foundations
MLOps vs LLMOps
LLMOps keeps the MLOps discipline but moves the focus from training models to prompting, evaluating and operating someone else's model.
- Classic MLOps: collect labelled data, train, validate on a held-out set with clear metrics (accuracy, AUC), deploy, watch for drift, retrain.
- LLMOps: usually start from a pre-trained foundation model via API or self-hosted weights. The 'model' you own is the prompt + retrieval + tools + guardrails + config.
- Outputs are open-ended text, so evaluation is hard: there may be many correct answers, and metrics need judges or humans.
- New concerns: token cost per request, latency of long generations, prompt injection, hallucination, provider rate limits and model deprecations.
- Change is cheap and frequent (edit a prompt), so regression testing of prompts matters as much as unit tests for code.
- Fine-tuning (often LoRA-style adapters) is one tool, not the default. Most teams try prompting and RAG first.
Interview questions
- What is LLMOps and how is it different from MLOps?
- What do you version in an LLM application?
- Why is evaluation harder for LLMs than for a classifier?
The LLM app lifecycle
Design, build, evaluate, deploy, monitor and improve, with production data feeding back into the eval set.
- Design: define the task, success criteria and failure cases. Write 20–50 example inputs with expected behaviour before writing prompts.
- Develop: pick a model, write the prompt, add RAG or tools, add guardrails. Iterate in a playground against the examples.
- Evaluate offline: run the golden dataset, compute metrics, compare with the baseline. Gate the release in CI.
- Deploy safely: feature flags, shadow traffic, canary or A/B rollout. Keep the previous prompt version one click away.
- Monitor online: traces, latency, cost, error rates, guardrail triggers, user feedback, online judge scores on sampled traffic.
- Improve: turn bad production traces into new golden examples, fix, re-evaluate. This data flywheel is the heart of LLMOps.
Interview questions
- Walk me through how you would ship an LLM feature to production.
- What is the 'data flywheel' in LLM apps?
- Shadow deployment vs canary release?
Core metrics: quality, latency, cost
Track quality (accuracy, faithfulness, relevance, safety), latency (TTFT, TPOT, p95) and cost per request together.
- Quality: task accuracy, faithfulness (claims supported by the given context), answer relevance (does it address the question), format validity, toxicity/safety, refusal rate.
- TTFT (time to first token): queueing + prompt processing (prefill). Long prompts raise it. It is what users feel with streaming.
- TPOT (time per output token, also called inter-token latency): decode speed. Total latency ≈ TTFT + TPOT × (output tokens − 1).
- Report percentiles (p50, p95, p99). LLM latency has a long tail; the mean hides it.
- Cost per request = input tokens × input price + output tokens × output price (+ tool and retrieval costs). Also track cost per successful task.
- Throughput: requests or tokens per second, important when self-hosting.
Interview questions
- What is TTFT vs TPOT and which matters more?
- Why report p95 latency instead of the average?
- Which metrics would you put on an LLM feature dashboard?
Evaluation
Evaluation basics: offline, online, golden sets
Offline evals on a golden dataset gate releases; online evals on real traffic catch what the dataset missed.
- A golden dataset is a curated set of inputs with expected outputs or grading notes. Cover common cases, edge cases, adversarial inputs and past bugs.
- Offline evaluation runs the dataset before release (locally and in CI). It is repeatable and cheap to compare versions.
- Online evaluation scores live traffic: user feedback, implicit signals (copy, retry, abandon), sampled LLM-judge scores, A/B tests.
- Reference-based metrics need a gold answer: exact match, token F1, BLEU/ROUGE, embedding similarity, judge 'is this equivalent to the reference'.
- Reference-free metrics need no gold answer: faithfulness to context, relevance to the question, toxicity, format/schema validity. They work on production traffic.
- Prefer deterministic checks first (JSON parses, contains required field, regex, length). Use judges only for what code cannot check.
Interview questions
- How do you build a golden dataset when you have no data yet?
- Reference-based vs reference-free evaluation?
- Offline evals pass but users complain. What happened?
LLM-as-a-judge
Use a strong model with a clear rubric to grade outputs, then control its known biases and validate it against humans.
- Pointwise: grade one output on a scale or pass/fail against a rubric. Gives absolute numbers you can track and gate on.
- Pairwise: show two outputs, ask which is better. More consistent for comparing two versions; used by arena-style leaderboards.
- Good judge prompts: one criterion per judge, explicit rubric with examples per score, ask for brief reasoning before the score, structured output (JSON), temperature 0.
- Known biases: position bias (prefers first or second slot), verbosity bias (prefers longer), self-preference (prefers its own model family), sensitivity to formatting and confident tone.
- Mitigations: swap order and count disagreement as a tie, length-control instructions, use a different model family as judge, binary or small scales (1–5 at most), few-shot calibration examples.
- Validate the judge: label 50–200 examples by hand and measure agreement (accuracy, Cohen's kappa). Re-check when you change the judge model.
Interview questions
- What biases does LLM-as-a-judge have and how do you reduce them?
- Pointwise or pairwise: which would you use?
- How do you know your LLM judge is any good?
- Why ask the judge for reasoning before the score?
Human eval and regression testing in CI
Humans define quality and calibrate judges; CI runs the eval suite on every change and blocks regressions.
- Human evaluation is the ground truth for subjective quality. Use clear guidelines, several raters on a sample, and measure inter-rater agreement.
- Human time is expensive, so use it to label golden data, calibrate judges and review edge cases, not to grade every run.
- Regression testing: every prompt, model or retrieval change runs the eval suite. Compare to the baseline of the current production version, not to an absolute ideal.
- Gate on thresholds with tolerance (LLMs are non-deterministic). Run several samples or temperature 0 for stability.
- Keep CI fast and cheap: a small smoke set on every pull request, the full suite nightly or before release.
- Tools like promptfoo and DeepEval are designed to run in CI and fail the build on regressions.
Interview questions
- How do you add LLM evals to CI/CD?
- LLM outputs are non-deterministic. How do you keep tests stable?
- When do you still need human evaluation?
RAG and agent evaluation
Score retrieval and generation separately: context precision/recall for the retriever, faithfulness and relevance for the answer.
- Context precision: how much of the retrieved context is relevant (and ranked high). Low = noisy prompts, higher cost, confused model.
- Context recall: did retrieval find everything needed to answer? Needs a reference answer. Low = the model cannot answer correctly however good it is.
- Faithfulness (groundedness): split the answer into claims and check each is supported by the context. Low = hallucination.
- Answer/response relevancy: does the answer address the question, regardless of truth?
- Agents: also check tool-call accuracy (right tool, right arguments), task/goal completion, number of steps and cost per task.
- RAGAS implements these metrics (context precision/recall, faithfulness, response relevancy, tool-call accuracy and more), mostly with an LLM doing the claim checks.
Interview questions
- How would you evaluate a RAG system?
- Faithfulness vs answer relevance vs correctness?
- How do you evaluate an agent that calls tools?
Eval tooling landscape
Pick a code-first test runner for CI and a platform for datasets, traces and experiment comparison; many teams use both.
- promptfoo: open-source CLI, YAML test cases, many assertion types (contains, regex,
llm-rubric, similarity), side-by-side prompt/model comparison, also does red-teaming. - DeepEval: open-source, pytest-style;
LLMTestCase+ metrics such as answer relevancy, faithfulness, hallucination, G-Eval; run withdeepeval test run. - RAGAS: open-source library focused on RAG and agent metrics; can also generate synthetic test sets.
- LangSmith (LangChain): hosted tracing, datasets, experiments, annotation queues and online evaluators; works with or without LangChain.
- Braintrust: hosted eval and observability platform; experiments with scorers (its open-source
autoevalslibrary), prompt playground, logging. - OpenAI Evals: an open-source framework/registry of evals, plus an Evals feature in the OpenAI platform for grading model outputs on your datasets.
Interview questions
- Which eval tools have you used and how would you choose?
- What is G-Eval?
- Can you trust off-the-shelf metrics like 'faithfulness' out of the box?
Observability & Lifecycle
Observability and tracing
Trace every LLM call and step with prompts, outputs, tokens, cost and latency, using OpenTelemetry GenAI conventions where possible.
- A trace is one user request; spans are its steps: guardrails, retrieval, each LLM call, each tool call. Nested spans show where time and money go.
- Record per LLM span: model, prompt version, params, input/output tokens, cost, latency (TTFT and total), finish reason, errors.
- OpenTelemetry GenAI semantic conventions standardise names: e.g.
gen_ai.operation.name,gen_ai.request.model,gen_ai.usage.input_tokens,gen_ai.usage.output_tokens, plus metrics such asgen_ai.client.token.usageandgen_ai.client.operation.duration. They are still marked experimental (development). - Prompt and completion content is sensitive and large, so capturing it is usually opt-in. Redact PII before export.
- Langfuse (open source, self-hostable): tracing, prompt management, evals, datasets. Arize Phoenix (open source): tracing and evals built on OpenTelemetry via OpenInference instrumentation. LangSmith: hosted equivalent from LangChain.
- Attach user feedback and online eval scores to the trace id so you can filter 'bad answers' and replay them.
Interview questions
- What would you log for every LLM call?
- What are the OpenTelemetry GenAI semantic conventions?
- How is LLM observability different from normal APM?
Prompt versioning and management
Store prompts as immutable, versioned artifacts with labels, evaluate every version, and roll back by moving a label.
- A prompt version should include the template, model, params and output schema. Changing any of them changes behaviour.
- Versions are immutable; deployments point to a label such as
productionorstaging. Promotion and rollback just move the label. - Options: prompts in Git next to code (simple, reviewed in PRs), or a prompt registry (Langfuse, LangSmith, Braintrust, PromptLayer and similar) so non-engineers can edit and release without a deploy.
- Every new version runs the eval suite before promotion and is logged on each trace.
- Keep templates parameterised (variables), never build them with unescaped string concatenation of user input.
- Cache the fetched prompt in the app with a fallback copy, so a registry outage does not take production down.
Interview questions
- How do you manage prompts in production?
- Prompts in Git or in a prompt management tool?
- A prompt change caused a quality drop. How do you handle it?
A/B testing and feedback loops
Randomly and stickily split users between versions, compare business and quality metrics with statistics, and feed feedback into evals.
- Assign users (not requests) to arms with a hash of user id + experiment name, so the experience is consistent and assignment is stateless.
- Decide the primary metric up front (task success, thumbs-up rate, conversion, deflection) plus guardrail metrics (latency, cost, safety).
- Check statistical significance and run long enough; LLM feedback signals are sparse and noisy.
- Explicit feedback: thumbs, ratings, corrections. Implicit: copy, regenerate, edit distance of the user's final text, abandonment, follow-up questions.
- Feedback is biased (angry users click more). Use it to find failures, then label them properly before adding to datasets.
- Offline pairwise evals pick candidates; online A/B tests confirm real impact.
Interview questions
- How would you A/B test two prompts?
- What implicit feedback signals are useful for a chat assistant?
Drift and production monitoring
Inputs, models and knowledge all drift; watch input distributions, quality scores, cost and safety signals, and alert on changes.
- Input drift: users ask new topics, languages or longer questions. Detect with embedding clustering, topic classifiers or simple stats (length, language mix).
- Model drift: the provider updates a model behind an alias, or you upgrade. Pin snapshots and re-run evals on upgrades.
- Knowledge drift: RAG documents go stale; answers become wrong while still faithful. Monitor index freshness.
- Output drift: answer length, refusal rate, format errors, judge scores and sentiment trend over time.
- Alert on: p95 latency, error/429 rate, fallback rate, cost per request, guardrail trigger rate, online judge score drops, thumbs-down spikes.
- Plan for model deprecation: providers retire models on a schedule; keep a migration eval ready.
Interview questions
- How do you detect drift in an LLM application without labels?
- Your provider silently changed model behaviour. How do you protect against that?
- Which alerts would you set up on day one?
Safety, Security & Compliance
Guardrails: input and output validation
Wrap the model with checks before (injection, PII, scope) and after (schema, toxicity, PII, groundedness) the call.
- Input rails: length limits, PII detection/redaction, jailbreak and prompt-injection classifiers, topic/scope filters, moderation.
- Output rails: JSON/schema validation (with retry on failure), toxicity/moderation, PII leakage, groundedness checks, banned content, citation checks.
- Moderation APIs and safety classifiers (e.g. provider moderation endpoints, Llama Guard-style models) flag harmful categories.
- NeMo Guardrails (NVIDIA): programmable rails defined in config and the Colang language, including dialogue flows and input/output checks.
- Guardrails AI: Python framework wrapping calls in a
Guardwith validators from a hub (PII, toxic language, regex, schema) and on-fail actions such as fix, re-ask or exception. - Each rail adds latency and can false-positive. Run cheap rules first, run checks in parallel, and measure block rates.
Interview questions
- What guardrails would you put around a customer-facing chatbot?
- NeMo Guardrails vs Guardrails AI?
- How do you handle PII when calling a third-party LLM API?
Security: OWASP Top 10 for LLM apps (2025)
Know the ten risks, especially prompt injection, sensitive data disclosure, improper output handling, excessive agency and unbounded consumption.
- Direct prompt injection: the user tells the model to ignore its instructions. Indirect: malicious instructions hide in content the model reads (web pages, emails, retrieved docs, tool results).
- There is no complete fix for injection. Defence in depth: separate trusted and untrusted content, least privilege for tools, human approval for risky actions, output validation, monitoring.
- Improper output handling: treat model output as untrusted user input. Escape before rendering HTML, never pass it straight to SQL, shell or
eval. - Excessive agency: too many tools, too many permissions, or too much autonomy. Scope tools narrowly and use the user's own permissions.
- Unbounded consumption: attackers burn your tokens or extract the model. Rate limit, cap
max_tokensand input size, set budgets. - OWASP has also published a 2026 edition of the LLM list and a separate Top 10 for agentic applications; the 2025 list below is the one most interviews reference.
Interview questions
- What is prompt injection and how do you defend against it?
- Jailbreak vs prompt injection?
- An LLM agent can send emails. What could go wrong and how do you secure it?
- Why is LLM output 'improper output handling' a risk?
Data privacy and compliance (EU AI Act basics)
Minimise and protect personal data across prompts, logs and vendors, and know the EU AI Act's risk tiers and timeline.
- GDPR still applies to prompts, outputs and traces: lawful basis, data minimisation, retention limits, data subject rights, DPAs with vendors, cross-border transfer rules.
- Check vendor terms: is API data used for training? What is the retention period? Is zero data retention or regional processing available?
- EU AI Act is risk-based: prohibited practices (e.g. social scoring, manipulative techniques), high-risk systems (e.g. hiring, credit scoring, education, critical infrastructure) with heavy obligations, transparency duties (tell users they talk to AI, mark synthetic content), and minimal risk.
- General-purpose AI (GPAI) model providers have duties such as technical documentation, a copyright policy and a training-data summary; models with systemic risk get extra evaluation and security duties.
- Timeline: in force 1 Aug 2024; prohibitions and AI-literacy duties from 2 Feb 2025; GPAI obligations from 2 Aug 2025; most remaining rules including Article 50 transparency from 2 Aug 2026. After the 2025–26 'digital omnibus' amendments, high-risk obligations apply from 2 Dec 2027 (Annex III) and 2 Aug 2028 (Annex I products).
- LLMOps supports compliance with audit trails (traces, prompt versions), documented evals, human oversight and incident processes.
Interview questions
- What are the basics of the EU AI Act an engineer should know?
- How do you keep an LLM app GDPR-friendly?
- A user asks you to delete their data. What LLM-specific places must you check?
Performance, Cost & Reliability
Latency optimisation and caching
Stream tokens, shrink prompts and outputs, use smaller or routed models, parallelise steps, and cache at exact, semantic and prompt-prefix level.
- Streaming does not reduce total time but cuts perceived latency to TTFT. Use it for every user-facing response.
- Fewer tokens: shorter prompts lower prefill time; output length dominates total latency, so ask for concise answers and set
max_tokens. - Smaller/faster models and routing: send easy requests to a small model and hard ones to a large model.
- Parallelise independent calls (retrieval + classification) and run guardrails concurrently with generation when safe.
- Exact cache: key = hash of normalised prompt + model + params. Safe, but low hit rate for free text.
- Semantic cache: embed the query, reuse the answer of a similar past query above a similarity threshold. Higher hit rate, but risk of serving a wrong answer.
- Prompt (prefix) caching by providers: a repeated long prefix (system prompt, tools, documents) is processed once and reused, cutting cost and TTFT. Put static content first and variable content last. Some providers do it automatically, others need explicit cache markers.
Interview questions
- How would you reduce latency of an LLM feature?
- Semantic cache vs exact cache vs prompt caching?
- How do you choose the semantic cache threshold?
Cost optimisation and token budgets
Measure cost per request and per feature, then cut tokens, route to cheaper models, cache, batch and enforce budgets.
- Output tokens usually cost several times more than input tokens, so verbose answers are expensive.
- Model routing/cascading: try a small model first, escalate to a large one only when needed (low confidence, failed validation, complex request).
- Trim context: fewer, better RAG chunks; summarise long chat history; remove unused tool definitions.
- Use prompt caching for long static prefixes and batch APIs (asynchronous, typically discounted) for offline jobs like nightly classification.
- Set budgets and limits per user, team and feature:
max_tokens, request rate, daily spend caps, alerts. - Consider fine-tuning or distilling a small model when a large model is used at scale for a narrow task, and self-hosting only when volume is high and steady.
Interview questions
- Your LLM bill doubled this month. How do you investigate and reduce it?
- What is model routing / cascading?
- When is self-hosting cheaper than an API?
Reliability: rate limits, retries, fallbacks, circuit breakers
Expect 429s, 5xx and slow responses; use timeouts, jittered retries on transient errors, fallback models and circuit breakers.
- Timeouts on every call (connect + total, plus a TTFT timeout for streams). Without them a stuck request holds resources forever.
- Retry only transient errors (429, 500/502/503, timeouts) with exponential backoff and jitter; respect
Retry-After. Never retry 400-type validation errors. - Fallback chain: same model in another region or provider, then a smaller model, then a cached or canned answer.
- Circuit breaker: after repeated failures, stop calling the provider for a cooldown and fail fast to the fallback; then let a probe through (half-open).
- Respect provider rate limits (requests and tokens per minute): client-side token buckets, queues and per-tenant quotas.
- Make side-effecting tool calls idempotent so retries do not double-charge or double-send.
Interview questions
- How do you make an LLM call resilient?
- Why add jitter to exponential backoff?
- Explain the circuit breaker states.
Model gateways and routers (LiteLLM)
A gateway puts one OpenAI-compatible API in front of many providers and centralises keys, routing, fallbacks, budgets and logging.
- LiteLLM is an open-source Python SDK and proxy server that calls 100+ providers with an OpenAI-style interface (
provider/modelnames). - Its Router load-balances across deployments of the same model alias and supports retries, timeouts, cooldowns and fallbacks; Redis can share rate-limit state across instances.
- The proxy adds virtual keys, per-key/team budgets and rate limits, spend tracking and logging callbacks to observability tools.
- Benefits: swap providers without code changes, central secrets, one place for policy (PII redaction, guardrails, caching).
- Costs: an extra network hop and a critical dependency. Run it highly available and keep it close to the app.
- Alternatives include cloud gateways (e.g. Azure API Management, AWS Bedrock routing, Cloudflare AI Gateway), OpenRouter and other hosted gateways.
Interview questions
- Why use an LLM gateway like LiteLLM?
- How would you design multi-provider failover?
Self-hosting and serving (vLLM, TGI, Ollama)
Inference servers maximise GPU use with continuous batching and paged KV-cache memory; pick vLLM for production throughput, Ollama for local use.
- Generation has two phases: prefill (process the whole prompt in parallel, compute-bound) and decode (one token at a time, memory-bandwidth-bound).
- The KV cache stores attention keys/values of previous tokens so decode does not recompute them. It grows with sequence length × batch size and is the main GPU memory limit.
- Continuous batching: the scheduler adds new requests and removes finished ones at every decode step, instead of waiting for a whole batch to finish. Much higher throughput.
- PagedAttention (vLLM): stores the KV cache in fixed-size blocks mapped through a block table, like OS virtual memory. Almost no fragmentation, more concurrent sequences, and prefix blocks can be shared.
- vLLM: high-throughput engine with an OpenAI-compatible server (
vllm serve <model>), prefix caching, quantisation, tensor parallelism. TGI (Hugging Face) has similar features but is now in maintenance mode; HF recommends vLLM or SGLang. Ollama: easy local runner for quantised models with a simple REST API. - Other levers: quantisation (INT8/INT4/FP8) for memory and speed, speculative decoding for latency, tensor parallelism across GPUs for big models.
Interview questions
- What is continuous batching and why does it help?
- What problem does PagedAttention solve?
- Throughput vs latency when self-hosting: how do you balance them?
- Prefill vs decode?