stephen-solka commited on
Commit
a9e8c17
·
verified ·
1 Parent(s): bccc80c

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +13 -21
README.md CHANGED
@@ -21,18 +21,19 @@ datasets:
21
 
22
  # DeBERTa-v3-base-mnli-fever-docnli-ling-2c-onnx
23
 
24
- ONNX exports of [`MoritzLaurer/DeBERTa-v3-base-mnli-fever-docnli-ling-2c`](https://huggingface.co/MoritzLaurer/DeBERTa-v3-base-mnli-fever-docnli-ling-2c), a DeBERTa-v3-base NLI cross-encoder, packaged for CPU inference with ONNX Runtime.
25
 
26
- This repository only re-packages the base model as ONNX — **no additional training was performed.**
27
 
28
- ## Variants
29
 
30
- | Subfolder | File | Precision | Size | Notes |
31
- |---|---|---|---|---|
32
- | `nli-onnx/` | `model.onnx` | fp32, O3-optimized | ~739 MB | Highest accuracy |
33
- | `nli-onnx-quantized/` | `model_quantized.onnx` | INT8 (AVX-512 VNNI) | ~233 MB | ~3× smaller, CPU-optimized |
34
 
35
- Each subfolder is self-contained (ONNX graph + tokenizer + config).
 
 
36
 
37
  ## Labels
38
 
@@ -50,9 +51,8 @@ import onnxruntime as ort, numpy as np
50
  from transformers import AutoTokenizer
51
 
52
  repo = "Hanno-Labs/DeBERTa-v3-base-mnli-fever-docnli-ling-2c-onnx"
53
- sub = "nli-onnx-quantized" # or "nli-onnx" for fp32
54
- tok = AutoTokenizer.from_pretrained(repo, subfolder=sub)
55
- sess = ort.InferenceSession(f"{sub}/model_quantized.onnx", providers=["CPUExecutionProvider"])
56
 
57
  enc = tok("A cat sat on the mat.", "There is a cat.", return_tensors="np", truncation=True)
58
  logits = sess.run(None, {k: v for k, v in enc.items()})[0]
@@ -60,22 +60,14 @@ probs = np.exp(logits) / np.exp(logits).sum(-1, keepdims=True)
60
  print("entailment prob:", float(probs[0, 0]))
61
  ```
62
 
63
- (Also loadable via `optimum.onnxruntime.ORTModelForSequenceClassification.from_pretrained(repo, subfolder=sub)`.)
64
 
65
- ## How these were exported
66
 
67
  ```bash
68
- # fp32 (O3):
69
  optimum-cli export onnx \
70
  --model MoritzLaurer/DeBERTa-v3-base-mnli-fever-docnli-ling-2c \
71
  --task text-classification --optimize O3 nli-onnx/
72
-
73
- # INT8 quantized (export without O3 first — O3 breaks quantization):
74
- optimum-cli export onnx \
75
- --model MoritzLaurer/DeBERTa-v3-base-mnli-fever-docnli-ling-2c \
76
- --task text-classification nli-onnx-temp/
77
- optimum-cli onnxruntime quantize \
78
- --onnx_model nli-onnx-temp --avx512_vnni -o nli-onnx-quantized/
79
  ```
80
 
81
  ## License & attribution
 
21
 
22
  # DeBERTa-v3-base-mnli-fever-docnli-ling-2c-onnx
23
 
24
+ fp32 ONNX export of [`MoritzLaurer/DeBERTa-v3-base-mnli-fever-docnli-ling-2c`](https://huggingface.co/MoritzLaurer/DeBERTa-v3-base-mnli-fever-docnli-ling-2c), a DeBERTa-v3-base NLI cross-encoder, packaged for CPU inference with ONNX Runtime.
25
 
26
+ This repository only re-packages the base model as ONNX — **no additional training was performed.** The export is numerically faithful to the original (entailment probabilities match PyTorch to 3 decimals).
27
 
28
+ ## Files
29
 
30
+ | Subfolder | File | Precision | Size |
31
+ |---|---|---|---|
32
+ | `nli-onnx/` | `model.onnx` | fp32, O3-optimized | ~739 MB |
 
33
 
34
+ Self-contained (ONNX graph + tokenizer + config).
35
+
36
+ > **Why no INT8 build?** Dynamic INT8 quantization severely degrades this model — DeBERTa's disentangled-attention ops are quantization-sensitive, and entailment probabilities collapse (e.g. a near-verbatim match drops from ~0.99 to ~0.49). Serve fp32. On CPU this ~184M model runs in tens of milliseconds per pair, so quantization buys little anyway.
37
 
38
  ## Labels
39
 
 
51
  from transformers import AutoTokenizer
52
 
53
  repo = "Hanno-Labs/DeBERTa-v3-base-mnli-fever-docnli-ling-2c-onnx"
54
+ tok = AutoTokenizer.from_pretrained(repo, subfolder="nli-onnx")
55
+ sess = ort.InferenceSession("nli-onnx/model.onnx", providers=["CPUExecutionProvider"])
 
56
 
57
  enc = tok("A cat sat on the mat.", "There is a cat.", return_tensors="np", truncation=True)
58
  logits = sess.run(None, {k: v for k, v in enc.items()})[0]
 
60
  print("entailment prob:", float(probs[0, 0]))
61
  ```
62
 
63
+ (Also loadable via `optimum.onnxruntime.ORTModelForSequenceClassification.from_pretrained(repo, subfolder="nli-onnx")`.)
64
 
65
+ ## How this was exported
66
 
67
  ```bash
 
68
  optimum-cli export onnx \
69
  --model MoritzLaurer/DeBERTa-v3-base-mnli-fever-docnli-ling-2c \
70
  --task text-classification --optimize O3 nli-onnx/
 
 
 
 
 
 
 
71
  ```
72
 
73
  ## License & attribution