What you will learn in Learn Generative AI with PyTorch
Chapter by chapter
Chapter 3: Generative adversarial networks: Shape and number generation
What you learn in chapter 3 →Chapter 11: Building a generative pretrained Transformer from scratch
What you learn in chapter 11 →Chapter 16: Pretrained large language models and the LangChain library
What you learn in chapter 16 →Concepts explained in this book
- discriminatorThe GAN component that learns to distinguish real training images or samples from fake generated ones.
- latent spaceA latent representation produced by the encoder and passed to the decoder for reconstruction or generation.
- generationA language-modeling task in which new text is produced without conditioning on a specific task label, here using a generic or empty prompt.
- transformer architectureThe internal design and structural organization of a Transformer model built around decoder blocks or self-attention components.
- tokenizationThe process of splitting text into discrete units such as characters, words, or subwords for modeling.
- attentionA neural sequence-processing technique that assigns learned weights to relationships between elements, including self-relationships, to model relevance across a sequence.
- generatorThe GAN component that maps latent inputs to synthetic samples intended to look like training data.
- training datasetThe source text examples used for model training, viewed here as material whose length and variation affect generation quality.
- decoder-only transformerA Transformer design that uses only decoder stacks for autoregressive generation.
- encoderAn encoder is a component that transforms input data into an encoded representation for subsequent processing, reconstruction, comparison, or transmission.
- token idA numeric identifier assigned to a token so it can be represented as an integer for model processing.
- embeddingA continuous numeric encoding that captures the meaning of an input sentence for downstream decoding.
- language modelA large language model trained beforehand on broad textual data and reused for downstream tasks.
- decodeDecoding is the process of transforming an encoded or internal representation into an interpretable or target-form output.
- positional embeddingA positional-encoding method that learns position vectors as parameters rather than using fixed formulas.
- arrayAn array with one or more dimensions, used here as the general definition of a tensor.
- classifierA task of assigning one of several discrete categories to text sequences.
- vocabularyThe number of distinct tokens available in a model's vocabulary.
- tensorA multidimensional numerical array used in PyTorch to represent model inputs, outputs, and intermediate values.
- MIDIA file containing musical performance data encoded according to the MIDI standard.
- masked attentionMasked attention is an attention mechanism in which a mask restricts which positions can influence each other, often preventing sequence positions from accessing future tokens.
- cross entropy lossA loss measure that compares predicted token distributions with the target next tokens for multiclass sequence prediction.
- feedforward networkA feedforward network is a neural network or subnetwork in which information flows from inputs toward outputs through successive computations without recurrent connections or cycles.
- residual connectionA neural-network connection that bypasses intermediate layers and passes earlier activations to later layers.
- decoder layerA Transformer building block composed of self-attention and feed-forward components, plus normalization and residual connections in this section.
- categorical encodingA vector representation with a single active entry used here to encode token or position identities before projection.
- MuseGANA music-generation GAN variant in this chapter that produces multidimensional representations of musical pieces for later conversion to MIDI.
- scaled-dot product attentionAn attention method that computes similarity between queries and keys with dot products, scales them, and uses the result to weight values.
- generateA function that converts a prompt to token indexes, generates more indexes with sample(), and converts the full sequence back to text.
- generate functionA function that turns a text prompt into token indexes, generates additional indexes by sampling, and converts the resulting sequence back to text.
- temperatureA sampling control parameter that scales the model’s output distribution before choosing the next token in text generation.
- variational autoencoderA generative model that learns an encoder-decoder latent-variable representation so it can reconstruct inputs and sample new outputs from latent space.
- multi-head attentionA self-attention variant that splits representations into multiple attention heads to capture different relationships in parallel.
- Kullback–Leibler divergenceA divergence measure used as a regularization term to encourage a latent-variable distribution to resemble a normal distribution.
- generative adversarial networkA generative adversarial network, a model family trained with a generator and discriminator to synthesize realistic data or transform data between domains.
- music TransformerA Transformer model in this chapter that is trained on music sequences and used autoregressively to generate new musical indexes.
- music TransformerA Transformer model in this chapter that is trained on music sequences and used autoregressively to generate new musical indexes.
- LSTMA recurrent neural network variant with long short-term memory units, mentioned here as an example of a deep learning model that cannot process raw text directly.
- machine translationThe task of automatically translating text from one natural language to another.
- parameterThe learned numerical parameters of a neural network model after or during training.
- music generationThe process of generating new musical event sequences from a trained model, here by extending a prompt of indexed music events.
- recurrent neural networkA neural network architecture for sequential data that processes inputs with loops so information can persist across time steps.
- subword tokenizationA partial word unit produced by subword tokenization, smaller than a whole word but larger than a character.
- transposed convolutionThe 2D computation performed by a transposed convolutional layer to expand an image or feature map.
- samplingA prediction strategy that samples next tokens according to predicted probabilities instead of always taking the maximum.
- U-NetA U-shaped convolutional encoder-decoder neural network with skip connections, used here to predict and remove noise during diffusion-based image generation.
- PyTorchA deep learning library used here for building and training neural networks, especially with dynamic computation graphs and GPU acceleration.
- GPT-2A decoder-only Transformer language model used here as the example model whose embeddings and positional encoding are being described.
- gradient penaltyAn added loss term that penalizes undesirable gradient behavior during GAN training to improve critic stability.
- adamAdam is an adaptive stochastic-gradient optimization algorithm that updates model parameters using moving estimates of the first and second moments of gradients.
- diffusion modelA generative model that learns to produce samples by progressively reversing a noising process over discrete time steps.
- labelThe reference target values used to supervise training, here the actual noise compared against the model’s prediction.
- text-to-image modelThe generative task of producing an image conditioned on a text prompt.
- softmaxAn activation that converts raw scores into a probability distribution over multiple classes or positions.
- tokenA discrete text unit produced by tokenization, such as a word, punctuation mark, or special character, used as an element of a sequence.
- CycleGANA GAN-family image-to-image translation model that learns to map samples between two unpaired visual domains while preserving content via cycle consistency.
- mean absolute errorA loss metric that averages the absolute difference between predicted and target values, used here for image reconstruction.
- autoencoderA neural network that learns to compress inputs into a latent representation and reconstruct them, used here for digit-image generation and reconstruction.
- from scratch implementationA development approach in which a model is implemented and trained directly rather than being treated as a prebuilt black box.
- evaluation datasetA held-out subset of data used to monitor training and tune model decisions without directly fitting parameters.
- layer normalizationA normalization technique that normalizes activations across features within each layer or sample.
- xThe input sequence of music-token indexes used to predict the next elements in this training example construction.
- xThe input sequence of music-token indexes used to predict the next elements in this training example construction.
- yThe output sequence of music-token indexes shifted one position right from x so the model learns next-element prediction.
- yThe output sequence of music-token indexes shifted one position right from x so the model learns next-element prediction.
- paddingA setting or operation that adds, fills, or ignores boundary or placeholder positions in tensor or sequence data.
- label arithmeticA conditioning technique that forms an intermediate label by weighted averaging two labels to smoothly vary a generated attribute.
- beginning-of-sequence tokenThe pair of special sequence markers that denote the beginning and end of a tokenized sequence.
- top-k samplingA decoding method that selects the next token from the K most likely candidates after truncating the distribution.
- conditional GANA GAN that conditions generation on auxiliary information such as class labels so the output can be steered toward a desired attribute.
- GPT modelA family of generative pretrained Transformer language models referenced here as the host family that Codex is integrated into.
- encoding arithmeticA latent-space manipulation method that adds and subtracts VAE encodings to synthesize new outputs.
- musical noteA musical pitch event encoded in the dataset as one of a fixed set of possible pitch values.
- promptThe chat message role that sets assistant behavior in the OpenAI chat-completions format.
- epochOne complete pass through the entire training dataset during model training.
- LangChainA Python library for building applications with large language models through tools, abstractions, and component chaining.
- UNKA special unknown-token symbol used to represent out-of-vocabulary words during tokenization and prompting.
- out-of-vocabulary wordAn out-of-vocabulary word or text unit is absent from a tokenizer’s or model’s available vocabulary and may be represented by a special unknown-token marker.
- exponential growth curveA curve whose values increase at an accelerating rate according to an exponential relationship.
- exponential growth curveA curve whose values increase at an accelerating rate according to an exponential relationship.
- convolutional layerA PyTorch convolution layer that applies learned 2D filters to an input tensor to produce feature maps.
- reconstruction lossThe loss term that measures pixel-level mismatch between an input image and its reconstruction in a VAE.
- Wasserstein distanceA distance measure used in Wasserstein GAN training to compare distributions and provide a smoother optimization signal than standard GAN losses.
- overfittingA training failure mode where the model memorizes training data too closely and generalizes poorly to new inputs.
- vector arithmeticThe manipulation of latent vectors by weighted averaging to interpolate between generated attributes in latent space.
- generative modelingA class of AI systems that create new content such as text, images, code, audio, music, or video rather than only classifying existing inputs.
- next-token predictionThe language-modeling objective of predicting the following token from the current and previous tokens in a sequence.
- musical measureA musical time unit that groups beats in a composition.
- JSB Chorales datasetA dataset of Bach chorales arranged as multitrack piano-roll music and used as training data for music generation models such as MuseGAN.
- strideThe step-size parameter that controls how far a convolutional operation moves and, in transposed convolution, how much upsampling occurs.
- train_epochA book-defined function that trains the model for one epoch.
- backpropagationA PyTorch call that computes gradients of the loss with respect to model parameters.
- conditional probabilityA probability of one variable given another, used here for discriminative prediction of Y from X.
- hyperparameterTraining or model settings chosen before fitting, such as layer counts, head counts, embedding size, vocabulary size, block size, and dropout rate.
- music21A Python library for analyzing, manipulating, and displaying symbolic music data such as notes and piano rolls.
- objective functionThe objective value minimized during training, here composed of reconstruction loss and KL divergence for the VAE.
- English-to-French translationThe cross-language text translation task from English into French.
- cycle consistency lossA loss term that penalizes failure to reconstruct the original input after translating it to another domain and back, used to preserve content in CycleGAN.
- denoisingThe process of removing noise from an image estimate one step at a time during generation.
- multitrack musicMusic represented as multiple separate tracks or voices that can be edited and processed independently.
- convolutional neural networkA neural network architecture using convolution operations, here applied to multidimensional music data to extract spatial features.
- queryAn attention query is a vector representation of the information sought by an input position, compared with key representations to determine which information to attend to.
- sequence predictionA learning setup where a model predicts the next element in an ordered sequence from earlier elements.
- end of text tokenA special end-of-sequence token used to mark completion of decoding or the end of a tokenized sequence.
- piano roll representationA grid-based representation of musical notes over time and pitch, commonly used to encode MIDI-like music for computation.
- transformersA software library for working with pretrained transformer models and tokenizers from Hugging Face.
- trainingThe iterative process of feeding data through a model, computing loss, and updating parameters.
- tensor shapeThe tuple of dimension sizes describing the structure of a multidimensional object.
- DataLoaderA PyTorch utility that wraps a dataset or iterable to provide batched access, optional shuffling, and iteration during training.
- interpolationThe technique of generating intermediate representations between two latent points to explore a smooth latent space.
- keyThe attention input that represents the searchable features used to match against a query.
- valueIn attention, a value is a vector representation of input content that is combined with other values according to attention weights to produce an output.
- logitAn unnormalized model output score produced before conversion to probabilities for sampling or selection.
- cross-attentionAn attention operation where queries come from one sequence or representation and keys/values come from another, enabling information transfer between them.
- batch normalizationA normalization technique that standardizes activations within minibatches to stabilize and speed neural-network training.
- kernel sizeThe spatial size of a convolutional kernel or receptive window applied to an input.
- pitchThe perceived highness or lowness of a musical sound, determined here by the note’s frequency and encoded by pitch numbers.
- DCGAN / deep convolutional ganA deep convolutional generative adversarial network architecture for image generation.
- note-on/note-off eventA musical event indicating that a note begins sounding in the performance encoding.
- time-shift eventA musical event in the encoding that advances the represented time between note events.
- velocityA musical performance attribute indicating how forcefully a note is played, represented as an event/value in the encoding.
- Wasserstein GANA GAN variant that uses the Wasserstein distance as its training objective to improve stability and provide a more informative critic score.
- timestepA discrete index into the diffusion/denoising schedule that determines how much noise is added or removed at a given stage.
- CLIPA multimodal Transformer model that learns aligned image and text representations for comparing and matching visual and textual inputs.
- linear layerA PyTorch layer that applies a learned linear transformation to its input.
- grayscale imageImages represented only by intensity values rather than color channels, used here as a simpler target for generation.
- encoding interpolationA technique for varying latent representations smoothly to generate intermediate decoded outputs between examples.
- accuracyThe fraction or percentage of predictions that match the true labels in a classification task.
- music pieceA musical work represented here as a sequence of musical notes and events for Transformer training.
- few-shot learningA prompting approach that provides exactly one example to condition a large language model on the task.
- musical eventA token-like symbolic unit representing a note or control information in a music sequence used for model training and generation.
- musical eventA token-like symbolic unit representing a note or control information in a music sequence used for model training and generation.
- sigmoidAn activation function that maps outputs into the range 0 to 1, used here to interpret the discriminator output as a probability.
- early stoppingA training control method that stops fitting when validation or other monitored performance no longer improves.
- byte pair encodingA subword tokenization method adapted from data compression that merges frequent character pairs to represent text as tokens.
- zero-shot promptingA prompting method that gives the model a task without any examples, relying only on instructions and prior knowledge.
- stepA subdivision of a musical bar used for sequencing rhythms, melodies, or notes.
- long-range dependencyA relationship between distant elements in a sequence whose interpretation depends on information far apart in the input.
- GPT-2XLA larger GPT-style decoder-only Transformer model used here as the comparison baseline for architecture size and parameter count.
- GPT-2XLA larger GPT-style decoder-only Transformer model used here as the comparison baseline for architecture size and parameter count.
- vanishing gradient problemA training failure mode in deep networks where gradient signals become too small to effectively update early layers.
- control messageA MIDI event that conveys performance control information such as note on/off timing and related parameters.
- tokenizerA text-processing component that splits text into tokens and converts text to a discrete token sequence for modeling.
- XLMA pretrained multilingual language model used here as a tokenizer because it handles multiple languages well.
- input-output pairA paired training example consisting of an input sequence and its shifted target sequence for next-token prediction.
- convolution kernelA learned convolutional kernel whose weights slide across local input regions to produce feature responses.
- ReLUA piecewise linear neural-network activation function that outputs zero for negative inputs and the input value for nonnegative inputs.
- DALL-EA text-to-image generative model that produces images from textual descriptions.
- GELUA smooth activation function used in neural networks to transform layer outputs and improve model performance.
- Oxford Flowers datasetA flower-image dataset used as training data for diffusion-model examples.
- multicategory classification modelA supervised neural network model that assigns each input to one of more than two discrete classes.
- argmaxArgmax is an operation that identifies an argument, position, or index at which a function or collection attains its maximum value.
- model architectureThe internal design and structural organization of a neural model, here referring to the overall layout of an autoencoder.
- multimodalA generative model that accepts more than one data modality, such as text plus images or audio, as input.
- query, key, and valueThe three attention inputs that represent what to match against, what features are matched on, and what content to aggregate.
- discriminative modelA model that learns to predict labels from inputs by estimating conditional probabilities and decision boundaries between classes.
- feature mapAn intermediate activation map in a neural network whose spatial resolution can be increased or preserved by convolutional operations.
- chordA combination of musical notes sounded together, here treated as one of the musical factors to control in generation.
- grooveThe rhythmic feel or swing of music that gives it motion and makes it feel compelling to move with.
- melodyThe sequence of pitched notes that forms the tune of a musical piece, here one of the controlled generation factors.
- styleA musical stylistic attribute that influences the character of generated pieces, distinct from the earlier visual-use sense.
- parallelismA training approach that computes multiple sequence elements simultaneously rather than strictly sequentially.
- encoder-decoder architectureAn encoder-decoder architecture is a model design in which an encoder transforms input into an intermediate representation and a decoder uses that representation to produce output.
- probabilistic vectorA latent representation whose values parameterize a probability distribution rather than a single deterministic code.
- probabilistic vectorA latent representation whose values parameterize a probability distribution rather than a single deterministic code.
- DDIMSchedulerA scheduler class used to control diffusion-step timing and denoising progression in a diffusion model.
- DDIMSchedulerA scheduler class used to control diffusion-step timing and denoising progression in a diffusion model.
- label smoothingA training technique that replaces one-hot target labels with softened target distributions to reduce overconfidence and improve generalization.
- OpenAI APIAn external programming interface used here to request text-to-speech conversion from OpenAI’s service.
- resolutionThe pixel dimensions of an image, used here to compare lower- and higher-resolution generated images.
- optimizationAn algorithm that updates model parameters to reduce loss during training.
- computation graphA directed graph of mathematical operations and data flow used to compute gradients in deep learning.
- octaveThe distance between one level of musical pitch and the next, where frequencies double from one octave to the next.
- performance-based representation of musicA music encoding that represents a piece as a sequence of performance events while preserving details such as timing and velocity.
- zero paddingThe addition of zero-valued borders around an input to control convolution output size.
- noiseRandom perturbation added to an image in a diffusion or denoising setup, which the model learns to predict and remove.
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.
