Interview Study Guide

Guide / AI engineering Most asked

22. Top AI system design questions

Created · Updated · 10 min read

Use the same 45-minute framework, adding three AI-specific steps: define quality (how you’ll evaluate), define the latency/cost budget, and define safety boundaries (what the AI may and may not do).

1. Customer-support AI agent that resolves most tickets. Intent router → RAG over help articles + tools (order status, cancel, refund with limits) → guardrails → human handoff with conversation summary. Deep dives: action authorization, idempotent refunds, eval set from historical tickets, deflection vs CSAT metrics, escalation triggers, multilingual support.

2. Enterprise RAG over 10M+ documents with permissions. Connectors with ACL sync, incremental CDC ingestion, hybrid search with permission filters at query time, reranker, citations, per-tenant isolation. Deep dives: ACL changes propagating quickly, stale docs, scale of vector index (sharding, quantization), eval.

3. Semantic product search / shopping assistant. Query understanding (extract filters: price, brand, size), hybrid retrieval over catalogue, business re-ranking (stock, margin, personalization), LLM for conversational refinement, real-time prices and inventory from tools (never from the index). Deep dives: freshness, latency < 1 s, cold-start products, A/B testing.

4. LLM gateway for 50 internal teams. Unified API, quotas and budgets, provider fallback, routing, caching, PII redaction, audit logs, per-team cost dashboards. Deep dives: rate limits across providers, streaming through the gateway, failover without duplicate side effects.

5. Real-time voice agent for 10K concurrent calls. Telephony (SIP) → media servers → streaming STT → LLM with tools → streaming TTS; session state store; barge-in; latency budget < 800 ms; horizontal scaling of stateful media workers; recording and compliance. Deep dives: reconnection mid-call, cost per minute, evaluation with simulated callers.

6. ChatGPT-style chat application. Conversation storage, streaming via SSE, context management (truncate/summarize), memory, file uploads (parse + RAG), rate limits per plan, model selection, abuse moderation. Deep dives: resuming a stream after a dropped connection (store generated tokens server-side, resume from offset), multi-device sync.

7. Document-processing pipeline (invoices, KYC, contracts). Upload → queue → OCR/vision LLM extraction to a schema → validation rules → confidence scoring → human review queue for low confidence → downstream systems. Deep dives: idempotent processing, throughput with batch APIs, accuracy measurement per field, PII handling.

8. Agent evaluation platform. Dataset management, runs against versions of prompts/models/agents, deterministic + LLM-judge scorers, simulated users, trace storage, comparisons and regressions in CI. Deep dives: judge calibration, cost of eval runs, flaky (non-deterministic) results → multiple runs and confidence intervals.

9. AI code-review or coding assistant. Repo indexing (code-aware chunking by symbol, embeddings + keyword + call graph), context selection for a diff, LLM review with structured comments, false-positive control, sandboxed execution of tests. Deep dives: large monorepos, privacy, feedback loop from accepted/rejected comments.

10. Content moderation at scale. Cheap classifiers first, LLM for ambiguous cases, human review for appeals, policy versioning, latency tiers (pre-publish vs post-publish), metrics: precision/recall per policy.

11. Recommendation system with LLMs. Candidate generation (collaborative filtering, embeddings, two-tower models) → ranking model → LLM for explanations or conversational recommendations. LLMs are rarely the ranker at scale because of cost and latency.

12. Text-to-SQL analytics assistant. Schema retrieval (relevant tables + column descriptions + sample queries), SQL generation, validation (parse, read-only, allowlisted tables, row limits), execution on a replica/warehouse, result summarization and charts, permission checks. Deep dives: ambiguous business terms (“active user”), semantic layer, eval with gold queries.

