What you will learn in Transformers in Action
Chapter by chapter
Concepts explained in this book
- embeddingA fixed-length vector is an ordered numerical representation with a predetermined number of components.
- attentionAn attention mechanism dynamically assigns greater computational weight to input elements that are more relevant to the current representation or prediction.
- multi-head attentionMultihead attention is an attention mechanism that computes multiple attention patterns in parallel so a model can represent different relationships among sequence positions.
- small language modelA small language model is a relatively compact language model designed to provide efficient inference with fewer parameters and lower resource requirements than larger models.
- transformer architectureA transformer is a neural network architecture that processes sequential and other structured data using attention mechanisms.
- similarity searchRetrieval is the process of finding and returning relevant information from a collection or database in response to a query.
- positional embeddingPositional encoding is a representation that incorporates sequence-position information into neural-network inputs or hidden states.
- keyIn attention, a key is a vector representation whose similarity to a query determines the relevance of its associated value.
- queryIn attention, a query is a vector representation that specifies the information for which relevance is being evaluated.
- valueIn attention, a value is a vector representation containing the content aggregated according to attention weights.
- scaled-dot product attentionScaled dot-product attention computes query-key dot products, scales them by the square root of the key dimension, applies softmax, and uses the results to weight values.
- hyperparameter tuningHyperparameter optimization is the systematic search for hyperparameter values that improve a model's training or evaluation performance.
- encoderAn encoder is the sequence-to-sequence component that processes an input sequence and produces a representation for a decoder.
- retrieval-augmented generationA retrieval-augmented generation system generates outputs using information retrieved from an external collection.
- vectorizationAn embedding model maps inputs such as queries and documents to vector representations capturing semantic or other task-relevant relationships.
- multimodalA multimodal model is a model that processes or generates information across multiple data modalities such as text, audio, video, and images.
- fine-tuningFine-tuning is the adaptation of a pretrained model by further optimizing its parameters for a specific task or behavior.
- softmaxThe softmax function converts a vector of scores into nonnegative values that sum to one.
- hyperparameterA hyperparameter is a configuration value set before or outside model training that controls architecture or optimization behavior.
- key-value cacheKey-value caching is an inference optimization technique that stores previously computed attention key and value vectors for reuse during autoregressive generation.
- language modelA large language model is a neural language model trained on large text corpora to predict and generate natural-language sequences.
- masked attentionCausal masking restricts a sequence position from attending to later positions so predictions depend only on preceding context.
- encoder-only transformerAn encoder-only architecture is a sequence-model architecture that uses an encoder without a separate output decoder.
- decodeThe component of a sequence model that generates an output sequence from encoded representations and contextual information.
- Gemma 3 270MGemma 3 270M is a compact Gemma language model with approximately 270 million parameters.
- exploding gradientThe exploding gradient problem is a training failure in which gradients become excessively large, causing unstable parameter updates and potentially preventing convergence.
- decoder-only transformerA decoder-only architecture is a sequence-model architecture that generates outputs using a decoder without a separate input encoder.
- beam searchBeam search is a decoding algorithm that maintains a fixed number of highest-probability partial token sequences and expands each sequence at every step.
- contextualized representationA contextual embedding is a vector representation whose value reflects the surrounding context of the represented text element.
- prompt engineeringPrompting is the practice of providing input instructions or context to a generative model to elicit a desired output.
- feedforward networkA feed-forward network is a neural-network component that transforms inputs through successive fully connected layers without recurrent state.
- interpretabilityExplainability is the degree to which a model's outputs and the factors behind them can be understood or audited.
- parameterA model parameter is a learned numerical value within a model that is optimized from training data.
- long-range dependencyA long-term dependency is a relationship between sequence elements separated by a substantial distance that influences their interpretation or prediction.
- mixture of expertsA mixture-of-experts model routes inputs among specialized subnetworks called experts, typically activating or combining only a selected subset for each input.
- tilingTiling is a technique that partitions a large computation into smaller subproblems whose data can be reused in faster local memory.
- few-shot learningFew-shot learning is the adaptation of a model to a new task using only a small number of task-specific examples.
- Proximal Policy OptimizationProximal policy optimization is a reinforcement-learning algorithm that limits policy updates so successive policies remain close during training.
- reward signalA reward signal is a numerical feedback signal that indicates the desirability of an action, output, or state in reinforcement learning.
- biasBias is a systematic deviation or tendency in data, measurements, estimates, judgments, or outputs that skews them relative to a relevant target or impartial baseline.
- Direct Preference OptimizationDirect Preference Optimization is a preference-alignment technique that directly optimizes a language model from chosen and rejected responses without separately training an explicit reward model.
- inference optimizationInference optimization is the improvement of a trained model's serving efficiency by reducing latency, increasing throughput, or lowering resource use without changing the model architecture.
- paged attentionPaged attention is an attention-memory technique that partitions a key-value cache into blocks managed like virtual-memory pages instead of requiring one contiguous allocation.
- guard modelA guard model is a compact classifier that labels prompts or outputs for safety-related properties such as benignness or maliciousness.
- top-k samplingTop-k sampling is a text-generation decoding technique that restricts sampling to a fixed number of the highest-probability tokens.
- RayRay is an open-source framework for scaling Python and machine-learning applications across distributed computing resources.
- linear layernn.Linear is a PyTorch module that applies an affine linear transformation to its input.
- meanA speedup is the ratio of the execution time of a baseline implementation to that of an optimized implementation.
- throughputThroughput is the amount of inference work completed per unit of time, such as generated tokens or served requests per second.
- quantizationQuantization is the transformation of numerical model parameters or activations into lower-precision representations to reduce memory consumption or computational cost.
- Weights and BiasesWeights & Biases is a machine-learning experiment-tracking platform for recording, visualizing, and managing training runs and model artifacts.
- QLoRAQLoRA is a parameter-efficient fine-tuning method that combines low-rank adapter updates with quantization of the base model.
- toxicityToxicity is the presence of harmful, abusive, hateful, or otherwise damaging content in model outputs or data.
- decoding strategyDecoding is the process of generating an output sequence conditioned on an input sequence.
- greedy algorithmGreedy decoding generates a sequence by selecting the highest-probability next token at each step without retaining alternative continuations.
- conditional computationConditional computation is a technique in which a model activates only a subset of its components for each input.
- expert networkAn expert is a specialized neural subnetwork within a mixture-of-experts architecture that processes inputs routed to it.
- generationNatural language generation is the computational production of human-readable language from learned representations or structured information.
- learning rateLearning rate is an optimization hyperparameter that controls the magnitude of parameter updates during training.
- DoRADoRA is a parameter-efficient fine-tuning method that decomposes model weights into separately tunable magnitude and directional components.
- low-rank adaptationA low-rank adapter is a parameter-efficient fine-tuning component that represents a weight update through low-rank factors.
- reinforcement learning with human feedbackReinforcement learning from human feedback is a model-optimization technique that uses human preference feedback to define or improve a reward signal.
- LLM GuardLLM Guard is a security toolkit that provides configurable scanning and protection for inputs and outputs of large language model systems.
- temperatureTemperature sampling is a sampling strategy that adjusts the sharpness of a token probability distribution before selecting the next token.
- FlashAttentionFlashAttention is an exact attention-computation technique that tiles queries, keys, and values to reduce memory traffic and linearize memory usage.
- waveformA waveform is a representation of a time-varying signal, such as an audio signal.
- iRoPEiRoPE is a positional strategy that alternates rotary-position layers with layers that omit positional encoding to support extremely long contexts.
- YaRNYaRN is a technique that rescales rotary-position frequencies to extend a model's usable context length beyond its training length.
- foundational modelA pretrained model is a machine-learning model whose parameters have already been learned from a broad training corpus before adaptation to a specific task.
- next-token predictionNext-token prediction is the task of predicting the token that follows a given preceding token sequence.
- chain-of-thought promptingChain-of-thought prompting guides a language model by providing or eliciting a sequence of intermediate reasoning steps before the final answer.
- double quantizationDouble quantization is a quantization technique that quantizes already-quantized values or their associated quantization parameters to reduce memory use.
- NormalFloat4NF4 is a four-bit numerical data type optimized for representing neural-network weights with an approximately normal distribution.
- vector databaseA vector database is a database optimized for storing, indexing, and searching vector representations by their similarity.
- dense modelA dense model is a neural model in which all relevant parameters and computational components are activated for every input.
- expert-choice routingExpert-choice routing is a routing strategy in which each expert selects the tokens it will process rather than receiving assignments from a token-side gate.
- expert collapseExpert collapse is a failure mode in which routing concentrates usage on only a small subset of experts.
- load balancingLoad balancing is the distribution of tokens or computation across experts so that no experts are overloaded while others remain underused.
- routingA gating network is a lightweight neural component that scores experts and selects or weights them for each input token.
- sparse gatingSparse gating is a routing strategy that activates only the top-ranked subset of experts for each input token.
- Tree-of-thoughtTree-of-thought prompting explores and evaluates multiple branching intermediate reasoning paths before producing an answer.
- batch sizeBatch size is the number of training examples processed in one forward and backward pass before a parameter update.
- reward modelA reward model is a learned model that assigns scores representing the desirability of outputs or actions according to preference feedback.
- perplexityPerplexity is a language-modeling metric equal to the exponential of average cross-entropy loss, measuring how well a model predicts a target token distribution.
- ProsocialDialogProsocialDialog is a dialogue dataset containing responses designed to promote prosocial and safe conversational behavior.
- input scannerAn input scanner is a preprocessing component that examines a prompt for policy violations or unwanted content before model inference.
- output scannerAn output scanner is a postprocessing component that examines generated model content for safety, privacy, factuality, or other policy violations.
- prompt injection detectionPromptInjection is an input-scanning component that detects attempts to manipulate a language model through injected instructions.
- generatorA generator is a generative model component that produces an output from an input representation or retrieved context.
- cosine similarityCosine similarity is a metric that measures the directional similarity between two vectors using the cosine of the angle between them.
- similarity metricA similarity score is a numerical value indicating how closely two represented items align according to a specified similarity measure.
- dataset splitSharding is the partitioning of model parameters, data, or computation across multiple devices or storage units.
- experiment trackingExperiment tracking is the systematic recording and organization of configurations, metrics, artifacts, and results from computational experiments.
- Rotary Position EmbeddingA rotary embedding encodes positional information by applying position-dependent rotations to neural representation components.
- stateA state is a representation of the situation in a decision process that provides the information relevant to selecting an action.
- policyA policy is a model or probability distribution that determines the actions or responses produced in a decision-making process.
- distillationDistillation is a model-compression technique in which a smaller student model learns to reproduce the behavior of a larger teacher model.
- Markov decision processA Markov decision process is a mathematical model for sequential decision-making in which an agent selects actions in states, receives rewards, and undergoes probabilistic transitions.
- vLLMvLLM is an open-source serving library for efficient inference of large language models.
- QA-LoRAQA-LoRA is a low-rank adaptation method that integrates quantization-aware operations and group-wise processing to support efficient low-bit adaptation.
- stochastic gradient descentStochastic gradient descent is an iterative optimization method that updates parameters using gradients estimated from individual examples or randomly selected small batches.
- zero-shot learningZero-shot learning is the ability to perform a task or recognize classes without task-specific examples during adaptation or inference.
- byte pair encodingByte pair encoding is a subword tokenization algorithm that iteratively merges frequent symbol pairs to form a vocabulary.
- transformer blockA transformer block is a repeated computational unit in a transformer composed of attention and feed-forward components with neural-network connections and normalization.
- CaptumCaptum is an open-source library for interpreting machine-learning model predictions through attribution and explainability methods.
- breadth-first searchBreadth-first search is a graph or tree traversal algorithm that explores all nodes at the current level before proceeding to the next level.
- residual connectionA residual connection adds a layer's input to its transformed output to facilitate optimization of deep neural networks.
- top-kTop-k selection is a selection operation that retains the k highest-scoring candidates.
- epochA training epoch is one complete pass through the training dataset during model optimization.
- LQ-LoRALQ-LoRA is a parameter-efficient fine-tuning method that decomposes a pretrained matrix into a quantized component and a high-precision low-rank component.
- mel spectrogramA mel spectrogram is a time-frequency representation of audio energy expressed on the perceptual mel frequency scale.
- ASHA schedulerThe ASHA scheduler is an asynchronous successive-halving algorithm that allocates resources preferentially to promising hyperparameter trials and stops poor trials early.
- CommitmentBankCommitmentBank is a natural-language inference dataset containing discourses whose final sentences express entailment, contradiction, or neutrality under entailment-canceling operators.
- Ray DataRay Data is a scalable data-processing library for machine-learning workloads within the Ray ecosystem.
- Ray TuneRay Tune is a Ray library for distributed hyperparameter tuning and experiment management.
- TorchTrainerTorchTrainer is a Ray training interface for distributing and managing PyTorch training workloads across workers and computational resources.
- needle in a haystack testThe needle in a haystack problem is the difficulty of locating a small amount of relevant information within a very long context.
- NoPENoPE is a transformer-layer design that omits positional encoding to provide unrestricted interactions across sequence positions.
- positional interpolationPositional interpolation is a technique that rescales or interpolates positional representations so a model can operate on sequences longer than those seen during training.
- feature attributionA feature attribution method assigns importance scores to input features to indicate their contribution to a model prediction.
- ModernBERTModernBERT is a modern encoder-only transformer language model designed to improve the performance and efficiency of BERT-style models.
- low-rank approximationA low-rank matrix is a matrix whose rank is substantially smaller than its number of rows or columns, enabling compact parameterization.
- paged optimizerA paged optimizer is an optimizer implementation that manages optimizer states in pages to reduce memory spikes and support movement between CPU and GPU memory.
- nonuniform quantizationNonuniform quantization maps values to discrete levels separated by variable-sized intervals adapted to the data distribution.
- post-training quantizationPosttraining quantization converts a pretrained model to lower-precision representations without additional model training.
- quantization-aware trainingQuantization-aware training retrains a model while simulating or applying quantized weights and activations so the model adapts to quantization effects.
- uniform quantizationUniform quantization maps values to discrete levels separated by equal-sized intervals across a numerical range.
- top-p filteringTop-p sampling generates each token by sampling from the smallest candidate set whose cumulative probability reaches a specified threshold.
- early stoppingEarly stopping is a training procedure that halts optimization when a validation measure stops improving for a specified interval.
- gradientA gradient is a vector of partial derivatives indicating how a function changes with respect to its parameters.
- transformersTransformers is an open-source software library for using pretrained transformer models across machine-learning tasks.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.
