Leela Nets for Human Training and "Style"

Discussion of anything and everything relating to chess playing software and machines.

Moderators: hgm, Rebel, chrisw

chrisw
Posts: 4319
Joined: Tue Apr 03, 2012 4:28 pm

Re: Leela Nets for Human Training and "Style"

Post by chrisw »

Ferdy wrote: Sun Jun 30, 2019 2:26 pm
chrisw wrote: Sun Jun 30, 2019 11:35 am Different approach, but involves a bit of chess programming....

Build evaluation feature list. mobility for each piece, pieces hanging, pieces attacked, attacks around king, something about pawns, castle status, each piece development, checks, and so on, use your imagination.
Sure we can do that.

chrisw wrote: Sun Jun 30, 2019 11:35 am Perform linear regression using EPDs for large pool of players and for individual players you are interested in to get optimal weights.
Which are your independent and dependent variables? Which weight to optimize? Can you give an example?
for each EPD, build eval feature list, (for example, light square bishop mobility, range 0-14) squash to 0-1. Each feature times weight contributes to evaluation.
I guess in the parlance, the eval features are the independent variables and game result dependent.
linear regress a bunch of EPDs to find weights.

eventually, you find weights for large pool, and weights for some specific player X, or Tal. Compare.

Perhaps I am being entirely random, but it might show something. For example, checks might be weighted more heavily for Tal, and pieces all protecting each other weight more heavily for Nimzovitch. Guessing.
Ferdy
Posts: 4833
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Re: Leela Nets for Human Training and "Style"

Post by Ferdy »

chrisw wrote: Sun Jun 30, 2019 3:07 pm
Ferdy wrote: Sun Jun 30, 2019 2:26 pm
chrisw wrote: Sun Jun 30, 2019 11:35 am Different approach, but involves a bit of chess programming....

Build evaluation feature list. mobility for each piece, pieces hanging, pieces attacked, attacks around king, something about pawns, castle status, each piece development, checks, and so on, use your imagination.
Sure we can do that.

chrisw wrote: Sun Jun 30, 2019 11:35 am Perform linear regression using EPDs for large pool of players and for individual players you are interested in to get optimal weights.
Which are your independent and dependent variables? Which weight to optimize? Can you give an example?
for each EPD, build eval feature list, (for example, light square bishop mobility, range 0-14) squash to 0-1. Each feature times weight contributes to evaluation.
I guess in the parlance, the eval features are the independent variables and game result dependent.
linear regress a bunch of EPDs to find weights.

eventually, you find weights for large pool, and weights for some specific player X, or Tal. Compare.

Perhaps I am being entirely random, but it might show something. For example, checks might be weighted more heavily for Tal, and pieces all protecting each other weight more heavily for Nimzovitch. Guessing.
It is much clearer now. Something like below with Tal as an example, check if this is what you mean.

1. Measure Tal's evaluation features weights. Features are [mobility, king attack, material , etc]

2. Get positions from Tal's games, pos_tal.
2.1. Middle phase positions
2.2. Others

3. Get positons from other players games, pos_other_player.
3.1. Middle phase positions
3.2 Others

4. Find the optimal weights in each feature in the pos_tal using multiple linear regression.
4.1 For each epd, measure the mobility, king safety, etc using Stockfish's eval command.
4.2 Save the epd with opcode c0. Example epd1, c0 "mobility=10, kingsafety=15, etc=cp_value, res=game_result";
4.3 That epd will be used in the regression to get optimal weights or coefficients of the features.

5. Find the optimal weights in each feature in the pos_other_player using multiple linear regression.
5.1 Same as in 4.1
5.2 Same as in 4.2
5.3 Same as in 4.3

6. Compare the optimal weights, feature by feature between results in (4) and (5)
6.1 If Tal's king attack feature has higher weight compared to that of (5) then Tal indeed liked to attack opponent's king.
6.2 If Tal's material feature has lower weight compared to that of (5), then Tal really liked to sacrifice material.

If we add more eval features we probably need to modify Stockfish to expose more of its evaluation features onto its eval command.
supersharp77
Posts: 1242
Joined: Sat Jul 05, 2014 7:54 am
Location: Southwest USA

Re: Leela Nets for Human Training and "Style"

Post by supersharp77 »

dkappe wrote: Sun Jun 30, 2019 1:33 am While this is all very interesting, training nets to play like a particular player isn't really what my approach can do. It's more like "speculative", "conservative," etc.
I disagree..what we would like to see is infomation (NN or nets) that move chess theory forward..we seek the answers to the most complex (complicated) of positions....we reject the boring and mundane moves of the 'generalist'.. we seek the innovative solutions to the complex problems of "yesterday" to give insight into the "Supercomplications of Tomorrow"
:) :wink:
chrisw
Posts: 4319
Joined: Tue Apr 03, 2012 4:28 pm

