问题标签 [roberta-language-model]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
25 浏览

python - 我在哪个程序/界面中运行以下代码?

对于机器学习/NLP 项目,我在 roBERTa 上查看来自 github 的一些代码。我想看看是否能得到相同的结果,然后修改程序以适应我自己的数据。

但是,我不知道如何/在哪里/使用什么程序来运行以下代码:

我尝试了多个程序/终端/jupyter,但似乎无法找出如何正确运行此代码。有人知道如何运行它吗?(我知道我必须更改第一行等中的目录,但现在只会出错。)

0 投票
0 回答
283 浏览

deep-learning - 使用带有 RoBERTa 的 WordPiece 标记化

据我了解,Huggingface库实现的 RoBERTa 模型使用了BPE分词器。这是文档的链接:

RoBERTa 具有与 BERT 相同的架构,但使用字节级 BPE 作为标记器(与 GPT-2 相同)并使用不同的预训练方案

但是,我有一个基于WordPiece标记化的自定义标记器,并且我使用了BertTokenizer

因为我的自定义标记器与我的任务更相关,所以我不喜欢使用 BPE。

当我使用我的自定义标记器从头开始预训练 RoBERTa (RobertaForMaskedLM) 时,MLM 任务的损失比 BPE 的损失要好得多。然而,在微调方面,模型(RobertaForSequenceClassification)表现不佳。我几乎可以肯定问题不在于标记器。我想知道 RobertaForSequenceClassification 的拥抱脸库是否与我的标记器不兼容。

有关微调的详细信息:

任务:具有不平衡标签的多标签分类。

时代:20

损失:BCEWithLogitsLoss()

优化器:Adam,weight_decay_rate:0.01,lr:2e-5,correct_bias:True

F1 和 AUC 非常低,因为标签的输出概率与实际标签不符(即使阈值非常低),这意味着模型无法学习任何东西。

*

注意:使用 BPE 分词器进行预训练和微调的 RoBERTa 比使用自定义分词器进行预训练和微调的 RoBERTa 表现更好,尽管使用自定义分词器的 MLM 的损失要好于 BPE。

0 投票
1 回答
479 浏览

python - Why is my tensorflow Roberta Model unable to train/finetune?

We are trying to finetune / train our RoBERTa model on our own train data. The project is exactly the same as the SemEval-2020 task B on choosing the right reason out of 3 on why a sentence is against common sense. For the past two days we have been struggling with errors, mainly when trying to train/finetune our model. The code we have used comes from https://huggingface.co/transformers/model_doc/roberta.html#robertamodel . Although we have tried to alter this code in multiple ways we can't seem to really start training our model. Our main problem is the data we try to train the model on. We have tried to immediately insert a numpy array or pandas dataframe, but to no avail. Finally we tried to use a tfds. We used the following code, which results in the error code which can be found below.

I install the following packages:

#xA;

I import my train and test sets as csv files, where after the data is cleaned and concatenated.

#xA;

I make a tfds of the train and test data:

#xA;

These data sets are then used to train the model through the following code:

#xA;

This results in the following error:

ValueError: The training dataset must have an asserted cardinality

If anybody has any advice or can point us in the right direction on how to train/finetune our model we would be very grateful!

0 投票
1 回答
415 浏览

python - 如何在 Tensorflow 数据集中给出整数列表作为输入?

我们正在尝试使用 tensorflow 微调/训练预训练的 RoBERTa 模型。为此,我们必须从我们的数据框中创建一个 tf.data.Dataset。

数据框如下所示: 训练数据

其中三个选项是编码字符串,答案是对应于选项 A、B 或 C 的整数。

我们尝试使用以下方法制作一个 tf.dataset:

但是,这不起作用,因为我们收到以下错误:

ValueError:无法将 NumPy 数组转换为张量(不支持的对象类型列表)。

我读过我们不能将列表用作 tf.dtype,我们现在在其中放置了“float32”。但是我们也不能将数据框中的列表转换为浮点数。

如果有人能指出我们正确的方向,我们将不胜感激!提前致谢!

0 投票
0 回答
92 浏览

python - 训练预训练 RoBERTa 的正确输入/形状是什么?

现在我正在尝试训练/微调一个带有多选头部的预训练 RoBERTa 模型,但我很难找到正确的输入,因此我的模型能够训练/微调。

我现在拥有的数据框如下所示: 在此处输入图像描述

使用 3 个选项被标记化的句子,使用:

我的评估集也是这样,测试集有 6500 行,评估集有 1500 行。我正在尝试通过以下方式实现这一点:

但我不断收到不同的键错误,例如:

密钥错误:2526

如果有人知道我做错了什么,我将非常感激,因为我在过去 3 天里一直在努力训练这个模型。

0 投票
2 回答
767 浏览

amazon-ec2 - 在 AWS EC2 上加载 torch.hub.load('pytorch/fairseq', 'roberta.large.mnli') 时出错

我正在尝试在 AWS 上的 EC2 实例上使用 Torch(和 Roberta 语言模型)运行一些代码。编译似乎失败了,有人有修复的指针吗?

确认 Torch 已正确安装

返回:张量([[0.7494, 0.5213, 0.8622],...

尝试加载罗伯塔

然后结束,过了很久。

0 投票
1 回答
2238 浏览

bert-language-model - IndexError:在添加特殊标记后尝试微调 Roberta 模型时,自身的索引超出范围

在向其标记器添加一些特殊标记后,我正在尝试微调 Roberta 模型:

当我尝试训练模型(在 cpu 上)时出现此错误:

ps如果我评论add_special_tokens代码有效。

0 投票
0 回答
77 浏览

bert-language-model - 如何在其他任务中使用微调过的bert模型?

我微调了一个用于序列分类的 bert(或 roberta)模型。我可以为不同的任务(QA 或情绪分析)微调相同的模型吗?

0 投票
1 回答
61 浏览

python-3.x - 在 imdb 电影评论数据集上训练 roberta 模型给出此错误?

NameError:未定义名称“InputExample”

运行这部分代码后,它会出错。请告诉我如何解决这个错误。

0 投票
0 回答
29 浏览

nlp - 如何使用源代码类 RobertaSelfAttention(nn.Module):

我想从下面的代码中获取查询和密钥。这部分来自https://huggingface.co/transformers/_modules/transformers/models/roberta/modeling_roberta.html#RobertaModel最后,我想重现本文 中的图1 有人可以直观地说明他们如何会做吗?