训练前需用 git-lfs 从 HuggingFace 下载数十 GB 级数据集,并先用 tools/parquet2json.py 转成 json 格式;预训练配置要求全局 batchsize 为 256,需按本地环境改数据与模型路径;微调前必须先用 tools/merge_lora.py 把 LoRA 权重合并进基座模型。
git clone https://github.com/Hon-Wong/VoRA.git
cd VoRA
pip3 install -e .README 未说明具体显存要求;训练示例使用单节点 8 卡 DeepSpeed 或多节点 torchrun,评测示例使用 8 进程 accelerate。
把视觉能力做成 LoRA 注入 LLM,无需外接视觉编码器就能把语言模型变成多模态模型
把视觉能力做成 LoRA 插件直接挂到语言模型上,无需额外视觉编码器就能做多模态理解,省显存也省部署成本。
核心能力
- 将视觉专用 LoRA 层直接注入 LLM 内部,推理时可合并回基座模型
- 用 block-wise 蒸馏把预训练 ViT 的视觉先验迁移进 LoRA 层
- 采用双向注意力掩码,更好捕捉图像上下文信息
- 继承 LLM 处理灵活上下文的能力,支持任意分辨率输入
- 提供 8M/29M 等预训练数据与权重,并已接入 LMMs-Eval 评测
容易踩的坑
暂无 release 数据(可能没有发版,或尚未同步)。
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
VoRA: Integrating Visual Capabilities into LLMs
News
- 2025-04-16: Training code released.
- 2025-04-06: LMMs-Eval has supported VoRA.
- 2025-04-04: VoRA Weights and training data are released.
Install
Clone this repository and install dependencies:
git clone https://github.com/Hon-Wong/VoRA.git
cd VoRA
pip3 install -e .
Data Preparation
We have collected or generated the following datasets for VoRA. The image bytes are also included, so there’s no need to download the images from URLs. The captions were created using a variety of prompts to ensure diversity.
| HF dataset 🤗 | #Samples | Source | Generated by |
|---|---|---|---|
| VoRA-Recap-8M | 8M | DataComp-1B | Qwen2-VL-72B-Instruct |
| VoRA-Recap-29M | 29M | DataComp-1B | Qwen2-VL-72B-Instruct |
| VoRA-Recap-GLDv2-1.4M | 1.4M | GLDv2 | Qwen2-VL-72B-Instruct |
| VoRA-TextQA-Mixed | 6.3M | Cambrian, LLaVA-ov, Infinity-Instruction, SmolTalk | - |
- download the pre-training datasets from HF.
datasets for ablation study
apt-get install git-lfs
git-lfs install
cd {raw_data_dir}
git clone https://huggingface.co/datasets/Hon-Wong/VoRA-Recap-8M
datasets for Pre-training
apt-get install git-lfs
git-lfs install
cd {raw_data_dir}
git clone https://huggingface.co/datasets/Hon-Wong/VoRA-Recap-29M
git clone https://huggingface.co/datasets/Hon-Wong/VoRA-Recap-GLDv2-1.4M
git clone https://huggingface.co/datasets/Hon-Wong/VoRA-TextQA-Mixed
- convert parquet to json
For ablation:
python3 tools/parquet2json.py --dataset_dir={raw_data_dir}/VoRA-Recap-8M --save_dir={data_dir}/VoRA-Recap-8M
For Pre-training:
python3 tools/parquet2json.py --dataset_dir={raw_data_dir}/VoRA-Recap-29M --save_dir={data_dir}/VoRA-Recap-29M
python3 tools/parquet2json.py --dataset_dir={raw_data_dir}/VoRA-Recap-GLDv2-1.4M --save_dir={data_dir}/VoRA-Recap-GLDv2-1.4M
python3 tools/parquet2json.py --dataset_dir={raw_data_dir}/VoRA-TextQA-Mixed --save_dir={data_dir}/VoRA-TextQA-Mixed
- Prepare LLaVA-mixture
convert it to VoRA's format:
{
"id": "00000000",
"frames": [
"frames/00000000.jpg",
],
"conversations": [
{
"from": "human",
"value": "Describe this image in detail."
},
{
"from": "gpt",
"value": "<image>\nThis image is a ..."
}
]
}
Also, if you want to use your own data, simply follow the step to format.
Training
- Pre-training
Set the config file in configs/pretrain_I30M_T6M.yaml. Make sure the global batchsize is 256. Change the data path and model path to your local ones.
Train VoRA on a single node with 8 GPUs:
deepspeed --master_port=20000 train/train.py configs/pretrain_I30M_T6M.yaml
Train VoRA on multi nodes:
torchrun --nproc_per_node 8 --nnodes 4 --node_rank $NODE_RANK --master_addr $MASTER_ADDR --master_port $MASTER_PORT train/train.py configs/pretrain_I30M_T6M.yaml
- Finetuning
Merge LoRA weights into the base model:
python3 tools/merge_lora.py --config=configs/pretrain_I30M_T6M.yaml --checkpoint={your_checkpoint_dir} --save_dir={your_save_dir}
Then set the model.pretrained in configs/finetune.yaml, and run:
deepspeed --master_port=20000 train/train.py configs/finetune.yaml
Evaluation
The original results in the paper were evaluated using a suite similar to LLaVA. Alternatively, you can use LMMs-Eval to evaluate the model.
- Install LMMs-Eval:
git clone https://github.com/EvolvingLMMs-Lab/lmms-eval
cd lmms-eval
pip3 install -e .
- Evaluate
Evaluate the checkpoints in the paper:
export HF_TOKEN={your_hf_token}
python3 -m accelerate.commands.launch --num_processes=8 --main_process_port=51999 -m lmms_eval --tasks textvqa_val --model vora --model_args pretrained=Hon-Wong/VoRA-7B-Instruct --batch_size 1 --log_samples --output_path ./logs/
Evaluate your own model:
export HF_TOKEN={your_hf_token}
cp generation_files/* {your_model_dir}
python3 -m accelerate.commands.launch --num_processes=8 --main_process_port=51999 -m lmms_eval --tasks textvqa_val --model vora --model_args pretrained={your_model_dir} --batch_size 1 --log_samples --output_path ./logs/
Citation
If you find this repository useful, please consider citing and starring it:
@article{wang2025vision,
title={Vision as LoRA},
author={Wang, Han and Ye, Yongjie and Li, Bingru and Nie, Yuxiang and Lu, Jinghui and Tang, Jingqun and Wang, Yanjie and Huang, Can},
journal={arXiv preprint arXiv:2503.20680},
year={2025}
}