# zjunlp/easyedit architecture

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

- Interactive diagram: https://gitdiagram.com/zjunlp/easyedit
- Repository: https://github.com/zjunlp/easyedit

## Overview

##### Project type and purpose
- From the file tree and README, this is an open-source Python library/framework (EasyEdit) for **knowledge/model editing** of large language models (LLMs).
- It provides a unified framework of three core abstractions:
- **Editor** (defines the editing scenario)
- **Method** (implements a specific editing algorithm, e.g. ROME, MEND, SERAC)
- **Evaluate** (computes metrics: Reliability, Generalization, Locality, Portability)
- It includes demos, Jupyter notebooks, command-line scripts, hyperparameter YAML configs, Dockerfile, dataset loaders, trainers, and tutorial notebooks.

##### File structure
Top-level:
- **easyeditor/**: core Python package for editors, methods, evaluation, models, dataset processors, trainers, utilities
- **steer/**: standalone steering framework (EasyEdit2) for real-time inference steering
- **demo/**, **examples/**, **tutorial-notebooks/**: sample code, apps, notebooks to demonstrate editing and steering
- **hparams/**: YAML configurations per method/model combination
- **Dockerfile**, **requirements.txt**, **colab_requirements.txt**: environment setup
- CLI helper scripts at root: `axbench.py`, `multimodal_edit.py`, `steering.py`, `vectors_apply.py`, `vectors_generate.py`

##### README for additional insights
- The README outlines:
- Supported methods grouped by editing paradigm
- Usage patterns: BaseEditor, Trainer
- Demo links, paper citations, contributor info

##### Detail
- Module at the folder level (e.g., `easyeditor/models/rome`, `easyeditor/editors`)
- How CLI scripts and notebooks invoke the core

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Configuration Loader
    ConfigLoader["Configuration Loader"]:::data
    %% Dataset Module
    DatasetModule["Dataset Module"]:::data
    %% Editor Core
    EditorCore["Editor Core"]:::core
    %% Method Implementations
    MethodImpl["Method Implementations"]:::methods
    %% Trainer
    Trainer["Trainer"]:::train
    %% Evaluation Engine
    EvalEngine["Evaluation Engine"]:::eval
    %% CLI / Demo Apps
    CLIApps["CLI / Demo Apps"]:::cli
    %% External Services / Libraries
    External["External Services / Libraries"]:::external

    %% Relationships
    ConfigLoader -->|"loads YAML"| EditorCore
    ConfigLoader -->|"loads YAML"| Trainer
    DatasetModule -->|provides data| Trainer
    Trainer -->|uses algorithms| MethodImpl
    EditorCore -->|"apply_method"| MethodImpl
    EditorCore -->|"evaluate()"| EvalEngine
    CLIApps -->|orchestrates| EditorCore
    CLIApps -->|orchestrates| EvalEngine
    CLIApps -->|orchestrates| DatasetModule
    EditorCore -->|depends on| External
    Trainer -->|depends on| External
    MethodImpl -->|pull models| External
    DatasetModule -->|pull datasets| External

    %% Click Events
    click ConfigLoader "https://github.com/zjunlp/easyedit/tree/main/hparams/"
    click ConfigLoader "https://github.com/zjunlp/easyedit/blob/main/easyeditor/util/hparams.py"
    click ConfigLoader "https://github.com/zjunlp/easyedit/blob/main/steer/utils/load_hparams.py"
    click DatasetModule "https://github.com/zjunlp/easyedit/tree/main/easyeditor/dataset/"
    click DatasetModule "https://github.com/zjunlp/easyedit/tree/main/steer/datasets/"
    click EditorCore "https://github.com/zjunlp/easyedit/tree/main/easyeditor/editors/"
    click EditorCore "https://github.com/zjunlp/easyedit/blob/main/easyeditor/editors/editor.py"
    click MethodImpl "https://github.com/zjunlp/easyedit/blob/main/easyeditor/models/rome/rome_main.py"
    click MethodImpl "https://github.com/zjunlp/easyedit/tree/main/steer/vector_generators/"
    click Trainer "https://github.com/zjunlp/easyedit/blob/main/easyeditor/trainer/EditTrainer.py"
    click Trainer "https://github.com/zjunlp/easyedit/tree/main/easyeditor/trainer/"
    click EvalEngine "https://github.com/zjunlp/easyedit/blob/main/easyeditor/evaluate/evaluate.py"
    click EvalEngine "https://github.com/zjunlp/easyedit/blob/main/steer/evaluate/evaluate.py"
    click CLIApps "https://github.com/zjunlp/easyedit/blob/main/axbench.py"
    click CLIApps "https://github.com/zjunlp/easyedit/tree/main/demo/"
    click CLIApps "https://github.com/zjunlp/easyedit/tree/main/examples/"
    click External "https://github.com/zjunlp/easyedit/tree/main/Dockerfile"
    click External "https://github.com/zjunlp/easyedit/blob/main/requirements.txt"

    %% Styles
    classDef core fill:#cfe2f3,stroke:#2f6f9f,color:#000;
    classDef data fill:#d9ead3,stroke:#38761d,color:#000;
    classDef methods fill:#fce5cd,stroke:#e69138,color:#000;
    classDef train fill:#d9d2e9,stroke:#674ea7,color:#000;
    classDef eval fill:#ead1dc,stroke:#a64d79,color:#000;
    classDef cli fill:#f4cccc,stroke:#cc0000,color:#000;
    classDef external fill:#cccccc,stroke:#666666,color:#000;
```
