Cross-encoder reranker for enterprise intent detection (DLP / security).
Fine-tuned from cross-encoder/nli-MiniLM2-L6-H768 on a synthetic intent-detection dataset.
1import torch
2from transformers import AutoTokenizer, AutoModelForSequenceClassification
3
4model_id = "aryasuneesh-quilr/intent-crossencoder-miniLM2-L6-H768"
5tokenizer = AutoTokenizer.from_pretrained(model_id)
6model = AutoModelForSequenceClassification.from_pretrained(model_id)
7model.eval()
8
9def score(user_input: str, intent_description: str) -> float:
10 pair = f"{user_input} [SEP] {intent_description}"
11 enc = tokenizer(pair, return_tensors="pt", truncation=True, max_length=256)
12 with torch.no_grad():
13 logits = model(**enc).logits
14 return torch.softmax(logits, dim=1)[0, 1].item() # P(match)
15
16# Example
17s = score(
18 "Our AWS_SECRET_ACCESS_KEY was found in a public repo",
19 "Identify exposure of authentication credentials or API keys"
20)
21print(f"Match probability: {s:.4f}") # use threshold 0.3727 for best F1