微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Bert句子变形器在微调期间停止/退出

如何解决Bert句子变形器在微调期间停止/退出

我正在按照BERT指令进行微调,如here

所述

这是我的代码

from sentence_transformers import SentenceTransformer,SentencesDataset,InputExample,losses,evaluation
from torch.utils.data import DataLoader

# load model
embedder = SentenceTransformer('bert-large-nli-mean-tokens')
print("embedder loaded...")

# define your train dataset,the DataLoader,and the train loss
train_dataset = SentencesDataset(x_sample["input"].tolist(),embedder)
train_DataLoader = DataLoader(train_dataset,shuffle=False,batch_size=16)
train_loss = losses.CosinesimilarityLoss(embedder)

sentences1 = ['This list contains the first column','With your sentences','You want your model to evaluate on']
sentences2 = ['Sentences contains the other column','The evaluator matches sentences1[i] with sentences2[i]','Compute the cosine similarity and compares it to scores[i]']
scores = [0.3,0.6,0.2]
evaluator = evaluation.EmbeddingSimilarityEvaluator(sentences1,sentences2,scores)

# tune the model
embedder.fit(train_objectives=[(train_DataLoader,train_loss)],epochs=1,warmup_steps=100,evaluator=evaluator,evaluation_steps=1)

在4%的情况下,培训停止并且程序存在,没有警告或错误。没有输出

我不知道如何进行故障排除-任何帮助都会很棒。

编辑:将标题从失败更改为停止/退出,因为我不知道它是否失败

这是我在终端上看到的内容: 时期:0%| 被杀:0%|

“杀死”一词与“迭代”一词重叠...也许是内存问题?仅供参考:我是在Windows的ubuntu vm上使用wsl在vscode的终端上运行它的

在github上发现了问题: https://github.com/ElderResearch/gpu_docker/issues/38

解决方法

我的解决方案是将批处理和工作程序设置为一个,而且速度很慢

HttpWebRequest.AllowWriteStreamBuffering = false

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。