-
Notifications
You must be signed in to change notification settings - Fork 31.9k
Fix 29807 sinusoidal positional encodings in Flaubert, Informer and XLM #29904
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
Changes from all commits
786da4b
8f181a5
538f2d2
1bf96b7
4b2fc86
ed44e69
15b6558
770c089
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 |
|---|---|---|
|
|
@@ -36,6 +36,7 @@ | |
| XLMModel, | ||
| XLMWithLMHeadModel, | ||
| ) | ||
| from transformers.models.xlm.modeling_xlm import create_sinusoidal_embeddings | ||
|
|
||
|
|
||
| class XLMModelTester: | ||
|
|
@@ -432,6 +433,14 @@ def test_xlm_model(self): | |
| config_and_inputs = self.model_tester.prepare_config_and_inputs() | ||
| self.model_tester.create_and_check_xlm_model(*config_and_inputs) | ||
|
|
||
| # Copied from tests/models/distilbert/test_modeling_distilbert.py with Distilbert->XLM | ||
| def test_xlm_model_with_sinusoidal_encodings(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. missing copied from
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. @ArthurZucker does this solve it?
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. Yes, but we need "with Distlbert->XLM"
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. changed them |
||
| config = XLMConfig(sinusoidal_embeddings=True) | ||
| model = XLMModel(config=config) | ||
| sinusoidal_pos_embds = torch.empty((config.max_position_embeddings, config.emb_dim), dtype=torch.float32) | ||
| create_sinusoidal_embeddings(config.max_position_embeddings, config.emb_dim, sinusoidal_pos_embds) | ||
| self.model_tester.parent.assertTrue(torch.equal(model.position_embeddings.weight, sinusoidal_pos_embds)) | ||
|
|
||
| def test_xlm_lm_head(self): | ||
| config_and_inputs = self.model_tester.prepare_config_and_inputs() | ||
| self.model_tester.create_and_check_xlm_lm_head(*config_and_inputs) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's use copied from for the test as well!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this solve it?