PyABSA icon indicating copy to clipboard operation
PyABSA copied to clipboard

Quick start resulting in errors from loading the checkpoints

Open chen-bowen opened this issue 1 year ago • 3 comments

Version pyabsa 2.2.2, python 3.10.6

Describe the bug No idea why quick start fails with model checkpoint can't be found.

ModuleNotFoundError                       Traceback (most recent call last)
File ~/opt/anaconda3/envs/mlqu/lib/python3.10/site-packages/pyabsa/tasks/AspectSentimentTripletExtraction/prediction/predictor.py:73, in AspectSentimentTripletExtractor.__init__(self, checkpoint, **kwargs)
     72 with open(config_path, mode="rb") as f:
---> 73     self.config = pickle.load(f)
     74     self.config.auto_device = kwargs.get("auto_device", True)

ModuleNotFoundError: No module named 'transformers.models.deberta_v2.tokenization_deberta_v2_fast'

During handling of the above exception, another exception occurred:

RuntimeError                              Traceback (most recent call last)
Cell In[1], line 4
      1 from pyabsa import AspectSentimentTripletExtraction as ASTE
      3 # Load the model
----> 4 triplet_extractor = ASTE.AspectSentimentTripletExtractor("english")
      5 # triplet_extractor = ASTE.AspectSentimentTripletExtractor("multilingual")
      6 
      7 # # Predict
      8 examples = [
      9     "I would like to have volume buttons rather than the adjustment that is on the front .####[([5, 6], [2], 'NEG')]",
     10     "It runs perfectly .####[([1], [2], 'POS')]",
     11     "Sometimes the screen even goes black on this computer .####[([2], [5], 'NEG')]",
     12     "Its fast and another thing I like is that it has three USB ports .####[([12, 13], [6], 'POS')]",
     13 ]

File ~/opt/anaconda3/envs/mlqu/lib/python3.10/site-packages/pyabsa/tasks/AspectSentimentTripletExtraction/prediction/predictor.py:99, in AspectSentimentTripletExtractor.__init__(self, checkpoint, **kwargs)
     96             print_args(self.config)
     98     except Exception as e:
---> 99         raise RuntimeError(
    100             "Fail to load the model from {}! "
    101             "Please make sure the version of checkpoint and PyABSA are compatible."
    102             " Try to remove he checkpoint and download again"
    103             " \nException: {} ".format(e, checkpoint)
    104         )
    106 self.dataset = ASTEInferenceDataset(self.config, self.tokenizer)
    108 self.__post_init__(**kwargs)

RuntimeError: Fail to load the model from No module named 'transformers.models.deberta_v2.tokenization_deberta_v2_fast'! Please make sure the version of checkpoint and PyABSA are compatible. Try to remove he checkpoint and download again 
Exception: english 

Code To Reproduce

from pyabsa import AspectSentimentTripletExtraction as ASTE

# Load the model
triplet_extractor = ASTE.AspectSentimentTripletExtractor("english")
# triplet_extractor = ASTE.AspectSentimentTripletExtractor("multilingual")

# # Predict
examples = [
    "I would like to have volume buttons rather than the adjustment that is on the front .####[([5, 6], [2], 'NEG')]",
    "It runs perfectly .####[([1], [2], 'POS')]",
    "Sometimes the screen even goes black on this computer .####[([2], [5], 'NEG')]",
    "Its fast and another thing I like is that it has three USB ports .####[([12, 13], [6], 'POS')]",
]
for example in examples:
    triplet_extractor.predict(example)

# Batch predict
# target_file = "ASTE"
target_file = ASTE.ASTEDatasetList.Laptop14

triplet_extractor.batch_predict(
    target_file=target_file,
    batch_size=32,
    ignore_error=True,
    save_result=True,
    auto_device=True,
)

Expected behavior a model checkpoint should be found

Screenshots If applicable, add screenshots to help explain your problem.

chen-bowen avatar Apr 06 '23 14:04 chen-bowen

Currently, I only train and upload the multilingual checkpoint

yangheng95 avatar Apr 08 '23 12:04 yangheng95

it's the same error if I'm using the multilingual checkpoint. please advice

chen-bowen avatar Apr 09 '23 23:04 chen-bowen

Did you install sentencepiece?

yangheng95 avatar Apr 10 '23 00:04 yangheng95