Closed YYGe01 closed 2 years ago
已解决, 替换成自定义的model类即可:
class HuggingfacePredictor:
def __init__(self, model_path, schema_file, max_source_length=256, max_target_length=192) -> None:
# self._tokenizer = huggingface_transformers.T5TokenizerFast.from_pretrained(
# model_path)
self._tokenizer = T5BertTokenizer.from_pretrained(model_path)
还有个问题是对于中文的unk词, UIE\uie\extraction\predict_parser\utils.py 中的 fix_unk_from_text函数, 好像不兼容.
您好,
不兼容是指?
您好: 作者您好, 我正在中文数据集上运行 inference.py , 平台为linux, 报错如下: ` Traceback (most recent call last): File "/home/ubuntu/yuyuangen/code/UIE/inference.py", line 163, in
main()
File "/home/ubuntu/yuyuangen/code/UIE/inference.py", line 94, in main
predictor = HuggingfacePredictor(
File "/home/ubuntu/yuyuangen/code/UIE/inference.py", line 38, in init
self._tokenizer = huggingface_transformers.T5TokenizerFast.from_pretrained(
File "/home/ubuntu/anaconda3/envs/uie/lib/python3.8/site-packages/transformers/tokenization_utils_base.py", line 1719, in from_pretrained
return cls._from_pretrained(
File "/home/ubuntu/anaconda3/envs/uie/lib/python3.8/site-packages/transformers/tokenization_utils_base.py", line 1732, in _from_pretrained
slow_tokenizer = (cls.slow_tokenizer_class)._from_pretrained(
File "/home/ubuntu/anaconda3/envs/uie/lib/python3.8/site-packages/transformers/tokenization_utils_base.py", line 1791, in _from_pretrained
tokenizer = cls(*init_inputs, **init_kwargs)
File "/home/ubuntu/anaconda3/envs/uie/lib/python3.8/site-packages/transformers/models/t5/tokenization_t5.py", line 130, in init
self.sp_model.Load(vocab_file)
File "/home/ubuntu/anaconda3/envs/uie/lib/python3.8/site-packages/sentencepiece/init.py", line 367, in Load
return self.LoadFromFile(model_file)
File "/home/ubuntu/anaconda3/envs/uie/lib/python3.8/site-packages/sentencepiece/init.py", line 171, in LoadFromFile
return _sentencepiece.SentencePieceProcessor_LoadFromFile(self, arg)
TypeError: not a string
Process finished with exit code 1 `
配置如下: