BMX: Entropy-weighted Similarity and Semantic-enhanced Lexical Search

Xianming Li, Julius Lipp, Aamir Shakir, Rui Huang, Jing LiarXiv 2024

Abstract

BM25, a widely-used lexical search algorithm, remains crucial in information retrieval despite the rise of pre-trained and large language models (PLMs/LLMs). However, it neglects query-document similarity and lacks semantic understanding, limiting its performance. We revisit BM25 and introduce BMX, a novel extension of BM25 incorporating entropy-weighted similarity and semantic enhancement techniques. Extensive experiments demonstrate that BMX consistently outperforms traditional BM25 and surpasses PLM/LLM-based dense retrieval in long-context and real-world retrieval benchmarks. This study bridges the gap between classical lexical search and modern semantic approaches, offering a promising direction for future information retrieval research.

Introduction

For decades, BM25 has been the "gold standard" for lexical search, powering engines like Lucene and Elasticsearch. It is prized for its efficiency and ability to work "out of the box" without training. However, BM25 has two major Achilles' heels: a lack of semantic understanding (it only looks for exact token matches) and the ignoring of global similarity (it doesn't account for the overall similarity between the query and the document structure).

While modern "dense" retrieval using vector embeddings solves the semantic problem, these models are often computationally expensive, struggle with very long documents, and don't generalize well to niche domains without fine-tuning. BMX seeks to provide lexical search with a semantic "brain transplant" without losing its efficiency and generalization strengths.

Methodology

BMX enhances the core BM25 formula through three key innovations:

  1. Entropy-weighted Similarity: Instead of treating all query terms with equal structural weight, BMX calculates the entropy of query tokens across the document set. This ensures that rare, highly informative tokens carry more weight. To prevent "keyword stuffing" from distorting results, a sigmoid function is used to cap the influence of highly repetitive terms.
  2. Weighted Query Augmentation (WQA): To add semantic depth, BMX uses a Large Language Model (LLM) to generate a set of augmented queries (synonyms or related phrases). These are combined with the original query into a single weighted scoring pass, maintaining high performance without separate searches.
  3. Score Normalization: BMX introduces a normalization technique to squash unconstrained BM25 scores into a predictable [0, 1] range, facilitating the setting of relevance thresholds.

Experimental Setup

BMX was evaluated across a diverse set of benchmarks:

  • BEIR: The industry-standard benchmark for zero-shot information retrieval across 15 tasks.
  • LoCo: Designed for long-context retrieval where documents exceed typical embedding model limits.
  • BRIGHT: A challenging benchmark focused on "reasoning-intensive" retrieval.
  • Multilingual Sets: Evaluation on Chinese, Japanese, Korean, German, and French datasets.

Key Results

BMX consistently demonstrates superior performance over traditional lexical methods and competitive performance against dense models.

Table 1: Performance comparison on BEIR benchmark tasks across embedding and lexical models.

On the BEIR benchmark, BMX outperformed all BM25 variants in 11 out of 15 cases. When combined with WQA, it surpassed the popular all-MiniLM-L6-v2 embedding model. In long-context (LoCo) scenarios, BMX outperformed several proprietary and open-source embedding models, including OpenAI’s ada-002, proving its strength in handling massive text blocks where neural models often suffer from context-window limitations.

Table 2: Performance on the BRIGHT reasoning-intensive benchmark.

On the reasoning-intensive BRIGHT benchmark, BMX + WQA achieved a score of 18.66, outperforming OpenAI's text-embedding-3-small (17.57) and Cohere’s embeddings. This highlights the effectiveness of blending LLM-generated synonyms into a lexical pipeline.

Conclusion

BMX demonstrates that improving the underlying mathematics of lexical search can yield massive gains, rivaling state-of-the-art neural models. By using a sigmoid function on term frequencies, BMX becomes robust against keyword stuffing. While indexing is slightly slower than BM25 due to entropy calculations, search speed remains comparable, making it viable for production. Future work will address hyperparameter sensitivity across different languages and the dependency on LLM latency for the WQA component.

The reference implementation of BMX is available in the open-source library Baguetter.

Summary updated

BibTeX
@misc{li2024bmx,
  author = {Xianming Li and Julius Lipp and Aamir Shakir and Rui Huang and Jing Li},
  title = {{BMX: Entropy-weighted Similarity and Semantic-enhanced Lexical Search}},
  year = {2024},
  eprint = {2408.06643},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2408.06643},
}
Figure