Published December 23, 20221:06:4714 fact-checks

Anton Teaches Packy AI | E4 | Latent Diffusion Models

Anton Troynikov walks Packy through the latent diffusion paper behind Stable Diffusion, from noise and guidance to artists’ claims for attribution.

Chapters

Quotes

  • On the pace of AI

    “And this is one of the things that really made me feel like, okay, the field is accelerating, because sitting here today it kind of feels like latent diffusion models are like five years old.”

    Anton TroynikovRead from 03:09
  • On what a computer "sees"

    “So pure static to a computer is the same thing as a picture of a puppy.”

    Anton TroynikovRead from 29:32
  • On the fight with artists

    “What matters here is: definitely this model requires artists’ work to exist and work well. And that hasn’t been acknowledged.”

    Anton TroynikovRead from 47:42
  • On stricter copyright

    “If you want stronger copyright protection for derivative works, you’re like, cool, you never get to draw a picture that kind of maybe looks like a Marvel character ever again.”

    Anton TroynikovRead from 48:04
  • On the real AI danger

    “I don’t really believe in a paperclip-maximizing evil overlord, for a variety of reasons — we might have that conversation at some point in the future. But I really do believe in the destabilizing effect of new media technologies, because we’ve seen that historically, as we’ve talked about before, and this is a new media technology.”

    Anton TroynikovRead from 50:12
  • On generative AI at the end of 2022

    “I think these are neat novel toys right now, but realistically, nobody’s figured out how to build something valuable yet.”

    Anton TroynikovRead from 59:00
  • On who will make money from AI

    “But the compute providers kind of win in every direction here. If you own GPUs, you’re probably going to be able to make money from them.”

    Anton TroynikovRead from 59:57

Summary

Anton Troynikov takes Packy McCormick through the latent diffusion paper behind Stable Diffusion: an autoencoder compresses the image, and a U-Net steered by the prompt through attention removes noise in a small latent space, which makes the model cheap to train and light enough to run at home. Along the way the hosts cover the guidance scale, textual inversion and DreamBooth, and Anton argues that artists have a fair claim to attribution and that the real dangers are stricter copyright and a destabilized media, not an evil AI. They close on who built Stable Diffusion, what it cost, and who will profit from the boom — in Anton’s view, first of all whoever owns the GPUs.

Advice

  1. Don’t cut junior hiring because of AI: it takes the boilerplate, but seniors grow out of juniors, and AI can become their teaching tool.

  2. When AI reaches your profession, don’t fear it — be ready to learn: how you earn a living will change, but technology remains a tool in human hands.

  3. Look for small improvements to methods that already work: researchers rarely go back to them, and even a student with one computer can contribute.

  4. When arguing with artists about generative AI, don’t hide behind technicalities like "the model doesn’t composite images": the model wouldn’t exist without their work, and that needs acknowledging.

Mentioned

  • Chroma00:00Packy invested in Anton’s company; over the episode Anton explains that Chroma studies how training data shapes generation and promises to show its attribution work.
  • Attention Is All You Need00:34The transformer paper from the first episode: Anton compares latent diffusion’s efficiency gain to it, and Packy, spotting attention blocks in the diagram, quips "attention is all you need."
  • High-Resolution Image Synthesis with Latent Diffusion Models01:08The paper of the episode: Anton explains how moving diffusion into a compressed latent space made image generation cheap.
  • Stable Diffusion01:30Anton calls its open release a watershed: anyone, not just Google or OpenAI, could have a generative model.
Show 53 more mentionsShow fewer mentions
  • DALL·E 201:30Anton places it next to Stable Diffusion as the same kind of model, and tells Packy that consumer apps are rarely built on it because it’s closed.
  • Google Brain01:58Anton lists it among the labs whose resources you used to need to have a generative model of your own.
  • Google DeepMind01:58Anton names DeepMind among the big labs whose monopoly the open Stable Diffusion broke.
  • OpenAI02:34Anton recalls that before Stable Diffusion you had to try models through OpenAI’s Playground and API, and later discusses its Shutterstock deals and secrecy about costs.
  • DreamBooth: Fine Tuning Text-to-Image Diffusion Models for Subject-Driven Generation03:37Anton calls it the year’s other big event and recalls waking Jeff with messages about it; avatar services are built on DreamBooth.
  • Chinchilla04:51Anton recalls the second episode’s conclusion: models are undertrained, so efficiency gains go into more training.
  • DALL-E05:49Packy asks about the first DALL-E, and Anton describes it as a "traditional" bottleneck model without diffusion.
  • CLIP (Contrastive Language–Image Pre-training)08:22Anton explains CLIP as a model that pulls image and caption vectors together, and blames noise in its data for "fried" images at high guidance.
  • The New York Times10:39Packy asks whether captions come from newspaper-style photo captions, and later recalls how the paper at first ignored ChatGPT.
  • BLIP (Bootstrapping Language-Image Pre-training)11:50Anton cites the Salesforce model as an attempt to caption images that have no captions.
  • Salesforce12:21Packy wonders why Salesforce is involved, and Anton calls its AI research strong and forward-thinking.
  • MetaMind12:22The startup whose acquisition, Anton says, gave Salesforce a strong AI team.
  • Richard Socher12:22MetaMind’s founder, whom Anton mentions to explain where Salesforce’s AI research comes from.
  • CodeGen12:22Salesforce’s code model, which Replit uses, according to Anton.
  • Replit12:22Anton cites it as a user of Salesforce’s code model.
  • The Box: How the Shipping Container Made the World Smaller and the World Economy Bigger14:54Anton recommends the book on containers as a case where automating ports led to labor shortages instead of unemployment.
  • Marc Levinson14:54Author of The Box, which Anton recommends.
  • OpenCLIP25:54Anton says Stable Diffusion switched to this open replacement for CLIP, trained on LAION.
  • LAION (Large-scale Artificial Intelligence Open Network)25:54Anton names the data set Stable Diffusion was trained on: nobody asked the artists in it, and the hosts plan to discuss its history next time.
  • John Searle30:54Anton compares generation to Searle’s Chinese room: the computer outputs numbers without understanding them.
  • Lensa AI37:46Packy asks how Lensa paints avatars from selfies; Anton says almost all such services use DreamBooth and doubts Lensa’s success will last.
  • An Image is Worth One Word: Personalizing Text-to-Image Generation using Textual Inversion38:13The first of the two personalization methods Anton walks through; he says it fine-tunes the model, though in fact the weights stay frozen.
  • Jeff Huber39:29Chroma’s co-founder, whom Anton bombarded with messages about DreamBooth at 4 a.m. San Francisco time.
  • Instagram45:59Anton cites it as a platform that uses people’s work but doesn’t yet generate its own photos.
  • Twitter45:59Like Instagram, Anton says, Twitter doesn’t generate images from what artists post.
  • ArtStation45:59Anton: the artists’ portfolio site doesn’t "commission 50 more" from their work, unlike generative models.
  • Unsplash46:30Packy cites it as an example of free photos where crediting the author is always easy.
  • Jürgen Schmidhuber46:45Anton jokes that Schmidhuber will show up at your talk and claim the idea came from his old work, to show how much attribution matters in science.
  • The Walt Disney Company48:04Only Disney and its lobbyists would win from a stricter law on derivative works, Anton says.
  • Marvel Entertainment48:04Under a strict law, Anton says, you couldn’t draw anything resembling a Marvel character.
  • Digital Millennium Copyright Act (DMCA)49:17Anton cites the law as an example of the copyright tightening he doesn’t want.
  • Nick Bostrom50:12Anton doesn’t buy Bostrom’s paperclip maximizer: the real AI danger, he argues, is destabilization by new media.
  • Shutterstock52:53Anton mentions OpenAI’s deals with Shutterstock for DALL-E training images.
  • Ludwig-Maximilians-Universität München52:53Anton names the Munich university as the lead author of the latent diffusion paper.
  • Universität Heidelberg52:53Anton names IWR in Heidelberg among the paper’s authors.
  • Runway52:53The company that did the research together with the universities, Anton says.
  • Stability AI52:53Stability AI paid for the compute to train Stable Diffusion, Anton says, and its openness set off the wave of apps.
  • GPT-354:01Packy asks what GPT-3 cost to train; Anton says "many millions" and suggests backing it out from Azure usage.
  • Microsoft Azure54:27Anton suggests estimating OpenAI’s training costs from how many Azure GPUs were left for other customers.
  • Midjourney55:30Anton thinks Midjourney was underway before Stable Diffusion, and later passes on rumors that it’s doing very well without outside money.
  • ChatGPT57:56Anton gets real use out of it, Packy uses it to decode terms, and the hosts expect people to show it to their families over the holidays.
  • CarperAI57:56Anton cites the Stability AI lab as proof that many will build open versions of InstructGPT and ChatGPT.
  • Training language models to follow instructions with human feedback57:56Anton mentions it among the OpenAI models Stability AI wants open equivalents of.
  • Codex57:56Another OpenAI model that Stability AI wants to release an open version of, Anton says.
  • Riffusion58:13Anton describes the fresh attempt to apply diffusion to music through spectrogram images.
  • Whisper58:20Anton notes that Whisper also treats a spectrogram as an image, only with a transformer.
  • Lambda1:00:47Anton jokingly suggests investing in Lambda Labs, since compute providers win either way.
  • Amazon Web Services1:00:49Packy asks how much of startups’ value AWS captured; Anton replies that without AWS that value wouldn’t exist.
  • iPhone1:02:07AI hasn’t gone mainstream yet, Anton says, unlike the iPhone, after which everyone started talking about smartphones.
  • Kevin Roose1:02:32Packy cites his episode on ChatGPT as a sign that word was spreading beyond tech Twitter.
  • The Daily1:02:32The New York Times podcast where, Packy recalls, Kevin Roose did a whole episode on ChatGPT.
  • GitHub Copilot1:03:31Anton says he doesn’t ask Copilot to write code but to suggest which API functions fit.
  • TikTok1:06:17Anton says Lensa blew up on TikTok, which is why he doubts it will last.

Transcript

01Why this paper set off the image boom

The open release of Stable Diffusion, built on this paper, showed you could have your own generative model without Google’s or OpenAI’s resources.

Welcome to Anton Teaches Packy AI, episode four. For those of you who are just joining us, the whole point of this is that Anton is deep in the weeds building and researching and doing all of the things that I just get to talk about in the world of AI. And I’m really curious, but when I read these papers, I have no idea what’s going on. So we had a Twitter back-and-forth — I’m an investor in Chroma,1Chroma is Anton’s company, founded in 2022 with Jeff Huber. At the time it was building tools to understand how data shapes a model’s behavior; since 2023 it has been known for its open-source vector database for AI applications. Anton’s company — we had a Twitter back-and-forth when I said that I had no idea what I was looking at, and he generously offered to explain what was going on in all of these papers that I keep hearing about.

And this is the result. And so we’ve done Transformers,2The first episode of the series (November 7, 2022) covered Google’s 2017 paper "Attention Is All You Need," which introduced the transformer architecture. which feels like maybe the foundation — pun intended, now that I know what that means3A pun on foundation models, the term Stanford researchers coined in 2021 for large models trained on vast data and adaptable to many tasks, such as GPT-3. arXiv — foundation of a lot of what we’re talking about in AI these days and a lot of the advances. And we’ve talked a lot about the language side of things. Today we’re moving over to the image side of things: the DALL-Es, the Stable Diffusions, the Midjourneys of the world. And today we’re doing a paper called Resolution Image Synthesis with Latent Diffusion Models. It is more exciting than it sounds, I promise.

High-Resolution Image Synthesis. That’s important.

Wow. Hi. See, this is my role. I’m the dumb one on the call, and Anton gets to explain what’s actually going on. That was a transcription error, a human error, which we won’t have many of in the future. But High-Resolution Image Synthesis with Latent Diffusion Models. Paper’s from April 2022,4Fact-checkNot so: the first version of the paper went up on arXiv on December 20, 2021. A second version, for CVPR 2022, followed in April 2022 — that’s the date Packy sees on the page. arXiv so a recent paper. Anton, what’s going on in this paper?

Yeah, this is a really great paper. This is the thing behind all of the recent generative image hype, which is pretty much everywhere. And DALL-E 2 and Stable Diffusion, which is based on this high-resolution latent diffusion paper, came out roughly the same time.5Fact-checkNot so: OpenAI unveiled DALL-E 2 on April 6, 2022, while Stable Diffusion was released publicly on August 22, more than four months later. But DALL-E 2 stayed behind a waitlist until September 28, so the general public got both at almost the same time. OpenAI It almost kind of felt like the open-sourcing of Stable Diffusion, which is a model of this type that we’re going to discuss, almost scooped OpenAI. And I think that that was a really — that’s like a watershed moment.

I’ve said it before, but I feel like the open-source release of Stable Diffusion really kicked off this idea that you could have your own generative model without being Google Brain6Google Brain — Google’s AI research group, where the transformer was invented in 2017. In 2023 it merged with DeepMind to form Google DeepMind. or OpenAI or DeepMind. You could just have one, right? If you had reasonable amounts of resources. And so it’s important for that reason. And the other reason that it’s really important is, before, a lot of this stuff was fairly gatekept, but with Stable Diffusion, you could just try it. An ordinary person can go to a website and just try it.

You didn’t have to go through OpenAI and sign up through Playground7Playground — OpenAI’s web sandbox where, from 2020, you could try GPT-3 and tune request settings. Before ChatGPT it was the main way to try OpenAI’s models without writing code, and access at first came through a waitlist. and play with the API. You could literally just go to a website and type text into a box. And what’s cool about it is a lot of people very quickly wrapped it up in more user-friendly ways to just let people play with it. And of course, since then it’s also generated a lot of controversy, because it allows you to mass-produce some sort of media at scale. And as we discussed last time, it produces a destabilizing effect.8The destabilizing effect came up in the second episode, on Chinchilla: Anton compared text and image generators to the printing press and other mass media technologies that first shake societies up. And this is certainly one of two big impactful results in AI this year.

And this is one of the things that really made me feel like, okay, the field is accelerating, because sitting here today it kind of feels like latent diffusion models are like five years old. But actually they came out, I don’t know, several months ago.

When I saw on the side that it says April 2022, I was like, no way. It does feel like we’ve just been living with this for a while. You’re used to the image styles almost that you get from the diffusion model. So it’s wild that it has been eight months since the paper was published.

It’s nuts. And I think the other big thing that came out on top of this was DreamBooth,9DreamBooth — a way to fine-tune a text-to-image model on a few photos of a specific person or object (Google, August 2022). Anton explains it later, around the 38-minute mark. and we’ll talk about that along the way as well. Because pretty much as soon as these came out, people were like, well, how can I do more stuff with these? How can I make it do more of the stuff that I want it to do? And then people very quickly raced ahead. So yeah, let’s get into it. Let’s talk a little bit about what it is, how it works, a little bit of the history here — what it took to get here, I think, is a really interesting question.

02Before latent diffusion

The paper’s core idea is not to spend compute on pixel-level detail that people can’t see.

I’m going to try to boil it down and do my "did I read this paper at all correctly," which is: my understanding is that previous attempts kind of traded off image quality and the computational cost, or how much compute you had to throw at these things. And latent diffusion kills the trade-off by moving from the pixel space to the latent space.10Latent space — a compressed representation of data that a model learns on its own: each image becomes far fewer numbers than it has pixels, while its meaning and shape survive. And as an outsider, I would think if you’re moving away from the pixels, you lose image quality, but there’s a bunch of kind of useless information at the pixel level, and when you move into latent space, you don’t have to spend the compute on all that useless stuff and you can just focus on the useful stuff. And so what you can get are pretty much the same quality images with a much, much more manageable amount of compute. Is that broadly correct?

ExplainerHow latent diffusion works

The paper by Robin Rombach and colleagues (the CompVis group at LMU Munich, plus Runway) splits generation into two independent parts.

  • Compression. First an autoencoder learns to squeeze an image into a latent and expand it back with almost no visible loss. In Stable Diffusion a 512×512 image with three color channels becomes a 64×64 tensor with four channels — 48 times fewer numbers, but still a small "image," not a column.
  • Diffusion. Then a U-Net is trained on these latents to turn random noise into a plausible latent, step by step.
  • The prompt. The conditioning encoder τθ turns text, a segmentation map or another image into vectors, and the U-Net takes them in through cross-attention.
  • Assembly. The decoder expands the finished latent into an image.

The heavy part — dozens to hundreds of denoising steps — happens in the small space. That’s why such a model trains at a fraction of the earlier cost and runs on an ordinary graphics card, which is what made it possible to release Stable Diffusion openly.

I think that is broadly correct. Yeah. And similar to Attention Is All You Need, the fact that we have this efficiency advance means we can train more. That’s usually how an efficiency advance gets used: for the same amount of compute, we can train more. And we don’t necessarily have scaling laws11Scaling laws — empirical relationships by which a model’s loss falls predictably as parameters, data and compute grow; for language models OpenAI described them in 2020. arXiv for generative image models yet, although people are working on this. We know from the Chinchilla laws12The subject of the series’ second episode. DeepMind’s 2022 Chinchilla paper found that for a given compute budget, parameters and training tokens should grow in equal proportion — roughly 20 tokens per parameter — which made GPT-3 and Gopher look undertrained. arXiv that, generally speaking, models have not enough data and are undertrained.

So efficiency advances allow us to get more out of what we already have, and these latent diffusion models are an advance in that direction. Importantly as well, there were two models this year that both kind of take the same approach, and DALL-E 2 is also a model of this form.13DALL-E 2 is also a diffusion model, but built differently: from the text it first produces a CLIP embedding of the future image, then a diffusion decoder draws a 64×64 image from it directly in pixels, and two more models upscale it to 1024×1024. arXiv They’re pretty closely related. They use a lot of the same ideas. But let’s focus on latent diffusion, this paper, because it’s the thing that’s really exploded, right? It’s the thing that anybody can get their hands on. And we can talk about the differences a little bit later.

Before we even dive into the details here, let’s talk about maybe DALL-E 1, because DALL-E 1 predated this. So what were people doing beforehand? How did DALL-E 1 work? And then we can get into the breakthroughs that this paper introduced.

Yeah, DALL-E 1 was a much more, let’s say, traditional thing.14DALL-E 1 (January 2021) worked like a language model: a discrete autoencoder compressed an image into a 32×32 grid of tokens, and a 12-billion-parameter transformer learned to continue a caption with image tokens. arXiv There wasn’t this diffusion model approach in DALL-E 1 — and we’ll talk about what diffusion actually is and means. It was a much more traditional sort of "we’re going to downscale this image, we’re going to add a prior, and then we’re going to upscale from the prior" type of deal. And it worked pretty well. It turns out with good encoding of the prior and a big enough data set and training well, you could get pretty good results. But for a variety of reasons those results are not as good as what we can get now with Stable Diffusion.

But it was a step in a similar direction.

DALL-E 1 is much more closely related to sort of the traditional way that this has been done in the past, which is generative adversarial networks, GANs,15GANs, generative adversarial networks (Ian Goodfellow, 2014): a generator learns to fool a discriminator that tells fakes from real images. Before diffusion, this was the main way to generate photorealistic images — StyleGAN’s faces, for example. arXiv variational autoencoders, VAEs,16VAEs, variational autoencoders (Diederik Kingma and Max Welling, 2013): an encoder compresses an image into a small vector and a decoder restores it, while the latents are pushed toward a normal distribution so new points can be drawn from it and decoded into new images. arXiv and other things where you basically have an information bottleneck: you add stuff into the information bottleneck to create a prior,17A prior here is a distribution fixed in advance at the network’s bottleneck: a random point is drawn from it and the decoder unfolds it into a new image. and then you expand from that bottleneck. In fact, this paper does do a similar thing, but the way it does it is a little bit more clever, and it turns out to work better. And as you said, one of the big advances here is that previously, in a model like DALL-E 1, so much of the stuff that went down into the information bottleneck ended up being irrelevant for the perceptual quality of an image,18The paper calls this separating perceptual from semantic compression: the autoencoder drops fine high-frequency detail the eye doesn’t notice, and the diffusion model learns meaning and composition. even though at the pixel level it was very important.

At the pixel level, the numbers that represent the pixels, it might be very important to change this small part in the bottleneck representation, but to a human looking at the image, it just doesn’t matter. You can’t tell the difference. And so battling with that is how we made things more efficient here.

03Figure 3: the autoencoder, CLIP and web captions

The model starts with an encoder-decoder pair, and everything depends on captions scraped from the web.

Got it. All right, so I guess let’s take it from the top. Technically, what is happening in this paper?

Right. The diagram we should display is figure three. Yep.

I have a screenshot in my notes.

Figure 3 of the latent diffusion paper, the one the hosts walk through: on the left the encoder E and decoder D in pixel space, in the middle the diffusion process and the denoising U-Net in latent space with cross-attention blocks (Q, K, V), on the right the conditioning encoder τθ for text, maps and images.
Figure 3 of the latent diffusion paper, the one the hosts walk through: on the left the encoder E and decoder D in pixel space, in the middle the diffusion process and the denoising U-Net in latent space with cross-attention blocks (Q, K, V), on the right the conditioning encoder τθ for text, maps and images.

So this here is the model architecture. On the left we have this red box that says "pixel space," and it’s got these things E and D in it. Those are an encoder-decoder pair. What these are trained to do is, given an input into the encoder, it encodes it into a lower-dimensional space called the latent space. That’s that green vector z there. And then the role of the decoder is to decode that vector z back to the same thing that was input, right? So this is called an autoencoder pair.19An autoencoder is a pair of networks trained together: the encoder compresses the input, the decoder restores it, and training pushes the output to match the input as closely as possible.

