aboutsummaryrefslogtreecommitdiff
path: root/examples/main
diff options
context:
space:
mode:
authorHoward Su <howard0su@gmail.com>2023-06-29 21:15:15 +0800
committerGitHub <noreply@github.com>2023-06-29 06:15:15 -0700
commitb8c8dda75fdf5fdea49c80af36818e7c30fe0ddf (patch)
tree85107b89339fe14e31b33703d6dcf440664695ca /examples/main
parent96a712ca1b7f427e3bd7ffc0c70b2105cfc7fbf1 (diff)
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 <ggerganov@gmail.com>
Diffstat (limited to 'examples/main')
-rw-r--r--examples/main/README.md2
-rw-r--r--examples/main/main.cpp4
2 files changed, 3 insertions, 3 deletions
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) {