Skip to content

arthurtran04/simple-RAG

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

image

Simple RAG (Retrieval Augemented Generation)

RAG Logo License Built with

This project is a lightweight web app for question-answering over PDFs using Retrieval Augmented Generation (RAG). Users upload a PDF, ask questions, and get answers based on the document content via a Hugging Face model.

Table of Contents

Prerequirements

Project Structure

simple-RAG/
├── static/
│   ├── style.css
│   └── script.js
├── templates/
│   └── index.html
├── .gitignore
├── server.py
├── worker.py
├── .env.example
├── Dockerfile
├── requirements.txt
├── LICENSE
└── README.md

Model

Architecture

flowchart TD
    A[User #40;Web Browser#41;] -- Prompt --> B[Flask Web Server<br/>#40;server.py#41;]
    B --> C[Worker<br/>#40;worker.py#41;]
    F[PDF file] -- Store --> D
    C --> D[Vector DB<br/>#40;Chroma#41;]
    C --> E[LLM]
    A -- Upload --> F
    D -- Retrieves context --> C
    E -- Generates answer --> C
    C -- Responds --> B
    B -- Returns answer --> A
Loading

Features

  • Upload and query PDF documents
  • RAG-powered chatbot interface
  • Uses Hugging Face models
  • Local semantic search with Chroma
  • Light/dark mode UI

Installation

To install this project, open your Terminal and follow these steps:

  1. Clone the repository:

    $ git clone https://github.com/arthurtran04/simple-RAG.git
  2. Change the directory to simple-RAG:

    $ cd "$(find . -type d -name "simple-RAG")"
  3. Create a Python virtual environment .venv and install the required dependencies:

    $ python -m venv .venv
    source .venv/bin/activate
    pip install -r requirements.txt
  4. Set up environment variables:

    $ cp .env.example .env
  5. Configure your .env file:

    # Hugging Face API Token
    HF_TOKEN=

How to get API Access Token

1. Go to Hugging Face website, click your avatar and click "Access Tokens"

2. Click "Create new token"

3. Name your token and tick the two checkboxes in the "Inference" section

4. Scroll down and click "Create token"

5. Copy your Access Token before closing and paste it into the HF_TOKEN variable inside the .env file

Usage

To start the application, run the server.py file:

$ python server.py

This application will run locally at http://127.0.0.1:5000:

Webpage

Upload your PDF file and enter your prompt in the textbox below, and the chatbot will respond:

Example

To stop the application, use Ctrl + C in the Terminal

License

This project is licensed under the Apache-2.0 License. See the LICENSE file for more details.

About

A Simple RAG Application.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 39.7%
  • JavaScript 28.8%
  • CSS 16.6%
  • HTML 14.3%
  • Dockerfile 0.6%