-
Notifications
You must be signed in to change notification settings - Fork 0
Set return_dict=True and remove output_hidden_states in Transformer #7
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
base: dev
Are you sure you want to change the base?
Changes from all commits
10ec27c
99f8c9a
2d973ce
a81645d
4c9d474
1f00c9f
d5e9c2f
928787b
023bf75
e017e04
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 |
|---|---|---|
|
|
@@ -97,7 +97,7 @@ def forward(self, *args, **kwargs): | |
| output_hidden_states = True | ||
| else: | ||
| output_hidden_states = False | ||
| output = self.model(*args, output_hidden_states = output_hidden_states, | ||
| output = self.model(*args, #output_hidden_states = output_hidden_states, | ||
| return_dict = True, **kwargs) | ||
|
Comment on lines
+100
to
101
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. issue (bug_risk): Passing Since
Comment on lines
+100
to
101
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.
When Useful? React with 👍 / 👎. |
||
| if self.config.fuse_layers: | ||
| encoder_layer = self.layers_fuser(output.hidden_states) | ||
|
|
@@ -165,4 +165,4 @@ def forward(self, input_ids, attention_mask, | |
| token_embeddings = self.encode_text(input_ids, attention_mask, *args, **kwargs) | ||
|
|
||
| labels_embeddings = self.encode_labels(labels_input_ids, labels_attention_mask, *args, **kwargs) | ||
| return token_embeddings, labels_embeddings | ||
| return token_embeddings, labels_embeddings | ||
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.
This change introduces a potential bug. By commenting out
output_hidden_states, the model will rely on its default configuration. Ifself.config.fuse_layersisTrue(checked on line 96), line 103 accessesoutput.hidden_states, which will likely not be present in the model's output, causing anAttributeErrorat runtime. Theoutput_hidden_statesparameter must be explicitly set toTruewhen layer fusion is enabled.Instead of commenting out this line, the logic should be corrected and simplified. The entire block from line 96 to 101 can be replaced with:
This is more concise and ensures
output_hidden_statesis correctly passed when needed.