AI 服務暫時不可用,以下為來源正文,待恢復後補全翻譯。
Learn Technical Articles miniCOIL: on the Road to Usable Sparse Neural Retrieval Back to Embedding Research miniCOIL: on the Road to Usable Sparse Neural Retrieval Evgeniya Sukhodolskaya · May 13, 2025 Have you ever heard of sparse neural retrieval? If so, have you used it in production? It’s a field with excellent potential – who wouldn’t want to use an approach that combines the strengths of dense and term-based text retrieval? Yet it’s not so popular. Is it due to the common curse of “What looks good on paper is not going to work in practice”?? This article describes our path towards sparse neural retrieval as it should be – lightweight term-based retrievers capable of distinguishing word meanings. Learning from the mistakes of previous attempts, we created miniCOIL, a new sparse neural candidate to take BM25’s place in hybrid searches. We’re happy to share it with you and are awaiting your feedback. The Good, the Bad and the Ugly Sparse neural retrieval is not so well known, as opposed to methods it’s based on – term-based and dense retrieval. Their weaknesses motivated this field’s development, guiding its evolution. Let’s follow its path. Retrievers evolution Term-based Retrieval Term-based retrieval usually treats text as a bag of words. These words play roles of different importance, contributing to the overall relevance score between a document and a query. Famous BM25 estimates words’ contribution based on their: Importance in a particular text – Term Frequency (TF) based. Significance within the whole corpus – Inverse Document Frequency (IDF) based. It also has several parameters reflecting typical text length in the corpus, the exact meaning of which you can check in our detailed breakdown of the BM25 formula. Precisely defining word importance within a text is nontrivial. BM25 is built on the idea that term importance can be defined statistically. This isn’t far from the truth in long texts, where frequent repetition of a certain word signals that the text is related to this concept. In very short texts – say, chunks for Retrieval Augmented Generation (RAG) – it’s less applicable, with TF of 0 or 1. We approached fixing it in our BM42 modification of BM25 algorithm. Yet there is one component of a word’s importance for retrieval, which is not considered in BM25 at all – word meaning. The same words have different meanings in different contexts, and it affects the text’s relevance. Think of “fruit bat” and “baseball bat"—the same importance in the text, different meanings. Dense Retrieval How to capture the meaning? Bag-of-words models like BM25 assume that words are placed in a text independently, while linguists say: “You shall know a word by the company it keeps” - John Rupert Firth This idea, together with the motivation to numerically express word relationships, powered the development of the second branch of retrieval – dense vectors. Transformer models with attention mechanisms solved the challenge of distinguishing word meanings within text context, making it a part of relevance matching in retrieval. Yet dense retrieval didn’t (and can’t) become a complete replacement for term-based retrieval. Dense retrievers are capable of broad semantic similarity searches, yet they lack precision when we need results including a specific keyword. It’s a fool’s errand – trying to make dense retrievers do exact matching, as they’re built in a paradigm where every word matches every other word semantically to some extent, and this semantic similarity depends on the training data of a particular model. Sparse Neural Retrieval So, on one side, we have weak control over matching, sometimes leading to too broad retrieval results, and on the other—lightweight, explainable and fast term-based retrievers like BM25, incapable of capturing semantics. Of course, we want the best of both worlds, fused in one model, no drawbacks included. Sparse neural retrieval evolution was pushed by this desire. Why sparse? Term-based retrieval can operate on sparse vectors, where each word in the text is assigned a non-zero value (its importance in this text). Why neural? Instead of deriving an importance score for a word based on its statistics, let’s use machine learning models capable of encoding words’ meaning. So why is it not widely used? Problems of modern sparse neural retrievers The detailed history of sparse neural retrieval makes for a whole other article. Summing a big part of it up, there were many attempts to map a word representation produced by a dense encoder to a single-valued importance score, and most of them never saw the real world outside of research papers (DeepImpact, TILDEv2, uniCOIL). Trained end-to-end on a relevance objective, most of the sparse encoders estimated word importance well only for a particular domain. Their out-of-domain accuracy, on datasets they hadn’t “seen” during training, was worse than BM25. The SOTA of sparse neural retrieval is SPLADE – (Sparse Lexical and Expansion Model). This model has made its way into retrieval systems - you can use SPLADE++ in Qdrant with FastEmbed. Yet there’s a catch. The “expansion” part of SPLADE’s name refers to a technique that combats against another weakness of term-based retrieval – vocabulary mismatch. While dense encoders can successfully connect related terms like “fruit bat” and “flying fox”, term-based retrieval fails at this task. SPLADE solves this problem by expanding documents and queries with additional fitting terms. However, it leads to SPLADE inference becoming heavy. Additionally, produced representations become not-so-sparse (so, consequently, not lightweight) and far less explainable as expansion choices are made by machine learning models. “Big man in a suit of armor. Take that off, what are you?” Experiments showed that SPLADE without its term expansion tells the same old story of sparse encoders — it performs worse than BM25. Eyes on the Prize: Usable Sparse Neural Retrieval Striving for perfection on specific benchmarks, the sparse neural retrieval field either produced models performing worse than BM25 out-of-domain(ironically, trained with BM25-based hard negatives) or models based on heavy document expansion, lowering sparsity. To be usable in production, the minimal criteria a sparse neural retriever should meet are: Producing lightweight sparse representations (it’s in the name!). Inheriting the perks of term-based retrieval, it should be lightweight and simple. For broader semantic search, there are dense retrievers. Being better than BM25 at ranking in different domains. The goal is a term-based retriever capable of distinguishing word meanings — what BM25 can’t do — preserving BM25’s out-of-domain, time-proven performance. The idea behind miniCOIL Inspired by COIL One of the attempts in the field of Sparse Neural Retrieval — Contextualized Inverted Lists (COIL) — stands out with its approach to term weights encoding. Instead of squishing high-dimensional token representations (usually 768-dimensional BERT embeddings) into a single number, COIL authors project them to smaller vectors of 32 dimensions. They propose storing these vectors in inverted lists of an inverted index (used in term-based retrieval) as is and comparing vector representations through dot product. This approach captures deeper semantics, a single number simply cannot convey all the nuanced meanings a word can have. Despite this advantage, COIL failed to gain widespread adoption for several key reasons: Inverted indexes are usually not designed to store vectors and perform vector operations. Trained end-to-end with a relevance objective on MS MARCO dataset, COIL’s performance is heavily domain-bound. Additionally, COIL operates on tokens, reusing BERT’s tokenizer. However, working at a word level is far better for term-based retrieval. Imagine we want to search for a “retriever” in our documentation. COIL will break it down into re, #trie, and #ver 32-dimensional vectors and match all three parts separately – not so convenient. However, COIL representations allow distinguishing homographs, a skill BM25 lacks. The best ideas don’t start from zero. We propose an approach built on top of COIL, keeping in mind what needs fixing: We should abandon end-to-end training on a relevance objective to get a model performant on out-of-domain data. There is not enough data to train a model able to generalize. We should keep representations sparse and reusable in a classic inverted index. We should fix tokenization. This problem is the easiest one to solve, as it was already done in several sparse neural retrievers, and we also learned to do it in our BM42. Standing on the Shoulders of BM25 BM25 has been a decent baseline across various domains for many years – and for a good reason. So why discard a time-proven formula? Instead of training our sparse neural retriever to assign words’ importance scores, let’s add a semantic COIL-inspired component to BM25 formula. $$ \text{score}(D,Q) = \sum_{i=1}^{N} \text{IDF}(q_i) \cdot \text{Importance}^{q_i}_{D} \cdot {\color{YellowGreen}\text{Meaning}^{q_i \times d_j}} \text{, where term } d_j \in D \text{ equals } q_i $$ Then, if we manage to capture a word’s meaning, our solution alone could work like BM25 combined with a semantically aware reranker – or, in other words: It could see the difference between homographs; When used with word stems, it could distinguish parts of speech. Meaning component And if our model stumbles upon a word it hasn’t “seen” during training, we can just fall back to the original BM25 formula! Bag-of-words in 4D COIL uses 32 values to describe one term. Do we need this many? How many words with 32 separate meanings could we name without additional research? Yet, even if we use fewer values in COIL representations, the initial problem of dense vectors not fitting into a classical inverted index persists. Unless… We perform a simple trick! miniCOIL vectors to sparse representation Imagine a bag-of-words sparse vector. Every word from the vocabulary takes up one cell. If the word is present in the encoded text — we assign some weight; if it isn’t — it equals zero. If we have a mini COIL vector describing a word’s meaning, for example, in 4D semantic space, we could just dedicate 4 consecutive cells for word in the sparse vector, one cell per “meaning” dimension. If we don’t, we could fall back to a classic one-cell description with a pure BM25 score. Such representations can be used in any standard inverted index. Training miniCOIL Now, we’re coming to the part where we need to somehow get this low-dimensional encapsulation of a word’s meaning – a miniCOIL vector. We want to work smarter, not harder, and rely as much as possible on time-proven solutions. Dense encoders are good at encoding a word’s meaning in its context, so it would be convenient to reuse their output. Moreover, we could kill two birds with one stone if we wanted to add miniCOIL to hybrid search – where dense encoder inference is done regardless. Reducing Dimensions Dense encoder outputs are high-dimensional, so we need to perform dimensionality reduction, which should preserve the word’s meaning in context. The goal is to: Avoid relevance objective and dependence on labelled datasets; Find a target capturing spatial relations between word’s meanings; Use the simplest architecture possible. Training Data We want [truncated for AI cost control]