# kyegomez/rt-2 architecture

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

- Interactive diagram: https://gitdiagram.com/kyegomez/rt-2
- Repository: https://github.com/kyegomez/rt-2

## Overview

##### Project type and purpose
- This is an open-source Python library (installed via pip) providing the “Robotic Transformer 2 (RT-2)” vision-language-action model.
- It wraps a pre-trained multi-modal backbone (PALM-E) in a PyTorch module (`rt2.model.RT2`) so users can feed images+language and get action-token outputs for robotics tasks.

##### File structure
- Top-level packaging & CI:
- `pyproject.toml` / `requirements.txt` → packaging metadata & dependencies
- `.github/workflows/python-publish.yml` → CI/CD for testing & PyPI publishing
- Core library:
- `rt2/__init__.py`
- `rt2/model.py` → defines the `RT2` class
- Documentation:
- `README.md`, `docs/*.md` → usage, datasets, evaluation, model details
- Tests:
- `tests/test.py` → sanity check for installation and basic API
- Example:
- `example.py` → sample client invoking `RT2()`

##### README for additional insights
- Describes the multi-modal architecture: Vision encoder + Language backbone → concatenation in a shared embedding space → action-token head.
- Mentions external datasets used in training but no dataset code in this repo.
- Emphasizes inference use case: feed images+captions → get action predictions.

##### Elements
- Clear labels:
- “User Application”
- “RT2 Library (rt2/model.py)”
- “Vision Encoder (PALM-E vision tower)”
- “Language Encoder (PALM-E language tower)”
- “Fusion Layer”
- “Action Head”
- “PyTorch”
- “CI/CD”
- “PyPI Packaging”
- “Documentation”
- img →Vision Encoder→
- caption →Language Encoder→
- outputs →action head→ action tokens → back to user

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User Layer
    UA["User Application"]:::module
    UA -->|"import RT2 and call model(img, caption)"| RT2

    %% Core Library
    subgraph "RT2 Library" 
        direction TB
        Init["Package Initialization\n(rt2/__init__.py)"]:::module
        RT2["RT2 Class\n(rt2/model.py)"]:::module
        Vision["Vision Encoder\n(PALM-E vision tower)"]:::module
        Language["Language Encoder\n(PALM-E language tower)"]:::module
        Fusion["Multi-Modal Fusion"]:::module
        Action["Action Head\n(token prediction)"]:::module

        Init -->|"loads pretrained weights"| RT2
        RT2 --> Vision
        RT2 --> Language
        Vision --> Fusion
        Language --> Fusion
        Fusion --> Action
        Action -->|action tokens| UA
    end

    %% External Dependencies
    PyTorch["PyTorch"]:::external
    RT2 -->|"uses torch.Tensor & autograd"| PyTorch

    %% Supporting Infrastructure
    subgraph "Packaging & Dependencies"
        direction TB
        PyProj["pyproject.toml"]:::infra
        ReqTxt["requirements.txt"]:::infra
    end

    subgraph "CI/CD"
        direction TB
        CI["GitHub Actions\n(.github/workflows/python-publish.yml)"]:::infra
    end

    subgraph "Documentation"
        direction TB
        README["README.md"]:::infra
        DATASETS["docs/DATASETS.md"]:::infra
        EVAL["docs/EVALUATION.md"]:::infra
        MODELDOC["docs/MODEL.md"]:::infra
        ROBOTEVAL["docs/ROBOTEVALSUITE.md"]:::infra
    end

    subgraph "Tests & Others"
        direction TB
        TESTS["tests/test.py"]:::infra
        LICENSE["LICENSE"]:::infra
        GITIGNORE[".gitignore"]:::infra
    end

    CI -->|runs tests & publishes| TESTS
    CI -->|publishes package| PyProj
    CI -->|publishes package| ReqTxt

    %% Click Events
    click UA "https://github.com/kyegomez/rt-2/blob/main/example.py"
    click RT2 "https://github.com/kyegomez/rt-2/blob/main/rt2/model.py"
    click Init "https://github.com/kyegomez/rt-2/blob/main/rt2/__init__.py"
    click Vision "https://github.com/kyegomez/rt-2/blob/main/rt2/model.py"
    click Language "https://github.com/kyegomez/rt-2/blob/main/rt2/model.py"
    click Fusion "https://github.com/kyegomez/rt-2/blob/main/rt2/model.py"
    click Action "https://github.com/kyegomez/rt-2/blob/main/rt2/model.py"
    click PyProj "https://github.com/kyegomez/rt-2/blob/main/pyproject.toml"
    click ReqTxt "https://github.com/kyegomez/rt-2/blob/main/requirements.txt"
    click CI "https://github.com/kyegomez/rt-2/blob/main/.github/workflows/python-publish.yml"
    click README "https://github.com/kyegomez/rt-2/blob/main/README.md"
    click DATASETS "https://github.com/kyegomez/rt-2/blob/main/docs/DATASETS.md"
    click EVAL "https://github.com/kyegomez/rt-2/blob/main/docs/EVALUATION.md"
    click MODELDOC "https://github.com/kyegomez/rt-2/blob/main/docs/MODEL.md"
    click ROBOTEVAL "https://github.com/kyegomez/rt-2/blob/main/docs/ROBOTEVALSUITE.md"
    click TESTS "https://github.com/kyegomez/rt-2/blob/main/tests/test.py"
    click LICENSE "https://github.com/kyegomez/rt-2/tree/main/LICENSE"
    click GITIGNORE "https://github.com/kyegomez/rt-2/blob/main/.gitignore"

    %% Styles
    classDef module fill:#D0E8FF,stroke:#0366d6,color:#0366d6,stroke-width:1px;
    classDef external fill:#DEFFDE,stroke:#28A745,color:#28A745,stroke-width:1px;
    classDef infra fill:#F5F5F5,stroke:#6A737D,color:#6A737D,stroke-dasharray: 5 5;
```
