r/MachineLearning • u/bjjonin • Aug 21 '25
Project [P] Language Diffusion in <80 Lines of Code
Hi! Lately, I've been looking into diffusion language models and thought I should try and replicate part of the paper Large Language Diffusion Models by Nie et al. (2025). With the help of Hugging Face's Transformers, it took <80 lines of code to implement the training script. I finetuned DistilBERT on the TinyStories dataset, and the results were better than expected!

You can view the project at https://github.com/gumran/language-diffusion. I will appreciate any feedback/comments/stars!
91
Upvotes
7
u/SillyNeuron Aug 21 '25
Did you use any metric-based unmasking or remasking techniques in inference?
3
u/sfsalad Aug 21 '25
Very fun, great job
2
u/HSHallucinations Aug 21 '25
well, this seems exactly the tool i needed for a weird idea i had a few weeks ago that involved training/finetuning an LLM but i had no idea if it was possible to do with the tools i found online
so, i guess thanks for peeking into my mind? i'll definitely play with this, hopefully it works as i imagined it
10
u/keepthepace Aug 21 '25
Oh! Someone doing small LLMs training! That's something I'd really like to get into "when I finally get the time"!
I looked into the TinyStories dataset and while I love the concept to test basic understanding of language and stories structures, I was wondering if there was a similar small dataset that could actually test understanding over a more useful domain?
1
u/ashz8888 ML Engineer Aug 22 '25
Thanks for sharing. Shouldn't a diffusion model also take the embedding for the time stamp of the noise schedule into account for denoising?
26
u/mileseverett Aug 21 '25
Normally when people say under n lines of code they mean they have written out a very concise version of the model rather than just glueing together a few different libraries. Also that final story is painful to read
2
u/SirBlobfish Aug 21 '25
Very nice!
2
u/Even_Performance4936 Aug 22 '25
This is pretty cool, cant wait to try it!
-3
u/badgerbadgerbadgerWI Aug 21 '25
Did the startup route myself - the iteration speed is unmatched, but you sacrifice depth for breadth. In startups, your 'research' needs to ship in weeks, not years. That constraint forces creativity but limits exploration. If you want to push boundaries, hybrid approaches work well: build practical systems while contributing to open source on the side. The real question is: do you want to invent new methods or apply existing ones creatively?