code-daemon-reranker-v1
A cross-encoder reranker for natural-language → code search. It reads a (query, candidate) pair and returns one relevance logit, and re-orders the top candidates of the Code-Daemon hybrid retriever (embeddings + BM25 + code graph).
What makes it different: it was fine-tuned on exactly what it sees when it serves — the candidate pools Code-Daemon's own retriever produces, with the retriever's own near-misses as negatives, and the document text in the form the search actually feeds it. A generic reranker learns from a proxy retriever's mistakes; this one learned from the ones it has to fix.
- ~117M parameters — XLM-RoBERTa, 12 layers × 384 hidden, multilingual 250k vocabulary.
- 2-input ONNX (
input_ids,attention_mask, notoken_type_ids) → one logit per pair. - 256 tokens per pair: the query is kept whole, the document's tail is cut.
The weights under this id were replaced on 2026-10-12. Same architecture, same inputs and outputs, same tokenizer; the backbone is now the MIT-licensed
hotchpotch/mMiniLMv2-L12-H384with no ranking stage in front of it. The previous revision (2026-09-13) was warm-started from an MS MARCO-derived ranker and scored 0.006 nDCG@10 higher on the same evaluation; the revision before that, a fine-tune on public pairs, scored below its own untuned base. Engines built for earlier weights are gone from this repository.
Numbers
Ten repositories never seen in training, 6 141 natural-language queries, Code-Daemon's own candidate pools (20 per query) re-scored and replayed offline with the daemon's ranking blend:
| reranker | hit@1 | hit@5 | MRR@10 | nDCG@10 |
|---|---|---|---|---|
| no reranker (the retriever alone) | 0.159 | 0.405 | 0.254 | 0.299 |
mmarco-mMiniLMv2-L12-H384-v1 (public, untuned) | 0.166 | 0.447 | 0.283 | 0.329 |
| this model | 0.166 | 0.465 | 0.293 | 0.339 |
- +0.040 nDCG@10 over the retriever alone and +0.010 over the public ranker of the same width, at the same cost — the architecture is the base's, so query latency is unchanged (about 55 ms end to end for retrieval plus 20 pairs on a laptop RTX 5060, TensorRT FP16).
- The gain sits in the middle of the list — hit@3 to hit@5 and MRR. It does not move the first result much.
- The trade is fit, not cost: the model is tuned to Code-Daemon's document shapes. Plain (query, code snippet) pairs work, but that is not what it was tuned on.
- Absolute numbers are low because the queries are single-positive at file level: a relevant neighbouring file scores zero. Read the difference between the rows, not the level.
How to use it
Re-rank the top ~20 candidates of a first-stage retriever. Feed (query, candidate) pairs, sort
by logit. The score is a raw logit — compare it within one query, not against a fixed threshold;
Code-Daemon takes sigmoid(logit) and blends it with the retriever's score.
import onnxruntime as ort, numpy as np
from transformers import AutoTokenizer
tok = AutoTokenizer.from_pretrained(".")
sess = ort.InferenceSession("model.onnx", providers=["CPUExecutionProvider"])
def rerank(query, docs, max_len=256):
enc = tok([query] * len(docs), docs, padding=True, truncation="only_second",
max_length=max_len, return_tensors="np", return_token_type_ids=False)
logits = sess.run(None, {"input_ids": enc["input_ids"].astype(np.int64),
"attention_mask": enc["attention_mask"].astype(np.int64)})[0]
return sorted(zip(logits.reshape(-1).tolist(), docs), reverse=True) # higher = more relevant
Documents. About 900 characters of code per candidate is what was measured above. Code-Daemon
often sends a candidate as a file header plus the matched entity's siblings, with a >>> marker
on the candidate itself; the model has seen that form.
Shapes. OpenVINO and Core ML ship batch 16 × seq 256 (Core ML also seq 64 and 128 — route short pairs there). Everything is FP16: under OpenVINO INT8 this graph hits a known access violation on the Intel iGPU.
How it was made
Starts from
hotchpotch/mMiniLMv2-L12-H384 —
Microsoft's multilingual MiniLM v2 (12 layers × 384, distilled from XLM-RoBERTa Large), a plain
masked-language-model encoder — with a freshly initialised [CLS] ranking head, and is
fine-tuned with a listwise objective (one positive against up to 16 negatives) on:
- behavioural queries written per code entity by an LLM that was not allowed to use the
entity's identifiers — "compare two hash hierarchies and return list of changed paths", not
diffMerkleTrees; - the candidate pools Code-Daemon's retriever returned for those queries, with negatives taken from the pool's uncertain band, over open-source repositories disjoint from the evaluation set.
The checkpoint was selected on the evaluation repositories' pools replayed offline.
Files
| file | what it is |
|---|---|
model.onnx + model.onnx.data | FP32 ONNX — the build source and the standalone path |
model.safetensors, config.json | the same weights as XLMRobertaForSequenceClassification; AutoModelForSequenceClassification loads them as-is; the Apple (MLX) build is prepared from this pair |
tokenizer.json, tokenizer_config.json, sentencepiece.bpe.model | the tokenizer — stock XLM-R |
code-daemon-reranker-v1_{win_x64,linux_x64}_trt11.3_sm_{75,80,86,89,90,120}.engine | TensorRT FP16 per OS × GPU; sm_90 (H100/H200) Linux only. The set is filled per architecture as each is built — the file list is the truth |
code-daemon-reranker-v1_ov2026.4_{cpu,igpu}_fp16_b16_s256.{xml,bin} | OpenVINO 2026.4 FP16, Intel CPU / iGPU |
code-daemon-reranker-v1_b128_s128_{win_x64,linux_x64}_tvm0.25_vulkan.{dll,so} | TVM Vulkan modules for GPUs without TensorRT or OpenVINO |
coreml_ane/embed.mlpackage/ | Core ML for the Apple Neural Engine, functions b16 s64 / s128 / s256; load with cpuAndNeuralEngine, fall back to MLX for other shapes |
License & attribution
Released under the MIT license.
Backbone: hotchpotch/mMiniLMv2-L12-H384 (MIT), Microsoft's Multilingual-MiniLM-L12-H384 distilled from XLM-RoBERTa Large.