faxenoff commited on
Commit
185f7ab
·
verified ·
1 Parent(s): 79efa93

compiled artefacts from win_x64 (sm_120)

Browse files
.gitattributes CHANGED
@@ -33,3 +33,8 @@ 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
+ code-daemon-reranker-v1_linux_x64_trt11.0_sm_120.engine filter=lfs diff=lfs merge=lfs -text
37
+ code-daemon-reranker-v1_win_x64_trt11.0_sm_120.engine filter=lfs diff=lfs merge=lfs -text
38
+ tokenizer.json filter=lfs diff=lfs merge=lfs -text
39
+ code-daemon-reranker-v1_linux_x64_tvm0.25_vulkan.so filter=lfs diff=lfs merge=lfs -text
40
+ code-daemon-reranker-v1_win_x64_tvm0.25_vulkan.dll filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,148 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ language:
4
+ - code
5
+ - multilingual
6
+ tags:
7
+ - code
8
+ - code-search
9
+ - code-retrieval
10
+ - reranker
11
+ - cross-encoder
12
+ - text-ranking
13
+ - knowledge-distillation
14
+ pipeline_tag: text-ranking
15
+ base_model:
16
+ - cross-encoder/mmarco-mMiniLMv2-L12-H384-v1
17
+ datasets:
18
+ - code_search_net
19
+ - unicamp-dl/mmarco
20
+ ---
21
+
22
+ # code-daemon-reranker-v1
23
+
24
+ A small, fast **cross-encoder reranker** purpose-built to re-order first-stage code-search hits for
25
+ precision. It ships with the [UltraCode](https://github.com/faxenoff/ultracode) MCP server as a
26
+ TensorRT / OpenVINO / TVM engine, scoring **(query, candidate)** pairs after the embedding retriever
27
+ has fetched a candidate pool.
28
+
29
+ A reranker is the **second stage**: the bi-encoder embed model
30
+ ([`code-daemon-embed-v1`](https://huggingface.co/faxenoff/code-daemon-embed-v1)) retrieves a pool fast,
31
+ then this cross-encoder reads each *(query, code)* pair **jointly** and emits a single relevance logit,
32
+ pulling the best match to the top. Joint attention over the pair is far more precise than the cosine of
33
+ two independent vectors — at the cost of one forward pass per candidate, so it scores only a bounded
34
+ pool (~64), not the whole index.
35
+
36
+ - **~117M params** — XLM-RoBERTa **12 layers / 384 hidden**, 250k multilingual SentencePiece vocab
37
+ (the embedding table dominates the size).
38
+ - **2-input ONNX** (`input_ids`, `attention_mask`; no `token_type_ids`) → a single relevance **logit**.
39
+ - **Max sequence 256** tokens for the concatenated *(query, document)* pair.
40
+ - **Listwise-trained** — the key quality lever (below).
41
+
42
+ ## How it was made
43
+
44
+ **Warm-started** from [`cross-encoder/mmarco-mMiniLMv2-L12-H384-v1`](https://huggingface.co/cross-encoder/mmarco-mMiniLMv2-L12-H384-v1)
45
+ (a strong multilingual MS MARCO cross-encoder) and **fine-tuned with a listwise loss** — **ListNet
46
+ top-1 softmax cross-entropy** over each query's *{1 positive + ≤8 hard negatives}* group. The hard
47
+ negatives were mined by the code retriever
48
+ [`nomic-ai/CodeRankEmbed`](https://huggingface.co/nomic-ai/CodeRankEmbed) from CoIR (NL→code,
49
+ code-dominant 0.75 share): the documents the first stage confuses with the answer are exactly what the
50
+ reranker must learn to push down. Trained on ~99k query groups, 2 epochs, on a single A100.
51
+
52
+ **Why listwise (not pointwise BCE):** a listwise loss optimizes the *order of the whole candidate
53
+ group*, not each pair in isolation, so it spends capacity on the **top of the list** — which is all a
54
+ reranker is for. Against the same model trained with pointwise BCE, listwise lifted **Hit@1 +0.12 and
55
+ MRR +0.10** on our golden set; recall (Hit@5/@10) is unchanged because that ceiling is set by the
56
+ first-stage retriever, not the reranker.
57
+
58
+ ## Built for speed
59
+
60
+ - **Short context (256)** — a *(query, code-unit)* pair is short; there is no long-document path.
61
+ - **Bounded pool** — the daemon reranks only the top ~64 fused candidates (the relevant file often sits
62
+ at fused rank 30–60), then cuts back to top-k *after* reranking.
63
+ - **Runs on the iGPU.** On a box with both NVIDIA + Intel, the daemon routes the reranker to the
64
+ **Intel iGPU (OpenVINO fp16)** and keeps CUDA free for the embedding model — the two search stages run
65
+ on different devices in parallel. TensorRT (NVIDIA) and TVM/Vulkan engines are bundled for boxes
66
+ without an Intel iGPU.
67
+ - **fp16** — mmarco-format INT8 on the iGPU hits a known OpenVINO AccessViolation, so fp16 is shipped.
68
+
69
+ ## Intended use
70
+
71
+ Re-rank a candidate pool from a first-stage retriever for **NL→code search** (multilingual text works
72
+ too). Feed *(query, candidate)* pairs, take the logit, sort descending. The score is a **raw, unbounded
73
+ logit** (Identity head) — compare relatively *within* a query, not against a fixed threshold.
74
+
75
+ ```python
76
+ import onnxruntime as ort, numpy as np
77
+ from transformers import AutoTokenizer
78
+
79
+ tok = AutoTokenizer.from_pretrained(".") # bundled XLM-R SentencePiece
80
+ sess = ort.InferenceSession("model.onnx", providers=["CPUExecutionProvider"])
81
+
82
+ def rerank(query, docs, max_len=256):
83
+ enc = tok([query] * len(docs), docs, padding=True, truncation=True,
84
+ max_length=max_len, return_tensors="np", return_token_type_ids=False)
85
+ logits = sess.run(None, {"input_ids": enc["input_ids"].astype(np.int64),
86
+ "attention_mask": enc["attention_mask"].astype(np.int64)})[0]
87
+ return sorted(zip(logits.reshape(-1).tolist(), docs), reverse=True) # higher = more relevant
88
+ ```
89
+
90
+ ## What's in this repo — ready-to-run compiled engines
91
+
92
+ Named per **runtime × GPU arch × OS** (single-profile — no length buckets):
93
+
94
+ - **TensorRT** `code-daemon-reranker-v1_{win_x64,linux_x64}_trt_sm_{86,89,120}.engine` — NVIDIA, fp16
95
+ (sm_86 ≈ RTX 30xx / A-series · sm_89 ≈ RTX 40xx / L4 · sm_120 ≈ RTX 50xx).
96
+ - **OpenVINO** `code-daemon-reranker-v1_ov_{cpu,igpu}_fp16_b16_s256.{xml,bin}` — Intel CPU / iGPU.
97
+ - **TVM** `code-daemon-reranker-v1_*_tvm_vulkan.{dll,so}` — Vulkan fallback for non-TRT / other GPUs.
98
+ - **Tokenizer** — `sentencepiece.bpe.model` + `tokenizer_config.json` (XLM-R SP; the daemon loads it
99
+ directly).
100
+ - **ONNX source** — `model.onnx` FP32 (the build source + standalone `onnxruntime` / `optimum` use).
101
+
102
+ ## Evaluation
103
+
104
+ Measured on the daemon's own `search-gold` golden set (26 NL→code queries — its real query
105
+ distribution), reranking the embed retriever's top-64 pool. Metrics are advisory; manual review of the
106
+ failures is the source of truth.
107
+
108
+ | metric | embed-only | **+ reranker** | Δ |
109
+ |---|--:|--:|--:|
110
+ | Hit@1 | 0.42 | **0.54** | **+0.12** |
111
+ | Hit@3 | 0.62 | **0.77** | **+0.15** |
112
+ | Hit@5 | 0.73 | **0.77** | +0.04 |
113
+ | Hit@10 | 0.81 | 0.81 | 0 *(recall ceiling — set by the retriever)* |
114
+ | MRR@10 | 0.55 | **0.65** | **+0.10** |
115
+ | nDCG@10 | 0.59 | **0.67** | **+0.08** |
116
+
117
+ The gains concentrate on the **top of the list** (Hit@1, MRR, nDCG) — the listwise signature. Hit@10 is
118
+ flat because a reranker can only reorder what the retriever already fetched.
119
+
120
+ ## Performance
121
+
122
+ | Backend | Hardware | Rerank latency |
123
+ |---|---|--:|
124
+ | OpenVINO fp16 | Intel iGPU (Xe) | **~550 ms / 64-candidate pool** (~8.6 ms/candidate) |
125
+
126
+ The daemon runs the reranker on the iGPU so the NVIDIA GPU stays free for the embedding model; the
127
+ TensorRT path is faster per pass where an NVIDIA GPU is used for reranking.
128
+
129
+ ## License & training data
130
+
131
+ Released under the **MIT license** (the mmarco base + XLM-R backbone are MIT/Apache; fine-tuned weights
132
+ released MIT). Training-data transparency:
133
+
134
+ | Source | Note |
135
+ |---|---|
136
+ | `cross-encoder/mmarco-mMiniLMv2-L12-H384-v1` (warm-start base) | **mMARCO ← MS MARCO → non-commercial research terms** |
137
+ | CoIR (NL→code hard-negative mining) | code-retrieval corpora; mixed upstream provenance |
138
+ | hard-neg miner `nomic-ai/CodeRankEmbed` | MIT |
139
+
140
+ ⚠️ The warm-start base derives from **MS MARCO (non-commercial)**. Whether a fine-tuned model inherits
141
+ dataset-use terms is legally unsettled; this is **not legal advice**. Retrain from a permissive base if
142
+ strict compliance is required.
143
+
144
+ ## Attribution
145
+
146
+ Warm-started from **[cross-encoder/mmarco-mMiniLMv2-L12-H384-v1](https://huggingface.co/cross-encoder/mmarco-mMiniLMv2-L12-H384-v1)**.
147
+ Hard negatives mined with **[nomic-ai/CodeRankEmbed](https://huggingface.co/nomic-ai/CodeRankEmbed)** (MIT).
148
+ Backbone: XLM-RoBERTa.
code-daemon-reranker-v1_linux_x64_trt11.0_sm_120.engine ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2c78582af9ce12d43ed61eccb7597cb3caedc1a3424fc62a3361f622b699d02a
3
+ size 240755356
code-daemon-reranker-v1_linux_x64_tvm0.25_vulkan.so ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6ad76ac886ef7adaf0c3c2f4d4759df299afc210b5a9adafc1a52cae117c62ad
3
+ size 471948752
code-daemon-reranker-v1_ov2026.2_cpu_fp16_b16_s256.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6f94b1400ef24846b666d7a49e0cdd9641ee62df6567de98b1418d074cc09bb0
3
+ size 235289514
code-daemon-reranker-v1_ov2026.2_cpu_fp16_b16_s256.xml ADDED
The diff for this file is too large to render. See raw diff
 
code-daemon-reranker-v1_ov2026.2_igpu_fp16_b16_s256.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6f94b1400ef24846b666d7a49e0cdd9641ee62df6567de98b1418d074cc09bb0
3
+ size 235289514
code-daemon-reranker-v1_ov2026.2_igpu_fp16_b16_s256.xml ADDED
The diff for this file is too large to render. See raw diff
 
code-daemon-reranker-v1_win_x64_trt11.0_sm_120.engine ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a09d0c27fd172f2e52857938cb364bd05f07ceb6905474edc25cbca64501f391
3
+ size 240727596
code-daemon-reranker-v1_win_x64_tvm0.25_vulkan.dll ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cccd7d3897a6c462b52076b83f7c09aaf86b7cc478a3a95cf9faf6c27e8318da
3
+ size 471798272
manifest.json ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_id": "code-daemon-reranker-v1",
3
+ "dimension": 1,
4
+ "max_tokens": 256,
5
+ "quantization": "fp16",
6
+ "targets": [
7
+ "openvino",
8
+ "tensorrt",
9
+ "tvm"
10
+ ],
11
+ "runtime_tags": {
12
+ "trt": "trt11.0",
13
+ "ov": "ov2026.2",
14
+ "tvm": "tvm0.25",
15
+ "mlx_dir": "model_gpu_mlx0.22"
16
+ },
17
+ "compiled_at": "2026-08-03T14:52:05Z",
18
+ "compiled_by": "models/_compile"
19
+ }
model.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e358b25d8f1704c834ea0817d740a6f9fefef4f1558971e7fdc5d388dbd4bc93
3
+ size 472163290
sentencepiece.bpe.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cfc8146abe2a0488e9e2a0c56de7952f7c11ab059eca145a0a727afce0db2865
3
+ size 5069051
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c0cb7277b7f6efc61e33bc5daf6f17142babb0bb68b2d5dd600c96471a90c62e
3
+ size 16766134