HHousen / TransformerSum

Models to perform neural summarization (extractive and abstractive) using machine learning transformers and a tool to convert abstractive summarization datasets to the extractive task.
https://transformersum.rtfd.io
GNU General Public License v3.0
429 stars 58 forks source link

unable to run pretrained model #20

Closed amiyamandal-dev closed 4 years ago

amiyamandal-dev commented 4 years ago

facing issue with every pre-trained model.

[2020-10-05 22:36:49,902] ERROR in app: Exception on /api/predict/ [POST]
Traceback (most recent call last):
  File "/media/amiya/hdd/miniconda/envs/transformersum/lib/python3.8/site-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/media/amiya/hdd/miniconda/envs/transformersum/lib/python3.8/site-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/media/amiya/hdd/miniconda/envs/transformersum/lib/python3.8/site-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/media/amiya/hdd/miniconda/envs/transformersum/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/media/amiya/hdd/miniconda/envs/transformersum/lib/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/media/amiya/hdd/miniconda/envs/transformersum/lib/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/media/amiya/hdd/miniconda/envs/transformersum/lib/python3.8/site-packages/gradio/networking.py", line 109, in predict
    prediction, durations = app.interface.process(raw_input)
  File "/media/amiya/hdd/miniconda/envs/transformersum/lib/python3.8/site-packages/gradio/interface.py", line 254, in process
    predictions, durations = self.run_prediction(processed_input, return_duration=True)
  File "/media/amiya/hdd/miniconda/envs/transformersum/lib/python3.8/site-packages/gradio/interface.py", line 216, in run_prediction
    prediction = predict_fn(*processed_input)
  File "predictions_website.py", line 11, in summarize_text
    summarizer = ExtractiveSummarizer.load_from_checkpoint(model_choice)
  File "/media/amiya/hdd/miniconda/envs/transformersum/lib/python3.8/site-packages/pytorch_lightning/core/saving.py", line 153, in load_from_checkpoint
    model = cls._load_model_state(checkpoint, *args, strict=strict, **kwargs)
  File "/media/amiya/hdd/miniconda/envs/transformersum/lib/python3.8/site-packages/pytorch_lightning/core/saving.py", line 192, in _load_model_state
    model.load_state_dict(checkpoint['state_dict'], strict=strict)
  File "/media/amiya/hdd/miniconda/envs/transformersum/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1044, in load_state_dict
    raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format(
RuntimeError: Error(s) in loading state_dict for ExtractiveSummarizer:
    Missing key(s) in state_dict: "word_embedding_model.embeddings.position_ids".
HHousen commented 4 years ago

@amiyamandal-dev See #12 and #15. Essentially, this is a problem with the update from 3.0.2 to 3.1.0 of huggingface/transformers. The problem is being discussed at huggingface/transformers#6882. While they work on a fix, you can install the previous version of huggingface/transformers by running pip install -U transformers==3.0.2. I've updated the environment.yaml to install version 3.0.2 for now.