A text encoder converts a prompt into numerical embeddings that downstream models can use. In text-to-image generation, those embeddings describe the requested image and guide diffusion from noise toward an image. section 17.3
A text encoder contributes to generation in several connected steps:
- Tokenizes the prompt and embeds its tokens into a continuous representation. section 17.3.1
- Provides text embeddings alongside noisy images to guide the denoising model. section 17.3
- Can produce both a final prompt vector and a sequence representation for richer conditioning. section 17.3.1
- Maps prompts into a smooth space where intermediate embeddings can represent meaningful transitions between prompts. section 17.3.1
Conditioning Stable Diffusion with a prompt
A KerasHub TextToImage task uses a pretrained text encoder inside Stable Diffusion. Given “A NASA astronaut riding an origami elephant in New York City,” it encodes the prompt and generates an image; a negative prompt such as “blue color” steers generation away from that attribute. section 17.3

