Instructions to use Amitava25/clinc150-contrastive-mpnet-maxsim with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use Amitava25/clinc150-contrastive-mpnet-maxsim with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("Amitava25/clinc150-contrastive-mpnet-maxsim") sentences = [ "The weather is lovely today.", "It's so sunny outside!", "He drove to the stadium." ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [3, 3] - Notebooks
- Google Colab
- Kaggle
CLINC150 Contrastive MPNet Max-Similarity Classifier
This model is a contrastive learningβbased intent classifier with built-in out-of-scope (OOS) detection, trained on the CLINC150 dataset.
Instead of a traditional softmax classifier, it uses embedding-based retrieval with a contrastively fine-tuned encoder, enabling robust generalization and strong OOS handling.
π Key Features
- Encoder:
sentence-transformers/all-mpnet-base-v2(contrastively fine-tuned) - Training Objective: Triplet loss with hard negative mining
- Inference Method: k-NN retrieval over labeled exemplars
- Voting Strategy: Max similarity (top match)
- OOS Detection: Confidence threshold on cosine similarity
π§ How It Works
- Input text is encoded into a dense embedding
- The embedding is compared against a bank of labeled exemplars
- The most similar example (max similarity) determines the predicted intent
- If similarity < threshold β prediction is OOS (out-of-scope)
This approach replaces probability-based classification with metric learning + retrieval, which improves robustness on unseen inputs.
π Performance (CLINC150 Test Set)
- Accuracy: 0.937
- Macro F1: 0.953
- OOS Recall: 0.803
- OOS Precision: 0.935
- OOS F1: 0.864
- False OOS Rate: 0.012
The model achieves a strong balance between:
- high in-scope classification quality
- accurate OOS detection
- low false rejection rate
βοΈ Threshold Configuration
Similarity threshold:
0.71Selected via OOS-aware constrained optimization:
- maximize macro F1
- constrain false OOS rate β€ 3%
π¦ Use Cases
- Intent classification with rejection (chatbots, assistants)
- Production systems requiring safe fallback on unknown inputs
- Retrieval-based classification pipelines
- Few-shot / exemplar-based systems
β οΈ Limitations
- Requires storing exemplar embeddings (memory tradeoff)
- Performance depends on exemplar coverage
- Threshold tuning may need adjustment for new domains
π§© Architecture Summary
| Component | Choice |
|---|---|
| Encoder | MPNet (contrastively fine-tuned) |
| Training | Triplet loss + hard negatives |
| Retrieval | k-NN (k=5) |
| Decision rule | Max similarity |
| OOS detection | Threshold-based |
π‘ Why This Model?
This model demonstrates that contrastive retrieval + thresholding can outperform traditional softmax classifiers for:
- OOS detection
- generalization
- robustness to distribution shift