llama-cpp-python icon indicating copy to clipboard operation
llama-cpp-python copied to clipboard

Setting seed to -1 (random) or using default LLAMA_DEFAULT_SEED generates a deterministic reply chain

Open m-from-space opened this issue 1 year ago • 3 comments

INB4 This is not about setting Top-P to 1.0 which causes the same output every time for every same prompt, documented here: https://github.com/abetlen/llama-cpp-python/issues/1797

When loading a model with release 0.3.1 and set the seed to either -1 (random) or leave the default (which is supposed to use a RNG according to the docs), the first reply of a model will always be the same for the same prompt. Consecutive replies for the same prompt will be different, but the chain will stay the same for each time loading the model and repeating the steps.

This points towards the seed not being randomized on load.

What I expect and what worked earlier: Loading a model with a random seed will generate a different first reply for the same prompt.

The issue is not present in version llama-cpp-python==0.2.90

m-from-space avatar Oct 24 '24 10:10 m-from-space

Problem is still present in llama-cpp-python==0.3.2

m-from-space avatar Nov 17 '24 16:11 m-from-space

Unfortunately the problem persists using version llama-cpp-python==0.3.9

Could this be an issue with llama.cpp itself? Shouldn't there be an easy fix, since it only seems to about the seed not being randomized as stated?

m-from-space avatar May 12 '25 16:05 m-from-space

Still an issue in version 0.3.12.

Please randomize the initial seed! 🥲

m-from-space avatar Jul 12 '25 12:07 m-from-space