我有深度微调模型。是否有一种方法可以转换为变形器可以使用的模型(https://github.com/huggingface/transformers)?
下面是如何从DeepPavlov模型中获得高频变压器模型的方法:
from deeppavlov import build_model, configs
m = build_model(configs.classifiers.insults_kaggle_bert_torch, download=True)
m.pipe
包含管道的所有元素:
[(([], ['x']),
['bert_features'],
<deeppavlov.models.preprocessors.torch_transformers_preprocessor.TorchTransformersPreprocessor at 0x7f9b0414e550>),
(([], ['bert_features']),
['y_pred_probas'],
<deeppavlov.models.torch_bert.torch_transformers_classifier.TorchTransformersClassifierModel at 0x7f9ae5625ac8>),
(([], ['y_pred_probas']),
['y_pred_ids'],
<deeppavlov.models.classifiers.proba2labels.Proba2Labels at 0x7f9ae56221d0>),
(([], ['y_pred_ids']),
['y_pred_labels'],
<deeppavlov.core.data.simple_vocab.SimpleVocabulary at 0x7f9abddfe470>)]
你可以用
获取TorchTransformersClassifierModelm.pipe[1][2]
并从中得到高频变压器模型:
hf_model = m.pipe[1][2].model
hf_model
是PyTorchnn.Module
,您可以像往常一样使用它。