---
title: LFM2.5-230M-Chess
canonical_url: "https://www.modelscope.cn/models/mlabonne/LFM2.5-230M-Chess"
md_url: "https://www.modelscope.cn/models/mlabonne/LFM2.5-230M-Chess.md"
repository: mlabonne/LFM2.5-230M-Chess
last_updated: 2026-10-24
license: other
pipeline_tag: text-generation
tasks:
  - text-generation
model_type:
  - lfm2
architectures:
  - Lfm2ForCausalLM
base_model:
  - LiquidAI/LFM2.5-230M-Base
base_model_relation: finetune
parameters: 230.7M
tensor_type:
  - BF16
library_name:
  - transformer
  - safetensors
  - pytorch
frameworks:
  - pytorch
language:
  - en
downloads: 168
stars: 0
tags:
  - liquid
  - lfm2.5
  - chess
---

# LFM2.5-230M-Chess

> LFM2.5-230M-Chess - mlabonne 在 ModelScope 开源的模型。📝 Article • 💻 Demo • 🤗 ONNX

mlabonne/LFM2.5-230M-Chess 是 ModelScope 魔搭社区上的 230.7M 参数text-generation模型，采用 other 许可，基于 LiquidAI/LFM2.5-230M-Base 构建。

- **Repository**: mlabonne/LFM2.5-230M-Chess
- **License**: other
- **Tasks**: text-generation
- **Parameters**: 230.7M
- **Base model**: LiquidAI/LFM2.5-230M-Base
- **Tags**: liquid, lfm2.5, chess
- **Downloads**: 168
- **Stars**: 0
- **Last updated**: 2026-10-24

Source: https://www.modelscope.cn/models/mlabonne/LFM2.5-230M-Chess

---

<div align="center">
  <img
    src="https://huggingface.co/mlabonne/LFM2.5-230M-Chess/resolve/main/fig_hero.png"
    alt="ChessLFM"
    style="width: 100%; max-width: 100%; height: auto; display: inline-block; margin-bottom: 0.5em; margin-top: 0.5em;"
  />
  <div style="display: flex; justify-content: center; gap: 0.5em; margin-bottom: 1em;">
    <a href="https://maximelabonne.substack.com/p/chesslfm-2000-elo-in-230m-params"><strong>📝 Article</strong></a> •
    <a href="https://hf.co/spaces/mlabonne/ChessLFM"><strong>💻 Demo</strong></a> •
    <a href="https://hf.co/mlabonne/LFM2.5-230M-Chess-ONNX"><strong>🤗 ONNX</strong></a>
  </div>
</div>

# LFM2.5-230M-Chess

A 230M chess engine with a language model interface, fine-tuned from [LFM2.5-230M-Base](https://huggingface.co/LiquidAI/LFM2.5-230M-Base) using Stockfish distillation.

Every possible chess move is a single token in the vocabulary. The model reads a position as a fixed 80-token prompt, predicts its own win probability, then predicts one move token. The host masks the move logits to the legal moves, so the model can never play an illegal move.

It plays at roughly 2004 Elo with a shallow depth-3 search on top, and roughly 1500 with the raw one-pass policy.

**Demo:** Play it in your browser with the [ChessLFM Space](https://hf.co/spaces/mlabonne/ChessLFM).

![Demo game](demo_game.gif)

## Usage

```python
import json
from transformers import AutoModelForCausalLM

model = AutoModelForCausalLM.from_pretrained("mlabonne/LFM2.5-230M-Chess")
token_ids = json.load(open("token_ids.json"))
```

Each move takes two short forward passes:

1. Build the 80-token prompt from the FEN. It encodes the 64 squares, side to move, castling rights, en passant file, halfmove clock, repetition count, and the last 8 plies.
2. Argmax over the 64 value tokens gives the model evaluation, where `<v:k>` means a win probability in `[k/64, (k+1)/64)`.
3. Append that value token and `<|bestmove|>`, mask the move logits to the legal moves, and take the argmax.

You can find the 2,106 added token IDs in `token_ids.json` (it starts at 64402).
