Retrievers explained

What is a Retriever

A Retriever in Gen AI Builder is a specialized Griptape Structure that defines how an AI Assistant retrieves relevant information from one or more Knowledge Bases at query time.

Retrievers form the core of Retrieval-Augmented Generation (RAG) pipelines:

  • They take the user’s question or Assistant task as input.
  • They run semantic and optional structured search across configured Knowledge Bases.
  • They return the most relevant "chunks" or documents.
  • The Assistant passes this retrieved content to the Large Language Model (LLM) as part of its input context.

In short: Retrievers connect your Assistant to your Knowledge Bases — grounding the AI in your organization’s content.

Why use Retrievers

  • Ground AI responses: Prevent hallucination by anchoring responses in trusted, current content.
  • Enable explainability: Retrieved content can be shown or cited in AI responses.
  • Power multi-KB search: Assistants can target multiple Knowledge Bases via a single Retriever.
  • Customize retrieval behavior: Max Tokens, metadata, and Griptape Structure logic enable fine-tuning.

Without Retrievers, Assistants can only rely on their base model knowledge — which is static and cannot reflect your organization's current content.

How do Retrievers work

Under the hood:

  1. User asks a question.
  2. Assistant sends this query to its assigned Retriever(s).
  3. Retriever (Griptape Structure) runs:
  • Vector search on unstructured content (using embeddings).
  • Structured filtering (if Hybrid KB is used and filters are specified).
  • Ranking and selection of relevant results.
  1. Retriever returns results to the Assistant:
  • Content is formatted as context for the LLM.
  • Optionally, references and metadata can be passed along.
  1. Assistant generates its response using the retrieved content.

This entire flow happens at query time — ensuring responses reflect the most current content in your Knowledge Bases.

The role of Griptape Structures

Retrievers are implemented as Griptape Structures — making them highly customizable.

The core structure typically defines:

  • Query preprocessing logic (if needed)
  • Search logic (vector search + filters)
  • Result post-processing and formatting
  • Optional metadata injection

This architecture allows organizations to:

  • Implement custom ranking strategies.
  • Apply domain-specific filters.
  • Enrich retrieved results with contextual tags.

See Structures explained for more on Griptape Structures.

Tuning and configuration points

Knowledge Bases selection

  • Select one or more Knowledge Bases to target.
  • A Retriever can search across multiple KBs — useful for broad Assistants.

Max Tokens

  • Controls the total size of content passed to the LLM.
  • Tuning guidance:
  • Too low → insufficient context for high-quality answers.
  • Too high → risk of LLM truncating the prompt or blowing past token limits.
  • Typical values: 1000–3000 depending on use case and LLM in use.

Metadata

  • Optional JSON object.
  • Use for:
  • Internal tracking and versioning
  • Configuring advanced search behavior (if supported by your Retriever Structure)
  • Passing hints to Assistants

Filters (Hybrid KB)

  • If targeting a Hybrid Knowledge Base, structured filters can be applied (e.g., region, product, price).
  • The Retriever Structure must support applying these filters.

Patterns of use

Single-KB Retriever

  • Simple pattern — target one Knowledge Base.
  • Example: HR Policy Retriever → queries HR Policy KB.

Multi-KB Retriever

  • Targets multiple Knowledge Bases.
  • Useful when an Assistant covers broad domains.
  • Example: Support Assistant Retriever → queries Product Docs KB, Pricing Policies KB, Support FAQs KB.

Hybrid KB Retriever

  • Targets Hybrid Knowledge Base.
  • Supports structured filtering + semantic search.
  • Example: Product Catalog Retriever → allows user to search Product Catalog Hybrid KB with filters for Category, Price, etc.

Cross-domain Retriever

  • Designed for Assistants that switch "personas" or tasks.
  • Can be implemented as:
  • Single Retriever with dynamic KB selection
  • Multiple Retrievers assigned per task or Assistant persona

Common tuning scenarios

GoalTuning action
Limit long irrelevant documentsTune Max Tokens downward
Retrieve rich multi-paragraph contextTune Max Tokens upward
Filter by structured fieldsUse Hybrid KB with filters
Improve ranking qualityCustomize Griptape Structure
Enable multi-source RAGTarget multiple Knowledge Bases

Could this page be better? Report a problem or suggest an addition!