Semantic Search & Embeddings
Semantic search: BM25, dual encoders, HNSW, ColBERT, hybrid ranking and relevance evaluation.
Semantic search matches an information need to a document even when the author and the user use different words. For exact SKUs, names and numbers, lexical matching remains useful. That is why the Answerwell tool combines learned representations with BM25 and tests the hybrid on its own queries.
The lexical and vector stages
Section titled “The lexical and vector stages”BM25 takes into account term rarity, frequency saturation and document length [1]:
is the term frequency, the length, the average length, and are parameters. The IDF variant is fixed, for example for documents and documents containing the term.
DPR trains separate encoders for the query and the passage [2]. For a relevant and negative examples :
is the temperature and the similarity of the representations. Hard negatives help training, but a useful document wrongly labelled as negative distorts the objective. The corpus is chunked so that passages keep headings, units and the context of tables.
Index, re-ranking and fusion
Section titled “Index, re-ranking and fusion”HNSW uses a multi-layer graph for approximate nearest-neighbour search [3]. Connectivity and search-width parameters trade off memory, speed and recall. The ANN loss relative to exhaustive search over the same vectors is measured separately: index quality and embedding quality are different properties.
ColBERT models late interaction between tokens [4]:
Each query token is matched to the closest document token. This is more expensive than a single vector, but it keeps a more detailed correspondence. A cross-encoder, by contrast, processes the pair jointly and is usually applied to a limited set of candidates.
To combine rankings, Reciprocal Rank Fusion applies [5]:
is a smoothing constant; a document missing from a ranking gets no term. Fusing positions avoids having to compare incompatible BM25 and cosine values directly.
Evaluation protocol
Section titled “Evaluation protocol”| Stage | Metric | Question |
|---|---|---|
| Candidates | Recall@100 | Is the needed evidence there |
| Final list | NDCG@10, MRR | How useful the order is |
| Infrastructure | p95, memory, index size | Can search run within the budget |
| Abstention | Quality of “not found” answers | Are irrelevant results forced on the user |
BEIR shows the importance of testing across different domains [6]. For our own set, say 500 queries, relevance is annotated on several grades of usefulness; similar rephrasings are not split randomly between training and test. Queries with an SKU, a negation, a date and no available answer are tested separately.
High similarity does not prove factual support: “supports export” and “does not support export” can have close vectors. Evaluating the generator without checking the first stage hides a retrieval failure. A new embedding version requires consistent reindexing, not mixing vector spaces.
Reproducibility and how Answerwell applies it
Section titled “Reproducibility and how Answerwell applies it”In the project’s research loop, Answerwell’s own robots and ML/DL models are applied to brand data. The grounds for each architecture, corpus versions, training parameters and compute are recorded according to the general methodology. Public, acquired and internal data each keep their own provenance; describing a method does not mean a proven match with the closed weights of an external platform.
The test set is separated from training by time and by object. Raw observations, failed attempts and unknown values are kept. Models are compared on the same data and budget, with the sample size and errors by segment reported. Illustrative calculations in this article are not a claim about an experiment Answerwell has carried out.
Sources
Section titled “Sources”- Stephen Robertson, Hugo Zaragoza. The Probabilistic Relevance Framework: BM25 and Beyond, 2009. Monograph.
- Vladimir Karpukhin et al. Dense Passage Retrieval, 2020. Paper.
- Yu. Malkov, D. Yashunin. Hierarchical Navigable Small World Graphs, 2016/2020. Paper.
- Omar Khattab, Matei Zaharia. ColBERT, 2020. Paper.
- Gordon Cormack, Charles Clarke, Stefan Buettcher. Reciprocal Rank Fusion, 2009. SIGIR.
- Nandan Thakur et al. BEIR, 2021. Benchmark.