Answers.Body: <p>Technically, Stockfish does make use of past matches, just not when it's playing. The way it uses its <a href="https://github.com/glinscott/nnue-pytorch/wiki/Training-datasets" rel="nofollow noreferrer">past matches is during training</a>, when a new neural network (NNUE in Stockfish's case) is being trained. Once the NNUE is trained, though, it is &quot;standalone&quot; and does not change anymore.</p>
  <p>The Stockfish you can download and play has an already-trained NNUE, so it does not use past matches.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-05-26T05:32:15.277Z
Answers.Text: Oh, so Stockfish uses a neural network as well ? I thought stockfish , komodo etc, were not neural network based, whereas leela, alphazero etc. were neural network based
Answers.UserDisplayName: silverrahul
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-05-26T05:33:12.283Z
Answers.Text: @silverrahul that's in the past - it changed last year: https://stockfishchess.org/blog/2020/introducing-nnue-evaluation/
Answers.UserDisplayName: Allure
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-08-20T15:08:54.070Z
Answers.Text: Comments are not for extended discussion; this conversation has been [moved to chat](https://chat.stackexchange.com/rooms/138650/discussion-on-answer-by-allure-does-the-stockfish-engine-use-past-matches-or-do).
Answers.UserDisplayName: Brian Towers
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-08-20T15:16:32.777Z
Answers.Text: @Allure Interesting. I didn't know SF uses Leela now. I could still be fussy here, but I'll give in and agree that past games were used to build current versions of SF. **BUT** the answer states that "*it uses its past matches [...] during training*", so I still think that the answer is wrong and that our discussion is somewhat misguided.
Answers.UserDisplayName: Hauptideal
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-08-20T23:37:09.453Z
Answers.Text: @Hauptideal but it does, the positions are generated from self-play. https://github.com/glinscott/nnue-pytorch/wiki/Training-datasets
Answers.UserDisplayName: Allure
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-08-21T13:30:16.160Z
Answers.Text: You're right. Sorry. I wasn't up to date - thanks for rectifying that and providing the links! - upvoted
Answers.UserDisplayName: Hauptideal
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-05-26T02:39:03.653Z
Answers.LastActivityDate: 2022-08-21T13:28:47.783Z
Answers.LastEditDate: 2022-08-21T13:28:47.783Z
Answers.UserDisplayName: Allure
Answers.Body: <blockquote>
  <p>does the Stockfish engine need to be fed data from past matches</p>
  </blockquote>
  <p>No.</p>
  <p>You are confusing Stockfish with AlphaZero. The two engines work in entirely different ways.</p>
  <p>Stockfish works by using brute force calculation plus clever evaluation functions to determine what is the best move in any position.  During a game it maintains hash tables of positions and evaluations <em>that have occurred during that game</em> so that when it calculates a transposition of an earlier calculated position it doesn't redo the calculations but just uses the previous one.</p>
  <p>If an opening database is available it <em>can</em> use that but it also works perfectly well albeit slower without. Similarly in the endgame it <em>can</em> use tablebases if available which can greatly increase speed and accuracy.</p>
  <p>AlphaZero, however, <em>does</em> rely on millions of training games played against itself in order to update its policy (learn to play chess well). It does not need data from past matches after it has been trained in order to play chess - the experience obtained from the past games is implicitly contained in the weights of the neural network.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-08-21T00:35:33.407Z
Answers.Text: Newer versions of Stockfish do use NNUE weights which come from millions of past games.
Answers.UserDisplayName: qwr
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-05-25T20:31:56.903Z
Answers.LastActivityDate: 2022-08-20T15:26:38.613Z
Answers.LastEditDate: 2022-08-20T15:26:38.613Z
Answers.UserDisplayName: Brian Towers
Answers.Body: <p>To answer your question concisely, SF does not need a 'database' as in raw data pulled from a bag, but its NNUE function concatenates the moves, move order, and outcomes of many games played against itself to make more informed move decisions based on learned strategies and deep thinking.</p>
  <p>A database is like a grocery store. An NNUE is like a cookbook from a Top Chef (it's gonna contain precise measurements, ingredients, cooking times, and detailed preparation as well as pictures showing garnished finished products--maybe even some backstory)</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-06-27T09:33:44.627Z
Answers.Text: why downvote and not explain why? (EDIT: this comment is for the one that downvoted, not the post-creator)  welcome to chess!
Answers.UserDisplayName: William Martens
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-08-20T07:58:00.993Z
Answers.LastActivityDate: 2022-08-20T07:58:00.993Z
Answers.UserDisplayName: rome
Answers.Body: <p>If you see &quot;NNUE&quot; on the end of Stockfish's name, it means it's using something called a neural network (i.e. &quot;Stockfish 15.1 NNUE&quot;). A neural network works in a similar fashion to how your brain does. For example, you can look at an easy chess puzzle (say, a simple knight fork), and immediately know the right move. You don't have to check that the knight is attacking your opponent's king and rook, or that it is moving to a safe square. You <em>know</em> that it wins the exchange. Or, a better explanation might be the common description of Jose Raul Capablanca's abilities---many said that he could take one glance at a chessboard and know what the position needed.</p>
  <p>That's a pretty simple explanation of how a neural network functions. Stockfish trains its neural network by playing millions of games with itself, and with each game the network gets a tiny bit better at evaluating positions. Then in an actual game or evaluation, it uses the network alongside traditional engine calculation to provide more accurate positional play (pawn structures and piece placement are what are really affected by neural network evaluation).</p>
  <p>So the answer is yes and no. Stockfish doesn't reference a game database when it plays, but it does use a neural network that essentially makes it learn from its mistakes during self-play.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-06-27T09:33:38.477Z
Answers.Text: why downvote and not explain why? (EDIT: this comment is for the one that downvoted, not the post-creator)  welcome to chess!
Answers.UserDisplayName: William Martens
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-06-26T20:59:56.113Z
Answers.LastActivityDate: 2023-06-26T20:59:56.113Z
Answers.UserDisplayName: InfiniteDonuts
Answers.Body: <p>NNue is not trained through self play.  It is using SF evaluations as target output data vector during some form of supervised learning.  It does not use game but many positions with SF single root searches of moderate depth, as target output data to fit with generalization power (requires validation data, contrary to fishtest optimization, which tests and &quot;train&quot; on games and their outcome, but not as RL self-play scheduling).</p>
  <p>I would love to be contradicted with specific link to support that.</p>
  <p>Otherwise, for my claim, I point of SF12 Blog, where it is stipulated as above, in very few economic lines.  Later, more recently, the blog mentions using also Leela's data, which I understand still as positions not games.</p>
  <p>I currently understand that the master NN (if still called that) is still trained using a single SF search on the input position of the input data vector.  It is an approximator of SF with either a simple non-NN evaluation (also looking for pointers), or some iteration of the process, where SF includes previous iteration of NNue approximating SF.  A sort of feedback loop of self-approximation. But no self-play, other than in fishtest but self is about the name SF, as none of the versions in SF ever play against own clone (unless pointer).  SFx vs SFy.  Global optimization scheme based pools of dev. instances (with different parameter values).</p>
  <p>There are rumors around that describe this (iteration over NNue SL training) as some sort of reinforcement learning (not at all what I think it means in ML). This might explain many propagated rumors using self-play and games, as if it was using Deep RL as in A0 or LC0.  I don't mind being contradicted with new information.</p>
  <p>Some old text from nodchip repository is still using such wording. Ai chat bot might still regurgitate the confusion.  I think SF should get their explanation reviewed  for that important chess interpretation question.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-03-24T07:42:32.650Z
Answers.LastActivityDate: 2024-03-24T07:49:39.563Z
Answers.LastEditDate: 2024-03-24T07:49:39.563Z
Answers.UserDisplayName: dbdb
Answers.Body: <p>While I understand that Stockfish is working with NNUE instead of having a separate database that contains critical positions with their evaluation, this is not very useful for game analysis, and I would not currently use Stockfish for that purpose. I would rather use the derivative engines SugaR NN 1.1, or SugaR AI 2.5, which are based on the Stockfish code but which CONTAIN data of previous matches, so-called 'experience' files and even tools to view and edit them. Basically, I'm not interested in using the 'strongest' chess engine but the one which allows me to intelligently carry out my analysis, and these experience files are a great part of it, a 'must-have' to make the engine's calculation go in a certain direction.</p>
  <p>So my answer is: NO, curently the main Stockfish engine doesn't have a separate 'learning' database, but some important derivative engines do have it. And YES, the main Stockfish engine should have such an accessible learning database, not for defeating other engines (NNUE can do that), but for offering to common chess players a useful tool for training or the analyses of their own games.</p>
  <p>For example, I would highly like what every engine could have provided in the last 40 years: A simple possibility to enter manually an evaluation of a certain position that is then considered in future tree calculations. To my knowledge only the older Shredder engine has this feature, and only in its own GUI. With SugaR 2.5 you have a similar feature by editing the experience files, but it's a cumbersome process that could be simplified by providing it in the UCI options.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-03-29T17:45:16.053Z
Answers.LastActivityDate: 2024-03-29T19:58:12.217Z
Answers.LastEditDate: 2024-03-29T19:58:12.217Z
Answers.UserDisplayName: MikeTrans
Body: <p>I have a simple question. Does the Stockfish engine use, amongst the steps of its complicated algorithm, a library/database of past matches?
  For such an algorithm to work, it would to need store many matches that have had a particular scenario. Each scenario has a player who went on to win. Thus, it is provided some kind of rating point to judge each particular scenario with, allowing it to choose the best move. It's either that or the Stockfish engine works just by working through the possible moves to figure out how to win.</p>
  <p><strong>In other words, does the Stockfish engine need to be fed data from past matches or can it work without any such data ?</strong></p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-05-25T17:27:12.523Z
Comments.Text: I think this will help you : https://www.quora.com/What-is-the-algorithm-behind-Stockfish-the-chess-engine
Comments.UserDisplayName: p_square
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-05-25T19:15:57.577Z
Comments.Text: @Algebrology thanks, a lot. So, it seems the answer is NO. Thank you for that link , it really helped a lot. I am surprised though, it feels like i have heard it said a lot that chess engines analyse positions by comparing them with the positions in previous matches played between people. But i guess, i must have misunderstood
Comments.UserDisplayName: silverrahul
Tags: <engines><stockfish>
Title: Does the Stockfish engine use past matches, or does it not need such a "database"?
ThreadText: # Does the Stockfish engine use past matches, or does it not need such a "database"?
  
  (Asked by: username_0 on 2021-05-25)
  
  I have a simple question. Does the Stockfish engine use, amongst the steps of its complicated algorithm, a library/database of past matches?
  For such an algorithm to work, it would to need store many matches that have had a particular scenario. Each scenario has a player who went on to win. Thus, it is provided some kind of rating point to judge each particular scenario with, allowing it to choose the best move. It's either that or the Stockfish engine works just by working through the possible moves to figure out how to win.
  
  **In other words, does the Stockfish engine need to be fed data from past matches or can it work without any such data ?**
  
  **Tags:** engines, stockfish
  
  > **Comments:**
  > **username_1**: I think this will help you : https://www.quora.com/What-is-the-algorithm-behind-Stockfish-the-chess-engine  
  > **username_0**: @Algebrology thanks, a lot. So, it seems the answer is NO. Thank you for that link , it really helped a lot. I am surprised though, it feels like i have heard it said a lot that chess engines analyse positions by comparing them with the positions in previous matches played between people. But i guess, i must have misunderstood  
  
  ---
  
  ## 6 answers
  
  ### Answer by username_2 on 2021-05-26. Score: 7
  
  Technically, Stockfish does make use of past matches, just not when it's playing. The way it uses its [past matches is during training](https://github.com/glinscott/nnue-pytorch/wiki/Training-datasets), when a new neural network (NNUE in Stockfish's case) is being trained. Once the NNUE is trained, though, it is "standalone" and does not change anymore.
  
  The Stockfish you can download and play has an already-trained NNUE, so it does not use past matches.
  
  > **Comments:**
  > **username_0**: Oh, so Stockfish uses a neural network as well ? I thought stockfish , komodo etc, were not neural network based, whereas leela, alphazero etc. were neural network based  
  > **username_2**: @username_0 that's in the past - it changed last year: https://stockfishchess.org/blog/2020/introducing-nnue-evaluation/  
  > **username_3**: Comments are not for extended discussion; this conversation has been [moved to chat](https://chat.stackexchange.com/rooms/138650/discussion-on-answer-by-username_2-does-the-stockfish-engine-use-past-matches-or-do).  
  > **username_4**: @username_2 Interesting. I didn't know SF uses Leela now. I could still be fussy here, but I'll give in and agree that past games were used to build current versions of SF. **BUT** the answer states that "*it uses its past matches [...] during training*", so I still think that the answer is wrong and that our discussion is somewhat misguided.  
  > **username_2**: @username_4 but it does, the positions are generated from self-play. https://github.com/glinscott/nnue-pytorch/wiki/Training-datasets  
  > **username_4**: You're right. Sorry. I wasn't up to date - thanks for rectifying that and providing the links! - upvoted  
  
  ---
  
  ### Answer by username_3 on 2021-05-25. Score: 1
  
  > does the Stockfish engine need to be fed data from past matches
  
  No.
  
  You are confusing Stockfish with AlphaZero. The two engines work in entirely different ways.
  
  Stockfish works by using brute force calculation plus clever evaluation functions to determine what is the best move in any position. During a game it maintains hash tables of positions and evaluations *that have occurred during that game* so that when it calculates a transposition of an earlier calculated position it doesn't redo the calculations but just uses the previous one.
  
  If an opening database is available it *can* use that but it also works perfectly well albeit slower without. Similarly in the endgame it *can* use tablebases if available which can greatly increase speed and accuracy.
  
  AlphaZero, however, *does* rely on millions of training games played against itself in order to update its policy (learn to play chess well). It does not need data from past matches after it has been trained in order to play chess - the experience obtained from the past games is implicitly contained in the weights of the neural network.
  
  > **Comments:**
  > **username_5**: Newer versions of Stockfish do use NNUE weights which come from millions of past games.  
  
  ---
  
  ### Answer by username_6 on 2022-08-20. Score: 0
  
  To answer your question concisely, SF does not need a 'database' as in raw data pulled from a bag, but its NNUE function concatenates the moves, move order, and outcomes of many games played against itself to make more informed move decisions based on learned strategies and deep thinking.
  
  A database is like a grocery store. An NNUE is like a cookbook from a Top Chef (it's gonna contain precise measurements, ingredients, cooking times, and detailed preparation as well as pictures showing garnished finished products--maybe even some backstory)
  
  > **Comments:**
  > **username_7**: why downvote and not explain why? (EDIT: this comment is for the one that downvoted, not the post-creator)  welcome to chess!  
  
  ---
  
  ### Answer by username_8 on 2023-06-26. Score: 0
  
  If you see "NNUE" on the end of Stockfish's name, it means it's using something called a neural network (i.e. "Stockfish 15.1 NNUE"). A neural network works in a similar fashion to how your brain does. For example, you can look at an easy chess puzzle (say, a simple knight fork), and immediately know the right move. You don't have to check that the knight is attacking your opponent's king and rook, or that it is moving to a safe square. You *know* that it wins the exchange. Or, a better explanation might be the common description of Jose Raul Capablanca's abilities---many said that he could take one glance at a chessboard and know what the position needed.
  
  That's a pretty simple explanation of how a neural network functions. Stockfish trains its neural network by playing millions of games with itself, and with each game the network gets a tiny bit better at evaluating positions. Then in an actual game or evaluation, it uses the network alongside traditional engine calculation to provide more accurate positional play (pawn structures and piece placement are what are really affected by neural network evaluation).
  
  So the answer is yes and no. Stockfish doesn't reference a game database when it plays, but it does use a neural network that essentially makes it learn from its mistakes during self-play.
  
  > **Comments:**
  > **username_7**: why downvote and not explain why? (EDIT: this comment is for the one that downvoted, not the post-creator)  welcome to chess!  
  
  ---
  
  ### Answer by username_9 on 2024-03-24. Score: 0
  
  NNue is not trained through self play. It is using SF evaluations as target output data vector during some form of supervised learning. It does not use game but many positions with SF single root searches of moderate depth, as target output data to fit with generalization power (requires validation data, contrary to fishtest optimization, which tests and "train" on games and their outcome, but not as RL self-play scheduling).
  
  I would love to be contradicted with specific link to support that.
  
  Otherwise, for my claim, I point of SF12 Blog, where it is stipulated as above, in very few economic lines. Later, more recently, the blog mentions using also Leela's data, which I understand still as positions not games.
  
  I currently understand that the master NN (if still called that) is still trained using a single SF search on the input position of the input data vector. It is an approximator of SF with either a simple non-NN evaluation (also looking for pointers), or some iteration of the process, where SF includes previous iteration of NNue approximating SF. A sort of feedback loop of self-approximation. But no self-play, other than in fishtest but self is about the name SF, as none of the versions in SF ever play against own clone (unless pointer). SFx vs SFy. Global optimization scheme based pools of dev. instances (with different parameter values).
  
  There are rumors around that describe this (iteration over NNue SL training) as some sort of reinforcement learning (not at all what I think it means in ML). This might explain many propagated rumors using self-play and games, as if it was using Deep RL as in A0 or LC0. I don't mind being contradicted with new information.
  
  Some old text from nodchip repository is still using such wording. Ai chat bot might still regurgitate the confusion. I think SF should get their explanation reviewed for that important chess interpretation question.
  
  
  ---
  
  ### Answer by username_10 on 2024-03-29. Score: 0
  
  While I understand that Stockfish is working with NNUE instead of having a separate database that contains critical positions with their evaluation, this is not very useful for game analysis, and I would not currently use Stockfish for that purpose. I would rather use the derivative engines SugaR NN 1.1, or SugaR AI 2.5, which are based on the Stockfish code but which CONTAIN data of previous matches, so-called 'experience' files and even tools to view and edit them. Basically, I'm not interested in using the 'strongest' chess engine but the one which allows me to intelligently carry out my analysis, and these experience files are a great part of it, a 'must-have' to make the engine's calculation go in a certain direction.
  
  So my answer is: NO, curently the main Stockfish engine doesn't have a separate 'learning' database, but some important derivative engines do have it. And YES, the main Stockfish engine should have such an accessible learning database, not for defeating other engines (NNUE can do that), but for offering to common chess players a useful tool for training or the analyses of their own games.
  
  For example, I would highly like what every engine could have provided in the last 40 years: A simple possibility to enter manually an evaluation of a certain position that is then considered in future tree calculations. To my knowledge only the older Shredder engine has this feature, and only in its own GUI. With SugaR 2.5 you have a similar feature by editing the experience files, but it's a cumbersome process that could be simplified by providing it in the UCI options.
  
  
  ---
  
  