= AI Model Text Classification Resource

ifdef::env-github[]
image:https://img.shields.io/static/v1?label=Available%20at&message=Gravitee.io&color=1EC9D2["Gravitee.io",link="https://download.gravitee.io/#graviteeio-ee/apim/plugins/resources/gravitee-resource-ai-model-text-classification/"]
image:https://img.shields.io/badge/License-Apache%202.0-blue.svg["License",link="https://github.com/gravitee-io/gravitee-resource-ai-model-text-classification/blob/master/LICENSE.txt"]
image:https://img.shields.io/badge/semantic--release-conventional%20commits-e10079?logo=semantic-release["Releases",link="https://github.com/gravitee-io/gravitee-resource-ai-model-text-classification/releases"]
image:https://dl.circleci.com/status-badge/img/gh/gravitee-io/gravitee-resource-ai-model-text-classification/tree/main.svg?style=svg["CircleCI",link="https://dl.circleci.com/status-badge/redirect/gh/gravitee-io/gravitee-resource-ai-model-text-classification/tree/main"]
image:https://f.hubspotusercontent40.net/hubfs/7600448/gravitee-github-button.jpg["Join the community forum",link="https://community.gravitee.io?utm_source=readme", height=20]
endif::[]

== Description

The resource is used to fetch and invoke a text classification model for Gravitee gateway policies. Models are fetched from Hugging Face.

== Compatibility

|===
| AI Model Text Classification Resource plugin | APIM

| 1.x | 4.8.x
| 2.x | 4.9.x
|===

== Notice

This plugin exposes models based on meta LLama 4:

* link:https://huggingface.co/gravitee-io/Llama-Prompt-Guard-2-22M-onnx[gravitee-io/Llama-Prompt-Guard-2-22M-onnx]
* link:https://huggingface.co/gravitee-io/Llama-Prompt-Guard-2-86M-onnx[gravitee-io/Llama-Prompt-Guard-2-86M-onnx]

``Llama 4 is licensed under the Llama 4 Community License, Copyright © Meta Platforms, Inc. All Rights Reserved.``

== Available models

The AI model text classification resource provides the following models:

- link:https://huggingface.co/minuva/MiniLMv2-toxic-jigsaw-onnx[minuva/MiniLMv2-toxic-jigsaw-onnx]
- link:https://huggingface.co/gravitee-io/detoxify-onnx[gravitee-io/detoxify-onnx]
- link:https://huggingface.co/gravitee-io/distilbert-multilingual-toxicity-classifier[gravitee-io/distilbert-multilingual-toxicity-classifier]
- link:https://huggingface.co/gravitee-io/Llama-Prompt-Guard-2-22M-onnx[gravitee-io/Llama-Prompt-Guard-2-22M-onnx]
- link:https://huggingface.co/gravitee-io/Llama-Prompt-Guard-2-86M-onnx[gravitee-io/Llama-Prompt-Guard-2-86M-onnx]

In addition to the models above, we've added 3 new lightweight models:

- link:https://huggingface.co/gravitee-io/bert-tiny-toxicity[gravitee-io/bert-tiny-toxicity]
- link:https://huggingface.co/gravitee-io/bert-mini-toxicity[gravitee-io/bert-mini-toxcity]
- link:https://huggingface.co/gravitee-io/bert-small-toxicity[gravitee-io/bert-small-toxcity]

NOTE: The models are not included in the resource package. The resource automatically downloads the models from Hugging Face when they are not available locally. The Models files are stored in `$GRAVITEE_HOME/models` directory. Ensure that the user that runs the Gateway can write in that directory.

WARNING: Models are loaded in memory. You may need to increase the memory (Java Heap size and Kubernetes resource limits) of the Gateway to avoid any OutOfMemory error. The increase depends on the model size and the number of APIs that use the resource.
