What does Link Authority, Retrieval Truncation and Direct Answers conclude, in numbers, about “BM25 and Length Normalisation: the Term-Frequency Ledger of Stuffing, Padding and Direct Answers”?
Answer: Chapter 3 implements BM25 with the standard library and shows that stuffing soon peaks while padding is discounted by length: a twelve-word direct answer padded to two hundred and forty words keeps only 0.302 of its score.
Scope of the numbers: Its parameters are illustrative; all calculations are generated by its programs; the book is not personalised legal, financial or business advice and makes no promise about citation rankings in any system. Chapter 1 computes PageRank and HITS with power iteration and a random surfer: in an illustrative knowledge base with damping factor 0.85, the mother page receives 0.3240, or 2.59 times the uniform share.
Data table
The numbers below are printed verbatim by the chapter's Python program and can be reproduced by running it. standard-library Python onlyprinted values that match the answer: 25
| query: pagerank damping factor | avgdl 22.9 | ||||
| snippet | length | BM25 b=0.75 | rank | BM25 b=0 | rank |
| stuffed | 11 | 4.371 | 1 | 3.827 | 1 |
| def | 21 | 2.672 | 2 | 2.582 | 2 |
| faq | 16 | 2.154 | 3 | 1.889 | 3 |
| notes | 10 | 0.900 | 4 | 0.693 | 5 |
| long | 97 | 0.752 | 5 | 1.173 | 4 |
| bm25 | 8 | 0.000 | 6 | 0.000 | 6 |
| hits | 9 | 0.000 | 7 | 0.000 | 7 |
| rag | 11 | 0.000 | 8 | 0.000 | 8 |
| stuffed leads def by 1.700 at b=0.75 and 1.245 at b=0 |
Show the full program
# Chapter 3. p31: BM25 on an illustrative eight-snippet corpus.
# Score = sum over query terms of idf * tf (k1 + 1) /
# (tf + k1 (1 - b + b dl / avgdl)),
# idf = ln(1 + (N - n + 0.5) / (n + 0.5)), the non-negative variant.
# k1 = 1.2 and b = 0.75 are common defaults discussed by Robertson and
# Zaragoza (2009). Snippets and query are invented for illustration.
import math
from collections import Counter
FILL = ("our team has written this complete guide so that every reader"
" can learn all about search and links and why they matter for"
" a growing brand in a crowded market").split()
DOCS = {
"def": "pagerank damping factor d is the chance that the surfer"
" follows a link and brin and page used d of 0.85",
"faq": "what is the damping factor short answer the chance of"
" following a link rather than jumping",
"long": " ".join(FILL * 3 + "pagerank matters pagerank helps"
" pagerank grows pagerank".split()),
"stuffed": "pagerank pagerank pagerank damping damping factor"
" factor pagerank best pagerank guide",
"bm25": "bm25 scores terms by frequency and document length",
"hits": "hits computes hubs and authorities for a query subgraph",
"rag": "retrieval augmented generation puts the top k passages"
" into the prompt",
"notes": "notes on link analysis pagerank hits and the random"
" surfer",
}
QUERY = "pagerank damping factor".split()
def bm25(docs, query, k1=1.2, b=0.75):
toks = {k: v.split() for k, v in docs.items()}
n_docs = len(toks)
avgdl = math.fsum(len(t) for t in toks.values()) / n_docs
df = Counter()
for t in toks.values():
df.update(set(t))
out = {}
for k, t in toks.items():
tf = Counter(t)
s = []
for q in query:
idf = math.log(1 + (n_docs - df[q] + 0.5) / (df[q] + 0.5))
norm = k1 * (1 - b + b * len(t) / avgdl)
s.append(idf * tf[q] * (k1 + 1) / (tf[q] + norm))
out[k] = math.fsum(s)
return out, avgdl
if __name__ == "__main__":
full, avgdl = bm25(DOCS, QUERY)
flat, _ = bm25(DOCS, QUERY, b=0.0)
print("query: " + " ".join(QUERY) + " avgdl {:.1f}".format(avgdl))
print("snippet length BM25 b=0.75 rank BM25 b=0 rank")
r1 = sorted(full, key=lambda k: (-full[k], k))
r0 = sorted(flat, key=lambda k: (-flat[k], k))
for k in r1:
print("{:<9}{:7d}{:13.3f}{:6d}{:10.3f}{:6d}".format(
k, len(DOCS[k].split()), full[k], r1.index(k) + 1, flat[k],
r0.index(k) + 1))
print("stuffed leads def by {:.3f} at b=0.75 and {:.3f} at b=0".format(
full["stuffed"] - full["def"], flat["stuffed"] - flat["def"]))Single source and citation
Fan, Y. (2026). Hyperlink Authority Propagation in Machine-Readable Knowledge Bases, Retrieval-Truncation Games in Generative Answering and High-SNR Snippet Extraction (Version 1.0.0), Chapter 3: BM25 and Length Normalisation: the Term-Frequency Ledger of Stuffing, Padding and Direct Answers. 5D Library. DOI pending
DOI pending · monograph page goes live after publication · 5DL-B-176 · v1.0.0 · CC-BY-NC-ND-4.0
BibTeX
@book{fan2026176,
author = {Fan, Yafu},
title = {Hyperlink Authority Propagation in Machine-Readable Knowledge Bases, Retrieval-Truncation Games in Generative Answering and High-SNR Snippet Extraction},
year = {2026},
publisher = {5D Library},
edition = {1.0.0},
note = {DOI pending}
}Other chapter answers in this book
- Chapter 1 · Power Iteration and the Damping Factor: How Hyperlink Authority Flows Through a Knowledge Base
- Chapter 2 · The Mother Page: How Internal-Link Topology Concentrates Authority
- Chapter 4 · Top-k Truncation: the Probability that a Passage Enters the Context
- Chapter 5 · Competing for k Positions: Position Auctions, Homogenisation and the Commons
- Chapter 6 · Signal-to-Noise and Softmax Reranking: the Selection Gain of Direct-Answer Snippets
- Chapter 7 · The Classics Examined: Zheng Qiao's Classification and Bush's Associative Trails
- Chapter 8 · Practice and Falsification: the Copy Checker, a Publisher's Checklist and a Pre-Registered Test