fastrag.retrieval.base#

The Retriever contract: turning a query into documents.

Classes

Retriever()

Turns one query into the documents that answer it, best first.

class fastrag.retrieval.base.Retriever[source]#

Bases: ABC

Turns one query into the documents that answer it, best first.

One method, one required argument. Every other knob — k, filters, thresholds — is constructor configuration, so a retriever is a fully specified object that can be passed around, swapped, and benchmarked without its call sites knowing anything about it.

abstractmethod async retrieve(query, *, k=5)[source]#

Return at most k documents relevant to query, best first.

Parameters:
  • query (str) – Natural-language query text.

  • k (int) – Maximum number of documents to return.

Return type:

list[Document]