https://github.com/google-deepmind/searchless_chess Skip to content Navigation Menu Toggle navigation Sign in * Product + GitHub Copilot Write better code with AI + Security Find and fix vulnerabilities + Actions Automate any workflow + Codespaces Instant dev environments + Issues Plan and track work + Code Review Manage code changes + Discussions Collaborate outside of code + Code Search Find more, search less Explore + All features + Documentation + GitHub Skills + Blog * Solutions By company size + Enterprises + Small and medium teams + Startups By use case + DevSecOps + DevOps + CI/CD + View all use cases By industry + Healthcare + Financial services + Manufacturing + Government + View all industries View all solutions * Resources Topics + AI + DevOps + Security + Software Development + View all Explore + Learning Pathways + White papers, Ebooks, Webinars + Customer Stories + Partners * Open Source + GitHub Sponsors Fund open source developers + The ReadME Project GitHub community articles Repositories + Topics + Trending + Collections * Enterprise + Enterprise platform AI-powered developer platform Available add-ons + Advanced Security Enterprise-grade security features + GitHub Copilot Enterprise-grade AI features + Premium Support Enterprise-grade 24/7 support * Pricing Search or jump to... Search code, repositories, users, issues, pull requests... Search [ ] Clear Search syntax tips Provide feedback We read every piece of feedback, and take your input very seriously. [ ] [ ] Include my email address so I can be contacted Cancel Submit feedback Saved searches Use saved searches to filter your results more quickly Name [ ] Query [ ] To see all available qualifiers, see our documentation. Cancel Create saved search Sign in Sign up Reseting focus You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert {{ message }} google-deepmind / searchless_chess Public * Notifications You must be signed in to change notification settings * Fork 7 * Star 114 Grandmaster-Level Chess Without Search arxiv.org/abs/2402.04494 License Apache-2.0 license 114 stars 7 forks Branches Tags Activity Star Notifications You must be signed in to change notification settings * Code * Issues 0 * Pull requests 1 * Actions * Projects 0 * Security * Insights Additional navigation options * Code * Issues * Pull requests * Actions * Projects * Security * Insights google-deepmind/searchless_chess main BranchesTags Go to file Code Folders and files Name Name Last commit Last commit message date Latest commit History 4 Commits checkpoints checkpoints data data src src .gitignore .gitignore CONTRIBUTING.md CONTRIBUTING.md LICENSE LICENSE README.md README.md overview.svg overview.svg requirements.txt requirements.txt View all files Repository files navigation * README * Apache-2.0 license Grandmaster-Level Chess Without Search Overview figure This repository provides an implementation of our paper Grandmaster-Level Chess Without Search. The recent breakthrough successes in machine learning are mainly attributed to scale: namely large-scale attention-based architectures and datasets of unprecedented scale. This paper investigates the impact of training at scale for chess. Unlike traditional chess engines that rely on complex heuristics, explicit search, or a combination of both, we train a 270M parameter transformer model with supervised learning on a dataset of 10 million chess games. We annotate each board in the dataset with action-values provided by the powerful Stockfish 16 engine, leading to roughly 15 billion data points. Our largest model reaches a Lichess blitz Elo of 2895 against humans, and successfully solves a series of challenging chess puzzles, without any domain-specific tweaks or explicit search algorithms. We also show that our model outperforms AlphaZero's policy and value networks (without MCTS) and GPT-3.5-turbo-instruct. A systematic investigation of model and dataset size shows that strong chess performance only arises at sufficient scale. To validate our results, we perform an extensive series of ablations of design choices and hyperparameters. Contents . | +-- BayesElo - Elo computation (need to be installed) | +-- checkpoints - Model checkpoints (need to be downloaded) | +-- 136M | +-- 270M | +-- 9M | +-- data - Datasets (need to be downloaded) | +-- eco_openings.csv | +-- test | +-- train | +-- puzzles.csv | +-- lc0 - Leela Chess Zero (needs to be installed) | +-- src | +-- engines | | +-- engine.py - Engine interface | | +-- lc0_engine.py - Leela Chess Zero engine | | +-- neural_engines.py - Neural engines | | +-- stockfish_engine.py - Stockfish engine | | | +-- bagz.py - Readers for our .bag data files | +-- config.py - Experiment configurations | +-- constants.py - Constants, interfaces, and types | +-- data_loader.py - Data loader | +-- metrics_evaluator.py - Metrics (e.g., Kendall's tau) evaluator | +-- puzzles.py - Puzzle evaluation script | +-- searchless_chess.ipynb - Model analysis notebook | +-- tokenizer.py - Chess board tokenization | +-- tournament.py - Elo tournament script | +-- train.py - Example training + evaluation script | +-- training.py - Training loop | +-- training_utils.py - Training utility functions | +-- transformer.py - Decoder-only Transformer | +-- utils.py - Utility functions | +-- Stockfish - Stockfish (needs to be installed) | +-- README.md +-- requirements.txt - Dependencies Installation Clone the source code into a local directory: git clone https://github.com/google-deepmind/searchless_chess.git cd searchless_chess This repository requires Python 3.10. pip install -r requirements.txt will install all required dependencies. This is best done inside a conda environment. To that end, install Anaconda. Then, create and activate the conda environment: conda create --name searchless_chess python=3.10 conda activate searchless_chess Install pip and use it to install all the dependencies: conda install pip pip install -r requirements.txt If you have a GPU available (highly recommended for fast training), then you can install JAX with CUDA support. pip install --upgrade "jax[cuda12_pip]" -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html Note that the jax version must correspond to the existing CUDA installation you wish to use (CUDA 12 in the example above). Please see the JAX documentation for more details. Installing Stockfish Download and compile the latest version of Stockfish (for Unix-like systems): git clone https://github.com/official-stockfish/Stockfish.git cd Stockfish/src make -j profile-build ARCH=x86-64-avx2 cd ../.. Installing Leela Chess Zero Follow the Lc0 download instructions, i.e., git clone -b release/0.30 --recurse-submodules https://github.com/LeelaChessZero/lc0.git Then build the engine as described in the Lc0 build instructions. We evaluate Lc0 with the largest-possible network from Lc0's model catalogue, i.e., the Large network. To download that network, run the following command: cd lc0/build/release wget https://storage.lczero.org/files/768x15x24h-t82-swa-7464000.pb.gz gzip -d 768x15x24h-t82-swa-7464000.pb.gz cd ../../.. Installing BayesElo To compute the Elos for the different agents, we require BayesElo, which can be installed as follows: wget https://www.remi-coulom.fr/Bayesian-Elo/bayeselo.tar.bz2 tar -xvjf bayeselo.tar.bz2 cd BayesElo make bayeselo cd .. Downloading the Datasets To download our datasets to the correct locations, run the following command: cd data ./download.sh cd .. We also provide the individual dataset download links in the following table (the action-value dataset is sharded into 2148 files due to its size and only the link to the first shard is listed below): Split Action-Value Behavioral Cloning State-Value Puzzles Train 1.2 GB (of 1.1 TB) 34 GB 36 GB - Test 141 MB 4.1 MB 4.4 MB 4.5 MB Downloading the Model Checkpoints To download the pretrained models to the correct locations, run the following command: cd checkpoints ./download.sh cd .. Usage Before running any code, make sure to activate the conda environment and set the PYTHONPATH: conda activate searchless_chess export PYTHONPATH=$(pwd)/.. Training To train a model locally, run the following command: cd src python train.py cd .. The model checkpoints will be saved to /checkpoints/local. Puzzles To evaluate a model's puzzle accuracy, run the following command: cd src python puzzles.py --num_puzzles 10 --agent=local cd .. puzzles.py supports the following agents: * the locally trained model: local * the pretrained models: 9M, 136M, and 270M * the Stockfish engines: stockfish and stockfish_all_moves * the Lc0 engines: leela_chess_zero_depth_1, leela_chess_zero_policy_net, and leela_chess_zero_400_sims Tournament Elo To compute the Elo for the different agents, run the tournament to play games between them and then compute the Elo for the PGN file generated by the tournament (more information on BayesElo can be found here): cd src python tournament.py --num_games=200 cd ../BayesElo ./bayeselo > ... ResultSet>readpgn ../data/tournament.pgn > N game(s) loaded, 0 game(s) with unknown result ignored. ResultSet>elo ResultSet-EloRating>mm > 00:00:00,00 ResultSet-EloRating>exactdist > 00:00:00,00 ResultSet-EloRating>ratings > ... cd .. Analysis Notebook To investigate the model's behavior (e.g., to compute the win percentage for all legal moves), start a notebook server and then open src/searchless_chess.ipynb in your browser: jupyter notebook Citing this work @article{ruoss2024grandmaster, author = {Anian Ruoss and Gr{\'{e}}goire Del{\'{e}}tang and Sourabh Medapati and Jordi Grau{-}Moya and Li Kevin Wenliang and Elliot Catt and John Reid and Tim Genewein}, title = {Grandmaster-Level Chess Without Search}, journal = {arXiv:2402.04494}, year = {2024} } License and disclaimer Copyright 2024 DeepMind Technologies Limited All software is licensed under the Apache License, Version 2.0 (Apache 2.0); you may not use this file except in compliance with the Apache 2.0 license. You may obtain a copy of the Apache 2.0 license at: https://www.apache.org/licenses/LICENSE-2.0 The model weights are licensed under Creative Commons Attribution 4.0 (CC-BY). You may obtain a copy of the CC-BY license at: https:// creativecommons.org/licenses/by/4.0/legalcode Some portions of the dataset are in the public domain by a Creative Commons CC0 license from lichess.org. The remainder of the dataset is licensed under Creative Commons Attribution 4.0 (CC-BY). You may obtain a copy of the CC-BY license at: https://creativecommons.org/ licenses/by/4.0/legalcode. Unless required by applicable law or agreed to in writing, software and materials distributed under the Apache 2.0 or CC-BY licenses are distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the licenses for the specific language governing permissions and limitations under those licenses. This is not an official Google product. About Grandmaster-Level Chess Without Search arxiv.org/abs/2402.04494 Resources Readme License Apache-2.0 license Activity Custom properties Stars 114 stars Watchers 10 watching Forks 7 forks Report repository Releases No releases published Packages 0 No packages published Contributors 2 * @anianruoss anianruoss Anian Ruoss * @johnhamlen johnhamlen John Hamlen Languages * Python 92.7% * Jupyter Notebook 5.0% * Shell 2.3% Footer (c) 2024 GitHub, Inc. Footer navigation * Terms * Privacy * Security * Status * Docs * Contact * Manage cookies * Do not share my personal information You can't perform that action at this time.