From b8c8dda75fdf5fdea49c80af36818e7c30fe0ddf Mon Sep 17 00:00:00 2001 From: Howard Su Date: Thu, 29 Jun 2023 21:15:15 +0800 Subject: Use unsigned for random seed (#2006) * Use unsigned for random seed. Keep -1 as the value to use a time based seed. Co-authored-by: Georgi Gerganov --- examples/main/README.md | 2 +- examples/main/main.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'examples/main') diff --git a/examples/main/README.md b/examples/main/README.md index 9ba1eb3..3753861 100644 --- a/examples/main/README.md +++ b/examples/main/README.md @@ -242,7 +242,7 @@ Example usage: `--logit-bias 29905-inf` ### RNG Seed -- `-s SEED, --seed SEED`: Set the random number generator (RNG) seed (default: -1, < 0 = random seed). +- `-s SEED, --seed SEED`: Set the random number generator (RNG) seed (default: -1, -1 = random seed). The RNG seed is used to initialize the random number generator that influences the text generation process. By setting a specific seed value, you can obtain consistent and reproducible results across multiple runs with the same input and settings. This can be helpful for testing, debugging, or comparing the effects of different options on the generated text to see when they diverge. If the seed is set to a value less than 0, a random seed will be used, which will result in different outputs on each run. diff --git a/examples/main/main.cpp b/examples/main/main.cpp index bcdc98d..3a17192 100644 --- a/examples/main/main.cpp +++ b/examples/main/main.cpp @@ -94,11 +94,11 @@ int main(int argc, char ** argv) { fprintf(stderr, "%s: build = %d (%s)\n", __func__, BUILD_NUMBER, BUILD_COMMIT); - if (params.seed < 0) { + if (params.seed == LLAMA_DEFAULT_SEED) { params.seed = time(NULL); } - fprintf(stderr, "%s: seed = %d\n", __func__, params.seed); + fprintf(stderr, "%s: seed = %u\n", __func__, params.seed); std::mt19937 rng(params.seed); if (params.random_prompt) { -- cgit v1.2.3