Repository navigation
feat(llm): temperature and seed settings; chat_eval --repeat - #36
Merged
Merged
Conversation
Two identical runs of a chat_eval scenario scored 12/13 and 9/13, so single runs could not tell two versions of codebud apart. The model's temperature was already 0 (hard-coded in the Ollama call); the spread comes from elsewhere -- most likely Ollama's prompt cache: a cold first run and a second run that reuses cached prefixes differ in tiny numerics, which can flip a token and then the whole answer. At temperature 0 and a fixed seed, two runs of the first scenario on the 3B scored 13/18 both times, every check alike, yet their texts differed on half the turns. So repeats, not single runs, are the unit of comparison. codebud now reads CODEBUD_TEMPERATURE and CODEBUD_SEED (also `temperature` and `seed` in config.toml) and passes them to Ollama on every model call (not the keep-alive ping), and to the OpenAI backend; unset, nothing changes (temperature stays 0). chat_eval sets them (--temperature, default 0; --seed, default 42) and gains --repeat N: each run in a fresh child and fixture, records carry the run, and the summary shows every run's score with min, mean and max. * src/codebud/llm_stub.py (sampling_options): New. (_call_ollama, _call_openai, prewarm_model, warm_model_sync): Use it. * src/codebud/settings.py: temperature and seed keys. * scripts/chat_eval.py (build_parser): --temperature, --seed, --repeat. (run_model, main): Repeats; the spread in the summary. * tests/test_sampling.py: New file. * tests/test_chat_eval.py: Test the new options. * docs/chapters/configuration.texi, docs/chapters/usage.texi, docs/chapters/performance-benchmarking.texi, docs/chapters/development.texi, NEWS: Document them.
Owner
Author
|
Merging. The review is in the PR body. CI is green on all five jobs, macOS included. CI on the merge is skipped: the branch sits on |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Single
chat_evalruns couldn't tell two versions apart: two identical runs of the log scenario scored 12/13 and 9/13.Finding: the temperature was already 0, hard-coded in the Ollama call, so the spread isn't sampling randomness. At temperature 0 and a fixed seed, two runs of the first scenario on the 3B scored 13/18 both times, every check alike, yet their texts differed on 5 of 10 turns. The most likely cause is Ollama's prompt cache: a cold first run and a second run that reuses cached prefixes differ in tiny numerics, which can flip one token and then the whole answer. Exact reproducibility isn't on offer, so repeats, not single runs, are the unit of comparison.
Change
CODEBUD_TEMPERATUREandCODEBUD_SEED, alsotemperatureandseedin config.toml. They're passed to Ollama on every model call (not the keep-alive ping) and to the OpenAI backend. Unset, nothing changes: temperature stays 0, and no seed is sent.chat_eval:--temperature(default 0),--seed(default 42), and--repeat N. Each run uses a fresh child process and fixture; records carry the run; the summary shows every run's score with min, mean and max.Review and CI