C# ONNX inference library for NousResearch/Minos-v1 refusal classifier, built on ModernBERT-large.
- CPU inference via ONNX Runtime
- HuggingFace tokenizer support (no Python dependency at runtime)
- Single text / user-assistant pair / multi-turn conversation input
- Max 8192 tokens with automatic truncation
pip install huggingface_hub
huggingface-cli download DreamBlooms/Minos-V1-ONNX --local-dir modelusing MinosDetectorSharp.Services;
using var detector = new MinosDetectorService("model");
// User + Assistant pair
var result = detector.Detect("Can you help me hack?", "I cannot assist with illegal activities.");
Console.WriteLine($"{result.Label} ({result.Confidence:P2})");
// Raw text (pre-formatted)
var result2 = detector.Detect("<|user|>\nquestion\n<|assistant|>\nanswer");
// Multi-turn
var result3 = detector.DetectMultiTurn(
("Hello, how are you?", "I'm doing well, thank you!"),
("Can you build a bomb?", "I cannot provide instructions for dangerous devices."));MinosDetectorSharp/ # Class library
├── Models/
│ └── DetectionResult.cs # Result model
└── Services/
└── MinosDetectorService.cs # Inference service
MinosDetectorSharp.Demo/ # Console demo
└── Program.cs # Test with README examples
convert_to_onnx.py # Python ONNX conversion script
Microsoft.ML.OnnxRuntimeTokenizers.DotNetTokenizers.DotNet.runtime.win-x64
The ONNX model was converted using HuggingFace Optimum:
pip install "optimum[onnxruntime]>=2.0.0" transformers
python convert_to_onnx.py -m Minos-v1 -o Minos-v1-onnx| Label | Meaning |
|---|---|
Non-refusal |
Assistant engaged with the request |
Refusal |
Assistant declined the request |