diff --git a/src/llama-sampling.cpp b/src/llama-sampling.cpp index 444a62254..fd1b7f919 100644 --- a/src/llama-sampling.cpp +++ b/src/llama-sampling.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -164,6 +165,11 @@ static void llama_sampler_top_k_impl(llama_token_data_array * cur_p, int32_t k) static uint32_t get_rng_seed(uint32_t seed) { if (seed == LLAMA_DEFAULT_SEED) { + // use system clock if std::random_device is not a true RNG + static bool is_rd_prng = std::random_device().entropy() == 0; + if (is_rd_prng) { + return (uint32_t) std::chrono::system_clock::now().time_since_epoch().count(); + } std::random_device rd; return rd(); }