Giles Thomas

Giles Thomas

@gilesthomas.com

Building LLMs, learning in public / Founded and led @PythonAnywhere.com / PSF Fellow / Writing at gilesthomas.com

227 followers67 following143 posts

Pinned

Interesting. By replacing the embedding layer with a low-rank bottleneck, I managed to *improve* my model's test loss while reducing parameter count by from 163M to 131M. Only two runs, so far from proven, but it's a surprising result! www.gilesthomas.com/2026/10/low-...

gilesthomas.comFun with low-rank vocab matrices (and a bonus test loss reduction?)I was told you can swap an LLM's embeddings and output head for low-rank factors without hurting the loss much. Was that true? Not in my tests. But doing just the embeddings seemed to improve it!

The real winner was using built-in PyTorch normalisation classes -- both nn.LayerNorm or nn.RMSNorm are *way* faster than hand-rolled versions, and weirdly (in these tests) got better loss too -- though I think that must be chance.

I extended the GPT-2-style code from @rasbt's "Build a Large Language Model (from Scratch)" so that it was a 6-expert (2 active) mixture-of-experts, and trained it from scratch over 8 days. It worked well! Full writeup with maths and code at www.gilesthomas.com/2026/09/gpt-...

gilesthomas.comExtending Raschka's GPT-2: an MoE trained from scratch on an RTX 3090How mixture-of-experts LLMs work, both in theory and in real working code based on 'Build a Large Language Model (from Scratch)'.

Giles Thomas reposted

Replying to @gilesthomas.com

And that's it! After 18 months, the capstone in my LLM from scratch journey. To test my knowledge, I built GPT-2 small in JAX, using just my notes. It worked really well, and I found an interesting way to put it together bit-by-bit, watching the loss go down. www.gilesthomas.com/2026/07/llm-...

gilesthomas.comWriting an LLM from scratch, part 34b -- from bigrams to GPT-2, one component at a time (in JAX)The capstone of my LLM from scratch journey: building up from a bigram-style model to GPT-2 small in JAX, watching the loss fall as each component goes in.

Giles Thomas reposted

Replying to @gilesthomas.com

Coming to the end of my LLM from scratch journey... I'm building a GPT-2-small in JAX, and decided to build the training loop first, then build the model step-by-step. Here's how I build the training loop. www.gilesthomas.com/2026/06/llm-...

gilesthomas.comWriting an LLM from scratch, part 34a -- building a JAX training loop for an LLM training runI'm going to build an LLM from scratch in JAX, but I wanted to get a training loop working first so that I could put it together piece by piece.

WiFi has made home wired networking boring for the last 20 years or so, I think, but 10Gb/s "fixes" that :-) I've had a bit of fun over the last two weeks doing an upgrade, here's part 1 of a two-part writeup: www.gilesthomas.com/2026/04/10g-...

gilesthomas.com10Gb Ethernet: what I had to (re)learnWired networking in the home and small offices has been pretty stagnant for ages, so upgrading my home from 2.5Gb ethernet to 10Gb meant I had to (re)learn a few things.

Giles Thomas reposted

Giles Thomas reposted

Replying to @gilesthomas.com

The appendices in "Build an LLM (from Scratch)" have a lot of really useful stuff. Should I have read them before heading off on my own training runs? I think no -- it would have saved time, but by trying, failing, and trying again, I learned more. YMMV! www.gilesthomas.com/2026/04/llm-...

gilesthomas.comWriting an LLM from scratch, part 33 -- what I learned from finally getting round to the appendicesI've finished the main body of Raschka's book -- here are my thoughts on the appendices, and why I'm glad I read them after learning things the hard way.

Giles Thomas reposted

Replying to @gilesthomas.com

Some interesting results with instruction fine-tuning. In general you'd expect that a model with lower loss on your test set would fine-tune to do better instruction-following. But the correlation doesn't seem as close as I would have thought: www.gilesthomas.com/2026/04/llm-...

gilesthomas.comWriting an LLM from scratch, part 32l -- Interventions: updated instruction fine-tuning resultsI wanted to revisit the instruction fine-tuning tests that I'd put on hold, and try them with my new models. I found that loss predicts real-world usefulness much less than I would have thought!

Giles Thomas reposted

Replying to @gilesthomas.com

Training a new GPT-2-small-style base model on my RTX 3090 in 40 hours: gradient accumulation, along with some of the other interventions I've experimented with, got me almost (but not quite) all the way to the quality of the original OpenAI model! www.gilesthomas.com/2026/04/llm-...

gilesthomas.comWriting an LLM from scratch, part 32k -- Interventions: training a better model locally with gradient accumulationHaving worked out which combination of interventions into my model and training run improved loss the most, it was time to see how well that worked with a local run, which meant I had to learn about g...

Giles Thomas reposted

Giles Thomas reposted