Skip to content

Latest commit

History

History
183 lines (176 loc) 路 7.38 KB

TRAIN_AND_VALIDATE_V1.5.md

File metadata and controls

183 lines (176 loc) 路 7.38 KB

Chat-UniVi v1.5

Following LLaVA v1.5, we add grounding data and visual question-answering (VQA) data into the training dataset, enhancing the model's reasoning capabilities.

1. Data

Download the training annotations. You can download from https://huggingface.co/datasets/Chat-UniVi/Chat-UniVi-Instruct/tree/main/v1.5_train_json.

DatasetsBaidu Disk
Image pretraining (From LLaVA v1.5)Link
Image tuning (From LLaVA v1.5)Link
Video pretraining (From Valley)Link

2. Train the model

Stage1: Multimodal Pre-training

deepspeed \
--include localhost:0,1,2,3,4,5,6,7 \
--master_port=29602 \
ChatUniVi/train/train_mem.py \
--deepspeed scripts/zero3.json \
--model_name_or_path ${LLM model path} \
--version v1 \
--model_use PRETUNEv1.5 \
--dataset_use Pretrain \
--vision_tower openai/clip-vit-large-patch14-336 \
--tune_mm_mlp_adapter True \
--mm_vision_select_layer -2 \
--mm_use_im_start_end False \
--mm_use_im_patch_token False \
--bf16 True \
--output_dir ${stage1 save path} \
--num_train_epochs 1 \
--per_device_train_batch_size 16 \
--per_device_eval_batch_size 4 \
--gradient_accumulation_steps 1 \
--evaluation_strategy "no" \
--save_strategy "steps" \
--save_steps 24000 \
--save_total_limit 1 \
--learning_rate 2e-3 \
--weight_decay 0. \
--warmup_ratio 0.03 \
--lr_scheduler_type "cosine" \
--logging_steps 1 \
--tf32 True \
--model_max_length 2048 \
--gradient_checkpointing True \
--dataloader_num_workers 4 \
--lazy_preprocess True \
--report_to wandb

Stage2: Joint Instruction Tuning

deepspeed \
--include localhost:0,1,2,3,4,5,6,7 \
--master_port=29601 \
ChatUniVi/train/train_mem.py \
--deepspeed scripts/zero2.json \
--model_name_or_path ${LLM model path} \
--version v1 \
--model_use FINETUNE \
--dataset_use FINETUNEv1.5 \
--vision_tower openai/clip-vit-large-patch14-336 \
--pretrain_mm_mlp_adapter ${stage1 save path}/mm_projector.bin \
--mm_vision_select_layer -2 \
--mm_use_im_start_end False \
--mm_use_im_patch_token False \
--bf16 True \
--output_dir ${stage2 save path} \
--num_train_epochs 2 \
--per_device_train_batch_size 16 \
--per_device_eval_batch_size 4 \
--gradient_accumulation_steps 1 \
--evaluation_strategy "no" \
--save_strategy "steps" \
--save_steps 50000 \
--save_total_limit 1 \
--learning_rate 2e-5 \
--weight_decay 0. \
--warmup_ratio 0.03 \
--lr_scheduler_type "cosine" \
--logging_steps 1 \
--tf32 True \
--model_max_length 2048 \
--gradient_checkpointing True \
--dataloader_num_workers 4 \
--lazy_preprocess True \
--report_to wandb

3. Results

Image Understanding Benchmarks

MethodsLLMVisual TokensVQA v2GQAVisWizSQA IVQA TPOPEMMBLLaVA WMM-Vet
LLaVA v1.5Vicuna-7B57678.562.050.066.858.285.964.363.430.5
Video-LLaVAVicuna-7B25674.760.348.166.451.884.460.973.132.0
Chat-UniVi-7B v1.5Vicuna-7B11275.459.644.268.153.085.462.764.328.3

VideoQA

MethodsLLM SizeMSRVTT-QAMSVD-QATGIF-QAActivityNet-QA
AccuracyScoreAccuracyScoreAccuracyScoreAccuracyScore
Video-LLaMA7B29.61.851.62.5--12.41.1
LLaMA-Adapter7B43.82.754.93.1--34.22.7
VideoChat7B45.02.556.32.834.42.326.52.2
Video-ChatGPT7B49.32.864.93.351.43.035.22.7
Video-LLaVA7B59.23.570.73.970.04.045.33.3
Chat-UniVi-7B7B54.63.165.03.660.33.445.83.2
Chat-UniVi-7B with new video loading code7B55.03.169.33.769.03.846.13.3
Chat-UniVi-7B v1.57B57.53.268.83.770.03.847.23.3

POPE

MethodsLLM SizeRandomPopularAdversarial
AccuracyF1-ScoreYesAccuracyF1-ScoreYesAccuracyF1-ScoreYes
LLaVA7B72.1678.2276.2961.3771.5285.6358.6770.1288.33
Video-LLaVA7B86.285.242.085.384.042.181.680.845.8
Chat-UniVi-7B7B85.1986.0554.6769.5074.3969.1064.9771.5473.10
Chat-UniVi-7B v1.57B87.0186.0941.8685.8784.7642.7383.2382.3144.77