Upload model_a
Browse files- .gitattributes +1 -0
- README.md +87 -0
- config.json +65 -0
- model.safetensors +3 -0
- tokenizer.json +3 -0
- tokenizer_config.json +22 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
base_model: sentence-transformers/paraphrase-multilingual-mpnet-base-v2
|
| 4 |
+
pipeline_tag: text-classification
|
| 5 |
+
language: [en, es, fr, de, zh, nl, it, ar]
|
| 6 |
+
tags: [intent-classification, logistics, multilingual, open-set, text-classification]
|
| 7 |
+
model-index:
|
| 8 |
+
- name: intent-classifier-mpnet
|
| 9 |
+
results:
|
| 10 |
+
- task: {type: text-classification, name: Intent classification}
|
| 11 |
+
dataset: {name: synthetic logistics intents (500 rows, private), type: private}
|
| 12 |
+
metrics:
|
| 13 |
+
- {type: f1, name: macro-F1 (test), value: 0.8848}
|
| 14 |
+
- {type: accuracy, name: accuracy (test), value: 0.8961}
|
| 15 |
+
---
|
| 16 |
+
|
| 17 |
+
# intent-classifier-mpnet
|
| 18 |
+
|
| 19 |
+
Routes a short user message from a logistics / supply-chain chat assistant to one of **12 intents**, and abstains with **`unknown`** when it is not confident (calibrated reject rule stored in `config.json`).
|
| 20 |
+
Fine-tuned from [`sentence-transformers/paraphrase-multilingual-mpnet-base-v2`](https://huggingface.co/sentence-transformers/paraphrase-multilingual-mpnet-base-v2) as a standard `AutoModelForSequenceClassification` (no custom code).
|
| 21 |
+
|
| 22 |
+
## Usage
|
| 23 |
+
|
| 24 |
+
```python
|
| 25 |
+
import torch
|
| 26 |
+
from transformers import AutoModelForSequenceClassification, AutoTokenizer
|
| 27 |
+
|
| 28 |
+
repo = "Badalt/intent-classifier-mpnet"
|
| 29 |
+
tok = AutoTokenizer.from_pretrained(repo)
|
| 30 |
+
model = AutoModelForSequenceClassification.from_pretrained(repo).eval()
|
| 31 |
+
|
| 32 |
+
texts = ["whats the eta on LD-55501 pls", "¿Cuántos remolques hay en el patio?"]
|
| 33 |
+
with torch.no_grad():
|
| 34 |
+
logits = model(**tok(texts, padding=True, truncation=True, max_length=64, return_tensors="pt")).logits
|
| 35 |
+
probs = torch.softmax(logits / model.config.calibration_temperature, dim=-1)
|
| 36 |
+
conf, idx = probs.max(-1)
|
| 37 |
+
for c, i in zip(conf, idx):
|
| 38 |
+
label = "unknown" if c < model.config.unknown_threshold else model.config.id2label[int(i)]
|
| 39 |
+
print(label, round(float(c), 3))
|
| 40 |
+
```
|
| 41 |
+
|
| 42 |
+
Reject rule: `unknown` if `max softmax(logits / 0.4622) < 0.5735`. The threshold keeps 95.0% of known-intent validation messages; the temperature was fitted on the same validation set.
|
| 43 |
+
|
| 44 |
+
## Labels
|
| 45 |
+
|
| 46 |
+
`ai_agent_performance`, `appointment_manager`, `chitchat`, `customer_support`, `document_processing`, `knowledge_base`, `orders`, `other`, `shipment_information.analytics`, `shipment_information.disruptions`, `shipment_information.realtime_query`, `yard_management` (+ `unknown` via the reject rule).
|
| 47 |
+
|
| 48 |
+
## Training data
|
| 49 |
+
|
| 50 |
+
500 labelled synthetic chat messages (12 intents, 30–55 per class; ~13% non-English: ES, FR, DE, ZH, NL, AR, IT; noisy, colloquial). The dataset is confidential and **not** distributed with this model. Split: stratified 70/15/15 (347 / 76 / 77) with near-duplicate paraphrases kept in the same split; seed 42.
|
| 51 |
+
|
| 52 |
+
## Training procedure
|
| 53 |
+
|
| 54 |
+
lr 5e-05, batch 16, ≤15 epochs with early stopping on validation macro-F1 (best epoch 4), linear decay, warmup 0.1, weight decay 0.01, class-weighted cross-entropy, max_length 64, seed 42. Backbone and learning rate chosen by 5-fold cross-validation among 3 multilingual encoders × 2 learning rates.
|
| 55 |
+
|
| 56 |
+
## Evaluation
|
| 57 |
+
|
| 58 |
+
**Held-out test set (n=77, never used for any decision):** macro-F1 **0.885** (95% bootstrap CI 0.791–0.950), accuracy 0.896; English 0.879 vs non-English 1.000 accuracy (n=11).
|
| 59 |
+
|
| 60 |
+
**5-fold CV on train+val (n=423, out-of-fold):** macro-F1 0.920 (fold mean 0.920 ± 0.028); non-English accuracy 0.942.
|
| 61 |
+
|
| 62 |
+
| intent | precision | recall | F1 | n |
|
| 63 |
+
|---|---|---|---|---|
|
| 64 |
+
| `ai_agent_performance` | 1.00 | 1.00 | 1.00 | 6 |
|
| 65 |
+
| `appointment_manager` | 0.88 | 1.00 | 0.93 | 7 |
|
| 66 |
+
| `chitchat` | 0.83 | 1.00 | 0.91 | 5 |
|
| 67 |
+
| `customer_support` | 0.86 | 1.00 | 0.92 | 6 |
|
| 68 |
+
| `document_processing` | 1.00 | 0.83 | 0.91 | 6 |
|
| 69 |
+
| `knowledge_base` | 0.67 | 1.00 | 0.80 | 6 |
|
| 70 |
+
| `orders` | 1.00 | 0.86 | 0.92 | 7 |
|
| 71 |
+
| `other` | 1.00 | 0.40 | 0.57 | 5 |
|
| 72 |
+
| `shipment_information.analytics` | 1.00 | 0.80 | 0.89 | 10 |
|
| 73 |
+
| `shipment_information.disruptions` | 0.83 | 1.00 | 0.91 | 5 |
|
| 74 |
+
| `shipment_information.realtime_query` | 0.89 | 1.00 | 0.94 | 8 |
|
| 75 |
+
| `yard_management` | 1.00 | 0.83 | 0.91 | 6 |
|
| 76 |
+
|
| 77 |
+
**Open-set (unknown intents).** A twin model trained without `yard_management` and `document_processing` was tested on known messages plus all messages of those unseen intents: max-softmax reject rule AUROC 0.791, rejection recall 26.2% at 93.8% retention; best scorer (kNN k=1 [mean]) AUROC 0.821.
|
| 78 |
+
|
| 79 |
+
## Intended use & limitations
|
| 80 |
+
|
| 81 |
+
- First-step router for a logistics assistant; low-confidence messages should go to a clarification / fallback path.
|
| 82 |
+
- Trained on 500 synthetic rows: expect lower accuracy on real traffic; monitor confidence, unknown-rate and language mix for drift and re-calibrate the threshold on fresh labelled data.
|
| 83 |
+
- The three `shipment_information.*` intents are semantically close and account for a large share of errors.
|
| 84 |
+
- Non-English evaluation rests on few examples; languages not seen in training (e.g. Arabic, Italian) are untested beyond anecdotes.
|
| 85 |
+
- `other` / `chitchat` are trained catch-alls; genuinely new intents are handled only by the confidence threshold.
|
| 86 |
+
|
| 87 |
+
Training curves and metrics: https://wandb.ai/badalthakur2212-iisc/intent-classifier/runs/ffy90jmz
|
config.json
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_cross_attention": false,
|
| 3 |
+
"architectures": [
|
| 4 |
+
"XLMRobertaForSequenceClassification"
|
| 5 |
+
],
|
| 6 |
+
"attention_probs_dropout_prob": 0.1,
|
| 7 |
+
"bos_token_id": 0,
|
| 8 |
+
"calibration_temperature": 0.46218203621972115,
|
| 9 |
+
"classifier_dropout": null,
|
| 10 |
+
"dtype": "float32",
|
| 11 |
+
"eos_token_id": 2,
|
| 12 |
+
"gradient_checkpointing": false,
|
| 13 |
+
"hidden_act": "gelu",
|
| 14 |
+
"hidden_dropout_prob": 0.1,
|
| 15 |
+
"hidden_size": 768,
|
| 16 |
+
"id2label": {
|
| 17 |
+
"0": "ai_agent_performance",
|
| 18 |
+
"1": "appointment_manager",
|
| 19 |
+
"2": "chitchat",
|
| 20 |
+
"3": "customer_support",
|
| 21 |
+
"4": "document_processing",
|
| 22 |
+
"5": "knowledge_base",
|
| 23 |
+
"6": "orders",
|
| 24 |
+
"7": "other",
|
| 25 |
+
"8": "shipment_information.analytics",
|
| 26 |
+
"9": "shipment_information.disruptions",
|
| 27 |
+
"10": "shipment_information.realtime_query",
|
| 28 |
+
"11": "yard_management"
|
| 29 |
+
},
|
| 30 |
+
"initializer_range": 0.02,
|
| 31 |
+
"intermediate_size": 3072,
|
| 32 |
+
"is_decoder": false,
|
| 33 |
+
"label2id": {
|
| 34 |
+
"ai_agent_performance": 0,
|
| 35 |
+
"appointment_manager": 1,
|
| 36 |
+
"chitchat": 2,
|
| 37 |
+
"customer_support": 3,
|
| 38 |
+
"document_processing": 4,
|
| 39 |
+
"knowledge_base": 5,
|
| 40 |
+
"orders": 6,
|
| 41 |
+
"other": 7,
|
| 42 |
+
"shipment_information.analytics": 8,
|
| 43 |
+
"shipment_information.disruptions": 9,
|
| 44 |
+
"shipment_information.realtime_query": 10,
|
| 45 |
+
"yard_management": 11
|
| 46 |
+
},
|
| 47 |
+
"layer_norm_eps": 1e-05,
|
| 48 |
+
"max_position_embeddings": 514,
|
| 49 |
+
"model_type": "xlm-roberta",
|
| 50 |
+
"num_attention_heads": 12,
|
| 51 |
+
"num_hidden_layers": 12,
|
| 52 |
+
"output_past": true,
|
| 53 |
+
"pad_token_id": 1,
|
| 54 |
+
"position_embedding_type": "absolute",
|
| 55 |
+
"reject_label": "unknown",
|
| 56 |
+
"reject_rule": "predict 'unknown' if max softmax(logits / calibration_temperature) < unknown_threshold",
|
| 57 |
+
"retention_target": 0.95,
|
| 58 |
+
"tie_word_embeddings": true,
|
| 59 |
+
"transformers_version": "5.18.0",
|
| 60 |
+
"type_vocab_size": 1,
|
| 61 |
+
"unknown_threshold": 0.5734586119651794,
|
| 62 |
+
"use_cache": false,
|
| 63 |
+
"val_retention_at_tau": 0.9605263157894737,
|
| 64 |
+
"vocab_size": 250002
|
| 65 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:43b810f29d1342c4ec1f83ea8cc7d9d86e29e7b6b81b7177759052d65f6f7a13
|
| 3 |
+
size 1112235768
|
tokenizer.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:bc5c1151948923156f20bcafd54fd796705d693f8d7b56c83aec49d651f6d602
|
| 3 |
+
size 17082986
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_prefix_space": true,
|
| 3 |
+
"backend": "tokenizers",
|
| 4 |
+
"bos_token": "<s>",
|
| 5 |
+
"cls_token": "<s>",
|
| 6 |
+
"eos_token": "</s>",
|
| 7 |
+
"is_local": false,
|
| 8 |
+
"local_files_only": false,
|
| 9 |
+
"mask_token": "<mask>",
|
| 10 |
+
"max_length": 128,
|
| 11 |
+
"model_max_length": 512,
|
| 12 |
+
"pad_to_multiple_of": null,
|
| 13 |
+
"pad_token": "<pad>",
|
| 14 |
+
"pad_token_type_id": 0,
|
| 15 |
+
"padding_side": "right",
|
| 16 |
+
"sep_token": "</s>",
|
| 17 |
+
"stride": 0,
|
| 18 |
+
"tokenizer_class": "XLMRobertaTokenizer",
|
| 19 |
+
"truncation_side": "right",
|
| 20 |
+
"truncation_strategy": "longest_first",
|
| 21 |
+
"unk_token": "<unk>"
|
| 22 |
+
}
|