Skip to content

[docs] adding audio/video processors - #45795

Merged
stevhliu merged 4 commits into
huggingface:mainfrom
stevhliu:processors
May 18, 2026
Merged

[docs] adding audio/video processors#45795
stevhliu merged 4 commits into
huggingface:mainfrom
stevhliu:processors

Conversation

@stevhliu

@stevhliu stevhliu commented May 5, 2026

Copy link
Copy Markdown
Member

follow up to this comment about separate docs for how to add audio and video processors

@HuggingFaceDocBuilderDev

Copy link
Copy Markdown

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.

@stevhliu
stevhliu requested review from vasqu and zucchini-nlp May 5, 2026 21:32

@zucchini-nlp zucchini-nlp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice to see more docs about each modality! The main q I have is about sectioning, since for me video+image belong together more than with audio. The API is also very similar to both

Also left a few more comments on common pain points when reviewing a model

Comment on lines +17 to +20
# Add audio or video processors

Audio models require a feature extractor and video models require a video processor. Multimodal models use a processor that wraps some combination of a tokenizer, feature extractor, image processor, or video processor behind one [`AutoProcessor`] entry point.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

not sure this is the right sectioning. Video is also part of vision processing component imo. Prob we need a 1) small dropdown sectioning for multimodal processing and add three separately (images/videos/audio) OR 2) we can have "vision" and "audio" as two big sections

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

lets have image/video as one section, audio as another, and use your docs in #45493 for multimodal processors :)

Comment thread docs/source/en/add_audio_video_processor.md Outdated
Comment thread docs/source/en/add_audio_video_processor.md Outdated
Comment thread docs/source/en/add_audio_video_processor.md Outdated
Comment thread docs/source/en/add_audio_video_processor.md Outdated
Comment thread docs/source/en/add_audio_video_processor.md Outdated

> [!TIP]
> See [`Gemma4Processor`] and [`Qwen3OmniMoeProcessor`] for reference.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

for processors, there is one more thing to mention. The usage of typed dicts and that we can enforce model-specific defaults in there
(now that I think of it, I dont understand why we set defaults in code and not save in configs 🤔 cc @molbap if you remember, or is that for BC?)

They are later merged in

def _merge_kwargs(
self,
ModelProcessorKwargs: ProcessingKwargs,
tokenizer_init_kwargs: dict | None = None,
**kwargs,
) -> dict[str, dict]:
"""
Method to merge dictionaries of kwargs cleanly separated by modality within a Processor instance.
The order of operations is as follows:
1) kwargs passed as before have highest priority to preserve BC.
```python
high_priority_kwargs = {"crop_size" = {"height": 222, "width": 222}, "padding" = "max_length"}
processor(..., **high_priority_kwargs)
```
2) kwargs passed as modality-specific kwargs have second priority. This is the recommended API.
```python
processor(..., text_kwargs={"padding": "max_length"}, images_kwargs={"crop_size": {"height": 222, "width": 222}}})
```
3) kwargs passed during instantiation of a modality processor have fourth priority.
```python
tokenizer = tokenizer_class(..., {"padding": "max_length"})
image_processor = image_processor_class(...)
processor(tokenizer, image_processor) # will pass max_length unless overridden by kwargs at call
```
4) defaults kwargs specified at processor level have lowest priority.
```python
class MyProcessingKwargs(ProcessingKwargs, CommonKwargs, TextKwargs, ImagesKwargs, total=False):
_defaults = {
"text_kwargs": {
"padding": "max_length",
"max_length": 64,
},
}
```
Args:
ModelProcessorKwargs (`ProcessingKwargs`):
Typed dictionary of kwargs specifically required by the model passed.
tokenizer_init_kwargs (`Dict`, *optional*):
Dictionary of kwargs the tokenizer was instantiated with and need to take precedence over defaults.
Returns:
output_kwargs (`Dict`):
Dictionary of per-modality kwargs to be passed to each modality-specific processor.

Map the new classes to the model config so the `Auto` classes can load them. The generated auto mapping file has a warning at the top. Do not edit it by hand. Add or update the model config, then run:

```bash
python utils/check_auto.py --fix_and_overwrite

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

oh this doesn't yet work for Processor and FeatureExtractor. I wanted to be sure it doesn't create new issues, and then expand more 😅
Will work on it next week!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

sounds good! removed for now, but will add it back once its ready :)

Comment thread docs/source/en/add_audio_video_processor.md Outdated
Comment thread docs/source/en/add_vision_processing_components.md Outdated
@zucchini-nlp

zucchini-nlp commented May 6, 2026

Copy link
Copy Markdown
Member

Also linking #45493 (processing refactor), I will add docs explaining how to add processors with the new API in mind and how to convert from old format to new. Not sure which one gets merged first, so I will tag you for review when the doc is pushed

@zucchini-nlp zucchini-nlp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks

I will merge the other PR on processors this week, and I can just rebase on top of yours. Feel free to merge when ready

from ...feature_extraction_sequence_utils import SequenceFeatureExtractor


class MyModelFeatureExtractor(SequenceFeatureExtractor):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

might need a re-do after merging #44394, just linking :)

Comment thread docs/source/en/add_vision_processing_components.md
@stevhliu
stevhliu added this pull request to the merge queue May 18, 2026
Merged via the queue into huggingface:main with commit ad327c9 May 18, 2026
31 checks passed
@stevhliu
stevhliu deleted the processors branch May 18, 2026 04:49
jp1924 pushed a commit to jp1924/transformers that referenced this pull request May 18, 2026
yuchenxie4645 pushed a commit to yuchenxie4645/transformers that referenced this pull request May 28, 2026
kashif pushed a commit to kashif/transformers that referenced this pull request Jun 1, 2026
khushali9 pushed a commit to khushali9/transformers that referenced this pull request Jun 8, 2026
stevhliu added a commit to stevhliu/transformers that referenced this pull request Jul 30, 2026
* docs

* feedback

* tests

* feedback
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.

4 participants