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

No module named 'pyabsa.functional' #385

Open
sqs17 opened this issue Feb 17, 2024 · 4 comments
Open

No module named 'pyabsa.functional' #385

sqs17 opened this issue Feb 17, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@sqs17
Copy link

sqs17 commented Feb 17, 2024

Version
See the console output for PyABSA, Torch, Transformers Version
pyabsa=2.3.4, torch=2.2.0,transformer=4.29.0

Describe the bug
Hello, I tried to use a pre-trained model on jupyter, I put the pre-trained model in.ipynb_checkpoints files, but there were runtime error, thank you for your answers.

Code To Reproduce
from pyabsa import ABSADatasetList, available_checkpoints
from pyabsa import ATEPCCheckpointManager
aspect_extractor = ATEPCCheckpointManager.get_aspect_extractor(checkpoint='Chinese',
auto_device=False # False means load model on CPU
)

[2024-02-17 09:55:41] (2.3.4) Fail to download checkpoints info from huggingface space, try to download from local
[2024-02-17 09:55:41] (2.3.4) No checkpoint found in Model Hub for task: Chinese
[2024-02-17 09:55:41] (2.3.4) Load aspect extractor from .ipynb_checkpoints\fast_lcf_atepc_Chinese_cdw_apcacc_96.09_apcf1_95.14_atef1_83.69
[2024-02-17 09:55:41] (2.3.4) config: .ipynb_checkpoints\fast_lcf_atepc_Chinese_cdw_apcacc_96.09_apcf1_95.14_atef1_83.69\fast_lcf_atepc.config
[2024-02-17 09:55:41] (2.3.4) state_dict: .ipynb_checkpoints\fast_lcf_atepc_Chinese_cdw_apcacc_96.09_apcf1_95.14_atef1_83.69\fast_lcf_atepc.state_dict
[2024-02-17 09:55:41] (2.3.4) model: None
[2024-02-17 09:55:41] (2.3.4) tokenizer: .ipynb_checkpoints\fast_lcf_atepc_Chinese_cdw_apcacc_96.09_apcf1_95.14_atef1_83.69\fast_lcf_atepc.tokenizer

ModuleNotFoundError Traceback (most recent call last)
File D:\anaconda\envs\absa\Lib\site-packages\pyabsa\tasks\AspectTermExtraction\prediction\aspect_extractor.py:83, in AspectExtractor.init(self, checkpoint, **kwargs)
82 with open(config_path, mode="rb") as f:
---> 83 self.config = pickle.load(f)
84 self.config.auto_device = kwargs.get("auto_device", True)

ModuleNotFoundError: No module named 'pyabsa.functional'

During handling of the above exception, another exception occurred:

RuntimeError Traceback (most recent call last)
Cell In[2], line 1
----> 1 aspect_extractor = ATEPCCheckpointManager.get_aspect_extractor(checkpoint='Chinese',
2 auto_device=False # False means load model on CPU
3 )

File D:\anaconda\envs\absa\Lib\site-packages\pyabsa\framework\checkpoint_class\checkpoint_template.py:223, in ATEPCCheckpointManager.get_aspect_extractor(checkpoint, **kwargs)
210 @staticmethod
211 def get_aspect_extractor(
212 checkpoint: Union[str, Path] = None, **kwargs
213 ) -> "AspectExtractor":
214 """
215 Get an AspectExtractor object initialized with the given checkpoint for Aspect Term Extraction and Polarity Classification.
216
(...)
220 :return: An AspectExtractor object initialized with the given checkpoint.
221 """
--> 223 return AspectExtractor(
224 CheckpointManager().parse_checkpoint(
225 checkpoint, TaskCodeOption.Aspect_Term_Extraction_and_Classification
226 )
227 )

File D:\anaconda\envs\absa\Lib\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 )

RuntimeError: Exception: No module named 'pyabsa.functional' Fail to load the model from .ipynb_checkpoints\fast_lcf_atepc_Chinese_cdw_apcacc_96.09_apcf1_95.14_atef1_83.69!

@sqs17 sqs17 added the bug Something isn't working label Feb 17, 2024
@yangheng95
Copy link
Owner

You are loading a outdated checkpoint, I will check the error later

@sqs17
Copy link
Author

sqs17 commented Feb 18, 2024

Ok, thank you very much!

@yangheng95
Copy link
Owner

BTW, you can try multilingual checkpoint which should be fine

@QIUQiting
Copy link

I try to use multilingual checkpoint ,but it still be wrong--"ModuleNotFoundError: No module named 'pyabsa.functional'"

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

3 participants