Skip to content
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

Update model.py #1

Closed
wants to merge 2 commits into from
Closed

Update model.py #1

wants to merge 2 commits into from

Conversation

darsh169
Copy link
Contributor

last_hidden_state from BertModel. Please review the changes

last_hidden_state from BertModel. Please review the changes
@hasanhuz
Copy link
Owner

hasanhuz commented Jun 15, 2021

Hi Darshan, Thank you for the pull request. Your changes are fine, but it is not really necessary for the work in this GitHub repository. Are you trying to use different layers of the BERT-Encoder instead of the last output layer?

@darsh169
Copy link
Contributor Author

Thanks for the review @hasanhuz ! when cloned the repo in colab the error occurred at [last_hidden_state, pooler_output = self.bert(input_ids=input_ids)] the line which I modified and error was -too many values to unpack. self.bert(input_ids=input_ids)[0] gives the last hidden state of bert model which i thought is the need here.
for reference: huggingface/transformers#1950
would like hear your thoughts on this

@hasanhuz
Copy link
Owner

Yes, this makes sense because you added the argument (output_hidden_states=True) to the BERT model, which returns three outputs instead of two. These outputs include the last hidden state, pooler output and all hidden states.

I would suggest that you keep everything intact unless you'd like to use different layers of the BERT-Encoder. If that's the case, please let me know and I'd be more than happy to add this to my code!

@darsh169
Copy link
Contributor Author

darsh169 commented Jun 16, 2021

Exactly, as last hidden state is accessible without using BertConfig the we can go without it surely.
Please check the recent commit

last_hidden_state, pooler_output = self.bert(input_ids=input_ids) returns last_hidden_state as a string which needs to be a tensor
@hasanhuz
Copy link
Owner

This also works fine. But you could still use the original implementation and get the same thing :)

@hasanhuz hasanhuz closed this Jun 16, 2021
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.

None yet

2 participants