Rapid Rag
A Rapid Retrieval-Augmented Generation Framework
Overview
RapidRag is a Python package that simplifies the implementation of Retrieval-Augmented Generation (RAG) systems. The framework provides intuitive interfaces for document storage, embedding generation, LLM integration, and RAG pipeline construction.
This document serves as a comprehensive reference for data scientists and data engineers working with the RapidRag framework.
Table of Contents
Installation
Core Components
Document Stores
Embeddings
Language Models (LLMs)
RAG Implementation
Document Readers
Utilities
Quick Start
Advanced Usage
API Reference
Installation
RapidRag can be installed directly from the UI either at the environment level or the recipe level. Refer images below for more details
Dependencies
RapidRag relies on the following Python packages:
qdrant-client: For interacting with the Qdrant vector database
llama-index: For managing and querying document indices
openai: For integration with OpenAI's language models and embeddings
numpy: For numerical computations and vector operations
pandas: For data manipulation and analysis
requests: For making HTTP requests to external APIs
tqdm: For progress bar visualization during data processing
typing-extensions: For enhanced type hinting support in Python
These dependencies are installed in your environment when RapidRag is selected.
Core Components
Document Stores
RapidRag provides vector store interfaces for efficiently storing and retrieving embeddings.
Available Document Stores
Qdrant: A high-performance vector similarity search engine
Usage
Embeddings
RapidRag offers interfaces for various embedding models to convert text into vector representations.
Available Embedding Types
OpenAI Embeddings: Uses OpenAI's embedding models
OpenAI-like Embeddings: Compatible with services that provide an OpenAI-like API
Custom Embeddings: For custom embedding implementations
Usage
Language Models (LLMs)
RapidRag integrates with various LLM providers for generating responses.
Available LLM Types
OpenAI: Direct integration with OpenAI models
OpenAI-like: Compatible with services providing an OpenAI-like API
Usage
RAG Implementation
RapidRag provides a high-level SimpleRag
class for easy implementation of RAG systems.
Features
Document ingestion from files or text
Integration with Qdrant vector store
Query and chat interfaces
Revival of existing vector stores
Usage
Document Readers
RapidRag includes document readers for ingesting various file types into the RAG system.
Available Readers
OpenAIAssistantPDFReader: Uses OpenAI's Assistant API to extract structured data from PDF documents
Usage
Utilities
RapidRag provides utility modules to support the RAG implementation.
Enums
DocumentStore: Types of document stores (e.g.,
QDRANT
)IngestorType: Types of ingestors (e.g.,
DOCLING
)ModelType: Types of models (e.g.,
OPEN_AI
,OPEN_AI_LIKE
,CUSTOM
)
Quick Start
Here's a complete example to get started with RapidRag:
Advanced Usage
Reviving Existing Vector Stores
Customizing Node Parsing
Using Custom Embeddings
API Reference
Document Stores
get_document_store(store_type, **kwargs)
Returns an initialized document store instance.
Parameters:
store_type
(DocumentStore): Type of document store to use**kwargs
: Arguments passed to the document store constructor
Returns: Document store instance
Raises: NotImplementedError if unsupported document store is requested
qdrant(**qdrant_kwargs)
Returns an initialized QdrantVectorStore instance.
Parameters:
**qdrant_kwargs
: Arguments for the Qdrant vector store
Returns: QdrantVectorStore instance
Embeddings
get_embeddings_model(type, **kwargs)
Returns an interface for embedding models of the specified type.
Parameters:
type
(ModelType): Type of embedding model**kwargs
: Arguments passed to the embedding model constructor
Returns: Embedding model instance
Raises: NotImplementedError if embedding model type is not supported
RemoteEmbeddingModelInterface
A model interface that wraps remote embedding models with a common API.
Parameters:
api_base
(str): Base URL of the remote API endpointmodel
(str): Model identifier to use for encodinginstruction
(str, optional): Instruction for semantic searchembedding_type
(str, optional): Type of embedding to use
RemoteEmbeddingOpenaiLike
A remote embedding model that uses an OpenAI-like interface for encoding text.
Parameters:
api_base
(str): Base URL of the remote API endpointmodel
(str): Model identifier to use for encoding
Language Models (LLMs)
get_llms(model_type, **kwargs)
Returns a LLM interaction object.
Parameters:
model_type
(ModelType): Type of LLM**kwargs
: Arguments passed to the LLM constructor
Returns: LLM instance
get_openai(**kwargs)
Returns an OpenAI LLM instance.
get_openai_like(**kwargs)
Returns an OpenAI-like LLM instance.
RAG Implementation
SimpleRag
A simple Retrieval-Augmented Generation (RAG) engine that integrates with a vector store.
Constructor
Parameters:
index
(VectorStoreIndex): The vector store index
Methods
as_query_engine(**kwargs)
: Returns a query engine interfaceas_chat_engine(**kwargs)
: Returns a chat engine interfacefrom_text_with_qdrant(texts, collection_name, client, ...)
: Creates a SimpleRag from text inputfrom_document_with_qdrant(files_dir, collection_name, client, ...)
: Creates a SimpleRag from documentsrevive_vector_store(client, collection_name, ...)
: Revives an existing vector store
Document Readers
OpenAIAssistantPDFReader
A reader that uses OpenAI's Assistant API to extract structured data from PDF documents.
Parameters:
assistant_name
(str): Name of the assistantassistant_prompt
(str): Instructions for the assistantapi_key
(str, optional): OpenAI API keymodel
(str, default="gpt-4o"): OpenAI model to usedelete_thread
(bool, default=False): Whether to delete the thread after processingmessage
(str, optional): User message promptmeta_data_extraction_keys
(List[str], optional): Keys to extract as metadata
Methods
load_data(file_path)
: Loads and parses data from a PDF file
Utilities
Enums
DocumentStore
: Vector store types (QDRANT)IngestorType
: Ingestor types (DOCLING)ModelType
: Model types (CUSTOM, OPEN_AI, OPEN_AI_LIKE)
Last updated