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

使用Randeng-Pegasus-523M-Summary-Chinese生成摘要报错PegasusTokenizer' object has no attribute 'vocab #461

Open
flystarts opened this issue Jun 13, 2024 · 1 comment

Comments

@flystarts
Copy link

flystarts commented Jun 13, 2024

我的代码来自 https://huggingface.co/IDEA-CCNL/Randeng-Pegasus-523M-Summary-Chinese

from transformers import PegasusForConditionalGeneration
from tokenizers_pegasus import PegasusTokenizer

model = PegasusForConditionalGeneration.from_pretrained("IDEA-CCNL/Randeng-Pegasus-523M-Summary-Chinese")
tokenizer = PegasusTokenizer.from_pretrained("IDEA-CCNL/Randeng-Pegasus-523M-Summary-Chinese")

text = "据微信公众号“界面”报道"
inputs = tokenizer(text, max_length=1024, return_tensors="pt")

summary_ids = model.generate(inputs["input_ids"])
print(tokenizer.batch_decode(summary_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0])

执行时报错:
tokenizer = PegasusTokenizer.from_pretrained("IDEA-CCNL/Randeng-Pegasus-523M-Summary-Chinese")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\Downloads\Fengshenbang-LM-main\Fengshenbang-LM-main.venv\Lib\site-packages\transformers\tokenization_utils_base.py", line 2110, in from_pretrained
return cls._from_pretrained(
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\Downloads\Fengshenbang-LM-main\Fengshenbang-LM-main.venv\Lib\site-packages\transformers\tokenization_utils_base.py", line 2336, in _from_pretrained
tokenizer = cls(*init_inputs, **init_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\Downloads\Fengshenbang-LM-main\Fengshenbang-LM-main\fengshen\examples\pegasus\tokenizers_pegasus.py", line 156, in init
super().init(
File "C:\Users\Administrator\Downloads\Fengshenbang-LM-main\Fengshenbang-LM-main.venv\Lib\site-packages\transformers\tokenization_utils.py", line 367, in init
self._add_tokens(
File "C:\Users\Administrator\Downloads\Fengshenbang-LM-main\Fengshenbang-LM-main.venv\Lib\site-packages\transformers\tokenization_utils.py", line 467, in _add_tokens
current_vocab = self.get_vocab().copy()
^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\Downloads\Fengshenbang-LM-main\Fengshenbang-LM-main\fengshen\examples\pegasus\tokenizers_pegasus.py", line 209, in get_vocab
return dict(self.vocab, **self.added_tokens_encoder)
^^^^^^^^^^
AttributeError: 'PegasusTokenizer' object has no attribute 'vocab'

@mephosto
Copy link

参考:#426

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants