Can´t use Extension attributes in Tok2Vec #6527
-
First of all, thanks for this awesome library. I´m trying to use a custom attr in the Tok2Vec. I registered it according to https://nightly.spacy.io/usage/processing-pipelines#custom-components-attributes , but I can´t use it from tok2vec. Did I did something wrong? I How to reproduce the behaviour
Error traceback
Your EnvironmentPython 3.8 with Spacy compiled from Today (12/08/2020) v3 branch version. |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 3 replies
-
This problem is related to #5382 The problem I´m trying to solve is that my NER need to have some external features from the document layout. Such as is_bold, is_italic, .... |
Beta Was this translation helpful? Give feedback.
-
Yes, that's the same underlying reason. In order to be fast, the provided You could implement an alternate hash embed with a custom feature extractor that can access custom attributes (the main drawback is that it will be slower), but we haven't provided this with the library (...yet?). It could look similar to how the spaCy/spacy/ml/featureextractor.py Lines 8 to 28 in 8921364 One of the tricky parts would be dealing with arbitrary data types in custom extensions. For |
Beta Was this translation helpful? Give feedback.
-
@adrianeboyd I just did this, created a custom feature extractor, and it is working great.
|
Beta Was this translation helpful? Give feedback.
-
Great, it's nice to hear that it was easy to extend and customize! It's ones of the things we wanted to make a lot easier in v3. |
Beta Was this translation helpful? Give feedback.
-
Was there a clean implementation of this in v3? ie/ I want to include a CUSTOM_ATTRIBUTE in my MultiHashEmbed in the tok2vec such that I can get more accurate NER classifications (ie/ include html tag info). (I prefer the statistical hashes rather then direct matches). |
Beta Was this translation helpful? Give feedback.
-
I wanted to use custom attributes,how to use https://spacy.io/usage/processing-pipelines#custom-components-attributes and train using the CLI ?If possible can you give us a small example |
Beta Was this translation helpful? Give feedback.
@adrianeboyd I just did this, created a custom feature extractor, and it is working great.
For future users, here is the Custom feature extractor code: