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

PyABSA Version 2 not working- RuntimeError: Exception: expected str, bytes or os.PathLike object, not NoneType Fail to load the model from multilingual! #403

Open
roses2204 opened this issue May 28, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@roses2204
Copy link

Version
PyABSA version 2.4.1.post1

Describe the bug
I have installed PyABSA and tried to run the examples, but I keep getting the error that the Runtime wrror that the model has failed to load. I have tried version 1, and this works, but none of the version 2 packages have worked. How do I go about solving this?

Code To Reproduce
pip install -U pyabsa

from pyabsa import AspectTermExtraction as ATEPC, available_checkpoints

you can view all available checkpoints by calling available_checkpoints()

checkpoint_map = available_checkpoints()

aspect_extractor = ATEPC.AspectExtractor('multilingual',
auto_device=True, # False means load model on CPU
cal_perplexity=True,
)

instance inference

aspect_extractor.predict(['I love this movie, it is so great!'],
save_result=True,
print_result=True, # print the result
ignore_error=True, # ignore the error when the model cannot predict the input
)

inference_source = ATEPC.ATEPCDatasetList.Restaurant16
atepc_result = aspect_extractor.batch_predict(target_file=inference_source, #
save_result=True,
print_result=True, # print the result
pred_sentiment=True, # Predict the sentiment of extracted aspect terms
)

print(atepc_result)

Expected behavior
This was expected to run and provide the sentiment classifications, but when run, the execution always fails with this error:

RuntimeError: Exception: expected str, bytes or os.PathLike object, not NoneType Fail to load the model from multilingual!
File /local_disk0/.ephemeral_nfs/envs/pythonEnv-b49d82e8-1a51-4577-a57e-bdaccd63c848/lib/python3.10/site-packages/pyabsa/tasks/AspectTermExtraction/prediction/aspect_extractor.py:82, in AspectExtractor.init(self, checkpoint, **kwargs)
80 fprint("tokenizer: {}".format(tokenizer_path))
---> 82 with open(config_path, mode="rb") as f:
83 self.config = pickle.load(f)
File /local_disk0/.ephemeral_nfs/envs/pythonEnv-b49d82e8-1a51-4577-a57e-bdaccd63c848/lib/python3.10/site-packages/pyabsa/tasks/AspectTermExtraction/prediction/aspect_extractor.py:131, in AspectExtractor.init(self, checkpoint, **kwargs)
128 self.tokenizer = pickle.load(f)
130 except Exception as e:
--> 131 raise RuntimeError(
132 "Exception: {} Fail to load the model from {}! ".format(
133 e, self.checkpoint
134 )
135 )
137 if not hasattr(ATEPCModelList, self.model.class.name):
138 raise KeyError(
139 "The checkpoint you are loading is not from any ATEPC model."
140 )

I have tried a number of things, including downloading the checkpoint, but I'm now not sure how to get this to work.

@roses2204 roses2204 added the bug Something isn't working label May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant