Enabling both "Assign relations" and "Select spans" in custom relations recipe

Hi!

I've written a custom recipe with the blocks API to do relation extraction. It works well and serves the results of a separately trained NER model as spans. However I'd like the ability for the user to "select spans" to correct mistakes in the NER model as seen in the "Relations & Spans" live demo.

What I want:

What I have:

I've tried passing a span-labels argument to the config (see below) but that didn't work.

blocks = [
    {"view_id": "relations", "labels": ["Within the", "Near the"], "wrap": True, 
     "span-labels": ["PATHOLOGY", "DESCRIPTOR", "LOCATION"]}
]
return {
    "view_id": "blocks",
    "dataset": dataset,  # Name of dataset to save annotations
    "stream": get_stream(),  # Incoming stream of examples
    "config": { "blocks": blocks}
}

Thanks in advance!

Hi! I think you just have a small typo in your config: the setting is called relations_span_labels. Also see here for the available configuration options for the relations UI: https://prodi.gy/docs/api-interfaces#relations-settings

Hi @ines, thanks for the quick reply. Changing the setting to relations_span_labels did not work unfortunately. Any other ideas? As feedback, maybe when using the blocks API an error should be raised when a key does not match a known setting as it does when not using the blocks API

Ah, I think you need to return the labels in the "config" returned by the recipe – they're currently not read from the block itself (because it's a setting that only applies to one single interface, unlike labels).

This makes sense – it's just a bit tricky, because each block allows you to override any arbitrary property on your task. So Prodigy can't really know what it is, because you can structure your JSON however you like.

Thanks! got it to work, for reference this is the code that worked

blocks = [
    {"view_id": "relations"}
]
return {
    "view_id": "blocks",
    "dataset": dataset,  # Name of dataset to save annotations
    "stream": get_stream(),  # Incoming stream of examples
    "config": {"blocks": blocks,
               "labels": ["Within the", "Near the"],
               "relations_span_labels": ["PATHOLOGY", "DESCRIPTOR", "LOCATION"]}
}
1 Like