# koii2k3/llama-oss architecture

> Architecture diagram of the GitHub repository koii2k3/llama-oss, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/koii2k3/llama-oss
- Repository: https://github.com/koii2k3/llama-oss

## Overview

LLaMA-OSS is a research workflow for distilling concise mathematical reasoning from GPT-OSS into a student model. Its documented path is teacher trace generation in multiple reasoning modes, answer verification and length-based curation, SFT, optional GRPO preparation and training, then benchmark evaluation. LLaMA-Factory and MS-SWIFT provide the training and inference frameworks. The README documents these stages, but the provided tree and excerpts do not expose the named workflow scripts or the curation implementation, so those links are documented rather than source-verified.

Main entry points: [`LLaMA-Factory/scripts`](https://github.com/koii2k3/llama-oss/tree/main/LLaMA-Factory/scripts) (Mode generation), [`ms-swift/swift/cli/main.py`](https://github.com/koii2k3/llama-oss/blob/main/ms-swift/swift/cli/main.py) (GRPO training), [`LLaMA-Factory/length_stats.py`](https://github.com/koii2k3/llama-oss/blob/main/LLaMA-Factory/length_stats.py) (Length selection), [`LLaMA-Factory/lm-evaluation-harness/lm_eval/evaluator.py`](https://github.com/koii2k3/llama-oss/blob/main/LLaMA-Factory/lm-evaluation-harness/lm_eval/evaluator.py) (Evaluation harness)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_curation["Trace Curation"]
  node_mode_generation["Mode generation"]
  node_answer_check["Answer verification"]
  node_length_filter["Length selection<br/>[length_stats.py]"]
end

subgraph group_factory["LLaMA-Factory"]
  node_sft["SFT workflow"]
  node_factory_chat["Chat inference<br/>[hf_engine.py]"]
  node_sglang_engine["SGLang engine<br/>[sglang_engine.py]"]
  node_vllm_engine["vLLM engine<br/>[vllm_engine.py]"]
end

subgraph group_swift["MS-SWIFT"]
  node_grpo_prep["GRPO data prep"]
  node_grpo_train["GRPO training<br/>[main.py]"]
  node_swift_infer["Inference engines"]
end

subgraph group_evaluation["Evaluation"]
  node_eval_scripts["Benchmark evaluation"]
  node_eval_harness["Evaluation harness<br/>[evaluator.py]"]
  node_gsm_math["GSM8K and MATH500"]
end

node_researcher(("Researcher"))
node_teacher["GPT-OSS teacher"]

node_researcher -->|"runs"| node_mode_generation
node_teacher -->|"generates traces"| node_mode_generation
node_mode_generation -->|"checks answers"| node_answer_check
node_answer_check -->|"filters traces"| node_length_filter
node_length_filter -->|"curated data"| node_sft
node_researcher -->|"prepares data"| node_grpo_prep
node_grpo_prep -->|"provides JSONL"| node_grpo_train
node_researcher -->|"starts training"| node_grpo_train
node_researcher -->|"runs evaluation"| node_eval_scripts
node_eval_scripts -.->|"evaluates models"| node_eval_harness
node_eval_harness -->|"reports scores"| node_gsm_math
node_sft -.->|"uses framework"| node_factory_chat
node_grpo_train -.->|"uses inference"| node_swift_infer

click node_mode_generation "https://github.com/koii2k3/llama-oss/tree/main/LLaMA-Factory/scripts"
click node_answer_check "https://github.com/koii2k3/llama-oss/tree/main/LLaMA-Factory/scripts"
click node_length_filter "https://github.com/koii2k3/llama-oss/blob/main/LLaMA-Factory/length_stats.py"
click node_sft "https://github.com/koii2k3/llama-oss/tree/main/LLaMA-Factory/scripts"
click node_factory_chat "https://github.com/koii2k3/llama-oss/blob/main/LLaMA-Factory/src/llamafactory/chat/hf_engine.py"
click node_sglang_engine "https://github.com/koii2k3/llama-oss/blob/main/LLaMA-Factory/src/llamafactory/chat/sglang_engine.py"
click node_vllm_engine "https://github.com/koii2k3/llama-oss/blob/main/LLaMA-Factory/src/llamafactory/chat/vllm_engine.py"
click node_grpo_train "https://github.com/koii2k3/llama-oss/blob/main/ms-swift/swift/cli/main.py"
click node_swift_infer "https://github.com/koii2k3/llama-oss/tree/main/ms-swift/swift/llm/infer/infer_engine"
click node_eval_harness "https://github.com/koii2k3/llama-oss/blob/main/LLaMA-Factory/lm-evaluation-harness/lm_eval/evaluator.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_mode_generation,node_answer_check,node_length_filter toneBlue
class node_sft,node_factory_chat,node_sglang_engine,node_vllm_engine toneAmber
class node_grpo_prep,node_grpo_train,node_swift_infer toneMint
class node_eval_scripts,node_eval_harness,node_gsm_math toneRose
class node_researcher,node_teacher toneIndigo
```

## Components

### Trace Curation

- [Mode generation](https://github.com/koii2k3/llama-oss/tree/main/LLaMA-Factory/scripts): `LLaMA-Factory/scripts`
- [Answer verification](https://github.com/koii2k3/llama-oss/tree/main/LLaMA-Factory/scripts): `LLaMA-Factory/scripts`
- [Length selection](https://github.com/koii2k3/llama-oss/blob/main/LLaMA-Factory/length_stats.py): `LLaMA-Factory/length_stats.py`

### LLaMA-Factory

- [SFT workflow](https://github.com/koii2k3/llama-oss/tree/main/LLaMA-Factory/scripts): `LLaMA-Factory/scripts`
- [Chat inference](https://github.com/koii2k3/llama-oss/blob/main/LLaMA-Factory/src/llamafactory/chat/hf_engine.py): `LLaMA-Factory/src/llamafactory/chat/hf_engine.py`
- [SGLang engine](https://github.com/koii2k3/llama-oss/blob/main/LLaMA-Factory/src/llamafactory/chat/sglang_engine.py): `LLaMA-Factory/src/llamafactory/chat/sglang_engine.py`
- [vLLM engine](https://github.com/koii2k3/llama-oss/blob/main/LLaMA-Factory/src/llamafactory/chat/vllm_engine.py): `LLaMA-Factory/src/llamafactory/chat/vllm_engine.py`

### MS-SWIFT

- **GRPO data prep**
- [GRPO training](https://github.com/koii2k3/llama-oss/blob/main/ms-swift/swift/cli/main.py): `ms-swift/swift/cli/main.py`
- [Inference engines](https://github.com/koii2k3/llama-oss/tree/main/ms-swift/swift/llm/infer/infer_engine): `ms-swift/swift/llm/infer/infer_engine`

### Evaluation

- **Benchmark evaluation**
- [Evaluation harness](https://github.com/koii2k3/llama-oss/blob/main/LLaMA-Factory/lm-evaluation-harness/lm_eval/evaluator.py): `LLaMA-Factory/lm-evaluation-harness/lm_eval/evaluator.py`
- **GSM8K and MATH500**

### Other components

- **Researcher**
- **GPT-OSS teacher**

## Connections

- Researcher → Mode generation: runs
- GPT-OSS teacher → Mode generation: generates traces
- Mode generation → Answer verification: checks answers
- Answer verification → Length selection: filters traces
- Length selection → SFT workflow: curated data
- Researcher → GRPO data prep: prepares data
- GRPO data prep → GRPO training: provides JSONL
- Researcher → GRPO training: starts training
- Researcher → Benchmark evaluation: runs evaluation
- Benchmark evaluation → Evaluation harness: evaluates models
- Evaluation harness → GSM8K and MATH500: reports scores
- SFT workflow → Chat inference: uses framework
- GRPO training → Inference engines: uses inference
