ner.teach not filtering by label when using prodigy.serve

I’ve run into a weird issue where if I run ner.teach using prodigy.serve, the label filtering does not work and I see entities of all types. If I run it from the command like like normal, the filtering does work. Any idea what’s going on? I’m including the two commands below.

prodigy.serve("ner.teach", "multiuser_test", "en_core_web_sm", 
                  "LOC/LOC.jsonl", label = "LOC", port=9000)
prodigy ner.teach multiuser_test en_core_web_sm  LOC/LOC.jsonl --label LOC

Ah, I think I know what the problem might be: Try setting all recipe arguments as positional arguments in the order of argument annotations, and use None for the ones you don’t want to set, e.g.:

prodigy.serve("ner.teach", "multiuser_test", "en_core_web_sm", 
              "LOC/LOC.jsonl", None, None, "LOC", port=9000)

The way this is currently handled is probably not ideal – the positional arguments are passed into the recipe, while the keyword arguments are used as the recipe config. Instead, prodigy.serve should probably allow specifying the recipe arguments as positional arguments and keyword arguments, and take an optional config keyword argument that’s not passed into the recipe.

That gives me this error:

✨  ERROR: Can't find label 'L' in model en_core_web_sm

I can fix that by changing lines 90 and 91 of ner.py to

        for l in label.split(","):
            if not model.has_label(l.strip()):

Then everything starts and it’s correctly filtered. The sidebar on the page says “L,O,C”, but it looks like that’s an easy fix in line 119.

Thanks!

Note that this solution then breaks regular CLI calls to ner.teach