Skip to content

fix(asr): pass temperature to Transformers Whisper generation - #5166

Merged
PeterStaar-IBM merged 1 commit into
docling-project:mainfrom
shashank11yadav:fix/5164-transformers-whisper-temperature
Nov 5, 2026
Merged

PeterStaar-IBM merged 1 commit into
docling-project:mainfrom
shashank11yadav:fix/5164-transformers-whisper-temperature

Conversation

@shashank11yadav

Copy link
Copy Markdown
Contributor

The Transformers Whisper path in _TransformersAsrModel.transcribe built generate_kwargs from task and language only. InlineAsrTransformersOptions.temperature was never passed, so decoding always ran with the pipeline defaults. This change forwards temperature in 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 ignore temperature. The default stays 0.0, so default behavior is unchanged: Whisper's generate treats temperature=0.0 as greedy decoding (do_sample=False), the same as before.

Tests added: test_transformers_whisper_forwards_temperature in tests/test_asr_transformers.py, parametrized with 0.0 and 0.2. It checks that the generate_kwargs passed to the Transformers ASR pipeline contain task and temperature.

Issue resolved by this Pull Request:
Resolves #5164

Checklist:

  • Documentation has been updated, if necessary.
  • Examples have been added, if necessary.
  • Tests have been added, if necessary.

Review evidence:

Before: generate_kwargs contains only task (and language when set). The new test fails without the fix (2 failed, exit 1).

After: the new test passes (2 passed), and tests/test_asr_transformers.py passes (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:

  • No real Whisper model was run. The test mocks the Transformers pipeline and checks the kwargs passed to it, not decoding output.
  • Whisper's handling of temperature in generate_kwargs was checked by reading the transformers source (5.20.2 and current main) only, not at the >=5.16.0 lower bound.
  • Full test suite (make test) was not run.
  • make check and make validate were not run.
  • ruff check and ruff format --check were not run on docs/examples, scripts/benchmarking and scripts/tools.

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]>
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

✅ DCO Check Passed

Thanks @shashank11yadav, all your commits are properly signed off. 🎉

@mergify

mergify Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Merge Protections

🟢 Merge protection satisfied — ready to merge.

Show 1 satisfied protection

🟢 Enforce conventional commit

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert)(?:\(.+\))?(!)?:

@github-actions github-actions Bot added ai:ci-safe AI triage found no CI-safety concern (advisory) asr Issues related to ASR (Automatic Speech Recognition) bug Something isn't working labels Nov 3, 2026
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

AI triage (advisory)

Checked commit a913bfdf31. The analysis read the diff only. It did not run code from this pull request.

The PR passes temperature to the Transformers Whisper generate_kwargs in _TransformersAsrModel.transcribe. It adds a parametrized test that checks the kwargs given to the pipeline.

Topic labels added: bug, asr.

CI safety: no concern found. A maintainer must still approve CI.

The ai:* labels are advisory. They do not approve CI and they do not add tests:full. A new push runs this check again.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@github-actions github-actions Bot added the ai:review-lgtm AI first review found no blocker or major issue (advisory) label Nov 3, 2026
@codecov

codecov Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@PeterStaar-IBM
PeterStaar-IBM merged commit 7f6b3d4 into docling-project:main Nov 5, 2026
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai:ci-safe AI triage found no CI-safety concern (advisory) ai:review-lgtm AI first review found no blocker or major issue (advisory) asr Issues related to ASR (Automatic Speech Recognition) bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ASR: Transformers Whisper ignores the temperature option

2 participants