# hoorangyee/lrage architecture

> Architecture diagram of the GitHub repository hoorangyee/lrage, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-02-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hoorangyee/lrage
- Repository: https://github.com/hoorangyee/lrage

## Overview

##### High-Level Architecture Components

a) User Interface Layer
- GUI Component (lrage/gui/)
- CLI Interface (main entry point)

b) Core Evaluation Layer
- Task Management (lrage/api/task.py)
- Model Management (lrage/api/model.py)
- Evaluation Pipeline Controller

c) RAG Components Layer
- Retriever System (lrage/api/retriever.py)
- Reranker System (lrage/api/reranker.py)
- Document Store/Index Interface

d) Model Integration Layer
- LLM Adapters (various model implementations)
- Judge Model Interface
- Model Registry (lrage/api/registry.py)

##### Data Flow Connections

a) Primary Flow:
**User Input → Task Configuration → Retriever → Reranker → LLM → Evaluation → Results**

b) Secondary Flows:
- Document Index ←→ Retriever
- Retrieved Documents → Reranker → Filtered Documents
- LLM Output → Judge Model → Evaluation Metrics

##### Component Details

a) Retrievers:
- Pyserini (BM25, Sparse, Dense, Hybrid)
- Index Management
- Document Processing

b) Rerankers:
- ColBERT
- RankLLM
- Custom Reranker Interface

c) Models:
- HuggingFace Models
- OpenAI Models
- vLLM Integration
- Other Model Adapters

##### Support Systems

Auxiliary components:

- Caching System (lrage/caching/)
- Logging System (lrage/loggers/)
- Metrics Collection (lrage/api/metrics.py)
- Filter Pipeline (lrage/api/filter.py)

##### Integration Points

Extension points:
- Custom Model Integration
- Custom Retriever Integration
- Custom Reranker Integration
- Task Configuration System

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph UI
        GUI["GUI Component"]
        CLI["CLI Interface"]
    end

    subgraph Core
        TaskMgr["Task Manager"]
        Registry["Model Registry"]
        Evaluator["Evaluation Controller"]
        Pipeline["Pipeline Orchestrator"]
        Config["Configuration Manager"]
        ErrorHandler["Error Handler"]
        Validator["Input Validator"]
        Scheduler["Task Scheduler"]
    end

    subgraph RAG
        Retriever["Retriever System"]
        Reranker["Reranker System"]
        Cache["Document Cache"]
    end

    subgraph Models
        LLMs["LLM Models"]
        subgraph ModelTypes
            Anthropic["Anthropic Models"]
            OpenAI["OpenAI Models"]
            HF["HuggingFace Models"]
        end
        Judge["Judge Models"]
    end

    subgraph Tasks
        Legal["Legal Tasks"]
        Metrics["Metrics"]
        TaskConfig["Task Configurations"]
    end

    subgraph Logging
        EvalTracker["Evaluation Tracking"]
        WandbLogger["Wandb Logger"]
    end

    %% Main Flow
    GUI --> TaskMgr
    CLI --> TaskMgr
    TaskMgr --> Pipeline
    Pipeline --> Validator
    Validator --> Scheduler
    Scheduler --> Retriever
    Retriever --> Reranker
    Reranker --> LLMs
    LLMs --> Evaluator
    Evaluator --> EvalTracker
    ErrorHandler --> Pipeline

    %% Secondary Flows
    TaskMgr --> Cache
    Cache <--> Retriever
    Judge <-- Evaluator
    Registry --> LLMs
    Legal --> TaskMgr
    Metrics --> Evaluator
    TaskConfig --> Legal
    EvalTracker --> WandbLogger
    Config --> Pipeline
    Config --> TaskMgr

    %% Model Connections
    LLMs --> Anthropic
    LLMs --> OpenAI
    LLMs --> HF

    %% Styling
    classDef default fill:#f9f9f9,stroke:#333,stroke-width:2px
    classDef storage fill:#f4d03f,stroke:#333
    classDef process fill:#85c1e9,stroke:#333
    classDef model fill:#82e0aa,stroke:#333
    classDef logging fill:#d7bde2,stroke:#333

    class Cache storage
    class LLMs,Judge,Anthropic,OpenAI,HF model
    class Retriever,Reranker,Evaluator process
    class EvalTracker,WandbLogger logging

    %% Click Events
    click GUI "https://github.com/hoorangyee/LRAGE/tree/main/lrage/gui/"
    click CLI "https://github.com/hoorangyee/LRAGE/blob/main/lrage/__main__.py"
    click TaskMgr "https://github.com/hoorangyee/LRAGE/blob/main/lrage/api/task.py"
    click Registry "https://github.com/hoorangyee/LRAGE/blob/main/lrage/api/registry.py"
    click Evaluator "https://github.com/hoorangyee/LRAGE/blob/main/lrage/evaluator.py"
    click Retriever "https://github.com/hoorangyee/LRAGE/blob/main/lrage/api/retriever.py"
    click Reranker "https://github.com/hoorangyee/LRAGE/blob/main/lrage/api/reranker.py"
    click Cache "https://github.com/hoorangyee/LRAGE/blob/main/lrage/caching/cache.py"
    click LLMs "https://github.com/hoorangyee/LRAGE/tree/main/lrage/models/"
    click Anthropic "https://github.com/hoorangyee/LRAGE/blob/main/lrage/models/anthropic_llms.py"
    click OpenAI "https://github.com/hoorangyee/LRAGE/blob/main/lrage/models/openai_completions.py"
    click HF "https://github.com/hoorangyee/LRAGE/blob/main/lrage/models/huggingface.py"
    click Legal "https://github.com/hoorangyee/LRAGE/tree/main/lrage/tasks/legalbench/"
    click Metrics "https://github.com/hoorangyee/LRAGE/blob/main/lrage/api/metrics.py"
    click TaskConfig "https://github.com/hoorangyee/LRAGE/tree/main/lrage/tasks/legalbench/prompt_templates/"
    click EvalTracker "https://github.com/hoorangyee/LRAGE/blob/main/lrage/loggers/evaluation_tracker.py"
    click WandbLogger "https://github.com/hoorangyee/LRAGE/blob/main/lrage/loggers/wandb_logger.py"
```
