File size: 10,033 Bytes
f2c9122 45cf443 f2c9122 45cf443 f2c9122 45cf443 f2c9122 45cf443 f2c9122 45cf443 f2c9122 45cf443 f2c9122 92c7321 f2c9122 d58698c f2c9122 d58698c f2c9122 d58698c f2c9122 d58698c f2c9122 d9f29d1 d58698c f2c9122 d58698c f2c9122 d58698c f2c9122 d58698c f2c9122 d58698c f2c9122 d58698c f2c9122 d58698c f2c9122 d58698c f2c9122 56d3c4a f2c9122 d58698c f2c9122 56d3c4a f2c9122 9a1a7d2 f2c9122 9a1a7d2 f2c9122 d58698c f2c9122 d58698c f2c9122 d58698c f2c9122 d58698c f2c9122 d58698c f2c9122 d58698c f2c9122 45cf443 f2c9122 d58698c 2a8cecd f2c9122 d58698c 45cf443 f2c9122 45cf443 f2c9122 2c87b68 4020c99 f2c9122 e14a9b6 4020c99 f2c9122 9a1a7d2 a4fb8db f2c9122 f1549f4 45cf443 f2c9122 2c87b68 f2c9122 2c87b68 f2c9122 9a1a7d2 f2c9122 89b5891 f2c9122 e14a9b6 f2c9122 f1549f4 2c87b68 f2c9122 2c87b68 f2c9122 89b5891 bf14804 45cf443 f2c9122 45cf443 6918b42 f2c9122 45cf443 f2c9122 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 | ---
language: en
library_name: omni
tags:
- llm
- multimodal
- vlm
- vam
- voice
- training-framework
---
# Omni: Multimodal LLM Training & Inference Framework




