Instructions to use MAIN-Lab/smollm2-135m-chess with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use MAIN-Lab/smollm2-135m-chess with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="MAIN-Lab/smollm2-135m-chess") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("MAIN-Lab/smollm2-135m-chess") model = AutoModelForCausalLM.from_pretrained("MAIN-Lab/smollm2-135m-chess", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use MAIN-Lab/smollm2-135m-chess with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "MAIN-Lab/smollm2-135m-chess" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "MAIN-Lab/smollm2-135m-chess", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/MAIN-Lab/smollm2-135m-chess
- SGLang
How to use MAIN-Lab/smollm2-135m-chess with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "MAIN-Lab/smollm2-135m-chess" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "MAIN-Lab/smollm2-135m-chess", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "MAIN-Lab/smollm2-135m-chess" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "MAIN-Lab/smollm2-135m-chess", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use MAIN-Lab/smollm2-135m-chess with Docker Model Runner:
docker model run hf.co/MAIN-Lab/smollm2-135m-chess
MAIN Lab · SmolLM2 135M, chess puzzles
A 135M language model fine-tuned by MAIN Lab on Stockfish-checked Lichess puzzles. It reads a board as text and names the best move. It does no search: one forward pass per move.
Results (Benchmark #005)
% of puzzles solved (every move of the solution right). 2,500 Lichess puzzles the model never saw, 500 per set. Each move is picked among the legal moves by log-likelihood, the same way for every model. SmolLM3-3B was run on 200 per set.
| Test | Chance | SmolLM2-135M (before) | Gemma 3 270M | SmolLM3-3B | This model |
|---|---|---|---|---|---|
| Mate in 1 | 3.4 | 0.8 | 0.4 | 1.5 | 44.2 |
| Mate in 2 | 0.1 | 0.0 | 0.0 | 0.0 | 24.8 |
| Easy (< 1200) | 1.3 | 1.0 | 1.0 | 0.5 | 35.6 |
| Medium (1200–1800) | 0.4 | 0.6 | 0.8 | 0.5 | 14.4 |
| Hard (≥ 1800) | 0.2 | 0.4 | 0.2 | 0.5 | 4.6 |
| Writes a legal move (free text) | – | 0.0 | 2.4 | 2.0 | 86.8 |
This model wins every test (paired McNemar p < 0.01, also against the 3B). Overall: 24.7% of the 2,500 puzzles solved, up from 0.6%.
Prompt format (use it exactly)
Chess puzzle. Find the best move. Answer in UCI (e.g. e2e4).
8 r . . . . . . k
7 p p . . r . . p
6 . . . . R p . Q
5 . . . p . . . .
4 . . . . . . . .
3 . N . P . . b .
2 P q P . . . P P
1 . . . . . . . K
a b c d e f g h
White to move. Castling: -.
Best move:
- The board is drawn from the side to move (for Black, rank 1 is at the top and files run h→a).
- UPPER case = white, lower case = black,
.= empty. - The answer is one UCI move followed by a newline, e.g.
h6f8. - Best results come from scoring every legal move (log-likelihood of
<move>\n) and taking the top one; greedy text also works (see "writes a legal move").
Code for the prompt, the scoring and the benchmark: chessft/ in the MAIN Lab repository.
How it was trained
- Teacher: Stockfish, through the Lichess puzzle database (CC0). Every puzzle solution is engine-verified.
- Data: 153,600 positions (4,800 steps × 32), drawn from 693,547 solver moves of 300k puzzles in shard 0 of
Lichess/chess-puzzles. Test puzzles (ids hashed into bucket 0 of 50) and every position inside them were removed from training. - Training: full fine-tune on CPU (4 cores, bf16 autocast), loss on the move tokens only, AdamW lr 3e-4 cosine, batch 32, 4,800 steps.
- Test sets: 2,500 puzzles from a held-out slice (puzzle ids hashed into bucket 0 of 50). They were never trained on, and every position inside a test-pool puzzle was removed from training.
Limits
- Puzzles only: it was never trained on openings, quiet positions or full games.
- No search. Deep combinations (hard puzzles) are where it fails most.
- It is a chess model now; its general chat ability was not kept or measured.
License
Apache-2.0 (base model: SmolLM2-135M-Instruct, Apache-2.0). Data: Lichess puzzle database, CC0.
- Downloads last month
- 17
Model tree for MAIN-Lab/smollm2-135m-chess
Base model
HuggingFaceTB/SmolLM2-135M
