spamon commited on
Commit
e2b915e
·
verified ·
1 Parent(s): 882c935

v2 models: 8-layer (apps) and 5-layer (low memory) students; README; v1 manifest kept

Browse files
README.md CHANGED
@@ -6,23 +6,28 @@ tags:
6
  - toxic
7
  - onnx
8
  - int8
9
- language: [en, de, fr, es, it, ru, uk, ar, hi, ja, zh, he, am, tt]
10
  ---
11
 
12
  # Ordicio toxicity classifier (ONNX, int8)
13
 
14
- An int8 ONNX export of
15
  [textdetox/bert-multilingual-toxicity-classifier](https://huggingface.co/textdetox/bert-multilingual-toxicity-classifier)
16
- for on-device inference in the Ordicio apps (ONNX Runtime on Android / iOS, onnxruntime-web in browsers).
 
 
 
17
 
18
- - `manifest.json`: the current version, file hashes, tokenizer settings, labels and threshold.
19
- - `v1/model.onnx`: weights quantized to int8 (dynamic quantization), inputs `input_ids`,
20
- `attention_mask`, `token_type_ids` as int32 (cast to int64 inside the graph), output `logits`
21
- (index 0 neutral, 1 toxic).
22
- - `v1/vocab.txt`: the WordPiece vocabulary of the base model (cased, no lowercasing).
 
 
23
 
24
- The int8 model agrees with the fp32 model on 98.5 % of decisions (3600 samples of
25
- textdetox/multilingual_toxicity_dataset in 12 languages). For accuracy per language, see the base
26
- model's card: German results are weak (F1 0.52).
27
 
28
- The use restrictions of the openrail++ license of the base model apply to this export.
 
6
  - toxic
7
  - onnx
8
  - int8
9
+ language: [en, de, fr, es, it, ru, uk]
10
  ---
11
 
12
  # Ordicio toxicity classifier (ONNX, int8)
13
 
14
+ Students of
15
  [textdetox/bert-multilingual-toxicity-classifier](https://huggingface.co/textdetox/bert-multilingual-toxicity-classifier)
16
+ for on-device inference in the Ordicio apps (ONNX Runtime on Android / iOS, onnxruntime-web in browsers): layers
17
+ taken from the base model, distilled from XLM-R large teachers and fine-tuned on textdetox, GermEval 2018/2019/2021 and
18
+ hand-labelled comments. Trained for English, German, French, Spanish, Italian, Russian and Ukrainian; texts in other
19
+ scripts score as harmless.
20
 
21
+ - `manifest.json`: the model the apps load (8 layers, `v2/L8/model.onnx`, 82 MB), with file hashes, tokenizer
22
+ settings, labels and threshold. `lowMemory` names the manifest for devices with little memory.
23
+ - `manifest-low-memory.json`: the 5-layer model (`v2/L5/model.onnx`, 52 MB) for iPhone and iPad browsers.
24
+ - `v2/vocab.txt`: the WordPiece vocabulary of both models (cased, no lowercasing).
25
+ - Models: weights quantized to int8, inputs `input_ids`, `attention_mask`, `token_type_ids` as int32, output `logits`
26
+ (index 0 harmless, 1 toxic).
27
+ - `manifest-v1.json`, `v1/`: the previous model (int8 export of the base model, 179 MB).
28
 
29
+ On a hand-checked test of 3,664 real comments, at threshold 0.5 the 8-layer model finds 41 % of the attacks and flags
30
+ 4 of 1,000 harmless comments (5-layer: 38 % and 5.4); ROC-AUC 96 (German 93). In ordinary traffic both flag fewer than
31
+ 0.4 of 1,000 harmless comments.
32
 
33
+ The use restrictions of the openrail++ license of the base model apply to these models.
manifest-low-memory.json ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": "ordicio-mbert-eu-L5-r256-int8-v2",
3
+ "source": "5 of the 12 layers of textdetox/bert-multilingual-toxicity-classifier, distilled from XLM-R large teachers and fine-tuned on textdetox, GermEval 2018/2019/2021 and hand-labelled comments (en, de, fr, es, it, ru, uk; abstains on other scripts)",
4
+ "license": "openrail++",
5
+ "files": {
6
+ "model": {
7
+ "path": "v2/L5/model.onnx",
8
+ "sha256": "92fe15d8dc2bd81ef999b5d0b3b4992e8fa58091cafdce871b40a15160fd6a5b",
9
+ "size": 52346473
10
+ },
11
+ "vocab": {
12
+ "path": "v2/vocab.txt",
13
+ "sha256": "8757cbccfe7417468b67f7543996c5a457520ffe00a7839def6177d09ee90963",
14
+ "size": 444290
15
+ }
16
+ },
17
+ "tokenizer": {
18
+ "type": "bert-wordpiece",
19
+ "lowercase": false,
20
+ "unk": "[UNK]",
21
+ "cls": "[CLS]",
22
+ "sep": "[SEP]",
23
+ "continuingPrefix": "##",
24
+ "maxCharsPerWord": 100
25
+ },
26
+ "maxLength": 128,
27
+ "maxWindows": 8,
28
+ "inputs": {
29
+ "ids": "input_ids",
30
+ "mask": "attention_mask",
31
+ "types": "token_type_ids",
32
+ "dtype": "int32"
33
+ },
34
+ "output": "logits",
35
+ "labels": [
36
+ null,
37
+ "toxic"
38
+ ],
39
+ "threshold": 0.5
40
+ }
manifest-v1.json ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": "textdetox-bert-multilingual-int8-v1",
3
+ "source": "https://huggingface.co/textdetox/bert-multilingual-toxicity-classifier",
4
+ "license": "openrail++",
5
+ "files": {
6
+ "model": {
7
+ "path": "v1/model.onnx",
8
+ "sha256": "7848310732d59be089d16c0b680efc7231415d9d758b8799dbee65205454fc4a",
9
+ "size": 178612680
10
+ },
11
+ "vocab": {
12
+ "path": "v1/vocab.txt",
13
+ "sha256": "fe0fda7c425b48c516fc8f160d594c8022a0808447475c1a7c6d6479763f310c",
14
+ "size": 995526
15
+ }
16
+ },
17
+ "tokenizer": {
18
+ "type": "bert-wordpiece",
19
+ "lowercase": false,
20
+ "unk": "[UNK]",
21
+ "cls": "[CLS]",
22
+ "sep": "[SEP]",
23
+ "continuingPrefix": "##",
24
+ "maxCharsPerWord": 100
25
+ },
26
+ "maxLength": 128,
27
+ "maxWindows": 8,
28
+ "inputs": {
29
+ "ids": "input_ids",
30
+ "mask": "attention_mask",
31
+ "types": "token_type_ids",
32
+ "dtype": "int32"
33
+ },
34
+ "output": "logits",
35
+ "labels": [
36
+ null,
37
+ "toxic"
38
+ ],
39
+ "threshold": 0.5
40
+ }
v2/L5/model.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:92fe15d8dc2bd81ef999b5d0b3b4992e8fa58091cafdce871b40a15160fd6a5b
3
+ size 52346473
v2/L8/model.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:61bf1b03add4172446972b27059d50c6475958fbb5bfd063d2a920a12dfe4c94
3
+ size 81597346
v2/vocab.txt ADDED
The diff for this file is too large to render. See raw diff