In these latent diffusion models, E and D are straight-up off-the-shelf things called CLIP encoders.20Fact-checkWrong: E and D in latent diffusion are not CLIP but the authors’ own autoencoder, trained to reconstruct images. CLIP sits elsewhere in the diagram: in Stable Diffusion 1.x its text half serves as the conditioning encoder τθ, turning the prompt into vectors. Anton mixes up these two roles for the rest of the conversation. arXiv And CLIP is a paper from OpenAI that came out, I think, late last year21Fact-checkWrong: OpenAI unveiled CLIP in January 2021, almost two years before this recording. And the name stands for Contrastive Language–Image Pre-training. arXiv — you can correct me if I’m wrong — and it’s called Contrastive Language-Image Pairs. What that means is they trained a model where, given an image and a caption for that image, and all of this is from the web, they train this model such that when you give it an image or text, the vector that the encoder produces for the image or the text should be the same, as close as possible, right? So basically it means that an image and its caption should have the same latent representation.22This is contrastive learning: CLIP pulls together the vectors of matching image-caption pairs and pushes apart mismatched ones — in each batch of 32,768 pairs, every image competes against all the other captions. It was trained on 400 million pairs from the web. arXiv

That’s fascinating.

And that’s an important first step. And what’s great about CLIP is, again, it’s dummy simple. The model itself is very straightforward. All the tricks were about training it effectively and having the data to train it.

Which feels like that puts so much… I know I’m speaking for myself: when I include an image in a Not Boring piece, the words that I care about in that whole essay the least are how I describe — the caption that I put below the image. It feels like that puts a lot of trust in how the images are captioned.

It does, and that’s a huge problem, actually. In practice, the data sets that are used to train these things are very noisy. And so it’s kind of nice that it still works very well. But a big problem with these models is that the data sets are very noisy. The captions are often nonsense, or unrelated to the image, or in a different language. So you’ll have the same image, but it’ll have five different captions. And so that makes it very difficult to encode it properly.

And the data sets themselves are noisy. So you might have English text and Russian text mixed in in a data set that’s supposed to just be English. And because of the scale of the data sets — billions of pairs — it’s very hard to clean them up. And that’s something that Chroma works on as part of our remit. Anyway, so that’s the first step.

One question on the captions, because I’ve heard this about latent diffusion models, that one of the really important things is that there actually are all of these images on the internet that are also captioned. Is that just like the New York Times saying "this is a picture of X"? Is that how I should think about captions, like human-visible captioning, or is there also something behind the scenes where in the HTML there’s also captioning?

So that’s an interesting question. Images can have alt text23Alt text — the alt attribute of an HTML image tag: a text description for screen readers and for when the image fails to load. Such descriptions, pulled from the Common Crawl web archive, became the captions in LAION, the data set Stable Diffusion was trained on. as part of the HTML. So that’s one place to get a caption. And then finding nearby text is another way to get a caption. So in practice, yes, it’s exactly like what you said. And they’re supposed to be human-readable, because the purpose of alt text is for screen readers and other assistive things, especially on places like the New York Times, where they want unsighted readers to be able to actually understand what the article is saying without necessarily being able to see the pictures.

So it’s so cool that… I mean, because you do a sighted versus an unsighted reader, you are going to need to give a lot more detail about what’s going on in the image to someone who can’t actually see the image, as opposed to just saying "boy in front of a tower." You have to actually describe it a little more. So it feels like without that, this isn’t possible.

Yeah, and people have been trying to improve or solve this, because there’s a lot more uncaptioned or very noisily captioned images, right? So there is a model from Salesforce called BLIP,24Fact-checkNot so: BLIP (Bootstrapping Language-Image Pre-training, Salesforce, January 2022) writes full-sentence captions, not tags. For training it generates its own captions for web images and filters out the noisy ones. arXiv and I forget what it stands for, but it is basically an attempt to automate captioning using a nice clean caption data set. And it more tries to tag the images. It doesn’t necessarily give a nice sentence, but it tries to throw up some relevant tags for whatever image you feed it. And people are calling this pre-captioning now.

04A detour: Salesforce, junior jobs and shipping containers

Anton thinks AI will take boilerplate work, not people, and points to the containerization of ports.

Why Salesforce?

Yeah, it’s like a problem. Salesforce has a pretty reasonable AI research arm, actually. They acquired a company a little while back. Salesforce acquired this company called MetaMind,25MetaMind — Richard Socher’s startup, founded in 2014. Salesforce bought it in 2016: the team became the core of Salesforce Research, and Socher became Salesforce’s chief scientist. which was founded and run by Richard Socher, and my friend Stephen Merity26Stephen Merity — an AI researcher who worked at MetaMind and Salesforce Research; author of the AWD-LSTM language model and the WikiText data set. arXiv worked there — shout-out to you guys. And yeah, they’re actually really quite strong in AI. They have their own code model, which is being used by Replit.27That’s CodeGen, Salesforce Research’s open-source code generation models (March 2022). Replit built the code completion in its Ghostwriter assistant on a distilled CodeGen model, and later moved to models it trained itself. Latent Space They’re actually pretty good. I know that it’s unexpected that a company like Salesforce would be investing in this, but they are. I actually kind of think that this points to the fact that they’re pretty forward-thinking, even if they’re not the leader.

It’s also a little scary if you’re a salesperson, that they have all this data that they can train on. Some of the roles of an AE28An AE, account executive, is the salesperson who runs a deal with a customer through to signing. might not be super hard to automate away at some point.

Yeah, but it’s interesting. The way that I’ve been thinking about this — and we’ll get into this later when we start talking about the implications — is that I think AI actually has a really hard time completely automating humans away. I think what it’s really good at right now, and will be good at for a long time, is just the boilerplate. The other way to think about it is that a lot of the work that gets done at the entry or junior level is that kind of boilerplate work.

And I think in those cases you still need people who are going to get to the mid or more senior level, and at those places I don’t see why it can’t be a teaching tool. I think it would be a mistake to kill the seed corn here. I mean, look, Packy, we’ve talked about my ideology before, but I believe that technology doesn’t replace humanity. Technology is this instrument and this thing that humans do. It’s a creative process like any other that we participate in, right? And so fears of automating humans away — I understand the fear. Automation is kind of scary, because you’re earning an income and the way you earn that income is probably going to change, but at the same time it’s kind of necessary to expand us as humans. We need to be able to do it.

So these fears, like "oh, people should be scared" — I don’t think they should be scared. I think they should be ready to learn, which I understand kind of sucks if you have a good thing going, or even if you’re just finally scraping by and this thing comes along. That really sucks.

And that one’s a super interesting one too, right? It goes from sending the same email over and over and over again, in a way that’s kind of already automated — we do mail merge, right? All that stuff happens already — to where the next level really becomes a lot more about relationship building, which is a very, very human thing. And so yeah, how do you move more people into that more quickly?

I think that that’s probably the right way to go about these things. And that is an opinion that’s kind of ideological. We’ll see if that shakes out. To take a big departure from everything we’re talking about: there’s a book out called The Box.29The Box (2006) — economist Marc Levinson’s book on how the standard steel container, first sent to sea by Malcom McLean in 1956, collapsed shipping costs and remade ports and world trade. It’s all about containerization of freight. If you’re into history and understanding how the modern world came to be the way it is, I really strongly recommend this book, because in this book freight containerization is this great template for the different ways that automation can actually go.

And it was this great natural experiment, because different ports in the world and in the United States approached containerization differently. And so we saw what happened in different cases, right? In some ports, the unions straight-up resisted containerization for a long time. In other ports, the unions found ways to, like, okay, we are going to stop hiring at the junior level — well, actually, no, we’re gonna continue hiring at the junior level, but we’re gonna start pensioning people off earlier.30In Levinson’s book this is above all New York versus the West Coast. New York’s longshoremen’s union fought containers for years, while the West Coast union under Harry Bridges signed a mechanization agreement with employers in 1960, accepting machines in exchange for guaranteed income and an early retirement fund. And a lot of people were very happy to take that pension, it turns out, because it meant they didn’t have to do backbreaking dock labor anymore.

And what happened there is it actually turned into labor shortages. Despite the fact that it took, I think, on average four or five times fewer people to unload the same container ship, it created labor shortages, because the demand for cargo increased so much.

Container cranes at the Port of Oakland, one of the main container ports on the US West Coast.
Container cranes at the Port of Oakland, one of the main container ports on the US West Coast.

And so automation is kind of unpredictable like that. I mean, the other reason… San Francisco no longer has a port and Oakland has a huge port,31Fact-checkOverstated: San Francisco still has a port that handles cruise ships and some cargo. But container shipping did move to Oakland in the 1960s and 1970s, which built the West Coast’s first container terminals, while San Francisco’s old piers turned into a waterfront of restaurants and offices. Port of San Francisco because Oakland was purpose-built for containerization and San Francisco wasn’t. And the railheads going to Oakland were a huge, huge deal. And that’s why San Francisco has a nice waterfront now and Oakland has a giant port.

Yeah, so that’s, I guess, the second-order effect: if you’re not prepared, you end up actually with a nice waterfront, and the one who is prepared and…

Not okay. Yeah, not okay, right? There’s this parable, like the "wait and see" parable.32"Wait and see" — the Chinese parable of the old man whose horse runs away. Neighbors commiserate and he says "we’ll see"; the horse returns with a herd, his son breaks a leg breaking in the horses and is spared from war. The moral: you can’t judge an event’s consequences right away. I’ll link to it later. But I think fear of automation — I understand it. I get where it comes from emotionally, in the gut, but the reality of it often is pretty surprising. And I think in the long term it’s net beneficial. And we kind of have to do it.

Industrial robot density in 2021, robots per 10,000 manufacturing employees
  1. South Korea1000
  2. Singapore670
  3. Japan399
  4. Germany397
  5. China322
  6. United States274

Source: IFR, World Robotics 2022

Yeah, like robotics as well is another great example of this, where if you look at the countries that have automated the most and have the most robots in their factories, their workers get paid more and have better working conditions, and there’s more robotics jobs, there’s more manufacturing jobs and better jobs. And so yeah, it’s not what you’d expect, but that seems to be something that we’ve figured out over and over and over again.

05Latent space and noise

A diffusion model learns to remove, step by step, the noise that was first added to the latent step by step.

But we’ve gone far afield, way off. So we are right now in the top left of the red box. I think we’ve moved just over into the green box.33In Figure 3 the red box on the left is pixel space and the green one is latent space. This is what we’re all about here: we’re gonna go off track. But so we have encoded into latent space. Yes. So, even before we go beyond that, can you define what latent space is, in as visual a way as possible?

Yeah, absolutely. So you can imagine you have an image, right? And in a computer, an image is made up of this giant matrix of numbers. Every pixel usually has three numbers associated with it to give you the color. And so when you think about it, any reasonably sized image is a lot of numbers, and that means it’s got what’s called a high dimensionality,34Dimensionality is how many numbers describe something. A 512×512 color image has 512 × 512 × 3 = 786,432. right? And a latent vector is just a representation of that same image in fewer numbers, basically in one column instead of a giant matrix.35Fact-checkNot so: in latent diffusion the latent is not a column but a small "image." In Stable Diffusion it is a 64×64 tensor with four channels instead of 512×512 with three: 48 times fewer numbers, but the spatial layout survives, which is why a convolutional U-Net can work on it. arXivencoderdecoderimage 512×512×3786,432 numberslatent 64×64×416,384 numbers48× fewer That’s the way to think about it.

