get rid of toggle in choice interface

So I have a text classification problem where there are multiple classes for each text. Do you have an established interface for this?

For instance, the text “What is your name and address?” Would get the labels of : request_address, request_name.

Is there an easy fix to so to manual textcat that I can choose multiple labels?

Also, I want to confirm that the current textcat model will work with the multiclass case because you are not taking a softmax over all the labels, but a prediction for each label … correct?

Thanks!

edit: I reread Ines comments - she says to use "choice_style": "multiple" in your config but I am having no luck with this. Maybe I am confused where this should go …

Not 100% sure this is what you're asking, but could the "choice_style": "multiple" do what you need?

For your other question:

In theory yes, that's correct --- that's how the model works, although we haven't tested this well with a choice interface for textcat. So if your results seem to not make sense, it's possible we have a bug in the data transformation around the multiple labels.

Maybe I’m confused about where “config” is …
for custom recipes would I do something like:


@prodigy.recipe('textcat_manual_multilabel',
    dataset=prodigy.recipe_args['dataset'],
    file_path=("Path to texts", "positional", None, str),
    label=prodigy.recipe_args['label'])
def textcat_manual_multilabel(dataset, file_path,label):
    """Annotate the sentiment of texts using different mood options."""
    stream = JSONL(file_path)     # load in the JSONL file
    stream = add_options(stream,label)  # add options to each task
    
    return {
        'dataset': dataset,   # save annotations in this dataset
        'view_id': 'choice',  # use the choice interface
        "choice_style": "multiple",
        'stream': stream,
    }

This does not seam to be working.

If I’m using textcat.teach can I pass --choice_style multiple flag?

thanks!

Ah, sorry if this was confusing. Your code is almost correct– the config just needs to be within a dictionary 'config', for example:

return {
    'dataset': dataset,   # save annotations in this dataset
    'view_id': 'choice',  # use the choice interface
    'stream': stream,
    'config': {
        'choice_style': 'multiple'
    }
}

Since you're using a custom recipe, you can also add your own custom arguments if you want to toggle single/multiple choice from the command line. The following will let you set a boolean flag --multiple or -m:

@prodigy.recipe('textcat_manual_multilabel',
    dataset=prodigy.recipe_args['dataset'],
    file_path=("Path to texts", "positional", None, str),
    label=prodigy.recipe_args['label'],
    multiple=("Multiple choice", "flag", "m", bool))
def textcat_manual_multilabel(dataset, file_path,label, multiple=False):
    # your code here
    return {
        # your other return values here
        'config': {
            'choice_style': 'multiple' if multiple else 'single'
        }
    }

You can be as creative with the recipe arguments as you like :slightly_smiling_face:

Can you point me to the documentation for the possible options for configuration …

Does the default textcat.teach work consistently with allowing multiple labels for each text?

Thanks, you guys are a big help!