Skip to content

Simple Retrieval Augmented Generation (RAG) system built from scratch using Python, Llama 3, Groq and Nomic embeddings.

License

Notifications You must be signed in to change notification settings

ruizguille/rag-from-scratch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Retrieval Augmented Generation from Scratch: Inception RAG

This repository contains the code for a simple Retrieval Augmented Generation (RAG) system built from scratch using Python and open-source tools. It uses Llama 3 as a language model, powered by Groq, and Nomic embeddings. It includes Christopher Nolan's Inception movie script as a source document in the data/docs folder to build the RAG app, but you can add any documents of your choice.

For a detailed explanation of the code and the concepts behind RAG, check out this blog post.

This project was developed by CodeAwake.

Structure

The code is contained in the app/ folder and organized into the following files:

  • config.py: Configuration settings for the application.
  • loader.py: Loads and processes the pdf source documents for RAG (chunking, embedding and storing in vector store).
  • splitter.py: Text chunking functionality.
  • vector_store.py: Simple vector store implementation.
  • rag.py: Core RAG functionality and interactive Q&A loop.

Installation

Prerequisites ✅

  • Python 3.11 or higher
  • Poetry (Python package manager)

Instructions

  1. Install the dependencies using Poetry:

    poetry install
  2. Create a .env file copying the .env.example file provided and set the required environment variable:

    • GROQ_API_KEY: Your Groq API key.

Running the Application

To load the source pdf documents and process them for RAG:

poetry run load-docs

To run the interactive Q&A RAG app:

poetry run rag

About

Simple Retrieval Augmented Generation (RAG) system built from scratch using Python, Llama 3, Groq and Nomic embeddings.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages