# adobe-research/nolima architecture

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

- Interactive diagram: https://gitdiagram.com/adobe-research/nolima
- Repository: https://github.com/adobe-research/nolima

## Overview

##### Project type and purpose
- Type: Benchmark/evaluation framework for large language models (LLMs).

##### File structure
Top‐level directories:
– data/           → data ingestion & preprocessing (haystacks, needle sets, filtering scripts, notebooks)
– evaluation/     → evaluation runner, model‐serving scripts, async API connector, config templates, result gathering
Other files:
– requirements.txt
– run‐and‐helper scripts (shell files for downloading data, starting model servers, running tests)
– notebooks for data cleaning (data/*.ipynb) and analysis (evaluation/gather_results.ipynb)

##### Key insights from README
– Describes the NoLiMa benchmark and pipeline steps: install, download data, start local server or configure API, prepare run configs, execute tests, collect & aggregate results.
– Mentions use of vLLM, asyncio, YAML configs, HuggingFace datasets, and API providers (Fireworks, OpenRouter).

##### Main components
A. Data Preparation Layer
- Raw Data (Haystack & Needle sets) in data/
- Preprocessing scripts & notebooks (data/clean_books.ipynb, remove_distractors.ipynb, download scripts)
- Output: formatted haystacks and needles in data/needlesets & data/haystack/rand_shuffle
B. Evaluation Layer
- Runner scripts (evaluation/run_tests.py, run_tests.sh)
- Async API connector (evaluation/async_api_connector.py)
- Model server startup (evaluation/vllm_serve.sh)
C. Configuration Layer
- Model configs (evaluation/model_configs/*.json)
- Run configs (evaluation/run_config/*.yaml)
D. Model Serving
– Local “vLLM” server (on‐prem GPU cluster)
– External API providers (OpenAI, Fireworks, OpenRouter)
E. Results & Analysis
- Raw outputs (per‐test JSON or CSV files)
- Aggregation notebook (evaluation/gather_results.ipynb)
- Final result tables & visualizations

##### Relationships & data flows
1) Data Preparation → generates haystacks & needles →
2) Runner (run_tests.sh / run_tests.py) reads run_config YAML →
3) Runner loads model_config JSON →
4) If local: launch vLLM serve script; if API: async_api_connector handles calls →
5) For each test: supply haystack+needle to LLM → collect predictions →
6) Store raw results in output directory →
7) Analysis notebook ingests outputs → produces consolidated CSV & plots

##### Architectural patterns & principles
– Modularity: clear separation between data prep, evaluation execution, configuration, and results analysis
– Extensibility: add new model_config files and run_config templates without code changes
– Asynchronous I/O: evaluation/async_api_connector.py uses asyncio to parallelize API calls
– Infrastructure‐agnostic: supports local GPU servers and external APIs via pluggable connectors

##### Technologies & frameworks
– Python 3.x, asyncio
– Shell scripts (bash) for orchestration
– Jupyter Notebooks for prototyping & analysis
– vLLM (local inference server)
– YAML (run configurations) & JSON (model configurations)
– HuggingFace Datasets for data storage & retrieval

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Data Preparation Layer
    subgraph "Data Preparation Layer"
        RawData["Raw Data (Haystack & Needle sets)"]:::data
        subgraph "Preprocessing"
            book_haystack["book_haystack.py"]:::compute
            clean_books["clean_books.ipynb"]:::compute
            remove_distractors["remove_distractors.ipynb"]:::compute
            filter_conflicts["filtering_conflicts.70b.py"]:::compute
            random_gen["random_book_gen_char.ipynb"]:::compute
            download_data["download_NoLiMa_data.sh"]:::compute
            download_books["download_books.sh"]:::compute
        end
        OutputData["Formatted Haystacks & Needles"]:::data
    end

    %% Evaluation Layer
    subgraph "Evaluation Layer"
        subgraph "Runner"
            run_py["run_tests.py"]:::compute
            run_sh["run_tests.sh"]:::compute
        end
        subgraph "Async API Connector"
            async_connector["async_api_connector.py"]:::compute
            async_evaluate["async_evaluate.py"]:::compute
        end
        model_serve["vllm_serve.sh"]:::compute
        OutputResults["Raw Results (JSON/CSV)"]:::data
    end

    %% Configuration Layer
    subgraph "Configuration Layer"
        model_configs["Model Configs (.json)"]:::config
        run_configs["Run Configs (.yaml)"]:::config
    end

    %% Model Serving
    subgraph "Model Serving"
        local_server["Local vLLM Server"]:::external
        external_apis["External API Providers"]:::external
    end

    %% Results & Analysis
    subgraph "Results & Analysis"
        results_store["Raw Results Store"]:::data
        analysis_nb["gather_results.ipynb"]:::analysis
        final_vis["Result Tables & Visualizations"]:::analysis
    end

    %% Connections
    RawData -->|"input to"| book_haystack
    book_haystack --> clean_books
    clean_books --> remove_distractors
    remove_distractors --> filter_conflicts
    filter_conflicts --> random_gen
    random_gen --> download_data
    download_data --> download_books
    download_books --> OutputData

    OutputData -->|"feeds"| run_py
    model_configs -->|"loaded by"| run_py
    run_configs -->|"read by"| run_py

    run_py -->|"starts"| model_serve
    model_serve --> local_server

    run_py -->|"calls"| async_connector
    async_connector --> async_evaluate
    async_evaluate --> external_apis

    run_py -->|"writes"| OutputResults
    run_sh --> run_py

    OutputResults --> results_store
    results_store --> analysis_nb
    analysis_nb --> final_vis

    %% Click Events
    click RawData "https://github.com/adobe-research/nolima/tree/main/data/"
    click book_haystack "https://github.com/adobe-research/nolima/blob/main/data/book_haystack.py"
    click clean_books "https://github.com/adobe-research/nolima/blob/main/data/clean_books.ipynb"
    click remove_distractors "https://github.com/adobe-research/nolima/blob/main/data/remove_distractors.ipynb"
    click filter_conflicts "https://github.com/adobe-research/nolima/blob/main/data/filtering_conflicts.70b.py"
    click random_gen "https://github.com/adobe-research/nolima/blob/main/data/random_book_gen_char.ipynb"
    click download_data "https://github.com/adobe-research/nolima/blob/main/data/download_NoLiMa_data.sh"
    click download_books "https://github.com/adobe-research/nolima/blob/main/data/download_books.sh"
    click run_py "https://github.com/adobe-research/nolima/blob/main/evaluation/run_tests.py"
    click run_sh "https://github.com/adobe-research/nolima/blob/main/evaluation/run_tests.sh"
    click async_connector "https://github.com/adobe-research/nolima/blob/main/evaluation/async_api_connector.py"
    click async_evaluate "https://github.com/adobe-research/nolima/blob/main/evaluation/async_evaluate.py"
    click model_serve "https://github.com/adobe-research/nolima/blob/main/evaluation/vllm_serve.sh"
    click model_configs "https://github.com/adobe-research/nolima/tree/main/evaluation/model_configs/"
    click run_configs "https://github.com/adobe-research/nolima/tree/main/evaluation/run_config/"
    click analysis_nb "https://github.com/adobe-research/nolima/blob/main/evaluation/gather_results.ipynb"
    click requirements_txt "https://github.com/adobe-research/nolima/blob/main/requirements.txt"

    %% Styles
    classDef data fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef compute fill:#90EE90,stroke:#333,stroke-width:1px
    classDef config fill:#FFD580,stroke:#333,stroke-width:1px
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:1px
    classDef analysis fill:#DDA0DD,stroke:#333,stroke-width:1px
```
