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.
- Recursive text splitting
- Text chunking
- Building embeddings
- Storing embeddings in a CSV file
- Searching based on cosine similarity
- Inference from local LLM/API
-
Clone the repository:
git clone https://github.com/adityaghai07/GenRAG.git cd GenRAG -
Create and activate a virtual environment:
python3 -m venv env source env/bin/activate # On Windows use `env\Scripts\activate`
-
Install the required dependencies:
pip install -r requirements.txt
-
Add a PDF file to the
datafolder and change the path in the script as necessary. -
Create embeddings by running:
python3 create_embeddings.py
You should see a CSV file generated in the
datafolder. -
Run the main script:
python3 main.py
Enter your query when prompted.
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
.envfile and pass the Gemini API key.
- Create a
.envfile in the root directory of the project. - Add your Gemini API key to the
.envfile:GEMINI_API_KEY=your_api_key_here
- The system will use the API key for generating responses through the Gemini API.
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch
git checkout -b feature/AmazingFeature
- Commit your Changes
git commit -m 'Add some AmazingFeature' - Push to the Branch
git push origin feature/AmazingFeature- Open a Pull Request
Special thanks to the following YouTube channels and research papers for their invaluable resources and insights:
- 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
This project is licensed under the MIT License - see the LICENSE file for details.