Teaching local LLMs to play chess.
tl;dr
This is a chronicle of me playing with small language models by Liquid AI, trying to teach them to play chess.
I started teaching LFM-2.5-1.2b to play chess (SFT, then GRPO with and without a curriculum and process reward). But I hit a ceiling on my puzzle benchmark[1] and switched to training a decision model instead (d1-omni-600M) where I needed less data and compute to get good results.
play against the final model!evaluating
Chess puzzles are a good measure of raw chess reasoning ability. Of course at the end I care about performance in playing chess, but it takes longer to test the model on 20-30 games, and even on those 20-30 games many possible positions are not reached.
I therefore built a benchmark from the Lichess puzzle database[1] with 1,000 puzzles. It was important to me that it contained varied situations and difficulties. The benchmark contains 20 puzzles for each of 50 themes (mating patterns, tactics, endgames, mates in 3 to 5), spread evenly over five difficulty bands from a 399 to a 2792 Lichess rating. It's on Hugging Face[2].
I did many experiments. This is how all of them perform on my benchmark:
LFM2.5-1.2B, prompted 0.0% + SFT v1 (24k rows) 0.0% + GRPO v1 0.0% + SFT v2 (1.3k rows) 0.0% + curriculum GRPO 0.0% + curriculum + process 0.0% d1-3B, base 0.0% + LoRA SFT 0.0% d1-omni-600M, base 0.0% + SFT 0.0% + 3-ply search 0.0%
part 1: Fine-tuning LFM-2.5-1.2b
Before training -> prompting. For that I built a custom harness with three tools: , and . This allows flexibility for playing larger games. Models can choose when to see the board, see a list of all current legal moves and make the last move. It is adapted from this benchmark[1].
With prompting, the model solved only 15 puzzles. Most of the puzzles failed on the tool protocol.
I created a dataset for SFT[1] with 24k full puzzle conversations, using deepseek-v4-flash with access to Stockfish traces as the teacher model. SFT taught LFM-2.5-1.2b to use the protocol correctly (0% -> 100% valid tool calls) and improved the performance of the model on chess a bit (1.5% -> 6.7%). But I had hoped that the 24k rows would have had a larger impact.
I then continued with GRPO (sampling 8 times per puzzle) with a simple reward: +1 for the right puzzle move, 0 for a wrong one, −0.5 for an illegal one. Performance on puzzles doubled to 13.0% and illegal moves almost disappeared.
But two unwanted things started to happen. First the model stopped exploring: 8 samples of the same position gave on average 1.7 different moves.
Second, training stalled around step 300 of 600. My hypothesis is that the easy puzzles the model could learn from ran out, and the hard ones only gave a sparse signal.
Before training further, I tested whether sampling at a higher temperature would get the GRPO model exploring again. At 1.4 it found the right move more often across its 8 tries, but the reflections that the model wrote before making a move made no sense. Here is an example:
The check Rd1# delivers immediate checkmate, as the white king has no legal escape and half the pieces are helpless. The rook from d7 captures behind the white pawn on d2, giving horarian assault to mate. White’s inhibits coordination—encoding together pieces trapped by the past exposing No.1 проход. No preparation reply confronts the fork-line: you finish inside Feint will call can’t help beyond finality; White deflected its own pieces one resource 높シート culminating on this public square with no Architekt angle either avoid annihilation.
Training at T=1.4 would have rewarded nonsense that happened to end in the right move, so I kept the temperature at 1.0.
This mainly showed me that the reflections never meant much: both nonsense and clean reflections picked the right moves.
Taking a closer look at the data I used for SFT, most rows named the final move in their first words. This likely taught the model to pick a move first and justify it after. I also realized that many of the rows I used for SFT contained chess inaccuracies.
I decided to start from scratch: I created a smaller dataset[1] (~1,300 rows, SFT v2) for SFT with claude-sonnet-4-6 and a loop that verified if the reflections had chess inaccuracies.
This smaller SFT run taught the model to use the tools in the harness. The fine-tuned model solved 3.7% of the puzzles against 6.7% for the first SFT. That was expected, I knew most of the learning would happen during RL.
I thought that the model was previously getting to hard positions too soon, and therefore it hadn't had the chance to learn chess basics before attempting the harder puzzles.
So I built a curriculum[1]: I divided Lichess puzzles into four stages of difficulty (about 19k each), sampled every stage again with the current model, and the puzzles where none of the 8 tries got a result were tried in a subsequent stage.
The model after this GRPO run reached 15.4% on my benchmark. But when I read the reflections, they had collapsed into a very specific template: The model again mentioned the final move in the first words of the reflection and had very repetitive wording.
The queen slides to h8 delivering immediate checkmate, as the queen covers h8 and the king on h7 is hemmed in by its own pawns on h6 and g7. The knight on d4 and pawns on h6 and g7 block any escape routes, while the pawns on a7 and b7 seal off the seventh rank. This mate is the fastest and most direct finish, exploiting the queen's reach and the black king's cramped position.
I think RL taught the model (again) to decide a move before reflecting and then write a chess sounding text.
I also did an experiment: I could review the correctness of the reflections by training a model to extract every move, square and claim in a reflection, and then check the correctness of these claims via python-chess.
I finetuned LFM2.5-Encoder-230M to do that (how the encoder works[1], see it in action[2]). Here is a pre-computed example:
The queen slides to h8 delivering immediate checkmate, as the queen covers h8 and the king on h7 is hemmed in by its own pawns on h6 and g7. The knight on d4 and pawns on h6 and g7 block any escape routes, while the pawns on a7 and b7 seal off the seventh rank. This mate is the fastest and most direct finish, exploiting the queen's reach and the black king's cramped position.
I thought I could use this encoder model to have a “less sparse” reward and do GRPO on chess puzzles. The GRPO run would penalize runs where the reflection didn't have the final move at the end and had chess mistakes.
This last experiment (the same SFT v2 start and curriculum) where I tried rewarding good chess reflections had mixed results.
False facts in reflections fell from 53% to 24% and self-contradictions from 39% to 5%, but puzzles stayed at 13.4%, against 14.2% for the curriculum alone after the same stage.
I stopped this last run after stage 3. The model wasn't learning much. After every stage I had to change the reward or retrain the encoder model, because of reward hacking: RL kept finding ways around the encoder model and my evaluation. Probably I could have continued this game with more patience and compute, but I had neither.
part 2: a decision model
My goal was to play against a language model trained by me and actually lose. LFM-2.5-1.2b wasn't getting there. And then Liquid released d1-3B and d1-omni-600M. So I decided to pivot this project.
same move, without writing a single token
From here on I trained on chess positions instead of conversations given that the decision models answer directly.
More specifically, I trained the decision model to answer two questions. First “Which move is best?” where the options are the legal moves on the specific position. And “How good is this position for the side to move?” where the options are 10 levels of win chance (0-10%, 10-20%, …, 90-100%). Stockfish's evaluation gives the right answer for both.
d1 plays Rf6# ✓ Stockfish's best
label: Rf6# (Stockfish's best move, depth 245)
d1's expected win chance for White: ~93%
label: 100% (Stockfish: mate in 1 for White)
over 999 positions from that same part: d1's expected win chance is off by 7.8 points on average, its tallest bar is within one level of the label on 90%, and its top move is Stockfish's best on 29%.
I first ran SFT on d1-3B with 120k Stockfish-labelled positions[1]. 6k came from Lichess puzzles and 114k from Lichess games[2] (September 2026, three positions per game). This got d1-3B to 16.2% performance on the puzzle benchmark.
Given that the decision models use less compute (one forward pass per move instead of ~150 tokens), I thought that I could afford RL on whole games. d1-3B could play thousands of games against Stockfish and I could reward the wins. But this didn't work.
First playing games takes long. One iteration was 128 games against Stockfish, and then training on ~3k moves from those games took ~7.5 minutes on an A100. A game is ~47 moves of d1, but it ends in one result, so most of the time goes into playing for very little signal. In an early experiment with 28 iterations (~3.5 hours, ~4k games) blunders stayed at ~8.5% of moves, and the model got worse at puzzles (16.2% -> 12.9%).
At the same time I was considering this RL run, I found the Lichess evaluation database[1]. It contains millions of positions that Stockfish already analysed at high depth. Suddenly I had a lot of already evaluated data that I could use directly for SFT.
With my limited compute and this much data, trying the smaller model made sense. d1-omni-600M trains about 5× faster than d1-3B, so I could train it for longer on more data.
I trained d1-omni-600M for 9 rounds on ~1.5M positions: ~1M from the evaluation database plus ~0.5M from new games Stockfish labelled on the VM's CPUs while the GPU trained. It got to 42.1% of puzzles without search, and it was still improving when I stopped. I could probably have continued training d1-omni-600M, but I didn't want to burn all of my Colab credits yet (more experiments are coming).
I then added a small search on top and it helped a lot: its score against Stockfish 1700 goes from 12.5% to 62.5%.
The search chooses a move by using both questions from above. The move question picks which moves to try: d1's top 3 moves, then the top 3 replies to each (simulating the opponent), then d1's top 3 answers to those. That gives 27 positions at the end of the tree. The win-chance question scores each of them.
But d1 doesn't just pick the best of the 27, because the second move of every line is the simulated opponent's. So the scores go back up the tree: at each position, the side to move takes the move that is best for them. A first move is only as good as what is left after the opponent's best reply, and d1 plays the first move with the best overall result.
So this is where it stands: a 600M decision model that solves 42.1% of my puzzles in one forward pass and, with a small search on top, scores 62.5% against Stockfish 1700. Can you beat it?[1]
To fit the model in the browser I quantized it. The matrix weights go from 32 to 4 bits and the embeddings from 32 to 16 bits (fp16). This makes the model go from 1.5 GB to 339 MB. On the 1,000-puzzle-benchmark the quantized version picks the same move as the full model 91% of the time, and solves 40.5% of them (close to the 42.1% of the non-quantized version).
That was still too much for phones. iPhones closed the tab on the model's first search. So I further quantized the embeddings from 16 to 8 bits. The model file size goes from 339 MB to 272 MB and uses about a quarter less memory in the browser, and on the benchmark it plays the same as before: 40.5% of the puzzles solved, and the same move as the full model 91% of the time.
But this improvement was still not enough. The site kept crashing on my iPhone. So I let Claude Code run an optimization loop overnight. It did a change at a time and measured the result in a browser (Chrome for desktop, Safari's engine for the iPhone) on speed, memory and download size. This loop ran on the copy in the browser, which I had also fine-tuned to understand voice. A change was only kept if d1 still solved about the same 38.4% of puzzles in one pass and understood the same 80.8% of my recorded voice commands. 19 changes were kept and 19 dropped.
That voice part needs explaining, because this is where I decided to make the model listen to me. d1-omni-600M also takes audio as input (that's the “omni”), and until then I wasn't using that piece of the model at all. Before fine-tuning it got 0 of 25 spoken moves right. So I fine-tuned it on about 1,100 commands I recorded myself, plus generated speech and written commands. Now the browser copy gets 22 of those 25 right, and you can hold a button and say your move. It cost a little chess: this copy solves 38.4% of the puzzles instead of 40.5%.
d1 plays Ne5 for me
“knight e5” (what I said, d1 only gets the audio)
The biggest wins were not in the model. d1's prompts only use 1,930 of its 65,536 tokens, so cutting the rest of the embedding table made the download 65 MB smaller and each position a quarter faster. On the iPhone the problem was onnxruntime itself: my hypothesis is that compiling its 27 MB WebAssembly file was what closed the tab. A build of the same engine for JSPI is 17 MB and uses about a third less memory, so phones now search 3 moves ahead too. In the search, looking deeper beat looking wider, and adding the move's own probability to its score found 1-3% more puzzle moves.
The last step only runs in desktop Chrome: most of the model's matrix multiplications in 16-bit floats instead of 32. Each position takes 59 ms instead of 72, and it solves one puzzle fewer (38.3% instead of 38.4%). That is the only accuracy the whole loop lost.
97 ms -> 59 ms (-39%). Chess puzzles solved 38.4% -> 38.3%, voice commands right 80.8% at every step.
- start
- vocabulary
- answer cache
- voice up front
- phones: 1.22
- JSPI build
- phones search
- policy blend
- fp16
When learning about building a curriculum for RL I stumbled on this paper[1], for which I built this video[2] with my skill[3]. Try the skill!
Right when I finished this write-up, Liquid released a new set of models (LFM3). So this chronicle is maybe not over. Follow me on X[1] to see what comes next.