Open caissist opened 1 week ago
Hello caissist,
I don't speak German, but if I understood the Google translation of your message correctly, yes, the idea of the library is to train a NNUE network solely from the results of games played. My Orion v1.0 UCI chess engine uses this library and is currently rated at over 3100 Elo (see here)!
To use the library, you must first retrieve (or create) pgn files, then follow these instructions.
Recently John Merlino managed to integrate the library into his own engine, Myrddin v0.91.
Best regards, David
Hello David,
Sorry, of course I wanted to write in English, but I was too quick - forgotten. A new attempt - please between the lines below.
yes, the idea of the library is to train a NNUE network solely from the results of games played.
I'm quoting from your project site: "Training now relies on game results (from which a win ratio is deduced for each position during a game) and material only !"
To me that means there are two parameters:
Is that right?
To use the library, you must first retrieve (or create) pgn files, then follow these [instructions] https://github.com/david-carteau/cerebrum/tree/main/v1.0
As I stated, I'm a beginner when it comes to NNUE. Please, asking back the following questions:
And finally:
Thank you very much!
best regards
Wieland
Hello caissist,
To me that means there are two parameters:
- game result
- material balance for each position
Is that right?
Yes, but... you only need to provide games in pgn format: the library will automatically extract the result of each game, and compute the raw material score of each position (you don't have to provide it) !
- It needs two things to integrate NNUE into a chess bot: NNUE architecture and a NNUE database.
I'm not sure to understand what you mean by "NNUE database", I imagine this corresponds to the "NNUE network".
From what I understand, the entire NNUE architecture is contained in your two files, cerebrum.c and cerebrum.h. Is that right?
Yes, these two files describe the network architecture in C language, and provide the inference code (i.e. the code used to produce outputs - the pseudo win ratio and the pseudo material score - from inputs).
NNUE architecture and NNUE database are interconnected and interdependent. A chess bot can only read a NNUE database if the correct NNUE architecture has been implemented. Is that right?
Yes, if you want to change the network architecture, you'll have to change these files (cerebrum.h and cerebrum.h), which are used for the inference, but also - and accordingly - the trainer (train.py).
- What do I still have to implement in the current code of my chess bot in order to be able to use your NNUE architecture?
The simplest approach is to "plug" the provided C inference code into your engine, and try to load and use Orion's own network. This will allow you to check that everything is ok on the inference side, and then you're ready to train your own networks!
To do this: 1) Import the library:
2) Load the network (the "NNUE database"): nn_load(NN_FILE);
3) When evaluating a position : NN_Accumulator accumulator; nn_update_all_pieces(accumulator, whites, blacks); nn_eval(accumulator, (color == WHITE ? 0 : 1));
Assuming that:
whites
and blacks
variables are arrays of six 'bitboards' (in this order : pawns, knights, bishops, rooks, queens, kings)bitboards
variables are 64-bit unsigned integers, where each bit represents a square (a1=bit #0, ..., h8 = bit #63), and a bit set to 1
means there's a piece on that squareWhich NNUE dimension does your NNUE architecture have? Is it correct that the NNUE dimension determines the size of the NNUE database?
The current (v1.0) network architecture is 2x(768x128)x32x32x2. I have tried to have less hidden layers, but it gave me worse results. And yes, changing the architecture will increase/decrease the number of parameters, and the size of the final network (in bytes).
- How many games (positions) do I have to prepare in order to be able to use your NNUE architecture (dimension) sensibly?
From my experiments, the minimum number of games needed to train a "good" network is at least 128 million positions.
- For preparing the data: How can I implement the path to my Syzygy table bases in your Python script syzygy.py?
As described in the README.md, put the tablebases in two different folders, one for 3-4-5 pieces, the other for 6 pieces endgames:
./1. data preparation/syzygy/3-4-5/
./1. data preparation/syzygy/6-pieces/
I hope this helps !
Kind regards,
David
Hi David, ich stolperte nur zufällig über Deinen Beitrag, und ich bin daran interessiert, um als Anfänger in Sachen NNUE meinen einfachen Schach-Bot in C auch mit einer NNUE-gestützten Bewertungsfunktion auszustatten. Am Anfang muß man einfach anfangen, daher mein Interesse an Deinem Vorschlag. Wenn ich richtig verstand, ist der Kerngedanke, ich zitiere: "Training now relies on game results (from which a win ratio is deduced for each position during a game) and material only". Es heißt, es werden nur das Partieergebnis und die Materialkonstellation für jede Stellung ausgewertet, und nichts anderes. Darin liegt Dein Grundgedanke für eine einfache NNUE-Datenbank. Ist das so richtig? Und: hast Du schon Testergebnisse im Spiel mit Deinem Schach-Bot mit einer solchen NNUE-Datenbank?
Dankeschön.