← Latest papers
💬 NLP

DreamOn: Diffusion Language Models For Code Infilling Beyond Fixed-size Canvas

DreamOn is a novel diffusion framework that overcomes the fixed-length generation limitation of existing Diffusion Language Models by introducing dynamic length control states, enabling flexible, variable-length code infilling that achieves performance comparable to state-of-the-art autoregressive models without requiring architectural changes.

Original authors: Zirui Wu, Lin Zheng, Zhihui Xie, Jiacheng Ye, Jiahui Gao, Shansan Gong, Yansong Feng, Zhenguo Li, Wei Bi, Guorui Zhou, Lingpeng Kong

Published 2026-02-03
📖 4 min read☕ Coffee break read

Original authors: Zirui Wu, Lin Zheng, Zhihui Xie, Jiacheng Ye, Jiahui Gao, Shansan Gong, Yansong Feng, Zhenguo Li, Wei Bi, Guorui Zhou, Lingpeng Kong

Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer

Imagine you are trying to fill in a blank space in a story or a piece of code. You have the beginning (the prefix) and the end (the suffix), and you need to write what goes in the middle.

For a long time, the smartest computer programs (called Autoregressive Models) have done this by writing one word at a time, from left to right, like a person typing a sentence. They are very good at it.

Then, a new type of program called a Diffusion Language Model (DLM) arrived. Think of these like a sculptor. Instead of writing word-by-word, they start with a block of clay where the middle part is completely hidden (masked). They chip away at the hidden parts, refining the shape until the perfect words appear. This is great because they can fix mistakes in any order, not just left-to-right.

The Problem: The "Fixed-Size Canvas" Trap
However, these sculptors had a major flaw. They could only work on a block of clay that was exactly the size you told them to use.

  • If you gave them a small block (say, 4 hidden words) but the answer needed 20 words, they would run out of space and give you a broken, incomplete answer.
  • If you gave them a huge block (say, 64 hidden words) but the answer only needed 4 words, they would get confused and fill the extra space with nonsense or repetitive garbage.

The paper calls this the "Fixed-Size Canvas" problem. The model is stuck waiting for you to guess the exact right size of the hole before it starts working. If you guess wrong, the result is bad.

The Solution: DREAMON
The authors introduce DREAMON, a new way to teach these sculptors how to change the size of their clay block while they are working.

They added two special "magic commands" to the model's vocabulary:

  1. [expand]: "I need more space! Turn this one hidden spot into two hidden spots."
  2. [delete]: "I have too much space! Remove this hidden spot entirely."

How It Works (The Analogy)
Imagine the model is drawing a picture inside a frame.

  • Old Way: You tell the model, "Draw inside this 10x10 square." If the picture needs to be 20x20, the model is squished. If it needs to be 2x2, the model is wasted space.
  • DREAMON Way: You give the model a frame, but you let it hold a remote control. As it draws, if it realizes the picture is getting too big for the frame, it presses [expand] and the frame magically grows. If it realizes the picture is tiny and the frame is huge, it presses [delete] and the frame shrinks.

The model does this entirely on its own, based on what it thinks the answer should look like. It doesn't need you to tell it the length beforehand.

The Results
The researchers tested this on coding tasks (filling in missing parts of computer programs).

  • Before DREAMON: The diffusion models were terrible at this if the "hole" size didn't match the answer perfectly. Their performance dropped by about 38% just because the size was slightly off.
  • After DREAMON: The models became as good as the best "word-by-word" writers (the autoregressive models). They could handle holes of any size, growing or shrinking the answer until it was just right.
  • Efficiency: They also added a trick called "Deletion Broadcasting." If the model decides to delete a huge chunk of the frame, it doesn't do it one tiny piece at a time; it deletes the whole chunk instantly, making the process much faster.

In Summary
DREAMON takes a powerful but rigid tool (Diffusion Models) and gives it the flexibility to stretch and shrink its output. It removes the need for humans to guess the perfect answer length, allowing these models to finally compete with the best code-writing AI we have today, but with the added benefit of being able to fix things in any order.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →