# novasearch-team/rag-retrieval architecture

> Architecture diagram of the GitHub repository novasearch-team/rag-retrieval, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/novasearch-team/rag-retrieval
- Repository: https://github.com/novasearch-team/rag-retrieval

## Overview

##### Project type and purpose
- RAG-Retrieval is a research-oriented full-stack toolkit and library for “Retrieval-Augmented Generation” (RAG) systems.
- It provides end-to-end support for:
a. Training RAG retrieval components: embedding models, late-interaction (ColBERT) models, and reranker models (both BERT and LLM-based).
b. Inference: a lightweight Python library (`rag-retrieval`) offering a unified interface to serve any reranker model.
c. Distillation: compressing large embedding or reranker models into smaller, production-friendly ones.

##### File structure
- Top-level:
- `rag_retrieval/` – core Python package, split into:
– `rag_retrieval/train/` – submodules for each training pipeline (colbert, embedding, reranker).
– `rag_retrieval/infer/` – inference API, reranker implementations.
– `rag_retrieval/reranker.py` – high-level entrypoint.
- `config/` – DeepSpeed and FSDP distributed-training configurations.
- `example_data/`, `examples/` – sample inputs, end-to-end experiment scripts.
- Config files and scripts (`*.sh`) reveal distributed multi-GPU support via DeepSpeed/FSDP.
- `tests/` validate each reranker variant.

##### README for additional insights
- README describes three pillars (training/inference/distillation), lists supported model families (bert, LLM, colbert), and points to per-pipeline READMEs.
- Emphasizes modularity: new rerankers plug into `BaseReranker`.

##### Final advice
- Be detailed: show all three training modules and the unified inference module.
- Distributed training configurations separately.
- Modularity and plugin points.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Data & Config Layers"
        D1["Example/Training Data"]:::data
        D2["Distributed Configs"]:::config
        D3["FSDP Defaults"]:::config
        D4["Embedding Train Configs"]:::config
        D5["Reranker Train Configs"]:::config
    end

    subgraph "Training Pipelines"
        ET["Embedding Trainer"]:::training
        CT["ColBERT Trainer"]:::training
        RT["Reranker Trainer"]:::training
    end

    subgraph "Model Artifacts"
        MA["Checkpoints & Distilled Models"]:::artifact
    end

    subgraph "Inference Library"
        IN["Base Reranker Entry"]:::inference
        RM["Reranker Models Dir"]:::inference
        CM["ColBERT Ranker"]:::inference
        XM["Cross-Encoder Ranker"]:::inference
        LM["LLM Rankers"]:::inference
        UT["Utility Classes"]:::inference
    end

    EX["External LLM API"]:::external

    D1 --> ET
    D1 --> CT
    D1 --> RT
    D2 --> ET
    D2 --> CT
    D2 --> RT
    D3 --> ET
    D4 --> ET
    D5 --> RT

    ET --> MA
    CT --> MA
    RT --> MA

    MA --> IN
    IN --> RM
    RM --> CM
    RM --> XM
    RM --> LM
    RM --> UT

    LM --> EX

    click D1 "https://github.com/novasearch-team/rag-retrieval/tree/master/example_data/"
    click D2 "https://github.com/novasearch-team/rag-retrieval/tree/master/config/deepspeed/"
    click D3 "https://github.com/novasearch-team/rag-retrieval/blob/master/config/default_fsdp.yaml"
    click D4 "https://github.com/novasearch-team/rag-retrieval/tree/master/rag_retrieval/train/embedding/config/"
    click D5 "https://github.com/novasearch-team/rag-retrieval/tree/master/rag_retrieval/train/reranker/config/"
    click ET "https://github.com/novasearch-team/rag-retrieval/tree/master/rag_retrieval/train/embedding/"
    click CT "https://github.com/novasearch-team/rag-retrieval/tree/master/rag_retrieval/train/colbert/"
    click RT "https://github.com/novasearch-team/rag-retrieval/tree/master/rag_retrieval/train/reranker/"
    click IN "https://github.com/novasearch-team/rag-retrieval/blob/master/rag_retrieval/reranker.py"
    click RM "https://github.com/novasearch-team/rag-retrieval/tree/master/rag_retrieval/infer/reranker_models/"
    click CM "https://github.com/novasearch-team/rag-retrieval/blob/master/rag_retrieval/infer/reranker_models/colbert_ranker.py"
    click XM "https://github.com/novasearch-team/rag-retrieval/blob/master/rag_retrieval/infer/reranker_models/cross_encoder_ranker.py"
    click LM "https://github.com/novasearch-team/rag-retrieval/blob/master/rag_retrieval/infer/reranker_models/llm_rankers.py"
    click UT "https://github.com/novasearch-team/rag-retrieval/blob/master/rag_retrieval/infer/reranker_models/utils.py"

    classDef data fill:#DDDDDD,stroke:#888888,color:#333333;
    classDef config fill:#EEEEEE,stroke:#AAAAAA,color:#333333;
    classDef training fill:#B3CDE3,stroke:#6497B1,color:#03396C;
    classDef artifact fill:#F2F2F2,stroke:#CCCCCC,color:#666666;
    classDef inference fill:#C7E9C0,stroke:#74C476,color:#238B45;
    classDef external fill:#FDD0A2,stroke:#FC8D59,color:#7F2704;
```
