← All questions
Retrieval & EmbeddingsMedium· BM25· Parameter Tuning· Ranking

Your BM25 index ranks a 40-page onboarding PDF above a two-sentence FAQ entry that answers the question exactly. Which constant do you turn, and which way?

Before adjusting constants, print the per-term contributions to determine if the failure is due to term frequency or document length. If the document is winning because it is long and length is not being penalized, increase b. If it is winning because of excessive term repetition, lower k1. Note that these adjustments involve trade-offs; for example, raising b may demote legitimately comprehensive documents.

Code playground (Python)