PaddlePaddle / PaddleNLP

👑 Easy-to-use and powerful NLP and LLM library with 🤗 Awesome model zoo, supporting wide-range of NLP tasks from research to industrial applications, including 🗂Text Classification, 🔍 Neural Search, ❓ Question Answering, ℹ️ Information Extraction, 📄 Document Intelligence, 💌 Sentiment Analysis etc.
https://paddlenlp.readthedocs.io
Apache License 2.0
12.18k stars 2.95k forks source link

『NLP打卡营』实践课7:中英文本翻译系统中引入from paddlenlp.data import Vocab, Pad from paddlenlp.datasets import load_dataset报错 #6485

Open xxch opened 1 year ago

xxch commented 1 year ago

请提出你的问题

版本paddlenlp-2.5.2 报错内容 16 from paddlenlp.data import Vocab, Pad 17 from paddlenlp.datasets import load_dataset 18 from paddlenlp.transformers import TransformerModel, InferTransformerModel, CrossEntropyCriterion, position_encoding_init /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddlenlp/__init__.py in <module> 33 import paddle 34 ---> 35 from . import ( 36 data, 37 dataaug, /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddlenlp/data/__init__.py in <module> 14 15 from .collate import * ---> 16 from .data_collator import * 17 from .vocab import * 18 from .sampler import * /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddlenlp/data/data_collator.py in <module> 23 import paddle 24 ---> 25 from ..transformers import BertTokenizer 26 from ..transformers.tokenizer_utils_base import ( 27 BatchEncoding, /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddlenlp/transformers/__init__.py in <module> 15 16 from .configuration_utils import PretrainedConfig ---> 17 from .model_utils import PretrainedModel, register_base_model 18 from .tokenizer_utils import ( 19 PretrainedTokenizer, /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddlenlp/transformers/model_utils.py in <module> 219 220 @six.add_metaclass(InitTrackerMeta) --> 221 class PretrainedModel(Layer, GenerationMixin, ConversionMixin): 222 """ 223 The base class for all pretrained models. It mainly provides common methods /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/six.py in wrapper(cls) 892 if hasattr(cls, '__qualname__'): 893 orig_vars['__qualname__'] = cls.__qualname__ --> 894 return metaclass(cls.__name__, cls.__bases__, orig_vars) 895 return wrapper 896 /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddlenlp/transformers/utils.py in __init__(cls, name, bases, attrs) 140 pre_init_func = getattr(cls, "_pre_init", None) if "__init__" in attrs else None 141 post_init_func = getattr(cls, "_post_init", None) if "__init__" in attrs else None --> 142 cls.__init__ = InitTrackerMeta.init_and_track_conf(init_func, pre_init_func, post_init_func) 143 super(InitTrackerMeta, cls).__init__(name, bases, attrs) 144 /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddlenlp/transformers/utils.py in __setattr__(self, name, value) 181 def __setattr__(self, name, value): 182 value = adapt_stale_fwd_patch(self, name, value) --> 183 return super(InitTrackerMeta, self).__setattr__(name, value) 184 185 TypeError: can't apply this __setattr__ to type object

调试了好久,也换过paddlenlp版本还是报错。什么原因呢?

w5688414 commented 6 months ago

可以升级paddle和paddlenlp的版本试一下,另外请问有具体的最小复现代码吗?paddle和paddlenlp的代码是什么