最大位置嵌入BERT
我现在正在学习伯特。
我认为由于内存问题,BERT限制位置嵌入为512。 但是,当我在拥抱脸上查找Bert代码时,我在Config上找到了此参数。
max_position_embeddings:此模型可能的最大序列长度 永远使用。通常将其设置为大的东西,以防万一 (例如512或1024或2048)。
据我了解,Bert可以拥有1024、2048的1024、2048,超过512。 我不明白这是怎么可能的。
有人可以更详细地解释它吗?
I'm studying BERT right now.
I thought BERT limits position embedding as 512 because of the memory problem.
However, when I look up the BERT code in hugging face I found this parameter on config.
max_position_embeddings: The maximum sequence length that this model might
ever be used with. Typically set this to something large just in case
(e.g., 512 or 1024 or 2048).
As I understand this, BERT can have 1024, 2048 which are over 512.
I don't understand how this is possible.
Could someone explains it in more detail of it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
训练BERT模型时,您可以决定最大的长度。但是,一旦模型训练(或预训练),就无法更改最大长度。 Bert使用学习的位置嵌入,因此仅学习了512以上位置的嵌入。
变形金刚需要序列处理的内存会随序列长度二次增长,因此限制预先限制序列长度是有意义的。
When training your BERT model, you can decide on whatever maximum length you want. However, you cannot change the maximum length once the model is trained (or pre-trained). BERT uses learned position embeddings, so embeddings for positions beyond 512 are just not learned.
The memory that Transformers need for sequence processing grows quadratically with the sequence length, so it makes sense to limit the sequence length in advance.