Skip to content

Scratchpad. This repository contains a Retrieval-Augmented Generation (RAG) framework developed in C++ for high performance and scalability, with CUDA support for computational acceleration.

License

Notifications You must be signed in to change notification settings

bbzaffari/purecpp_sp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Note: Please disregard the commit history in this repository. This repository is my development scratchpad, where all structural changes are designed and documented before being pushed to the official ecosystem.


Status πŸ‘‰ πŸ”— Stable purecpp




PureCPP

Status this

Overview

PureCPP is a powerful C++ backend architecture for RAG systems.

Designed for maximum performance and scalability, it integrates vector search, ONNX models, and CPU/CUDA acceleration into a seamless, Python-integrated framework.

This repository provides detailed guidance on how to set up the environment, configure dependencies and build.

Table of Contents

πŸ” Explore all of Bruno Bavaresco Zaffari’s contributions (explained) related to this framework.


Environment Setup


First of all clone the repository

git clone --recursive https://github.com/bbzaffari/purecpp_sp
cd purecpp_sp

Warning

If you forgot to use --recursive when cloning the repository, make sure to run:

git submodule update --init --recursive

Docker


  • 1. Build a Docker image from the current directory and tag it as 'purecpp_env'
docker build -t purecpp_env .
  • 2. Start a Docker container named 'env' from the 'purecpp_env' image, mounting current dir to /home
docker run -it --name env -v "$PWD":/home purecpp_env
  • 3. Run the env_config.sh
chmod +x installers/*.sh
./installers/env_config.sh

This script automates the setup. Installing Python essentials, LibTorch, FAISS, and configuring Conan profile.d

Caution

Once you've created the container using docker run, you don't need to recreate it again. Instead, follow these two simple commands to reuse the container:

docker start env

This command starts an existing container that has already been created earlier using docker run.

docker exec -it env bash

This command attaches a terminal to the running container, allowing you to interact with it just like you would with a regular Linux shell.


Local


Requirements

  • GCC/G++ >= 13.1
  • CMake >= 3.22
  • Python >= 3.8

1. Installing dependencies

  • Ubuntu/Debian
sudo apt update && \
sudo apt upgrade -y && \
sudo apt install -y \
  build-essential wget curl \
  ninja-build cmake libopenblas-dev \
  libgflags-dev python3-dev libprotobuf-dev \
  protobuf-compiler unzip libssl-dev zlib1g-dev
  • Red Hat
yum update && 
yum install -y \
      gcc gcc-c++ make git curl wget \
      ninja-build libffi-devel openssl-devel \
      protobuf-devel gflags-devel zlib-devel \
      openblas-devel unzip \

2. Install Rust via rustup

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y

Run rustup installer non-interactively (-y).

source ~/.cargo/env

This places cargo and rustc in /root/.cargo & activate Rust Environment

3. Execute the env_config.sh

In case you do not have a Docker environment available, we strongly recommend that you use a Python venv (virtual environment) to ensure proper isolation of dependencies and reproducibility of results.

  • Create the virtual environment (replace 'venv' with your preferred name)

    python3 -m venv venv
  • Activate the virtual environment on Linux or macOS

    source venv/bin/activate

This practice minimizes conflicts between global packages and project-specific requirements.

Then run env_config.sh script

chmod +x installers/*.sh
./installers/env_config.sh

This script automates the setup. Installing Python essentials, LibTorch, FAISS, and configuring Conan profile.


How to Build

The build.sh is a development version pipeline, that makes it easier to compile and test all five modules.

Ensure the scripts have the execution permission

chmod -R +x ./CMAKE/*/sub_mod_build.sh
chmod +x ./build.sh

Compile all at once

./build.sh all

Compile one at a time

./build.sh MODULE-NUMBER

Each module (CMAKE_LIBS, CMAKE_META, CMAKE_EMBED, CMAKE_EXTRACT, CMAKE_CHUNKS_CLEAN) has its own sub_mod_build.sh script, which:

  • Cleans the build/ folder
  • Installs Conan dependencies if missing
  • Compiles the code
  • Sends the purecpp_*.so output to the central Sandbox/

Testing

The shared object will be placed inside the Sandbox/

Sandbox/
    β”œβ”€β”€ Resources/
    β”œβ”€β”€ purecpp_*.so
    └── YOUR-TEST.py

To test the Python bindings:

import purecpp_MODULE



About

Scratchpad. This repository contains a Retrieval-Augmented Generation (RAG) framework developed in C++ for high performance and scalability, with CUDA support for computational acceleration.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Contributors 4

  •  
  •  
  •  
  •