VoRA

Hon-Wong长期未更新

把视觉能力做成 LoRA 插件直接挂到语言模型上,无需额外视觉编码器就能做多模态理解,省显存也省部署成本。

[Fully open] [Encoder-free MLLM] Vision as LoRA

暂无版本387star30fork同步于 2026-11-07 07:31 UTC

怎么上手

由 README 提炼,执行前请确认
git clone https://github.com/Hon-Wong/VoRA.git
cd VoRA
pip3 install -e .
硬件要求按 README 说明

README 未说明具体显存要求;训练示例使用单节点 8 卡 DeepSpeed 或多节点 torchrun,评测示例使用 8 进程 accelerate。

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

把视觉能力做成 LoRA 注入 LLM,无需外接视觉编码器就能把语言模型变成多模态模型

把视觉能力做成 LoRA 插件直接挂到语言模型上,无需额外视觉编码器就能做多模态理解,省显存也省部署成本。

核心能力

  • 将视觉专用 LoRA 层直接注入 LLM 内部,推理时可合并回基座模型
  • 用 block-wise 蒸馏把预训练 ViT 的视觉先验迁移进 LoRA 层
  • 采用双向注意力掩码,更好捕捉图像上下文信息
  • 继承 LLM 处理灵活上下文的能力,支持任意分辨率输入
  • 提供 8M/29M 等预训练数据与权重,并已接入 LMMs-Eval 评测

容易踩的坑

训练前需用 git-lfs 从 HuggingFace 下载数十 GB 级数据集,并先用 tools/parquet2json.py 转成 json 格式;预训练配置要求全局 batchsize 为 256,需按本地环境改数据与模型路径;微调前必须先用 tools/merge_lora.py 把 LoRA 权重合并进基座模型。

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

0 个版本

暂无 release 数据(可能没有发版,或尚未同步)。

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    VoRA: Integrating Visual Capabilities into LLMs

    Website arXiv  huggingface

    News

    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 🤗#SamplesSourceGenerated by
    VoRA-Recap-8M8MDataComp-1BQwen2-VL-72B-Instruct
    VoRA-Recap-29M29MDataComp-1BQwen2-VL-72B-Instruct
    VoRA-Recap-GLDv2-1.4M1.4MGLDv2Qwen2-VL-72B-Instruct
    VoRA-TextQA-Mixed6.3MCambrian, LLaVA-ov, Infinity-Instruction, SmolTalk-
    1. 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
    
    1. 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
    
    1. 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

    1. 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
    
    1. 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.

    1. Install LMMs-Eval:
    git clone https://github.com/EvolvingLMMs-Lab/lmms-eval
    cd lmms-eval
    pip3 install -e .
    
    1. 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}
    }