Position Embedding not needed with BERT? #11172
-
Let me start of with that i'm not sure if this is the right place for this question. This question is more focused on NLP and less about spacy. However i couldn't find a other active community to post this question in. If there is one please let me know that i'll take my question there. I'm trying to change this rel component (from spacy) because it was meant more as a tutorial and not meant to be used in production. I want to add more features to it, specifically the sequence of words between two entities. To add the information about the position of a token in a sentence you'd need to add something or do a operation to it's vector.
The question i have is that i'm planning to use a BERT model which already has some positional information in it in the form of positional encoding. Do i still have to add positional information as the input of the rel component? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
This discussion seems like it might fit in the HuggingFace forums, depending on how you approach the problem. Keep in mind that the actual Transformers implementation in spaCy is just HuggingFace Transformers, and If you're using a CNN tok2vec in spaCy, you can specify the token position as one of the attributes in the model config. Because the actual BERT implementation is inside the HuggingFace library, I don't think there's a similar option to control how that's handled in the spaCy config. If you want to add context, take a look at how the EntityLinker is implemented - it uses context to disambiguate entities. When adding context what you do is get a vector representation of the surrounding text. You don't need to explicitly represent positional indices to get a good context representation. Since BERT already has positional information internally, I'm skeptical that adding a more explicit representation would help. |
Beta Was this translation helpful? Give feedback.
This discussion seems like it might fit in the HuggingFace forums, depending on how you approach the problem. Keep in mind that the actual Transformers implementation in spaCy is just HuggingFace Transformers, and
spacy-transformers
is a wrapper around that.If you're using a CNN tok2vec in spaCy, you can specify the token position as one of the attributes in the model config. Because the actual BERT implementation is inside the HuggingFace library, I don't think there's a similar option to control how that's handled in the spaCy config.
If you want to add context, take a look at how the EntityLinker is implemented - it uses context to disambiguate entities. When adding context what you d…