# Can't get labels to be shown.

**URL:** <https://support.prodi.gy/t/cant-get-labels-to-be-shown/2866>\
**Category:** Uncategorized\
**Tags:** solved, usage, done, docs, textcat\
**Created:** [May 4, 2020, 6:17pm UTC](https://support.prodi.gy/t/cant-get-labels-to-be-shown/2866 "2020-05-04T18:17:02Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![steffres](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/steffres/32/1374_2.png) [@steffres](https://support.prodi.gy/u/steffres)\
**Post date:** [May 4, 2020, 6:17pm UTC](https://support.prodi.gy/t/cant-get-labels-to-be-shown/2866/1 "2020-05-04T18:17:02Z")

</div>

I'm trying to set up a multi label text classification but fail at the basics of replicating and modifying recipes from this repo [https://github.com/explosion/prodigy-recipes](https://github.com/explosion/prodigy-recipes)

**Firstly: Problems with basic examples**

I can't get the a provided recipe running as communicated in the repo. There it says to run (as an example NER):

```python
python -m prodigy -F prodigy-recipes/ner/ner_teach.py

```

which results in this error:

```python
✘ Can't find recipe or command '-F'.
Run prodigy --help to see available options

```

Could this be outdated? Since all the other run commands I've seen around prodigy documentation mostly pass further arguments such as datasets, models, sources, etc. Addiationally the method signature (and decorator arguments) in `ner_teach.py` also indicates the need to pass arguments in the command line.

**Secondly: Problems with adapting examples**

Now, since I need text classification I've run the textcat\_\* scripts in the repo without arguments, to no avail, and then with arguments. In order to zero in on error causes I've cut away a lot of code from the original function. After that and after running with respective arguments in the command line a prodigy instance is successfully started up and sample text is correctly loaded, however the label choice form is missing.

The code is this:

```python
import prodigy
from prodigy.components.loaders import JSONL
from prodigy.models.textcat import TextClassifier
from prodigy.util import split_string
import spacy
from typing import List, Optional

@prodigy.recipe(
    "foo_cat",
    dataset=("The dataset to use", "positional", None, str),
    spacy_model=("The base model", "positional", None, str),
    source=("The source data as a JSONL file", "positional", None, str),
    label=("One or more comma-separated labels", "option", "l", split_string),
)
def foo_cat(
    dataset: str,
    spacy_model: str,
    source: str,
    label: Optional[List[str]] = None,
):
    nlp = spacy.load(spacy_model)
    model = TextClassifier(nlp, label)
    update = model.update
    stream = JSONL(source)

    return {
        "view_id": "classification",
        "dataset": dataset,
        "stream": stream,
        "update": update,
    }

```

and the command is this:

```python
prodigy foo_cat some_dataset "de_core_news_sm" news_headlines.jsonl -F prodigy-recipes/textcat/foo_cat.py --label bla,ble,blo

```

Which runs and results in the web server looking like this:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/prodigy/original/2X/7/706bcb6ec0e62cf050a378d4aa28c5fea67d650a.png)

And here the label choice form is missing. I'd like to have a non-mutually-exclusive form like this here: [https://prodi.gy/docs/text-classification#manual](https://prodi.gy/docs/text-classification#manual)

How to do this please?

prodigy stats:

```python
============================== ✨ Prodigy Stats ==============================

Version 1.9.9                         
Location /home/steff-vm/mara/acdh-prodigy-utils/venv/lib/python3.6/site-packages/prodigy
Prodigy Home /home/steff-vm/.prodigy       
Platform Linux-5.3.0-51-generic-x86_64-with-Ubuntu-18.04-bionic
Python Version 3.6.9                         
Database Name SQLite                        
Database Id sqlite                        
Total Datasets 9                             
Total Sessions 105                           

```

Cheers,  
Stefan

---

<div class="post-metadata">

**Author:** ![ines](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/ines/32/3_2.png) [@ines](https://support.prodi.gy/u/ines)\
**Post date:** [May 4, 2020, 6:55pm UTC](https://support.prodi.gy/t/cant-get-labels-to-be-shown/2866/2 "2020-05-04T18:55:43Z")

</div>

Hi! I just had a look at the README and it's true that this example is a bit unfortunate – I think it was supposed to have a `...` to indicate the respective settings, but I just updated it to show an example command with example arguments.

> [@steffres](#):
>
> I can't get the a provided recipe running as communicated in the repo. There it says to run (as an example NER):

Yes, in addition to just the `-F` pointing to the path, you do have to provide the name of the recipe and the arguments it needs. Otherwise, Prodigy can't know which recipe in the file you want to run (there can be multiple) and how the recipe should be configured. Also see the custom recipes documentation here: [Custom Recipes · Prodigy · An annotation tool for AI, Machine Learning & NLP](https://prodi.gy/docs/custom-recipes)

For the recipe in [`ner_teach.py`](https://github.com/explosion/prodigy-recipes/blob/master/ner/ner_teach.py), that could look like this:

```bash
prodigy ner.teach your_dataset en_core_web_sm ./data.jsonl --label PERSON -F ./ner_teach.py

```

> [@steffres](#):
>
> After that and after running with respective arguments in the command line a prodigy instance is successfully started up and sample text is correctly loaded, however the label choice form is missing.

The problem here is that you're not actually using the model to process any examples in your stream or to add the labels – the recipe is just using the `JSONL` loader to load the incoming examples and then returns those. The examples don't have a `"label"`, so it's not shown in the UI.

So how you set up the recipe depends on what you want – if you want the model to apply labels, you probably want something more similar to the `textcat.teach` example. Or if you just want to show examples with a pre-defined label, you can add it to each outgoing example, e.g. like this:

```python
def get_stream():
    stream = JSONL(source)
    for eg in stream:
        eg["label"] = label
        yield eg

```

> [@steffres](#):
>
> And here the label choice form is missing. I'd like to have a non-mutually-exclusive form like this here: [Text Classification · Prodigy · An annotation tool for AI, Machine Learning & NLP](https://prodi.gy/docs/text-classification#manual)

The choice UI uses the `choice` interface. You can see examples of the data format it expects and the config options here: [Annotation interfaces · Prodigy · An annotation tool for AI, Machine Learning & NLP](https://prodi.gy/docs/api-interfaces#choice)

The recipes repo also has an example script using it here: [https://github.com/explosion/prodigy-recipes/blob/master/other/choice.py](https://github.com/explosion/prodigy-recipes/blob/master/other/choice.py)

And the custom recipes docs have an example that shows how to put together a workflow with multiple choice options: [Custom Recipes · Prodigy · An annotation tool for AI, Machine Learning & NLP](https://prodi.gy/docs/custom-recipes)

---

<div class="post-metadata">

**Author:** ![steffres](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/steffres/32/1374_2.png) [@steffres](https://support.prodi.gy/u/steffres)\
**Post date:** [May 25, 2020, 11:08am UTC](https://support.prodi.gy/t/cant-get-labels-to-be-shown/2866/3 "2020-05-25T11:08:06Z")

</div>

Thanks Ines, that did mostly resolve my questions. But now I'm still struggling to get the choice view\_id to show the labels als non-mutually exclusive (as it even should be set by default according to the docs).

So, the reduced code is this:

```python
import prodigy

def foo_stream():

    options = [
        {"id": "option_a", "text": "option_a"},
        {"id": "option_b", "text": "option_b"},
        {"id": "option_c", "text": "option_c"},
    ]

    yield {"text": "text 1", "options": options}
    yield {"text": "text 2", "options": options}
    yield {"text": "text 3", "options": options}

@prodigy.recipe(
    "choice",
)
def choice():

    return {
        "view_id": "choice",
        "dataset": "some_dataset",
        "stream": foo_stream(),
        "config": {
            "choice_style": "multiple",
            "choice_auto_accept": True,
        },
    }

```

Which would display the options correctly, but shows them in a mutually exclusive manner, i.e. only one option can be selected at all times. What is it that I'm doing wrong here?

---

<div class="post-metadata">

**Author:** ![ines](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/ines/32/3_2.png) [@ines](https://support.prodi.gy/u/ines)\
**Post date:** [May 26, 2020, 8:47am UTC](https://support.prodi.gy/t/cant-get-labels-to-be-shown/2866/4 "2020-05-26T08:47:55Z")

</div>

> [@steffres](#):
>
> Which would display the options correctly, but shows them in a mutually exclusive manner, i.e. only one option can be selected at all times. What is it that I'm doing wrong here?

It looks like in your config, you're setting `"choice_style": "multiple"`, which makes the interface accept multiple selections at the same time. If you set it to `"single"` (or remove that line alltogether), you'll only be able to select one option.

---

<div class="post-metadata">

**Author:** ![steffres](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/steffres/32/1374_2.png) [@steffres](https://support.prodi.gy/u/steffres)\
**Post date:** [May 27, 2020, 6:45am UTC](https://support.prodi.gy/t/cant-get-labels-to-be-shown/2866/5 "2020-05-27T06:45:50Z")

</div>

The other way around: It is showing the options as single, i.e. mutually exclusive, but I want it to be multiple, non-mutually exclusive.

This is the browser UI resulting from the code from above, where as I take it from your docs, the round radio buttons mean mutually exclusive options (and of course they do act like that - but that can not be displayed here):

 ![image](https://us1.discourse-cdn.com/flex020/uploads/prodigy/original/2X/8/803e29a9dd578bfb2813bb2c3f0fd3b0a6b19aec.png)

---

<div class="post-metadata">

**Author:** ![ines](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/ines/32/3_2.png) [@ines](https://support.prodi.gy/u/ines)\
**Post date:** [May 27, 2020, 11:13am UTC](https://support.prodi.gy/t/cant-get-labels-to-be-shown/2866/6 "2020-05-27T11:13:47Z")

</div>

> [@steffres](#):
>
> The other way around: It is showing the options as single, i.e. mutually exclusive, but I want it to be multiple, non-mutually exclusive.

Ahh, misread the question, sorry! Check if your global or local `prodigy.json` overrides the `"choice_style"` value then and if so, remove that entry. The global and local config lets you overwrite recipe defaults, but if it overrides stuff like `"choice_style"`, this will apply to all recipes and is typically not what you want.

---

<div class="post-metadata">

**Author:** ![steffres](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/steffres/32/1374_2.png) [@steffres](https://support.prodi.gy/u/steffres)\
**Post date:** [May 28, 2020, 11:37am UTC](https://support.prodi.gy/t/cant-get-labels-to-be-shown/2866/7 "2020-05-28T11:37:07Z")

</div>

That was it. Thank you Ines!
