๐ค Renumics RAG: Explore and Visualize RAG Data
The Renumics RAG project is a demonstration tool designed to showcase retrieval-augmented generation (RAG) capabilities by using LangChain and Streamlit. This tool is particularly suitable for exploring RAG data, offering both a command-line interface and a graphical user interface (GUI) for an interactive experience.
๐ ๏ธ Installation
To get started with the Renumics RAG project, one needs to first set up a virtual environment within the project directory. This ensures that all necessary dependencies can be installed without interfering with the system's global Python environment.
python3.8 -m venv .venv
source .venv/bin/activate # For Linux/MacOS
# .\.venv\Scripts\activate.bat # For Windows CMD
# .\.venv\Scripts\activate.ps1 # For PowerShell
pip install -IU pip setuptools wheel
Once the virtual environment is active, the RAG demo package, along with some additional dependencies, can be installed. This supports either GPU or CPU environments, depending on the available hardware.
# For GPU support
pip install renumics-rag[all]@git+https://github.com/Renumics/renumics-rag.git torch torchvision sentence-transformers accelerate
# For CPU support
# pip install renumics-rag[all]@git+https://github.com/Renumics/renumics-rag.git torch torchvision sentence-transformers accelerate --extra-index-url https://download.pytorch.org/whl/cpu
โ๏ธ Local Setup
For those interested in modifying the project, it's advised to clone the repository and install it in an editable mode. This setup enables direct modifications to the source code and immediate testing.
To clone the repository:
git clone [email protected]:Renumics/renumics-rag.git
In either method, using pip
or poetry
, the setup requires similar steps. It's important to have the virtual environment activated before proceeding with installation and configuration.
โ๏ธ Configuration
For operations using OpenAI models, users need to create a .env
file containing relevant API keys. Depending on whether the models are accessed through OpenAI directly or via Azure, the contents of the .env
file will vary slightly.
For OpenAI models:
OPENAI_API_KEY="Your OpenAI API key"
When using Azure:
OPENAI_API_TYPE="azure"
OPENAI_API_VERSION="2023-08-01-preview"
AZURE_OPENAI_API_KEY="Your Azure OpenAI API key"
AZURE_OPENAI_ENDPOINT="Your Azure OpenAI endpoint"
๐ Usage: Indexing and Questioning
The tool helps users index documents to later retrieve relevant information and generate answers. Users can download a demo database or create their own dataset by placing documents in a specified directory.
To start indexing documents, run:
create-db
Once documents are indexed, the tool can retrieve relevant documents or provide answers to specific queries through command-line commands or a web application.
To retrieve documents:
retrieve "Your question here"
To answer questions:
answer "Your question here"
Launching a web application is also possible, where users can input questions through a GUI:
app
The GUI provides an interactive way to choose from different language models (like OpenAI or Hugging Face), adjust retrieval settings, and view detailed sources used for generating answers.
๐ Interactive Exploration
Renumics RAG allows users to interactively explore the questions and document snippets through a visualization tool called Renumics Spotlight. This visualization assists in understanding the distribution and clustering of questions and documents.
By exploring, users can see how different document clusters correspond to various topics, such as race statistics in the F1 dataset, and identify how frequently certain documents are referenced.
๐ Tutorials and References
For those eager to delve deeper into the visualization techniques available in RAG, the project showcases a couple of detailed tutorials on data visualization:
-
Visualize your RAG Dataโ-โEDA for Retrieval-Augmented Generation: This tutorial emphasizes the use of visualization in enhancing the understanding and evaluation of RAG systems.
-
Evaluate your Retrieval-Augmented Generation System with Ragas: Another insightful article available that focuses on using visualization to explore embeddings and understand the clustering of data in the context of RAG systems.
These articles are complemented with rich visualizations that showcase how questions and document relationships can be interpreted and analyzed for better insight into RAG system performances.