Knowledge Sprint SeriesMT24 Learning

Phase 13 · Sprint 40/90 · Semantic Search & RetrievalCormack · Thakur · Lin

Searching by Meaning: Dense & Hybrid Retrieval

Meaning finds what words miss. Here, words still ranked better.

In short. One vector per text, why keywords still won on this collection, fusing rankings by rank, and testing whether a small gain is real.

Sprint 40 of 90 infographic: Searching by Meaning: Dense & Hybrid Retrieval. Meaning finds what words miss. Here, words still ranked better. The full text of the image is on this page.
Full resolution2160 × 2700 PNGPhase summary

The part of the image you are reading lights up. Tap a part to jump to its text.

Fig. 1 in words

One collection, five retrievers · Cranfield 1 400 · same data as code 05

  1. 1 Five retrievers

    • nDCG@10, mean of 225 questions
    • GloVe mean 0.102 · BM25 + GloVe 0.258 · WordLlama 0.340 · BM25 0.382 · BM25 + WordLlama 0.395
    • fusion helps only with a good partner
  2. 2 Question by question

    • nDCG@10: BM25 (x) vs WordLlama (y), 0 to 1
    • WordLlama wins 75 · BM25 wins 119 · ties 31
    • p = 0.0012 for the mean gap of −0.042
  3. 3 Fuse by rank

    • question 52 · score = Σ 1 ÷ (60 + rank)
    • doc · grade · BM25 · WordL. · fused
    • 306 · 2 · 3 · 1 · 1
    • 1215 · — · 1 · 12 · 2
    • 326 · 4 · 13 · 2 · 3
    • 550 · — · 6 · 9 · 4
    • 306: 1 ÷ 63 + 1 ÷ 61 = 0.0323
    • nDCG@10 0.41 → 0.82
    • — = not judged · grade 2 beats grade 4
  4. 4 Is +0.013 real?

    • 100 000 random sign flips, hybrid − BM25
    • observed +0.013 · p ≈ 0.18 · axis -0.03 to +0.03
    • red: flips at least as far out

01 Text to One Vector Dense

  • A text becomes a point; nearness is the cosine (Sprint 33)
  • GloVe mean: 50 numbers per abstract, words averaged
  • WordLlama: 256 numbers from a token table trained for similarity, then averaged (Miller 2024)

Dense search began with LSI (Deerwester et al. 1990). Neither model here reads word order.

02 Keywords Still Win Here Claim

  • Claim: “search by meaning beats keyword search.” Here WordLlama 0.340 < BM25 0.382
  • It wins 75 questions and loses 119 (p = 0.0012)
  • BEIR, 18 data sets: “BM25 is a robust baseline” (Thakur et al. 2021)

Verdict: fails here, for a small static model on 1960s aerodynamics.

03 Fuse by Rank RRF

  • Reciprocal rank fusion: add 1 ÷ (60 + rank) from each list (Cormack et al. 2009)
  • Ranks need no score scaling: BM25 scores and cosines live on different scales
  • k barely matters: 10 → 0.400 · 60 → 0.395 · 100 → 0.396

Cormack et al. fixed k = 60 in a pilot and kept it through validation.

04 Is +0.013 Real? Test

  • Paired randomization test: flip the sign of each question’s gap 100 000 times
  • Hybrid − BM25 = +0.013, p ≈ 0.18: not shown better on 225 questions
  • A paired t-test agrees (p = 0.18); sign and Wilcoxon tests detect less (Smucker et al. 2007)

A bigger mean is not yet a better system.

05 Try It Yourself WORDLLAMA 0.4.0.POST1

sprint40_searching_by_meaning_dense_hybrid_retrieval.py

import numpy as np, gensim.downloader as api
from wordllama import WordLlama
from s39 import docs, qs, rel, bm25, ndcg, N    # Sprint 39's code

unit = lambda X: X / np.maximum(np.linalg.norm(X, axis=-1,
                                               keepdims=True), 1e-12)
glove = api.load("glove-wiki-gigaword-50")      # 400 000 words x 50
def glove_vec(words):             # mean of unit word vectors
    v = [unit(glove[w]) for w in words if w in glove]
    return unit(np.mean(v, 0)) if v else np.zeros(50)
wl = WordLlama.load(disable_download=True)      # trained, 256 numbers
wl_vec = lambda words: unit(wl.embed([" ".join(words)])[0])
D = {"glove": np.array([glove_vec(d) for d in docs]),
     "wl": unit(wl.embed([" ".join(d) for d in docs]))}

def rrf(*runs, k=60):             # reciprocal rank fusion
    out = np.zeros(N)
    for s in runs:
        r = np.empty(N)
        r[np.argsort(-s, kind="stable")] = np.arange(1, N + 1)
        out += 1 / (k + r)
    return out

runs = {"bm25": bm25,
        "glove": lambda q: D["glove"] @ glove_vec(q),
        "wl": lambda q: D["wl"] @ wl_vec(q),
        "bm25+wl": lambda q: rrf(bm25(q), D["wl"] @ wl_vec(q)),
        "bm25+glove": lambda q: rrf(bm25(q), D["glove"] @ glove_vec(q))}
S = {n: np.array([ndcg(f(q), rel[i + 1]) for i, q in enumerate(qs)])
     for n, f in runs.items()}
for n, v in S.items():
    print(f"nDCG@10 {n:10s} {v.mean():.3f}")
d = S["wl"] - S["bm25"]
print("wl vs bm25, queries won/lost/tied:",
      (d > 0).sum(), (d < 0).sum(), (d == 0).sum())
rng = np.random.default_rng(40)   # paired randomization test
for a in ("wl", "bm25+wl"):
    d = S[a] - S["bm25"]
    flip = np.abs((rng.choice([-1, 1], (100_000, d.size)) * d).mean(1))
    p = (flip >= abs(d.mean())).mean()
    print(f"{a} - bm25 = {d.mean():+.3f}, p = {p:.4f}")

Output, as printed on the image

nDCG@10 bm25       0.382
nDCG@10 glove      0.102
nDCG@10 wl         0.340
nDCG@10 bm25+wl    0.395
nDCG@10 bm25+glove 0.258
wl vs bm25, queries won/lost/tied: 75 119 31
wl - bm25 = -0.042, p = 0.0012
bm25+wl - bm25 = +0.013, p = 0.1811

Run it. sprint40_searching_by_meaning_dense_hybrid_retrieval.py · versions, data and steps

Check: 0.340 − 0.382 = −0.042 · 0.395 − 0.382 = +0.013 · 75 + 119 + 31 = 225 · gensim 4.4.0

06 General Notes Practice

  • “Hybrid always helps” fails: BM25 + GloVe 0.258 < BM25 alone
  • Lin (2018): neural rankers were often shown to beat weak or untuned baselines
  • On Sprint 39’s 393 word-mismatch pairs WordLlama ranks 250 of them higher: median rank 296 vs 479

Bridge: meaning finds what words miss, but only 11 of 393 reach its top 10. Fuse, then test per question.

07 Mini Project Hands-on

  • Load a transformer encoder (DPR, Karpukhin et al. 2020) and rerun all five
  • Weight the fusion: 2 ÷ (60 + rank) for BM25, then retest
  • Score only the mismatch pairs: which retriever finds them?

My container could not download one; yours may.

R Trusted Sources

  1. Thakur, Reimers, Rücklé, Srivastava & Gurevych (2021) BEIR, NeurIPS 2021
  2. Cormack, Clarke & Büttcher (2009) SIGIR, 758–759
  3. Karpukhin et al. (2020) EMNLP, 6769–6781
  4. Smucker, Allan & Carterette (2007) CIKM, 623–632
  5. Lin (2018) SIGIR Forum 52(2), 40–51
  6. Pennington, Socher & Manning (2014) GloVe, EMNLP, 1532–1543
  7. Miller (2024) WordLlama, github.com/dleemiller/WordLlama (MIT)
  8. Deerwester et al. (1990) JASIS 41(6), 391–407
  9. Cleverdon, Mills & Keen (1966) ASLIB Cranfield Research Project

Cite this phase

Tahri, M. (2026). MT24 Learning — Knowledge Sprint Series, Phase 13: Semantic Search & Retrieval (Version 1.0) [Educational resource]. Zenodo. https://doi.org/10.5281/zenodo.24012904

Version DOI 10.5281/zenodo.24012904 · all versions 10.5281/zenodo.24012903 · first published 27 October 2026