Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

GenRAG

MIT License

GenRAG is a terminal tool designed to set up a Retrieval-Augmented Generation Pipeline locally from scratch, without utilizing any high-level frameworks like LangChain or vector databases. It includes features such as recursive text splitting, chunking, and building embeddings. The embeddings are stored in a CSV file,without using any Vector Databases and searching is based on cosine similarity.

Features

  • Recursive text splitting
  • Text chunking
  • Building embeddings
  • Storing embeddings in a CSV file
  • Searching based on cosine similarity
  • Inference from local LLM/API

Installation

  1. Clone the repository:

    git clone [repo name]
    cd GenRAG
  2. Create and activate a virtual environment:

    python3 -m venv env
    source env/bin/activate  # On Windows use `env\Scripts\activate`
  3. Install the required dependencies:

    pip install -r requirements.txt

Usage

  1. Add a PDF file to the data folder and change the path in the script as necessary.

  2. Create embeddings by running:

    python3 create_embeddings.py

    You should see a CSV file generated in the data folder.

  3. Run the main script:

    python3 main.py

    Enter your query when prompted.

LLM Response

You can use both a local LLM or an LLM from an API like Gemini for generating responses.

  • Local LLM: If you have the capability to run a local LLM, you can use it for generating responses. Cause mine is too slow :(

  • LLM from API: If your system is not powerful enough for local inference, you can use an API like Gemini. To do this, create a .env file and pass the Gemini API key.

Using Gemini API

  1. Create a .env file in the root directory of the project.
  2. Add your Gemini API key to the .env file:
    GEMINI_API_KEY=your_api_key_here
  3. The system will use the API key for generating responses through the Gemini API.

Credits

Research Papers

  • Patrick Lewis ., "Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks" arXiv:2005.11401
  • Vaswani et al., "Attention is All You Need" arXiv:1706.03762
  • Reimers et al., "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks" arXiv:1908.10084

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages