Repository navigation
fix(asr): pass temperature to Transformers Whisper generation - #5166
Conversation
The Transformers Whisper branch built generate_kwargs from task and language only, so InlineAsrTransformersOptions.temperature was ignored and decoding was always greedy. Forward the value the same way the native and mlx Whisper backends do. The 0.0 default stays greedy. Resolves docling-project#5164 Signed-off-by: Shashank Yadav <[email protected]>
|
✅ DCO Check Passed Thanks @shashank11yadav, all your commits are properly signed off. 🎉 |
Merge Protections🟢 Merge protection satisfied — ready to merge. Show 1 satisfied protection🟢 Enforce conventional commitMake sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
|
AI triage (advisory)Checked commit The PR passes Topic labels added: CI safety: no concern found. A maintainer must still approve CI. The |
There was a problem hiding this comment.
AI first review (advisory): no blocker found
This review covers the full diff at a913bfdf31. It read the code and did not run it.
I found no defects. generate_kwargs now includes temperature for the Transformers Whisper path, and the new test checks the exact dict that the pipeline receives. In the installed Transformers source, WhisperGenerationMixin.generate (generation_whisper.py:1002-1003) sets do_sample to temperature > 0.0 and uses 1.0 otherwise. So the default 0.0 stays greedy, and 0.2 turns on sampling.
A maintainer makes the merge decision. This review never approves the pull request.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
The Transformers Whisper path in
_TransformersAsrModel.transcribebuiltgenerate_kwargsfromtaskandlanguageonly.InlineAsrTransformersOptions.temperaturewas never passed, so decoding always ran with the pipeline defaults. This change forwardstemperaturein the same way the native and mlx Whisper paths already do. The fix covers the Transformers Whisper path only. The granite, granite_ctc, parakeet and nemotron paths still ignoretemperature. The default stays0.0, so default behavior is unchanged: Whisper'sgeneratetreatstemperature=0.0as greedy decoding (do_sample=False), the same as before.Tests added:
test_transformers_whisper_forwards_temperatureintests/test_asr_transformers.py, parametrized with0.0and0.2. It checks that thegenerate_kwargspassed to the Transformers ASR pipeline containtaskandtemperature.Issue resolved by this Pull Request:
Resolves #5164
Checklist:
Review evidence:
Before:
generate_kwargscontains onlytask(andlanguagewhen set). The new test fails without the fix (2 failed, exit 1).After: the new test passes (2 passed), and
tests/test_asr_transformers.pypasses (8 passed).Commands run:
uv run pytest tests/test_asr_transformers.py: pass (exit 0)uv run pytest tests/test_asr_transformers.py -k test_transformers_whisper_forwards_temperature: pass (exit 0)uv run ruff check --config=pyproject.toml docling tests: pass (exit 0)uv run ruff format --check --config=pyproject.toml docling tests: pass (exit 0)uv run --no-sync ty check: pass (exit 0, 0 errors)Not run:
temperatureingenerate_kwargswas checked by reading the transformers source (5.20.2 and current main) only, not at the>=5.16.0lower bound.make test) was not run.make checkandmake validatewere not run.ruff checkandruff format --checkwere not run ondocs/examples,scripts/benchmarkingandscripts/tools.