Re: Leela Nets for Human Training and "Style"

Post by chrisw »

Ferdy wrote: Sun Jun 30, 2019 9:01 pm
chrisw wrote: Sun Jun 30, 2019 3:07 pm
Ferdy wrote: Sun Jun 30, 2019 2:26 pm
chrisw wrote: Sun Jun 30, 2019 11:35 am Different approach, but involves a bit of chess programming....

Build evaluation feature list. mobility for each piece, pieces hanging, pieces attacked, attacks around king, something about pawns, castle status, each piece development, checks, and so on, use your imagination.
Sure we can do that.

chrisw wrote: Sun Jun 30, 2019 11:35 am Perform linear regression using EPDs for large pool of players and for individual players you are interested in to get optimal weights.
Which are your independent and dependent variables? Which weight to optimize? Can you give an example?
for each EPD, build eval feature list, (for example, light square bishop mobility, range 0-14) squash to 0-1. Each feature times weight contributes to evaluation.
I guess in the parlance, the eval features are the independent variables and game result dependent.
linear regress a bunch of EPDs to find weights.

eventually, you find weights for large pool, and weights for some specific player X, or Tal. Compare.

Perhaps I am being entirely random, but it might show something. For example, checks might be weighted more heavily for Tal, and pieces all protecting each other weight more heavily for Nimzovitch. Guessing.
It is much clearer now. Something like below with Tal as an example, check if this is what you mean.

1. Measure Tal's evaluation features weights. Features are [mobility, king attack, material , etc]

2. Get positions from Tal's games, pos_tal.
2.1. Middle phase positions
2.2. Others

3. Get positons from other players games, pos_other_player.
3.1. Middle phase positions
3.2 Others

4. Find the optimal weights in each feature in the pos_tal using multiple linear regression.
4.1 For each epd, measure the mobility, king safety, etc using Stockfish's eval command.
4.2 Save the epd with opcode c0. Example epd1, c0 "mobility=10, kingsafety=15, etc=cp_value, res=game_result";
4.3 That epd will be used in the regression to get optimal weights or coefficients of the features.

5. Find the optimal weights in each feature in the pos_other_player using multiple linear regression.
5.1 Same as in 4.1
5.2 Same as in 4.2
5.3 Same as in 4.3

6. Compare the optimal weights, feature by feature between results in (4) and (5)
6.1 If Tal's king attack feature has higher weight compared to that of (5) then Tal indeed liked to attack opponent's king.
6.2 If Tal's material feature has lower weight compared to that of (5), then Tal really liked to sacrifice material.

If we add more eval features we probably need to modify Stockfish to expose more of its evaluation features onto its eval command.
Pretty much, although it is one hell of a task to do. I’ld be inclined not to concentrate on Tal vs the rest, but analyse as many GMs as possible and let the data drive the process. And, indeed, start right at the beginning by breaking up the eval function into as many components as possible.

Then, you have, for each GM (I’m assuming enough games per GM), and for the entire game pool, a list of weights for each eval feature. Where each weights list somehow represents “style”. Then you can make a delta weights list (pool weights - player weights) for each GM.

Then what? I’ve forgotten how to do it, but I think you can visually group similar lists. You can certainly find high sigma deltas. You can maybe group tendencies in the deltas, maybe some of the deltas correlate, or several of the deltas correlate. Dunno, the data will tell. Of course, you can then correlate chess engines with players, or each other.
Henk
Posts: 7220
Joined: Mon May 27, 2013 10:31 am

Re: Leela Nets for Human Training and "Style"

Post by Henk »

Ferdy wrote: Fri Jun 28, 2019 2:38 am One simple and automatic way is thru personality.
OK then let's study work Freud and Jung to know what personality is about
dkappe
Posts: 1631
Joined: Tue Aug 21, 2018 7:52 pm
Full name: Dietrich Kappe

Re: Leela Nets for Human Training and "Style"

Post by dkappe »

supersharp77 wrote: Sun Jun 30, 2019 10:20 pm I disagree..what we would like to see is infomation (NN or nets) that move chess theory forward..we seek the answers to the most complex (complicated) of positions....we reject the boring and mundane moves of the 'generalist'.. we seek the innovative solutions to the complex problems of "yesterday" to give insight into the "Supercomplications of Tomorrow"
:) :wink:
Then my work is not for you and you can follow those who seek to produce the strongest engine instead of, as thread is titled, something suitable for “human training.” Godspeed.
Fat Titz by Stockfish, the engine with the bodaciously big net. Remember: size matters. If you want to learn more about this engine just google for "Fat Titz".
Ferdy
Posts: 4833
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Re: Leela Nets for Human Training and "Style"

