-
Notifications
You must be signed in to change notification settings - Fork 33.9k
[MMS] Fix mms #25267
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[MMS] Fix mms #25267
Changes from 3 commits
bad26e4
153af5c
35cf772
3d97b19
0ccd919
e73a059
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1151,6 +1151,40 @@ def get_logits(model, input_features): | |
|
|
||
| self.assertTrue(torch.allclose(logits, logits_2, atol=1e-3)) | ||
|
|
||
| def test_load_and_new_target_lang_adapter(self): | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. might be good to add a short comment to explain a bit what this test does, as this is for a very special situation.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. even just a link to issue and this PR page is fine for me.
patrickvonplaten marked this conversation as resolved.
Outdated
|
||
| processor = Wav2Vec2Processor.from_pretrained( | ||
| "hf-internal-testing/tiny-random-wav2vec2", return_attention_mask=True | ||
| ) | ||
|
|
||
| def get_logits(model, input_features): | ||
| model = model.to(torch_device) | ||
| batch = processor( | ||
| input_features, | ||
| padding=True, | ||
| sampling_rate=processor.feature_extractor.sampling_rate, | ||
| return_tensors="pt", | ||
| ) | ||
|
|
||
| with torch.no_grad(): | ||
| logits = model( | ||
| input_values=batch["input_values"].to(torch_device), | ||
| attention_mask=batch["attention_mask"].to(torch_device), | ||
| ).logits | ||
| return logits | ||
|
|
||
| input_features = [np.random.random(16_000 * s) for s in [1, 3, 2, 6]] | ||
|
|
||
| model = Wav2Vec2ForCTC.from_pretrained("hf-internal-testing/tiny-random-wav2vec2-adapter", target_lang="fr", ignore_mismatched_sizes=True) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. better test! The other tests didn't check for mismatched vocab sizes actually. This should solve it |
||
|
|
||
| logits = get_logits(model, input_features) | ||
|
|
||
| model_2 = Wav2Vec2ForCTC.from_pretrained("hf-internal-testing/tiny-random-wav2vec2-adapter") | ||
| model_2.load_adapter("fr") | ||
|
|
||
| logits_2 = get_logits(model_2, input_features) | ||
|
|
||
| self.assertTrue(torch.allclose(logits, logits_2, atol=1e-3)) | ||
|
|
||
| def test_load_attn_adapter(self): | ||
| processor = Wav2Vec2Processor.from_pretrained( | ||
| "hf-internal-testing/tiny-random-wav2vec2", return_attention_mask=True | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.