22.1 Template answer: customer-support AI agent (practise until fluent)#

  1. Requirements: resolve common intents (order status, returns, refunds ≤ ₹X, address change), hand off the rest; p95 first token < 2 s; multilingual; no unauthorized actions; full audit.
  2. Estimates: 200K conversations/day × 6 turns × ~3K tokens/turn ≈ 3.6B tokens/day → cost dominates design; route simple intents to a small model, cache system prompt.
  3. Architecture: chat/voice channel → API gateway (auth, rate limit) → conversation service (state in Redis + Postgres) → agent orchestrator (LangGraph state machine) → tools (order service, refund service with idempotency keys and limits) + RAG (help center) → guardrails → response stream. Async: transcripts to Kafka → analytics, eval sampling, QA.
  4. Deep dives: intent routing vs one agent; tool authorization as the customer; refund idempotency; handoff with summary; how you evaluate (offline golden set + LLM judge + online resolution/CSAT); prompt versioning and canary.
  5. Failure modes: LLM provider down (fallback model, then “connecting you to an agent”); tool timeout (tell the user, retry safely); injection via order notes (treat as data, least privilege); hallucinated policy (answer only from retrieved policy, cite).

22.2 Full walkthrough — Enterprise RAG over 10M documents with permissions#

1. Requirements. Employees ask questions over company knowledge (Confluence, Google Drive, Slack, Jira, PDFs); answers cite sources; users must only see content they have access to in the source system. Non-functional: p95 first token < 3 s, permission changes reflected within ~15 minutes, new documents searchable within ~30 minutes, 20K employees, multi-tenant if sold as SaaS.

2. Estimates. 10M documents × ~10 chunks = 100M chunks. At 1,024 dims × 4 bytes ≈ 400 GB raw vectors (~100 GB with int8 quantization) → a dedicated vector store, sharded. Queries: 20K users × 10/day = 200K/day ≈ 2.3/s average, ~20/s peak — query load is light; ingestion and permissions are the hard parts.

3. Ingestion pipeline. Connectors per source (webhooks or polling with change tokens) → queue (Kafka) → parse (layout-aware for PDFs, OCR for scans) → chunk (structure-aware, parent-child) → enrich (title, path, author, updated_at, ACL list) → embed (batched, rate-limited, idempotent by doc_id + version + chunk_no) → write to vector index + BM25 index + chunk store (Postgres/S3). Deleted or moved docs trigger chunk deletion. Embedding model version is stored on every vector.

4. Deep dive A — permissions (the question this design is really about).

  • Model: store on each chunk the principals allowed to read it (user IDs and group IDs, from the source’s ACL). At query time, resolve the user’s groups (cached, from the identity provider) and filter retrieval with allowed_principals ∩ user_principals ≠ ∅.
  • Filter inside the retrieval query, never after generation — otherwise restricted content reaches the LLM context.
  • ACL changes: permission-change events re-tag affected chunks (metadata update, no re-embedding). Large group membership changes are handled by resolving groups at query time rather than expanding users onto chunks.
  • Safety net: a final check against the source system’s permission API for the few documents that make it into the answer (late-binding check) catches stale ACLs.
  • Tenant isolation (SaaS): separate namespace/collection per tenant, so a missing filter can’t leak across companies.

5. Query path. Auth → conversation rewrite into a standalone query → hybrid search (dense + BM25) with ACL + metadata filters, top 50 → RRF fusion → cross-encoder rerank to top 8 → parent-chunk expansion → prompt with numbered sources → LLM streams answer with citations → citation validation → log trace.

6. Deep dive B — scale of the vector index. 100M chunks: HNSW with int8/binary quantization in RAM + full vectors on disk for rescoring; shard by tenant (or by hash for one huge tenant); replicas for availability. Blue-green index for embedding-model upgrades.

7. Deep dive C — freshness and staleness. Change-driven ingestion, updated_at boost in ranking, prefer latest version when duplicates exist, show source dates in citations.

8. Evaluation. Golden set of ~300 real questions per department with expected source docs; retrieval recall@10 and nDCG; faithfulness and answer correctness by calibrated LLM judge; permission tests (users who must not see a doc ask about it — any leak is a sev-1); online thumbs and “was this helpful”.

9. Failure modes. Connector rate-limited by the source API (backoff, incremental sync, priority for recent changes); embedding provider outage (queue backs up, search serves slightly stale index); LLM outage (fallback model, or return the top sources without a generated answer); prompt injection inside a document (treat context as data, no tools with side effects in this assistant, output filtering).

Follow-ups: “Why not give the LLM everything with a long context?” (cost, latency, and permission filtering still needs retrieval). “How do you handle ‘summarize all incidents this quarter’?” (route to a map-reduce or GraphRAG global flow, or a structured query over incident metadata). “Cost per query?” (embedding the query is negligible; rerank + LLM tokens dominate — estimate tokens × price).

