What you will learn in Build a Text-to-Image Generator (from Scratch)
With transformers and diffusions
Chapter by chapter
Chapter 8: CLIP: A model to measure the similarity between image and text
What you learn in chapter 8 →Chapter 13: New developments and challenges in text-to-image generation
What you learn in chapter 13 →Concepts explained in this book
- embeddingAn embedding is a numerical vector representation of an input or discrete item in a learned feature space.
- decodeA sequence decoder is a neural-network component that generates an output sequence from contextual representations and previously generated elements.
- encoderA sequence encoder is a neural-network component that maps an input sequence to contextualized representations for subsequent processing.
- latent spaceA latent space is a lower-dimensional representation space in which encoded data is represented before decoding or further generation.
- U-NetU-Net is an encoder-decoder neural-network architecture commonly used as the denoising backbone in diffusion models.
- diffusion modelA denoising diffusion probabilistic model is a diffusion generative model that samples through a probabilistic sequence of noise-removal steps.
- variational autoencoderA variational autoencoder is a generative neural model that encodes data into a lower-dimensional probabilistic latent representation and decodes that representation into reconstructed or generated data.
- transformer architectureA transformer architecture is a neural-network architecture that uses attention mechanisms to process relationships among elements in a sequence or other structured input.
- text-to-image modelA text-to-image model is a machine-learning model that generates images from textual descriptions.
- Vision TransformerA Transformer model that processes an image as a sequence of patch representations for computer-vision tasks.
- VQGANA vector-quantized generative adversarial network that combines discrete latent representations with adversarial and perceptual image modeling.
- positional embeddingA positional encoding is a representation added to sequence-element embeddings to convey their positions or ordering.
- attentionA neural-network mechanism that weights input elements according to their relevance when computing a representation or prediction.
- CLIPContrastive language-image pretraining is a training technique that aligns image and text representations by contrasting matching and nonmatching pairs.
- promptA text prompt is a natural-language instruction or description that specifies desired generated content.
- multi-head attentionAn attention mechanism that computes attention through multiple separate query, key, and value subspaces to capture different relationships simultaneously.
- denoisingA denoising process is a procedure that progressively removes noise from a data sample to produce a clean result.
- patchAn image patch is a spatially localized portion of an image represented separately in a grid or latent representation.
- codebookA codebook is a learned finite collection of discrete vectors used as representatives for continuous latent vectors.
- image tokenizationImage tokenization is the process of converting image content into a sequence of discrete visual tokens.
- autoregressive modelA process that produces an ordered output sequence one element at a time, conditioning each element on previously generated elements and available conditioning information.
- encoder-decoder transformerAn encoder-decoder transformer is a transformer model with an encoder that represents an input sequence and a decoder that generates an output sequence from that representation.
- residual connectionA direct link that transfers representations between corresponding layers or stages of a neural network.
- text encoderA text encoder is a neural-network component that maps natural-language text to a numerical representation for downstream conditioning or processing.
- latent diffusion modelA latent diffusion model is a diffusion model that performs forward and reverse diffusion in a compressed latent representation rather than directly in pixel space.
- VQGAN decoderA VQGAN decoder is the image-reconstruction component that maps discrete image tokens to an output image.
- CFG scaleCFG scale is a sampling parameter that controls the strength with which classifier-free guidance follows conditioning information.
- sequenceSequential data is data whose elements have an order that carries information about their meaning or interpretation.
- [CLS] tokenA class token, or CLS token, is a learned sequence element whose contextual representation supports sequence-level or image-level classification.
- image-text pairAn image-text pair is a paired example consisting of an image and an associated textual description or caption.
- scaled-dot product attentionScaled dot-product attention computes attention weights from scaled dot products between query and key vectors.
- tokenA token is a discrete unit produced by segmenting text, such as a word, punctuation mark, or subword.
- noise scheduleA sampling configuration component that determines how noise levels and transitions are applied across diffusion inference steps.
- ResNet50ResNet50 is a 50-layer residual convolutional neural network commonly used for image recognition and visual feature extraction.
- interpolationInterpolation is the construction of intermediate values or representations between specified endpoints by varying their contributions.
- masked attentionMulti-head self-attention that restricts each position from accessing subsequent positions in the sequence.
- classifier-free guidanceClassifier-free guidance is a diffusion-sampling technique that steers generation by combining conditional and unconditional predictions from the diffusion model itself rather than using an external classifier.
- cross-attentionAn attention mechanism that computes attention between decoder representations and representations from an encoded conditioning input.
- vector-wise quantizationVector quantization maps a continuous vector to a discrete representative selected from a codebook.
- beginning-of-sequence tokenA beginning-of-sentence token is a special sequence marker that indicates where a generated sentence starts.
- end of text tokenAn end-of-sequence token is a special marker indicating the end of a token sequence.
- latent imageA latent image is an image-like tensor represented in the compressed latent space of an image-generation model rather than directly in pixel space.
- next-token predictionNext-token prediction is a sequence-generation technique that predicts the next discrete token from preceding tokens and conditioning information.
- vector quantized variational autoencoderA vector quantized variational autoencoder is a variational autoencoder that represents inputs with discrete learned codebook vectors.
- training datasetA training subset is the portion of a dataset supplied to a model for learning its parameters or representations.
- Stable DiffusionStable Diffusion is a latent diffusion model for generating and editing images from text and other conditioning inputs.
- noiseNoise is random variation added to an image that obscures its original visual information.
- noise tensorA noise tensor is a tensor containing noise values with a specified shape, here serving as the starting sample for image generation.
- fine-tuningFine-tuning is adapting a pretrained model to a new task by updating selected parameters, often only the task-specific output layers.
- noisy imageA noisy image is an image formed by combining an underlying image with injected noise.
- resolutionImage resolution is the spatial dimensions and corresponding level of discrete visual detail represented by an image.
- min-DALL-EA compact Transformer-based text-to-image model that predicts discrete image tokens autoregressively from text.
- VQGAN encoderA VQGAN encoder is the image-processing component that maps an image to a sequence of discrete image tokens.
- transposed convolutionA transposed convolutional layer increases spatial resolution by applying a learned convolution-like operation that can expand spatial dimensions.
- discrete codeA discrete latent vector is a latent representation whose components are selected from a finite set of learned codebook vectors.
- feedforward networkA feed-forward network that applies the same transformation independently to each position in a sequence.
- shared representationA joint embedding space is a shared representation space in which different data modalities are encoded so that corresponding items have related representations.
- BART encoderA BART encoder is the component that transforms a text caption or prompt into an encoded representation for sequence generation.
- sequence predictionA prediction task in which a model generates or estimates elements of an ordered sequence.
- Transformer encoder layerAn encoder layer is a transformer block that combines self-attention and a position-wise feed-forward network, typically with normalization and residual connections.
- pretrained modelPretrained weights are model parameter values learned previously on another task or dataset and reused for later adaptation.
- CIFAR-10CIFAR-10 is a labeled image dataset containing color images divided into 10 classes for machine-learning evaluation and training.
- tokenizerA tokenizer is a text-processing component that segments a character string into discrete tokens or token identifiers.
- keyA key is an attention vector representing information against which a query is compared to determine relevance.
- queryA query is an attention vector representing the information whose relevance to sequence elements is being evaluated.
- valueA value is an attention vector whose information is combined according to attention weights.
- reconstruction lossA reconstruction loss measures the discrepancy between input data and the data reconstructed from its latent representation.
- batchingA batch is a group of training examples processed together in one model update or evaluation step.
- padding tokenA padding token is a special marker appended to shorter sequences so that sequences in a batch have equal length.
- max poolingMax pooling is a spatial downsampling operation that retains the maximum activation within each local window.
- Flickr 8k datasetThe Flickr 8k Dataset is a collection of 8,000 photographs, each paired with five human-written captions for image-captioning research.
- clean imageA clean image is an image containing the original visual signal without diffusion noise.
- encoder-only transformerAn encoder-only transformer consists of encoder layers that convert an input sequence into continuous vector representations.
- layer normalizationLayer normalization normalizes the activations within each example to stabilize neural-network computation and training.
- softmaxA function that converts a vector of real-valued scores into nonnegative values that sum to one.
- tokenizationTokenization is the process of splitting text into discrete tokens such as words, punctuation marks, or subwords.
- quantization lossA quantization loss measures the discrepancy between continuous latent vectors and their selected discrete codebook representatives.
- attention_maskA tensor or pattern that hides selected sequence positions from a model during processing or prediction.
- BARTBART is a denoising sequence-to-sequence transformer model whose encoder is bidirectional and whose decoder is autoregressive.
- DALL-EA text-to-image generative model that produces images conditioned on natural-language descriptions.
- evaluation datasetA validation set is a held-out dataset split used to assess model performance during training and select configurations or checkpoints.
- deep fakeA deepfake is synthetic or manipulated media generated or altered with machine-learning methods to impersonate or misrepresent real people or objects.
- DDIMA DDIM scheduler is a configuration component that determines the noise levels and time-step transitions for sampling with DDIM.
- tensorA tensor is a multidimensional numerical array used to represent data and intermediate computations in a neural network.
- label embeddingA label embedding is a learned vector or tensor representation of a class label supplied to a conditional denoising network.
- down blockA down block is a U-Net component that extracts features while reducing spatial resolution through convolutional and pooling operations.
- up blockAn up block is a U-Net component that increases spatial resolution through operations such as transposed convolution.
- bottleneck layerA bottleneck layer is the narrow intermediate representation connecting the contracting and expansive paths of an encoder-decoder network.
- deepfake detectionDeepfake detection is the analysis of digital media to determine whether it has been synthetically generated or manipulated using machine-learning methods.
- objective functionA loss function is a function that quantifies the discrepancy between a model's predictions and the desired outputs.
- image captioningImage captioning is the task of generating natural-language descriptions of image content.
- timestepA time step is a discrete stage in the diffusion process at which a particular noise level is applied.
- unconditional promptAn unconditional prompt is an empty text input representing the absence of a specific conditioning description.
- feature vectorA feature vector is a numerical vector whose components encode properties of an input or intermediate representation.
- linear noise scheduleA linear diffusion schedule is a noise schedule in which the noise parameter changes linearly across diffusion time steps.
- reconstructed imageA reconstructed image is an image recovered by decoding a compressed or latent representation.
- diffusersDiffusers is an open-source software library providing implementations and pipelines for diffusion models and their image-generation workflows.
- maskA mechanism that selectively blocks information from specified sequence positions during model computation.
- poolingA pooling layer aggregates values within local spatial windows to produce a reduced or transformed feature representation.
- timestep embeddingA time embedding is a learned vector or tensor representation of a diffusion time step supplied to a denoising network.
- token idA token ID is an integer identifier assigned to a token in a vocabulary.
- DALL-E miniDALL-E mini is an open-source project that replicates the text-to-image behavior of DALL-E.
- image-to-text generationImage-to-text generation is the creation of natural-language descriptions from visual input.
- cross entropy lossCategorical cross-entropy loss measures the discrepancy between predicted class probabilities and the ground-truth class in multicategory classification.
- accuracyAccuracy is the proportion of predictions that exactly match the corresponding ground-truth labels.
- contrastive learningContrastive learning is a representation-learning technique that brings related examples closer and separates nonmatching examples in an embedding space.
- contracting encoder pathA contracting path is the encoder-side portion of a U-Net that progressively reduces spatial resolution while learning increasingly abstract feature representations.
- expansive decoder pathAn expansive path is the decoder-side portion of a U-Net that increases spatial resolution and reconstructs an image from condensed features.
- attention weightA normalized attention score that determines how strongly a value contributes to an attention output.
- denoising modelA denoising model estimates or removes noise from a corrupted data sample.
- image selectionImage selection is the task of choosing the image that best matches a textual description from a collection of images.
- multimodalA generative model that processes or connects two or more data modalities, such as text, images, audio, or video.
- image-to-text transformerA transformer model that encodes an image and generates a natural-language description of it.
- AdamWAdamW is an adaptive gradient-based optimizer that decouples weight decay from the parameter update.
- decoder-only transformerA decoder-only transformer consists of decoder layers that autoregressively generate output sequences from preceding tokens.
- logitA logit is an unnormalized real-valued score assigned to a class before conversion into probabilities.
- downsamplingDownsampling is the reduction of the spatial resolution of a representation.
- geometric consistencyThe preservation of coherent spatial structure, proportions, and object geometry across objects, scenes, and viewpoints.
- geometric inconsistency problemThe geometric inconsistency problem is the difficulty of producing generated images whose spatial structure and geometric relationships are coherent.
- parameterA model parameter is a numerical value used by a model that is typically learned or adjusted during training.
- discriminatorA discriminator is a neural-network component that distinguishes generated samples from samples drawn from the target data distribution.
- perceptual lossA perceptual loss measures differences between images using features intended to reflect human visual similarity rather than only pixel-wise differences.
- biasModel bias is a systematic tendency in a model's outputs that reflects or amplifies unequal or stereotypical patterns associated with social groups or cultural contexts.
- environmental impactThe effects that an activity or technology has on the natural environment, including through resource and energy use.
- misinformationFalse or inaccurate information that is presented or circulated as factual, regardless of whether deception is intended.
- language modelA language model is a model that processes or generates human language, typically as sequences of text.
- generative modelingGenerative AI is a class of machine-learning models that creates new content resembling patterns learned from data.
- convolutional layerConv2d is a two-dimensional convolution layer that applies learned spatial filters to image-like tensors.
- adversarial trainingAdversarial training is a training procedure in which competing models are optimized against each other, typically with a generator producing samples and a discriminator judging them.
- linear layerA fully connected layer is a neural-network layer in which every output unit receives input from every unit in the preceding layer.
- generatorA GAN generator is a neural network that transforms random input noise into synthetic samples intended to resemble real data.
- VQ-VAE decoderA VQ-VAE decoder is the image-reconstruction component that maps quantized latent codes or their codebook vectors back to an image.
- top-k samplingTop-k sampling draws the next token from a probability distribution restricted to the k highest-probability candidates.
- out-of-vocabulary wordAn unknown token is a special marker representing a token not present in the model's vocabulary.
- attention matrixAn attention map is a matrix of attention probabilities showing how strongly tokens attend to one another.
- visual encoderAn image encoder is a neural-network component that maps an image to a numerical representation.
- quantized latent representationA quantized latent representation is a latent representation whose continuous vectors have been replaced by discrete codebook vectors.
- early stoppingEarly stopping is a training technique that halts optimization when a model fails to improve for a specified number of epochs.
- single-modal modelA unimodal model processes data within a single modality, such as text-only or image-only data.
- DistilBERTDistilBERT is a smaller and faster transformer-based language model distilled from BERT while retaining much of its language understanding capability.
- mean absolute errorMean absolute error, also called L1 loss, measures the average absolute difference between predicted numerical values and their target values.
- attention scoreAn attention score is a numerical measure of the relevance between a query and a key.
- geometryThe three-dimensional organization and shape of objects and their spatial arrangement in a scene.
- spatial informationThe relative positional or geometric arrangement between objects or parts of a scene.
- intellectual propertyLegal rights protecting creations of the mind, including artistic works and inventions.
- VisionEncoderDecoderVisionEncoderDecoder is a local model class that combines an image encoder with a text decoder for image-conditioned text generation.
- classifierClassification is the task of assigning an input to one or more predefined categories.
- transformer-based text-to-image modelA transformer-based text-to-image model generates images from text by modeling relationships between textual and visual token sequences with transformer architectures.
- StableDiffusionPipelineStableDiffusionPipeline is a Diffusers pipeline component that runs Stable Diffusion text-to-image generation from a prompt.
- cosine noise scheduleA cosine diffusion schedule is a noise schedule whose clean-image and noise weights vary over time according to a cosine-based function.
- image generationImage synthesis is the computational generation of new images from learned representations or specified conditions.
- conditioningConditioning information is auxiliary input supplied to a generative process to influence the characteristics of its output.
- probability distributionA probability distribution describes the possible values of a random variable and the probabilities associated with those values.
- normal distributionA normal distribution is a continuous probability distribution characterized by a bell-shaped density determined by its mean and variance.
- label maskingLabel masking is the probabilistic removal of class-label conditioning during training so a model learns both conditional and unconditional predictions.
- embedding blockAn embedding block is a neural-network module containing two linear layers with a GELU activation that transforms time-step or label inputs into shaped embeddings.
- categorical encodingA one-hot tensor represents each categorical value with a vector containing one active entry and zeros elsewhere.
- transformer blockA transformer block is a neural-network component that combines attention sublayers with a feed-forward network for sequence processing.
- PyTorch UnfoldPyTorch Unfold is a tensor operation that extracts sliding local blocks from an input tensor.
- Fashion MNISTFashion MNIST is a dataset of 70,000 grayscale images of clothing items such as shirts, shoes, and bags.
- classifier guidanceClassifier guidance is a diffusion-sampling technique that uses a separately trained classifier to steer intermediate samples toward a desired class or condition.
- computational footprintThe total computational resource requirement associated with operating a model or system.
- energy consumptionThe amount of electrical energy consumed by computing processes such as model training and inference.
- VQ-VAE generatorA VQ-VAE generator is the VQGAN component consisting of an encoder, a codebook, and a decoder that reconstructs images from discrete latent codes.
- LPIPSLPIPS is a learned perceptual image similarity metric that compares images using features extracted by pretrained neural networks.
- mean squared errorMean squared error is the average of the squared differences between predicted and reference numerical values.
- adversarial lossAn adversarial loss is a training objective that evaluates how convincingly generated samples resemble real samples in a generative adversarial setup.
- generative adversarial networkA generative adversarial network is a generative model trained through competition between a generator that creates samples and a discriminator that distinguishes generated samples from real data.
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.
