[GH-ISSUE #2773] Random Seed Parameter #1670

Closed
opened 2026-04-12 11:38:27 -05:00 by GiteaMirror · 4 comments
Owner

Originally created by @dwrout on GitHub (Feb 27, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/2773

Originally assigned to: @jmorganca on GitHub.

Currently, the Ollama "seed" parameter is set as a fixed preset number that remains constant throughout an interaction unless changed manually by the user or API. I propose an enhancement allowing this seed parameter to be random as a preset option. This could add more variability and unpredictability to the chat responses. Because the seed parameter is a positive integer, using a negative number could invoke the random function.

Here are some thoughts on implementing this feature:

  1. Allow users to set "-1" as a seed parameter so that each new chat started uses a new random number as the seed parameter for the duration of the session.
  2. Allow users to set "-2" as a seed parameter so that each new chat response within a chat session uses a new random number as the seed parameter.
  3. Allow users to set "-3" as a seed parameter to generate and automatically use unique seeds based on specific conditions, such as asking the same question again.
Originally created by @dwrout on GitHub (Feb 27, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/2773 Originally assigned to: @jmorganca on GitHub. Currently, the Ollama "seed" parameter is set as a fixed preset number that remains constant throughout an interaction unless changed manually by the user or API. I propose an enhancement allowing this seed parameter to be random as a preset option. This could add more variability and unpredictability to the chat responses. Because the seed parameter is a positive integer, using a negative number could invoke the random function. Here are some thoughts on implementing this feature: 1. Allow users to set "-1" as a seed parameter so that each new chat started uses a new random number as the seed parameter for the duration of the session. 2. Allow users to set "-2" as a seed parameter so that each new chat response within a chat session uses a new random number as the seed parameter. 3. Allow users to set "-3" as a seed parameter to generate and automatically use unique seeds based on specific conditions, such as asking the same question again.
GiteaMirror added the bug label 2026-04-12 11:38:27 -05:00
Author
Owner

@Crytoma commented on GitHub (Apr 19, 2024):

Hear hear!

<!-- gh-comment-id:2066901984 --> @Crytoma commented on GitHub (Apr 19, 2024): Hear hear!
Author
Owner

@spergware commented on GitHub (May 3, 2024):

+1

<!-- gh-comment-id:2093287189 --> @spergware commented on GitHub (May 3, 2024): +1
Author
Owner

@jmorganca commented on GitHub (Jun 11, 2024):

Hi folks, this should be fixed in https://github.com/ollama/ollama/pull/4986. Thanks so much for creating an issue.

RE 1-3 above, you should be able to do this via the seed parameter sent with each request – generally the Ollama API tries to be "stateless" and the client can send the seed. Let me know if that helps!

<!-- gh-comment-id:2161577916 --> @jmorganca commented on GitHub (Jun 11, 2024): Hi folks, this should be fixed in https://github.com/ollama/ollama/pull/4986. Thanks so much for creating an issue. RE 1-3 above, you should be able to do this via the `seed` parameter sent with each request – generally the Ollama API tries to be "stateless" and the client can send the `seed`. Let me know if that helps!
Author
Owner

@cirosantilli commented on GitHub (Mar 10, 2025):

Hi folks, this should be fixed in #4986. Thanks so much for creating an issue.

RE 1-3 above, you should be able to do this via the seed parameter sent with each request – generally the Ollama API tries to be "stateless" and the client can send the seed. Let me know if that helps!

How to set the seed from CLI? I had a look at: https://github.com/ollama/ollama/issues/2505 and naively tried:

/bin/time ollama run llama2 '/set parameter seed 0' 'What is quantum field theory?'

but it didn't seem to work.

Edit: OK it seems you can't set parameters from CLI yet https://github.com/ollama/ollama/issues/2505#issuecomment-2733425744 but we can expect it for now:

#!/usr/bin/expect -f
set prompt ">>> "
spawn ollama run llama3.2
expect $prompt
send "/set parameter seed 0\r"
expect $prompt
send "/set parameter num_predict 20\r"
expect $prompt
send "What is quantum field theory?\r"
expect $prompt
send -- "/bye"
<!-- gh-comment-id:2710957152 --> @cirosantilli commented on GitHub (Mar 10, 2025): > Hi folks, this should be fixed in [#4986](https://github.com/ollama/ollama/pull/4986). Thanks so much for creating an issue. > > RE 1-3 above, you should be able to do this via the `seed` parameter sent with each request – generally the Ollama API tries to be "stateless" and the client can send the `seed`. Let me know if that helps! How to set the seed from CLI? I had a look at: https://github.com/ollama/ollama/issues/2505 and naively tried: ``` /bin/time ollama run llama2 '/set parameter seed 0' 'What is quantum field theory?' ``` but it didn't seem to work. Edit: OK it seems you can't set parameters from CLI yet https://github.com/ollama/ollama/issues/2505#issuecomment-2733425744 but we can `expect` it for now: ``` #!/usr/bin/expect -f set prompt ">>> " spawn ollama run llama3.2 expect $prompt send "/set parameter seed 0\r" expect $prompt send "/set parameter num_predict 20\r" expect $prompt send "What is quantum field theory?\r" expect $prompt send -- "/bye" ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#1670