# Is it possible to use model-in-the-loop with multi text classification using the "choice" view\_id?

**URL:** https://support.prodi.gy/t/is-it-possible-to-use-model-in-the-loop-with-multi-text-classification-using-the-choice-view-id/2987
**Category:** Uncategorized
**Tags:** solved, usage, textcat
**Created:** [June 4, 2020, 5:51pm UTC](https://support.prodi.gy/t/is-it-possible-to-use-model-in-the-loop-with-multi-text-classification-using-the-choice-view-id/2987 "2020-06-04T17:51:14Z")
**Posts on this page:** 1
**Showing post:** 3

<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: [June 11, 2020, 5:28pm UTC](https://support.prodi.gy/t/is-it-possible-to-use-model-in-the-loop-with-multi-text-classification-using-the-choice-view-id/2987/3 "2020-06-11T17:28:03Z")

</div>

Thank you Ines, I could get it working with what is exemplified by this code:

```python
import prodigy
import spacy

def get_basic_text_stream():

    yield "The story so far:"
    yield "In the beginning the Universe was created."
    yield "This has made a lot of people very angry "
    yield "and been widely regarded as a bad move."

choice_options = [
    {"id": 0, "text": "category A"},
    {"id": 1, "text": "category B"},
    {"id": 2, "text": "category C"},
]

def stream_pre_annotated():

    nlp = spacy.blank("en")
    nlp.add_pipe(nlp.create_pipe("textcat"))
    nlp.from_disk("./dummy_model")

    options = choice_options

    for text in get_basic_text_stream():

        cat_scores = nlp(text).cats
        options_accepted = []

        for o in options:
            if cat_scores[o["text"]] >= 0.5:
                options_accepted.append(o["id"])

        yield {
            "text": text,
            "options": options,
            "accept": options_accepted
        }

@prodigy.recipe("prodigy_textcat_pre_annotated_id")
def custom_recipe():

    return {
        "view_id": "choice",
        "dataset": "prodigy_standalone_dataset",
        "stream": stream_pre_annotated(),
        "config": {"choice_style": "multiple"}
    }

prodigy.serve("prodigy_textcat_pre_annotated_id")

```

---

_[View the full topic](https://support.prodi.gy/t/is-it-possible-to-use-model-in-the-loop-with-multi-text-classification-using-the-choice-view-id/2987)._
