Skip to content

loko-ai/zero_shot_ext

Repository files navigation

Zero Shot Classifier


Zero Shot Classifier extension performs multilingual text classification without any previous training. It allows to set the output labels directly from the block configuration:

The first time you run your flow, the extension automatically downloads the requested model. Once the model is loaded in memory, output results will be faster.

Example:

Input:

Il vostro prodotto è meraviglioso

Output:

{
    "labels": [
        "positive",
        "neutral",
        "negative"
        ],
    "scores": [
        0.9860814213752747,
        0.007435222622007132,
        0.0064834230579435825
        ],
    "sequence": "Il vostro prodotto è meraviglioso"
}

Configuration

In the file config.json you can set the Hugging Face model (you can find the available models here), your Hugging Face token and where to mount your Hugging Face volume (all the downloaded models will be saved in this directory):

{
  "main": {
    "environment": {
      "HF_TOKEN": "<insert your HF token here>",
      "HF_MODEL": "joeddav/xlm-roberta-large-xnli"
    },
      "volumes": [
        "/var/opt/huggingface:/root/.cache/huggingface"
      ]
    }
}

Note: you can drop the HF_TOKEN variable if your model does not require authentication, otherwise you have to sign up and create your Access Token.