BoolQuestions: Does Dense Retrieval Understand Boolean Logic in Language?

Zongmeng Zhang, Jinhua Zhu, Wengang Zhou, Xiang Qi, Peng Zhang, Houqiang Li

Abstract

Modern dense retrieval (DR) models are highly effective at semantic matching but often fail to respect basic logical constraints. This paper introduces BOOLQUESTIONS, a benchmark designed to evaluate DR models on Boolean logic (AND, OR, NOT). Results show that state-of-the-art models frequently ignore negation, returning documents containing the exact topics users wish to exclude. We propose a contrastive continual training method to improve logical grounding in dense encoders.

Introduction

Information Retrieval has evolved from keyword-based sparse retrieval to neural dense retrieval, which maps queries and documents into a shared semantic space. While this shift has improved synonym handling, it has introduced a "logic gap." Dense models prioritize semantic overlap; consequently, a query like "symptoms of flu but not COVID" often retrieves COVID-related documents because "flu" and "COVID" are semantically close. This paper quantifies this failure and explores methods to bridge the gap between semantic similarity and logical relevance.

The BOOLQUESTIONS Benchmark

To systematically study this issue, the authors developed BOOLQUESTIONS, a benchmark derived from the MS MARCO and Natural Questions (NQ) datasets. The dataset contains subsets specifically for AND, OR, and NOT operations, allowing researchers to pinpoint exactly where a model’s logic breaks down.

Automated Generation and Filtering

Since human-annotated logical queries are scarce, the authors leveraged GPT-4 to generate Boolean questions based on clusters of related passages. To ensure quality, they implemented a Cyclic Consistency Filtering process.

The automated pipeline for generating and filtering logically consistent Boolean questions.

In this pipeline, an LLM-based "Answerer" must successfully answer the generated question using the source passage. If the answer is incorrect or the question is unanswerable, the entry is discarded, ensuring the benchmark remains high-fidelity.

Experimental Results

The study evaluates several popular DR models, including DistilBERT, MiniLM, and larger instruct-tuned models like gte-Qwen2-7B-instruct.

The Failure of Negation

The most striking finding is the models' inability to handle the "NOT" operator. As shown in the results table, models that perform well on standard benchmarks struggle significantly with logical constraints.

Main results showing MRR and Negative Recall across different Boolean operators. Note the high NegRecall for NOT queries.

For example, distilbert-dot-v5 exhibits a NegRecall@10 of 54.62% on the MS MARCO NOT subset. This indicates that over half of the top-10 retrieved documents contained the negated term. Even large-scale models like gte-Qwen2-7B-instruct show a marked performance drop on NOT queries compared to their standard retrieval performance.

Boolean Contrastive Training

To address these failures, the authors propose Boolean Contrastive Continuous Training. By training models on triplets—a Boolean query, a positive passage, and a "hard negative" containing the excluded logic—they successfully reduced Negative Recall. For instance, on the MS MARCO NOT subset, Negative Recall dropped from 19.5% to 13.7% while maintaining competitive overall accuracy (MRR).

Discussion and Conclusion

The "logic gap" in dense retrieval highlights a fundamental limitation of current semantic embedding techniques. While "OR" queries are relatively well-handled (as they essentially expand the search scope), "NOT" queries act as structural constraints that current models often treat as additional context.

Future work should focus on scaling logical training data and exploring more complex, nested logical structures. For retrieval to be truly intelligent, it must move beyond simple semantic matching and begin to understand the formal logic embedded in human language.

Summary updated

BibTeX
@inproceedings{zhang2024boolquestions,
  author = {Zongmeng Zhang and Jinhua Zhu and Wengang Zhou and Xiang Qi and Peng Zhang and Houqiang Li},
  title = {{BoolQuestions: Does Dense Retrieval Understand Boolean Logic in Language?}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2024},
  doi = {10.18653/v1/2024.findings-emnlp.156},
}
Figure