AI system design

AI system design library

Content updated · What changed

Study estimates cover the whole lesson, including diagrams, tables and code. Allow extra time to do exercises and quizzes.

149 lessons · About 84 hr 38 min to study

Foundations

Concepts ·

Tokenization Deep Dive: How Text Becomes Model Input

Text tokenization segments text into discrete units called tokens. For a language model, the tokenizer also maps those units to integer token IDs in its vocabulary. A decoder reconstructs text from IDs according…

Diagram

Attention Mechanisms: How Tokens Share Information

Attention computes a weighted aggregation of value vectors, using compatibility scores between a query and the available keys. In standard scaled dot-product attention, the scores are scaled, masked and…

Diagram

Embeddings and Vector Spaces

An embedding is a numerical representation of an item in a vector space, usually learned so useful relationships are reflected in the representation. For dense text retrieval, the item is text and the output is…

Diagram

Inference Pipeline

Inference is using a trained model to compute outputs from new inputs. This chapter covers the serving pipeline for a decoder-only autoregressive language model: how a request becomes generated text, how the…

Diagram

Model Landscape

Concepts ·

Model Taxonomy

A taxonomy is a systematic classification using stated characteristics. In model selection, those characteristics include the training objective, input/output contract, architecture, available weights, license…

Diagram

Capability Assessment

Measure how reliably a model completes a task. Choose representative examples, define what counts as success, and compare quality, latency and cost.

Diagram

Pricing and Costs

Estimate AI costs from token rates, tool calls, retries and human review. Work through examples, then design a service that tracks usage and reserves budget before each call.

Diagram

Model Selection Guide

Model selection is choosing a model and its operating configuration to meet a defined task, objective and constraints. In a production application, the decision includes the prompt, retrieval, tools, runtime and…

Diagram

Training And Adaptation

Concepts ·

Pretraining: learning a reusable language model

Pretraining is the initial large-scale training of a model on a broad data distribution before adaptation to a particular application. For a causal language model, training usually learns to predict the next…

Diagram

Fine-tuning: change behavior for a measured reason

Fine-tuning continues training a pretrained model on additional data to adapt its parameters to a task or domain. Supervised fine-tuning (SFT) learns from labeled examples, commonly instructions paired with…

Diagram

LoRA and QLoRA: understand what becomes smaller

Parameter-efficient fine-tuning (PEFT) adapts a model by training a subset of parameters or additional small components. Low-Rank Adaptation (LoRA) freezes a base weight matrix and learns an additive update…

Diagram

Preference learning: RLHF and DPO

Reinforcement learning from human feedback (RLHF) uses human feedback to guide a model through reinforcement learning. A common language-model recipe trains a reward model from human preferences and then…

Diagram

Quantization: budget memory without guessing quality

Quantization represents numerical values using a restricted set of levels, commonly to reduce the bits used for model weights, activations, or cached attention tensors. It introduces approximation. Whether that…

Diagram

RLVR and GRPO: train against a checkable outcome

Reinforcement learning with verifiable rewards (RLVR) updates a model using rewards computed by a checker, such as answer comparison, code tests, or a proof verifier. The model is the policy that produces…

Diagram

Inference Optimization

Concepts ·

Inference: follow the request before optimizing it

Inference is using a trained model to compute predictions or outputs. In an autoregressive language model, the service processes the prompt and then repeatedly predicts the next token from the available prefix.…

Diagram

Prompting And Context

Concepts ·

Prompt Engineering Fundamentals

Prompt engineering is the design and evaluation of inputs that guide a language model toward a specified task. The input may contain instructions, examples, source material and an output contract. Prompting…

Diagram

Few-Shot and In-Context Learning

In-context learning (ICL) is a model's adaptation to a task through information supplied in its context, without updating its parameters. Few-shot prompting supplies a small number of demonstrations of the…

Diagram

Chain-of-Thought Prompting and Reasoning

Chain-of-thought (CoT) prompting elicits intermediate reasoning steps before a final answer. The original few-shot approach included worked reasoning demonstrations in the prompt. It improved results on several…

Diagram

Tree of Thoughts and Deliberate Search

