# Building with large language models

Read these guides in order to go from how a language model works to serving and evaluating one in a real product.

## Stage 1: How the models work

1. **[Generative AI and LLMs](/topics/generative-ai-llms)**  
   A practical map of generative AI and large language models: how LLMs work, retrieval and vector databases, evaluation, observability, safety and serving.
2. **[GPT architecture](/tools/gpt-architecture)**  
   The GPT architecture is a decoder-only transformer trained to predict the next token. Learn its layers, causal attention, pre-training and why it scales.
3. **[Embeddings](/tools/embeddings)**  
   Embeddings are numeric vectors that capture the meaning of text, images or records so similar items sit close together. Learn how they power search and RAG.
4. **[Reasoning models](/tools/reasoning-models)**  
   Reasoning models think step by step before answering, spending more compute at inference time on harder problems. Learn how they work and when to use them.

## Stage 2: Prompting and context

5. **[Prompt engineering](/tools/prompt-engineering)**  
   Prompt engineering is writing clear instructions, examples and formats so language models produce reliable results. Learn the techniques that work.
6. **[Context engineering](/tools/context-engineering)**  
   Context engineering is the practice of deciding exactly what information, instructions, tools and memory go into a model's context at each step of an AI system.
7. **[Structured outputs](/tools/structured-outputs)**  
   Structured outputs make a language model return data that matches a JSON Schema. Learn constrained decoding, schema design, validation and when to use it.

## Stage 3: Retrieval

8. **[Retrieval-augmented generation (RAG): from naive to agentic](/articles/rag-from-naive-to-agentic)**  
   How retrieval-augmented generation works, why naive RAG fails, and how advanced, graph, and agentic RAG fix it, with evaluation.
9. **[pgvector](/tools/pgvector)**  
   pgvector adds a vector type and similarity search to PostgreSQL, with HNSW and IVFFlat indexes. Learn when keeping vectors in Postgres is the right choice.
10. **[Qdrant](/tools/qdrant)**  
   Qdrant is an open-source vector search engine written in Rust, known for payload filtering, quantization and hybrid dense-sparse search. Learn how it works.

## Stage 4: Adapting a model

11. **[Fine-tuning](/tools/fine-tuning)**  
   Fine-tuning adapts a pretrained model to your task by training it further on your data. The full map: full tuning, LoRA, QLoRA, SFT, RLHF, DPO and RAG.
12. **[LoRA](/tools/lora)**  
   LoRA fine-tunes large models by training small low-rank update matrices while the base weights stay frozen. Learn how it works, when to use it, and its limits.
13. **[DPO](/tools/dpo)**  
   DPO explained: how direct preference optimization aligns language models from chosen and rejected answers without a reward model, with math, code and…

## Stage 5: Serving and evaluating

14. **[vLLM](/tools/vllm)**  
   vLLM is an open-source engine for fast, memory-efficient LLM inference using PagedAttention and continuous batching, with an OpenAI-compatible server.
15. **[KV cache](/tools/kv-cache)**  
   The KV cache stores attention keys and values from earlier tokens so a language model does not recompute them for each new token, trading memory for speed.
16. **[Prompt caching](/tools/prompt-caching)**  
   Prompt caching stores the computed state for the start of a prompt so later requests with the same prefix skip that work, cutting cost and latency.
17. **[LLM routing](/tools/llm-routing)**  
   LLM routing sends each request to the most suitable model, using rules, classifiers, learned routers or cascades, to balance quality against cost and speed.
18. **[LLM-as-judge](/tools/llm-as-judge)**  
   LLM-as-judge uses a language model to grade AI outputs against a rubric. Learn grading modes, known biases, calibration against humans and when to trust it.
19. **[The new LLM serving stack: cache-aware routing, continuous batching and expert pruning](/articles/llm-inference-serving-stack-cache-routing)**  
   Buoyant's Kinference, Fireworks Forge and AWS research on MoE expert pruning show where LLM serving costs now go. How KV caches, routing and batching work.

## How to use this path

Read the steps in order; each guide links onward to related topics, so you can go deeper wherever you need to. If you already know a stage, skip to the next one. All learning paths are listed on [Learning paths](/paths).
