Skip to content

Actually create a random seed when using seed = -1 on load #2042

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion llama_cpp/llama.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,11 @@ def __init__(
self.n_threads_batch = n_threads_batch or multiprocessing.cpu_count()

# Used by the sampler
self._seed = seed or llama_cpp.LLAMA_DEFAULT_SEED
if seed == -1:
# set a random seed
self._seed = random.randint(0, 2 ** 32)
else:
self._seed = seed or llama_cpp.LLAMA_DEFAULT_SEED

# Context Params
self.context_params = llama_cpp.llama_context_default_params()
Expand Down