Tree of Thoughts (ToT) is a search framework that explores and evaluates alternative intermediate reasoning states produced by a language model. A state represents partial progress toward a solution. The system…

Diagram

Context Engineering

Context engineering is the design of how information is selected, organized and supplied to a model for each call. That information can include instructions, the current request, conversation history, tool…

Diagram

Structured Generation

Structured generation produces model output that follows a defined machine-readable format or schema. It can use ordinary prompting, constrained decoding, or a provider's structured-output interface. The…

Diagram

Prompt Optimization with DSPy

DSPy is a framework for expressing language-model programs and optimizing them against examples and a metric. It separates the program's input/output contracts and control flow from some of the instructions and…

Diagram

Prompt Injection and Defense

Prompt injection is an attack in which supplied content attempts to override or redirect a language-model application's intended instructions. In a direct attack, the attacker supplies the user-facing input. In…

Diagram

Retrieval Systems

Concepts ·

RAG Fundamentals

Retrieval-augmented generation (RAG) combines retrieval of external information with generation conditioned on that information. In a question-answering application, the system finds relevant evidence at request…

Diagram

Chunking Strategies

Chunking divides source material into units that can be indexed, retrieved and supplied as evidence. The search unit and the unit shown to the answering model do not have to be identical. A small matching…

Diagram

Embedding Models

An embedding model maps an input into a numerical representation learned for tasks such as similarity search. For retrieval, compatible query and document representations are scored to rank candidate evidence.…

Diagram

Vector Databases and Search Indexes

A vector database stores vector representations and supports similarity search, usually alongside identifiers, metadata, updates and operational controls. Vector search can also be a capability inside a…

Diagram

Hybrid Search

Hybrid search combines multiple retrieval signals, commonly lexical and dense-vector relevance, to produce a ranked candidate set. Its purpose is to cover different ways a query and document can match. It is a…

Diagram

Reranking Strategies

Reranking reorders a retrieved candidate set using an additional relevance model or scoring method. It spends more work on a bounded set of candidates than is usually practical across the entire corpus. It can…

Diagram

GraphRAG

Graph-based retrieval-augmented generation uses a graph of entities or relationships to select or organize information supplied to a generative model. It can support local relationship queries, multi-hop…

Diagram

Agentic RAG

Agentic RAG uses model-driven decisions to choose retrieval actions as part of an answering workflow. The model may select a source, formulate a follow-up query or decide that more evidence is needed.…

Diagram

Advanced Retrieval Patterns

Retrieval enhancements change the query, indexed representation or candidate-selection process to address a specific evidence-retrieval failure. Start by naming that failure. A more elaborate pipeline is useful…

Diagram

Contextual Retrieval

Contextual retrieval adds information about a passage's surrounding document to its searchable representation. The aim is to make a chunk understandable when separated from its original location. In the approach…

Diagram

Late Interaction and ColBERT

Late interaction encodes queries and documents separately, then compares their finer-grained representations during scoring. ColBERT is a text-retrieval architecture that uses contextualized token vectors and a…

Diagram

Multimodal RAG

Multimodal retrieval-augmented generation retrieves evidence involving more than one type of information, such as text, images, audio or video, and uses that evidence to produce an answer. A table's structure…

Diagram

RAG Evaluation Patterns

RAG evaluation measures how well a retrieval-augmented system finds appropriate evidence, uses it accurately, and satisfies the user's task. Evaluate those stages separately so a failure leads to a specific repair.

Diagram

Production RAG at Scale

A production RAG system combines maintained knowledge sources, authorized retrieval and answer generation under explicit quality and operating requirements. Scaling it means sustaining useful, supported answers…

Diagram

Data Engineering for AI

Data engineering for AI builds and operates the pipelines that turn source data into reliable inputs for retrieval, training, prediction and evaluation. It includes ingestion, transformation, validation, lineage…

Diagram

Agentic Systems

Concepts ·

Agentic Systems: Design, Control and Verification

An AI agent uses a model to select actions toward a goal, observes their results and can adapt its next action. A workflow fixes more of that control flow in application code. Real products often combine both: a…

