<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Aarav Gupta on Medium]]></title>
        <description><![CDATA[Stories by Aarav Gupta on Medium]]></description>
        <link>https://medium.com/@gupta-aarav?source=rss-893cf16f92cd------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dmbNkD5D-u45r44go_cf0g.png</url>
            <title>Stories by Aarav Gupta on Medium</title>
            <link>https://medium.com/@gupta-aarav?source=rss-893cf16f92cd------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 05:38:13 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@gupta-aarav/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[The Hitchhiker’s Guide to Diffusion LLMs]]></title>
            <link>https://generativeai.pub/a-computer-scientists-guide-to-diffusion-llms-ce8aec8c96cd?source=rss-893cf16f92cd------2</link>
            <guid isPermaLink="false">https://medium.com/p/ce8aec8c96cd</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[diffusion-models]]></category>
            <category><![CDATA[llm]]></category>
            <dc:creator><![CDATA[Aarav Gupta]]></dc:creator>
            <pubDate>Tue, 16 Dec 2025 14:02:16 GMT</pubDate>
            <atom:updated>2025-12-17T07:49:32.858Z</atom:updated>
            <content:encoded><![CDATA[<p>What are they, how do they work, and why should you even care?</p><h4>Let’s Set the Scene — Large Language Models</h4><p>Large Language Models are massive models on the order of billions of parameters, focused on learning natural language and adapting to a variety of textual tasks. The advent of these models came in 2017 when Google’s <em>Attention is All You Need </em>paper introduced the Attention mechanism and Transformer architecture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/728/0*f2veJ5rdQSjfwzQ_" /><figcaption>Illustration of Attention Mechanism</figcaption></figure><p>The Attention mechanism, in a nutshell, was a way of processing a sequence of input embedding tokens to understand how different tokens “pay attention” to each other and influence each other, which proved essential in downstream natural language tasks. Think about how such a function could help a model understand lengthy documents and sequences of tokens, or how understanding a given phrase could help a model better predict the following words.</p><p>This gets extended further, with something called “Multi-Headed Attention” where instead of one sequence operating on all inputs, multiple different “heads” operate on slices of the input sequence, allowing this operation to be parallelized and made more efficient during training and inference. It also increases how robust a model is, with different heads learning different aspects of the input in parallel.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/438/0*uIu9uwvrUPM3tIn7.png" /><figcaption>Example Transformer Block Leveraging Multi-Head Attention</figcaption></figure><p>There were different spin-offs of this architecture, focusing on blocks called “Encoders” and “Decoders”. Some models, like BERT (by Google), were Encoder-only and excelled at generating representations of text for later use (think sentiment identification, text classification, etc.) via finetuning. Others used a combination of these for tasks like translation, where one block creates an encoding of the source language via an Encoder block, which is then fed into a Decoder block to slowly generate the corresponding sequence in the target language token by token.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/356/1*mj5PP9Y5mewc9wNfKIIXrg.png" /><figcaption>Example of an Encoder-Decoder Transformer Architecture</figcaption></figure><p>After a few years of experimentation, OpenAI demonstrated the efficacy of Decoder-only models with their GPT-1 model, and these types of models have now become the norm for current LLMs with their strength at text generation. The way that these work is pretty much the same as other Transformer architectures with masked self-attention as the main change, where each token/position in the generated sequence only attends to previous ones by masking future tokens in sequence. This way, there won’t be a case where a token is dependent on a not yet generated future token.</p><p>These models are trained auto-regressively; at each timestep, the model is provided an input sequence and predicts the probability of each vocabulary token being the next one. That probability distribution is then compared to the true next token, with cross-entropy loss used to train the model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2pPCv-n70sXA5d61.png" /><figcaption>Cross-Entropy Loss Example</figcaption></figure><p>The above image is an example of the usage of cross-entropy loss, with each row in the output logit analogous to P(vocab[0]), P(vocab[1]), … being the next token in sequence, and a smaller loss indicating that the model is learning better.</p><p>With transformers, attention, and masked decoding as our building blocks, we can scale up to billion and trillion parameter models for autoregressive text generation, giving us our fancy LLMs. However, this sequential generation has drawbacks: variable latency, error propagation from early tokens, and inability to revise earlier token choices once committed.</p><h4>How Does Diffusion Come Into Play?</h4><p>Diffusion itself is a really interesting idea. It’s been around for a while, with one of the biggest papers in its domain being <em>Denoising Diffusion Probabilistic Models</em>, written by researchers at UC Berkeley. The base idea is fairly simple. Some model will learn how to gradually “denoise” some piece of data, where given some randomly sampled data, it will “diffuse” it into a clear piece of information.</p><p>The best way I can describe it is coming up with an idea. Think about how you feel like you have a fuzzy idea for something, and slowly flesh it out into a coherent plan, project proposal, writeup, or something else. The idea of diffusion is to approach content generation from this same angle. You can use some piece of randomly sampled data (i.e. an image from gaussian noise), and gradually denoise it into an image over some finite number of timesteps.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/788/1*84wZewEere6cI2TVy28CaQ.png" /><figcaption>Illustration of Forward and Reverse Noising Processes</figcaption></figure><p>Above is an example of the diffusion process. The forward “noising” process informs how the model learns the image and what it sees during training time, and the reverse “denoising” process is what the model replicates at generation time, when it generates some piece of content based off of the input noise. The noise is used to corrupt training data over a series of timesteps and the hope is that over time, the model will learn the reverse process to denoise some noisy input into a clean sample. This can be done with varying architectures (UNets or Variational Autoencoders), but it isn’t our concern for this article. The main thing we’re concerned about is just how diffusion works at a root level, and how we can potentially apply it towards language models.</p><h4><strong><em>Diffusion for LLMs</em></strong></h4><p>Here’s where it gets interesting. How can we actually apply this to an LLM? Traditionally, they’ve operated in an autoregressive manner, where they learn to generate sequences one token at a time. There are many optimizations on this with speculative decoding, resource caching, and more to help optimize this, but the generation process is inherently variable and tough to predict, as sequences are only complete when an End of Sequence (EOS) token is predicted.</p><p>Using Diffusion for LLMs helps to change this altogether. Rather than generating for an arbitrary/unpredictable number of timesteps, the sequence length is inherently finite and the number of timesteps for generation is also finite. We can follow a similar process to image diffusion and mask out tokens in different places in different rates to mimic the corruption process</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ICFr6am5zTo2CJdT" /><figcaption>Image from LLaDA Paper on LLMs for Diffusion</figcaption></figure><p>The graphic above is from the LLaDA paper, which focuses on using an architecture similar to Llama but training it for diffusion generation in 3 different methods. The first, pretraining, corrupts the entire sequence and gradually unmasks it. The second, supervised finetuning, operates on a prompt-response format and corrupts the expected response for the LLM, simulating generating a response for an arbitrary prompt. The third is sampling, which operates similarly to SFT to gradually unmask the response (“reverse process”) over a finite number of timesteps.</p><p>The most interesting thing about the application of diffusion is how it changes the function of attention. With autoregressive models, masked self-attention is used so that each token only depends on previous ones, but it also means that if something factually incorrect or low-quality is generated, then it may significantly influence the tokens generated in the future. Diffusion LLMs use bidirectional attention (shown in papers like <em>Attention Sinks in Diffusion Language Models</em>) which shows promise in generation. Not only are these models able to attend to all tokens at once, but also they can generate multiple tokens at once via the unmasking process, which can potentially make the generation process more efficient and allow the full sequence to be more aligned in its content. In addition, it can change token choices if it decides to (“correct itself”), which is one thing that autoregressive LLMs actually can’t do during the generation process.</p><p>It can potentially be more efficient in terms of decoding and generating, with the added benefit that this is a <strong>finite process</strong>. Decoding can be arbitrarily long for autoregressive models (assuming no early stopping or other techniques to adjust generation) but for diffusion based models, you know that your final sequence will be a specified number of tokens long and due to bidirectional attention, it will most likely be a coherent generation as well (whereas arbitrarily terminating autoregressive generation won’t necessarily return an output that makes sense).</p><p>However, it does have the tradeoff that the training itself will likely be more complex due to the multiple phases and noising/denoising schedules for the text and the timestep based diffusion process. In addition, it could also take more time overall for the model to train to converge to a comparable performance to autoregressive models just due to how the training process works, and it’s still unclear if these models are able to significantly outperform autoregressive LLMs or are just a more expensive solution for the same problem.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fe3k2qJh6A_1Fe0x.png" /><figcaption>Metric Comparison of Mercury Diffusion Models Against Autoregressive LLMs</figcaption></figure><p>With inference time and model serving optimizations, long sequence generation can be blazingly fast with these diffusion models. Take the Mercury line for example — they have insane throughput (tokens/sec) that is 4–5x that of Gemini flash, with comparable performance across the board on benchmarks like HumanEval, MBPP, LiveCodeBench, and others. Alongside that, the Mercury Diffusion models exhibit better performance on the “Fill-in-the-middle” benchmark than competitive autoregressive models (Gemini, Claude, GPT-4o, Qwen) reinforcing usage of bidirectional attention and the efficacy of diffusion models.</p><p>Granted, part of this is likely due to optimizations on Mercury itself that the company may not have disclosed to maintain a competitive advantage, and could potentially be matched with other inference side optimizations for autoregressive LLMs to increase throughput with minimal performance tradeoff. However, in my opinion, it’s still very telling for the potential of putting these types of models into production and their potential to compete with autoregressive LLMs.</p><p>New tools and models are being developed constantly for these types of models as well. Libraries like DiffuLlama are used to adapt autoregressive models for diffusion based tasks. In addition, companies like Mercury are deploying their models for commercial use, and Salesforce Research released a Diffusion model called CoDA, which uses diffusion for coding tasks and is able to match autoregressive performance even with the alternative generation method.</p><h4>Wrapping Up</h4><p>Diffusion LLMs are a pretty fundamental shift in how we think about text generation. Instead of predicting tokens sequentially, they iteratively refine masked sequences with bidirectional context. Whether they’ll end up complementing autoregressive models or competing with them directly is still an open question, and the field is young enough (1–2 years of serious research vs 7+ years for autoregressive LLMs) that we’re still figuring out where they excel and where they fall short.</p><p>The results seem to be promising. We’re already seeing 4–5x throughput improvements in production systems like Mercury with minimal performance loss, and the bidirectional attention seems to work particularly well for tasks like code infilling and fixed-length generation.</p><p>Interestingly, based on some research I did at Georgia Tech, Diffusion LLMs also appear to be more robust than Autoregressive LLMs on MBPP/HumanEval benchmarks when quantized to the same degree (<a href="https://drive.google.com/file/d/1qEx2UuSRWntDF3t00PFJb7wWx_0deOh3/view?usp=sharing">report</a>). At the same time, the training complexity and uncertainty around whether these gains hold across all use cases, alongside the depth of research into Autoregressive LLM optimizations, means we’re not quite at the point where you can just swap one paradigm for the other.</p><p>If you’re working with LLMs or keeping an eye on the space, it’s worth watching how diffusion models evolve. The next big breakthrough in language models might not come from scaling up transformers as much as from rethinking the generation process entirely.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*AQdD2_8sW_8peqPE.png" /></figure><p>This story is published on <a href="https://generativeai.pub/">Generative AI</a>. Connect with us on <a href="https://www.linkedin.com/company/generative-ai-publication">LinkedIn</a> and follow <a href="https://www.zeniteq.com/">Zeniteq</a> to stay in the loop with the latest AI stories.</p><p>Subscribe to our <a href="https://www.generativeaipub.com/">newsletter</a> and <a href="https://www.youtube.com/@generativeaipub">YouTube</a> channel to stay updated with the latest news and updates on generative AI. Let’s shape the future of AI together!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*EwMkzJbNqSCfScbe.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ce8aec8c96cd" width="1" height="1" alt=""><hr><p><a href="https://generativeai.pub/a-computer-scientists-guide-to-diffusion-llms-ce8aec8c96cd">The Hitchhiker’s Guide to Diffusion LLMs</a> was originally published in <a href="https://generativeai.pub/">Generative AI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>