staleguard / README.md
Arthur920's picture
Update README.md
647570a verified
|
Raw
History Blame Contribute Delete
2.08 kB
---
license: mit
library_name: optimum
pipeline_tag: text-classification
tags:
- onnx
- int8
- code
- nli
- cross-encoder
- unixcoder
base_model: microsoft/unixcoder-base
---
# Staleguard (int8 ONNX)
A 3-class **code↔doc coherence** cross-encoder: given a `(code premise, prose claim)`
pair it predicts `{entailment, neutral, contradiction}`. Fine-tuned from
[`microsoft/unixcoder-base`](https://huggingface.co/microsoft/unixcoder-base),
then exported to ONNX and **dynamically quantized to int8** (per-channel,
avx512_vnni) for portable CPU inference.
Please note that the ml drift detection approach is undergoing quite some change.
Take a look at the Github Project below for a deterministic fast and lightweight documentation drift detection layer on which this model intends to build.
**GitHub:** [Arthur920/Staleguard](https://github.com/Arthur920/Staleguard) ·
**Docs:** [arthur920.github.io/Staleguard](https://arthur920.github.io/Staleguard/)
- **Artifact:** `model_quantized.onnx` (~121 MB, ~4× smaller than the fp32 checkpoint)
- **Labels:** `0=entailment, 1=neutral, 2=contradiction`
- **Lead metric:** held-out contradiction precision (repo-disjoint eval split) —
**~87.6% precision / ~89.9% recall** on the contradiction (alert) class.
## Usage
```python
from optimum.onnxruntime import ORTModelForSequenceClassification
from transformers import AutoTokenizer
repo = "Arthur920/staleguard"
tok = AutoTokenizer.from_pretrained(repo)
model = ORTModelForSequenceClassification.from_pretrained(
repo, file_name="model_quantized.onnx")
inputs = tok("def add(a, b): return a + b",
"The function returns the sum of a and b.",
truncation=True, max_length=192, return_tensors="pt")
logits = model(**inputs).logits
print(model.config.id2label[int(logits.argmax(-1))])
```
## Notes
Int8 dynamic quantization quantizes the Linear/MatMul weights; activations stay
fp32. Parity check vs the fp32 checkpoint showed matching argmax labels on
sample pairs. Re-quantize from the fp32 export with `model/quantize.py`.