拡散系の言語モデルをゼロから自作する方が思ったより簡単だった

Reddit r/MachineLearning / 2026/4/22

💬 オピニオンDeveloper Stack & InfrastructureSignals & Early TrendsTools & Practical UsageModels & Research

要点

  • 著者は、最近Claude Codeに頼りがちだったこともあり、AIが生成したコードの助けを借りずに拡散系言語モデルをゼロから実装してみようとしました。
  • MacBook Air M2上で数時間学習し、tiny Shakespeareデータセットを使って「to be,」とプロンプトすると、完全ではないもののテキスト生成の結果を得ました。
  • 得られたモデルは約7.5Mパラメータで語彙サイズは66([MASK]を含む)で、ただし学習が十分でなかったため品質は限定的だと著者は述べています。
  • この取り組みは、トークナイザー、エンコーダ/デコーダ、(離散)拡散といった難しそうな概念を理解するための助けになるとしており、同様の試みに挑戦することを後押ししています。
  • 実装コードはGitHubリポジトリで公開されているため、興味のある読者は複製や学習に利用できます。

Since I felt like I was relying on Claude Code a lot recently, I wanted to see how hard it is to implement a diffusion language model from scratch without the help of AI-Generated code. So I built one while waiting for the training for my master's thesis.

This is what I got after a few hours of training on my MacBook Air M2. I trained on the tiny Shakespeare dataset from Karpathy and prompted "to be, "

To be, fo hend! First her sense ountier to Jupits, be horse. 

Words of wisdom! The model has around 7.5M Params and vocabulary size is 66 (65 chars + [MASK]. I definitely did not train long enough, but I ran out of time for this one.

Projects like these help me make sense of big scary words like (discrete) diffusion, encoder, decoder, tokenizer. Maybe this encourages someone :)

Check out the code here if you're interested: https://github.com/Encrux/simple_dlm

Thanks for reading! Be horse.

submitted by /u/Encrux615
[link] [comments]