Instructions to use billygeekourson/philidor-142m with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use billygeekourson/philidor-142m with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="billygeekourson/philidor-142m")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("billygeekourson/philidor-142m") model = AutoModelForCausalLM.from_pretrained("billygeekourson/philidor-142m", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use billygeekourson/philidor-142m with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "billygeekourson/philidor-142m" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "billygeekourson/philidor-142m", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/billygeekourson/philidor-142m
- SGLang
How to use billygeekourson/philidor-142m 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 "billygeekourson/philidor-142m" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "billygeekourson/philidor-142m", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "billygeekourson/philidor-142m" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "billygeekourson/philidor-142m", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use billygeekourson/philidor-142m with Docker Model Runner:
docker model run hf.co/billygeekourson/philidor-142m
Philidor 142M
A language model trained from scratch to play chess, without ever being given a single rule of the game.
It never sees a board. It does not know that pieces, squares or a king exist. It receives a sequence of moves in UCI notation and predicts the next one, exactly the way a language model predicts the next word.
"Pawns are the soul of chess." François-André Danican Philidor, 1749
Result
98.85 % of the moves it proposes are legal, in free generation, with no constraint whatsoever. 95 % confidence interval: [98.69 – 98.99], measured on 20,000 positions from held-out games.
No rule was ever hard-coded. The model inferred the mechanics of the game from 3.2 billion moves played by humans.
Usage
from transformers import AutoModelForCausalLM, AutoTokenizer
tok = AutoTokenizer.from_pretrained("billygeekourson/philidor-142m")
model = AutoModelForCausalLM.from_pretrained("billygeekourson/philidor-142m")
ids = tok("e2e4 e7e5 g1f3 b8c6", return_tensors="pt").input_ids
out = model.generate(ids, max_new_tokens=20, do_sample=True,
temperature=0.6, top_k=20, pad_token_id=0)
print(tok.decode(out[0], skip_special_tokens=True))
Moves are written in UCI, separated by spaces. One move is exactly one token, so an 80-ply game takes 80 tokens.
Playing without ever producing an illegal move
The bundled vocab_uci.json lets you mask impossible moves before choosing.
A single forward pass is enough, and the model keeps its preference ordering
among the playable moves.
import json, torch, chess
from huggingface_hub import hf_hub_download
v = json.load(open(hf_hub_download("billygeekourson/philidor-142m",
"vocab_uci.json")))
board = chess.Board()
board.push_uci("e2e4"); board.push_uci("c7c5")
logits = model(tok("e2e4 c7c5", return_tensors="pt").input_ids).logits[0, -1]
mask = torch.full_like(logits, float("-inf"))
for move in board.legal_moves:
i = v["stoi"][move.uci()]
mask[i] = logits[i]
print(v["itos"][int(mask.argmax())]) # g1f3
Architecture
Decoder-only Transformer: 20 layers, width 768, 12 attention heads, hidden MLP 2048. Pre-norm, RMSNorm, RoPE, SwiGLU, tied embeddings. Context of 256 moves, i.e. a whole game.
141,589,248 non-embedding parameters (143,102,976 total).
The architecture happens to match Llama exactly, which was not planned: the
four building blocks were each chosen on their own merits. The model therefore
loads as a standard LlamaForCausalLM, and the conversion was verified with a
maximum logit difference of 0.00e+00 at every sequence length.
Vocabulary
1,971 tokens: the 1,968 geometrically possible UCI moves on a chessboard,
plus <pad>, <bos> and <eos>.
No BPE. The vocabulary is finite and known in advance, which makes legality
masking possible and spares the model from relearning that e2 and e4 form
a single unit.
Data
Four months of public Lichess archives, April to July 2026.
| Games read | 356,621,928 |
| Games kept | 43,824,173 (12.3 %) |
| Training tokens | 3,186,179,287 |
Filtering: both players between 1800 and 2600 Elo, bullet excluded, normal termination, between 20 and 300 plies. The validation split is done per game, never per token, so that no game is cut between the two sets.
Training
A single RTX 3090. 20 hours, 77,787 steps, one full epoch. bf16, AdamW, cosine schedule with warmup, effective batch of 40,960 tokens. Measured MFU: 71 %.
Final loss: 1.4312 training, 1.4439 validation. Both curves stay superimposed, so no overfitting.
What the model knows
| Metric | Value |
|---|---|
| Legal moves in free generation | 98.85 % |
| Agreement with the human move, top-1 | 55.48 % |
| Agreement with the human move, top-5 | 91.95 % |
| Castling | 100.00 % |
| En passant | 100.00 % |
| Promotion | 99.80 % |
| Getting out of check | 98.60 % |
All measurements are on held-out validation positions, at temperature 1.0 for legality and on the argmax for the rest.
Known limitations
No board representation. The model only understands a sequence of moves from the initial position. It cannot resume from an arbitrary FEN position.
About one move in a hundred is illegal without masking. For actual play, masking is essential.
Modest playing strength. On par with Stockfish capped at skill level 0, it drops off at level 1. This is a search-free model: it plays the most probable move after a single forward pass, with no lookahead.
It plays endgames less well than openings. Positions with few pieces offer less statistical regularity to exploit.
Related model
philidor-51m: same method, 51 M parameters, one month of data, two hours of training, 97.86 % legal moves. Useful for observing the effect of scale.
License
MIT for the model. Data comes from the public Lichess archives, released under CC0.
Philidor 142M (français)
Un modèle de langage entraîné de zéro à jouer aux échecs, sans qu'aucune règle du jeu ne lui ait jamais été donnée.
Il ne voit pas d'échiquier. Il ne sait pas qu'il existe des pièces, des cases, un roi. Il reçoit une suite de coups en notation UCI et prédit le suivant, exactement comme un modèle de langage prédit le mot suivant.
« Les pions sont l'âme des échecs. » François-André Danican Philidor, 1749
Le résultat
98,85 % des coups qu'il propose sont légaux, en génération libre, sans aucune contrainte. Intervalle de confiance à 95 % : [98,69 – 98,99], mesuré sur 20 000 positions issues de parties de validation jamais vues.
Aucune règle n'a été codée. Le modèle a déduit la mécanique du jeu de 3,2 milliards de coups joués par des humains.
Utilisation
from transformers import AutoModelForCausalLM, AutoTokenizer
tok = AutoTokenizer.from_pretrained("billygeekourson/philidor-142m")
model = AutoModelForCausalLM.from_pretrained("billygeekourson/philidor-142m")
ids = tok("e2e4 e7e5 g1f3 b8c6", return_tensors="pt").input_ids
out = model.generate(ids, max_new_tokens=20, do_sample=True,
temperature=0.6, top_k=20, pad_token_id=0)
print(tok.decode(out[0], skip_special_tokens=True))
Les coups s'écrivent en UCI, séparés par des espaces. Un coup vaut exactement un token, donc une partie de 80 demi-coups occupe 80 tokens.
Jouer sans jamais produire de coup illégal
Le fichier vocab_uci.json permet de masquer les coups impossibles avant de
choisir. Un seul passage avant suffit, et le modèle conserve son ordre de
préférence entre les coups jouables.
import json, torch, chess
v = json.load(open("vocab_uci.json"))
board = chess.Board()
board.push_uci("e2e4"); board.push_uci("c7c5")
logits = model(tok("e2e4 c7c5", return_tensors="pt").input_ids).logits[0, -1]
masque = torch.full_like(logits, float("-inf"))
for coup in board.legal_moves:
i = v["stoi"][coup.uci()]
masque[i] = logits[i]
print(v["itos"][int(masque.argmax())]) # g1f3
Architecture
Transformer décodeur : 20 couches, dimension 768, 12 têtes d'attention, MLP caché 2048. Pre-norm, RMSNorm, RoPE, SwiGLU, embeddings liés. Contexte de 256 coups, soit une partie entière.
141 589 248 paramètres hors embeddings (143 102 976 au total).
L'architecture correspond exactement à celle de Llama, ce qui n'était pas
prévu : les quatre briques ont été choisies séparément pour leurs mérites
propres. Le modèle se charge donc comme un LlamaForCausalLM standard, et la
conversion a été vérifiée : écart maximal de 0.00e+00 sur les logits, à
toutes les longueurs de séquence.
Vocabulaire
1 971 tokens : les 1 968 coups UCI géométriquement possibles sur un
échiquier, plus <pad>, <bos> et <eos>.
Pas de BPE. Le vocabulaire est fini et connu d'avance, ce qui rend possible le
masquage de légalité et évite au modèle de réapprendre que e2 et e4
forment une seule unité.
Données
Quatre mois d'archives publiques Lichess, d'avril à juillet 2026.
| Parties lues | 356 621 928 |
| Parties conservées | 43 824 173 (12,3 %) |
| Tokens d'entraînement | 3 186 179 287 |
Filtrage : les deux joueurs entre 1800 et 2600 Elo, bullet exclu, terminaison normale, entre 20 et 300 demi-coups. Le découpage validation se fait par partie et non par token, pour qu'aucune partie ne soit coupée entre les deux jeux.
Entraînement
Une seule RTX 3090. 20 heures, 77 787 steps, une époque complète. bf16, AdamW, cosinus avec chauffe, batch effectif de 40 960 tokens. MFU mesuré : 71 %.
Loss finale : 1,4312 en entraînement, 1,4439 en validation. Les deux courbes restent superposées, donc aucun surapprentissage.
Ce que le modèle sait
| Mesure | Valeur |
|---|---|
| Coups légaux en génération libre | 98,85 % |
| Accord avec le coup humain, top-1 | 55,48 % |
| Accord avec le coup humain, top-5 | 91,95 % |
| Roque | 100,00 % |
| Prise en passant | 100,00 % |
| Promotion | 99,80 % |
| Sortie d'échec | 98,60 % |
Toutes les mesures portent sur des positions de validation jamais vues à l'entraînement, à température 1,0 pour la légalité et sur l'argmax pour le reste.
Limites à connaître
Aucune représentation de l'échiquier. Le modèle ne comprend qu'une suite de coups depuis la position initiale. Il ne sait pas repartir d'une position arbitraire donnée en FEN.
Environ un coup sur cent est illégal sans masquage. Pour jouer réellement, le masquage est indispensable.
Force de jeu modeste. À égalité avec Stockfish bridé au niveau 0, il décroche au niveau 1. C'est un modèle sans recherche : il joue le coup le plus probable après un unique passage avant, sans aucune anticipation.
Il ne joue pas les finales aussi bien que les ouvertures. Les positions à peu de pièces offrent moins de régularité statistique à exploiter.
Modèle apparenté
philidor-51m : même méthode, 51 M de paramètres, un mois de données, deux
heures d'entraînement, 97,86 % de coups légaux. Utile pour observer l'effet de
l'échelle. Le résultat est instructif : tripler la taille du modèle à volume de
données égal ne change presque rien à la légalité, mais gagne deux à trois
points d'accord avec le coup humain.
Licence
MIT pour le modèle. Les données proviennent des archives publiques Lichess, diffusées en CC0.
- Downloads last month
- -