Diagram

Agent Fundamentals

Follow an agent through one failed deployment. See how the model proposes actions, how the application checks them, and what the L0–L4 labels mean.

Diagram

Tool Use and MCP

Tool use lets a model propose a structured operation that application code validates and executes. The result becomes input for a later model decision or answer. The model does not gain database, filesystem or…

Diagram

Multi-Agent Orchestration

Multi-agent orchestration coordinates two or more agents: it assigns work, controls communication, manages shared state and combines results. Each agent may have its own model, instructions, tools and context.…

Diagram

Agent Memory and State

Memory makes earlier information available to an agent. Workflow state records what is happening now, such as whether a refund is still waiting for confirmation.

Diagram

Planning and Decomposition

Planning selects actions and their ordering to reach a goal under constraints. Decomposition breaks a task into smaller tasks with explicit dependencies. A plan can be a short checklist, a dependency graph or a…

Diagram

Error Handling and Recovery

Error handling detects and classifies failures, then selects an appropriate response. Recovery restores the task to a known valid state or ends it with an accurate account of what remains unresolved. A…

Diagram

Human-in-the-Loop Patterns

Human-in-the-loop (HITL) systems include human input, judgment or authorization at defined points in an automated process. The person may supply missing information, review a proposal or resolve an exception.…

Diagram

Agentic Security and Sandboxing

Agentic security protects data, systems and users when an AI application can choose and execute actions. The familiar goals of confidentiality, integrity and availability still apply. The additional challenge is…

Diagram

Evaluating Agentic Systems

Evaluate the answer, the actions the agent took, and the resources it used. Check whether it finished the task and respected permissions and budgets.

Diagram

Durable Execution for Long-Running Agents

Durable execution preserves enough execution state and completed results for work to continue after a process failure. Its guarantees depend on the runtime, persistence configuration and the contracts of the…

Diagram

Loop Engineering

Build the application code that runs an agent, checks its permissions, and stops when the task is complete or repeated attempts stop helping.

Diagram

Memory And State

Concepts ·

Memory Architectures

Decide what an AI application should remember, when it should update or delete it, and what it should retrieve for each new request.

Diagram

Short-Term Context Management

Context management is the application's selection, organization and budgeting of information supplied to a model interaction. It includes instructions, messages, tool schemas, retrieved evidence and tool…

Diagram

Long-Term Memory

Store useful information across sessions. Track where a preference or fact came from, how to correct it, and when to stop using it.

Diagram

Agentic Memory with Mem0

Mem0 extracts and retrieves information from conversations. See how to use it while keeping control of who can read, update and delete that information.

Diagram

Semantic Caching

Semantic caching reuses a previously computed result when a new request is judged equivalent enough for that result to remain valid. It usually uses embeddings to find candidates, then applies additional…

Diagram

State Management Patterns

Application state is the information needed to describe a system's current condition and determine its next valid actions. For an agent task, that includes its goal, stage, artifact versions, completed…

Diagram

Frameworks And Tools

Concepts ·

LangChain Deep Dive

LangChain is a framework ecosystem for composing model integrations, tools and agent behavior. Its current high-level agent entry point is create_agent; LangGraph provides the lower-level orchestration runtime…

Diagram

LangGraph Orchestration

LangGraph is an orchestration framework for stateful workflows and agents. It represents work through state, nodes and control flow, with facilities for persistence, interrupts and streaming. A graph can contain…

Diagram

LangSmith Observability

Observability is the ability to understand a system's behavior from its emitted telemetry. In an AI application, useful telemetry connects the user's task to retrieval, model calls, tool actions, state…

Diagram

DSPy: programming and evaluating model behavior

DSPy is a Python framework for composing language-model programs and optimizing parts of those programs against a chosen metric. You specify inputs, outputs, and program structure. An optimizer can search for…

Diagram

Semantic Kernel and Microsoft Agent Framework

Semantic Kernel is Microsoft's open-source SDK for integrating models, prompts, and callable functions into applications. A kernel connects configured services and functions; plugins group related functions. The…

Diagram

Claude Code: designing a dependable coding workflow

