-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
develop NN #16
Comments
I found these 2 nice links for NNUE implementations in chess: |
Nice finding .. those papers are to complicated for me .. lots of unknown terms .. i see the global picture though, i recognize some principles & terms .. however, i like you mention this here, also for any other developer who ever joins this Issue. |
can you briefly explain in general how we can use many positions (variations from the 4N position) to build / train a NN ? This is basic for me to understand NNs .. |
Sure. It works very similar to feed forward NNs with 1 layer and liner activation function. Its ideal is to check the sign of the expected evaluation of the position (generated by SF14.1 as example) minus actual evaluation of own evaluation function. For source code, look at method newAdjustment, here: https://github.com/bagaturchess/Bagatur/blob/master/Sources/LearningImpl/src/bagaturchess/learning/goldmiddle/visitors/LearningVisitorImpl.java Than the algorithm accumulates all changes - millions of +1 and -1. At the end of each tuning iteration, the weights are multiplied by weight, so next time the error / delta between both evaluations will be smaller. We can start with it. I also have used standard Java NN frameworks, like Neuroph, Deep Netts and DeepLearning4J. Is this starting point works for you? |
Regarding this: "Can a max depth be set when training the NN ?" Just for information. The code of positions generator is here: https://github.com/bagaturchess/Bagatur/tree/master/Sources/UCITracker |
A bit more comments on this: "In general, no, because we tune the evaluation function, not the search - there is no depth at all. This is general problem for tuning accuracy ... it is valid issue in all cases, when we use Neuroph, Deep Netts, DeepLearning4J or Gold Middle tuning algorithm. In order to know for which position we have evaluation, we need to know the best moves line. We have to play it and then to assign the evaluation to this position. This is problematic, because for example SF very often cuts the move lines, which are send over the UCI protocol. Only the first move appears very often. From this perspective SF is not good choice at all. Do you have observations on that during your engines testing? We need strong engine in endgames, which always produce full move lists and send them to UCI. We talk about the PV line. |
for that, do you need an engine with MPV ? |
and then each MPV line must be full / long ? |
i should test your UCITracker .. is it for Linux also ? Should i be able to compile it ? |
Yes, I use: |
Yes, this is the main benefit from using Java :-) The only negative is that you have to install Java for your OS. :-) |
500 ? In most positions only 10 moves are relevant ? Maybe even max 50 moves possible ? So why 500 ? |
We need all possible moves, it is set to higher value to be on the safe side. |
Java runs nice on my OS until now. |
The GitHub repo of Bagatur is Eclipse workspace. This is the best IDE for Java in this case, because it will be very easy to make it working. |
mmm .. can i do without Elipse ? I think i can install it but i like not to .. |
regarding the real value of a NN just for the 4N position : then we have created game from a "fixed chess position", and white player can try to draw or even win this psotion, but the NN will never loose and often win !? Because i think the black position can ALWAYS be won - i could be wrong here .. |
You have to write build scripts and run code in console. |
OK, i will install Elipse and let you know. |
The color / winner doesn't matter, we use all positions for tuning, just switch the sign, working always from white player point of view. |
Just to mention this: when I use SF, at the end of the tuning I reach 60% accuracy, because of this issue with incomplete PV lines. With some engines, I have tested Glaurung in the past, it may reach even 85% accuracy ... |
regarding the UCITracker : can (2) differnet engines play multi games ? Or can it do only self play ? |
I will investigate my archive .. I will find a nice strong (endgame) engine like that :-) |
Only one engine is supported at the moment https://github.com/bagaturchess/Bagatur/blob/master/Sources/UCITracker/src/bagaturchess/ucitracker/run/GamesGenerator_MultiPv.java |
Hopefully you will find an engine with 3000+ ELO strength. |
here is the list of all my engines above 3000 :
|
however these engine ELOs functuate among the existing (CCRL) lists .. |
Nice, we can start from the top of this list and go down (but skip SF engines) What about Ethereal v13.25 ? |
i don't often use Ethereal .. it tends to crash or disconnect etc .. reaaly, it's strange but true .. most other engines run fine here .. the ShashChess engine is very strong and i like it, but in fact a SF derivative .. |
Ok, then which is the next, which works stable ? Komodo v13.3 or Weiss v2.0? |
that's a pitty, i never had problems with Pedone .. nevermind .. what about Stash ? Has 3222 rating, see https://gitlab.com/mhouppin/stash-bot/-/releases |
Stash : Hash can be minimal 1 Mb (!), it can Ponder, and MPV max 500 ! |
The author of Wasp, John Stanbeck, is a long time chess engine programmer, he also did Zarkov more then 40 years ago ! I did some communication with him, some years ago. My intuition tells me Wasp is not suitable for this 4N pos NN, but Wasp is now even v5.00 with a NN ! So it might have evolved .. |
Wasp v5.00 (with or without NNUE, it's an option)
However, its pv lines in the many-captures position are not long .. all engines have their disadvantages .. that's what i discovered yesterday .. |
Recently I discovered "Fat Titz" .. it's a SF clone .. but at depth 1 it gives rather long (3..) pv lines compared to most other engines and it has nice features :
|
see https://github.com/Sopel97/FatTitz .. the release page offers Windows binaries also. |
This will be the best option if the author somehow succeeded to improve the PV line of standard SF! I will test it ... |
No changes in this cloning in regards to PV collection I will test now Wasp v5.00 ... This is the result of WASP 500 with 0.5M positions It is around SF as PV accuracy. |
Give me some time, I have to investigate and think a bit whether I make the tests correctly ... I will re-test if necessary. |
That is what i thought also .. when doing wrong tests (i know) the conclusions and next steps are nonsense :-) |
It's hard to find a proper engine for our needs .. i stumbled upon Ivanhoe, also for Windows .. rating about 3050 .. it has an impressive option list and rather long pv lines ! .. MPV max 250 ! .. also 'TryPVinAnalysis' and 'AlwaysAnalyze' (which i didn't test yet) :
|
Sure, although we relay on data/facts and logic, we are people and make mistakes ... Here is the last result with engines restart after each game with small amount of positions (below 1M):
Now, I would like to tune Bagatur Dev against stockfish-14.1 evaluations capturing and then measure the ELO difference with 50-100 games in Arena. With the previous test, Bagatur had -320 ELO degradation. |
maybe this SF page is interesting for you : it has several custom builds for many OS .. binary assets for download or to compile : https://abrok.eu/stockfish/ -- this is updated regularly. |
With engines restart before each game and with 7M positions captured by SF 14.1, we reached 61% accuracy after the weights tuning. For years, I never achieved better version via this tuning. I am also not completely sure, that what we are doing now with UCITracker is correct ... |
Currently, we generate positions with initial FEN as starting position, because we have to start more general from the whole game. Next step after the Bagatur Dev vs. Bagatur 2.3 testing, will be to tune for positions produced from 4N position as a starting point. |
Now I remember how much time I have invested in supervised learning experiments. May be the approach used in UCI Tracker, which I have explained in this issue is wrong. May be this is not correct ... We face many examples of this:
Yes, some engines support switching them off, but there are also other factors, even when the PV is correct:
One option to resolve all this issues is to call directly SF evaluation function in Java. We could use Java Native Interface (JNI) for this, but it will need a lot of work. Another direction would be to start with something new, like NNUE. |
Thanks for the info. |
I made some fixes and changes. For now, I would propose to pause the work here for a while and continue working on the online syzygy feature. What do you think? |
This NNUE architecture looks like 2 rockets! ;-) Screenshot taken from https://www.chessprogramming.org/NNUE |
yes, i agree, that's better .. take your time to read about the newest NNUE info & tools etc. The 4Npos NN was just an experiment .. maybe it leads to more insights :-) |
i find a lot of info about training NNUE .. eg. "NN Trainer for use with the Berserk Chess Engine" : https://github.com/jhonnold/berserk-trainer . |
So you are developing a NN version of Bagatur .. i just stumbled upon the GAiA chess engine, see https://github.com/Plagiat01/GAiA .. i managed to compile it on Linux, following its README and copy the concerning ONNX library files .. GAiA uses a special NN, based on ONNX, which is some layer for NN or so .. i have no insight if ONNX is a good technique, but it feels unique and genius - see also its page https://github.com/microsoft/onnxruntime. I hope this will help -- i like to know if ONNX is a good idea, so please give feedback .. no other engines use ONNX, as far as i know - regarding NN there's a lot "on the market" :-) Here's a document about it (the link is in the GitHub text) : Performing Regression on Complex Data.pdf |
Hi, yes, but I am in the beginning and don't know whether and when it will be ready ... I want to achieve better version in ELO. This is what all others have reported when NNUE was widely adopted in the chess engines field. For example, the author of GAiA chess engines reports the opposite. He uses Stockfish 14 and change its static evaluation function with NN. There is ELO drop from 3500 to 2300. Still good chess play and achievement (Congratulations to the author!), but this is not what I am looking for. ONNX should be an optimization of the training speed and/or accuracy ... These code and frameworks again are non-java ... it is always easier to understand algorithms by having look at their code or usage. I only found whitepapers with diagrams, but without enough details regarding the exact NNUE architecture (layers, sizes, connections, activations, and the actual code which creates it) ... including into the PDF document you shared in the previous post. Best regards, |
There is a not productive implementation (not included in the distribution) of NNUE evaluation function. More information and final results could be found here: https://github.com/bagaturchess/Bagatur/tree/master/NNUE |
You and I mentioned this subject in Issue #9 : "draw simple (winning) endgame" ?
the "4N position" : 8/p5pp/1pk5/5p2/P1nn4/2NN3P/5PPK/8 w - - 0 1
It's an endgame from a fixed starting position, which was composed to induce all kinds of complications, while 'zugzwang' occurs because each player has only two knights and some pawns.
Black has a plus pawn and should be able to win this position, but White can draw in many ways.
A few basic chess principles are involved in this position : it shows how tempo, material and the threat of promotion intertwine.
NNs are said to play more intuitively and i just like to test such NN to get a better understanding of it by this rather simple endgame position. I don't know "how this will help" to improve Bagatur in general - we can contemplate later .. therefor I hope the training of such NN will not be too complicated.
Can a max depth be set when training the NN ? I think this position does not deserve searching in great depth, better evaluate a wide spectrum of variations, including all kinds of sacrifices : maybe offer knights for pawn(s), especially the last black pawn, because even when black keeps the 2 knights he can not win without any pawn left on the board .. the engine should know this chess fact in this position !
The text was updated successfully, but these errors were encountered: