yangheng95 / PyABSA

Sentiment Analysis, Text Classification, Text Augmentation, Text Adversarial defense, etc.;
https://pyabsa.readthedocs.io
MIT License
936 stars 159 forks source link

您好,我想用自己的数据训练模型,可是pyabsa.functional无法使用,请问是什么原因呢 #352

Open wangying15 opened 1 year ago

wangying15 commented 1 year ago

ModuleNotFoundError Traceback (most recent call last) ~\AppData\Local\Temp\ipykernel_22276\1578182218.py in 3 import findfile 4 ----> 5 from pyabsa.functional import ATEPCModelList 6 from pyabsa.functional import Trainer, ATEPCTrainer 7 from pyabsa.functional import ABSADatasetList

ModuleNotFoundError: No module named 'pyabsa.functional'

wangying15 commented 1 year ago

我用的是最新2.3.3版本了,麻烦大佬看看是什么问题呢?

wangying15 commented 1 year ago

尝试了https://pyabsa.readthedocs.io/en/stable/6_tutorials/Aspect_Term_Extraction.html提供的: from pyabsa import ModelSaveOption, DeviceTypeOption import warnings

warnings.filterwarnings("ignore")

config.batch_size = 16 config.patience = 2 config.log_step = -1 config.seed = [1] config.verbose = False # If verbose == True, PyABSA will output the model strcture and seversal processed data examples config.notice = ( "This is an training example for aspect term extraction" # for memos usage )

trainer = ATEPC.ATEPCTrainer( config=config, dataset=dataset, from_checkpoint="english", # if you want to resume training from our pretrained checkpoints, you can pass the checkpoint name here auto_device=DeviceTypeOption.AUTO, # use cuda if available checkpoint_save_mode=ModelSaveOption.SAVE_MODEL_STATE_DICT, # save state dict only instead of the whole model load_aug=False, # there are some augmentation dataset for integrated datasets, you use them by setting load_aug=True to improve performance )

NameError Traceback (most recent call last) ~\AppData\Local\Temp\ipykernel_22276\2525470414.py in 4 warnings.filterwarnings("ignore") 5 ----> 6 config.batch_size = 16 7 config.patience = 2 8 config.log_step = -1

NameError: name 'config' is not defined

yangheng95 commented 1 year ago

pyabsa.functional属于1.x 版本的用法,你可以查看新用法或者降级到1.x版本,例如 pip install pyabsa<2.0 -U

wangying15 commented 1 year ago

谢谢!请问这个问题也是同样的原因吗?

尝试了https://pyabsa.readthedocs.io/en/stable/6_tutorials/Aspect_Term_Extraction.html提供的: from pyabsa import ModelSaveOption, DeviceTypeOption import warnings

warnings.filterwarnings("ignore")

config.batch_size = 16 config.patience = 2 config.log_step = -1 config.seed = [1] config.verbose = False # If verbose == True, PyABSA will output the model strcture and seversal processed data examples config.notice = ( "This is an training example for aspect term extraction" # for memos usage )

trainer = ATEPC.ATEPCTrainer( config=config, dataset=dataset, from_checkpoint="english", # if you want to resume training from our pretrained checkpoints, you can pass the checkpoint name here auto_device=DeviceTypeOption.AUTO, # use cuda if available checkpoint_save_mode=ModelSaveOption.SAVE_MODEL_STATE_DICT, # save state dict only instead of the whole model load_aug=False, # there are some augmentation dataset for integrated datasets, you use them by setting load_aug=True to improve performance ) NameError Traceback (most recent call last) ~\AppData\Local\Temp\ipykernel_22276\2525470414.py in 4 warnings.filterwarnings("ignore") 5 ----> 6 config.batch_size = 16 7 config.patience = 2 8 config.log_step = -1

NameError: name 'config' is not defined

yangheng95 commented 1 year ago

代码不完整,请参考完整的代码。这里没有定义config.

e.g., https://github.com/yangheng95/PyABSA/blob/release/demos/aspect_term_extraction/train_atepc_english.py https://github.com/yangheng95/PyABSA/blob/release/demos/aspect_polarity_classification/train_apc_english.py