That’s perfect.

And in the case of CLIP, it’s mostly 64-dimensional.36Fact-checkWrong: CLIP vectors are longer — 512 numbers in the base versions and 768 in ViT-L/14, the one used in Stable Diffusion 1.x. And the latent of the image itself in Stable Diffusion is 64×64×4, or 16,384 numbers. arXiv I’m not sure which one they used in this paper, but a typical CLIP latent vector is dimension 64, from an image with hundreds and hundreds of numbers. I think this might be 256. It might be 256.

Yeah, I think that’s what I’m recalling from the paper. All right, so we’ve moved into latent space, and then we have this box in the middle that is "diffusion process," which feels like it’s an important piece of this. What’s happening?

It is. So the diffusion process here — this diagram includes both training and inference.37Inference — running an already trained model: producing an answer or an image for a request. So this is a complete depiction of the system. So here’s how a diffusion model gets trained. You take your image, you encode it into this vector, and then you add noise, Gaussian noise, to that vector38Gaussian noise — random additions following the normal distribution (the bell curve) with a mean of zero: small deviations are common, large ones rare. The diagram below shows the noise piling up step by step and the U-Net walking the path back.z0z1z2zT…training: noise is added step by stepgeneration: the U-Net removes noise step by step several times over. So you go from this guy on the left, z, to this thing on the right, zT. And in between z and zT, there’s z1, z2, z3… zn.

And between every zn and zn minus one, you add a little bit of noise. And eventually the vector zT is completely noise. It’s random. If you fed it back through the decoder now, you would get random garbage.

And so the noise that you’re adding — you’re just replacing some numbers with other ones, or just adding numbers, or subtracting?

So it’s zero-mean Gaussian noise, which means it’s a normal curve, and you add it evenly to the whole vector. To each number in the vector, you add a little bit of that kind of noise centered around zero. In principle, I think you can use all kinds of noise, but de facto people use Gaussian. I don’t think anyone’s really done the work to figure out if it’s better or worse than doing it uniformly or something.39Fact-checkNot so: other kinds of noise had already been tried. In 2021 "denoising diffusion gamma models" came out, and their authors reported that gamma noise gave better results than Gaussian for images and speech. arXiv Hopefully someone does. But it’s like a micro-optimization, because these things already work. So yeah, this is actually this interesting thing.

It’s the thing that drives machine learning research. If things kind of work well already, not a lot of researchers will go back and be like, can we make this a little bit better? Which, to my mind, kind of means that we’re leaving a lot undone on the ground, but it also means that there’s a lot of little projects that people can just do for themselves and see if it’s better, and then contribute that back as a small thing.

Are there some of those examples — when we talked about the AI winters40AI winters — stretches of disappointment and funding cuts in the mid-1970s and the late 1980s to early 1990s, discussed at length in the third episode of the series. and the stops and starts and all of that — do some of those examples lead to dead ends, and then you have to go back and rethink everything? Or is this really just, if you want to make it a little bit better, we’re all still moving in the same direction?

Well, that’s a question with deep roots in philosophy of science.41Thomas Kuhn, for instance, described in The Structure of Scientific Revolutions (1962) paradigm shifts in which accumulated anomalies force a rethink of everything, while Imre Lakatos described "research programs" that keep developing as long as they yield new predictions. The answer is kind of nobody knows, and there are different schools of thought. To my mind, if we have stuff that works, it makes sense to explore around it a little bit to see — maybe we’ll learn something new. And I think I’ve mentioned before that in a lot of cases for machine learning research, the justification for why it works is purely intuitive. The researcher will say, yeah, I think it works because of this. And then someone will come along months later and be like, no, that intuition is clearly wrong, because I just did this other experiment and it still works, or it doesn’t work. And so we have to think about it. But it’s a fast-moving field. There’s a lot of low-hanging fruit that can just be tried. And just coming up with a research result is an easy thing that even, I don’t know, even a college student could do. Even a high school student, honestly, could do some of these things if they have access to a computer and are smart, which is a lot of high school students.

ExplainerHow a diffusion model learns and draws

This is how DDPM (Jonathan Ho and colleagues, 2020) and latent diffusion work.

  • Training. Take an image latent z0, pick a random step t from 1 to 1,000, and add noise of the matching strength in one go: a closed-form formula gives zt directly, without walking through the earlier steps. The U-Net gets zt, the step number and the prompt, and has to predict the noise that was added. The loss is the mean squared difference between the real and the predicted noise.
  • Parallelism. Each example is an independent pair of noisy latent and noise, so millions of them are processed at once, with no need to run the chain end to end.
  • Generation. Start from pure noise zT and subtract the network’s predicted noise step by step. Faster samplers like DDIM need 20–50 steps instead of a thousand.

Comparing images in pixels plays no part in training the diffusion model: the autoencoder is trained separately beforehand and then frozen.

Anyway, so, diffusion. So you end up with this noisy vector, but the real thing that you get during training are these pairs of a less noisy and a slightly more noisy vector. And then what you try to do is you train this denoising U-Net,42U-Net — a U-shaped convolutional network invented in 2015 for segmenting medical images: it first compresses the image, then expands it back, while "skip connections" carry detail straight across. In diffusion models it predicts the noise in a noisy latent. arXiv which is the thing below there, which takes the really noisy vector and iteratively denoises it. So you’re trying to train this model to get back from noise the original vector that you started with. And you do this in an iterative process, and it’s called a diffusion model because this resembles a physical process in thermodynamics.43The idea came from non-equilibrium thermodynamics: a 2015 paper by Jascha Sohl-Dickstein and colleagues first framed generation as reversing a process that destroys the structure of data step by step with noise. arXiv It’s kind of like heat diffusion.

There’s a really complicated paper, if you want to go out and read it, which deals with diffusion models, and it’s a thing called Langevin dynamics,44Langevin dynamics describes a particle moving under a force plus random kicks (Paul Langevin, 1908). In 2019 Yang Song and Stefano Ermon generated images by following the gradient of the data density with such noise, and later showed that this and diffusion models are two forms of the same approach. arXiv which is a process from physics. It’s hard. I think if you just want to play with Stable Diffusion, you don’t need to know about it.

And what’s interesting is people have compared this to Langevin dynamics, and then this is one of those things where people have come along and been like, well, actually it’s not, because you can do these other things and it still works.45For example, the Cold Diffusion paper (August 2022): instead of noise, images were degraded by blurring or masking, and the network still learned to restore them — so the physical analogy with noise isn’t essential. arXiv So anyway, so then you try to train this network that denoises it to bring it back to the original vector. And then you decode that original vector.

06Prompting through attention, training and generation

The model takes in the prompt through attention blocks, so generation can be conditioned on almost anything, and it starts from pure noise set by the seed.

And how does the fact that there’s the image and the caption… is that happening simultaneously on the two? Is there something trying to get them closer together in the diffusion process? How do those play together?

Yeah, so you can see here these little boxes that say QKV.46Q, K, V — the queries, keys and values of the attention mechanism from the series’ first episode. Here it’s cross-attention: queries come from the image latent, keys and values from the encoded prompt, so each region of the image "looks at" the relevant words. Those are our friends, the transformer attention heads. And you can see that on the right here there’s another thing that looks like an encoder, T theta,47In the figure it’s the Greek τθ ("tau theta"), the conditioning encoder. In the paper itself, for text, it’s a transformer trained together with the U-Net; in Stable Diffusion 1.x it’s the off-the-shelf text half of CLIP. and a bunch of things that you can feed into T theta, called conditioning.48Conditioning — an extra input the result depends on: a text prompt, a segmentation map, another image. And what’s the reason that they have this box that says "conditioning" and this general encoder for conditioning? In principle, because of the way attention works, as long as you can encode it into something like a vector, an embedding that attention can pay attention to, you can condition on almost anything. And they demonstrate that in the paper. As long as your model is trained.

Attention is all you need,49Packy is riffing on the title of "Attention Is All You Need," the paper the series started with. and then you can train on anything. That is amazing. It was one of those things when I’m reading the paper where I’m like, all right, I kind of know a little bit now. I see the word "attention." I see that something like that is happening here. But to me what that means essentially is that before, I can’t even imagine the data sets that you would have needed, how clean they’d need to be, or if you’d need to do something ahead of time, whereas now you can use the whole internet as a palette. Is that a kind of correct way of thinking about it?

I think that’s still an open question. The research hasn’t been done. People are working on it really hard. In this sense, image generative models lag text generative models, because they’re also harder to work with for a variety of reasons. Like I mentioned before, it only matters if the human thinks the image looks good. The actual information content, the numbers in the giant matrix, don’t matter as much. And that makes this harder to work with, but language models kind of have the same problem, because the meaning of the text matters much more than how the text does its thing.

So yeah, you train conditionally, and there’s two things. They have this switch here, right? And one thing you can do is concatenate the encoding of the conditioning directly to the noisy vector and just diffuse that, or you can feed it into the attention heads and do that. And they compare these two approaches, and I think attention wins out pretty much all the time.50In the paper the choice depends on the kind of input: conditions that line up with the image spatially — segmentation maps, low-resolution images, inpainting masks — are concatenated to the latent as extra channels, while text and class labels go in through cross-attention. And yes, you train this diffusion model, and during training you try to make this end-to-end loop basically work. So you include the image — CLIP is frozen, by the way. CLIP is not trained in the latest versions of this model.

What does that mean?

The encoder-decoder pair doesn’t get trained during the training process of this whole model. CLIP is just taken off the shelf. With Stable Diffusion in particular, they used to use OpenAI’s API to get their CLIP embeddings.51Fact-checkWrong: Stable Diffusion 1.x didn’t call OpenAI’s API — it ran the published weights of CLIP ViT-L/14’s text encoder locally. Stable Diffusion 2.0 (November 24, 2022) replaced it with OpenCLIP ViT-H/14, trained on the open LAION-5B data set. Stability AI Now they use OpenCLIP, which is an open project to replicate the CLIP result using the same data set that Stable Diffusion is trained on, called LAION.52LAION — a German nonprofit. Its LAION-5B (March 2022) holds 5.85 billion image-caption pairs extracted from the Common Crawl archive; Stable Diffusion was trained on its English-language part and on a subset filtered for aesthetics. LAION So yeah, so then you try to basically… this is your loss now,53A loss is a number that measures how far the model’s output is from the right answer; training means adjusting the weights to bring it down. In diffusion the comparison is between predicted and actual noise, not between images — see the explainer above. right? What is the difference between the thing you end up decoding from the latent vector that comes out of the diffusion process versus the image you encoded in the first place, conditioned on the caption that you gave that image. So that’s training, right? You’re trying to minimize that difference across the entire data set.

And what are they measuring specifically with the loss there? So they’re measuring kind of the difference between the before and after, but what is the thing that they’re looking at to measure that?

