--- language: - en - de base_model: sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2 pipeline_tag: text-classification tags: - onnx - intent-classification - education - setfit - quantized library_name: onnxruntime license: mit --- # Search Intent Classifier Binary text classifier that decides whether a student's search query needs an AI-generated answer (`trigger_ai`) or can be satisfied with search results alone (`skip_ai`). ## Model Details | Property | Value | |---|---| | Base model | [sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2](https://huggingface.co/sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2) | | Architecture | BERT (12 layers, 384 hidden size) | | Task | Binary text classification | | Quantization | Dynamic INT8 (weights QInt8, activations QUInt8) | | Format | ONNX Runtime | | Languages | English, German (multilingual) | ## Labels | Label | ID | Meaning | |---|---|---| | `skip_ai` | 0 | Query can be answered with search results (e.g. "Lecture 4", "Exercise Sheet 2") | | `trigger_ai` | 1 | Query needs an LLM-generated explanation (e.g. "explain recursion", "wie funktioniert hashing") | ## Usage ```python import numpy as np import onnxruntime as ort import joblib from transformers import AutoTokenizer # Load model components tokenizer = AutoTokenizer.from_pretrained("sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2") session = ort.InferenceSession("model_quantized.onnx") head = joblib.load("model_head.joblib") def predict(query: str) -> str: inputs = tokenizer(query, return_tensors="np", truncation=True, max_length=512, padding=True) outputs = session.run(None, { "input_ids": inputs["input_ids"], "attention_mask": inputs["attention_mask"], "token_type_ids": inputs["token_type_ids"], }) embedding = outputs[0].mean(axis=1) label_id = head.predict(embedding)[0] return "trigger_ai" if label_id == 1 else "skip_ai" print(predict("explain recursion")) # trigger_ai print(predict("how does quicksort work step by step")) # trigger_ai print(predict("was ist ein Deadlock")) # trigger_ai print(predict("Lecture 4")) # skip_ai print(predict("Exercise Sheet 2")) # skip_ai print(predict("Vorlesung 7 Folien")) # skip_ai ``` ## Training Data Trained on a synthesized dataset of student search queries generated by Claude (Anthropic) in English and German.