推理前需从 Hugging Face 单独下载 unitok_tokenizer.pth 并填入 ckpt_path;训练需自行下载 DataComp-1B 及损失计算所需模型放到 ./external;训练前需在 launch.sh 中配置 nnodes、nproc_per_node、master_addr、master_port 等分布式参数

UniTok
FoundationVisionMIT更新放缓统一视觉分词器,把图像同时编码成适合生成和理解任务的离散 token,解决生成与理解模型各用一套 tokenizer 的割裂问题。
[NeurIPS 2025 Spotlight] A Unified Tokenizer for Visual Generation and Understanding
git clone https://github.com/FoundationVision/UniTok.git
cd UniTok
pip install -r requirements.txt
python inference.py --ckpt_path /path/to/unitok_tokenizer.pth --src_img /path/to/test_img --rec_img /path/to/rec_imgREADME 未说明显存与 GPU 型号要求,仅要求 Python ≥ 3.10、PyTorch ≥ 2.3.1
统一视觉 tokenizer,让同一套离散 token 同时服务图像生成与多模态理解
统一视觉分词器,把图像同时编码成适合生成和理解任务的离散 token,解决生成与理解模型各用一套 tokenizer 的割裂问题。
核心能力
- 用 256 个 token、16×16×8 码本编码图像
- 兼容 LlamaGen、LLaVA、Chameleon、Liquid 等模型
- 提供 inference.py 做图像重建推理
- 配套发布统一 MLLM 权重与 Gradio Demo
- 在 ImageNet 256×256 上 rFID 达 0.41
容易踩的坑
暂无 release 数据(可能没有发版,或尚未同步)。
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
Chuofan Ma1,2 · Yi Jiang2† · Junfeng Wu2,3 · Jihan Yang1 Xin Yu1 · Zehuan Yuan2* · Bingyue Peng2 · Xiaojuan Qi1†*
1HKU 2ByteDance 3HUST †project lead *corresponding author
This repo implements UniTok, a unified visual tokenizer well-suited for both generation and understanding tasks. It is compatiable with autoregressive generative models (e.g. LlamaGen), multimodal understanding models (e.g. LLaVA), and unified MLLMs (e.g. Chameleon and Liquid).

Built upon UniTok, we construct an MLLM capable of both multimodal generation and understanding with the Liquid framework, which sets a new state-of-the-art among unified autoregressive MLLMs.

News
2025-09-18: UniTok is accepted at NeurIPS 2025 as a spotlight.
2025-05-19: We find UniTok favors generation without classifier-free-guidance -- it reduces gFID (without cfg) from 14.6 to 2.51 on ImageNet 256x256 using LlamaGen-XXL as the generator. Please refer to the updated EVAL.md for more details.
2025-04-15: The gradio demo of UniTok MLLM is available on Huggingface now!
2025-04-02: A new checkpoint of UniTok is released, which has better downstream task performance by replacing the causal attention projection layer with full attention. The model weights of our unified MLLM are also available on Huggingface now!
2025-02-28: Paper, code, model, and project page for UniTok are all released.
Performance
† indicates the model uses pretrained CLIP weights for initialization. Although CLIP weight initialization boosts ImageNet zero-shot accuracy, we notice that random initialization leads to better downstream understanding performance. We thus release the model checkpoint of UniTok that is trained from scratch.
Model Weights
| Model | Res. | #Token | Code Shape | rFID | Checkpoint |
|---|---|---|---|---|---|
| UniTok-Large | 256 | 256 | 16 $\times$ 16 $\times$ 8 | 0.41 | Download |
Usage
Requirements
- Python ≥ 3.10
- PyTorch ≥ 2.3.1
Installation
git clone https://github.com/FoundationVision/UniTok.git
cd UniTok
pip install -r requirements.txt
Inference
Please download the checkpoint and fill in the ckpt_path.
python inference.py \
--ckpt_path /path/to/unitok_tokenizer.pth \
--src_img /path/to/test_img --rec_img /path/to/rec_img
Training
-
We train UniTok on DataComp-1B. Please follow the instructions to download and prepare the data.
-
Download the models used for loss calculation and put them under
./external. -
Download the ImageNet validation set for zero-shot accuracy evaluation.
-
Download the ImageNet 256$\times$256 reference batch for FID evaluation.
Configure nnodes, nproc_per_node, node_rank, master_addr, master_port in launch.sh and run:
bash launch.sh \
--output_dir '/path/to/save/checkpoints/' \
--train_data '/path/to/datacomp/shards/{00000000..00140146}.tar' \
--imagenet_val '/path/to/imagenet_val/' \
--fid_eval_src '/path/to/imagenet_reference_batch' \
--fid_eval_dst '/path/to/save/imagenet_reconstructed_batch'
Note: For more hyper-parameter configurations, please check utils/config.py.
Unified MLLM
We show that UniTok significantly boosts the performance of unified MLLMs.
Visual Understanding Performance on VQA Benchmarks.
| Method | LLM | Res. | VQAv2 | GQA | TextVQA | POPE | MME | MM-Vet |
|---|---|---|---|---|---|---|---|---|
| Show-o | Phi-1.5-1.3B | 256 | 59.3 | 48.7 | - | 73.8 | 948 | - |
| Liquid | Gemma-7B | 512 | 71.3 | 58.4 | 42.4 | 81.1 | 1119 | - |
| VILA-U | Llama-2-7B | 256 | 75.3 | 58.3 | 48.3 | 83.9 | 1336 | 27.7 |
| UniTok | Llama-2-7B | 256 | 76.8 | 61.1 | 51.6 | 83.2 | 1448 | 33.9 |
Visual Generation Performance on GenAI-Bench.
Please refer to EVAL.md for more details.
Evaluation
We also benchmark UniTok in terms of both understanding performance using the LLaVA framework and generation performance using the LLamaGen framework. Please refer to EVAL.md for more details.
Acknowledgement
UniTok is built upon the awesome works VAR, DataComp, Liquid, LLaVA, LlamaGen, and ViTamin.
LICENSE
This project is licensed under the MIT License - see the LICENSE file for details.
Citation
If you find this project useful, please consider citing:
@article{unitok,
title={UniTok: A Unified Tokenizer for Visual Generation and Understanding},
author={Ma, Chuofan and Jiang, Yi and Wu, Junfeng and Yang, Jihan and Yu, Xin and Yuan, Zehuan and Peng, Bingyue and Qi, Xiaojuan},
journal={arXiv preprint arXiv:2502.20321},
year={2025}
}