Claude Code is Anthropic's coding agent: a model-driven tool loop that can inspect a repository, edit files, run commands, and use configured integrations. It is available through several interfaces, including…

Diagram

Coding models and agents: choose by evidence

A coding model predicts useful code or tool calls; a coding agent combines a model with context, tools, an execution loop, and verification. A product adds a user interface, account policies, integrations, and…

Diagram

Framework changes: reproduce, diagnose, migrate

Dependency churn is the ongoing change in libraries, integrations, runtimes and hosted services that an application depends on. It can break imports, alter behavior, or retire a service while your own source…

Diagram

Document Processing

Concepts ·

Infrastructure And MLOps

Concepts ·

Security And Access

Concepts ·

LLM security: protect data, authority and execution

LLM application security protects the confidentiality, integrity and availability of an application that uses a language model. It includes ordinary web, identity, data and infrastructure security, plus risks…

Diagram

Access control for AI applications

Authentication verifies an identity. Authorization decides whether a principal may perform an action on a resource. Isolation enforces the boundaries between users, tenants or workloads. Authentication alone…

Diagram

Reliability And Safety

Concepts ·

Evaluation And Observability

Concepts ·

AI Design Patterns

Concepts ·

Tool Use And Computer Agents

Concepts ·

Architecture patterns for dependable tool-use agents

A tool-use architecture separates model decisions from authorized execution and verified outcomes. The model proposes what to do. The application validates the request, enforces access and limits, executes it,…

Diagram

Safety and governance for tool-using agents

Agent safety means preventing or limiting harmful outcomes from an agent's decisions and actions. Security protects the system and its data against unauthorized access, manipulation, and disruption. Governance…

Diagram

Voice And Audio Agents

Concepts ·

Multimodal Generation

Concepts ·

Case Studies

System designs ·

Design an Enterprise Knowledge Assistant

Interview problem: design a read-only assistant that answers employee questions from internal policies, procedures and research, with inspectable citations and current access control.

Diagram

Design a Conversational Customer-Support Agent

Interview problem: design a support assistant for a multi-tenant SaaS product. It must resolve a bounded set of issues, maintain useful conversation state, read authorized account information, and transfer…

Diagram

Design a Source-Verified Financial Research Assistant

Interview problem: build a system that helps analysts prepare company research reports from filings, earnings material and licensed research. Every published report requires an authorized analyst to approve its…

Diagram

Design an IDE Code Assistant

Interview problem: provide fast inline completions, explanations and developer-requested edits inside an IDE, while protecting repository data and preserving the developer's work.

Diagram

Design a Content-Moderation Platform

Interview problem: moderate text and media at social-platform scale while limiting harmful exposure, avoiding wrongful restrictions, and providing timely human review and appeals.

Diagram

Design a Multi-Tenant Contract-Analysis Platform

Interview problem: let competing businesses upload private contracts and ask grounded questions on shared infrastructure, while enforcing access, predictable service and accountable data lifecycle operations.

Diagram

Case Study: Pharmaceutical Promotion Review

This is a hypothetical interview scenario. Workload, performance, staffing and costs are planning assumptions, not measured results. Regulatory references describe the US scope of this example and must be…

Diagram

Case Study: Clinical Voice Documentation

This is a hypothetical interview scenario. Workload, latency, staffing and costs are planning assumptions, not measured results. Model and interoperability facts have primary-source links. Clinical review and…

Diagram

Case Study: Real-Time Payment Fraud Decisions

This is a hypothetical interview scenario. Traffic, thresholds, latency and costs are planning assumptions, not measured results. Provider-specific behavior has source links; the proposed service has its own…

Diagram

Case Study: Enterprise Knowledge Assistant

This is a hypothetical interview scenario. Traffic, latency, storage, staffing and costs are planning assumptions, not measured results. Connector behavior and model pricing have primary-source links.

Diagram

Case Study: Customer-Specific Fine-Tuning Platform

This is a hypothetical interview scenario. Tenant counts, workloads, latency, training times and costs are planning assumptions, not measured results. Model, framework and research references are linked to their…

Diagram