Yeah, they’re measuring how well denoised the final vector was. They’re actually measuring the loss directly on the latent vector. So they’re comparing: okay, after you’ve denoised zT — or in fact, this is where the training efficiency comes in — at each pair of vector, slightly more noisy vector, slightly more noisy, slightly more noisy, did you successfully manage to get back the slightly less noisy vector? And that means you can parallelize, right? Because you have all these noisy pairs right away. You don’t need to wait for it to noise and then denoise and then do a loss. You can actually just do it for each pair. So you parallelize that. That’s an efficiency win.

So you can train more of the diffusion U-Net faster, because you’re training on these noisy pairs. And so yeah, you do all of that and you try to minimize the overall loss for the entire thing. And so you train that, you try to get the same latent vector back, and then you decode that latent vector and that gives you an image. So that’s training time. So then how does it work at inference time, right? Because at inference time, you don’t feed an image, you don’t feed anything into that encoder.

So at inference time, what you do is you have only the conditioning input. And your zT at inference time is a random vector. It’s random. So you know when you select the random seed54A seed is the starting value of a random number generator. With the same seed and prompt, Stable Diffusion produces the same image. when you play with Stable Diffusion?

That’s setting the random vector. So you set a seed, and that seed generates a random vector of dimensionality 25655Fact-checkWrong: in Stable Diffusion 1.x the seed sets not a 256-number vector but a 64×64×4 noise latent — 16,384 numbers for a 512×512 image: the autoencoder shrinks each side by 8 and outputs 4 channels. Hugging Face or whatever it is for your particular model. And then you have your conditioning prompt. And then the denoiser, which has now been trained to take a maximally noisy vector and get a non-noisy vector out — that’s what it does. It takes a random vector, takes the conditioning, and produces an image that’s in some way conditioned on the thing that you fed it. So here they have semantic maps,56A semantic map is a layout where each region is painted with its class color — sky, tree, water — and the model paints a landscape to match. text. Text is de facto the main modality that people really care about.

So when people are used to using Stable Diffusion, this is the inference process that we’re all used to doing. The model’s already been trained. And so, if I’m understanding this correctly, I throw in text. There’s already in there, based on the seed phrase, this very noisy… it almost looks like a TV screen, like if you’re…

Yeah, you can actually picture it. You can take the noisy vector, throw it through the decoder, and you’ll get noise. It’ll just be noise. It’ll look like TV static.

Stable Diffusion 1.5, the same prompt and seed with different numbers of denoising steps (DDIM sampler): after 1–2 steps it is still noise; by 15–20 steps the castle appears.
Stable Diffusion 1.5, the same prompt and seed with different numbers of denoising steps (DDIM sampler): after 1–2 steps it is still noise; by 15–20 steps the castle appears.

Yeah, it looks like TV static. And so you just start with that, your text comes in, and then it works its way back through the system and tries to denoise to get back to the thing that’s closest to looking like what your text says.

That’s right. There’s a few subtleties here, which I can go into a little bit more, but that’s the basic idea: you have just the conditioning prompt and a vector that’s pure noise. And because the denoising network has been trained to take a noisy vector and give an output that’s in the training distribution, which is nominally over all possible images that humans think are images, you get back something that looks like an image. Because you have to remember, to a computer, it doesn’t know what an image is. It’s just a matrix of numbers. So pure static to a computer is the same thing as a picture of a puppy. It doesn’t know. All of this training and conditioning comes from, ultimately, what humans find interesting or pleasing to look at.

And so what this denoising network is doing is finding something in latent space that will decode to something that humans find interesting or pleasing to look at, because that’s what it’s conditioned to do. That’s it.

Yeah, it feels like there’s something philosophical going on in there. I mean, it’s technical, to me as someone who doesn’t understand the inner workings of it, but the fact that this whole process just exists for the computer to make something pleasing for us, even though it doesn’t care, is… yeah, it [unclear] interesting.

I mean, there’s the classic thought experiment, Searle’s Chinese room,57The Chinese room — philosopher John Searle’s 1980 thought experiment: a person who knows no Chinese sits in a room and, following a rulebook, answers Chinese characters with Chinese characters so well that outsiders think he understands. Searle’s point: a program that manipulates symbols by rules doesn’t understand their meaning. The photo shows Searle speaking at Google. and this is kind of similar for images, right? The computer doesn’t know what a dog is. It just knows to produce something. It’s really like that thought experiment: I’ve been handed a card, it says this, it’s got these numbers on it, which means I’m going to output these numbers. And the computer doesn’t know what the numbers mean. It doesn’t have a concept of meaning. We assign meaning. But because of the way we train it, we only put meaningful things in it — or we try to; as I mentioned, the data set’s really noisy. Anyway, so that’s what you get. There’s a little bit of subtlety here.

07What the guidance scale does

The guidance scale sets how closely the model sticks to the prompt, but because of CLIP’s noise, maxing it out "fries" the images.

So one thing that you might have noticed when you’re using Stable Diffusion is this thing called the guidance scale.58The guidance scale is a setting in Stable Diffusion interfaces, usually from 1 to 20, with a default of 7.5. How it really works is in the explainer below; the diagram shows the step at s = 7.5.no prompts = 0with prompts = 1s = 7.5the step takenStable Diffusion default

ExplainerWhat the guidance scale really does

Stable Diffusion’s guidance scale is classifier-free guidance (Jonathan Ho and Tim Salimans, 2021–2022).

  • In training, the prompt is replaced with an empty one about 10% of the time, so one network learns to predict the noise both with and without a prompt.
  • In generation, the network runs twice at every step, and instead of the with-prompt prediction it takes an exaggeration of it: no prompt + s × (with prompt − no prompt).
  • The values. At s = 1 it’s an ordinary conditional model; at s = 0 an unconditional one that draws "something like an image." Stable Diffusion’s default is s = 7.5.

The higher s, the more closely the image follows the prompt, but the less varied the results, and at very high values the colors blow out — the "fried" images. So the prompt is heeded at every step, not "sometimes": the scale sets how much to exaggerate its pull.

So the guidance scale is: sometimes during the denoising, you listen to what the prompt says, you listen to the conditioning. Sometimes you don’t. And it weights how much the prompt is actually used at each denoising step. And what’s interesting is, if you crank the guidance scale all the way up, which is like "heavily weight attention on every denoising iteration, only use this," it will try really, really hard to find a latent that’s closest to the conditioning latent.

You can think of that as — remember how I said you’re training with a caption? It’s trying to find the latent that would be there if the caption had existed in the training set, right? So it’s really trying hard to get exactly that latent. Whereas if you take the guidance down a little bit, it’s more trying to get more information from the overall distribution rather than exactly what you said.

When I’ve played with that in the past — and maybe I haven’t turned it all the way up — it doesn’t feel like it gets any closer to the thing that I want it to get to. What are the trade-offs inherent with the guidance scale?

Yeah, that’s really interesting. And I think that comes back to — and I’ve been looking into this myself. Again, this is original research right now. Nobody’s really done a deep dive on this, but we’re working on it. Training CLIP isn’t perfect, right? Like I mentioned, when you train CLIP, the same image will have multiple captions, and very different images might have the same caption.

You can imagine "puppy," right? You can imagine a lot of images just have the caption "a photo of a puppy," and all of them will look very different. So it ends up noisy. It’s trying to put all these puppy images into the same caption space, or it’s trying to put all these captions into the same image. And remember how I mentioned with CLIP, they’re trying to make these things close together.

But because of that, they can’t be perfect. They can’t be perfect. And what that results in is, if you try to decode just the raw embedding of the caption that you put in, you’ll get not very pleasing results. And so what the diffusion process does by having that conditioning scale is adding more of "I know what images are supposed to look like in general," rather than "I know what this caption is supposed to look like in particular."

Is that something… I remember we were talking — I think we were doing Attention Is All You Need — and you said, because I was getting results that were too predictable and boilerplate, that I should increase the noise.59Packy is recalling advice from the first episode — to play with the "noise parameter" in Playground. It’s usually called temperature: it flattens the probability distribution over the next token, so the model more often picks less likely words. Is something similar happening in those two?

No, this is a little bit different, because what you’re doing when you’re increasing the noise in a text generative model is… The model doesn’t produce just one prediction per token in the output. It produces a distribution, and then it selects. So when you’re increasing the noise on a generative text model, you’re just letting it select lower-probability things sometimes, at random. Here it’s a little bit different. This is more like a smoothing thing. This is kind of like: I’m going to let information from everything about images leak in and override maybe the stuff that I’m getting from just what I’m supposed to know about this caption.

So it’s more like a smoothing thing than an additional-noise thing. And you can try this for yourself, by the way. If you turn guidance to zero, you’ll just let it hallucinate things which are like, "I think this is an image. This is a picture, I’m pretty sure." That’s what you get if you turn guidance all the way down. And you’ll notice, though, if you turn guidance all the way up, you get these really fried-looking images60"Fried" images — overexposed, with acid colors and harsh contrast. It’s a known artifact of high guidance values; Google proposed "dynamic thresholding" to fight it in its Imagen model. arXiv a lot of the time.

And that’s an artifact of the CLIP issue that I mentioned, in part. It’s also an artifact of the fact that the training process is never perfect — the loss never goes to zero — but it does point to this divergence between the image and text CLIP latents.

08Training data, retrieval models and avatars

An image isn’t assembled from specific training pictures, but the data shape it, and textual inversion and DreamBooth brought personalization.

Makes sense. I guess one of the things I’m wondering here is, it has this huge multi-billion-image data set that it’s working with. Is it picking, at any point, the images that go into this final image? Is there some subset that it’s actually working on for each particular image?

Not directly. Diffusion is obviously an indirect process, right? There’s multiple steps. But definitely you can say that the training data influences what images are possible, to a greater or lesser extent. And again, we’re working on something right now that maps the degree of that influence from the training set to the generations.61In February 2023 Chroma released Stable Attribution, a site that took a Stable Diffusion image and found the training images that influenced it most. The sixth and last episode of the series is about it. Again, this is Chroma bread and butter.

We think about latent spaces, we think about embeddings. And we think it would be pretty great to be able to make that attribution, because there’s been a lot of controversy around this stuff. Artists are feeling like their work isn’t being recognized, despite being fed into these billion-picture data sets. So I think it would be really nice if we could crack that, but it’s ultimately indirect. There is a class of model where it’s more direct. There’s a class of model called retrieval models.62Retrieval models look up relevant examples in an external database while they work and lean on them. For images, such a model was proposed in 2022 by the same Munich group that created latent diffusion. arXiv

And there are combinations of retrieval and diffusion models, which basically explicitly pick from a database. So rather than just using the weights in the diffusion model and the decoder, you can use a similar diffusion process to be like, okay, I’m going to pick from the database, and I’m going to learn to interpolate things to get the output that I want. So that’s a little bit more explicit. I actually think that retrieval models have a pretty bright future,63The prediction came true, but for text: from 2023 retrieval-augmented generation (RAG) became the standard way to connect language models to one’s own data, with vector databases like Chroma as a tool for it. arXiv but they’re not mainstream yet. They’re cheaper to train. They’re more explicit about what data they give you; because of that, they’re sort of less likely to hallucinate, I think people generally believe. Again, it hasn’t been tried at scale, so we’re not sure. But for things like code and legal and medical, it seems like having a retrieval model is a pretty nice thing.

