fix(sampling): escalate temperature at the exact retry midpoint#274
fix(sampling): escalate temperature at the exact retry midpoint#274Osamaali313 wants to merge 1 commit into
Conversation
dynamically_adjust_temperature returned 0.0 when attempts == max_attempts / 2 (reachable whenever max_attempts is even). The two branches were strictly exclusive (attempts < max/2 -> 0.5, attempts > max/2 -> 0.75), so the exact midpoint fell through to the default 0.0, dropping the choice-sampling temperature back to zero for that retry instead of escalating it. Make the upper branch inclusive (>=) so the midpoint escalates to 0.75. All other attempt counts are unchanged. Adds the first unit tests for concordia/utils/sampling.py.
|
Heads-up on the red This PR only changes |
Summary
dynamically_adjust_temperature(inconcordia/utils/sampling.py) returns0.0whenattempts == max_attempts / 2, which is reachable whenevermax_attemptsis even.Both branches are strictly exclusive (
< max/2and> max/2), so the exact midpoint falls through to the default0.0. For example withmax_attempts=10,attempts=5returns0.0— dropping the choice-sampling temperature back to zero for that retry instead of escalating it, which defeats the retry-diversity intent at exactly the point where it should be ramping up.Fix
Make the upper branch inclusive so the midpoint escalates:
attempts=5, max=10now returns0.75(was0.0).attemptsovermax_attemptsin 2..20).max_attempts(no integer midpoint) are unaffected.Tests
Adds
concordia/utils/sampling_test.py— the first unit tests for this module — covering the temperature schedule (incl. the midpoint regression) andextract_choice_response. All 11 tests pass.