使用 Bert 预测多个 token

Use Bert to predict multiple tokens

我正在寻找有关使用 Bert 和 Bert 的屏蔽语言模型来预测多个标记的建议。

我的数据如下:

上下文:some very long context paragraph

问题:rainy days lead to @placeholder 这个 @placeholder 的答案是 wet weather。在模型中,wet environment 是要预测的答案。

所以在预处理阶段,我应该把文本改成rainy days lead to [MASK]还是类似rainy days lead to [MASK] [MASK]的东西?我知道 masked LM 在单 token 预测上效果很好,你认为 masked LM 在多 token 预测上效果好吗?如果没有,您对如何预处理和训练这类数据有什么建议吗?

非常感谢!

所以有3个问题:

首先,

So at the pre-processing stage, should I change the text into rainy days lead to [MASK] or something like rainy days lead to [MASK] [MASK]?

从字面上看,你应该设置[MASK][MASK]。但请记住,在 BERT 中,mask 是从 token 的角度设置的。事实上,'wet weather' 可能被标记为:[wet] [weath] [##er],在这种情况下,你应该有 [MASK] [MASK] [MASK]。所以每个令牌一个 [MASK]。

第二,

I know that the masked LM works well on the single token prediction, do you think the masked LM can work well on the multiple tokens prediction?

正如您在 the original paper 中看到的那样,他们说:

The training data generator chooses 15% of the token positions at random for prediction. If the i-th token is chosen, we replace the i-th token with (1) the [MASK] token 80% of the time (2) a random token 10% of the time (3) the unchanged i-th token 10% of the time.

他们注意到每个句子的 MASKED token 数量没有限制,在预训练 BERT 期间你有几个 MASKED token。 根据我自己的经验,我对 BERT 进行了多次预训练,我注意到如果我的输入中只有一个或多个 MASKED 令牌,则对 MASKED 令牌所做的预测几乎没有差异。

第三,

If no, do you have any suggestions on how to pre-process and train this kind of data?

所以答案是肯定的,但如果你真的想屏蔽你选择的元素(而不是像论文中那样随机),你应该在数据被标记化时调整 MASK,因为 MASKED 标记的数量将是大于(或等于)您设置的单词 space 中 MASK 的数量(就像我给您的示例:1 个单词不等于 1 个标记,所以基本上,1 个 MASKED 单词将是 1 个或更多 MASK 标记).但老实说,标签化的过程将是如此巨大,我建议你增加 MASK tokien 的 15% 概率,或者为每个 MASKED 标记(或类似的东西)做一个 MASK 1 或 2 下一个标记的过程..