Blenderbot Finetuning

发布于 2025-02-11 03:55:38 字数 1520 浏览 1 评论 0原文

我一直在尝试微调拥抱面的对话模型:Blendebot。我尝试了在官方拥抱面孔网站上给出的常规方法,该网站要求我们使用Trainer.Train()方法进行操作。我使用.compile()方法尝试了它。我尝试使用pytorch以及数据集中的张量进行微调。这两种方法似乎都失败了,并给我们一个错误,说没有任何方法称为Blenderbot模型的编译或火车。我什至在网上浏览了任何地方,以检查Blenderbot如何在我的自定义数据上进行微调,并且在没有丢失错误的情况下没有正确地提及它。我已经浏览了YouTube教程,博客和Stackoverflow帖子,但没有一个回答这个问题。希望有人在这里回应并帮助我。我也愿意使用其他拥抱面对话模型以及进行微调。

这是我用来微调Blenderbot模型的链接。

微调方法: https://huggingface.co/docs/transformers/transformers/training

blenderbot blenderbot a href =“ https://huggingface.co/docs/transformers/model_doc/blenderbot” rel =“ noreferrer”> https://huggingface.co/docs/transformers/model_doc/blenderblenderbot

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)

这些工作。

I have been trying to fine-tune a conversational model of HuggingFace: Blendebot. I have tried the conventional method given on the official hugging face website which asks us to do it using the trainer.train() method. I tried it using the .compile() method. I have tried fine-tuning using PyTorch as well as TensorFlow on my dataset. Both methods seem to fail and give us an error saying that there is no method called compile or train for the Blenderbot model. I have even looked everywhere online to check how Blenderbot could be fine-tuned on my custom data and nowhere does it mention properly that runs without throwing an error. I have gone through Youtube tutorials, blogs, and StackOverflow posts but none answer this question. Hoping someone would respond here and help me out. I am open to using other HuggingFace Conversational Models as well for fine-tuning.

Here is a link I am using to fine-tune the blenderbot model.

Fine-tuning methods: 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)

None of these work.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

笑脸一如从前 2025-02-18 03:55:38

也许尝试使用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(),
)
....

请参阅“ nofollow noreferrer”> docs 以获取更多信息。

Maybe try using the TFBlenderbotForConditionalGeneration class for Tensorflow. It has what you need:

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(),
)
....

See the docs for more information.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文