Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

feat(llm): temperature and seed settings; chat_eval --repeat - #36

Merged
mkhellat merged 1 commit into
mainfrom
feat/sampling-settings
Dec 1, 2026
Merged

mkhellat merged 1 commit into
mainfrom
feat/sampling-settings

Conversation

@mkhellat

Copy link
Copy Markdown
Owner

Single chat_eval runs 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

  • Two settings, CODEBUD_TEMPERATURE and CODEBUD_SEED, also temperature and seed in 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

  • Implemented by a Sonnet subagent and reviewed locally. The keep-alive ping deliberately gets no sampling options (fix(llm): keep the model loaded without evicting its prompt cache #30: it runs nothing).
  • 11 + 7 new tests; the full suite passes (1927); ruff is clean; the manual builds without warnings.
  • CI runs once on this head: it changes the LLM client and the settings.

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.
@mkhellat

mkhellat commented Dec 1, 2026

Copy link
Copy Markdown
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 main (5e1f04b), which has not moved, so the merged tree is the tested one; the merge commit carries [skip ci]. I start the docs workflow by hand for the configuration and benchmarking changes.

@mkhellat
mkhellat merged commit 75656bd into main Dec 1, 2026
7 checks passed
@mkhellat
mkhellat deleted the feat/sampling-settings branch December 1, 2026 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant