Training command for Dependencies and Relations

Hi, I followed this tutorial to annotate NER as well as the Relation between NER. Then I trained the NER model with command and it worked well. prodigy train ner ner_rels en_vectors_web_lg --init-tok2vec ./tok2vec_cd8_model289.bin -output ./tmp_model --eval-split 0.2

However, when i tried to train the parser model with command, the training result is 0. prodigy train parser ner_rels en_vectors_web_lg --init-tok2vec ./tok2vec_cd8_model289.bin --output ./model

Can you have a look and tell me where the problem might be? The wrong training command or the annotated data.

Hi! The problem here is that you're trying to train a syntactic dependency parser on data collected on entity relationships. These are fundamentally two very different tasks so it's not surprising you're seeing a 0 accuracy score here. The dependency parser just isn't the right fit for this task.

spaCy doesn't currently have a generic built-in relation prediction component because the type of model you want for this can often differ significantly between use cases. But this tutorial of implementing an entity relation component might be a good place to start:

Thanks a lot for the tutorial Ines :slight_smile: . I've gone through it. However, I am slightly confused about how to put Prodigy and this Tutorial together into the pipeline. More specifically,

  • How can i generate the asset/annotations.jsonl from my corpus? If with Prodigy, which annotation tasks are required?

  • After I generated my own asset/annotations.jsonl, can I simply run this tutorial without any change to train my model? If not, which part am I supposed to change?

And currently, I have a corpus with raw sentences in jsonl format. And my goal is to generate my own ontology with my own NER and my own Relation among these NERs. Looking forward to your reply :slight_smile:.

The relation annotations here were created using Prodigy's rel.manual recipe:

Sofie also shows this process in the tutorial video: SPACY v3: Custom trainable relation extraction component - YouTube

Yes, just make sure that you're also training a named entity recognizer that predicts the named entities, which your relation component can then predict the relations for.