Text Classification
ONNX
setfit
English
German
onnxruntime
intent-classification
education
quantized
Instructions to use NayerKotry/iris-intent-classifier with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- setfit
How to use NayerKotry/iris-intent-classifier with setfit:
from setfit import SetFitModel model = SetFitModel.from_pretrained("NayerKotry/iris-intent-classifier") preds = model.predict(["i loved the spiderman movie!", "pineapple on pizza is the worst"]) print(preds) - Notebooks
- Google Colab
- Kaggle
Add model card with description and usage example
Browse files
README.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language:
|
| 3 |
+
- en
|
| 4 |
+
- de
|
| 5 |
+
base_model: sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2
|
| 6 |
+
pipeline_tag: text-classification
|
| 7 |
+
tags:
|
| 8 |
+
- onnx
|
| 9 |
+
- intent-classification
|
| 10 |
+
- education
|
| 11 |
+
- setfit
|
| 12 |
+
- quantized
|
| 13 |
+
library_name: onnxruntime
|
| 14 |
+
license: mit
|
| 15 |
+
---
|
| 16 |
+
|
| 17 |
+
# Iris Intent Classifier
|
| 18 |
+
|
| 19 |
+
Binary text classifier that decides whether a student's search query in [Artemis](https://github.com/ls1intum/Artemis) needs an AI-generated answer (`trigger_ai`) or can be satisfied with search results alone (`skip_ai`).
|
| 20 |
+
|
| 21 |
+
Used by [Iris](https://github.com/ls1intum/edutelligence), the AI assistant embedded in the Artemis learning platform.
|
| 22 |
+
|
| 23 |
+
## Model Details
|
| 24 |
+
|
| 25 |
+
| Property | Value |
|
| 26 |
+
|---|---|
|
| 27 |
+
| Base model | `sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2` |
|
| 28 |
+
| Architecture | BERT (12 layers, 384 hidden size) |
|
| 29 |
+
| Task | Binary text classification |
|
| 30 |
+
| Quantization | Dynamic INT8 (weights QInt8, activations QUInt8) |
|
| 31 |
+
| Format | ONNX Runtime |
|
| 32 |
+
| Accuracy | 99.7% |
|
| 33 |
+
| Languages | English, German (multilingual) |
|
| 34 |
+
|
| 35 |
+
## Labels
|
| 36 |
+
|
| 37 |
+
| Label | ID | Meaning |
|
| 38 |
+
|---|---|---|
|
| 39 |
+
| `skip_ai` | 0 | Query can be answered with search results (e.g. "Lecture 4", "Exercise Sheet 2") |
|
| 40 |
+
| `trigger_ai` | 1 | Query needs an LLM-generated explanation (e.g. "explain recursion", "wie funktioniert hashing") |
|
| 41 |
+
|
| 42 |
+
## Usage
|
| 43 |
+
|
| 44 |
+
```python
|
| 45 |
+
import numpy as np
|
| 46 |
+
import onnxruntime as ort
|
| 47 |
+
import joblib
|
| 48 |
+
from transformers import AutoTokenizer
|
| 49 |
+
|
| 50 |
+
# Load model components
|
| 51 |
+
tokenizer = AutoTokenizer.from_pretrained("sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2")
|
| 52 |
+
session = ort.InferenceSession("model_quantized.onnx")
|
| 53 |
+
head = joblib.load("model_head.joblib")
|
| 54 |
+
|
| 55 |
+
def predict(query: str) -> str:
|
| 56 |
+
inputs = tokenizer(query, return_tensors="np", truncation=True, max_length=512, padding=True)
|
| 57 |
+
outputs = session.run(None, {
|
| 58 |
+
"input_ids": inputs["input_ids"],
|
| 59 |
+
"attention_mask": inputs["attention_mask"],
|
| 60 |
+
"token_type_ids": inputs["token_type_ids"],
|
| 61 |
+
})
|
| 62 |
+
# Mean pooling
|
| 63 |
+
embedding = outputs[0].mean(axis=1)
|
| 64 |
+
label_id = head.predict(embedding)[0]
|
| 65 |
+
return "trigger_ai" if label_id == 1 else "skip_ai"
|
| 66 |
+
|
| 67 |
+
# Examples
|
| 68 |
+
print(predict("explain recursion")) # trigger_ai
|
| 69 |
+
print(predict("how does quicksort work step by step")) # trigger_ai
|
| 70 |
+
print(predict("was ist ein Deadlock")) # trigger_ai
|
| 71 |
+
print(predict("Lecture 4")) # skip_ai
|
| 72 |
+
print(predict("Exercise Sheet 2")) # skip_ai
|
| 73 |
+
print(predict("Vorlesung 7 Folien")) # skip_ai
|
| 74 |
+
```
|
| 75 |
+
|
| 76 |
+
## Training Data
|
| 77 |
+
|
| 78 |
+
Trained on a custom dataset of student search queries from Artemis, labeled as either requiring an AI explanation or not. Queries span multiple subjects (computer science, mathematics) in both English and German.
|