Giter Club home page Giter Club logo

enterprise-grade-rag's Introduction

Logo

Enterprise Grade RAG Solution Template

This is a template for Enterprise Grade RAG solution focusing on Low latency. The code is very modular and contains the most important elements and can be very easily extended for your needs.

Elements of RAG

  • Redis based Vector DB When a user uploads a document, it is chunked and passed through a embedding model, both chunk and embedding are stored in Redis.

  • Redis based Semantic cache A cache is used to store query embedding against previous chatbot responses. This is very important element because if your RAG is based upon some specific data most of the questions will be very similar so inorder to avoid redundant calls to a LLM.

  • Nemo Guardrails Guardrails can be used before call to LLM to check for off topic quries, this is also very important as it will not allow the quries which are not related to the topic for which the RAG is being designed and will save the cost of LLM call.

Flow of RAG

App Screenshot

  1. When a user enter a query on HTML frontend, it is passed to FAST API server.
  2. The user query will be passed to semantic cache and will be checked if exists in cache. If it exists then the response stored will be returned to the user.
  3. If query is not present in cache then the query will be passed to Nemo Guardrails.
  4. Guardrails will check the query and will follow that predefined flow which is semanticallly near to the query.
  5. I have defined a flow in guardrails that if query doesn't take any other flow it should be directed to a function which passes the query to Langchain QA chain.
  6. The chain will pass the query to LLM and the retrieved response will be saved in semantic cache and will be returned to the user on HTML page.

Deployment

Firstly redis server should be setup. We will use docker for it. Run the command below after downloading docker.

  docker run -d --name redis-stack-server -p 6379:6379 redis/redis-stack-server:latest

After this clone this repo and in the app folder run the command

   pip install -r requirements.txt

As Langchain and vectordb is using gpt 3.5 and embedding model so api-key is needed. You need to write your own api key inside the agent.py file.

Finally run the following command to setup a run FAST API server.

   python -m uvicorn main:app --reload

Contributers

https://github.com/salmanjann

Thank you for developing the frontend.

enterprise-grade-rag's People

Contributors

harras3 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.