我一直在尝试微调拥抱脸(HuggingFace)的对话模式:Blendebot。我尝试了官方拥抱脸网站上给出的传统方法,该网站要求我们使用培训师进行。train()方法。我试着用。compile()方法。我在我的数据集上尝试了使用PyTorch和TensorFlow进行微调。这两种方法似乎都失败了,并给了我们一个错误,即Blenderbot模型没有称为compile或train的方法。我甚至在网上到处查看Blenderbot是如何根据我的自定义数据进行微调的,但它没有正确提到运行时不会出错。我看过Youtube教程、博客和StackOverflow帖子,但没有人回答这个问题。希望有人能在这里回应并帮助我。我也愿意使用其他拥抱式对话模型进行微调。
这是我用来微调blenderbot模型的链接。
微调方法:
https://huggingface.co/docs/transformers/training
Blenderbot:
https://huggingface.co/docs/transformers/model_doc/blenderbot
from transformers import BlenderbotTokenizer, BlenderbotForConditionalGeneration
mname = "facebook/blenderbot-400M-distill"
model = BlenderbotForConditionalGeneration.from_pretrained(mname)
tokenizer = BlenderbotTokenizer.from_pretrained(mname)
#FOR TRAINING:
trainer = Trainer(
model=model,
args=training_args,
train_dataset=small_train_dataset,
eval_dataset=small_eval_dataset,
compute_metrics=compute_metrics,
)
trainer.train()
#OR
model.compile(
optimizer=tf.keras.optimizers.Adam(learning_rate=5e-5),
loss=tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True),
metrics=tf.metrics.SparseCategoricalAccuracy(),
)
model.fit(tf_train_dataset, validation_data=tf_validation_dataset, epochs=3)
这些都不管用。