AI basics › From statistics to AGI
What is generative AI? How AI makes text, images, and sound
What generative AI is, how it differs from models that classify, how text and image generators work, why one question gets different answers, and the risks.
Perhaps you first met the words generative AI in a chat window that drafted an email for you, or in an app that turned a single sentence into a picture. Two releases in 2022 helped the term spread. On August 22 that year, Stability AI publicly released the image model Stable Diffusion for anyone to download and use (announcement). Then on November 30, OpenAI opened ChatGPT as a free research preview (Introducing ChatGPT).
Put in one sentence, generative AI is AI that makes new text, images, sound, video, or code that resembles the data it learned from. The Generative AI Profile that the US National Institute of Standards and Technology (NIST) published in July 2024 describes it in much the same way. Borrowing the definition in US Executive Order 14110, it calls generative AI “the class of AI models that emulate the structure and characteristics of input data in order to generate derived synthetic content” (NIST AI 600-1). The series “From statistics to AGI” reaches its sixth part here. The previous part stepped back to look at the field of AI as a whole, so this time we’ll look closely at the branch of it you’ve probably heard about most.
Models that sort and models that make
Much of the machine learning you meet day to day is discriminative. A discriminative model looks at an input and picks an answer, such as whether an email is spam or what a house will sell for, so it only needs to learn where the line between answers falls. A generative model, on the other hand, learns what the data itself looks like and which shapes are common or rare. That’s why it can draw new examples that resemble the data. If a discriminative model is an expert who can tell a cat photo from a dog photo, a generative model is closer to a painter who can paint a cat nobody has seen before.
The two terms are older than the current boom. In 2001, Andrew Ng and Michael Jordan described generative classifiers as learning how inputs and labels occur together, and discriminative classifiers as learning the label for an input directly (Ng and Jordan, 2001). The models they compared, naive Bayes and logistic regression, were ordinary classifiers, so generative is really a word about what a model learns.
Four ways to make something new
Of the many ways to build a generative model, here are four worth knowing by name, each with a key paper you can read yourself.
| Approach | How it makes something new | Paper |
|---|---|---|
| Autoregressive language model | Predicts the next token, adds it, and repeats | Brown et al., 2020 |
| Diffusion model | Learns to undo noise added step by step, then cleans up pure noise a little at a time | Ho et al., 2020 |
| GAN | A generator learns by trying to fool a discriminator that tells real from fake | Goodfellow et al., 2014 |
| VAE | Learns to squeeze data into a short list of numbers and expand it back, then expands new lists | Kingma and Welling, 2013 |
A token is a small piece of text, often a word or part of a word. The GPT-3 paper introduces GPT-3 as an autoregressive language model with 175 billion parameters, the numbers a model adjusts as it learns. For diffusion models, Ho and colleagues showed high-quality image results, and Stable Diffusion describes itself as a kind of text-to-image diffusion model (CompVis). A GAN uses both branches from the previous section, a model that makes and a model that tells apart.
Watching a small model pick its next word
Text generation is the easiest of these to run yourself. I used SmolLM2-135M-Instruct, a small open model with 135 million parameters. It’s released under the Apache 2.0 license (model card), and since its weights file is about 270 MB, it runs comfortably on a laptop CPU. The model card says it mainly understands English, so I asked it in English to describe the sea in one sentence. First, let’s see what the model has in mind for the very next word.
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
name = "HuggingFaceTB/SmolLM2-135M-Instruct"
tok = AutoTokenizer.from_pretrained(name)
model = AutoModelForCausalLM.from_pretrained(name)
chat = [{"role": "user", "content": "Describe the sea in one sentence."}]
inputs = tok.apply_chat_template(chat, add_generation_prompt=True,
return_tensors="pt", return_dict=True)
# A score for every token that could come next
with torch.no_grad():
logits = model(**inputs).logits[0, -1]
print("vocabulary size:", len(logits))
for t in [0.5, 1.0, 2.0]:
probs = torch.softmax(logits / t, dim=-1) # temperature divides the scores
top = probs.topk(5)
pairs = [f"{tok.decode(i)!r} {p:.3f}" for p, i in zip(top.values, top.indices)]
print(f"T={t}:", " | ".join(pairs))
vocabulary size: 49152
T=0.5: 'The' 0.961 | 'A' 0.037 | '"' 0.000 | 'In' 0.000 | 'It' 0.000
T=1.0: 'The' 0.781 | 'A' 0.153 | '"' 0.009 | 'In' 0.008 | 'It' 0.006
T=2.0: 'The' 0.122 | 'A' 0.054 | '"' 0.013 | 'In' 0.012 | 'It' 0.011
The model doesn’t answer with a word straight away. It gives a score to every one of the 49,152 tokens it knows, and a function called softmax turns those scores into probabilities that add up to 1. Temperature is the number the scores are divided by just before that step. At T=1.0, where the scores are left as they are, ‘The’ gets 78.1%. At T=0.5 the gaps between the scores widen and it climbs to 96.1%, while at T=2.0 the gaps shrink and it drops to 12.2%. At T=2.0 the top five together hold only about 21%, so the other 79% or so is spread across the remaining 49,000-odd tokens.
Writing a sentence is just this step repeated. The model picks one token, appends it to the input, and scores every token again. Always picking the top candidate is called greedy decoding, and since turning the temperature all the way down ends up there, I’ve labeled it T=0 below. Drawing a token at random in proportion to its probability is called sampling, and according to the Transformers generation strategies guide, the default is greedy search.
def answer(**settings):
out = model.generate(**inputs, max_new_tokens=40, **settings)
return tok.decode(out[0, inputs["input_ids"].shape[1]:], skip_special_tokens=True)
print("T=0:", answer(do_sample=False))
print("T=0:", answer(do_sample=False))
for seed in [1, 2, 3, 1]:
torch.manual_seed(seed) # fix the random draws
print(f"T=1.0, seed {seed}:", answer(do_sample=True, temperature=1.0, top_k=0))
T=0: The sea is a vast, mysterious, and awe-inspiring body of water that stretches across the globe, teeming with life and mystery.
T=0: The sea is a vast, mysterious, and awe-inspiring body of water that stretches across the globe, teeming with life and mystery.
T=1.0, seed 1: The sea is a massive, underworld sea where people—and animals—inhabit unending storms that rage through the ancient blue, carrying sounds of the North Atlantic and imposing malevolent forces.
T=1.0, seed 2: The waves roll gently against the shore, creating a kaleidoscope of colors and sensations that reflect the Phoenician influence on shaping the Mediterranean.
T=1.0, seed 3: A calming and serene place with a shimmering blue color, resembling the waves of a given area.
T=1.0, seed 1: The sea is a massive, underworld sea where people—and animals—inhabit unending storms that rage through the ancient blue, carrying sounds of the North Atlantic and imposing malevolent forces.
The greedy runs gave the same sentence both times. Sampling at T=1.0, on the other hand, gave a different sentence for each seed, and with seed 3 the first pick was ‘A’, which had a 15.3% chance in the first step. A seed is the starting number for the computer’s random draws, and the same seed gives the same sequence of draws. That’s why seed 1, used a second time, gave a sentence identical to the first down to the last character. There’s one more detail. When sampling, Transformers 5.20.2 draws only from the 50 most likely tokens unless told otherwise, so I set top_k=0 to turn that limit off and leave the effect of temperature alone.
So when a chat assistant answers the same question a little differently each time, sampling is one of the reasons. A lower temperature makes the answers more consistent, but that doesn’t guarantee they’re right. The seed 2 sentence smoothly brings up a Phoenician influence on the Mediterranean. Still, the model only picked likely words, and nothing in the process checks whether what they say is true.
Multimodal models, and where LLMs fit
A modality is a kind of data, such as text, images, sound, or video, and a multimodal model handles two or more of them. The GPT-4 Technical Report, published in March 2023, describes GPT-4 as a multimodal model that takes image and text inputs and produces text outputs (OpenAI, 2023).
Large language models, or LLMs, also sit inside this picture. An LLM is a language model trained on a vast amount of text to predict the next token, and the same report says GPT-4 was pre-trained to predict the next token in a document. It’s what the small model above did, on a much larger scale. In other words, LLMs are the branch of generative AI that makes text, and generative AI also has branches that make images, sound, and video.
What it’s good for, and where it fits less
The uses follow the kinds of data. With text, people draft, summarize, translate, and ask questions. With images, they make illustrations from a sentence or edit part of a photo. Code is text too, so language models continue code, explain it, and even write tests. On the sound side, WaveNet came out in 2016. It builds an audio waveform one sample at a time from the samples before it, and listeners rated it more natural than the best existing systems of its time (van den Oord et al., 2016).
Generative AI often fits well when many answers are acceptable and a person checks the result, as with drafting, brainstorming, or code that tests can verify. It fits less well when there’s one right answer that’s hard to check, such as an exact figure, a citation, or a medical judgment. The NIST profile sees it similarly. It says false content is most often a problem for text, while for sound, images, or video, making up things that aren’t factual can be exactly what you want.
Risks and open questions
Many of the questions around generative AI haven’t been settled, so I’ll stick to what the sources say.
The first is hallucination. NIST calls it confabulation, meaning erroneous or false content that a system presents confidently. Its explanation is that generative models produce outputs that approximate the statistical distribution of their training data, which can give accurate text but can also give text that is wrong or contradicts itself.
Copyright splits into two questions. One is about the works a model learns from and outputs that resemble them, and NIST wrote in 2024 that how generative AI relates to copyright is still being debated in legal fora. The other is whether the output itself can be protected. In January 2025, the US Copyright Office concluded that copyright does not extend to purely AI-generated material and that prompts alone do not currently give enough control (Copyright Office, Part 2). Whether a person’s contribution is enough, it says, has to be judged case by case. Of course, that’s the US view, and other countries may draw the lines differently.
Deepfakes are, in NIST’s words, synthetic audiovisual content and photorealistic images. The profile explains that multimodal models make realistic deepfakes possible, and it gives the example of a synthetic image of a blast at the Pentagon that went viral and briefly caused a drop in the stock market. Nonconsensual intimate imagery is on its list of harms as well.
Privacy is the last. In a 2020 paper, Nicholas Carlini and colleagues pulled hundreds of verbatim passages out of GPT-2’s training data just by querying the model (Carlini et al., 2020). Among them were names, phone numbers, and email addresses that had been public online, and the attack worked even on passages that appeared in only one document of the training data.
If you’d like to try it
If you’d like to try it, install torch and transformers with pip and run the two code blocks above in order. Then change the question, the temperature, and the seed one at a time and watch how the answers change. The Transformers guide above covers decoding strategies in more detail, and the NIST profile goes through twelve risks one by one. The next part of the series turns to AGI, the goal of an artificial general intelligence that can take on as wide a range of work as people do. I ran the examples above on October 27, 2026, on macOS using the CPU, with Python 3.13.12, PyTorch 2.14.1, and Transformers 5.20.2.
AI tools helped with the research for this post.