Skip to content

Return feature attention masks from Wav2Vec2-derived models#47554

Open
DebadityaHait wants to merge 2 commits into
huggingface:mainfrom
DebadityaHait:fix/wav2vec2-output-attention-mask
Open

Return feature attention masks from Wav2Vec2-derived models#47554
DebadityaHait wants to merge 2 commits into
huggingface:mainfrom
DebadityaHait:fix/wav2vec2-output-attention-mask

Conversation

@DebadityaHait

@DebadityaHait DebadityaHait commented Jul 25, 2026

Copy link
Copy Markdown

CI

What does this PR do?

Fixes #25307.

Wav2Vec2-derived base models already compute a feature-vector attention mask for padded inputs but did not expose it in their return-dict outputs. This adds an optional attention_mask field to Wav2Vec2BaseModelOutput and returns the exact reduced mask from Wav2Vec2Model, WavLM, Data2Vec Audio, and Wav2Vec2 Conformer.

The mask aligns with last_hidden_state; return_dict=False tuple layouts are unchanged.

The WavLM, Data2Vec Audio, and Wav2Vec2 Conformer return sites are generated from their modular definitions, so they are included to keep repository modular consistency valid.

Code Agent Policy

This was a human-led contribution. AI assistance was used for implementation and testing; the human submitter reviewed every changed line and validated the behavior locally.

Before submitting

@DebadityaHait DebadityaHait changed the title Return feature attention mask from Wav2Vec2Model Return feature attention masks from Wav2Vec2-derived models Jul 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

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

run-slow: data2vec, wav2vec2, wav2vec2_conformer, wavlm

@github-actions

Copy link
Copy Markdown
Contributor

CI recap

Dashboard: View test results in Grafana
Latest run: 30190618585:2
Result: success | Jobs: 16 | Tests: 174,844 | Failures: 0 | Duration: 16h 27m

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.

Return updated attention mask from Wav2Vec 2.0

1 participant