# datawhalechina/tiny-universe architecture

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

- Interactive diagram: https://gitdiagram.com/datawhalechina/tiny-universe
- Repository: https://github.com/datawhalechina/tiny-universe

## Overview

Tiny Universe is a hands-on collection of independent, from-scratch LLM and generative-AI projects, rather than one integrated runtime. Its principal learning workflow spans preparing data, building or training models, running inference or retrieval/generation, and evaluating results; the README also highlights Agent and GraphRAG capabilities. The graph preserves the major projects and sampled internal layers. Many relationships are documented only at project level, so the graph avoids inferring a shared application or unshown call paths.

Main entry points: [`content/TinyGraphRAG/tinygraph/graph.py`](https://github.com/datawhalechina/tiny-universe/blob/main/content/TinyGraphRAG/tinygraph/graph.py) (GraphRAG Engine), [`content/TinyLLM/code`](https://github.com/datawhalechina/tiny-universe/tree/main/content/TinyLLM/code) (Tiny LLM), [`content/TinyDiffusion/ddpm`](https://github.com/datawhalechina/tiny-universe/tree/main/content/TinyDiffusion/ddpm) (Tiny Diffusion), [`content/TinyRAG/RAG`](https://github.com/datawhalechina/tiny-universe/tree/main/content/TinyRAG/RAG) (Tiny RAG)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_models["Model Foundations"]
  node_tinyllm["Tiny LLM"]
  node_preprocess["Data Preparation<br/>[preprocess.py]"]
  node_tokenizer["Tokenizer<br/>[tokenizer.py]"]
  node_llm_model["LLM Model<br/>[model.py]"]
  node_transformer["Tiny Transformer"]
end

subgraph group_generation["Image Generation"]
  node_diffusion["Tiny Diffusion"]
  node_image_data["Image Data<br/>[dataloader.py]"]
  node_noise_schedule["Noise Scheduler<br/>[diffusion.py]"]
  node_unet["Noise Predictor<br/>[unet.py]"]
  node_image_metrics["Image Metrics<br/>[metrics.py]"]
end

subgraph group_rag["Retrieval Systems"]
  node_tiny_rag["Tiny RAG"]
  node_embeddings["Text Embeddings<br/>[Embeddings.py]"]
  node_vector_base[("Vector Store<br/>[VectorBase.py]")]
  node_rag_llm["Answer Generation<br/>[LLM.py]"]
end

subgraph group_agents["Agents and Evaluation"]
  node_agent["Tiny Agent<br/>[Agent.py]"]
  node_agent_llm["Agent LLM<br/>[LLM.py]"]
  node_agent_tools["Agent Tools<br/>[tool.py]"]
  node_tiny_eval["Tiny Eval"]
  node_eval_inference["Model Inference<br/>[inference.py]"]
  node_eval_model["Evaluation Model<br/>[LLM.py]"]
  node_eval_metrics["Task Metrics<br/>[metrics.py]"]
end

subgraph group_graphrag["GraphRAG"]
  node_graph_rag["GraphRAG Engine<br/>[graph.py]"]
  node_graph_prompt["Graph Prompts<br/>[prompt.py]"]
  node_graph_embedding["Graph Embeddings<br/>[base.py]"]
  node_graph_llm["Graph LLM<br/>[base.py]"]
end

node_learner(("Learner"))
node_neo4j[("Neo4j")]

node_learner -->|"studies"| node_tinyllm
node_learner -->|"studies"| node_transformer
node_learner -->|"studies"| node_diffusion
node_learner -->|"studies"| node_tiny_rag
node_learner -->|"studies"| node_agent
node_learner -->|"studies"| node_tiny_eval
node_learner -->|"studies"| node_graph_rag
node_preprocess -->|"uses"| node_tokenizer
node_tinyllm -->|"trains from"| node_preprocess
node_tinyllm -->|"trains"| node_llm_model
node_tinyllm -->|"generates with"| node_tokenizer
node_diffusion -->|"loads data"| node_image_data
node_diffusion -->|"trains"| node_unet
node_diffusion -->|"trains with"| node_noise_schedule
node_image_metrics -->|"evaluates"| node_unet
node_image_metrics -->|"samples with"| node_noise_schedule
node_tiny_rag -.->|"embeds documents"| node_embeddings
node_tiny_rag -.->|"retrieves context"| node_vector_base
node_tiny_rag -.->|"generates answers"| node_rag_llm
node_agent -->|"calls"| node_agent_llm
node_agent -->|"dispatches tools"| node_agent_tools
node_tiny_eval -->|"runs evaluation"| node_eval_inference
node_eval_inference -->|"predicts with"| node_eval_model
node_tiny_eval -.->|"scores outputs"| node_eval_metrics
node_graph_rag -->|"embeds text"| node_graph_embedding
node_graph_rag -->|"queries"| node_graph_llm
node_graph_rag -->|"formats prompts"| node_graph_prompt
node_graph_rag -->|"queries graph"| node_neo4j

click node_tinyllm "https://github.com/datawhalechina/tiny-universe/tree/main/content/TinyLLM/code"
click node_preprocess "https://github.com/datawhalechina/tiny-universe/blob/main/content/TinyLLM/code/preprocess.py"
click node_tokenizer "https://github.com/datawhalechina/tiny-universe/blob/main/content/TinyLLM/code/tokenizer.py"
click node_llm_model "https://github.com/datawhalechina/tiny-universe/blob/main/content/TinyLLM/code/model.py"
click node_transformer "https://github.com/datawhalechina/tiny-universe/blob/main/content/TinyTransformer/tiny_transformer.py"
click node_diffusion "https://github.com/datawhalechina/tiny-universe/tree/main/content/TinyDiffusion/ddpm"
click node_image_data "https://github.com/datawhalechina/tiny-universe/blob/main/content/TinyDiffusion/ddpm/dataloader.py"
click node_noise_schedule "https://github.com/datawhalechina/tiny-universe/blob/main/content/TinyDiffusion/ddpm/diffusion.py"
click node_unet "https://github.com/datawhalechina/tiny-universe/blob/main/content/TinyDiffusion/ddpm/unet.py"
click node_image_metrics "https://github.com/datawhalechina/tiny-universe/blob/main/content/TinyDiffusion/ddpm/metrics.py"
click node_tiny_rag "https://github.com/datawhalechina/tiny-universe/tree/main/content/TinyRAG/RAG"
click node_embeddings "https://github.com/datawhalechina/tiny-universe/blob/main/content/TinyRAG/RAG/Embeddings.py"
click node_vector_base "https://github.com/datawhalechina/tiny-universe/blob/main/content/TinyRAG/RAG/VectorBase.py"
click node_rag_llm "https://github.com/datawhalechina/tiny-universe/blob/main/content/TinyRAG/RAG/LLM.py"
click node_agent "https://github.com/datawhalechina/tiny-universe/blob/main/content/TinyAgent/tinyAgent/Agent.py"
click node_agent_llm "https://github.com/datawhalechina/tiny-universe/blob/main/content/TinyAgent/tinyAgent/LLM.py"
click node_agent_tools "https://github.com/datawhalechina/tiny-universe/blob/main/content/TinyAgent/tinyAgent/tool.py"
click node_tiny_eval "https://github.com/datawhalechina/tiny-universe/tree/main/content/TinyEval"
click node_eval_inference "https://github.com/datawhalechina/tiny-universe/blob/main/content/TinyEval/inference.py"
click node_eval_model "https://github.com/datawhalechina/tiny-universe/blob/main/content/TinyEval/Eval/model/LLM.py"
click node_eval_metrics "https://github.com/datawhalechina/tiny-universe/blob/main/content/TinyEval/Eval/metrics.py"
click node_graph_rag "https://github.com/datawhalechina/tiny-universe/blob/main/content/TinyGraphRAG/tinygraph/graph.py"
click node_graph_prompt "https://github.com/datawhalechina/tiny-universe/blob/main/content/TinyGraphRAG/tinygraph/prompt.py"
click node_graph_embedding "https://github.com/datawhalechina/tiny-universe/blob/main/content/TinyGraphRAG/tinygraph/embedding/base.py"
click node_graph_llm "https://github.com/datawhalechina/tiny-universe/blob/main/content/TinyGraphRAG/tinygraph/llm/base.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_tinyllm,node_preprocess,node_tokenizer,node_llm_model,node_transformer toneBlue
class node_diffusion,node_image_data,node_noise_schedule,node_unet,node_image_metrics,node_neo4j toneAmber
class node_tiny_rag,node_embeddings,node_vector_base,node_rag_llm toneMint
class node_agent,node_agent_llm,node_agent_tools,node_tiny_eval,node_eval_inference,node_eval_model,node_eval_metrics toneRose
class node_graph_rag,node_graph_prompt,node_graph_embedding,node_graph_llm,node_learner toneIndigo
```

## Components

### Model Foundations

- [Tiny LLM](https://github.com/datawhalechina/tiny-universe/tree/main/content/TinyLLM/code): `content/TinyLLM/code`
- [Data Preparation](https://github.com/datawhalechina/tiny-universe/blob/main/content/TinyLLM/code/preprocess.py): `content/TinyLLM/code/preprocess.py`
- [Tokenizer](https://github.com/datawhalechina/tiny-universe/blob/main/content/TinyLLM/code/tokenizer.py): `content/TinyLLM/code/tokenizer.py`
- [LLM Model](https://github.com/datawhalechina/tiny-universe/blob/main/content/TinyLLM/code/model.py): `content/TinyLLM/code/model.py`
- [Tiny Transformer](https://github.com/datawhalechina/tiny-universe/blob/main/content/TinyTransformer/tiny_transformer.py): `content/TinyTransformer/tiny_transformer.py`

### Image Generation

- [Tiny Diffusion](https://github.com/datawhalechina/tiny-universe/tree/main/content/TinyDiffusion/ddpm): `content/TinyDiffusion/ddpm`
- [Image Data](https://github.com/datawhalechina/tiny-universe/blob/main/content/TinyDiffusion/ddpm/dataloader.py): `content/TinyDiffusion/ddpm/dataloader.py`
- [Noise Scheduler](https://github.com/datawhalechina/tiny-universe/blob/main/content/TinyDiffusion/ddpm/diffusion.py): `content/TinyDiffusion/ddpm/diffusion.py`
- [Noise Predictor](https://github.com/datawhalechina/tiny-universe/blob/main/content/TinyDiffusion/ddpm/unet.py): `content/TinyDiffusion/ddpm/unet.py`
- [Image Metrics](https://github.com/datawhalechina/tiny-universe/blob/main/content/TinyDiffusion/ddpm/metrics.py): `content/TinyDiffusion/ddpm/metrics.py`

### Retrieval Systems

- [Tiny RAG](https://github.com/datawhalechina/tiny-universe/tree/main/content/TinyRAG/RAG): `content/TinyRAG/RAG`
- [Text Embeddings](https://github.com/datawhalechina/tiny-universe/blob/main/content/TinyRAG/RAG/Embeddings.py): `content/TinyRAG/RAG/Embeddings.py`
- [Vector Store](https://github.com/datawhalechina/tiny-universe/blob/main/content/TinyRAG/RAG/VectorBase.py): `content/TinyRAG/RAG/VectorBase.py`
- [Answer Generation](https://github.com/datawhalechina/tiny-universe/blob/main/content/TinyRAG/RAG/LLM.py): `content/TinyRAG/RAG/LLM.py`

### Agents and Evaluation

- [Tiny Agent](https://github.com/datawhalechina/tiny-universe/blob/main/content/TinyAgent/tinyAgent/Agent.py): `content/TinyAgent/tinyAgent/Agent.py`
- [Agent LLM](https://github.com/datawhalechina/tiny-universe/blob/main/content/TinyAgent/tinyAgent/LLM.py): `content/TinyAgent/tinyAgent/LLM.py`
- [Agent Tools](https://github.com/datawhalechina/tiny-universe/blob/main/content/TinyAgent/tinyAgent/tool.py): `content/TinyAgent/tinyAgent/tool.py`
- [Tiny Eval](https://github.com/datawhalechina/tiny-universe/tree/main/content/TinyEval): `content/TinyEval`
- [Model Inference](https://github.com/datawhalechina/tiny-universe/blob/main/content/TinyEval/inference.py): `content/TinyEval/inference.py`
- [Evaluation Model](https://github.com/datawhalechina/tiny-universe/blob/main/content/TinyEval/Eval/model/LLM.py): `content/TinyEval/Eval/model/LLM.py`
- [Task Metrics](https://github.com/datawhalechina/tiny-universe/blob/main/content/TinyEval/Eval/metrics.py): `content/TinyEval/Eval/metrics.py`

### GraphRAG

- [GraphRAG Engine](https://github.com/datawhalechina/tiny-universe/blob/main/content/TinyGraphRAG/tinygraph/graph.py): `content/TinyGraphRAG/tinygraph/graph.py`
- [Graph Prompts](https://github.com/datawhalechina/tiny-universe/blob/main/content/TinyGraphRAG/tinygraph/prompt.py): `content/TinyGraphRAG/tinygraph/prompt.py`
- [Graph Embeddings](https://github.com/datawhalechina/tiny-universe/blob/main/content/TinyGraphRAG/tinygraph/embedding/base.py): `content/TinyGraphRAG/tinygraph/embedding/base.py`
- [Graph LLM](https://github.com/datawhalechina/tiny-universe/blob/main/content/TinyGraphRAG/tinygraph/llm/base.py): `content/TinyGraphRAG/tinygraph/llm/base.py`

### Other components

- **Learner**
- **Neo4j**

## Connections

- Learner → Tiny LLM: studies (evidence: `README.md`)
- Learner → Tiny Transformer: studies (evidence: `README.md`)
- Learner → Tiny Diffusion: studies (evidence: `README.md`)
- Learner → Tiny RAG: studies (evidence: `README.md`)
- Learner → Tiny Agent: studies (evidence: `README.md`)
- Learner → Tiny Eval: studies (evidence: `README.md`)
- Learner → GraphRAG Engine: studies (evidence: `README.md`)
- Data Preparation → Tokenizer: uses (evidence: `content/TinyLLM/code/preprocess.py`)
- Tiny LLM → Data Preparation: trains from (evidence: `content/TinyLLM/code/train.py`)
- Tiny LLM → LLM Model: trains (evidence: `content/TinyLLM/code/train.py`)
- Tiny LLM → Tokenizer: generates with (evidence: `content/TinyLLM/code/sample.py`)
- Tiny Diffusion → Image Data: loads data (evidence: `content/TinyDiffusion/ddpm/train.py`)
- Tiny Diffusion → Noise Predictor: trains (evidence: `content/TinyDiffusion/ddpm/train.py`)
- Tiny Diffusion → Noise Scheduler: trains with (evidence: `content/TinyDiffusion/ddpm/train.py`)
- Image Metrics → Noise Predictor: evaluates (evidence: `content/TinyDiffusion/ddpm/metrics.py`)
- Image Metrics → Noise Scheduler: samples with (evidence: `content/TinyDiffusion/ddpm/metrics.py`)
- Tiny RAG → Text Embeddings: embeds documents (evidence: `content/TinyRAG/RAG/VectorBase.py`)
- Tiny RAG → Vector Store: retrieves context (evidence: `content/TinyRAG/RAG/VectorBase.py`)
- Tiny RAG → Answer Generation: generates answers
- Tiny Agent → Agent LLM: calls (evidence: `content/TinyAgent/tinyAgent/Agent.py`)
- Tiny Agent → Agent Tools: dispatches tools (evidence: `content/TinyAgent/tinyAgent/Agent.py`)
- Tiny Eval → Model Inference: runs evaluation (evidence: `README.md`)
- Model Inference → Evaluation Model: predicts with (evidence: `content/TinyEval/inference.py`)
- Tiny Eval → Task Metrics: scores outputs (evidence: `content/TinyEval/eval.py`)
- GraphRAG Engine → Graph Embeddings: embeds text (evidence: `content/TinyGraphRAG/tinygraph/graph.py`)
- GraphRAG Engine → Graph LLM: queries (evidence: `content/TinyGraphRAG/tinygraph/graph.py`)
- GraphRAG Engine → Graph Prompts: formats prompts (evidence: `content/TinyGraphRAG/tinygraph/graph.py`)
- GraphRAG Engine → Neo4j: queries graph (evidence: `content/TinyGraphRAG/tinygraph/graph.py`)
