redis-developer / llm-redisrail

RAG with Redis. Parallel implementations with/without guardrails.

Home Page:https://joeywhelan.blogspot.com/2024/02/redis-rag-with-nvidia-nemoguardrails.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Redis RAG with Rails

Contents

  1. Summary
  2. Architecture
  3. Features
  4. Prerequisites
  5. Installation
  6. Usage

Summary

This is a demo of usage of Redis as a vector store for Retrieval Augmented Generation (RAG) in two distinct scenarios:

  • Pure LangChain Expression Language (LCEL) chain with no safeguards on user or LLM interactions
  • NVIDIA NeMo-Guardrails implementation restricting both user inputs and LLM outputs Content from the Redis online documentation of Redis Vector Search is used for the RAG content. For the Guardrails implementation, questions and answers are restricted to the topic of Redis Vector Search.

Architecture

High-level Architecture

architecture

Application-level Architecture

app

Features

  • Redis Stack for the vector store
  • Python Bot server (Chainlit)
  • LangChain implementation of RAG with Redis
  • Parallel NVIDIA NeMo-Guardrails implementation of RAG with Redis

Prerequisites

  • Docker
  • Docker Compose
  • python3
  • git
  • pip

Installation

git clone https://github.com/redis-developer/llm-redisrail.git
cd llm-redisrail
python3 -m venv .venv
source .venv/bin/activate
pip install -qU python-dotenv redis bs4 langchain langchain_openai
  • Edit the .env_template file with your OpenAI key and rename the file to .env
  • By default, the guardrailed bot is executed. If you want a non-railed bot, change the MODE variable in docker-compose to 'chain'.

Usage

Environment Start Up

start.sh

Environment Shut Down

stop.sh

About

RAG with Redis. Parallel implementations with/without guardrails.

https://joeywhelan.blogspot.com/2024/02/redis-rag-with-nvidia-nemoguardrails.html

License:Other


Languages

Language:Python 92.2%Language:Dockerfile 5.1%Language:Shell 2.7%