Get the model
The sentence model the desk runs, free to download and use under the Apache 2.0 license. It reads a support ticket and suggests its department and priority.
The files
- model_quantized.onnx 22.8 MB the model, 8-bit ONNX
- tokenizer.json 712 KB turns text into word pieces
- heads.json 111 KB turns the sentence vector into a department and a priority
- manifest.json 23 bytes the token limit
- LICENSE Apache License 2.0
- NOTICE.md what was changed from the base model
Put the files in one folder. Download them on a fast connection: together they are about 23.7 MB.
The same files are also on Hugging Face: goudymt/support-ticket-triage.
How to load it
In Python, with onnxruntime, tokenizers and numpy. Mask personal data first (emails, phone, order and card numbers): the model was trained on masked text.
import json
import numpy as np
import onnxruntime as ort
from tokenizers import Tokenizer
folder = "bundle_v2" # the folder you saved the files in
manifest = json.load(open(f"{folder}/manifest.json"))
heads = json.load(open(f"{folder}/heads.json"))
tokenizer = Tokenizer.from_file(f"{folder}/tokenizer.json")
tokenizer.enable_truncation(max_length=manifest["max_length"])
session = ort.InferenceSession(f"{folder}/model_quantized.onnx", providers=["CPUExecutionProvider"])
def triage(text):
encoded = tokenizer.encode(text)
feeds = {
"input_ids": np.array([encoded.ids], dtype=np.int64),
"attention_mask": np.array([encoded.attention_mask], dtype=np.int64),
"token_type_ids": np.array([encoded.type_ids], dtype=np.int64),
}
wanted = {item.name for item in session.get_inputs()}
hidden = session.run(None, {k: v for k, v in feeds.items() if k in wanted})[0]
vector = hidden[0].mean(axis=0)
vector /= max(np.linalg.norm(vector), 1e-12)
answer = {}
for field, head in heads.items():
scores = np.array(head["weight"], dtype=np.float32) @ vector + np.array(head["bias"], dtype=np.float32)
answer[field] = head["classes"][int(scores.argmax())]
return answer
print(triage("I was charged twice for my subscription this month and need a refund."))
# {'category': 'Billing', 'priority': 'Medium'}
What it is good for, and its limits
On ticket wording it never trained on, it picks the right department 83.9% of the time, against 57.3% for the word model. On 2,000 tickets kept from every model and read once, 90.8%. It was trained on generated tickets, not real ones, and it is built to suggest an answer to a person, not to decide alone. The numbers and every limit are on Model History and in the model card.
License
A trained copy of sentence-transformers/all-MiniLM-L6-v2, which its authors publish under the Apache License, Version 2.0. This copy is under the same license; NOTICE.md says what was changed.