-
Notifications
You must be signed in to change notification settings - Fork 27.7k
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
DPR usage of BertPooler #14486
Comments
Hi ! I think it was kept in case some version of DPR had a projection layer (but afaik none of the official versions have that and the paper doesn't mention that either). I think it would also break the conversion script from DPR weights of the official repository to Not sure exactly how such changes are welcomed in the library but @patrickvonplaten probably knows more? |
DPR has an optional projection layer in the original implementation but it is only applied on the sequence output, not on BertPooler's output. |
This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread. Please note that issues that do not follow the contributing guidelines are likely to be ignored. |
Sorry to be so late on this. @PaulLerner - would you like to open a PR to fix it? Otherwise I can try to give it a shot |
No problem, I’m not sure to be familiar enough with the library to be able to fix it by myself. And I have no clue about the conversion script for the weights that @lhoestq is talking about. |
Hey @PaulLerner, don't worry about the conversion script. I think it'll be enough to just fix everything as suggested by you in |
Ok, I’ll let you know. I’m quite busy atm. |
Environment info
transformers
version: 4.8.2Who can help
RAG, DPR: @patrickvonplaten, @lhoestq
Information
DPR initializes BertModel with a BertPooler module which is not used in the end
Although this seems consistent with the original implementation, it is confusing for the user. One would expect that the
pooled_output
will come from the BertPooler module, if it is present, and the last layer of the model. Moreover it wastes memory and compute.How to fix
Simply add the
add_pooling_layer=False
flag in https://github.com/huggingface/transformers/blob/master/src/transformers/models/dpr/modeling_dpr.py#L178Some other parts of the code need also to be fixed, like https://github.com/huggingface/transformers/blob/master/src/transformers/models/dpr/modeling_dpr.py#L205
should be
sequence_output = outputs[0]
The text was updated successfully, but these errors were encountered: