Giter VIP home page Giter VIP logo

rag_in_cpu's Introduction

Advanced Retrieval-Augmented Generation (RAG) System

This project implements an Advanced RAG system designed to work on a regular PC using all free resources, leveraging various APIs and tools to achieve this.

Models Used

  • Embedding Model: Utilized nomic-embed-text-v1 using HuggingFace API.
  • Reranker: Utilized rerank-english-v2.0 using Cohere API.
  • Language Model (LLM): Leveraged Groq API with llama3-70b-8192.

System Overview

System Architecture Diagram

The RAG system consists of the following components:

Chunking and Embedding:

Text data is chunked into manageable pieces. Each chunk is embedded using a model from HuggingFace. Embeddings are stored in a vector database (ChromaDB).

Retrieval and Reranking:

Relevant chunks are retrieved from ChromaDB based on the query. Retrieved chunks are reranked using the Cohere API to ensure the most relevant chunks are prioritized.

Response Generation:

The top-ranked chunks are passed to the Llama model (via Groq API) to generate a coherent and relevant response.

How to start

  1. Clone the repository
git clone https://github.com/AnasAber/RAG_in_CPU.git
  1. Install the dependencies
pip install -r requirements.txt
  1. Set up the setup.py file
py setup.py install
  1. Set up the environment variables
export GROQ_API_KEY="your_groq_api_key"
export COHERE_API_KEY="your_cohere_api_key"
export HUGGINGFACE_API_KEY="your_hugging
  1. Run the app.py file
python app.py

The reason why I'm using a virtual environment is to avoid any conflicts with the dependencies (I had to manually change things in configuration files), and to make sure that the project runs smoothly.

This project's RAG uses semantic search using ChromaDB, I'll work on doing a combination of Hybrid Search and a HyDE following the best practices of RAG mentioned in the following paper: link

System Architecture Diagram

If you encounter an error just hit me up, make a pull request, or report an issue, and I'll happily respond.

Disadvantages

  • For cohere API, it's free for testing and unlimited, but not for production use as it's paid

Next goals

  • See if there's a fast and good alternative to cohere api
  • Evaluating the performance of this RAG pipeline
  • Implement a combination of Hybrid Search and HyDE
  • Add Repacking after Reranking, and before giving the prompt back to the model

rag_in_cpu's People

Contributors

anasaber avatar

Stargazers

 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.