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:
+1
-1
@@ -25,7 +25,7 @@ A bi-encoder (all-MiniLM-L6-v2) retrieves candidates, a cross-encoder (ms-marco-
|
|||||||
|
|
||||||
## Run
|
## 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 |
|
| Output | Shows |
|
||||||
|---|---|
|
|---|---|
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
# One question, the bi-encoder's top 8, rescored
|
# One question, the bi-encoder's top 8, rescored
|
||||||
|
|
||||||
question: A buyer told their bank they never got the item. What now?
|
question: Meaning of E-4133
|
||||||
gold passage: G-04
|
gold passage: E-4133
|
||||||
|
|
||||||
retrieved id cosine cross-encoder logit
|
retrieved id cosine cross-encoder logit
|
||||||
1 G-06 0.446 -7.40
|
1 E-4134 0.424 4.27
|
||||||
2 G-04 0.440 -8.06
|
2 E-4140 0.405 2.17
|
||||||
3 E-4117 0.418 -11.08
|
3 E-4135 0.394 3.98
|
||||||
4 E-4101 0.418 -11.30
|
4 E-4130 0.393 0.73
|
||||||
5 G-03 0.405 -10.33
|
5 E-4133 0.386 4.90
|
||||||
6 E-4140 0.403 -9.91
|
6 E-4139 0.377 2.85
|
||||||
7 G-08 0.399 -9.62
|
7 E-4132 0.368 2.74
|
||||||
8 G-24 0.391 -9.61
|
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,6 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# Regenerates every file in output/ by running the test suite.
|
# 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.
|
# No database, no API key. Latency files (06, 07) depend on your machine; every other file is deterministic.
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
cd "$(dirname "$0")/.."
|
cd "$(dirname "$0")/.."
|
||||||
|
|||||||
@@ -32,12 +32,12 @@ class PairEncodingTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void oneQuestionByHand() {
|
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));
|
List<Document> candidates = Fixture.retriever().withTopK(8).retrieve(new Query(question));
|
||||||
float[] scores = Fixture.fp32().score(question, candidates.stream().map(Document::getText).toList());
|
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")) {
|
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("question: %s", question);
|
||||||
t.line("gold passage: G-04");
|
t.line("gold passage: E-4133");
|
||||||
t.blank();
|
t.blank();
|
||||||
t.line("%-9s %-7s %-12s %s", "retrieved", "id", "cosine", "cross-encoder logit");
|
t.line("%-9s %-7s %-12s %s", "retrieved", "id", "cosine", "cross-encoder logit");
|
||||||
int goldRetrieved = -1;
|
int goldRetrieved = -1;
|
||||||
@@ -45,7 +45,7 @@ class PairEncodingTest {
|
|||||||
for (int i = 0; i < candidates.size(); i++) {
|
for (int i = 0; i < candidates.size(); i++) {
|
||||||
Document d = candidates.get(i);
|
Document d = candidates.get(i);
|
||||||
t.line("%-9d %-7s %-12.3f %.2f", i + 1, d.getMetadata().get("pid"), d.getScore(), scores[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;
|
goldRetrieved = i + 1;
|
||||||
}
|
}
|
||||||
if (scores[i] > scores[best]) {
|
if (scores[i] > scores[best]) {
|
||||||
@@ -53,7 +53,7 @@ class PairEncodingTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
t.blank();
|
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"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user