ONNX Model Zoo

govtech/jina-embeddings-v2-small-en-off-topic

By govtech · ↓ 10 · ♥ 2 · Updated 2024-11-22

What's in this repo

This page lists the files in govtech/jina-embeddings-v2-small-en-off-topic, including off-topic-jinaai-jina-embeddings-v2-small-en-TwinEncoder.onnx.

  • 1 ONNX models (.onnx files)
  • 10 files, including 2 .py, 1 .md, 1 .json, 1 .onnx, 1 .safetensors, 1 .txt
  • Last updated 2024-11-22

ONNX files

File Size Download
models/off-topic-jinaai-jina-embeddings-v2-small-en-TwinEncoder.onnx — Download

How to use

These ONNX files can be loaded with ONNX Runtime. To inspect a model graph, upload the file to the Netron viewer. Download links point to the original files on Hugging Face.

README

Off-Topic Classification Model

This repository contains a fine-tuned Jina Embeddings model designed to perform binary classification. The model predicts whether a user prompt is off-topic based on the intended purpose defined in the system prompt.

Model Highlights

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.

Approach Model ROC-AUC F1 Precision Recall
Fine-tuned bi-encoder classifier jina-embeddings-v2-small-en 0.99 0.97 0.99 0.95
👉 Fine-tuned cross-encoder classifier stsb-roberta-base 0.99 0.99 0.99 0.99
Pre-trained cross-encoder stsb-roberta-base 0.73 0.68 0.53 0.93
Prompt Engineering GPT 4o (2024-08-06) - 0.95 0.94 0.97
Prompt Engineering GPT 4o Mini (2024-07-18) - 0.91 0.85 0.91
Zero-shot Classification GPT 4o Mini (2024-07-18) 0.99 0.97 0.95 0.99

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

Usage

  1. Clone this repository and install the required dependencies:

    pip install -r requirements.txt
    
  2. 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.

Model info

onnx en dataset:gabrielchua/off-topic arxiv:2411.12946 base_model:jinaai/jina-embeddings-v2-small-en base_model:quantized:jinaai/jina-embeddings-v2-small-en license:other region:us
↓ 10 ♥ 2

Created: 2024-11-16

Updated: 2024-11-22

View on Hugging Face

Files (10)

.gitattributes
.gitignore
LICENSE
README.md
config.json
inference_onnx.py
inference_safetensors.py
models/off-topic-jinaai-jina-embeddings-v2-small-en-TwinEncoder.onnx ONNX
models/off-topic-jinaai-jina-embeddings-v2-small-en-TwinEncoder.safetensors
requirements.txt

Related models