And the other thing that you can do with it is you can swap the database out underneath. So you can train the model once but keep adding to it, or keep removing from it, or change it however you like, because it has to look in this database ultimately. But that’s not how this works. This works a little bit differently.

In this case — and I want to get back to the thing that you’re working on — but one other question that the retrieval model just brought up is: when I’m on Lensa or Vana64Lensa — a photo editor from Prisma Labs. In late November 2022 its "magic avatars," portraits of the user in various styles generated from their selfies, took it to the top of the App Store. Vana was another AI portrait app of the time. or wherever I’m doing it, sending pictures of myself and saying "add this and make me look like a god." Yeah, that sounds like almost the retrieval model piece, but what is actually happening?

ExplainerHow to teach a model a new face

In the summer of 2022 two ways to "personalize" a text-to-image model from a few photos came out almost at once.

  • Textual inversion (Tel Aviv University and NVIDIA): the whole model stays frozen, and from three to five images a single new vector in the text embedding space is found — a pseudo-word that then goes into prompts, like "S* in the style of Van Gogh." Only one vector is learned and the file weighs kilobytes, but the likeness is loose.
  • DreamBooth (Google Research and Boston University): the whole model is fine-tuned on three to five photos, binding the subject to a rare word: "a photo of [V] dog." So the model doesn’t forget what other dogs look like, its own images of the class are added to training (a prior preservation loss). The likeness is closer, but the result is a whole new copy of the model.

In the fall of 2022, avatar services like Lensa fine-tuned Stable Diffusion separately for each user from their selfies. Lighter variants like LoRA, which train only small additions to the weights, came later.

Yeah, that’s a really great question, because right after this came out and this was open-sourced, there was a burst of further research, and this research direction is called personalizing, or inserting personal objects, or whatever — those are the kind of keywords that you can search for. And two big things came out. One was called textual inversion, and textual inversion basically says: okay, I want to add something that wasn’t in the training set. I’d like to fine-tune my model.65Fact-checkNot so: textual inversion specifically does not fine-tune the model — its weights stay frozen. From three to five images it finds only the vector for a new pseudo-word, which is then used in prompts. arXiv And what you basically do is you inject a new latent-image pair. You train the model slightly more, and you inject this extra image into the latent space, and then you can say, okay…

The example they have in textual inversion is this picture of a clock. They show five images of the clock from different angles, and then they get back basically a token that represents a particular new embedding, a new latent vector that wasn’t in the training set but is now, because it’s been fine-tuned on a little bit, and you can start generating images with that token.

It’s almost the reverse: here we have a fixed latent; in that approach it’s more like we want to find a latent where, if this image had been in the training set, that’s the latent that it would have had, and then start using that latent.

DreamBooth is the other thing, and DreamBooth is the most popular one to put your faces on the bodies of surfers or gods or cyberpunk techno-samurai or what have you, right? And DreamBooth tries a different approach. I remember when DreamBooth came out, I was like, this is a big deal. I remember I frantically messaged — I was slamming Jeff66Jeff is Jeff Huber, Anton’s co-founder at Chroma. with Signal messages, because I was in Germany at the time, so I think it was something like 4 a.m. in San Francisco, and I’m like, you have to look at this, this is so important, this is a big deal. Yeah, so DreamBooth does things a little bit differently. It fine-tunes a little bit differently. They also create an extra identifier, and they have an additional text-to-image model that they fit on top of the existing Stable Diffusion model.67Fact-checkNot so: DreamBooth doesn’t add a separate model on top: it fine-tunes the text-to-image model itself on three to five photos, binding the subject to a rare identifier word. And Google built it on its closed Imagen model; enthusiasts ported the method to Stable Diffusion. arXiv So it works a little bit differently. It’s a little bit more involved than textual inversion, but it works really well.

And that’s what almost all those avatar companies like Lensa are doing.

Can you send me that paper, or whatever it was, on DreamBooth, and we’ll include it in the show notes for people to dive into that one further.

There you go. This is DreamBooth right here. This was such a big deal when it came out. I remember reading this, and I’m like, this is huge, this is so important. And it is, because I actually don’t think the full implications here have been explored yet.

People are like, oh, we can insert pictures of my dog into different scenes, or I can put my face on all these people. I actually think that there’s interesting applications for really augmenting data for machine learning purposes and for other purposes, which we’ll explore as well. Well, I’ll give you an example. Traditionally, when you train a computer vision model, you want to do data augmentation.68Data augmentation — artificially multiplying training examples by flipping, rotating, cropping and adding noise to images, so the model doesn’t memorize specific pictures. And data augmentation in practice means you’re trying to make your model robust to things that are not quite in the training distribution.

So you’ll take an image and you flip it, you add jitter, add noise, you crop and recompose images differently for an object detection model. But the thing is, none of these things are very physically plausible. No real image looks like that. No real image looks like random crops of a street scene combined with other street scenes, and blah, and you want your object detector to still work. It’s not real, right? There’s nothing in the real-world distribution like that.

But this is intended to prevent the model from overfitting69Overfitting — when a model memorizes its training examples instead of general patterns and does worse on new data. the training set and to be a little bit more robust to new stuff in the real world. But because that data isn’t really physically plausible, there’s a limit to how well you can do it. But if you can create data augmentations that are physically plausible by using an approach like DreamBooth combined with one of these diffusion models, that becomes maybe very powerful. It’s one of those things where it’s unclear how much better it is than just very traditional augmentation, but I think there’s something to it. And I think there’s something to it in particular in the case where you have rare examples that are hard to collect in the wild, but are physically plausible.

So I heard this story recently of a very famous person in machine learning, who works at a very famous company, manually having to annotate pictures of deer in the road. Like thousands — this is a person who’s a leading light in machine learning, having to manually annotate pictures of deer, thousands of pictures of deer. This is what he was spending his evenings doing. And you just don’t have to do that if you can inject deer in physically plausible ways into all kinds of scenes and situations.

That’s super interesting.

And again, well within the Chroma wheelhouse. So I love it.

09Artists, attribution and copyright

Anton finds artists’ grievances fair and fears the answer will be stricter copyright that only Disney wins from.

Wait, so back to the Chroma wheelhouse: there was a point in the paper — I think it was in the societal impact section — where it said "generative models also reveal their training data70In the societal impact section the authors write that generative models can reveal their training data, which is especially worrying when the data contain personal information collected without explicit consent." as one of the risks. Is that how you can pull apart what’s going on behind the scenes and which images are being used, or is that a different thing?

Our approach that we’re taking right now is a bit more direct, but this is definitely an area that needs more research as well. I think the risk that they highlighted in that section is: if your data is in the training set, you can probably get it back out. And that’s generally true.71In January 2023 this was demonstrated on Stable Diffusion: Nicholas Carlini and colleagues used the captions of images duplicated often in the training set to get the model to produce about a hundred near-copies of training images. arXiv I’ve been doing a few experiments lately. I mean, one way that you can kind of check this out for yourself, how well it works, is: grab a caption from an image you know was in the data set — and you can go look this up, LAION is public — grab a caption that you know is in the data set, crank guidance all the way up, and see what it returns.

And it’s not going to give you, in most cases, back the original training image, and the reason it won’t do that is, again, because of this CLIP noise that we discussed. It can’t perfectly do that. It’s trying to recreate a latent that’s like the caption, but CLIP is noisy. Every stage of this has a little bit of noise in it, because it’s not perfect. It can’t perfectly fit the distribution. And so you won’t get the same thing back. But it is a way to see, okay, this is what it’s trying to get out of the [unclear]. This is the closest thing you can get to really directly looking in there. Our approach is a little bit different. It’s more indirect.

I think it’s still very technically valid and works, and we’ll talk about that more maybe next time. But yeah, it is a risk. You can do this stochastically as well. If you have the data set of captions, you can go through it and then try to select images where, okay, they actually do look good, and then see if they match something. You can try all kinds of stuff.

Got it. Well, I’m excited to dive more into this, because that is, to me at least, on Twitter, the issue that I see talked about the most with these models. We talked about automation already, but: "this is going to put artists out of work, it’s stealing from artists." And I disagree — I know you disagree, we’ve talked about this — but the idea that we’re all unknowingly feeding the beast without getting any attribution or any compensation for doing that just seems like a constant topic of conversation now.

So I don’t necessarily think that artists are wrong to feel like their work has been appropriated without permission, because certainly nobody asked the people in LAION whether they wanted their artwork or imagery to be trained on,72A month after this recording, in January 2023, artists Sarah Andersen, Kelly McKernan and Karla Ortiz filed a class action against Stability AI, Midjourney and DeviantArt, and Getty Images sued Stability AI. right? This is definitely true. The stuff is publicly available. You can get it from the internet. And people do post it to platforms which definitely do use that data as well for their own purposes, right?

But at the same time, the platforms where that stuff is shared are not really used to create images of their own. Instagram isn’t out here yet — maybe soon73In 2023 Meta launched the Imagine image generator, built on its Emu model, and put generation into its apps, Instagram included; it was trained in part on public photos from Facebook and Instagram. — generating its own photos to post to its own stream. Twitter isn’t doing that. ArtStation74ArtStation — a portfolio site for game, film and illustration artists, owned by Epic Games since 2021. In December 2022 artists flooded it with "No AI" images to protest AI-generated pictures on its front page. isn’t out here being like, oh yeah, we took your art and then we commissioned 50 more art like it. So I really do empathize with artists in the way that they feel here. I think it’s actually totally valid.

I mean, even something like Unsplash, right? Where the point is to be able to use it across the internet for free, but with attribution in every case.75Fact-checkNot so: the Unsplash license doesn’t require crediting the photographer — the site only asks you to and offers a ready-made credit line. Unsplash It always makes it really easy to copy who the artist or the photographer is behind the thing that you’re using.

Yeah, exactly. And a lot of the stock photo websites work on exactly that model, right? The whole point is you use it, but attribute it, and attribution is very important in art. It’s also important in science, right? In science, bibliography is really important. And someone like Jürgen Schmidhuber76Jürgen Schmidhuber — co-inventor of the LSTM recurrent network, known for priority disputes. The best-known episode came at NIPS 2016: during Ian Goodfellow’s tutorial on GANs, Schmidhuber stood up and argued the idea repeated his work from the early 1990s. The photo shows Schmidhuber in 2017. will come to your paper talk and say, well, actually, this is based on work that I did five years ago — if you’re Jürgen Schmidhuber. But the point is, in science culture this is important, and in art culture this is important. And I think that we’ve elided that a little bit too much.

And I see these conversations happening on Twitter where artists are like, these machine learning people, they stole my art. These AI geeks stole my art. And they’re generating art and the art is kind of trash. And they’re shit-talking the generative models. And the thing is, the AI people are not responding charitably, in my opinion. I think that they’re missing the point in many cases.

