Build and Train a GLM-5.3-Flash Model From Scratch with Python
Beau Carnes
GLM-5.3-Flash combines linear and sparse attention, a mixture-of-experts design, and manifold constrained hyperconnections. A scaled-down version with 25 million parameters can be built in Python and trained on a standard CPU.
We just published a course on the freeCodeCamp.org YouTube channel that will teach you how to build and train a multimodal language model from scratch, covering both pre-training and post-training. The course is from @vukrosic, and all of the code, slides, and experiments are in the GitHub repository linked in the video description.
The model uses a 260-token byte-level vocabulary, a 192-token context, and a small vision encoder that turns a 32 by 32 image into 16 tokens.
In this course, you will learn:
- Tokenization & Embeddings
Why a small model needs a small byte-level vocabulary and how weight tying shares one matrix between the embeddings and the output head.
- Linear & Sparse Attention
How linear attention keeps a fixed-size memory of recent tokens while every fourth layer uses sparse attention with an indexer to find distant details.
- Mixture of Experts
How tokens are routed to a few chosen experts plus a shared expert that learns information common to every token.
- Adding Vision
How images are split into patches with 2D RoPE and merged into image tokens so the model can recognize digits.
- Pre-Training Experiments
How data diversity, interleaving, and curriculums affect learning, including how interleaving helps prevent catastrophic forgetting.
- Reinforcement Learning
How to design reward functions, compute advantages as in GRPO, update only the final layers, and test group size, temperature, and seeds.
After reinforcement learning, the model goes from solving 0 of 24 Python tasks to 16 of 24.
Watch the full course on the freeCodeCamp.org YouTube channel (44-minute watch).
Recommended courses from our partners (sidebar)
(opens in a new tab) ADVERTISEMENT-
On Scrimba
Learn JavaScript
Per Borgen
9h 21m
9 hours 21 minutes
Beginner
View course
(opens in a new tab)
-
On Scrimba
Learn HTML and CSS
Per Borgen
5h 40m
5 hours 40 minutes
Beginner
View course
(opens in a new tab)
-
On Coursera
Small Business Marketing Using YouTube
Julia Arteno
4.6 out of 5 stars (1,442) from 1,442 ratings
1h 55m
1 hour 55 minutes
Beginner
Certificate
View course
(opens in a new tab)
-
On Udemy
YouTube Marketing: Grow Your Business with YouTube
Phil Ebiner and Video School
4.6 out of 5 stars (1,460) from 1,460 ratings
4h 58m
4 hours 58 minutes
Beginner
Certificate
View course
(opens in a new tab)
Beau Carnes
I'm a teacher and developer with freeCodeCamp.org. I run the freeCodeCamp.org YouTube channel.
If this article was helpful, .
Learn to code for free. freeCodeCamp's open source curriculum has helped more than 40,000 people get jobs as developers. Get started
Recommended courses from our partners
(opens in a new tab) ADVERTISEMENT-
On Scrimba
Learn JavaScript
Per Borgen
9h 21m
9 hours 21 minutes
Beginner
View course
(opens in a new tab)
-
On Scrimba
Learn HTML and CSS
Per Borgen
5h 40m
5 hours 40 minutes
Beginner
View course
(opens in a new tab)
-
On Coursera
Small Business Marketing Using YouTube
Julia Arteno
4.6 out of 5 stars (1,442) from 1,442 ratings
1h 55m
1 hour 55 minutes
Beginner
Certificate
View course
(opens in a new tab)
-
On Udemy
YouTube Marketing: Grow Your Business with YouTube
Phil Ebiner and Video School
4.6 out of 5 stars (1,460) from 1,460 ratings
4h 58m
4 hours 58 minutes
Beginner
Certificate
View course
(opens in a new tab)