Text Generation
Transformers
Safetensors
hrm_text

HRM-Chess-Reasoning-0.3B

This is a pet-project attempting to train a HRM-Text model to play chess. Given the initial board, it generates reasoning traces and the board after the next move. In combination with a Stockfish evaluation to choose the move from generated samples, it can win in the game against the Stockfish 1350 ELO.

Game example:

[Event "?"]
[Site "?"]
[Date "2026.06.15"]
[Round "?"]
[White "HRM-Chess-Reasoning-0.3B - 12 samples with Stockfish searchtime for 3 seconds"]
[Black "Stockfish 1350 ELO"]
[Result "1-0"]

1. e4 e6 2. d4 d5 3. exd5 Nf6 4. Nf3 Nxd5 5. c4 Nf6 6. Nc3 h6 7. Bf4 Bd6 8. Ne5 Nc6 9. a3 a6 10. Nxc6 Bxf4 11. Nxd8 e5 12. g3 exd4 13. Ne6 fxe6 14. gxf4 Ke7 15. Qxd4 Rd8 16. Qe3 Ng4 17. Qe4 Kf8 18. f3 Nf2 19. Kxf2 b5 20. Bd3 b4 21. axb4 a5 22. Qg6 e5 23. fxe5 Bg4 24. fxg4 h5 25. e6 axb4 26. g5 Kg8 27. Ne4 Ra4 28. Nf6+ Kf8 29. Qf7# 1-0

Minimal usage:

from transformers import AutoTokenizer, AutoModelForCausalLM
import torch

model_name = "dr3z/HRM-Chess-Reasoning-0.3B"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name, dtype=torch.bfloat16).cuda().eval()


TEMPLATE = """<|im_start|><|object_ref_start|>
You are a Chess Grandmaster.
Given a chessboard position, you must:
1. Think deeply about the justification of your move.
2. Derive the move step‑by‑step, explaining your reasoning internally, but **do not reveal the move until you have finished the analysis**.
3. After the analysis, play the chosen move and output **only** the resulting board state in the following format:
'''
<answer>
[board representation]
</answer>
'''
No additional commentary, explanations, or text should appear outside of the `<answer>` tags.
{source}<|im_end|><think>"""


CURRENT_STATE = """
8 | _ _ _ _ _ _ _ _ |
7 | _ _ p _ _ k _ p |
6 | _ _ _ p _ n p _ |
5 | _ _ _ P _ p _ _ |
4 | _ _ _ P _ _ _ _ |
3 | _ P _ K _ P P _ |
2 | _ _ B _ _ _ _ P |
1 | _ _ _ _ _ _ _ _ |
    a b c d e f g h
White moves
"""


inp = tokenizer(TEMPLATE.format(source=CURRENT_STATE), return_tensors="pt")
inp["token_type_ids"] = torch.ones_like(inp["input_ids"])

out = model.generate(**inp.to(model.device), max_new_tokens=6000, temperature=0.2, do_sample=True, num_return_sequences=1)
out = [tokenizer.decode(c) for c in out]

for text in out:
    print(text)

Training params

  • optimizer: adamatan2
  • learning_rate: 3e-04
  • global_batch_size (in tokens): 8000
  • epochs: 5
Downloads last month
20
Safetensors
Model size
0.3B params
Tensor type
BF16
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Dataset used to train dr3z/HRM-Chess-Reasoning-0.3B