# para-lost/autopresent architecture

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

- Interactive diagram: https://gitdiagram.com/para-lost/autopresent
- Repository: https://github.com/para-lost/autopresent

## Overview

##### Project Type and Purpose
- This is an open‐source research codebase implementing AutoPresent, a system for automatic slide generation.
- It provides:
- A core library (SlidesLib) for programmatically creating slides
- A pipeline to generate Python “programs” (via LLM inference), refine them, execute them to build slides
- A training component (autopresent) for fine-tuning Llama models on slide‐creation tasks
- A benchmarking suite (slidesbench) with datasets and reference decks
- An evaluation suite (evaluate) with both reference-based and reference-free metrics

##### High-Level Directory/Module Analysis
- SlidesLib/ – low-level Python API for image generation, plotting, PPTX creation, search, VQA
- generate/ – scripts to invoke an LLM to produce slide‐creation code (create_slide, create_slide_deck) plus prompt libraries and utilities
- refinement/ – scripts and prompts to refine first-pass code outputs
- scripts/ – code‐cleanup and execution harnesses for generated/refined Python programs
- autopresent/ – training & inference wrappers to fine-tune and run slide‐generation models on HuggingFace
- slidesbench/ – functions to build datasets from PPTX, generate reference code, plus a directory of example slide decks and train/test data

A. Data & Models
1. slidesbench Dataset (CSV + PPTX decks)
2. Pretrained Llama Models & Fine-tuned AutoPresent Weights (on HF Hub)
B. Core Library
- SlidesLib (image_gen, plotting, ppt_gen, etc.)
C. Generation Pipeline
1. generate/create_slide_deck.py (calls LLM via generate/utils.py)
2. Output: Python “programs” per slide
D. Refinement Pipeline
1. refinement/refine.py & refine_all.py (takes existing_slide + code + prompt)
2. Output: refined Python code
E. Execution Layer
- scripts/clean_generated_code.py → scripts/execute_each_file.py
- These ingest raw/refined code, call SlidesLib to produce .pptx or images
F. Training Pipeline
1. autopresent/train.py (loads slidesbench CSV, fine-tunes a model on HF)
2. autopresent/generate.py (uses fine-tuned model to produce code on test CSV)
G. Evaluation Suite
1. evaluate/slides_eval.py, evaluate/page_eval.py (reference-based)
2. evaluate/reference_free_eval.py (LLM-based design critique)
H. External Services & Tools
- OpenAI API (LLM inference)
- HuggingFace Hub (model weights)
- unoconv (pptx→jpg/pdf conversion)

##### Relationships & Data Flows
- slidesbench/train_data → autopresent/train.py → Fine-tuned Model → HF Hub
- Fine-tuned Model &/or Base Llama → generate scripts → Generated Code → refinement (optional) → scripts execution → SlidesLib calls → Slide assets (.pptx/.jpg)
- Slide assets + reference slides → evaluate modules → Metrics
- The core SlidesLib is invoked by both generated/refined code and by any user-written programs

##### Architectural Patterns & Principles
- Modular pipeline: separate stages for generation, refinement, execution, training, evaluation
- Library/API layer (SlidesLib) decoupled from orchestration scripts
- Use of external LLM inference and HF ecosystems for extensibility
- Reproducibility via slidesbench reference code generation and standardized CLI scripts

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Data & Models
    subgraph "Data & Models"
        DB1["slidesbench Dataset (CSV + PPTX)"]:::data
        DB2["Pretrained & Fine-tuned Models"]:::data
    end

    %% Core Library
    subgraph "Core Library"
        SL["SlidesLib"]:::module
    end

    %% Generation Pipeline
    subgraph "Generation Pipeline"
        GEN1["create_slide_deck.py"]:::module
        GEN_UTIL["utils.py"]:::module
    end

    %% Refinement Pipeline
    subgraph "Refinement Pipeline"
        RF1["refine.py"]:::module
        RF2["refine_all.py"]:::module
    end

    %% Execution Layer
    subgraph "Execution Layer"
        EX1["clean_generated_code.py"]:::module
        EX2["execute_each_file.py"]:::module
    end

    %% Training Pipeline
    subgraph "Training Pipeline"
        TR1["train.py"]:::module
        TR2["generate.py"]:::module
    end

    %% Benchmarking Suite
    subgraph "Benchmarking Suite"
        BS["slidesbench"]:::module
    end

    %% Evaluation Suite
    subgraph "Evaluation Suite"
        EV1["slides_eval.py"]:::module
        EV2["page_eval.py"]:::module
        EV3["reference_free_eval.py"]:::module
    end

    %% External Services
    subgraph "External Services"
        EO["OpenAI API"]:::cloud
        EH["HuggingFace Hub"]:::cloud
        UN["unoconv"]:::cloud
    end

    %% Slide Assets
    AS["Slide Assets (.pptx / .jpg)"]:::data

    %% Data Flows
    DB1 -->|"CSV→Model input"| TR1
    TR1 -->|"Train→HF Hub"| EH
    EH -->|"Weights→Generation"| GEN1
    EO -->|"Infer→Code"| GEN1
    GEN1 -->|"Python code"| RF1
    RF1 -->|"Refined code"| EX1
    EX1 -->|"Clean code→"| EX2
    EX2 -->|"Calls SlidesLib API"| SL
    SL -->|"Produces slides"| AS
    AS -->|"Slides + reference"| EV1
    AS -->|"Slides + reference"| EV2
    AS -->|"Slides"| EV3

    BS -->|"Provides data"| DB1

    %% Styles
    classDef module fill:#AED6F1,stroke:#1A5276,color:#1A5276
    classDef data fill:#A9DFBF,stroke:#196F3D,color:#196F3D
    classDef cloud fill:#F9E79F,stroke:#B9770E,color:#B9770E

    %% Click Events
    click SL "https://github.com/para-lost/autopresent/tree/main/SlidesLib/"
    click GEN1 "https://github.com/para-lost/autopresent/blob/main/generate/create_slide_deck.py"
    click GEN_UTIL "https://github.com/para-lost/autopresent/blob/main/generate/utils.py"
    click RF1 "https://github.com/para-lost/autopresent/blob/main/refinement/refine.py"
    click RF2 "https://github.com/para-lost/autopresent/blob/main/refinement/refine_all.py"
    click EX1 "https://github.com/para-lost/autopresent/blob/main/scripts/clean_generated_code.py"
    click EX2 "https://github.com/para-lost/autopresent/blob/main/scripts/execute_each_file.py"
    click TR1 "https://github.com/para-lost/autopresent/blob/main/autopresent/train.py"
    click TR2 "https://github.com/para-lost/autopresent/blob/main/autopresent/generate.py"
    click BS "https://github.com/para-lost/autopresent/tree/main/slidesbench/"
    click EV1 "https://github.com/para-lost/autopresent/blob/main/evaluate/slides_eval.py"
    click EV2 "https://github.com/para-lost/autopresent/blob/main/evaluate/page_eval.py"
    click EV3 "https://github.com/para-lost/autopresent/blob/main/evaluate/reference_free_eval.py"
```
