rerank: use an example where the cross-encoder fixes the order in 02, correct the download size

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Cfo2K4u4rF18QsPXPFnytf
This commit is contained in:
Claude
2026-10-24 18:03:45 +00:00
parent a429aa40f6
commit ff58ff0189
4 changed files with 17 additions and 17 deletions
+1 -1
View File
@@ -25,7 +25,7 @@ A bi-encoder (all-MiniLM-L6-v2) retrieves candidates, a cross-encoder (ms-marco-
## Run
`scripts/run-all.sh`. The first run downloads about 250 MB of model files. Every file in `output/` is written by a test that asserts the same facts. Files 06 and 07 contain wall-clock latency and depend on your machine; the others were identical across two consecutive runs.
`scripts/run-all.sh`. The first run downloads about 200 MB of model files. Every file in `output/` is written by a test that asserts the same facts. Files 06 and 07 contain wall-clock latency and depend on your machine; the others were identical across two consecutive runs.
| Output | Shows |
|---|---|
+11 -11
View File
@@ -1,16 +1,16 @@
# One question, the bi-encoder's top 8, rescored
question: A buyer told their bank they never got the item. What now?
gold passage: G-04
question: Meaning of E-4133
gold passage: E-4133
retrieved id cosine cross-encoder logit
1 G-06 0.446 -7.40
2 G-04 0.440 -8.06
3 E-4117 0.418 -11.08
4 E-4101 0.418 -11.30
5 G-03 0.405 -10.33
6 E-4140 0.403 -9.91
7 G-08 0.399 -9.62
8 G-24 0.391 -9.61
1 E-4134 0.424 4.27
2 E-4140 0.405 2.17
3 E-4135 0.394 3.98
4 E-4130 0.393 0.73
5 E-4133 0.386 4.90
6 E-4139 0.377 2.85
7 E-4132 0.368 2.74
8 E-4138 0.345 1.68
bi-encoder rank of G-04: 2; cross-encoder winner: G-06
bi-encoder rank of E-4133: 5; cross-encoder winner: E-4133
+1 -1
View File
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
# Regenerates every file in output/ by running the test suite.
# Needs: JDK 25, Maven, and internet on the first run (about 250 MB of models from Hugging Face, cached in ~/.cache/rerank).
# Needs: JDK 25, Maven, and internet on the first run (about 200 MB of models from Hugging Face, cached in ~/.cache/rerank).
# No database, no API key. Latency files (06, 07) depend on your machine; every other file is deterministic.
set -euo pipefail
cd "$(dirname "$0")/.."
@@ -32,12 +32,12 @@ class PairEncodingTest {
@Test
void oneQuestionByHand() {
String question = "A buyer told their bank they never got the item. What now?";
String question = "Meaning of E-4133";
List<Document> candidates = Fixture.retriever().withTopK(8).retrieve(new Query(question));
float[] scores = Fixture.fp32().score(question, candidates.stream().map(Document::getText).toList());
try (Transcript t = new Transcript("02-one-question-by-hand.txt", "One question, the bi-encoder's top 8, rescored")) {
t.line("question: %s", question);
t.line("gold passage: G-04");
t.line("gold passage: E-4133");
t.blank();
t.line("%-9s %-7s %-12s %s", "retrieved", "id", "cosine", "cross-encoder logit");
int goldRetrieved = -1;
@@ -45,7 +45,7 @@ class PairEncodingTest {
for (int i = 0; i < candidates.size(); i++) {
Document d = candidates.get(i);
t.line("%-9d %-7s %-12.3f %.2f", i + 1, d.getMetadata().get("pid"), d.getScore(), scores[i]);
if ("G-04".equals(d.getMetadata().get("pid"))) {
if ("E-4133".equals(d.getMetadata().get("pid"))) {
goldRetrieved = i + 1;
}
if (scores[i] > scores[best]) {
@@ -53,7 +53,7 @@ class PairEncodingTest {
}
}
t.blank();
t.line("bi-encoder rank of G-04: %d; cross-encoder winner: %s", goldRetrieved, candidates.get(best).getMetadata().get("pid"));
t.line("bi-encoder rank of E-4133: %d; cross-encoder winner: %s", goldRetrieved, candidates.get(best).getMetadata().get("pid"));
}
}
}