Dense Retrieval with Quantity Comparison Intent (2025)

Abstract: Pre-trained language models (PLMs) fragment numerals and units that express quantities in arbitrary ways, depending on their subword vocabulary. Consequently, they are unable to contextualize the fragment embeddings well enough to be proficient with dense retrieval in domains like e-commerce and finance. Arithmetic inequality constraints (“laptop under 2 lb”) offer additional challenges. In response, we propose DeepQuant, a dense retrieval system built around a dense multi-vector index, but carefully engineered to elicit and exploit quantities and associated comparison intents. A novel component of our relevance score compares two quantities with compatible units, conditioned on a proposed comparison operator. The uncertain extractions of numerals, units and comparators are marginalized in a suitable manner. On two public and one proprietary e-commerce benchmark, DeepQuant is both faster and more accurate than popular PLMs. It also beats several competitive sparse and dense retrieval systems that do not take special cognizance of quantities.

## introduction transformer-based contextual text encoders @xcite @xcite have greatly enhanced dense retrieval @xcite in recent years. in several retrieval applications, such as in finance and e-commerce, quantities enjoy a central role. a quantity consists of a numeric component and possibly a unit, which implies the type of the quantity. e.g., a laptop may weigh 2.5 (numeral) lbs (unit of weight). units can be written in many ways @xcite . numerals can have diverse styles (use of comma vs period, or mantissa-exponent vs decimal). current transformer-based text encoders use byte-pair or subword @xcite dictionaries to fragment the input text. because this process is not tailored to quantities, numerals and possibly units are fragmented, and transformer networks have limited means to contextualize the fragments back into meaningful representations, resulting in limited numeracy (number representations that are effective for inference and generation) @xcite . additional complications arise in quantity cognizant search, because the quantities in the query are often associated with comparison intents. these are exceedingly common in e-commerce, e.g., xl shirt under 20 dollars, 2-way 6 amp switch, or phone with 10 hour battery. in the first query, the inequality constraint is explicit; in the third, a tablet with a 12-hour battery will be satisfactory (if not too expensive). in the second query, 2 requires a categorical match. such "common sense" is often baked into plms. a plm may even be able to model that a light car weighs about a ton, whereas a light laptop weighs under two pounds. if only plms were endowed with better quantity representations, and these could be exploited in search, such queries would perform better. our goal is to build a dense retriever with modest-sized plm as its encoder to fetch documents matching the quantitative inequality constraints in the natural language queries. we wish to capture the semantics of quantities in the same dense space as ordinary words, on both the query and corpus sides. our contributions: we present deepquant, a quantity and comparison-cognizant dense retrieval system. like several recent quantityoriented retrievers, deepquant preprocesses the quantity spans in a custom module before injecting quantity-derived features into a transformerbased encoder plm. the plm is fine-tuned to reconstruct masked quantities and their units, as well as contextual arithmetic comparison opera-tors expressed in natural language. through an attention-like structure that assists diagnostics and explainability, quantity constraints in the query are matched and scored against quantities in corpus documents. deepquant uses generic neural building blocks that are end-to-end trainable from relevance judgments. apart from two public data sets, we experiment with a proprietary data set (ecom) from a major e-commerce company, showing broad gains against sparse and dense retrievers and fine-tuned lms without special devices to handle quantities, and a large zero-shot plm. anonymized prototype code and data are available at https://anonymous.4open. science/r/proj-d9fe/ ## related work an emerging body of work @xcite @xcite @xcite seeks to address the gap between text indexes and quantity-rich queries. underlying lexical search (sparse retrieval) or execution engines (e.g., apache solr, sparql implementations) at last stage inference of these systems provide limited structured query interfaces (like sql) involving quantities and hence are not suited for end-user interaction. open-domain question answering, where the answer is a distribution over quantities, has been attempted on unstructured text @xcite and tables with quantities @xcite . semantic interpretation, e.g., text2sql @xcite , is applicable more for a structured (e.g., rdbms) rather than unstructured text corpus. in specific verticals such as agronomics, strict schemaadherent data can be extracted from text @xcite for structured query execution. also, none of these works addresses quantity comparisons. representing numbers meaningfully in language models (lm) is a parallel development @xcite @xcite . @xcite prepared a dataset for comparing numbers, which can be used to finetune lms. numeracy can be enhanced by laying anchors via unsupervised pre-training @xcite . alternatively, mathematical priors can help compute aggregated digit embeddings explicitly incorporating them into transformer mod-els @xcite . deepquant incorporates insights from @xcite , who adopted the (mantissa, exponent, unit, type) representation as a 'measurement' and pioneered reconstruction of masked measurements from context. they were not concerned with retrieval. apropos of retrieval, apart from a disjoint comparison of text and quantity, almasian et al. (2024a, section 3.3) propose a templated corpus augmentation method that highlights comparisons and unit surface forms. this is a data engineering approach: once a lm is tuned on this augmented corpus, scoring remains the same as in bm25 @xcite , colbert @xcite or splade @xcite . in contrast, we engineer both the encoding and scoring networks substantially, with clear payoffs. ## deepquant we describe deepquant in detail, guided by figure 1. to keep it simple, most of the exposition will make the assumption that the query has exactly one quantity associated with one comparison intent. this is the case in all but a vanishing minority of queries in all our data sets. however, deepquant applies equally to multiple comparisons; see appendix g. ## experiments we report on experiments with two public and one proprietary datasets, guided by the following research questions. rq1: how does deepquant compare with sparse and dense retrievers that do not implement special treatment of quantities? rq2: how does deepquant compare with pretrained lms in zero-shot mode? rq3: how do competitors compare when queries are bucketed by quantity magnitudes, and by α (that signifies the importance of quantities)? ## conclusion we introduced deepquant, a dense retrieval system that is tailored to queries with quantity comparison intent, as is overwhelmingly common in ecommerce and finance search. deepquant uses a plm fine-tuned for reconstructing masked quantities with units, as well as end-to-end passage ranking proficiency. it infers the nature of quantity comparison, and deploys a novel passage scoring function that incorporates (uncertain) comparison operators. experiments on three real-life datasets establish the promise of our approach.