Use deterministic ollama settings (#250)

* deterministic ollama settings

* add missing file
This commit is contained in:
Sebastian Raschka
2024-06-27 07:16:48 -05:00
committed by GitHub
parent 1db1999951
commit e296e8f6be
3 changed files with 104 additions and 135 deletions

View File

@@ -15,11 +15,14 @@ def query_model(prompt, model="llama3", url="http://localhost:11434/api/chat"):
# Create the data payload as a dictionary
data = {
"model": model,
"seed": 123, # for deterministic responses
"temperature": 0, # for deterministic responses
"messages": [
{"role": "user", "content": prompt}
]
],
"options": { # Settings below are required for deterministic responses
"seed": 123,
"temperature": 0,
"num_ctx": 2048
}
}
# Convert the dictionary to a JSON formatted string and encode it to bytes