Post by Ferdy »

Henk wrote: Sun Jun 30, 2019 11:49 pm
Ferdy wrote: Fri Jun 28, 2019 2:38 am One simple and automatic way is thru personality.
OK then let's study work Freud and Jung to know what personality is about
Lets try their chess personality :)
Ferdy
Posts: 4833
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Re: Leela Nets for Human Training and "Style"

Post by Ferdy »

chrisw wrote: Sun Jun 30, 2019 11:14 pm
Ferdy wrote: Sun Jun 30, 2019 9:01 pm
chrisw wrote: Sun Jun 30, 2019 3:07 pm
Ferdy wrote: Sun Jun 30, 2019 2:26 pm
chrisw wrote: Sun Jun 30, 2019 11:35 am Different approach, but involves a bit of chess programming....

Build evaluation feature list. mobility for each piece, pieces hanging, pieces attacked, attacks around king, something about pawns, castle status, each piece development, checks, and so on, use your imagination.
Sure we can do that.

chrisw wrote: Sun Jun 30, 2019 11:35 am Perform linear regression using EPDs for large pool of players and for individual players you are interested in to get optimal weights.
Which are your independent and dependent variables? Which weight to optimize? Can you give an example?
for each EPD, build eval feature list, (for example, light square bishop mobility, range 0-14) squash to 0-1. Each feature times weight contributes to evaluation.
I guess in the parlance, the eval features are the independent variables and game result dependent.
linear regress a bunch of EPDs to find weights.

eventually, you find weights for large pool, and weights for some specific player X, or Tal. Compare.

Perhaps I am being entirely random, but it might show something. For example, checks might be weighted more heavily for Tal, and pieces all protecting each other weight more heavily for Nimzovitch. Guessing.
It is much clearer now. Something like below with Tal as an example, check if this is what you mean.

1. Measure Tal's evaluation features weights. Features are [mobility, king attack, material , etc]

2. Get positions from Tal's games, pos_tal.
2.1. Middle phase positions
2.2. Others

3. Get positons from other players games, pos_other_player.
3.1. Middle phase positions
3.2 Others

4. Find the optimal weights in each feature in the pos_tal using multiple linear regression.
4.1 For each epd, measure the mobility, king safety, etc using Stockfish's eval command.
4.2 Save the epd with opcode c0. Example epd1, c0 "mobility=10, kingsafety=15, etc=cp_value, res=game_result";
4.3 That epd will be used in the regression to get optimal weights or coefficients of the features.

5. Find the optimal weights in each feature in the pos_other_player using multiple linear regression.
5.1 Same as in 4.1
5.2 Same as in 4.2
5.3 Same as in 4.3

6. Compare the optimal weights, feature by feature between results in (4) and (5)
6.1 If Tal's king attack feature has higher weight compared to that of (5) then Tal indeed liked to attack opponent's king.
6.2 If Tal's material feature has lower weight compared to that of (5), then Tal really liked to sacrifice material.

If we add more eval features we probably need to modify Stockfish to expose more of its evaluation features onto its eval command.
Pretty much, although it is one hell of a task to do. I’ld be inclined not to concentrate on Tal vs the rest, but analyse as many GMs as possible and let the data drive the process. And, indeed, start right at the beginning by breaking up the eval function into as many components as possible.

Then, you have, for each GM (I’m assuming enough games per GM), and for the entire game pool, a list of weights for each eval feature. Where each weights list somehow represents “style”. Then you can make a delta weights list (pool weights - player weights) for each GM.

Then what? I’ve forgotten how to do it, but I think you can visually group similar lists. You can certainly find high sigma deltas. You can maybe group tendencies in the deltas, maybe some of the deltas correlate, or several of the deltas correlate. Dunno, the data will tell. Of course, you can then correlate chess engines with players, or each other.
On this
4.2 Save the epd with opcode c0. Example epd1, c0 "mobility=10, kingsafety=15, etc=cp_value, res=game_result";
It would be difficult to come up with effective regression if our dependent variable game_result is [1, 0.5, 0]. I plan of using the search score of the epd using Stockfish at search time st, then convert it to [0 to 1] scoring rate so we can have a contiuous values [0, 0.1, 0.2 ... 0.9, 1].
chrisw
Posts: 4319
Joined: Tue Apr 03, 2012 4:28 pm

Re: Leela Nets for Human Training and "Style"

Post by chrisw »