The point is not the technicality. The point is not, "oh yeah, technically the model is not actually taking something in its training set and compositing it." But who cares? That’s not what matters here. What matters here is: definitely this model requires artists’ work to exist and work well. And that hasn’t been acknowledged.

And part of that is this attribution difficulty. Because of the way the model works, it’s difficult to say, okay, this generation came from this part of the training set — but not impossible. And again, this is something we’re really looking hard at right now, because we think it’s important. Generally speaking, I think it’s important to have a good conversation, because ultimately this is creativity. Creating these models and making them do this stuff is a creative act. And if we as technologists are not in dialogue with other creative people, that’s a huge loss, and it will be a huge loss for everybody, because the thing that I’m terrified about — and we can maybe talk about this more in the next episode — is if IP law for derivative works77A derivative work is a new work based on someone else’s: a translation, adaptation, fan fiction, remix. Under US law it needs the rights holder’s permission unless it’s fair use. gets stronger. That’s just bad. Everyone loses. Everyone except Disney loses.78Disney is the emblem of lobbying for stricter copyright: the 1998 law that extended copyright terms by 20 years was nicknamed the "Mickey Mouse Protection Act." Mickey’s first cartoon, Steamboat Willie, entered the public domain only on January 1, 2024. Everyone except Disney loses, right? Yeah. They’re the ones with the lobbyists, they’re the ones with the money. If you want stronger copyright protection for derivative works, you’re like, cool, you never get to draw a picture that kind of maybe looks like a Marvel character ever again.

So that’s DMCA79The DMCA, the Digital Millennium Copyright Act (1998), bans circumventing copy protection and set up the takedown process for rights holders’ complaints. too. I really don’t want that. And more importantly, I really want this to be regarded as a creative and amplifying tool, not something that replaces anybody. And I think that’s a really important thing to do.

10The real danger is new media

The danger, Anton says, isn’t a paperclip maximizer but the destabilizing effect of a new media technology that society will have to build immunity to.

Well, and to your point earlier, right? This seems like it’s been around for a while. Everybody probably watching this has at least used Stable Diffusion or used DALL-E. This paper came out, again, eight months ago. And to the extent that this is kind of how people are creating, or one of the media that people are going to use to create into the future — we’re talking, you know, until maybe the end of humans — this is the very, very, very beginning of this new form. And I’m worried that if certain ways of doing things just kind of get locked in and get Lindy80The Lindy effect — the heuristic that the longer something has lasted, the longer it is likely to last. It’s named after Lindy’s deli in New York, where comedians debated how long shows would run, and was popularized by Nassim Taleb in Antifragile. just by existing a little bit longer, without actually having the conversation, you’re wasting this opportunity to be at the kind of inflection point or turning point.

Strongly agree. Yeah, it’s important to do now. There’s a strong path dependence,81Path dependence — when early, often accidental choices lock in and shape development for decades; the textbook example is the QWERTY keyboard. and I think eventually, over time, humans do converge on better stuff, but there’s a path dependence right now. It’s important to really… right now, we have to do it right now. Otherwise we’re in danger. This, for me, is the real AI danger. I don’t really believe in a paperclip-maximizing evil overlord,82The paperclip maximizer — philosopher Nick Bostrom’s 2003 thought experiment: a superintelligent AI with the harmless goal of making paperclips turns everything, people included, into paperclips. The point is that the danger isn’t an evil AI but one with a badly specified goal. for a variety of reasons — we might have that conversation at some point in the future. But I really do believe in the destabilizing effect of new media technologies, because we’ve seen that historically, as we’ve talked about before, and this is a new media technology.

This is before we get into issues like deepfakes83Deepfakes — fake video, photos and voices generated by neural networks. The word appeared in 2017 as the handle of a Reddit user who posted such clips. and whatnot. But the thing is, I distinctly remember the era of "don’t believe anything you read on the internet." I grew up with that. I don’t trust anything I read on the internet. I just assume it’s all garbage.

But a lot of people don’t. And we live now in an era where people treat the internet as authoritative, even though anyone can put anything on there. And I think that’s also destabilizing. It’s going to be easier to create imagery, and you can figure out if it’s fake or not, but that’s going to get better or worse depending on how you perceive it. And so we’re going to have to develop a new immune system for visual and textual media, which is what humanity does eventually. Eventually we kind of get tired of being hoodwinked and we get over it. We just stop trusting it.

But that’s going to take a little while, and I’m a little bit worried about that effect.

All right. So I think our next episode, after the holidays, if you’re able to share more then, should be on how you’re thinking about solving this, or contributing to the solution to this problem.

Yeah, we’re working really hard right now to — we want to really at least make progress on this attribution question, which, again, Chroma is all about: figuring out why a model behaves the way it does, given the data that it was fed. So this is well within our remit. And we’ve got promising signs that we’re doing the right thing. So yeah, where do we want to wrap on diffusion models?

11Who built Stable Diffusion and why openness matters

Two German universities and Runway did the research with Stability AI’s support, and open source, Anton says, showed that a small organization could build a model like this.

Right, so unless there’s anything else kind of important technically, I think, at least for my understanding of what’s happening, we’ve gotten to a good spot. But then what happened, right? I think half the fun that we have in these conversations is talking about the politics of the AI world: who uses what, the commercialization of stuff, or at least bringing it to market and putting it in people’s hands. So this paper was released in April. What happens? Who are the big players? We’ve mentioned a few of them, but how did that all come to be?

Yeah, good question. So this paper in particular… So DALL-E is obviously OpenAI, right? And with DALL-E, OpenAI did some deals with Shutterstock84From 2021 Shutterstock sold OpenAI licenses to images for training DALL-E. In October 2022 the companies announced a partnership: DALL-E 2 was built into Shutterstock, and contributors were promised payouts from a dedicated fund. and a few other people to get the imagery. This one was done in a combination with researchers from LMU in Munich — and actually, I better make sure it’s actually LMU. Yeah, LMU in Munich, IWR in Heidelberg,85Latent diffusion came from Björn Ommer’s CompVis computer vision group, which moved in 2021 from Heidelberg University — where it worked at the Interdisciplinary Center for Scientific Computing, IWR — to LMU Munich. One of the paper’s authors, Patrick Esser, worked at Runway. a company called Runway ML, and Stability AI86Stability AI — Emad Mostaque’s London startup. It paid for the compute to train Stable Diffusion and released the model openly. also supported the work. And so there’s two pieces to it.

This is a model — my understanding is the original version of Stable Diffusion cost $600,000 to train.87The figure comes from Stability AI’s Emad Mostaque: in August 2022 he wrote that training took 150,000 A100 GPU-hours, about $600,000 at market prices. In 2023 MosaicML trained a Stable Diffusion 2 equivalent from scratch for under $50,000. The Decoder The latest one is much cheaper. The latest one is about 180K, because I think a lot of the experimental, practical engineering has been worked out. And that first model would have had a lot of false starts, and things would have gone wrong, and it takes debugging. So Stability supported it with compute. And the research came from LMU and Heidelberg and Runway ML. So it was a pretty large, broad collaboration.

For comparison, what’s the rough ballpark on what GPT-3 cost to train?

Oh man, they will never tell you that number.

They’ll never tell you. What’s the scuttlebutt?

Oh boy. Order of, you know, many millions of dollars.88OpenAI never disclosed the number. The best-known estimate is Lambda’s: in 2020 it calculated that a single GPT-3 training run would take 355 GPU-years and cost about $4.6 million at the cheapest cloud prices. Lambda It’s expensive. It’s expensive, but also how those costs break down is not clear a lot of the time as well. And OpenAI have gotten pretty good, once they kick off training, at doing the right thing.

So it’s really hard to say, and they will never, ever, ever tell you. But maybe you could work it out — if you can somehow back out Azure89Azure is Microsoft’s cloud. In 2019 Microsoft invested $1 billion in OpenAI and became its exclusive cloud provider; it built OpenAI a supercomputer on Azure, on which GPT-3 was trained. GPU usage, like how many GPUs were available to everybody else. If you can somehow back that out, maybe you can figure it out.

And if you know the details of their deal with Microsoft also. There’s a bunch of things to do that.

Yeah, well, I mean, there’s only so many GPUs that Azure has, right? So if something big is carving out a lot of them, you can probably infer something. It might not be zero information. That might be what I would try, if you could somehow get those figures.

Interesting. All right, so we have this collaborative research effort: Runway ML, Stability AI, two universities in Germany. And then all of a sudden onto the scene come Midjourney, Stable Diffusion, DreamBooth, then Lensa, then the things that are built on top. Like, what…

I think Midjourney was actually already well underway, because generative art — you could see it coming if you were sensitive. Like I said, all of the advances here were already in play, and as so often happens in research, putting them together is the right thing.

I think Midjourney was already being worked on before Stable Diffusion was released,90David Holz’s Midjourney opened its beta to everyone on July 12, 2022, a month and a half before Stable Diffusion came out. and certainly if you were into Stability early, if you got into their Discords and whatever early, you would have seen this coming, probably. And yeah, I think the fact that it was open-sourced sparked a lot of these things. And I think the fact that it was open source let people productize it very rapidly, because you can run your own copy of Stable Diffusion on a Mac by itself — you can run it on your own M1 Mac.91In the fall of 2022 apps like DiffusionBee appeared for running Stable Diffusion on a Mac, and on December 1 Apple itself released a version of the model optimized for its chips. And people were very quick to let ordinary people use that. People who don’t want to deal with Python, they just want to click a button. People very quickly packaged it up. And so I think that was like the six-minute-mile moment92A slip: Anton means the four-minute mile, as Packy says later. On May 6, 1954, Roger Bannister became the first to run a mile in under four minutes, and 46 days later John Landy broke his record. The "four-minute mile" has since stood for a breakthrough after which many suddenly do the impossible. History for a lot of this stuff.

And I think it was a six-minute-mile moment not just for image generation, but for large models in general. This idea that you could be a relatively small, unknown organization and build something like this changed people’s minds about what was possible. And I think because of that, we’re gonna see a lot more invested in research and a lot more smaller players contributing and pushing this stuff forward. And so 2023 is going to be pretty exciting in AI, I think.

So there’s two things there that are interesting, right? There’s the one that, just because it’s open source, now it’s easier for people to build on top of than having to get access to OpenAI’s API and build on top of that — and maybe it’s more expensive and less customizable. There’s probably some ethics stuff there too, on how customizable you want these things to be for people. But what percent of the consumer applications that we’ve touched are built on top of DALL-E versus Stable Diffusion?

I think almost all of them are built on top of Stable Diffusion, simply because the model is open source.

Got it. And then the second piece, right, is that four-minute-mile inspiration type thing, where you can now just see that a thing is possible, until like 50 people then break that time in the next year. Language is a big category, images are a big category. Does this look like building smaller foundation models within companies? Does this look like trying to tackle different chunks that are still remaining? Where do you think the model work is going to come into play from, kind of more diffuse?