22.3 Full walkthrough — Real-time voice agent for 10K concurrent calls#

1. Requirements. Inbound and outbound phone calls (and in-app voice) handled by an AI agent that can look up orders, reschedule deliveries and take payments-free actions; hands off to humans; supports English and Hindi. Non-functional: voice-to-voice response < 800 ms p50 (< 1.5 s p95), barge-in, 10K concurrent calls at peak, call recording and transcripts for compliance, cost per minute tracked.

2. Estimates. 10K concurrent calls × ~1 LLM turn every 5–10 s ≈ 1–2K LLM requests/s at peak; streaming STT and TTS sessions = 10K each. Audio: ~8 kHz telephony (≈ 64 kbps G.711) per call → ~640 Mbps of media at peak. Cost per minute (STT + LLM + TTS + telephony) is the key business number — estimate each component per minute.

3. Architecture.

  1. Telephony: SIP trunk / CPaaS (Twilio, Exotel, Plivo) → media streamed over WebSocket or SIP to your media layer; in-app calls via WebRTC.
  2. Media workers (stateful, one call per pipeline instance; Pipecat/LiveKit Agents): VAD → streaming STT → turn detection → agent → streaming TTS → audio back. Many calls per worker; autoscale on active-call count.
  3. Agent service: LangGraph state machine with tools (order lookup, reschedule, create ticket, handoff), guardrails, prompt versions.
  4. Session state: Redis per call (conversation, slots collected, step) so a worker crash can resume on another worker.
  5. Async: transcripts, recordings (S3), events → Kafka → analytics, QA sampling, evals.

4. Deep dive A — the latency budget. Example for 800 ms: endpointing/turn detection ~200 ms after the user stops → final STT ~100 ms → LLM TTFT ~300 ms (small fast model, cached system prompt, short context) → TTS first audio ~150 ms → network ~50 ms. Tricks: stream everything, start TTS on the first sentence, speculative LLM call on partial transcripts, filler phrases (“let me check that”) while slow tools run, colocate workers with STT/LLM regions, keep connections warm.

5. Deep dive B — turn-taking and barge-in. VAD + semantic turn detection (has the user finished the thought, not just paused?). On barge-in: stop TTS within ~100 ms, flush audio buffers, truncate the assistant message in history to what was actually played, and process the new user input. Handle backchannels (“hmm”, “okay”) without treating them as interruptions.

6. Deep dive C — reliability. Media worker dies → the call is still connected at the telephony provider; reconnect the stream to a new worker which loads session state from Redis and says “sorry, I lost you for a second”. STT/LLM/TTS provider errors → per-component fallback providers; if the agent can’t recover, warm transfer to a human with a summary. Tool actions take idempotency keys (a retried “reschedule” mustn’t book twice).

7. Speech-to-speech vs cascaded. Speech-to-speech models (Gemini Live, OpenAI Realtime) cut latency and sound more natural; the cascaded pipeline gives text at every step (guardrails, logging, swapping providers, language-specific STT). A common compromise: cascaded for regulated or tool-heavy flows, speech-to-speech for conversational ones.

8. Evaluation. Simulated callers (personas, accents, noisy audio, interruptions) running scripted scenarios; metrics: task completion, word error rate per language, latency percentiles per stage, interruption handling, escalation rate, CSAT from post-call surveys; LLM-judge on transcripts for policy compliance.

9. Compliance and safety. Announce AI and recording; PII redaction in transcripts; DTMF or secure flows for sensitive data (never have the LLM read card numbers); consent and calling-hour rules for outbound; audit logs of every action.

Follow-ups: “How do you scale media workers?” (stateful; scale on concurrent calls, drain gracefully on deploy — don’t kill live calls). “Hindi-English code-mixing?” (STT model choice per language, evaluate WER on real recordings). “How do you cut cost per minute?” (smaller LLM for most turns, cache prompts, cheaper TTS voices, shorter responses, end idle calls).

Finished this page?Mark it done to track your progress across the guide.
Pritam Ghosh · System design & AI engineering study notes