ProsusAI / finBERT

Financial Sentiment Analysis with BERT
Apache License 2.0
1.42k stars 413 forks source link

Cannot load the model #8

Closed kirkanshin closed 4 years ago

kirkanshin commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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.