JoaoGabrielSC/rag-vectordb

An application that leverages Retrieval-Augmented Generation (RAG) to provide answers to questions that are related to local documents

1

stars

23

commits

Python

primary language

Jul 19, 2025

updated

README

RAG - Retrieval Augmented Generation With Vector DB

This project provides a complete pipeline for extracting text from various document formats (PDF, Word, Images), chunking it, generating embeddings, and storing them in a Vector Database. It is designed to support document-based Retrieval-Augmented Generation (RAG) systems.

TODO

  • ...
  • Implement Services and Repositories to handle database operations (CRUD, queries, etc.)
  • [/] Add ML Embedding Model to transform raw data into vector embeddings
  • Add support for multiprocessing or multithreading to concurrently load and process chunked data (ETL load step)
  • Create the Retrieval API for querying and retrieving vectorized data

Overview

image

πŸ” Pipeline Steps (see diagram)

  1. Start – Begin the document ingestion process.

  2. Send Raw Documents – Upload raw documents such as PDFs, Word docs, or images.

  3. Text Extractor – Extract text from different file types using specialized parsers:

    • PDFs β†’ pdf_text_extractor.py
    • Images β†’ image_text_extractor.py (OCR)
  4. Splitter – Break extracted text into smaller chunks using a customizable splitter strategy.

  5. Parallel Chunk Processing – Process chunks in parallel using threads.

  6. Embedding Model – Convert each chunk into an embedding vector using a pre-trained model.

  7. Vector Database – Store the resulting embeddings in a vector store for fast retrieval.

Project Structure

  .
  β”œβ”€β”€ docker-compose.yaml
  β”œβ”€β”€ Dockerfile
  β”œβ”€β”€ examples
  β”‚Β Β  β”œβ”€β”€ image.png
  β”‚Β Β  └── volume_tracing.pdf
  β”œβ”€β”€ LICENSE
  β”œβ”€β”€ main.py
  β”œβ”€β”€ Makefile
  β”œβ”€β”€ mypy.ini
  β”œβ”€β”€ README.md
  β”œβ”€β”€ requirements.txt
  └── src
      β”œβ”€β”€ config
      β”‚Β Β  └── __init__.py
      β”œβ”€β”€ database
      β”‚Β Β  β”œβ”€β”€ __init__.py
      β”‚Β Β  β”œβ”€β”€ dto
      β”‚Β Β  β”‚Β Β  β”œβ”€β”€ __init__.py
      β”‚Β Β  β”‚Β Β  β”œβ”€β”€ base_dto.py
      β”‚Β Β  β”‚Β Β  └── embedding_dto.py
      β”‚Β Β  └── models
      β”‚Β Β      β”œβ”€β”€ __init__.py
      β”‚Β Β      β”œβ”€β”€ base.py
      β”‚Β Β      └── embedding.py
      β”œβ”€β”€ entities
      β”‚Β Β  └── embedding.py
      β”œβ”€β”€ machine_learning_models
      β”‚Β Β  β”œβ”€β”€ __init__.py
      β”‚Β Β  β”œβ”€β”€ factory
      β”‚Β Β  β”‚Β Β  └── __init__.py
      β”‚Β Β  └── strategies
      β”‚Β Β      β”œβ”€β”€ __init__.py
      β”‚Β Β      β”œβ”€β”€ embedding_strategy.py
      β”‚Β Β      β”œβ”€β”€ hugging_face_strategy.py
      β”‚Β Β      └── torch_vision_strategy.py
      β”œβ”€β”€ repositories
      β”‚Β Β  β”œβ”€β”€ __init__.py
      β”‚Β Β  β”œβ”€β”€ base_repository.py
      β”‚Β Β  β”œβ”€β”€ base_unit_of_work.py
      β”‚Β Β  β”œβ”€β”€ embedding_repository.py
      β”‚Β Β  └── unit_of_work.py
      β”œβ”€β”€ services
      β”‚Β Β  β”œβ”€β”€ embedding_service
      β”‚Β Β  β”‚Β Β  └── embedding_service.py
      β”‚Β Β  β”œβ”€β”€ preprocessing
      β”‚Β Β  β”‚Β Β  └── image.py
      β”‚Β Β  └── text_extractor
      β”‚Β Β      β”œβ”€β”€ __init__.py
      β”‚Β Β      β”œβ”€β”€ image_text_extractor.py
      β”‚Β Β      └── pdf_text_extractor.py
      └── utils
          β”œβ”€β”€ __init__.py
          └── parser.py

Installation

# Clone the repo
git clone git@github.com:JoaoGabrielSC/rag-vectordb.git
cd RAG

# (Optional) Create a virtual environment (using pyenv)
pyenv virtualenv 3.12.9 rag
pyenv activate rag
pyenv local rag

# Install dependencies
pip install -r requirements.txt

Contributors

JoaoGabrielSC

23 commits

JoaoGabrielSC/rag-vectordb

