Skip to content

Conversation

@eustlb
Copy link
Contributor

@eustlb eustlb commented Oct 17, 2025

What does this PR do?

Parakeet encoder modified the sequence length, making that the input attention_mask cannot be directly used to know which embeddings positions correspond to padding.

Here we do it differently than the actual external approach like we have on mimi that consists to retreive the correct mask:

attention_mask = mimi_model.get_audio_codes_mask(inputs.attention_mask)

and that recomputes as mask that is already known in the forward and that can simply be returned along with the outputs.

@eustlb eustlb requested a review from ArthurZucker October 17, 2025 15:23
@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.


return BaseModelOutput(last_hidden_state=hidden_states)
return ParakeetEncoderModelOutput(
last_hidden_state=hidden_states, attention_mask=output_mask.int() if output_attention_mask else None
Copy link
Contributor

Choose a reason for hiding this comment

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

can we return lengths directly instead or along with attention_mask

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd rather keep an explicit approach here for potiential future usage of the same with left padding, you can retreive lengths by doing attention_mask.sum(-1)

Copy link
Contributor

Choose a reason for hiding this comment

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

sounds good.

@eustlb eustlb mentioned this pull request Oct 23, 2025
Copy link
Collaborator

@ArthurZucker ArthurZucker left a comment

Choose a reason for hiding this comment

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

Okay sounds good !

@eustlb eustlb enabled auto-merge (squash) October 23, 2025 23:01
@github-actions
Copy link
Contributor

[For maintainers] Suggested jobs to run (before merge)

run-slow: parakeet

@eustlb eustlb merged commit e4b920b into huggingface:main Oct 23, 2025
17 checks passed
ngazagna-qc pushed a commit to ngazagna-qc/transformers that referenced this pull request Oct 24, 2025
i3hz pushed a commit to i3hz/transformers that referenced this pull request Oct 30, 2025
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