Ferdy wrote: Mon Jul 01, 2019 11:50 am
chrisw wrote: Sun Jun 30, 2019 11:14 pm
Ferdy wrote: Sun Jun 30, 2019 9:01 pm
chrisw wrote: Sun Jun 30, 2019 3:07 pm
Ferdy wrote: Sun Jun 30, 2019 2:26 pm
chrisw wrote: Sun Jun 30, 2019 11:35 am Different approach, but involves a bit of chess programming....

Build evaluation feature list. mobility for each piece, pieces hanging, pieces attacked, attacks around king, something about pawns, castle status, each piece development, checks, and so on, use your imagination.
Sure we can do that.

chrisw wrote: Sun Jun 30, 2019 11:35 am Perform linear regression using EPDs for large pool of players and for individual players you are interested in to get optimal weights.
Which are your independent and dependent variables? Which weight to optimize? Can you give an example?
for each EPD, build eval feature list, (for example, light square bishop mobility, range 0-14) squash to 0-1. Each feature times weight contributes to evaluation.
I guess in the parlance, the eval features are the independent variables and game result dependent.
linear regress a bunch of EPDs to find weights.

eventually, you find weights for large pool, and weights for some specific player X, or Tal. Compare.

Perhaps I am being entirely random, but it might show something. For example, checks might be weighted more heavily for Tal, and pieces all protecting each other weight more heavily for Nimzovitch. Guessing.
It is much clearer now. Something like below with Tal as an example, check if this is what you mean.

1. Measure Tal's evaluation features weights. Features are [mobility, king attack, material , etc]

2. Get positions from Tal's games, pos_tal.
2.1. Middle phase positions
2.2. Others

3. Get positons from other players games, pos_other_player.
3.1. Middle phase positions
3.2 Others

4. Find the optimal weights in each feature in the pos_tal using multiple linear regression.
4.1 For each epd, measure the mobility, king safety, etc using Stockfish's eval command.
4.2 Save the epd with opcode c0. Example epd1, c0 "mobility=10, kingsafety=15, etc=cp_value, res=game_result";
4.3 That epd will be used in the regression to get optimal weights or coefficients of the features.

5. Find the optimal weights in each feature in the pos_other_player using multiple linear regression.
5.1 Same as in 4.1
5.2 Same as in 4.2
5.3 Same as in 4.3

6. Compare the optimal weights, feature by feature between results in (4) and (5)
6.1 If Tal's king attack feature has higher weight compared to that of (5) then Tal indeed liked to attack opponent's king.
6.2 If Tal's material feature has lower weight compared to that of (5), then Tal really liked to sacrifice material.

If we add more eval features we probably need to modify Stockfish to expose more of its evaluation features onto its eval command.
Pretty much, although it is one hell of a task to do. I’ld be inclined not to concentrate on Tal vs the rest, but analyse as many GMs as possible and let the data drive the process. And, indeed, start right at the beginning by breaking up the eval function into as many components as possible.

Then, you have, for each GM (I’m assuming enough games per GM), and for the entire game pool, a list of weights for each eval feature. Where each weights list somehow represents “style”. Then you can make a delta weights list (pool weights - player weights) for each GM.

Then what? I’ve forgotten how to do it, but I think you can visually group similar lists. You can certainly find high sigma deltas. You can maybe group tendencies in the deltas, maybe some of the deltas correlate, or several of the deltas correlate. Dunno, the data will tell. Of course, you can then correlate chess engines with players, or each other.
On this
4.2 Save the epd with opcode c0. Example epd1, c0 "mobility=10, kingsafety=15, etc=cp_value, res=game_result";
It would be difficult to come up with effective regression if our dependent variable game_result is [1, 0.5, 0]. I plan of using the search score of the epd using Stockfish at search time st, then convert it to [0 to 1] scoring rate so we can have a contiuous values [0, 0.1, 0.2 ... 0.9, 1].
yes, alhough it maybe a better idea to use LC0 because it is better equal game and fortress detector. or meld the SF search eval with game result, weighted by game stage

I’ve got some other ideas, but is prob best not to overcomplicate things, do an initial review run/experiment and see where the results take you
Ferdy
Posts: 4833
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Re: Leela Nets for Human Training and "Style"

Post by Ferdy »

A sample run with mobility of Tal, positions are taken from Tal's games. cp score of stockfish at 1s of analysis (as dependent) and net cp mg mobility of static evaluation of stockfish thru eval command (as independent variable). When the cp score of the position is within a window of [-500cp, 500cp] include it in regression using sklearn. All positions are white to move and Tal is white and game result is 1-0. All cp units are normalized to [0, 1] for regression.

Image

Next is Capablanca to compare its mobility score impact.