Eval parameters tuning

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

Moderators: hgm, Rebel, chrisw

Rentib
Posts: 6
Joined: Sun Jul 28, 2024 1:41 am
Full name: Stanislaw Bitner

Eval parameters tuning

Post by Rentib »

I was wandering whether somebody has already done something like this:
Let's say we want to create an engine with HCE which will aim to be as strong as some other engine.
We assume that the other engine has a perfect evaluation function.
Then we can create a data set for some OLS model.

We chose some parameters that the eval would consider. Then we have 2 sets of those parameters: 1 for middle game and 1 for endgame, let's call those vectors b1 and b2. Then we collect the evaluation scores and independent variables from multiple positions.

For example we could take a position with eval=32 centipawns where there are: backward pawn, passed pawn on 6th rank and so on (just collect observations).

Then we try to optimize this function derived from https://www.chessprogramming.org/Tapered_Eval.

eval = (((x^T * b1) * (256 - phase)) + ((x^T * b2) * phase)) / 256
256 * eval = x^T * (b1 * (256 - phase) + b2 * phase)

Where eval is evaluation score of the strong engine, x is a vector of observations, b1 is a vector of middle game parameters, b2 is a vector of end game parameters and x^T is the transpose of vector x.

We can collect A LOT of those and then use ordinary least squares method to optimize the b1 and b2 vectors.

Is it completely stupid and there is no point in doing this or is this a fine method which I just somehow missed?
This could also be used to somehow understand neural networks better as we could for example get to know which parameters have bigger weights and so on.
AndrewGrant
Posts: 1847
Joined: Tue Apr 19, 2016 6:08 am
Location: U.S.A
Full name: Andrew Grant

Re: Eval parameters tuning

Post by AndrewGrant »

I've done something exactly like this this, many years ago, and many others have replicated it, in the HCE days. you don't really define what you're optimizing towards. In the usual case, its game result, or trying to make an eval look more like a depth X search.

See: https://github.com/AndyGrant/Ethereal/b ... Tuning.pdf
Friendly reminder that stealing is a crime, is wrong, and makes you a thief.
"Those who can't do, clone instead" - Eduard ( A real life friend, not this forum's Eduard )
Viz
Posts: 168
Joined: Tue Apr 09, 2024 6:24 am
Full name: Michael Chaly

Re: Eval parameters tuning

Post by Viz »

Or you also can do SPSA as a bonus, it's also reasonably effective.
Rentib
Posts: 6
Joined: Sun Jul 28, 2024 1:41 am
Full name: Stanislaw Bitner

Re: Eval parameters tuning

Post by Rentib »

AndrewGrant wrote: Tue Jul 30, 2024 5:21 am I've done something exactly like this this, many years ago, and many others have replicated it, in the HCE days. you don't really define what you're optimizing towards. In the usual case, its game result, or trying to make an eval look more like a depth X search.

See: https://github.com/AndyGrant/Ethereal/b ... Tuning.pdf
Thank you very much, especially for pointing me to this paper. Though from what I see what is described there is a method of tuning an engine against itself, just using evaluation from search instead.
My idea was to tune against another engine's evaluation function. It should be much quicker to gain elo this way as compared to tuning against the one's self, assuming that the other engine is much stronger.

So instead of doing a search to get a more precise evaluation of the position, we could use for example the evaluation from NNUE.