Efficiently updatable neural network
Neural network based evaluation function
From Wikipedia, the free encyclopedia
NNUE, which stands for Efficiently updatable neural network (often stylized as ƎUИИ) is a neural network made to replace the evaluation of Shogi, chess and other board games using alpha-beta searchers running on a CPU.[1]
History
NNUE was invented by Yu Nasu in 2018, and was first used in the computer shogi engine YaneuraOu. It is a Japanese wordplay on Nue (鵺), a mythical Japanese chimera.[2] Following it's success in Shogi, NNUE was for the first time ported to the chess engine Stockfish 12, resulting in a major increase in Elo for the engine. Since then, NNUE has been used for almost every other competitive engine.[3][4][5]
The architecture was inspired by Kunihito Hoki's approach in the shogi engine Bonanza, which used piece-square tables indexed by king location (also known as the "Bonanza method"). It was first implemented into YaneuraOu which was developed by Motohiro Isozaki.[6]
Adaptation to Computer Chess
In early 2020, Japanese programmer Hisayori "Nodchip" Noda added the NNUE evaluation into a development branch of Stockfish (specifically in Stockfish 10) to prove its effectiveness in chess. This prototype, known as "Stockfish NNUE", demonstrated a significant increase in Elo (or playing strength) even though it halved the engine's raw search (nodes per second) because of the higher computational cost of neural inference compared to handcrafted rules.
Following the success of the Stockfish NNUE prototype in early 2020, many developers realized that handcrafted evaluation could no longer compete with the massive playing strength provided by NNUE. This led the chess engine community to shift towards a neural-network evaluation approach, making NNUE largely popular among chess engines.
Architecture
The NNUE 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, which is the score of the board.[7]
NNUE starts with how it looks at the board. Instead of passing a simple 8x8 grid, it uses a massive, sparse input layer, often called the HalfKP feature set. This means the network tracks the position of every piece relative to the king's location. Because only one piece moves at a time, the engine doesn't need to recalculate the entire network from the start for every move, it simply "updates" the changed neurons. The first layer is massive, often containing tens of thousands of input features, but it stays fast because it is sparse.[8][9]
Performance
NNUE is a neural-network based evaluation function used inside a chess engine's search.[10][11] They use incremental computation and single instruction multiple data (SIMD) techniques along with appropriate intrinsic instructions.[12] In contrast, deep neural network-based chess engines such as Leela Chess Zero or AlphaZero require GPU-based (TPU-based in AlphaZero's case) inference.[13][14]
See also
- YaneuraOu - The shogi engine that first implemented the NNUE.
- Elmo (shogi engine)
- Stockfish chess engine - The chapter about NNUE features a visualization of NNUE.
- List of chess software