Train and serve **Language-only (LM)**, **Vision-Language (VLM)**, and **Full Omni-modal (VAM β text + vision + audio)** models under one framework.
## π’ News
- **2026-07-23** ποΈ HF Xet for large files β migrated all checkpoints & dataset (29 GB) to Xet storage; git stores LFS pointers, HF server uses Xet for chunk-dedup transport.
- **2026-07-23** π¦ Omni-O HF conversion β `convert_omni_o_to_hf.py` converts `.pth` checkpoints to HuggingFace format with `trust_remote_code` support; auto-detects MoE vs dense architecture.
- **2026-07-22** π₯ Real-time camera + voice β `omni_o_call.py` streams webcam frames and ASR-transcribed voice into the Omni-O model; FP16 NaN guard, VAD-based interrupt, no hardcoded "θ―·ζθΏ°θΏεΌ εΎη".
- **2026-07-21** π€ Published to HF Hub β model code + checkpoints at [chenbhao/omni](https://huggingface.co/chenbhao/omni).
- **2026-07** π§ͺ VAM real-time inference β `RealtimeSession` with SileroVAD, SenseVoice ASR, MimiCodec audio decode, and streaming generation.
- **2026-06** π¬ Omni-O (VAM) training β Full-modal SFT with speech I/O, audio projector, and TalkerModule.
- **2026-05** πΌοΈ VLM training β Vision-language pretrain + SFT with SigLIP encoder and projector.
- **2026-04** ποΈ LM training β Core pretrain / full SFT / LoRA / DPO / PPO / GRPO / distillation pipelines.
- **2026-03** π Initial commit β core architecture (Attention, RoPE, MoE, RMSNorm, Block), LM training loop.
## π¦ Install
```bash
uv sync
# optional extras: RL training / API serving / web demo
uv sync --extra rl --extra serve --extra demo
```
### HF Xet (faster large-file transfer)
Large checkpoint files (`*.pth`, `*.safetensors`, `*.parquet`, etc.) are tracked via Git LFS.
Install the **git-xet** custom transfer agent to replace the standard LFS protocol with
Xet's chunk-dedup transport for much faster push/pull:
```bash
curl --proto '=https' --tlsv1.2 -sSf \
https://raw.githubusercontent.com/huggingface/xet-core/refs/heads/main/git_xet/install.sh | sh
git xet install
```
After setup, use normal git workflow β `git-xet` automatically handles LFS objects:
```bash
git lfs pull # download all large files
git add <file> && git commit # LFS pointer stored in git
git push # Xet protocol uploads actual content
```
## π Quick Start
### Train (YAML-driven)
All training shares a single entrypoint pattern `python -m trainers.<pkg>.<script> --config <yaml>`.
Any CLI flag overrides the YAML default.
<details>
<summary>Language Model (LM)</summary>
```bash
# Pretrain from scratch
python -m trainers.lm.pretrain --config configs/lm/lm_pretrain.yaml
# Full SFT (init from pretrained weights)
python -m trainers.lm.full_sft --config configs/lm/lm_full_sft.yaml
# Train tokenizer
python -m trainers.lm.train_tokenizer --data_path dataset/lm/sft_t2t_mini.jsonl \
--vocab_size 6400 \
--checkpoint_dir ./checkpoint --no_eval
# LoRA / DPO / PPO / GRPO / Distillation
python -m trainers.lm.lora_sft --config configs/lm/lm_full_sft.yaml
python -m trainers.lm.dpo --config configs/lm/lm_full_sft.yaml
python -m trainers.lm.ppo --config configs/lm/lm_full_sft.yaml
python -m trainers.lm.grpo --config configs/lm/lm_full_sft.yaml
python -m trainers.lm.distill --teacher <teacher_path> --config configs/lm/lm_full_sft.yaml
# MoE variant
python -m trainers.lm.full_sft --config configs/lm/lm_full_sft_moe.yaml
# Mini variant (h=128, L=4, ~14min pretrain for quick validation)
python -m trainers.lm.pretrain --config configs/lm/lm_pretrain_mini.yaml
python -m trainers.lm.full_sft --config configs/lm/lm_full_sft_mini.yaml
```
</details>
<details>
<summary>Vision-Language Model (VLM)</summary>
```bash
# Pretrain (vision modality alignment)
python -m trainers.vlm.pretrain --config configs/vlm/vlm_pretrain.yaml
python -m trainers.vlm.pretrain --config configs/vlm/vlm_pretrain_moe.yaml
# Full SFT
python -m trainers.vlm.full_sft --config configs/vlm/vlm_sft.yaml
python -m trainers.vlm.full_sft --config configs/vlm/vlm_sft_moe.yaml
# Mini variant (h=768, L=8, ~1h on RTX 4060)
python -m trainers.vlm.full_sft --config configs/vlm/vlm_sft_mini.yaml
python -m trainers.vlm.full_sft --config configs/vlm/vlm_sft_mini_resume.yaml
```
</details>
<details>
<summary>Omni-modal VAM (text + vision + speech)</summary>
```bash
# Full SFT
python -m trainers.vam.full_sft --config configs/vam/vam.yaml
python -m trainers.vam.full_sft --config configs/vam/vam_moe.yaml # MoE
```
</details>
#### Common overrides
```bash
# Override any YAML field
python -m trainers.lm.full_sft --config configs/lm/lm_full_sft.yaml \
--epochs 3 --batch_size 8 --learning_rate 5e-6
# Multi-GPU DDP
torchrun --nproc_per_node=4 -m trainers.lm.pretrain --config configs/lm/lm_pretrain.yaml
```
### Inference / Chat
```bash
# Native torch format (.pth)
python scripts/eval_llm.py --native --save_dir checkpoint/lm_full_sft_mini \
--weight full_sft --hidden_size 128
# HuggingFace format (config.json + model.safetensors)
python scripts/eval_llm.py --load_from checkpoint/omni/native_hf \
--tokenizer_path checkpoint/omni/native_hf
# Multimodal (VLM)
python scripts/eval_vlm.py --native --save_dir checkpoint/vlm_sft_mini \
--weight sft_vlm --hidden_size 768
# Omni-O real-time voice/video call
python scripts/omni_o_call.py
```
### Format Conversion
```bash
# Native torch β HuggingFace
python scripts/convert_model.py checkpoint/lm_full_sft_mini/full_sft_128.pth \
checkpoint/lm_full_sft_mini/hf \
--tokenizer_path checkpoint/tokenizer
# VLM SFT checkpoint (text-only LM in HF format)
python scripts/convert_model.py checkpoint/vlm_sft_mini/sft_vlm_768.pth \
checkpoint/vlm_sft_mini/hf \
--tokenizer_path checkpoint/omni/native_hf
# Omni-O (VAM) β HF format (auto-detect MoE, includes modeling_omni_o.py)
python scripts/convert_omni_o_to_hf.py checkpoint/omni-o/omni-o.pth \
checkpoint/omni-o-hf
```
> `--tokenizer_path` must point to the **exact tokenizer used during training**, otherwise vocabulary mismatch causes garbled output.
## ποΈ Architecture
```
src/
βββ core/ # Primitive components (by layer depth)
β βββ norm.py # RMSNorm
β βββ rope.py # RoPE freqs / apply_rotary_pos_emb / repeat_kv
β βββ attention.py # Attention
β βββ mlp.py # FeedForward / MOEFeedForward
β βββ block.py # Transformer Block
βββ models/ # Model assembly (by modality)
β βββ lm/ # Text-only: LMConfig, LMForCausalLM, LoRA
β βββ vlm/ # Text + vision: VLMConfig, VLM
β βββ vam/ # Full omni: VAMConfig, VAM + TalkerModule
βββ encoders/ # Modality encoders
β βββ vision/ # SigLIP
β βββ audio/ # SenseVoice
βββ projectors/ # Modality bridging (vision / audio β LLM dim)
βββ trainers/ # Training scripts (lm / vlm / vam)
βββ dataset/ # Dataset classes (pretrain, sft, dpo, rlaif, agent, vlm, vam)
βββ utils/ # Training & multimodal helpers
βββ serve/ # Real-time voice session (SileroVAD, RealtimeSession)
configs/ # YAML configs (lm / vlm / vam)
checkpoint/ # Model weights & tokenizer
scripts/ # Inference, serving, conversion
```
## β¨ Features
### Full training spectrum
| Capability | LM | VLM | VAM |
|:---|:---:|:---:|:---:|
| Pretrain | β
| β
| |
| Full SFT | β
| β
| β
|
| LoRA | β
| | |
| DPO / PPO / GRPO | β
| | |
| Distillation | β
| | |
| MoE | β
| β
| β
|
| Mini variant (fast debug) | β
| β
| β
|
### Trained models
All models share the same base LM backbone (hidden_size=768, 8 layers, 8 heads, GQA).
| Model | Params | Active / token | Modalities | Highlights |
|:---|---:|---:|:---|:---|
| Omni | 64M | 64M | Text | Dense LM, tied embeddings, SwiGLU, RoPE |
| Omni-V | 65M | 65M | Text + Vision | Omni + frozen SigLIP + vision projector |
| Omni-O | 113M | 113M | Text + Vision + Speech | Omni-V + audio projector + 4-layer Talker |
| Omni-O MoE | 315M | 113M | Text + Vision + Speech | Omni-O with 4-expert MoE, top-1 routing |
### Real-time voice/video call
<div align="center">
<img src="assets/video_call.png" alt="Omni video call" width="80%">
</div>
- WebRTC/WebSocket-based streaming
- VAD with interrupt support
- ASR (SenseVoice) β generation β TTS pipeline
- Camera frame integration (no hardcoded image description prompt)
- Voice cloning via `SpeakerEmbedding`
- HuggingFace Hub compatible (`VAM.from_pretrained()`)
## π Checkpoints & Dataset
Large files are stored via **HF Xet** β git holds LFS pointers, HF server stores content with chunk-level deduplication.
```bash
git lfs pull # download actual file content
```
| Directory | Contents | Size |
|:---|---:|---:|
| `checkpoint/` | Model weights (HF + native) | ~3 GB |
| `dataset/` | Training data (parquet, jsonl) | ~29 GB |
|