An application that leverages Retrieval-Augmented Generation (RAG) to provide answers to questions that are related to local documents

1

stars

23

commits

Python

primary language

Jul 19, 2025

updated

README

RAG - Retrieval Augmented Generation With Vector DB

This project provides a complete pipeline for extracting text from various document formats (PDF, Word, Images), chunking it, generating embeddings, and storing them in a Vector Database. It is designed to support document-based Retrieval-Augmented Generation (RAG) systems.

TODO

  • ...
  • Implement Services and Repositories to handle database operations (CRUD, queries, etc.)
  • [/] Add ML Embedding Model to transform raw data into vector embeddings
  • Add support for multiprocessing or multithreading to concurrently load and process chunked data (ETL load step)
  • Create the Retrieval API for querying and retrieving vectorized data

Overview

image

πŸ” Pipeline Steps (see diagram)

  1. Start – Begin the document ingestion process.

  2. Send Raw Documents – Upload raw documents such as PDFs, Word docs, or images.

  3. Text Extractor – Extract text from different file types using specialized parsers:

    • PDFs β†’ pdf_text_extractor.py
    • Images β†’ image_text_extractor.py (OCR)
  4. Splitter – Break extracted text into smaller chunks using a customizable splitter strategy.

  5. Parallel Chunk Processing – Process chunks in parallel using threads.

  6. Embedding Model – Convert each chunk into an embedding vector using a pre-trained model.

  7. Vector Database – Store the resulting embeddings in a vector store for fast retrieval.

Project Structure

  .
  β”œβ”€β”€ docker-compose.yaml
  β”œβ”€β”€ Dockerfile
  β”œβ”€β”€ examples
  β”‚Β Β  β”œβ”€β”€ image.png
  β”‚Β Β  └── volume_tracing.pdf
  β”œβ”€β”€ LICENSE
  β”œβ”€β”€ main.py
  β”œβ”€β”€ Makefile
  β”œβ”€β”€ mypy.ini
  β”œβ”€β”€ README.md
  β”œβ”€β”€ requirements.txt
  └── src
      β”œβ”€β”€ config
      β”‚Β Β  └── __init__.py
      β”œβ”€β”€ database
      β”‚Β Β  β”œβ”€β”€ __init__.py
      β”‚Β Β  β”œβ”€β”€ dto
      β”‚Β Β  β”‚Β Β  β”œβ”€β”€ __init__.py
      β”‚Β Β  β”‚Β Β  β”œβ”€β”€ base_dto.py
      β”‚Β Β  β”‚Β Β  └── embedding_dto.py
      β”‚Β Β  └── models
      β”‚Β Β      β”œβ”€β”€ __init__.py
      β”‚Β Β      β”œβ”€β”€ base.py
      β”‚Β Β      └── embedding.py
      β”œβ”€β”€ entities
      β”‚Β Β  └── embedding.py
      β”œβ”€β”€ machine_learning_models
      β”‚Β Β  β”œβ”€β”€ __init__.py
      β”‚Β Β  β”œβ”€β”€ factory
      β”‚Β Β  β”‚Β Β  └── __init__.py
      β”‚Β Β  └── strategies
      β”‚Β Β      β”œβ”€β”€ __init__.py
      β”‚Β Β      β”œβ”€β”€ embedding_strategy.py
      β”‚Β Β      β”œβ”€β”€ hugging_face_strategy.py
      β”‚Β Β      └── torch_vision_strategy.py
      β”œβ”€β”€ repositories
      β”‚Β Β  β”œβ”€β”€ __init__.py
      β”‚Β Β  β”œβ”€β”€ base_repository.py
      β”‚Β Β  β”œβ”€β”€ base_unit_of_work.py
      β”‚Β Β  β”œβ”€β”€ embedding_repository.py
      β”‚Β Β  └── unit_of_work.py
      β”œβ”€β”€ services
      β”‚Β Β  β”œβ”€β”€ embedding_service
      β”‚Β Β  β”‚Β Β  └── embedding_service.py
      β”‚Β Β  β”œβ”€β”€ preprocessing
      β”‚Β Β  β”‚Β Β  └── image.py
      β”‚Β Β  └── text_extractor
      β”‚Β Β      β”œβ”€β”€ __init__.py
      β”‚Β Β      β”œβ”€β”€ image_text_extractor.py
      β”‚Β Β      └── pdf_text_extractor.py
      └── utils
          β”œβ”€β”€ __init__.py
          └── parser.py

Installation

# Clone the repo
git clone git@github.com:JoaoGabrielSC/rag-vectordb.git
cd RAG

# (Optional) Create a virtual environment (using pyenv)
pyenv virtualenv 3.12.9 rag
pyenv activate rag
pyenv local rag

# Install dependencies
pip install -r requirements.txt

Contributors

JoaoGabrielSC

23 commits

Languages

Python

96.4%

Makefile

3.6%