stephen-solka commited on
Commit
102a99f
·
verified ·
1 Parent(s): 966b017

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +87 -0
README.md ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ language:
4
+ - en
5
+ base_model: MoritzLaurer/DeBERTa-v3-base-mnli-fever-docnli-ling-2c
6
+ pipeline_tag: text-classification
7
+ library_name: transformers
8
+ tags:
9
+ - onnx
10
+ - optimum
11
+ - deberta-v3
12
+ - nli
13
+ - natural-language-inference
14
+ - zero-shot-classification
15
+ - cross-encoder
16
+ - text-classification
17
+ datasets:
18
+ - nyu-mll/multi_nli
19
+ - fever
20
+ ---
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
+
39
+ Binary NLI (2-class). Apply softmax to the logits; the entailment probability is `softmax(logits)[0]`.
40
+
41
+ | id | label |
42
+ |---|---|
43
+ | 0 | entailment |
44
+ | 1 | not_entailment |
45
+
46
+ ## Usage
47
+
48
+ ```python
49
+ 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]
59
+ 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
82
+
83
+ **MIT**, inherited from the base model. Base architecture: DeBERTa-v3-base (Microsoft). Packaged by Hanno-Labs.
84
+
85
+ If you use this model, please cite the original author:
86
+
87
+ > Laurer, Moritz, Wouter van Atteveldt, Andreu Salleras Casas, and Kasper Welbers. 2022. *Less Annotating, More Classifying – Addressing the Data Scarcity Issue of Supervised Machine Learning with Deep Transfer Learning and BERT - NLI.*