RAG
Configure your end-to-end RAG
RAG Customization
RAG (Retrieval-Augmented Generation) in R2R can be extensively customized to suit various use cases. The main components for customization are:
- Generation Configuration: Control the language model’s behavior.
- Search Settings: Fine-tune the retrieval process.
- Task Prompt Override: Customize the system prompt for specific tasks.
LLM Provider Configuration
Refer to the LLM configuration page here.
Retrieval Configuration
Refer to the retrieval configuration page here.
Combining LLM and Retrieval Configuration for RAG
The rag_generation_config
parameter allows you to customize the language model’s behavior. Default settings are set on the server-side using the r2r.toml
, as described in in previous configuraiton guides. These settings can be overridden at runtime as shown below:
When performing a RAG query you can combine these vector search, knowledge graph search, and generation settings at runtime:
R2R defaults to the specified server-side settings when no runtime overrides are specified.
RAG Prompt Override
For specialized tasks, you can override the default RAG task prompt at runtime:
This prompt can also be set statically on as part of the server configuration process.
Agent-based Interaction
R2R supports multi-turn conversations and complex query processing through its agent endpoint:
The agent can break down complex queries into sub-tasks, leveraging both retrieval and generation capabilities to provide comprehensive responses. The settings specified in the example above will propagate to the agent and it’s tools.
By leveraging these configuration options, you can fine-tune R2R’s retrieval and generation process to best suit your specific use case and requirements.