DEV Community

Cover image for SPLADE Search: Combining Keyword Search with Semantic Understanding
kevinrawal
kevinrawal

Posted on

SPLADE Search: Combining Keyword Search with Semantic Understanding

Imagine searching for:

"How to fix a car that won't start?"

But your document contains:

"Troubleshooting a vehicle with engine ignition failure."

A traditional keyword search might struggle because the query and document use different words.

Dense retrieval might understand their semantic similarity, but it doesn't explicitly preserve traditional keyword matching.

This is where SPLADE comes in.

What is SPLADE?

SPLADE stands for Sparse Lexical and Expansion Model.

It is a neural information retrieval model that combines two important ideas:

  • Lexical matching: Matching important words between queries and documents.
  • Term expansion: Understanding related terms that might not explicitly appear in the original text.

In simple terms, SPLADE expands your query and documents with relevant terms and assigns importance weights to them.

Unlike dense retrieval, which represents text using fixed-size dense vectors, SPLADE generates sparse vectors over a vocabulary.

How does SPLADE work?

Let's understand it step by step.

1. Input text

We provide a query or document to a pre-trained language model.

2. Term expansion

The model predicts additional relevant vocabulary terms based on the context.

For example:

Original query:

car won't start

Possible expanded terms:

vehicle, engine, ignition, battery, starting, automobile

These are illustrative terms, not fixed outputs.

3. Term weighting

Not every term is equally important.

SPLADE assigns a weight to each term based on its importance.

For example:

Term Weight
car 0.9
engine 0.8
ignition 0.7
vehicle 0.6
battery 0.5

4. Sparse representation

The resulting representation contains weights for selected vocabulary terms, while most vocabulary dimensions remain zero.

When searching, SPLADE compares query and document representations using a dot product.

Documents with stronger matching term weights receive higher relevance scores.

The important part is that SPLADE can find relevant documents even when the exact query words aren't present.

BM25 vs Dense Search vs SPLADE

Let's compare the three approaches:

Feature BM25 Dense Search SPLADE
Representation Sparse Dense Sparse
Exact term matching Yes Not explicit Yes
Semantic expansion No Yes Yes
Inverted index Yes No (typically ANN) Yes
Interpretability High Lower Higher

SPLADE offers an interesting middle ground: learned semantic expansion while retaining the benefits of sparse lexical retrieval.

Where does SPLADE fit in RAG?

In a RAG pipeline, retrieval quality directly affects the quality of the context provided to the LLM.

SPLADE can be used as a retriever to improve document discovery, especially when users phrase queries differently from the language used in documents.

It can also be combined with other retrieval approaches, such as BM25 and dense retrieval, in a hybrid retrieval pipeline.

Final Thoughts

SPLADE is an interesting approach because it doesn't force us to choose entirely between keyword-based and semantic retrieval.

It brings language-model understanding into sparse retrieval while retaining explicit term-level matching.

For anyone building search systems or RAG applications, SPLADE is definitely worth exploring.

Further reading:

Top comments (0)