我一直在尝试微调HuggingFace的会话模型:混合体。我尝试了官方拥抱脸网站上给出的传统方法,它要求我们使用trainer.train()方法。我使用.compile()方法进行了尝试。我尝试过使用PyTorch和TensorFlow对我的数据集进行微调。这两种方法似乎都失败了,并给出了一个错误,说明没有名为Blenderbot模型的编译或训练方法。我甚至在网上到处查看Blenderbot是如何对我的自定义数据进行微调的,但是它没有正确地提到运行时没有抛出一个错误。我已经浏览过Youtube教程、博客和StackOverflow帖子,但没有人回答这个问题。希望有人能在这里回应并帮助我。我也愿意使用其他HuggingFace会话模型进行微调。
下面是我用来微调blenderbot模型的链接。
微调方法:https://huggingface.co/docs/transformers/training
布兰德机器人: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)这些都不管用。
发布于 2022-06-28 06:46:45
也许可以尝试将TFBlenderbotForConditionalGeneration类用于Tensorflow。它有你需要的东西:
import tensorflow as tf
from transformers import BlenderbotTokenizer, TFBlenderbotForConditionalGeneration
mname = "facebook/blenderbot-400M-distill"
model = TFBlenderbotForConditionalGeneration.from_pretrained(mname)
tokenizer = BlenderbotTokenizer.from_pretrained(mname)
model.compile(
optimizer=tf.keras.optimizers.Adam(learning_rate=5e-5),
loss=tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True),
metrics=tf.metrics.SparseCategoricalAccuracy(),
)
....有关更多信息,请参见文档。
https://stackoverflow.com/questions/72776834
复制相似问题