Everywhere. I think all of the above. ChatGPT is out; Stability have efforts from Carper93CarperAI — a lab within Stability AI working on training language models from human feedback (RLHF), the method that turned GPT-3 into InstructGPT and ChatGPT. and other places to put InstructGPT94InstructGPT — a version of GPT-3 that OpenAI fine-tuned in January 2022 to follow instructions using human ratings; ChatGPT’s predecessor. versions out, to put ChatGPT versions out, to put Codex95Codex — OpenAI’s code model (2021), which powered the first GitHub Copilot. out.

And we’re seeing — recently someone tried to apply a diffusion model to music,96That’s Riffusion, released on December 15, 2022: Seth Forsgren and Hayk Martiros fine-tuned Stable Diffusion on spectrograms — "pictures of sound" with time across, frequency up and loudness as brightness. The generated spectrogram is then converted back to audio. and it kind of works. I don’t know if you saw this.

Yeah, and it’s kind of funny the way that it works. They just encode the music as an image and then they diffuse an image. It’s like, okay, I guess that works. Which is pretty funny. It’s also how Whisper works.97Whisper (OpenAI, September 2022) — a speech recognition model: the transformer takes a spectrogram of the audio, the same kind of "picture of sound," and outputs text.

Huh. I didn’t know that.

Yeah, they just shove the right encoding of a spectrogram in, and then it just kind of goes. And that was a transformer model, but this one is a diffusion model. So I think it’s just gonna keep coming. And like I said, there’s so many little things that just somebody with a computer can do, can genuinely contribute. And I think that it’s also easier to convince people right now to give you a little bit of compute because you want to try an experiment, because that experiment could probably benefit everybody. So I think we’re just gonna see it from everywhere.

It wouldn’t surprise me if another totally unknown research group somewhere, which is like five people, delivered something really spectacular, because they just cracked some nice little neat puzzle and it turned out to work better than everything else. That wouldn’t surprise me at all in the new year. I think we’re gonna be surprised and disappointed, actually. I think these are neat novel toys right now, but realistically, nobody’s figured out how to build something valuable yet.98A month after this recording, ChatGPT had 100 million monthly users by UBS’s estimate — faster growth than any consumer service before it. Reuters They’re just kind of cool. And certainly I’ve been getting value out of ChatGPT, and it’s fun to play with Stable Diffusion or DALL-E, but it’s unclear what we want to do with them.

And people are working on it. There’s tons of companies who are working on all kinds of different verticals, and it’s likely that some of them will succeed. But the future is very unclear. And it’s also unclear who’s actually going to capture the value.

12Who profits and when AI goes mainstream

Anton is sure the owners of compute win either way, and that AI will go mainstream after some big event, likely a fake news story.

100%. We could do a whole episode on — yeah, I think that’s a fascinating one to me.

I mean, I talked to everybody in this space. I talked to researchers and founders and investors and just random people. And I asked them, who do you think is actually going to make this useful? And then, even if somebody makes it useful, who’s going to make money? And obviously OpenAI has the bet that, okay, they own the model, so they’re going to be able to make money off all of the products that get built on top of it. But the compute providers kind of win in every direction here. If you own GPUs, you’re probably going to be able to make money from them.99The prediction came true many times over: the biggest winner of the AI boom was Nvidia, which in October 2025 became the first company ever worth more than $5 trillion. And the more popular, the more successful things get, the more valuable compute becomes as well.

If a business model in this space proves to be successful, there’s going to be competitors, and competitors need compute. So everyone needs compute.

So I don’t know. I wonder — it’d be interesting to look at even, like, what…

Invest in Lambda Labs,100Lambda sells and rents out GPU servers for deep learning — the same company that estimated GPT-3’s training cost. I guess. I don’t know.

Yeah, what percent of the value of the past decade of startup growth has been captured by founders and employees, investors, and AWS? Like, AWS’s share is probably a pretty huge chunk of that.

Yeah, but at the same time, it’s kind of like what we were talking about before with the cargo container. It’s induced demand.101Induced demand — a transportation economics idea: a new road doesn’t relieve traffic but generates new trips. Here, cheap cloud capacity created startups that wouldn’t otherwise exist.

The fact that it’s possible makes more demand appear out of the ground. The demand is latent and couldn’t be captured before. So yeah, maybe AWS is capturing a large fraction, but that fraction wouldn’t have existed without AWS either.

Yeah, no, 100%.

We’ll see. And I think there’s other concerns too. I’m kind of glad that we’re in crypto winter102Crypto winter — the 2022 crypto market crash, after Terra collapsed in May and FTX in November. GPUs also freed up because on September 15, 2022, Ethereum abandoned mining for proof-of-stake, leaving miners’ graphics cards idle. and we can use GPUs for something cooler. Some people are probably less glad than me, but I’m glad. But we really will have to start asking questions like, are we using all this energy for something useful, or are we just kind of spinning here? And I think that’ll get shaken out over the next few years as well.

We’ll see. The public conversation hasn’t really started. I think what’s surprising is this stuff is still not mainstream. And people are gonna go home over the new year and they’re going to show people, like, here’s ChatGPT, here’s what AI is doing. And that’ll get a bump. But then I don’t know when this goes mainstream.

There has to be an event or thing, or it has to diffuse enough through the culture somehow for people to be aware of it. Because it hasn’t reached that point. It’s not like the iPhone, right? When the iPhone launched, people started saying the word "smartphone" a lot, or "iPhone" a lot. It’s not in the discourse. We haven’t seen it on — I don’t know what the late-night shows are.

It was on… I was surprised to see, because there was that initial kind of tech Twitter "oh, look at the New York Times, they haven’t even mentioned this. They’re mentioning Elon and blah blah blah, but they haven’t even mentioned ChatGPT, and it’s the most important thing in the world." And then they did a bunch of articles on it. Kevin Roose went on The Daily103The Daily’s episode "Did Artificial Intelligence Just Get Too Smart?" came out on December 16, 2022. Kevin Roose is a New York Times tech columnist and co-host of the Hard Fork podcast. and did a whole episode on ChatGPT. And so it felt like maybe there’s a little awareness there. I think you’re absolutely right. I’m glad that we’re recording this right before the holidays, so that people can go home and show their families both what’s going on on the image generation side and also ChatGPT. But yeah, I don’t know what that thing is, because ChatGPT has been a ton of fun, but it’s like a background thing, where if I’m writing an article on Aleo104Aleo — a blockchain whose applications are private by default thanks to zero-knowledge proofs. Packy’s essay on it, "Aleo: Can You Keep a Secret?", ran in Not Boring in December 2022 as a sponsored piece. Not Boring and zero-knowledge proofs,105A zero-knowledge proof is a cryptographic protocol in which one party convinces another that a statement is true without revealing anything beyond that. there were some things that I was reading in the papers where it’s just like, in this particular context, what does that mean?

And it’s actually pretty good. And I would never copy and paste it in, but it’s telling me what kind of things I should be thinking about in that space. But that’s how I use [unclear].

That’s how I use Copilot. I don’t use Copilot to write code for me. I’m like, I really don’t want to Google how to use this API. I’m just gonna ask it, what functions do you think are relevant here? And then I’ll just go look them up specifically. That’s really how I use it.

And it’s really useful. Yeah, but it’s not sexy enough to go public. Yeah, exactly. And so what are those things? I mean, because it’s year-end — this is the last one we’re doing this year — I think a fun way to end it: what are a couple of… "predictions" is a strong word, because nobody gets their New Year’s predictions right, but a couple of possible avenues where you see this breaking out in the next 12 months?

I don’t know. The big one is, like, national news turns out to be fake.106Partly true, and soon: in March 2023 millions took a Midjourney image of Pope Francis in a white puffer coat for a real photo, and in May a generated "photo" of an explosion near the Pentagon spread on Twitter and briefly knocked the US stock market down. Look at the hand holding the bottle and the crucifix chain — typical generation flaws of the time.Pope Francis in a white puffer coat: a Midjourney image that millions of people took for a real photo in March 2023. I think that could be one that really instantly makes everybody aware: something everybody thought was true turned out to be deepfaked.

Interesting. I hope that’s not the one, because that would set the conversation down a bad path.

Yeah, it would be pretty bad. I think that maybe the discussion around art breaks through into the mainstream. I think that’s pretty unlikely. Most people don’t care enough, unfortunately. They’re just not engaged with the creative process enough. They just like what they like. It could be that… I don’t know. This one is really, really hard to predict. It’s unknown. I think the other thing that might happen, that might be really bad, is that hyper-targeted, down-to-the-individual propaganda could start happening.

But that’s one of those things where it’s too fuzzy to be made aware of, because propaganda — foreign propaganda — is already in the national conversation, so it’s hard to break away from it.

Back to your artist point, though. I think one of the interesting things — and this just might be a me thing, having spent a bunch of time talking to you about this, and a bunch of time in crypto — I think there’s something really interesting that might happen when people start passively… like, the first article is about somebody who’s made a million dollars because their stuff was used in models. And so they’re passively making all of this money without even necessarily opting in really ahead of time. People love talking about people making money. That feels like a really interesting one to me: when people can just have stuff that they’ve put out there in the past, and it starts getting credit and then money from being used in models.107Similar schemes did appear, though without millions for individuals: since 2022 Shutterstock has paid contributors from a fund when their photos are used for training, and Adobe pays bonuses to Adobe Stock contributors whose work trained its Firefly generator.

Yeah, that’s another good reason to try to crack the attribution problem. The thing about that, though, is it’s unclear if anybody is making money doing this. Somebody has to be making money doing it before someone can get paid a million dollars. The scuttlebutt is that Midjourney is doing really well.108Midjourney never raised venture money and earned from subscriptions from its first months. Obviously it was bootstrapped. I think a few other people are doing really well. So we’ll see. Maybe that will kick off.

I think Lensa’s made $7 million since we started this conversation an hour ago.109An exaggeration for laughs, but the order of magnitude is right: by Appfigures’ estimate, Lensa made over $37 million in net revenue in the 60 days after launching avatars — about $600,000 a day. Appfigures

Yeah, Lensa is definitely right now making a lot of money, but Lensa is this concrete, narrow application which blew up on TikTok.

So I don’t know how sustainable that is. It’s definitely of the moment. We’ll see. I hope so.

All right, Packy, this was great. Great to talk. And next time, let’s talk about the data behind Stable Diffusion. Let’s talk about LAION and how it came to be.110The fifth episode of the series did turn out to be about training data, and the sixth about Stable Attribution.

That sounds good to me. Awesome. Anton, thank you for teaching me AI this year. Happy holidays, and we’ll talk in 2023.

Talk then. Bye, Packy.

Chapters
  1. 1Why this paper set off the image boom
  2. 2Before latent diffusion
  3. 3Figure 3: the autoencoder, CLIP and web captions
  4. 4A detour: Salesforce, junior jobs and shipping containers
  5. 5Latent space and noise
  6. 6Prompting through attention, training and generation
  7. 7What the guidance scale does
  8. 8Training data, retrieval models and avatars
  9. 9Artists, attribution and copyright
  10. 10The real danger is new media
  11. 11Who built Stable Diffusion and why openness matters
  12. 12Who profits and when AI goes mainstream

Related episodes