Python,Fast Bert,使用预先训练的模型进行预测

Python,Fast Bert,使用预先训练的模型进行预测,python,tensorflow,nlp,pytorch,bert-language-model,Python,Tensorflow,Nlp,Pytorch,Bert Language Model,我正在使用快速伯特软件包来训练伯特模型。 快速保存模型输出以下文件: -Resources -- config.json -- pytorch_model.bin -- specail_tokens_map.json -- tokenizer_config.json -- vocab.txt -- events.out.tfevents.1601151257 (1).ffce4853f2c9 我尝试加载到模型并使用它来预测,同样使用fast bert: 来自fast\u bert.predic

我正在使用快速伯特软件包来训练伯特模型。 快速保存模型输出以下文件:

-Resources
-- config.json
-- pytorch_model.bin
-- specail_tokens_map.json
-- tokenizer_config.json
-- vocab.txt
-- events.out.tfevents.1601151257 (1).ffce4853f2c9
我尝试加载到模型并使用它来预测,同样使用fast bert:

来自fast\u bert.prediction导入BertClassificationPredictor
def预测器(文本,模型路径=无):
"""
:param MODEL_PATH:训练模型的路径
:键入文本:列表
:param:text:运行预测的文本
"""
模型路径='/content/Resources/'
LABEL_DATA='/content/DATA/'#与培训时的路径相同,因此它是有效的
如果模型路径为“无”:
raise LookupError(“此路径错误或不存在经过训练的模型”)
预测器=分类预测器(
模型路径=模型路径,
label_path=label_数据,#labels.csv文件的位置
多重标签=假,
型号\u type='xlnet',
do_lower_case=False)
#批量预测
多个预测=预测器。预测批次(文本)
pprint((“预测文本准确性”),多个预测)
返回多个_预测
因此,我得到以下错误:

OSError: Unable to load weights from pytorch checkpoint file. If you tried to load a PyTorch model from a TF 2.0 checkpoint, please set from_tf=True.