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].

50 themes × 20 puzzles · hover a square, click to open it
44 themes · 4 puzzles in every band6 uneven
399–980981–12891290–16111612–20002001–2792
The puzzle benchmark tried to be as balanced as possible in both puzzle difficulty and puzzle type. The 6 themes on the right don't have 4 puzzles in every band.

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% 
Performance of every model I finetuned on my benchmark of 1,000 puzzles, where every move of a puzzle has to be right. d1-omni-600M ran in fp32 on a Mac without search (42.1%), and in bfloat16 on a Colab A100 with search (60.2%: 3 plies ahead on the top 4 moves).

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].

illustration: one turn of a puzzle through the three tools
One move through the harness: look at the board, ask for the legal moves, reflect, then move.

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.

prompted
+ SFT
+ GRPO
solvedwrong moveillegal move or broken tool call
How each of the 1,000 puzzles ended.

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.

SFT: 7 different moves of 8
········0 distinct
GRPO: 2 different moves of 8
········0 distinct
puzzle 5FJz1 at temperature 1.0 · gxf7+ is right · over all curriculum puzzles: SFT 5.7, GRPO 1.7 different moves
Eight tries at the same position. After GRPO the model keeps playing the same wrong move: Bxf7+ in 6 of 8 tries, where gxf7+ wins.

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:

puzzle hbcVN · temperature 1.4 · played d7d1, the right move

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.

A reflection at temperature 1.4. Highlighted: words in other scripts; underlined: made-up words. The move at the end was still right.

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.

0%50%100%50%54%58%nonsensemovesT=0.81% nonsenseT=1.03% nonsenseT=1.218% nonsenseT=1.487% nonsenseT=1.6100% nonsense51.8%53.8%55%57.2%55.9%
nonsense reflections (left axis)puzzles with a right move in 8 tries (right axis)
Raising the temperature made more reflections nonsense but found the right move more often. At the best temperature for moves, 87% of the reflections were nonsense, so the reflection wasn't what picked the move.

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.

stage 1…stage 2…stage 3…stage 4…
each dot is a group of puzzles; yellow = at least one of 8 tries was right (a training signal)
The curriculum: four stages from easy to hard. Puzzles where none of the 8 tries was right give no signal, so they move on to a later 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.

puzzle 2nNFF · curriculum model · played Qh8+, not mate · the puzzle wanted Qg8+

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.

A reflection of the final curriculum model on benchmark puzzle 2nNFF. It names the move in its first words and calls it mate. After the curriculum, 95% of the reflections named the move in their first words (0% after SFT v2), and 93.5% contained “immediate checkmate” (3% after SFT v2).

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.

  • ✓ move: Qh8+ is legal
  • ✗ claim: mate: not mate: Kxh8 and Kg6 are legal
  • ✓ square: black king on h7
  • ✓ square: black pawns on h6, g7
  • ✓ square: black knight on d4
  • ✓ square: black pawns on a7, b7
  • ✗ claim: mate: still no mate on the board
the encoder extracts structured chess data out of a text; python-chess checks it
The encoder on the template reflection above: five facts in the reflection about the board are true but the mate is not.

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.

0%25%50%false facts in reflectionsself-contradictionspuzzles solved
curriculum only+ reward on true reflections
Rewarding true reflections made them truer, not better at chess.
0%5%10%15%20%stage 1stage 2stage 3stage 4GRPO steps -> (curriculum stages are 250 steps each)benchmark puzzles solved15.4%13.4%
SFT v2 + curriculumSFT v2 + curriculum + process reward
The GRPO runs with a curriculum on the chess benchmark as they trained.

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.

LFM-2.5-1.2b: writes token by token, then moves
get_current_board()
1r6/p3Nppk/8/7b/6P1/3r1BK1/PP5R/8 w - - 9 31
get_legal_moves()
e7c8, e7g8, e7g6, e7f5, e7d5, e7c6, g4g5, g4h5, g3f4, g3h4, … h2h5, h2h1, h2g2 (26 moves)
Black's king on h7 is boxed in: the knight on e7 covers g8 and g6. Rxh5+ takes the bishop with check along the h-file, and nothing can capture on h5 or block. So the move is Rxh5#.
make_move(move="h2h5")
d1-omni-600M: one forward pass scores every legal move
Rxh5#
gxh5
Ng6
Kg2
Rh3
… 21 more

same move, without writing a single token

illustration: the LLM writes ~150 tokens before it moves; d1 runs once
The same puzzle, two ways to get a move.

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

question 1: White to move. Which move is best? (options: the 18 legal moves)
Rf6#
Ng3+
Rxd6
Kf2
h4
… 13 more

label: Rf6# (Stockfish's best move, depth 245)

question 2: how good is this position for White? (options: 10 levels of win chance)
0102030405060708090win chance, %

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%.

d1-omni-600M against the label, on positions from outside training
The two questions that I fine-tuned d1-omni-600m on.

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%).

RL on a game: ~47 moves, then one result
SFT: Stockfish labels every position
signal you get to train on
RL
0
SFT
0
One game of RL ends in one result. The same moves labelled by Stockfish give each a usable signal.

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%.

50%6188vs sf-13201979vs sf-15001363vs sf-1700535vs sf-2000
one forward pass4-ply search, ~0.3 s a move on an A100
Score against Stockfish, 40 games each from balanced positions at move 5, with one forward pass per move and with 4 plies of search on the top 3 moves. A win counts 1 and a draw ½. d1-omni-600m ran on a Colab A100 (PyTorch, bfloat16). sf-N is Stockfish limited at Elo N (0.1 s a move, one CPU thread), and sf-1320 is its Skill Level 0 (0.05 s a move).

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.

d1's top 3 moves
d1 movessimulated opponentd1 answerswin chance919160553030252070706540626258507070666164645952454540358080755055555248
win chance for d1win chance for the opponent
The search on an example tree. The 27 end positions get a win chance for d1, and the scores go back up: at every move, the side to move picks its highest win chance. The opponent's win chance is 100 minus d1's.

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.

42.1%40.5%40.5%puzzles solved56.7%56.0%56.0%first move right91.4%91.2%same move as fp32
fp32, 1.5 GB4-bit, 339 MB4-bit + 8-bit embeddings, 272 MB (in your browser)
The full model (fp32) and the two quantized ones, on the 1,000 benchmark puzzles (2,378 positions), one forward pass per move. The one with 8-bit embeddings runs in your browser.

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)

pass 1: what do I want?
move
nothing
highlight
hint
undo
pass 2: which move? (options: the 39 legal moves)
Ne5
Be5
h4
Rb1
Rg1
… 34 more
a real recording, on the model that runs in your browser
A real recording of me saying a command, from the held-out set that training never used, and what the browser copy does with it. One pass asks what I want, and a second picks the move. This clip is one it gets right: over all 52 held-out recordings it gets 80.8% fully right.

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.

5060708090100msstep97 ms73 ms72 ms59 ms012345678voice commands right80.8% at every stepchess puzzles solved38.4% -> 38.3%
  1. start
  2. vocabulary
  3. answer cache
  4. voice up front
  5. phones: 1.22
  6. JSPI build
  7. phones search
  8. policy blend
  9. fp16
time per position (desktop), lower is better
The kept steps of the overnight loop. Pick a number to see it change; hover a step to see what it was. The y axis starts near the lowest value, not at 0. The accuracy lines stay flat; fp16 costs one puzzle. Phone numbers are Safari's engine on a Mac pretending to be an iPhone.
play against the final model!

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.