Skip to content

Use correct sampling rate in chat template#43674

Merged
zucchini-nlp merged 2 commits intohuggingface:mainfrom
zucchini-nlp:template-sampling-rate
Feb 2, 2026
Merged

Use correct sampling rate in chat template#43674
zucchini-nlp merged 2 commits intohuggingface:mainfrom
zucchini-nlp:template-sampling-rate

Conversation

@zucchini-nlp
Copy link
Member

@zucchini-nlp zucchini-nlp commented Feb 2, 2026

What does this PR do?

Fixes #43262

Supersedes #43273 and #43660

I don't think the prev PR will be updated by contributor, since it's a code agent PR. Also I am seeing that it attracts more code agents as long as the issue is open, so let's merge a fix here

I also made a small clean-up of ChatTemplateKwargs and deleted unused/duplicate kwargs, as we discussed in above linked PR review comments

@zucchini-nlp zucchini-nlp requested a review from ebezzam February 2, 2026 09:32
@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Copy link
Contributor

@ebezzam ebezzam left a comment

Choose a reason for hiding this comment

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

Thanks for addressing this @zucchini-nlp!

It looks good to me, I don't see ChatTemplateLoadKwargs nor ProcessorChatTemplateKwargs used anywhere else so probably shouldn't be breaking. Is there any related test that can be checked?

Comment on lines +1716 to +1720
if "sampling_rate" not in template_kwargs:
if hasattr(self, "feature_extractor") and hasattr(self.feature_extractor, "sampling_rate"):
template_kwargs["sampling_rate"] = self.feature_extractor.sampling_rate
else:
template_kwargs["sampling_rate"] = 16_000
Copy link
Contributor

Choose a reason for hiding this comment

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

great!



class ProcessorChatTemplateKwargs(ChatTemplateLoadKwargs, TokenizerChatTemplateKwargs, total=False):
class ProcessorChatTemplateKwargs(TokenizerChatTemplateKwargs, total=False):
Copy link
Contributor

Choose a reason for hiding this comment

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

nice idea to merge together

@zucchini-nlp
Copy link
Member Author

Is there any related test that can be checked?

yeah, the processor MixinTests have a test_chat_template_audio which is passing in audio LLMs

@zucchini-nlp zucchini-nlp enabled auto-merge (squash) February 2, 2026 10:30
@zucchini-nlp zucchini-nlp merged commit e4b22ba into huggingface:main Feb 2, 2026
25 checks passed
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.

Audio processors: apply_chat_template() defaults to 16kHz sampling rate, even if the processor config sets a different value

3 participants