# wyczzy/aigi-holmes architecture

> Architecture diagram of the GitHub repository wyczzy/aigi-holmes, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/wyczzy/aigi-holmes
- Repository: https://github.com/wyczzy/aigi-holmes

## Overview

AIGI-Holmes targets AI-generated-image detection with human-verifiable explanations. Its documented workflow prepares image data, trains a visual expert, fine-tunes a multimodal language model (SFT, then preference optimization), and runs inference; collaborative decoding is a further documented strategy. The repository also contains the broader SWIFT toolkit for training, inference, evaluation, export, model adaptation, and serving. The README describes dataset annotation and quality control, but the supplied tree does not expose an implementation for that stage; sampled source covers only selected SWIFT modules.

Main entry points: [`swift/cli/main.py`](https://github.com/wyczzy/aigi-holmes/blob/main/swift/cli/main.py) (Command router), [`swift/llm/infer.py`](https://github.com/wyczzy/aigi-holmes/blob/main/swift/llm/infer.py) (Inference), [`swift/llm/sft.py`](https://github.com/wyczzy/aigi-holmes/blob/main/swift/llm/sft.py) (SFT training), [`swift/llm/rlhf.py`](https://github.com/wyczzy/aigi-holmes/blob/main/swift/llm/rlhf.py) (Preference training)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_visual["Visual expert"]
  node_data["Image datasets<br/>[datasets.py]"]
  node_visual_train["Visual pretraining<br/>[trainer.py]"]
  node_visual_model["Visual expert<br/>[models.py]"]
end

subgraph group_mllm["MLLM training"]
  node_sft["SFT training<br/>[sft.py]"]
  node_preprocess["Data and templates<br/>[preprocess.py]"]
  node_tuner["Model adapters<br/>[lora.py]"]
  node_trainer["Trainer framework<br/>[trainers.py]"]
  node_preference["Preference training<br/>[rlhf.py]"]
end

subgraph group_runtime["Inference runtime"]
  node_inference["Inference<br/>[infer.py]"]
  node_decode["Collaborative decoding"]
  node_serving["Model serving<br/>[deploy.py]"]
  node_evaluation["Evaluation<br/>[eval.py]"]
  node_export["Model export<br/>[export.py]"]
  node_logits["Logits processors"]
end

subgraph group_swift["SWIFT toolkit"]
  node_cli["Command router<br/>[main.py]"]
  node_model_utils["Model utilities<br/>[model.py]"]
  node_hub["Model hub"]
end

node_user(("Researcher"))
node_endpoint(("vLLM endpoint"))

node_user -->|"prepares data"| node_data
node_data -->|"trains on"| node_visual_train
node_visual_train -->|"trains"| node_visual_model
node_user -->|"invokes commands"| node_cli
node_cli -->|"routes SFT"| node_sft
node_cli -->|"routes RLHF"| node_preference
node_sft -->|"prepares examples"| node_preprocess
node_sft -->|"adapts model"| node_tuner
node_sft -->|"trains with"| node_trainer
node_preference -->|"prepares examples"| node_preprocess
node_preference -->|"trains with"| node_trainer
node_cli -->|"routes inference"| node_inference
node_inference -->|"loads model"| node_model_utils
node_inference -->|"formats inputs"| node_preprocess
node_inference -.->|"uses visual expert"| node_visual_model
node_inference -.->|"supports decoding"| node_decode
node_decode -->|"processes logits"| node_logits
node_cli -->|"routes deployment"| node_serving
node_cli -->|"routes evaluation"| node_evaluation
node_cli -->|"routes export"| node_export
node_export -.->|"publishes model"| node_hub
node_serving -->|"serves requests"| node_endpoint

click node_data "https://github.com/wyczzy/aigi-holmes/blob/main/Baselines_AIGI/data/datasets.py"
click node_visual_train "https://github.com/wyczzy/aigi-holmes/blob/main/Baselines_AIGI/networks/trainer.py"
click node_visual_model "https://github.com/wyczzy/aigi-holmes/blob/main/Baselines_AIGI/models.py"
click node_sft "https://github.com/wyczzy/aigi-holmes/blob/main/swift/llm/sft.py"
click node_preprocess "https://github.com/wyczzy/aigi-holmes/blob/main/swift/llm/utils/preprocess.py"
click node_tuner "https://github.com/wyczzy/aigi-holmes/blob/main/swift/tuners/lora.py"
click node_trainer "https://github.com/wyczzy/aigi-holmes/blob/main/swift/trainers/trainers.py"
click node_preference "https://github.com/wyczzy/aigi-holmes/blob/main/swift/llm/rlhf.py"
click node_cli "https://github.com/wyczzy/aigi-holmes/blob/main/swift/cli/main.py"
click node_model_utils "https://github.com/wyczzy/aigi-holmes/blob/main/swift/llm/utils/model.py"
click node_inference "https://github.com/wyczzy/aigi-holmes/blob/main/swift/llm/infer.py"
click node_decode "https://github.com/wyczzy/aigi-holmes/tree/main/logits-processor-zoo/logits_processor_zoo/vllm"
click node_serving "https://github.com/wyczzy/aigi-holmes/blob/main/swift/llm/deploy.py"
click node_evaluation "https://github.com/wyczzy/aigi-holmes/blob/main/swift/llm/eval.py"
click node_export "https://github.com/wyczzy/aigi-holmes/blob/main/swift/llm/export.py"
click node_hub "https://github.com/wyczzy/aigi-holmes/tree/main/swift/hub"
click node_logits "https://github.com/wyczzy/aigi-holmes/tree/main/logits-processor-zoo/logits_processor_zoo/vllm"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_data,node_visual_train,node_visual_model toneBlue
class node_sft,node_preprocess,node_tuner,node_trainer,node_preference toneAmber
class node_inference,node_decode,node_serving,node_evaluation,node_export,node_logits toneMint
class node_cli,node_model_utils,node_hub toneRose
class node_user,node_endpoint toneIndigo
```

## Components

### Visual expert

- [Image datasets](https://github.com/wyczzy/aigi-holmes/blob/main/Baselines_AIGI/data/datasets.py): `Baselines_AIGI/data/datasets.py`
- [Visual pretraining](https://github.com/wyczzy/aigi-holmes/blob/main/Baselines_AIGI/networks/trainer.py): `Baselines_AIGI/networks/trainer.py`
- [Visual expert](https://github.com/wyczzy/aigi-holmes/blob/main/Baselines_AIGI/models.py): `Baselines_AIGI/models.py`

### MLLM training

- [SFT training](https://github.com/wyczzy/aigi-holmes/blob/main/swift/llm/sft.py): `swift/llm/sft.py`
- [Data and templates](https://github.com/wyczzy/aigi-holmes/blob/main/swift/llm/utils/preprocess.py): `swift/llm/utils/preprocess.py`
- [Model adapters](https://github.com/wyczzy/aigi-holmes/blob/main/swift/tuners/lora.py): `swift/tuners/lora.py`
- [Trainer framework](https://github.com/wyczzy/aigi-holmes/blob/main/swift/trainers/trainers.py): `swift/trainers/trainers.py`
- [Preference training](https://github.com/wyczzy/aigi-holmes/blob/main/swift/llm/rlhf.py): `swift/llm/rlhf.py`

### Inference runtime

- [Inference](https://github.com/wyczzy/aigi-holmes/blob/main/swift/llm/infer.py): `swift/llm/infer.py`
- [Collaborative decoding](https://github.com/wyczzy/aigi-holmes/tree/main/logits-processor-zoo/logits_processor_zoo/vllm): `logits-processor-zoo/logits_processor_zoo/vllm`
- [Model serving](https://github.com/wyczzy/aigi-holmes/blob/main/swift/llm/deploy.py): `swift/llm/deploy.py`
- [Evaluation](https://github.com/wyczzy/aigi-holmes/blob/main/swift/llm/eval.py): `swift/llm/eval.py`
- [Model export](https://github.com/wyczzy/aigi-holmes/blob/main/swift/llm/export.py): `swift/llm/export.py`
- [Logits processors](https://github.com/wyczzy/aigi-holmes/tree/main/logits-processor-zoo/logits_processor_zoo/vllm): `logits-processor-zoo/logits_processor_zoo/vllm`

### SWIFT toolkit

- [Command router](https://github.com/wyczzy/aigi-holmes/blob/main/swift/cli/main.py): `swift/cli/main.py`
- [Model utilities](https://github.com/wyczzy/aigi-holmes/blob/main/swift/llm/utils/model.py): `swift/llm/utils/model.py`
- [Model hub](https://github.com/wyczzy/aigi-holmes/tree/main/swift/hub): `swift/hub`

### Other components

- **Researcher**
- **vLLM endpoint**

## Connections

- Researcher → Image datasets: prepares data
- Image datasets → Visual pretraining: trains on
- Visual pretraining → Visual expert: trains
- Researcher → Command router: invokes commands
- Command router → SFT training: routes SFT
- Command router → Preference training: routes RLHF
- SFT training → Data and templates: prepares examples
- SFT training → Model adapters: adapts model
- SFT training → Trainer framework: trains with
- Preference training → Data and templates: prepares examples
- Preference training → Trainer framework: trains with
- Command router → Inference: routes inference
- Inference → Model utilities: loads model
- Inference → Data and templates: formats inputs
- Inference → Visual expert: uses visual expert
- Inference → Collaborative decoding: supports decoding
- Collaborative decoding → Logits processors: processes logits
- Command router → Model serving: routes deployment
- Command router → Evaluation: routes evaluation
- Command router → Model export: routes export
- Model export → Model hub: publishes model
- Model serving → vLLM endpoint: serves requests
