CONTENTS
APPENDIX B

Glossary

3 MIN READ

Agent: A system where a model directs its own process and tool use in a loop to accomplish a goal.

Attention: The transformer mechanism by which each token computes a weighted mix of information from other tokens based on query–key similarity.

Base model: A pretrained model before instruction tuning; continues text rather than following instructions.

BM25: A classic keyword-based ranking algorithm used in search; paired with vector search in hybrid retrieval.

Chain-of-thought (CoT): Intermediate reasoning steps generated before a final answer.

Context window: The maximum number of tokens a model can process in one call (input plus output).

Context engineering: Designing and managing everything that goes into the model’s context: instructions, retrieved data, tools, history, memory.

Cosine similarity: Similarity between vectors measured by the angle between them; standard for embedding search.

Cross-entropy loss: The training objective for language models; the negative log probability of the correct next token.

Distillation: Training a smaller model to reproduce a larger model’s behavior, often using the larger model’s outputs as training data.

DPO (Direct Preference Optimization): A method that tunes a model directly on preference pairs without a separate reward model.

Embedding: A vector representation of text (or another input) where semantic similarity corresponds to geometric closeness.

Eval: A systematic test measuring an AI system’s behavior across a dataset of cases.

Few-shot prompting: Including examples of the task in the prompt.

Fine-tuning: Further training a pretrained model on task-specific data.

Guardrails: Programmatic checks on model inputs and outputs (validation, moderation, policy enforcement).

Hallucination: Model output that is fluent and plausible but not factually correct or not grounded in the provided sources.

Harness: The scaffolding around an agent loop: tools, permissions, context management, sandboxing, memory, observability.

HNSW: A popular approximate-nearest-neighbor graph index for fast vector search.

Hybrid search: Combining vector (semantic) and keyword (lexical) retrieval.

Inference: Running a trained model to produce outputs.

KV cache: Cached attention keys and values for previous tokens; speeds up generation and enables prompt caching.

LLM-as-judge: Using a language model to grade outputs against criteria.

LoRA: Low-Rank Adaptation; fine-tuning by training small low-rank matrices added to frozen weights.

MCP (Model Context Protocol): An open protocol for connecting AI applications to tools, data, and prompts via servers.

Mechanistic interpretability: Research reverse-engineering the internal computations of neural networks.

Mixture of Experts (MoE): An architecture routing each token to a subset of expert sub-networks, increasing capacity without proportional compute.

Perplexity: Exponentiated average cross-entropy loss; lower means the model predicts text better.

Post-training: Training after pretraining (SFT, preference optimization, RL) that shapes assistant behavior.

Prefill / decode: The parallel processing of the input prompt vs. the sequential generation of output tokens.

Prompt caching: Reusing computed state for repeated prompt prefixes to cut cost and latency.

Prompt injection: An attack where untrusted content contains instructions that hijack the model’s behavior.

Quantization: Representing model weights (and sometimes activations) with fewer bits to reduce memory and speed up inference.

RAG (Retrieval-Augmented Generation): Retrieving relevant information and inserting it into the model’s context at query time.

Reranker: A model that rescores retrieved candidates by examining query and document together.

Residual stream: The running vector through a transformer to which each layer adds its output.

Reward hacking: A model exploiting flaws in a reward signal rather than achieving the intended goal.

RLHF: Reinforcement Learning from Human Feedback.

RLVR: Reinforcement Learning from Verifiable Rewards; RL using automatically checkable outcomes such as tests or correct answers.

RoPE: Rotary Position Embeddings; encodes token positions by rotating query and key vectors.

Sampling / temperature: The process and settings for selecting tokens from the model’s predicted distribution.

Scaling laws: Empirical relationships between model performance and parameters, data, and compute.

SFT (Supervised Fine-Tuning): Training on examples of desired input–output behavior.

Sparse autoencoder (SAE): An interpretability tool that decomposes activations into sparse, often human-interpretable features.

Speculative decoding: Using a small draft model to propose tokens that a large model verifies in parallel.

Structured outputs: Constraining or validating model outputs to match a schema.

Test-time compute: Computation spent at inference (e.g., longer reasoning) to improve answer quality.

Token: The unit of text a model processes; typically a subword chunk.

Tool use / function calling: A model emitting structured requests to call external functions, which your code executes.

Transformer: The neural network architecture, built on attention and MLP blocks, behind modern LLMs.

Workflow: An LLM system where code, not the model, defines the control flow.


Closing thought: the best way to finish this book is to close it and build something. Pick one exercise, open your editor, and start.