Efficiently updatable neural network
{{Short description|Neural network based evaluation function}}
{{Chess programming series}}
In computer strategy games, for example in shogi and chess, an efficiently updatable neural network (NNUE, a Japanese wordplay on Nue, sometimes stylised as ƎUИИ) is a neural network-based evaluation function whose inputs are piece-square tables, or variants thereof like the king-piece-square table.{{cite web | url=https://github.com/glinscott/nnue-pytorch/blob/master/docs/nnue.md | title=NNUE | author=Gary Linscott | website=GitHub | date=April 30, 2021 | access-date=December 12, 2020}} NNUE is used primarily for the leaf nodes of the alpha–beta tree.{{cite web |title=Stockfish 12 |url=https://blog.stockfishchess.org/post/628172810852925440/stockfish-12 |website=Stockfish Blog |accessdate=19 October 2020}}
NNUE was invented by Yu Nasu and introduced to computer shogi in 2018.{{cite web|title=Efficiently Updatable Neural-Network-based Evaluation Function for computer Shogi|author=Yu Nasu|url=https://www.apply.computer-shogi.org/wcsc28/appeal/the_end_of_genesis_T.N.K.evolution_turbo_type_D/nnue.pdf|date=April 28, 2018|language=Japanese}}{{cite web|title=Efficiently Updatable Neural-Network-based Evaluation Function for computer Shogi (Unofficial English Translation)|author=Yu Nasu|website=GitHub |url=https://github.com/asdfjkl/nnue/blob/main/nnue_en.pdf|date=April 28, 2018|language=English}} On 6 August 2020, NNUE was for the first time ported to a chess engine, Stockfish 12.{{cite web|title=Introducing NNUE Evaluation|url=https://blog.stockfishchess.org/post/625828091343896577/introducing-nnue-evaluation|date=6 August 2020}}{{cite web|title= official-stockfish / Stockfish, NNUE merge|url=https://github.com/official-stockfish/Stockfish/issues/2823#issue-665540175|author=Joost VandeVondele|website=GitHub |date=July 25, 2020}} Since 2021, many of the top rated classical chess engines such as Komodo Dragon have an NNUE implementation to remain competitive.
NNUE runs efficiently on central processing units (CPU) without a requirement for a graphics processing unit (GPU).{{cite web|title=Stockfish FAQ: Can Stockfish use my GPU? |url=https://official-stockfish.github.io/docs/stockfish-wiki/Stockfish-FAQ.html#can-stockfish-use-my-gpu|access-date=19 January 2025|website=Stockfish}}{{Cite web|title=nnue-pytorch/docs/nnue.md|website=GitHub |url=https://github.com/official-stockfish/nnue-pytorch/blob/master/docs/nnue.md}} In contrast, deep neural network-based chess engines such as Leela Chess Zero require a GPU.{{Citation|title=Neural Networks for Chess|author=Dominik Klein|date=2022 |page=49|arxiv=2209.01506 }}{{cite arXiv |eprint=2409.12272 |last1=Monroe |first1=Daniel |last2=Chalmers |first2=Philip A. |title=Mastering Chess with a Transformer Model |date=2024 |class=cs.LG }}
The neural network used for the original 2018 computer shogi implementation consists of four weight layers: W1 (16-bit integers) and W2, W3 and W4 (8-bit). It has 4 fully-connected layers, ReLU activation functions, and outputs a single number, being the score of the board.
W1 encoded the king's position and therefore this layer needed only to be re-evaluated once the king moved. It used incremental computation and single instruction multiple data (SIMD) techniques along with appropriate intrinsic instructions.
See also
- elmo (shogi engine)
- Stockfish chess engine - The chapter about NNUE features a visualization of NNUE.
- List of chess software
References
{{Reflist}}
External links
- [https://www.chessprogramming.org/NNUE NNUE] on the Chess Programming Wiki.
- [https://github.com/ynasu87/nnue NNUE evaluation functions for computer shogi] on github.com