Configure a Text Classification Model

A container administrator can configure a text classification model in the container configuration file. The exact configuration depends on the model type and runtime.

The following example shows a vLLM model configured for text classification:

{
  "models": [
    {
      "name": "twitter-roberta-base-sentiment-latest",
      "path": "cardiffnlp/twitter-roberta-base-sentiment-latest",
      "runtime": "vllm",
      "capabilities": ["TEXT_CLASSIFICATION"]
    }
  ]
}

For ONNX models, the service derives the classification capability from the validated model function and metadata.

The following examples provide sample configurations for reranking models using the vLLM and ONNX runtimes, respectively:

The following example sends a request to the /classify API endpoint, asking the sentiment model to classify the sentiment of the two given inputs. Ensure any model specified in a request to /classify is configured for TEXT_CLASSIFICATION.

curl -X POST \
  --header 'Content-Type: application/json' \
  --header 'Accept: application/json' \
  --header "Authorization: Bearer $API_KEY" \
  --cacert "$SECRETS_DIR/cert.pem" \
  -d '{
    "model": "sentiment",
    "input": [
      "I loved the service.",
      "The experience was frustrating."
    ]
}' https://localhost:9091/classify

For more information about configuring the Private AI Services Container, see Configure the Private AI Services Container.