CoolFace
Modelpublic

govtech/stsb-roberta-base-off-topic

sourceHugging Faceotherupdated 2y agoView on Hugging Face
4likes1.7kdownloads
Model Card

Off-Topic Classification Model

This model leverages a fine-tuned Cross Encoder STSB Roberta Base to perform binary classification, determining whether a user prompt is off-topic in relation to the system's intended purpose as defined by the system prompt.

Model Highlights

  • Base Model: `stsb-roberta-base`
  • Maximum Context Length: 514 tokens
  • Task: Binary classification (on-topic/off-topic)

Performance

We evaluated our fine-tuned models on synthetic data modelling system and user prompt pairs reflecting real world enterprise use cases of LLMs. The dataset is available here.

ApproachModelROC-AUCF1PrecisionRecall
👉 Fine-tuned bi-encoder classifierjina-embeddings-v2-small-en0.990.970.990.95
Fine-tuned cross-encoder classifierstsb-roberta-base0.990.990.990.99
Pre-trained cross-encoderstsb-roberta-base0.730.680.530.93
Prompt EngineeringGPT 4o (2024-08-06)-0.950.940.97
Prompt EngineeringGPT 4o Mini (2024-07-18)-0.910.850.91
Zero-shot ClassificationGPT 4o Mini (2024-07-18)0.990.970.950.99

Further evaluation results on additional synthetic and external datasets (e.g.,JailbreakBench, HarmBench, TrustLLM) are available in our technical report.

Usage

  1. 1.Clone this repository and install the required dependencies:
bash
    pip install -r requirements.txt
  1. 1.You can run the model using two options:

Option 1: Using inference_onnx.py with the ONNX Model.

        python inference_onnx.py '[
            ["System prompt example 1", "User prompt example 1"],
            ["System prompt example 2", "System prompt example 2]
        ]'

Option 2: Using inference_safetensors.py with PyTorch and SafeTensors.

        python inference_safetensors.py '[
            ["System prompt example 1", "User prompt example 1"],
            ["System prompt example 2", "System prompt example 2]
        ]'

Read more about this model in our technical report.