Skip to main content
Back

Maxime Labonne's LFM2.5-230M-Chess Hits 2000 Elo Running in Your Browser

A 230M parameter Liquid model reaches 2004 Elo in chess by combining Stockfish distillation, a bit of RL, and shallow test-time search.

Pro

  • LFM2.5-230M-Chess reaches 2004 Elo, running in-browser via WebGPU.
  • Every legal chess move (1,968 total) is encoded as a single vocabulary token.
  • SFT distills Stockfish across 126M positions from Lichess and endgame drills.
  • HL-Gauss soft value targets added +60 Elo, GRPO polish added +16 Elo.
  • Depth-3 test-time search over 12/6 branching adds ~300 Elo on top.
  • Read the full write-up or try the demo.

Large general-purpose language models often emit illegal chess moves, revive captured pieces, or lose track of the board during long games. Their text tokenization does not encode the game’s legal action space. Maxime Labonne’s LFM2.5-230M-Chess weights take a specialized approach: a 230-million-parameter decoder fine-tuned from Liquid AI’s LFM2.5 base. Labonne reports roughly 2000 Elo when the model uses its depth-3 search.

Labonne’s implementation combines chess-specific tokens, Stockfish distillation, an ordinal value loss, Group Relative Policy Optimization, and shallow minimax search. The model can run locally through WebGPU, exports to ONNX, and is published under the LFM1.0 license.

ChessLFM playing a game in a browser through WebGPU
ChessLFM performs model inference and search inside a compatible browser.

Chess becomes a token problem

LFM2.5-230M-Chess emits constrained chess tokens. The vocabulary includes all 1,968 geometrically possible UCI-style moves, with each move represented by one token such as <m:e2e4>. Another 64 tokens divide win probability into discrete bins.

The position is serialized into an 80-token prompt containing a fixed 64-token board sequence and state information for the side to move, castling rights, en passant, the halfmove clock, and repetition. Forsyth-Edwards Notation, commonly called FEN, supplies most of those fields. Repetition requires game history because a FEN string does not preserve prior positions.

Direct policy inference uses two forward passes. The first pass selects one of the 64 value tokens, producing the model’s position evaluation. The second appends that value token and a best-move marker, restricts the output logits to moves supplied by an external legal-move generator, and selects the highest-scoring legal move. Illegal output remains possible only if the position serializer or legal-move generator is wrong.

The project adds 2,106 tokens for moves, values, and control state. Their embeddings are initialized from the mean and covariance of the existing embedding distribution, which keeps their initial scale aligned with the base model. A single causal decoder emits both value and policy tokens, allowing standard causal-language-model tooling to export and run the network.

Stockfish supplies the labels

Training uses 126 million positions drawn from Lichess user-requested analyses, Lichess puzzles, and synthetic endgame drills covering basic mates. Puzzle and endgame positions were re-annotated with Stockfish 17.1 at MultiPV 10, which returns a ranked set of ten candidate lines for each position.

Supervision is concentrated at two output positions, one for the value token and one for the move token:

  • Value loss: cross-entropy against the target win-probability bin.
  • Move loss: cross-entropy against Stockfish’s highest-ranked move.
  • Distillation loss: KL divergence between the model’s move distribution and Stockfish’s ranking of candidate moves.

The supervised fine-tuning baseline reached about 1450 Elo. Longer runs and hyperparameter changes produced no measured improvement outside the evaluation’s confidence interval.

Loss design and search add the Elo

A flat 64-class value target carries no information about the distance between bins. Predicting bin 37 for a target in bin 38 receives the same target structure as predicting bin 5. HL-Gauss replaces the one-hot label with a Gaussian histogram centered on the target, using a standard deviation of 1.5 bins. Nearby evaluations receive some probability mass, producing smoother position rankings.

Group Relative Policy Optimization samples eight legal moves for each position and asks Stockfish to score the resulting boards. The reward is the change in win probability. Each move is compared with the group’s average reward, and a KL penalty anchors the updated policy to the frozen supervised model. Greedy strength remained within the reported confidence interval. The search prior improved because the six highest-probability moves contained a strong candidate more often.

Depth-3 search expands the 12 most likely root moves and the six most likely moves at later plies. This produces roughly 430 positions for the value model to evaluate. Minimax then propagates those scores toward the root, accounting for each player choosing the strongest available reply.

Reported ablation results; the figures come from separate comparisons and should not be added together.
Configuration Reported result
Supervised fine-tuning baseline About 1450 Elo
HL-Gauss value targets About +60 Elo
GRPO with greedy decoding No measurable change
GRPO used as a search prior About +16 Elo
Depth-3 search over the raw policy About +300 Elo

Three ablations that lost

Several plausible variants consumed additional compute without improving measured playing strength:

  • Denser teacher labels: re-annotating the full training mixture at MultiPV 10 produced no Elo change outside the confidence interval.
  • Sequential search allocation: Gumbel MuZero-style sequential halving scored below uniform depth-3 search at the same compute budget.
  • Self-training: fine-tuning on moves selected by the model’s own search reduced Elo by 47 points. In this setup, Stockfish was roughly 1200 Elo stronger than the student, favoring continued teacher distillation.

From the Hub to WebGPU

The live browser demo performs inference through WebGPU after downloading the model assets. An ONNX export is available for other runtimes.

Parameters 230 million
Published precision BF16
Outputs Win-probability bin and move token
Browser runtime ONNX through WebGPU
Default search Depth 3, about 430 evaluated positions
License LFM1.0

Python applications can load the checkpoint through Transformers and download the repository’s token mapping with huggingface_hub:

from pathlib import Path
import json

from huggingface_hub import hf_hub_download
from transformers import AutoModelForCausalLM

MODEL_ID = "mlabonne/LFM2.5-230M-Chess"

model = AutoModelForCausalLM.from_pretrained(
    MODEL_ID,
    torch_dtype="auto",
)
model.eval()

token_path = hf_hub_download(
    repo_id=MODEL_ID,
    filename="token_ids.json",
)
with Path(token_path).open(encoding="utf-8") as f:
    token_ids = json.load(f)

The snippet loads the model and token IDs, not a complete engine. A working integration must serialize the position into the expected 80-token format, preserve repetition history, run the value and move passes, generate legal moves, mask the move logits, and optionally implement depth-3 search. A chess library such as python-chess can provide board state and legal-move generation.

A reusable constrained-decoding pattern

DeepMind’s ChessBench showed that compact transformers can learn strong chess policies from engine supervision. LFM2.5-230M-Chess combines that idea with a single causal decoder and a browser-oriented deployment path.

The architecture suggests a practical sequence for other verifiable tasks:

  1. Represent valid actions as dedicated tokens.
  2. Serialize the full task state into a fixed, compact prompt.
  3. Distill values and ranked actions from a reliable specialist.
  4. Use an ordinal loss when target classes have a meaningful order.
  5. Refine the policy with verifier-based rewards and a KL anchor.
  6. Apply external validity checks before selection.
  7. Use shallow search when the verifier or value model is cheap enough.

The pattern fits domains with bounded actions and inexpensive verification, including theorem proving with a proof checker, code generation with tests, constrained tool calls with schema validation, and testable SQL generation. Its usefulness declines as verification becomes noisy, expensive, or vulnerable to reward hacking. Search cost also grows quickly with the branching factor.

The reported 2000-Elo figure depends on the project’s opponent pool, search settings, and rating procedure. Cross-pool comparison with human federation ratings is unreliable. The concrete engineering result is a 230-million-parameter decoder that represents board state, predicts values and legal moves, performs shallow search, and runs locally in a compatible browser.