Lesson 3 of 12 · What Is Generative AI?
Text, Image, Audio and Video Models
Generative AI beyond chat: how image generators turn noise into pictures, how speech, music and video models work, and what multimodal models are. With Python.
- 7 min read
- Beginner
- Reviewed
- The main kinds of generative model: text, image, audio, video and code
- What a modality and a multimodal model are
- How image generators turn random noise into a picture
- What each kind of model is useful for, and the risks that come with it
Not just chat
The chat assistant is the best-known kind of generative AI, but models now create almost every kind of media. The useful way to sort them is by what goes in and what comes out.
| Kind of model | Goes in | Comes out | Everyday examples |
|---|---|---|---|
| Language model | text | text | chat assistants, writing help, translation |
| Code model | text | code | code completion, "write me a script" |
| Image generator | text (and sometimes an image) | image | illustrations, product mock-ups, editing photos |
| Speech-to-text | audio | text | meeting transcripts, subtitles, voice typing |
| Text-to-speech | text | audio | audiobooks, screen readers, voice assistants |
| Music model | text | audio | background music, jingles |
| Video generator | text or image | video | short clips, animation |
Multimodal models
Early models did one thing: text in, text out. Today the leading assistants are multimodal.
You can photograph a broken bicycle part and ask how to fix it, upload a chart and ask what it shows, or talk to the assistant out loud. Inside, the image or sound is turned into the same kind of internal numbers as text, so one model can reason over all of it together.
How image generators work: from noise to picture
Most image generators today are diffusion models. The idea is surprisingly simple.
Training. Take millions of real images with captions. Add random noise to each, a little or a lot. Train the model to look at a noisy image plus its caption and predict the noise, so it can be removed. Do this billions of times.
Generating. Start with an image of pure noise. Ask the model, "this is a noisy picture of a cat on a sofa; what noise should I remove?" Remove some. Repeat, perhaps 20 to 50 times. A cat on a sofa appears.
The program below shows the generating half. Our "model" cheats: it already knows the picture it wants, a smiley face. A real model has to guess from what it learned in training. But the step-by-step clearing of noise is the same.
import random
# The picture we want: a 7 x 9 smiley face (1 = dark, 0 = light)
target = [
[0, 0, 1, 1, 1, 1, 1, 0, 0],
[0, 1, 0, 0, 0, 0, 0, 1, 0],
[1, 0, 1, 0, 0, 0, 1, 0, 1],
[1, 0, 0, 0, 0, 0, 0, 0, 1],
[1, 0, 1, 0, 0, 0, 1, 0, 1],
[0, 1, 0, 1, 1, 1, 0, 1, 0],
[0, 0, 1, 1, 1, 1, 1, 0, 0],
]
def show(image):
for row in image:
line = ""
for value in row:
if value > 0.66:
line += "#"
elif value > 0.33:
line += "+"
else:
line += "."
print(line)
# Step 0: start from pure random noise
random.seed(1)
image = []
for row in target:
noisy_row = []
for _ in row:
noisy_row.append(random.random())
image.append(noisy_row)
print("Step 0 (pure noise):")
show(image)
print()
steps = 4
for step in range(1, steps + 1):
# Each step removes some of the noise: move every pixel part of the way
# towards what the "model" thinks the picture should be
for r in range(len(image)):
for c in range(len(image[r])):
image[r][c] += 0.4 * (target[r][c] - image[r][c])
if step in (1, 2, 4):
print(f"After step {step}:")
show(image)
print()Try changing 0.4 to 0.1. Each step now removes less noise, so you need more steps. Real generators face the same trade-off: more steps give cleaner images but take longer.
Audio models
- Speech-to-text (transcription) turns recordings into text. It is mature and very accurate for clear speech in common languages.
- Text-to-speech reads text aloud in natural voices. Modern systems can copy a voice from a short sample.
- Speech-to-speech assistants listen and talk back directly, so a conversation flows like a phone call.
- Music models create songs or background tracks from a description such as "calm piano, rainy evening".
Video models
Video generators create short clips from a text description or bring a still image to life. They are the hardest of all, because the picture must stay consistent from frame to frame: a person cannot change shirt or gain a finger halfway through. They have improved quickly but are expensive to run, and clips are usually short.
Risks that come with realistic media
Common mistakes
Find the tasks that change modality: these need a model that handles more than text.
# Each task: (name, what goes in, what comes out)
tasks = [
("Summarise an article", "text", "text"),
("Describe a photo", "image", "text"),
("Turn a voice note into text", "audio", "text"),
("Draw a logo from a description", "text", "image"),
("Translate a sentence", "text", "text"),
]
# Print the name of every task where what goes in is a different
# modality from what comes out, one per line.
How does a diffusion model create an image?
Summary
- A modality is a type of data: text, image, audio, video or code.
- Multimodal models read and produce more than one modality.
- Diffusion models turn random noise into a picture, step by step, guided by the prompt.
- Audio models transcribe speech, speak text aloud and make music. Video models are the newest and hardest.
- Realistic media brings real risks, especially deepfakes.
Next: what generative AI is good at, and where it lets you down.
Finished reading? Tick it off to track your progress.