Trying to add doc.sents to rel_component example's get_instances function #12680
-
Hello, File "C:\rel-model\scripts\rel_model.py", line 79, in get_instances Here are my modifications to the config file What do I have to do to include the sents from the parser or sentencizer in training this rel_component model so that I can access them in the model's get_instances function? Thank You! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
Could you paste your full config? |
Beta Was this translation helpful? Give feedback.
-
Thanks for your response @shadeMe. I will try these suggestions and let you know how it turns out.
This happens in the "get_loss" function when calculating the gradient |
Beta Was this translation helpful? Give feedback.
-
Hello @shadeMe, I modified the config as below according to your suggestions, so the model will tain fine as long as I don't try to loop through the doc.sents in the get_instences function, otherwise I get a "ValueError: operands could not be broadcast together with shapes (200,36) (196,36)" Config:[paths] [system] [nlp] [components] [components.tok2vec] [components.tok2vec.model] [components.parser] [components.relation_extractor] [components.relation_extractor.model] [components.relation_extractor.model.create_instance_tensor] [components.relation_extractor.model.create_instance_tensor.tok2vec] [components.relation_extractor.model.create_instance_tensor.pooling] [components.relation_extractor.model.create_instance_tensor.get_instances] [components.relation_extractor.model.classification_layer] [initialize] [initialize.before_init] [initialize.components] [corpora] [corpora.dev] [corpora.train] [training] [training.batcher] [training.batcher.size] [training.optimizer] [training.score_weights] Modified the get_instences function to loop through doc.sents
Training stops after first epoch with this errorE # LOSS TOK2VEC LOSS RELAT... DEP_UAS DEP_LAS SENTS_F REL_MICRO_P REL_MICRO_R REL_MICRO_F SCORE |
Beta Was this translation helpful? Give feedback.
I'd suggest doing the following:
replace_listeners
for the sourced parser so that it gets its own copy of thetok2vec
layer.tok2vec
from the frozen and annotating components so that it's just used forrelation_extractor
.tok2vec
hasinclude_static_vectors = true
so that it's using the vectors that have been included fromen_core_web_lg
.