BM25 scoring and parameter tuning 00:00:01 One battery reference or six One article mentions battery once. Another mentions battery six times and has a different length. Which should rank higher for the word battery? Start by separating the inputs instead of assuming repetition alone settles relevance. For the first comparison, suppose two otherwise comparable documents each contain three hundred words. One has a single battery mention, the other has six. That isolates what the frequency term does. For a single shared term in the same index, both candidates receive the same inverse-document-frequency factor. We can focus on the remaining term-frequency and length factor before final scores are compared. Think of BM twenty-five as a family of lexical ranking formulas. Comparing just two word counts leaves out the corpus frequency, length normalization and parameters. To understand one component, hold the other inputs still. 00:01:02 Diminishing returns for repetition Set k one to one point two and turn length normalization off for this first calculation. Going from zero mentions to one gives a frequency factor of one. With six occurrences, that factor is thirteen point two divided by seven point two, about one point eight three. This is rational saturation; it is not a logarithm applied to repetitions. Positive k one changes the shape of that saturation. Six mentions have given more evidence than one, but nothing close to six times as much in this worked example. With length normalization disabled, the single-term frequency factor is term frequency times k one plus one, divided by term frequency plus k one. The numerator and denominator both grow, which is why the sixth appearance adds less than the first. 00:01:56 Compare document lengths Now keep the six mentions and vary only length. Compare a three-hundred-word article with an eight-hundred-forty-word article against a collection average of four hundred twenty words. Set b to zero and document length has no effect on this part of the score. Both six-mention documents have the same term-frequency factor under those assumptions. With positive b, the longer-than-average document receives stronger length normalization at the same frequency. Its overall relevance still depends on the entire query and evidence in the document. The length parameter controls how much the document-to-average-length ratio enters the denominator. A high score for a short piece is a model preference, not a judgment that every detailed manual is worse. 00:02:44 Rarity is another input The rarity of battery in the corpus affects its IDF score. If few documents mention it, each mention counts more toward relevance. I compute each query term’s contribution using the current tokenizer and indexing setup. The sum of these parts determines the final score. Scoring depends on how terms were split and stored during indexing. If the system treated 'battery' as 'batteries', the match would differ. For a multiword query, add the relevant term contributions under one consistent implementation. A document mentioning several informative query terms can rank above one that repeats only a single familiar word. 00:03:25 Evaluate the setting Try several reasonable k one and b settings on labeled battery queries. Tune on one set, then evaluate on held-out queries to see whether a change generalizes. Inspect both a short runbook and a longer manual a reviewer considered relevant. Overall metrics can improve while a valuable class of documents becomes harder to find. Compare measured relevance and latency before choosing a setting. A parameter adjustment may help this collection, but no improvement should be claimed before the appropriate experiment. The operator can now explain a changed ordering by pointing to repetition, document length, rarity or a different query. That explanation is much more valuable than claiming that a tuned numerical score means a reader will like the result.