question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DPR AutoModel loading incorrect architecture for DPRContextEncoders

See original GitHub issue

Environment info

  • transformers version: 4.10.2
  • Platform: Darwin-20.6.0-x86_64-i386-64bit
  • Python version: 3.7.7
  • PyTorch version (GPU?): 1.9.0 (False)
  • Tensorflow version (GPU?): not installed (NA)
  • Flax version (CPU?/GPU?/TPU?): not installed (NA)
  • Jax version: not installed
  • JaxLib version: not installed
  • Using GPU in script?: No
  • Using distributed or parallel set-up in script?: No

Who can help

Model type dpr: @LysandreJik @patrickvonplaten @lhoestq

Information

Model I am using:

To reproduce

Loading a DPR context encoder DPRContextEncoder using AutoModel.from_pretrained is actually loading DPRQuestionEncoder instead, and later fails.

Steps to reproduce the behavior:

AutoModel.from_pretrained('facebook/dpr-ctx_encoder-single-nq-base')

File "venv/lib/python3.7/site-packages/transformers/modeling_utils.py", line 579, in _init_weights
    raise NotImplementedError(f"Make sure `_init_weigths` is implemented for {self.__class__}")
NotImplementedError: Make sure `_init_weigths` is implemented for <class 'transformers.models.dpr.modeling_dpr.DPRQuestionEncoder'>

Note in the above that it’s trying to use the DPRQuestionEncoder even though the config for this context encoder is correct and points to architecture=DPRContextEncoder.

Using explicitly the DPRContextEncoder.from_pretrained works just fine, so it looks like this is somewhere in AutoModel.

DPRContextEncoder.from_pretrained('facebook/dpr-ctx_encoder-single-nq-base')

Expected behavior

Using AutoModel.from_pretrained should pick the correct architecture for a DPRContextEncoder.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
qqaatwcommented, Sep 24, 2021

To the best of my knowledge, this would be a major change of auto factory because the mapping file defines all Auto- models all together, not for each specific model. Only modifying DPR-related models might break the consistency of them.

0reactions
github-actions[bot]commented, Oct 25, 2021

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

DPR - Hugging Face
This is the configuration class to store the configuration of a DPRContextEncoder, DPRQuestionEncoder, or a DPRReader. It is used to instantiate the ...
Read more >
Source code for farm.modeling.language_model - Deepset
Enables generic load() or all specific LanguageModel implementation. ... "DPRQuestionEncoder" elif config.architectures[0] == "DPRContextEncoder": ...
Read more >
transformers add TFCLIPModel - GitAnswer
... transformers get started docs · transformers dPR AutoModel loading incorrect architecture for DPRContextEncoders · transformers add support for BORT ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found