# datawhalechina/self-llm architecture

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

- Interactive diagram: https://gitdiagram.com/datawhalechina/self-llm
- Repository: https://github.com/datawhalechina/self-llm

## Overview

This repository is a Chinese-language learning guide and collection of tutorials for using open-source language models, rather than one integrated runtime product. Its documented learning path moves from Linux environment preparation to local model deployment and applications, then to fine-tuning. The graph preserves major documented application and training branches, with representative source paths from the supplied tree. The README describes broader tutorial coverage than the sampled files expose, so unsampled subsystems are represented at the `models` directory level and their internal wiring is not inferred.

Main entry points: [`models`](https://github.com/datawhalechina/self-llm/tree/master/models) (Model Deployment), [`models_mlx/run_app_gradio.py`](https://github.com/datawhalechina/self-llm/blob/master/models_mlx/run_app_gradio.py) (MLX Chat App), [`models/ChatGLM/05-ChatGLM3-6B接入LangChain搭建知识库助手`](https://github.com/datawhalechina/self-llm/tree/master/models/ChatGLM/05-ChatGLM3-6B%E6%8E%A5%E5%85%A5LangChain%E6%90%AD%E5%BB%BA%E7%9F%A5%E8%AF%86%E5%BA%93%E5%8A%A9%E6%89%8B) (Knowledge Assistants), [`models/DeepSeek-V4-Flash/01-DeepSeek-V4-Flash-LoRA-Inference.py`](https://github.com/datawhalechina/self-llm/blob/master/models/DeepSeek-V4-Flash/01-DeepSeek-V4-Flash-LoRA-Inference.py) (Command-Line Use)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_learn["Learning Path"]
  node_environment["Linux Environment"]
end

subgraph group_deploy["Model Use"]
  node_deployment["Model Deployment"]
  node_chat["Command-Line Use"]
  node_webdemos["Web Demos<br/>[app.py]"]
  node_multimodal["Multimodal Inference<br/>[inference.py]"]
  node_api["Model APIs"]
end

subgraph group_apps["Applications"]
  node_rag["Knowledge Assistants"]
  node_ragmodel["LangChain Model Adapters<br/>[LLM.py]"]
  node_mlx["MLX Chat App<br/>[run_app_gradio.py]"]
  node_mlxbackend["MLX Backends<br/>[framework.py]"]
  node_mlxdownload["Model Download<br/>[download_model.py]"]
end

subgraph group_tune["Fine-Tuning"]
  node_finetuning["Fine-Tuning Methods"]
  node_lora["LoRA Training"]
  node_ptuning["P-Tuning"]
  node_distributed["Distributed Training"]
end

node_learner(("Learner"))
node_modelhub(("Model Sources"))
node_hardware(("Linux Hardware"))

node_learner -->|"learns first"| node_environment
node_environment -->|"prepares for"| node_deployment
node_learner -->|"studies"| node_deployment
node_deployment -->|"covers"| node_chat
node_deployment -->|"covers"| node_webdemos
node_deployment -->|"covers"| node_multimodal
node_deployment -->|"covers"| node_api
node_learner -->|"studies"| node_rag
node_rag -->|"uses adapter"| node_ragmodel
node_learner -->|"uses"| node_mlx
node_mlx -->|"calls"| node_mlxdownload
node_mlx -->|"creates backend"| node_mlxbackend
node_learner -->|"studies next"| node_finetuning
node_finetuning -->|"covers"| node_lora
node_finetuning -->|"covers"| node_ptuning
node_finetuning -->|"covers"| node_distributed
node_modelhub -.->|"provides models"| node_deployment
node_hardware -.->|"runs models"| node_deployment
node_hardware -.->|"supports training"| node_finetuning

click node_deployment "https://github.com/datawhalechina/self-llm/tree/master/models"
click node_chat "https://github.com/datawhalechina/self-llm/blob/master/models/DeepSeek-V4-Flash/01-DeepSeek-V4-Flash-LoRA-Inference.py"
click node_webdemos "https://github.com/datawhalechina/self-llm/blob/master/models/Llama4/01-Llama4-%E5%AF%B9%E8%AF%9D%E5%8A%A9%E6%89%8B/app/app.py"
click node_multimodal "https://github.com/datawhalechina/self-llm/blob/master/models/Qwen2-VL/06-Qwen2-VL-2B-Instruct%20Lora%E5%BE%AE%E8%B0%83%E6%A1%88%E4%BE%8B%20-%20LaTextOCR%20%E5%8F%82%E8%80%83%E4%BB%A3%E7%A0%81/inference.py"
click node_api "https://github.com/datawhalechina/self-llm/blob/master/models/Qwen2-VL/01-Qwen2-VL-2B-Instruct%20FastApi%20%E5%8F%82%E8%80%83%E4%BB%A3%E7%A0%81/api_server_image.py"
click node_rag "https://github.com/datawhalechina/self-llm/tree/master/models/ChatGLM/05-ChatGLM3-6B%E6%8E%A5%E5%85%A5LangChain%E6%90%AD%E5%BB%BA%E7%9F%A5%E8%AF%86%E5%BA%93%E5%8A%A9%E6%89%8B"
click node_ragmodel "https://github.com/datawhalechina/self-llm/blob/master/models/ChatGLM/05-ChatGLM3-6B%E6%8E%A5%E5%85%A5LangChain%E6%90%AD%E5%BB%BA%E7%9F%A5%E8%AF%86%E5%BA%93%E5%8A%A9%E6%89%8B/LLM.py"
click node_mlx "https://github.com/datawhalechina/self-llm/blob/master/models_mlx/run_app_gradio.py"
click node_mlxbackend "https://github.com/datawhalechina/self-llm/blob/master/models_mlx/modules/framework.py"
click node_mlxdownload "https://github.com/datawhalechina/self-llm/blob/master/models_mlx/modules/download_model.py"
click node_finetuning "https://github.com/datawhalechina/self-llm/tree/master/models"
click node_lora "https://github.com/datawhalechina/self-llm/blob/master/models/ChatGLM/06-ChatGLM3-6B-Lora%E5%BE%AE%E8%B0%83.py"
click node_ptuning "https://github.com/datawhalechina/self-llm/blob/master/models/Qwen/05-Qwen-7B-Chat%20Ptuning%20%E5%BE%AE%E8%B0%83.py"
click node_distributed "https://github.com/datawhalechina/self-llm/blob/master/models/MiniMax-M3/finetune/train/finetune_m3_bf16_zero3.py"

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_environment toneBlue
class node_deployment,node_chat,node_webdemos,node_multimodal,node_api toneAmber
class node_rag,node_ragmodel,node_mlx,node_mlxbackend,node_mlxdownload toneMint
class node_finetuning,node_lora,node_ptuning,node_distributed toneRose
class node_learner,node_modelhub,node_hardware toneIndigo
```

## Components

### Learning Path

- **Linux Environment**

### Model Use

- [Model Deployment](https://github.com/datawhalechina/self-llm/tree/master/models): `models`
- [Command-Line Use](https://github.com/datawhalechina/self-llm/blob/master/models/DeepSeek-V4-Flash/01-DeepSeek-V4-Flash-LoRA-Inference.py): `models/DeepSeek-V4-Flash/01-DeepSeek-V4-Flash-LoRA-Inference.py`
- [Web Demos](https://github.com/datawhalechina/self-llm/blob/master/models/Llama4/01-Llama4-%E5%AF%B9%E8%AF%9D%E5%8A%A9%E6%89%8B/app/app.py): `models/Llama4/01-Llama4-对话助手/app/app.py`
- [Multimodal Inference](https://github.com/datawhalechina/self-llm/blob/master/models/Qwen2-VL/06-Qwen2-VL-2B-Instruct%20Lora%E5%BE%AE%E8%B0%83%E6%A1%88%E4%BE%8B%20-%20LaTextOCR%20%E5%8F%82%E8%80%83%E4%BB%A3%E7%A0%81/inference.py): `models/Qwen2-VL/06-Qwen2-VL-2B-Instruct Lora微调案例 - LaTextOCR 参考代码/inference.py`
- [Model APIs](https://github.com/datawhalechina/self-llm/blob/master/models/Qwen2-VL/01-Qwen2-VL-2B-Instruct%20FastApi%20%E5%8F%82%E8%80%83%E4%BB%A3%E7%A0%81/api_server_image.py): `models/Qwen2-VL/01-Qwen2-VL-2B-Instruct FastApi 参考代码/api_server_image.py`

### Applications

- [Knowledge Assistants](https://github.com/datawhalechina/self-llm/tree/master/models/ChatGLM/05-ChatGLM3-6B%E6%8E%A5%E5%85%A5LangChain%E6%90%AD%E5%BB%BA%E7%9F%A5%E8%AF%86%E5%BA%93%E5%8A%A9%E6%89%8B): `models/ChatGLM/05-ChatGLM3-6B接入LangChain搭建知识库助手`
- [LangChain Model Adapters](https://github.com/datawhalechina/self-llm/blob/master/models/ChatGLM/05-ChatGLM3-6B%E6%8E%A5%E5%85%A5LangChain%E6%90%AD%E5%BB%BA%E7%9F%A5%E8%AF%86%E5%BA%93%E5%8A%A9%E6%89%8B/LLM.py): `models/ChatGLM/05-ChatGLM3-6B接入LangChain搭建知识库助手/LLM.py`
- [MLX Chat App](https://github.com/datawhalechina/self-llm/blob/master/models_mlx/run_app_gradio.py): `models_mlx/run_app_gradio.py`
- [MLX Backends](https://github.com/datawhalechina/self-llm/blob/master/models_mlx/modules/framework.py): `models_mlx/modules/framework.py`
- [Model Download](https://github.com/datawhalechina/self-llm/blob/master/models_mlx/modules/download_model.py): `models_mlx/modules/download_model.py`

### Fine-Tuning

- [Fine-Tuning Methods](https://github.com/datawhalechina/self-llm/tree/master/models): `models`
- [LoRA Training](https://github.com/datawhalechina/self-llm/blob/master/models/ChatGLM/06-ChatGLM3-6B-Lora%E5%BE%AE%E8%B0%83.py): `models/ChatGLM/06-ChatGLM3-6B-Lora微调.py`
- [P-Tuning](https://github.com/datawhalechina/self-llm/blob/master/models/Qwen/05-Qwen-7B-Chat%20Ptuning%20%E5%BE%AE%E8%B0%83.py): `models/Qwen/05-Qwen-7B-Chat Ptuning 微调.py`
- [Distributed Training](https://github.com/datawhalechina/self-llm/blob/master/models/MiniMax-M3/finetune/train/finetune_m3_bf16_zero3.py): `models/MiniMax-M3/finetune/train/finetune_m3_bf16_zero3.py`

### Other components

- **Learner**
- **Model Sources**
- **Linux Hardware**

## Connections

- Learner → Linux Environment: learns first
- Linux Environment → Model Deployment: prepares for
- Learner → Model Deployment: studies
- Model Deployment → Command-Line Use: covers
- Model Deployment → Web Demos: covers
- Model Deployment → Multimodal Inference: covers
- Model Deployment → Model APIs: covers
- Learner → Knowledge Assistants: studies
- Knowledge Assistants → LangChain Model Adapters: uses adapter
- Learner → MLX Chat App: uses
- MLX Chat App → Model Download: calls
- MLX Chat App → MLX Backends: creates backend
- Learner → Fine-Tuning Methods: studies next
- Fine-Tuning Methods → LoRA Training: covers
- Fine-Tuning Methods → P-Tuning: covers
- Fine-Tuning Methods → Distributed Training: covers
- Model Sources → Model Deployment: provides models
- Linux Hardware → Model Deployment: runs models
- Linux Hardware → Fine-Tuning Methods: supports training
