This is the
final (SFT + RL) model. The SFT-stage checkpoint is
UofTCSSLab/C1-SFT-4B.
Average response length ~169 tokens.
The prompt gives the FEN, piece positions, and legal moves, then asks for a
step-by-step analysis ending in FINAL_ANSWER: <uci_move>. Greedy decoding
(temperature 0) is recommended.
1# pip install chess
2import chess
3
4def build_prompt(fen: str) -> str:
5 board = chess.Board(fen)
6 names = {1: "Pawn", 2: "Knight", 3: "Bishop", 4: "Rook", 5: "Queen", 6: "King"}
7 pieces = {}
8 for sq in chess.SQUARES:
9 p = board.piece_at(sq)
10 if p:
11 key = f"{'White' if p.color else 'Black'} {names[p.piece_type]}"
12 pieces.setdefault(key, []).append(chess.square_name(sq))
13 order = [f"{c} {t}" for c in ("White", "Black")
14 for t in ("King", "Queen", "Rook", "Bishop", "Knight", "Pawn")]
15 arrangement = ", ".join(f"{k}: {sorted(pieces[k])}" for k in order if k in pieces)
16 legal = ", ".join(m.uci() for m in board.legal_moves)
17 return (
18 f"You are given a chess position in FEN: {fen}.\n"
19 f"Piece positions: {arrangement}\n"
20 f"Legal moves: {legal}\n"
21 "Find the best move for the side to play.\n"
22 "Analyze step by step and explain your reasoning.\n"
23 "Finish with a single line formatted EXACTLY as:\n"
24 "FINAL_ANSWER: <answer>\n"
25 "Use UCI notation (e.g., e2e4, c2b1q) for the final answer."
26 )
27
28MODEL_ID = "UofTCSSLab/C1-4B"
29FEN = "2kr3r/ppp2Npp/2nbp3/6N1/2PP2n1/4B2q/PP2BP2/R2Q1RK1 b - - 2 15"
30messages = [{"role": "user", "content": build_prompt(FEN)}]
1# pip install transformers torch
2from transformers import AutoModelForCausalLM, AutoTokenizer
3
4tok = AutoTokenizer.from_pretrained(MODEL_ID)
5model = AutoModelForCausalLM.from_pretrained(MODEL_ID, torch_dtype="bfloat16", device_map="auto")
6
7ids = tok.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt").to(model.device)
8out = model.generate(ids, max_new_tokens=1024, do_sample=False) # greedy
9print(tok.decode(out[0, ids.shape[-1]:], skip_special_tokens=True))
10# ... step-by-step reasoning ...
11# FINAL_ANSWER: h3h2
1# pip install vllm
2from vllm import LLM, SamplingParams
3
4llm = LLM(model=MODEL_ID, dtype="bfloat16")
5sampling = SamplingParams(temperature=0.0, max_tokens=1024) # greedy
6out = llm.chat(messages, sampling_params=sampling)
7print(out[0].outputs[0].text)
8# ... step-by-step reasoning ...
9# FINAL_ANSWER: h3h2
1@article{tang2026grounded,
2 title={Grounded Chess Reasoning in Language Models via Master Distillation},
3 author={Tang, Zhenwei and Wen, Qianfeng and Grief-Albert, Seth and Elgabra, Yahya and Yang, Blair and Dong, Honghua and Anderson, Ashton},
4 journal={arXiv preprint arXiv:2603.20510},
5 year={2026}
6}