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

Cannot load the model #8

Closed
kirkanshin opened this issue Dec 22, 2019 · 2 comments
Closed

Cannot load the model #8

kirkanshin opened this issue Dec 22, 2019 · 2 comments

Comments

@kirkanshin
Copy link

When trying to load the model I get the following error. Do I need to download any additional model files? Thank you.

---------------------------------------------------------------------------
UnpicklingError                           Traceback (most recent call last)
<ipython-input-8-19ad01fc2649> in <module>
      5     pass
      6 
----> 7 bertmodel = BertForSequenceClassification.from_pretrained(lm_path,cache_dir=None, num_labels=3)
      8 
      9 

/anaconda/envs/bert10k/lib/python3.7/site-packages/pytorch_pretrained_bert/modeling.py in from_pretrained(cls, pretrained_model_name_or_path, *inputs, **kwargs)
    601         if state_dict is None and not from_tf:
    602             weights_path = os.path.join(serialization_dir, WEIGHTS_NAME)
--> 603             state_dict = torch.load(weights_path, map_location='cpu')
    604         if tempdir:
    605             # Clean up temp dir

/anaconda/envs/bert10k/lib/python3.7/site-packages/torch/serialization.py in load(f, map_location, pickle_module, **pickle_load_args)
    424         if sys.version_info >= (3, 0) and 'encoding' not in pickle_load_args.keys():
    425             pickle_load_args['encoding'] = 'utf-8'
--> 426         return _load(f, map_location, pickle_module, **pickle_load_args)
    427     finally:
    428         if new_fd:

/anaconda/envs/bert10k/lib/python3.7/site-packages/torch/serialization.py in _load(f, map_location, pickle_module, **pickle_load_args)
    601             f.seek(0)
    602 
--> 603     magic_number = pickle_module.load(f, **pickle_load_args)
    604     if magic_number != MAGIC_NUMBER:
    605         raise RuntimeError("Invalid magic number; corrupt file?")

UnpicklingError: invalid load key, 'v'.
@kirkanshin
Copy link
Author

Solved by downloading the actual (large) model file with
wget https://github.com/ProsusAI/finBERT/raw/master/models/language_model/finbertTRC2/pytorch_model.bin. It replaces models/language_model/finbertTRC2/pytorch_model.bin

@l0rem1psum
Copy link

Solved by downloading the actual (large) model file with
wget https://github.com/ProsusAI/finBERT/raw/master/models/language_model/finbertTRC2/pytorch_model.bin. It replaces models/language_model/finbertTRC2/pytorch_model.bin

Hi, could you please share the pytorch_model.bin file somewhere downloadable? It seems that this repository is exceeding the bandwidth limit for git-lfs and as a result those model files cannot be accessed. Thank you.

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

No branches or pull requests

2 participants