FDS-Iterations commited on
Commit
d3875fa
·
verified ·
1 Parent(s): 3aa395c

Publish third-pass feed ranker

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ tokenizer.json filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ language:
4
+ - multilingual
5
+ tags:
6
+ - cross-encoder
7
+ - reranker
8
+ - feed-ranking
9
+ - onnx
10
+ - int8
11
+ pipeline_tag: text-classification
12
+ base_model: cross-encoder/mmarco-mMiniLMv2-L12-H384-v1
13
+ library_name: optimum
14
+ ---
15
+
16
+ # Third-Pass Feed Ranker — ONNX + INT8
17
+
18
+ ONNX and dynamically-quantized **INT8** builds of the [third-pass feed ranker](../) for fast
19
+ **CPU** inference. Same model, two files:
20
+
21
+ | file | precision | size | notes |
22
+ |---|---|---|---|
23
+ | `model.onnx` | fp32 | ~471 MB | scores are **identical** to the PyTorch model |
24
+ | `model_quantized.onnx` | int8 (dynamic) | ~118 MB | **4× smaller**; scores within ~0.05 of fp32 (ranking order preserved) |
25
+
26
+ ## CPU throughput (job_title × post scoring)
27
+ Measured on a desktop CPU (AVX2/AVX-VNNI, no AVX-512), 8 threads:
28
+
29
+ | build | items/sec |
30
+ |---|---|
31
+ | onnx fp32 | ~910 |
32
+ | **onnx int8** | **~1080 (~1.2×)** |
33
+
34
+ On **server CPUs with AVX-512 VNNI** (e.g. Intel Xeon Scalable), the INT8 speedup is typically
35
+ **2–4×** — this desktop under-shows it. Absolute rates depend on post length.
36
+
37
+ ## Usage
38
+ ```python
39
+ from optimum.onnxruntime import ORTModelForSequenceClassification
40
+ from transformers import AutoTokenizer
41
+ import torch
42
+
43
+ name = "you/third-pass-feed-ranker-onnx"
44
+ tok = AutoTokenizer.from_pretrained(name)
45
+ model = ORTModelForSequenceClassification.from_pretrained(name, file_name="model_quantized.onnx") # or model.onnx
46
+
47
+ title, posts = "Registered Nurse", ["Updated sepsis screening pathway is now live.", "Q3 revenue beat expectations!"]
48
+ enc = tok([title]*len(posts), posts, truncation=True, max_length=160, padding=True, return_tensors="pt")
49
+ scores = model(**enc).logits.squeeze(-1).tolist() # higher = more relevant
50
+ ```
51
+
52
+ The promotion/gate logic (which item to move to slot 1, and when) is **not** in the model — see
53
+ the base model card for the decision-logic snippet. This repo only provides the CPU-optimized
54
+ scorer. Trained on **synthetic data**; validate on your own before production. See the base model
55
+ card for full evaluation, limitations, and license/attribution.
config.json ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "XLMRobertaForSequenceClassification"
4
+ ],
5
+ "attention_probs_dropout_prob": 0.1,
6
+ "bos_token_id": 0,
7
+ "classifier_dropout": null,
8
+ "dtype": "float32",
9
+ "eos_token_id": 2,
10
+ "hidden_act": "gelu",
11
+ "hidden_dropout_prob": 0.1,
12
+ "hidden_size": 384,
13
+ "id2label": {
14
+ "0": "LABEL_0"
15
+ },
16
+ "initializer_range": 0.02,
17
+ "intermediate_size": 1536,
18
+ "label2id": {
19
+ "LABEL_0": 0
20
+ },
21
+ "layer_norm_eps": 1e-05,
22
+ "max_position_embeddings": 514,
23
+ "model_type": "xlm-roberta",
24
+ "num_attention_heads": 12,
25
+ "num_hidden_layers": 12,
26
+ "pad_token_id": 1,
27
+ "position_embedding_type": "absolute",
28
+ "problem_type": "regression",
29
+ "sbert_ce_default_activation_function": "torch.nn.modules.linear.Identity",
30
+ "transformers_version": "4.57.6",
31
+ "type_vocab_size": 1,
32
+ "use_cache": false,
33
+ "vocab_size": 250002
34
+ }
model.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b77beb06a32bc9e45f34efee574f43a0c4d2cb0fb678f8ba9ea549d78d8997d6
3
+ size 470787224
model_quantized.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7742ff5d5a1755222b2d5deabd097ed7ead0a25e1800265751b2ef27508a828d
3
+ size 118276448
ort_config.json ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "one_external_file": true,
3
+ "opset": null,
4
+ "optimization": {},
5
+ "quantization": {
6
+ "activations_dtype": "QUInt8",
7
+ "activations_symmetric": false,
8
+ "format": "QOperator",
9
+ "is_static": false,
10
+ "mode": "IntegerOps",
11
+ "nodes_to_exclude": [],
12
+ "nodes_to_quantize": [],
13
+ "operators_to_quantize": [
14
+ "Conv",
15
+ "MatMul",
16
+ "Attention",
17
+ "LSTM",
18
+ "Gather",
19
+ "Transpose",
20
+ "EmbedLayerNormalization"
21
+ ],
22
+ "per_channel": false,
23
+ "qdq_add_pair_to_weight": false,
24
+ "qdq_dedicated_pair": false,
25
+ "qdq_op_type_per_channel_support_to_axis": {
26
+ "MatMul": 1
27
+ },
28
+ "reduce_range": false,
29
+ "weights_dtype": "QUInt8",
30
+ "weights_symmetric": true
31
+ },
32
+ "use_external_data_format": false
33
+ }
special_tokens_map.json ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": {
3
+ "content": "<s>",
4
+ "lstrip": false,
5
+ "normalized": false,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "cls_token": {
10
+ "content": "<s>",
11
+ "lstrip": false,
12
+ "normalized": false,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "eos_token": {
17
+ "content": "</s>",
18
+ "lstrip": false,
19
+ "normalized": false,
20
+ "rstrip": false,
21
+ "single_word": false
22
+ },
23
+ "mask_token": {
24
+ "content": "<mask>",
25
+ "lstrip": true,
26
+ "normalized": false,
27
+ "rstrip": false,
28
+ "single_word": false
29
+ },
30
+ "pad_token": {
31
+ "content": "<pad>",
32
+ "lstrip": false,
33
+ "normalized": false,
34
+ "rstrip": false,
35
+ "single_word": false
36
+ },
37
+ "sep_token": {
38
+ "content": "</s>",
39
+ "lstrip": false,
40
+ "normalized": false,
41
+ "rstrip": false,
42
+ "single_word": false
43
+ },
44
+ "unk_token": {
45
+ "content": "<unk>",
46
+ "lstrip": false,
47
+ "normalized": false,
48
+ "rstrip": false,
49
+ "single_word": false
50
+ }
51
+ }
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3ed3aba76839292e668a3726cf01dfaf90cbc141502955998c4bc233aac28ce6
3
+ size 17082832
tokenizer_config.json ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": true,
3
+ "added_tokens_decoder": {
4
+ "0": {
5
+ "content": "<s>",
6
+ "lstrip": false,
7
+ "normalized": false,
8
+ "rstrip": false,
9
+ "single_word": false,
10
+ "special": true
11
+ },
12
+ "1": {
13
+ "content": "<pad>",
14
+ "lstrip": false,
15
+ "normalized": false,
16
+ "rstrip": false,
17
+ "single_word": false,
18
+ "special": true
19
+ },
20
+ "2": {
21
+ "content": "</s>",
22
+ "lstrip": false,
23
+ "normalized": false,
24
+ "rstrip": false,
25
+ "single_word": false,
26
+ "special": true
27
+ },
28
+ "3": {
29
+ "content": "<unk>",
30
+ "lstrip": false,
31
+ "normalized": false,
32
+ "rstrip": false,
33
+ "single_word": false,
34
+ "special": true
35
+ },
36
+ "250001": {
37
+ "content": "<mask>",
38
+ "lstrip": true,
39
+ "normalized": false,
40
+ "rstrip": false,
41
+ "single_word": false,
42
+ "special": true
43
+ }
44
+ },
45
+ "backend": "tokenizers",
46
+ "bos_token": "<s>",
47
+ "clean_up_tokenization_spaces": false,
48
+ "cls_token": "<s>",
49
+ "eos_token": "</s>",
50
+ "extra_special_tokens": {},
51
+ "is_local": false,
52
+ "local_files_only": false,
53
+ "mask_token": "<mask>",
54
+ "max_length": 160,
55
+ "model_max_length": 512,
56
+ "pad_token": "<pad>",
57
+ "sep_token": "</s>",
58
+ "stride": 0,
59
+ "tokenizer_class": "XLMRobertaTokenizerFast",
60
+ "truncation_side": "right",
61
+ "truncation_strategy": "longest_first",
62
+ "unk_token": "<unk>"
63
+ }