agentskit.js
RAG

Hybrid search

Vector + BM25 blend with weighted normalization.

baseRetriever is any Retriever that already produces vector candidates.

createHybridRetriever(base, { vectorWeight?, bm25Weight?, topK?, candidatePool? }) returns a Retriever. Weights are relative and normalized before blending (defaults to 0.6 vector / 0.4 BM25); it considers up to 20 candidates and returns 5 by default. If both weights are zero, the blend uses 0.5 / 0.5.

import { createHybridRetriever } from '@agentskit/rag'

const hybrid = createHybridRetriever(baseRetriever, {
  vectorWeight: 0.7,
  bm25Weight: 0.3,
})

#When to use

Queries with rare keywords or exact tokens (error codes, SKUs, identifiers) that vector alone misses.

Explore nearby

✎ Edit this page on GitHubΒ·Found a problem? Open an issue β†’Β·How to contribute β†’

On this page

Ask the docs
Ask anything about AgentsKit. Answers come from the docs corpus and cite their sources.