Skip to content

Retriever

A retriever in LlamaIndex is what is used to fetch Nodes from an index using a query string.

  • VectorIndexRetriever will fetch the top-k most similar nodes. Ideal for dense retrieval to find most relevant nodes.
  • SummaryIndexRetriever will fetch all nodes no matter the query. Ideal when complete context is necessary, e.g. analyzing large datasets.
  • SummaryIndexLLMRetriever utilizes an LLM to score and filter nodes based on relevancy to the query.
  • KeywordTableLLMRetriever uses an LLM to extract keywords from the query and retrieve relevant nodes based on keyword matches.
  • KeywordTableSimpleRetriever uses a basic frequency-based approach to extract keywords and retrieve nodes.
  • KeywordTableRAKERetriever uses the RAKE (Rapid Automatic Keyword Extraction) algorithm to extract keywords from the query, focusing on co-occurrence and context for keyword-based retrieval.
  • Bm25Retriever uses the BM25 algorithm to extract keywords from the query and retrieve relevant nodes based on keyword matches.
const retriever = vectorIndex.asRetriever({
similarityTopK: 3,
});
// Fetch nodes!
const nodesWithScore = await retriever.retrieve({ query: "query string" });
Note for AI agents: this documentation is built for programmatic access. - Overview of all docs: https://developers.llamaindex.ai/llms.txt - Any page is available as raw Markdown by appending index.md to its URL — e.g. https://developers.llamaindex.ai/llamaparse/parse/getting_started/index.md - Agent-friendly REST search APIs live under https://developers.llamaindex.ai/api/ — search (BM25 full-text), grep (regex), read (fetch a page), and list (browse the doc tree). See https://developers.llamaindex.ai/llms.txt for parameters. - A hosted documentation MCP server is available at https://developers.llamaindex.ai/mcp. If you support MCP, you can ask the user to install it for browsing these docs directly (an alternative to the REST API). Setup: https://developers.llamaindex.ai/python/shared/mcp/