Design an Evaluation Gate for AI Releases

Hypothetical interview scenario. Workloads, tolerances, costs and service targets are assumptions for this design. They are not Learnastra operating results or universal standards.

Diagram

Design a Customer-Specific Distillation Pipeline

Hypothetical interview scenario. Traffic, quality margins, GPU throughput, staffing and project costs are planning assumptions. Model documentation and quoted API prices have primary-source links.

Diagram

Platform & Product Designs

System designs ·

Design an Adaptive AI Learning Tutor

Design a tutor that explains approved material, gives hints, checks answers and recommends exercises. Measure what learners can do on their own after practice.

Diagram

Design an AI Gateway and Model-Routing Service

Interview problem: several product teams use different model providers. Create one governed API that enforces identity, budget, model eligibility, regional processing constraints and reliable usage accounting.

Diagram

Design a Deadline-Aware Batch Inference Platform

Interview problem: teams need to classify, enrich or summarize millions of records overnight. Build a platform that validates input, schedules model work within quotas, resumes after failure and produces…

Diagram

Design an Image and Video Generation Platform

Interview problem: let a creative team generate, revise and export images and short videos from text and approved reference assets. Jobs can take seconds to minutes, so the product must expose progress,…

Diagram

Design a Multi-Tenant Model-Serving Platform

Interview problem: provide an internal inference API for interactive assistants and offline jobs. Teams choose from approved model versions; the platform enforces tenant budgets, predictable latency, isolation…

Diagram

Design a Multi-Tenant Vector Search Service

Interview problem: offer filtered semantic search over customer document passages. Support ingestion, updates, deletions, index upgrades and predictable search latency without leaking another tenant's records.

Diagram

Interview Prep

Interview toolkit ·

AI System Design Interview Practice

An AI system design interview asks you to turn an ambiguous product request into an implementable, measurable system. Explain what the system must do, how data moves through it, what can fail, and why the…

Diagram

AI Engineering and System Design Question Bank

This page has three levels: 40 quick checks for recall, 128 developed answers for understanding, and five worked design scenarios for synthesis. The ten leadership follow-ups apply when the role includes those…

Diagram

Answer Frameworks for AI System Design Interviews

An answer framework is a way to organize reasoning so another person can follow it. For system design, use the conventional sequence: clarify requirements, estimate scale, propose a baseline, define contracts,…

Diagram

Common Pitfalls in AI System Design Interviews

A weak design answer often contains correct terms but omits the reasoning that connects them. This chapter helps you identify the missing requirement, mechanism or evidence, then repair the explanation. It is a…

Diagram

Whiteboard Exercises for AI System Design

A system design diagram explains how a defined user outcome is produced under stated constraints. Use these nine authored exercises to practice the full interview: requirements → baseline → flaws → detailed…

Diagram

AI Engineering FAQ

An AI engineer builds software systems that use AI models to perform useful tasks. Work can include data preparation, model integration, evaluation, serving, security and operations. A role may focus on…

Diagram

Resources

Interview toolkit ·

AI Architecture Pattern Reference

A design pattern is a reusable approach to a recurring problem under stated conditions. It gives you a starting structure and known tradeoffs. It does not establish that your application needs the pattern or…

Diagram

AI Engineering Glossary

The model can propose an action. Application code decides whether that action is allowed and records its outcome.

Diagram

AI Evaluation Lab: Build, Inspect, and Compare

Build a small evaluation workflow you can explain in an interview and inspect in code. Start with the evaluation foundations guide for definitions and statistical assumptions. This companion applies those ideas…

Diagram

Corrections and Editorial Standards

A useful interview guide must be accurate enough to build understanding and clear enough to recall under pressure. This page explains how to report a problem and what a publishable correction should establish.

Learning Resources and Practice Paths

Choose a resource to close a specific skill gap, then demonstrate the skill in a small project and a design explanation. Completing more courses is not the same as becoming ready for an interview.

Diagram

Preparing for an AI Engineering Role

Start with the work you want to do, then connect your existing experience to evidence that you can do it. An “AI” title can describe product development, model research, infrastructure, evaluation, customer…

Diagram