Loading pre-annotated data that has multiple sub-labels per word


I currently have pre-annotated data that has words that require multiple labels in a hierarchical format. EX:

Text: "I took tylenol."

Tylenol - Label: Medication
Tylenol - Sub-label: Polar
Tylenol - Sub-label: Generic

Currently the format to load this in a single label is:

'text': 'I took tylenol.',
'tokens': etc.. ,

This format loaded in using prodigy mark as a JSONL will highlight Tylenol as the medication which is a great first step. How can I edit this format to include the multiple sub-labels on the same word?


Traditionally, NER annotation in Prodigy allows only one label per token.

However, for Prodigy 1.11, we've created a new recipe spans.manual that will allow you to annotate overlapping and nested spans. Your input would look something like this (added newlines for readability but those wouldn't be in your JSONL file):

{"text":"I took tylenol.",



And then with

prodigy spans.manual my_output blank:en input.jsonl -l Medication,Generic

those spans would be preannotated:


For more information on the upcoming 1.11 release, currently available as a "nightly" release, see this thread: ✨ Prodigy nightly: spaCy v3 support, UI for overlapping spans, improved feeds & more

1 Like