If I understand correctly NN is based on many games from the opening position.
During a game people get a position that is not the opening position so the question is why not building a special NN for the specific position that you want to analyze and instead of analyzing it for 2 weeks with a bad evaluation to use one week in order to build a better evaluation for the specific position you analyze and one week to analyze(assuming one week is enough to build a significantly better evaluation that does not have to be a better evaluation for chess but only a better evaluation for the root position and what comes after it).
I wonder if there is a tool that people can download simply to build NN for some time that you define in advance and analyze later with the NN you got.
building NN for different chess positions
Moderator: Ras
-
- Posts: 10793
- Joined: Thu Mar 09, 2006 12:37 am
- Location: Tel-Aviv Israel
-
- Posts: 3233
- Joined: Wed Mar 10, 2010 10:18 pm
- Location: Hamburg, Germany
- Full name: Srdja Matovic
Re: building NN for different chess positions
I guess you misunderstand how a NN is trained by chess positions, a two weeks analyze of a single position won't improve anything.
A common scheme for training NNUE is to take billions of different chess positions, run an depth n search with AB+QS+Eval, get the score, label the position with score, train neural network via these labeled positions. Hence by runing a deeper search you get a better score to label the position. There are various concepts for mixing games/positions and multilabeling positions.
During this process the NN memorizes chess patterns used for the inference in the actual eval of the chess playing engine.
A0/Lc0 training is done via Reinforcement Learning, it plays against itself, learning these patterns on its own during selfplay.
There was an TDLeaf approach present in computer chess, idk if it is used anymore, in theory, TDLeaf should profit from increasing search depth not only via a better score, but due to backpropagating the score to the initial position.
https://www.chessprogramming.org/Tempor ... 8.CE.BB.29
--
Srdja
A common scheme for training NNUE is to take billions of different chess positions, run an depth n search with AB+QS+Eval, get the score, label the position with score, train neural network via these labeled positions. Hence by runing a deeper search you get a better score to label the position. There are various concepts for mixing games/positions and multilabeling positions.
During this process the NN memorizes chess patterns used for the inference in the actual eval of the chess playing engine.
A0/Lc0 training is done via Reinforcement Learning, it plays against itself, learning these patterns on its own during selfplay.
There was an TDLeaf approach present in computer chess, idk if it is used anymore, in theory, TDLeaf should profit from increasing search depth not only via a better score, but due to backpropagating the score to the initial position.
https://www.chessprogramming.org/Tempor ... 8.CE.BB.29
--
Srdja
-
- Posts: 10793
- Joined: Thu Mar 09, 2006 12:37 am
- Location: Tel-Aviv Israel
Re: building NN for different chess positions
What is the source of billions of different chess positions?smatovic wrote: ↑Thu May 19, 2022 8:21 pm I guess you misunderstand how a NN is trained by chess positions, a two weeks analyze of a single position won't improve anything.
A common scheme for training NNUE is to take billions of different chess positions, run an depth n search with AB+QS+Eval, get the score, label the position with score, train neural network via these labeled positions. Hence by runing a deeper search you get a better score to label the position. There are various concepts for mixing games/positions and multilabeling positions.
During this process the NN memorizes chess patterns used for the inference in the actual eval of the chess playing engine.
A0/Lc0 training is done via Reinforcement Learning, it plays against itself, learning these patterns on its own during selfplay.
There was an TDLeaf approach present in computer chess, idk if it is used anymore, in theory, TDLeaf should profit from increasing search depth not only via a better score, but due to backpropagating the score to the initial position.
https://www.chessprogramming.org/Tempor ... 8.CE.BB.29
--
Srdja
If it is games from the opening position then it is possible to play games from a different opening position and build NN for the different opening position.
Do you say that 2 weeks are not enough to build something useful?
In this case how much time you need to build NN that is clearly superior to chess evaluation without NN?
How much time for NNUE and how much time for NN in the way Lc0 training is done?
Without understanding exactly how NN or NNUE work I understand that
there is nothing special about the opening position of chess and you can define chessX to be a game with a different opening position(for example white without pawn e2) and build lc0 or NNUE engine for this position.
-
- Posts: 3233
- Joined: Wed Mar 10, 2010 10:18 pm
- Location: Hamburg, Germany
- Full name: Srdja Matovic
Re: building NN for different chess positions
Sorry, I am not into Lc0 and SF NNUE development, and the best practices are a moving target, maybe these links help:
https://github.com/glinscott/nnue-pytor ... g-datasets
https://github.com/LeelaChessZero/lc0/w ... t-Training
or someone else can chime in to answer your questions.
--
Srdja
https://github.com/glinscott/nnue-pytor ... g-datasets
https://github.com/LeelaChessZero/lc0/w ... t-Training
or someone else can chime in to answer your questions.
--
Srdja
-
- Posts: 540
- Joined: Thu Mar 09, 2006 3:01 pm
- Full name: Brian Richardson
Re: building NN for different chess positions
The billions of positions come from games. SF uses some of the many millions of Lc0 game positions in its NNUE training sometimes too.Uri Blass wrote: ↑Thu May 19, 2022 9:37 pm What is the source of billions of different chess positions?
If it is games from the opening position then it is possible to play games from a different opening position and build NN for the different opening position.
Do you say that 2 weeks are not enough to build something useful?
In this case how much time you need to build NN that is clearly superior to chess evaluation without NN?
How much time for NNUE and how much time for NN in the way Lc0 training is done?
Without understanding exactly how NN or NNUE work I understand that
there is nothing special about the opening position of chess and you can define chessX to be a game with a different opening position(for example white without pawn e2) and build lc0 or NNUE engine for this position.
The training is teaching the net to generalize. The reason that Lc0 type nets are so strong in the opening is that the nets have seen many more positions closer to the opening than the vastly more diverse middle and end game positions. Interestingly, a net was trained with fewer pieces (I don't recall how many exactly, maybe 12ish), so it had never seen an opening position with all 32 pieces, and yet it played surprisingly well. So, you could train from a specific line and the positions would all flow from that. It would take less time to get to say 3,000+ Elo, but it would not become competitive with the very strongest nets without training for months.
How long depends. NNUE training is much faster once you have the billions of positions, so data preparation takes quite a bit of time, but the actual net is tiny relative to the size of the nets used with Lc0. Lc0 nets that are very strong take longer to train than 2 weeks, but a net that is about roughly 3,200 Elo in human terms can be trained from existing games (that have already been played and the data saved in a special format by Lc0) in just a day or so. Training an Lc0 type net from PGN games (which lack the special additional info) can be done in a day and play at about 3,000 Elo. After that, things get progressively more difficult. That is generally termed supervised learning or SL. Starting from scratch is typically called reinforcement learning or RL. There, the playing of many hundreds of millions of games takes much longer than training the new nets incrementally along the way. Lc0 training is measured in many months including the so-called self-play games along the way. If those game are already done, then the SL training can take a day or so up to about a month. Fully developed RL nets so far have always been about 100 Elo stronger than any comparable SL net.
-
- Posts: 10793
- Joined: Thu Mar 09, 2006 12:37 am
- Location: Tel-Aviv Israel
Re: building NN for different chess positions
I wonder if time to build a good NN for some endgame position is smaller because the number of future positions is clearly smaller than the number of future positions from the opening position.
usually 0.00 positions or positions with high score is no problem and the main problem is with positions with 1.xx evaluation to see if the engine can learn if it is a win for the better side or maybe a draw.
usually 0.00 positions or positions with high score is no problem and the main problem is with positions with 1.xx evaluation to see if the engine can learn if it is a win for the better side or maybe a draw.
-
- Posts: 540
- Joined: Thu Mar 09, 2006 3:01 pm
- Full name: Brian Richardson
Re: building NN for different chess positions
Endgames with a few pieces do not work, at least for me.
I was able to quickly train small nets to mate with KQvK or KRvK.
However, I could not train a net to mate with KBNvK.
I suspect it is because there a too FEW positions available.
When training those test nets I generated every possible endgame position as input.
It could also be related to the fact that NN search is generally quite poor at tactics compared to A/B engines which excel at tactics.
With "early" endgame positions with more pieces there are enough positions to train.
However, then the problem becomes that with table bases available, it is a "waste" to train nets to learn what the TBs already contain as "perfect" information. In practice those endgame nets will fare poorly vs "standard" nets with TB access, so why bother.
Others have trained endgame-specific nets with around 98% accuracy (IIRC), but of course that is useless in actual play when TBs are 100%.
I was able to quickly train small nets to mate with KQvK or KRvK.
However, I could not train a net to mate with KBNvK.
I suspect it is because there a too FEW positions available.
When training those test nets I generated every possible endgame position as input.
It could also be related to the fact that NN search is generally quite poor at tactics compared to A/B engines which excel at tactics.
With "early" endgame positions with more pieces there are enough positions to train.
However, then the problem becomes that with table bases available, it is a "waste" to train nets to learn what the TBs already contain as "perfect" information. In practice those endgame nets will fare poorly vs "standard" nets with TB access, so why bother.
Others have trained endgame-specific nets with around 98% accuracy (IIRC), but of course that is useless in actual play when TBs are 100%.
-
- Posts: 147
- Joined: Mon Apr 16, 2012 7:23 pm
- Location: Istanbul, TURKEY
Re: building NN for different chess positions
I still think it'll be better aproach to train endgames first with reinforcement learning because we can now what's happening %100 sure up-to 7 pieces so their weight gonna be accurate. Also this is a theory but net sizes should contain 204 filter/block (w/e) instead random 256 or 128 because there are total of 204 squares in chess board. I also don't believe they are too few positions argument. Measure twice cut once approach feels correct after that it can go to middle game or oppening phase of training.
-
- Posts: 10793
- Joined: Thu Mar 09, 2006 12:37 am
- Location: Tel-Aviv Israel
Re: building NN for different chess positions
I wonder if the score of all wins are the same in the training.brianr wrote: ↑Fri May 20, 2022 3:43 pm Endgames with a few pieces do not work, at least for me.
I was able to quickly train small nets to mate with KQvK or KRvK.
However, I could not train a net to mate with KBNvK.
I suspect it is because there a too FEW positions available.
When training those test nets I generated every possible endgame position as input.
It could also be related to the fact that NN search is generally quite poor at tactics compared to A/B engines which excel at tactics.
With "early" endgame positions with more pieces there are enough positions to train.
However, then the problem becomes that with table bases available, it is a "waste" to train nets to learn what the TBs already contain as "perfect" information. In practice those endgame nets will fare poorly vs "standard" nets with TB access, so why bother.
Others have trained endgame-specific nets with around 98% accuracy (IIRC), but of course that is useless in actual play when TBs are 100%.
Maybe it is the problem and it is better to train for a game when mating faster gives more points.
You do not need a deep search in KBN vs K if you know to push the king to the right corner and the question if the NN learned that positions when the king is close to the right corner are better than positions when the king is not close to the right corner.
-
- Posts: 540
- Joined: Thu Mar 09, 2006 3:01 pm
- Full name: Brian Richardson
Re: building NN for different chess positions
For KBNvK it is actually a surprising deep search for Lc0.
Even A/B engines have trouble without a specific piece square table for that mate.
But, you are correct that Lc0 does not often see the fastest mate.
BTW, a 3rd part of the net architecture called the moves left head was added to try to address that, but it is only marginally useful.
Even A/B engines have trouble without a specific piece square table for that mate.
But, you are correct that Lc0 does not often see the fastest mate.
BTW, a 3rd part of the net architecture called the moves left head was added to try to address that, but it is only marginally useful.