ClouisleClouisle

Retrieval and Quality Tuning

Compare vector, full-text, hybrid, and rerank results in the retrieval lab, and diagnose failures per stage

Hit Testing (the retrieval lab) runs real retrieval without touching the production configuration and shows the intermediate values of each stage: recall, fusion, rerank, and final ranking. Use it to prove that a chunking change, a mode switch, or a weight change actually improved recall. Open it from the knowledge base detail page → Hit Testing (requires the kb:test permission).

Retrieval modes

ModeChannelRequest-level defaultKB setting defaultBest for
vectorVector (semantic)—nullQuestions phrased differently from the source; requires an embedding model
fulltextFull-text (keyword, BM25-style)—nullProper nouns, identifiers, error codes — exact strings
hybridBoth channels in parallel + RRF fusionhybridnullRecommended general default

There are two layers of defaults: a search request without search_mode runs as hybrid, while the knowledge base setting search_mode defaults to empty (null) and only becomes the default for that KB's Agent/workflow retrieval once you set it explicitly. Field definitions are in the Knowledge Base settings reference.

Hybrid may silently fall back to pure vector

hybrid is behind a rollout gate: if the site disables hybrid mode (retrieval_hybrid_mode = disabled, RETRIEVAL_HYBRID_KILL_SWITCH, or the team falls outside the rollout percentage), retrieval degrades silently to pure vector search with no separate degradation flag in the response. If hybrid is selected but keyword results are missing, first confirm with your administrator that hybrid is enabled for that team.

Parameter reference

The hit-testing panel lets you override the following (all optional):

ParameterUI defaultRangeNotes
Query query—1-1000 charactersMatched literally; no boolean operators, wildcards, or field syntax
Search mode search_modehybridvector / fulltext / hybridSee the table above
Max results top_k51-20Number of results (the KB setting allows 1-100)
Dense score threshold score_threshold00-1Drops vector recalls below that similarity
Dense weight dense_weight1.0>=0RRF weight of the vector channel in hybrid mode
Lexical weight lexical_weight1.0>=0RRF weight of the full-text channel in hybrid mode
rrf_k601-1000RRF rank constant; larger flattens rank differences
Rerank rerank_enabledtruebooleanOverrides the KB setting
Rerank candidate pool rerank_candidate_k101-100Candidates sent to the reranker; the UI uses max(top_k, candidate pool)
Rerank score threshold rerank_score_thresholdempty (disabled)0-1Drops results below that rerank score
Document filter filter_doc_idsemptylist of document IDsCurrently the only retrieval filter

Reranking needs a bound model

When the knowledge base has no rerank model bound, the UI does not send rerank parameters at all and rerank_enabled has no effect. Once a model is bound, rerank_enabled (default true) and rerank_candidate_k (default 10) from the KB settings apply automatically, and request parameters only override them when you fill them in.

How hybrid retrieval fuses channels

After both channels recall, results are merged by weighted reciprocal rank fusion (RRF):

score = Σ weight × 1 / (rrf_k + rank)
  • Each weight affects only its own channel: dense_weight for the vector channel, lexical_weight for the full-text channel; setting one to 0 disables that channel.
  • In hybrid mode the two weights cannot both be 0, or the request is rejected (the UI also disables the search button).
  • A smaller rrf_k favours the top-ranked results more strongly; a larger one flattens the ranking differences.

A/B comparison

Turn on A/B Comparison to run two configurations for the same query side by side:

  1. Configure side A and side B independently (each with its own mode, top_k, threshold, weights, and rerank parameters).
  2. The batch returns an independent result per configuration: a failure on one side never hides the other side's success, and the failing side reports its own reason.
  3. The result panel shows each side's ranks, the number of overlapping results (Overlap: N/total), and per-stage scores.

The batch endpoint POST /api/v1/knowledge-bases/{kb_id}/search/batch accepts up to 10 configurations, and each configuration id must be unique.

Retrieval lab results
Retrieval lab results: A/B ranks, overlap, and per-stage scores

Reading results and diagnostics

Every result carries the per-stage values, and final_score_stage tells you which stage decided the final order:

FieldMeaning
dense_score / dense_rankVector-channel similarity and rank (null means the chunk was not recalled by the vector channel)
lexical_score / lexical_rankFull-text BM25-style score and rank (no fixed upper bound)
fusion_score / fusion_rankRRF fusion score and rank
rerank_score / rerank_rank / rerank_reasonPairwise reranker score (0-1) and explanation
final_score_stageBasis of the final order: dense / lexical / fusion / rerank
degradation_reasonsChannel degradation reasons (for example full-text recall failed but vector results were still returned)

Stage timings timings are split into recall, rerank, context, and total, so you can tell whether recall or rerank is the slow part.

Diagnostics diagnostics may return:

CodeMeaningWhere to look
inactiveThe knowledge base is not activeEnable the knowledge base
missing_embedding_modelNo embedding model (pure vector mode)Bind an authorized embedding model to the KB
timeoutThe recall stage timed outLower top_k, narrow the scope, or check vector store load
failedRecall or fusion failedUse stage and the error category below

Failed requests carry retrieval_error_category and stage so you can pick a direction:

CategoryTypical causeDirection
configuration_mismatchEmbedding dimension does not match the indexVerify the model and dimension; rebuild the index after a model change
provider_authenticationInvalid model credentialsCheck the provider key and access rights
quota_or_rate_limitQuota or rate limitCheck quota and retry later
model_configurationModel missing, disabled, or incompatibleSelect or enable a compatible model
lexical_unavailableFull-text retrieval unavailableCheck PostgreSQL and pg_search, and that documents finished processing
provider_unavailableProvider unreachableRetry; if it persists, check the provider status
unknownAnything elseRetry or inspect server logs

Applying to production

A hit-testing configuration can be saved as a local preset (stored in the browser only, not synced across devices); then Apply to Production writes side A's configuration back into the knowledge base settings:

{
  "search_mode": "hybrid",
  "top_k": 5,
  "score_threshold": 0.0,
  "dense_weight": 1.0,
  "lexical_weight": 1.0,
  "rrf_k": 60,
  "rerank_enabled": true,
  "rerank_candidate_k": 10,
  "rerank_score_threshold": null
}

Before applying, confirm:

  • The embedding model and index dimension have not changed (otherwise rebuild the index first).
  • In hybrid mode at least one weight is greater than 0.
  • The knowledge base is actually referenced — what you write back is the knowledge base level default, and an Agent's retrieval_top_k, score_threshold, and search_mode still override it.

Not implemented / Roadmap

Adjacent-chunk expansion exists in the retrieval service but is not exposed by the public search API: the request body does not accept the parameter and a passed value is ignored. Query analytics, search history, and result export are likewise unavailable.

Troubleshooting

SymptomCheck first
Hybrid returns only keyword resultsWhether hybrid rollout is enabled for the team; whether degradation_reasons names a failing vector channel
Hit testing returns 0 resultsWhether documents are completed; whether score_threshold is too high; switch to fulltext to confirm the keyword exists
A "dimension mismatch" errorWhether the embedding model changed; whether embedding_dimension matches the vector collection
A full-text-unavailable errorPostgreSQL and pg_search; whether documents finished lexical indexing
Reranking has no effectWhether a rerank model is bound; whether rerank_enabled is true; whether the candidate pool is smaller than top_k
Results differ from productionHit testing runs with request parameters, while production retrieval also applies the Agent's retrieval_top_k/search_mode and the rollout gate

Common failures and recovery steps are also covered in the Knowledge Base settings reference; for tuning trade-offs see Knowledge Base Optimization.

How is this guide?

On this page