From 76c73987bfee43e922ed384eeea4d7d0e7817412 Mon Sep 17 00:00:00 2001 From: KerfuffleV2 Date: Wed, 24 May 2023 02:55:30 -0600 Subject: [PATCH] Use the initial value of params.seed to determine if user supplied seed Display some helpful information to the user when loading a session to make it clear when the seed applies or not. --- examples/main/main.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/main/main.cpp b/examples/main/main.cpp index 868dc03a2..eeb20162a 100644 --- a/examples/main/main.cpp +++ b/examples/main/main.cpp @@ -85,6 +85,9 @@ int main(int argc, char ** argv) { fprintf(stderr, "%s: build = %d (%s)\n", __func__, BUILD_NUMBER, BUILD_COMMIT); + // Save the initial seed parameter before overwriting it so it's possible to determine whether + // the user supplied a seed or not. This is useful when loading saved sessions. + int32_t initial_seed = params.seed; if (params.seed < 0) { params.seed = time(NULL); } @@ -153,8 +156,11 @@ int main(int argc, char ** argv) { return 1; } session_tokens.resize(n_token_count_out); - if (params.seed != -1) { + if (initial_seed != -1) { + fprintf(stderr, "%s: seed argument overrides session file RNG state, will now use seed: %d\n", __func__, params.seed); llama_set_rng_seed(ctx, params.seed); + } else { + fprintf(stderr, "%s: using RNG state from loaded session file rather than seed\n", __func__); } fprintf(stderr, "%s: loaded a session with prompt size of %d tokens\n", __func__, (int) session_tokens.size());