Skip to content

Commit

Permalink
Change data generation default parameters
Browse files Browse the repository at this point in the history
Set defaults to reasonable values and document them.
  • Loading branch information
ianfab committed Sep 15, 2024
1 parent ed0eafd commit 9c5c2be
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
16 changes: 8 additions & 8 deletions docs/generate_training_data.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ Currently the following options are available:

`nodes` - the number of nodes to use for evaluation of each position. This number is multiplied by the number of PVs of the current search. This does NOT override the `depth` and `depth2` options. If specified then whichever of depth or nodes limit is reached first applies.

`count` - the number of training data entries to generate. 1 entry == 1 position. Default: 8000000000 (8B).
`count` - the number of training data entries to generate. 1 entry == 1 position. Default: 100000000 (100M).

`output_file_name` - the name of the file to output to. If the extension is not present or doesn't match the selected training data format the right extension will be appended. Default: generated_kifu
`output_file_name` - the name of the file to output to. If the extension is not present or doesn't match the selected training data format the right extension will be appended. Default: training_data

`eval_limit` - evaluations with higher absolute value than this will not be written and will terminate a self-play game. Should not exceed 10000 which is VALUE_KNOWN_WIN, but is only hardcapped at mate in 2 (\~30000). Default: 3000

Expand All @@ -36,28 +36,28 @@ Currently the following options are available:

`random_move_like_apery` - either 0 or 1. If 1 then random king moves will be followed by a random king move from the opponent whenever possible with 50% probability. Default: 0.

`random_multi_pv` - the number of PVs used for determining the random move. If not specified then a truly random move will be chosen. If specified then a multiPV search will be performed the random move will be one of the moves chosen by the search.
`random_multi_pv` - the number of PVs used for determining the random move. If zero then a truly random move will be chosen. If non-zero then a multiPV search will be performed the random move will be one of the moves chosen by the search.

`random_multi_pv_diff` - Makes the multiPV random move selection consider only moves that are at most `random_multi_pv_diff` worse than the next best move. Default: 30000 (all multiPV moves).
`random_multi_pv_diff` - Makes the multiPV random move selection consider only moves that are at most `random_multi_pv_diff` worse than the next best move. Default: 100.

`random_multi_pv_depth` - the depth to use for multiPV search for random move. Default: `depth2`.

`write_min_ply` - minimum ply for which the training data entry will be emitted. Default: 16.
`write_min_ply` - minimum ply for which the training data entry will be emitted. Default: 5.

`write_max_ply` - maximum ply for which the training data entry will be emitted. Default: 400.

`book` - a path to an opening book to use for the starting positions. Currently only .epd format is supported. If not specified then the starting position is always the standard chess starting position.
`book` - a path to an opening book to use for the starting positions. Currently only .epd format is supported. If not specified then the starting position is always the variant starting position.

`save_every` - the number of training data entries per file. If not specified then there will be always one file. If specified there may be more than one file generated (each having at most `save_every` training data entries) and each file will have a unique number attached.

`random_file_name` - if specified then the output filename will be chosen randomly. Overrides `output_file_name`.

`keep_draws` - either 0 or 1. If 1 then training data from drawn games will be emitted too. Default: 1.
`keep_draws` - between 0 and 1. Limit on fraction of drawn games that will be emitted. Default: 1.

`adjudicate_draws_by_score` - either 0 or 1. If 1 then drawn games will be adjudicated when the score remains 0 for at least 8 plies after ply 80. Default: 1.

`adjudicate_draws_by_insufficient_mating_material` - either 0 or 1. If 1 then position with insufficient material will be adjudicated as draws. Default: 1.

`data_format` - format of the training data to use. Either `bin` or `binpack`. Default: `binpack`.
`data_format` - format of the training data to use. Either `bin` or `binpack`. Default: `bin`.

`seed` - seed for the PRNG. Can be either a number or a string. If it's a string then its hash will be used. If not specified then the current time will be used.
18 changes: 8 additions & 10 deletions src/tools/training_data_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ namespace Stockfish::Tools

// Upper limit of evaluation value of generated situation
int eval_limit = 3000;
int eval_diff_limit = 500;
int eval_diff_limit = 64000;

// minimum ply with random move
// maximum ply with random move
Expand All @@ -75,27 +75,27 @@ namespace Stockfish::Tools
// and the evaluation value of the move of the Nth place is.
// Must be in the range random_multi_pv_diff.
// random_multi_pv_depth is the search depth for MultiPV.
int random_multi_pv = 0;
int random_multi_pv_diff = 32000;
int random_multi_pv = 5;
int random_multi_pv_diff = 100;
int random_multi_pv_depth = -1;

// The minimum and maximum ply (number of steps from
// the initial phase) of the sfens to write out.
int write_minply = 16;
int write_minply = 5;
int write_maxply = 400;

uint64_t save_every = std::numeric_limits<uint64_t>::max();

std::string output_file_name = "training_data";

SfenOutputType sfen_format = SfenOutputType::Binpack;
SfenOutputType sfen_format = SfenOutputType::Bin;

std::string seed;

float write_out_draw_game_in_training_data_generation = 1;
bool detect_draw_by_consecutive_low_score = true;
bool detect_draw_by_insufficient_mating_material = true;
bool filter_captures = false;
bool filter_captures = true;
bool filter_checks = false;
bool filter_promotions = false;

Expand Down Expand Up @@ -749,13 +749,13 @@ namespace Stockfish::Tools
void generate_training_data(istringstream& is)
{
// Number of generated game records default = 8 billion phases (Ponanza specification)
uint64_t loop_max = 8000000000UL;
uint64_t loop_max = 100000000UL;

TrainingDataGenerator::Params params;

// Add a random number to the end of the file name.
bool random_file_name = false;
std::string sfen_format = "binpack";
std::string sfen_format = "bin";

string token;
while (true)
Expand Down Expand Up @@ -844,8 +844,6 @@ namespace Stockfish::Tools
{
if (sfen_format == "bin")
params.sfen_format = SfenOutputType::Bin;
else if (sfen_format == "binpack")
params.sfen_format = SfenOutputType::Binpack;
else
cout << "WARNING: Unknown sfen format `" << sfen_format << "`. Using bin\n";
}
Expand Down

0 comments on commit 9c5c2be

Please sign in to comment.