Beyond embeddings: combining vector and lexical search to improve relevance

Vadim Sklyarov25 Nov 2025

Problem

Search is often built on embeddings alone: documents are sorted by cosine similarity and the analyst must pick a cut-off between relevant and irrelevant. That threshold is unstable because the score depends on how the query is worded. Teams tune it by experiment and still cannot say why document D missed query Q.

Example from the article: a document about Scottish islands scored 0.6411, 0.5900 and 0.5805 for three paraphrases of one question, and 0.5547 for a question about Luxembourg's islands. A threshold of 0.6 loses two correct matches; 0.55 accepts the wrong one.

Solution in brief

Run two searches in parallel, vector and lexical (PostgreSQL full-text search restricted by named entities from the query), and merge their ranked lists with Reciprocal Rank Fusion. Documents found by both searches get a clearly higher fused score than documents found by one, so the result splits into groups without a hand-tuned threshold. No cross-encoder is needed; one database is enough.

Questions this case answers
  • How to separate relevant from irrelevant documents in a ranked list when the similarity score changes with every wording of the same query and no fixed threshold works
  • How to build an explainable retrieval step on a single database without heavy reranking models
  • How to decide which documents count as relevant when vector search returns only a ranked list of similarity scores?
  • How to explain to the business why a document did not appear in the results for a query?

Tools and methods

  • Reciprocal Rank Fusion (RRF) — merges the vector and lexical rankings using only positions.
  • PostgreSQL full-text search (ispell lemmatization) — lexical ranking of the candidates.
  • pgvector with LaBSE (cointegrated/LaBSE-en-ru) — vector search by cosine similarity.
  • spaCy named entity recognition — keywords that must be present in a relevant document.
  • k-means — proposed for splitting fused scores into clusters.
Continue reading — it's free

Google or a one-time email code. No password.