-
Notifications
You must be signed in to change notification settings - Fork 818
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Features] Support multi_modal training #628
Merged
Merged
Changes from 1 commit
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
4dc5fb8
support multi_modal training
lianqing11 588679d
support llava inference
lianqing11 68f8639
update second stage finetune
lianqing11 5fd7bbd
polish the code style and modify the dataset and model path
lianqing11 ab9598c
update script and the path to download the model
lianqing11 ddfa884
fix link in download llava dataset
lianqing11 76b01aa
add the script for downloading the dataset
lianqing11 a518629
update the num gpu-1 command for inference
lianqing11 10ac23e
update downloading script
lianqing11 7e93a25
update downloading dataset for multimodal
lianqing11 0ffa432
update the link to constans
lianqing11 a91bd3e
remove cd .., modify llava inference script
lianqing11 1bef01d
modify input arg
lianqing11 c529723
modify vicuna model
lianqing11 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"fp16": { | ||
"enabled": false | ||
}, | ||
"bf16": { | ||
"enabled": false | ||
}, | ||
"comms_logger": { | ||
"enabled": false, | ||
"verbose": false, | ||
"prof_all": false, | ||
"debug": false | ||
}, | ||
"steps_per_print": 20000000000000000, | ||
"train_micro_batch_size_per_gpu": 1, | ||
"wall_clock_breakdown": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#!/bin/bash | ||
# Please run this script under ${project_id} in project directory of | ||
# https://github.com/shizhediao/llm-ft | ||
# COMMIT: d5fecf30ba8011067b10cf51fede53a5ab6574e4 | ||
|
||
# Parses argumen | ||
model_name_or_path=Salesforce/blip2-flan-t5-xxl | ||
dataset_path=/home/qlianab/data1/llm/llava_instruct_80k.json | ||
image_folder=/home/qlianab/data1/2d_detection/coco/train2017 | ||
output_dir=output_models/finetune | ||
deepspeed_args="--master_port=12000 --include localhost:9" | ||
|
||
while [[ $# -ge 1 ]]; do | ||
key="$1" | ||
case ${key} in | ||
-m|--model_name_or_path) | ||
model_name_or_path="$2" | ||
shift | ||
;; | ||
-d|--dataset_path) | ||
dataset_path="$2" | ||
shift | ||
;; | ||
-o|--output_model_path) | ||
output_dir="$2" | ||
shift | ||
;; | ||
--deepspeed_args) | ||
deepspeed_args="$2" | ||
shift | ||
;; | ||
*) | ||
echo "error: unknown option \"${key}\"" 1>&2 | ||
exit 1 | ||
esac | ||
shift | ||
done | ||
|
||
# Finetune | ||
exp_id=finetune | ||
project_dir=$(cd "$(dirname $0)"/..; pwd) | ||
log_dir=${project_dir}/log/${exp_id} | ||
mkdir -p ${output_dir} ${log_dir} | ||
|
||
deepspeed ${deepspeed_args} \ | ||
examples/finetune_multi_modal.py \ | ||
--deepspeed configs/ds_config_multimodal.json \ | ||
--arch_type vision_encoder_decoder \ | ||
--llava_loading True \ | ||
--model_name_or_path ${model_name_or_path} \ | ||
--image_encoder_name_or_path openai/clip-vit-large-patch14 \ | ||
--pretrained_language_projection_path /home/qlianab/checkpoints/llava-336px-pretrain-vicuna-7b-v1.3/mm_projector.bin \ | ||
--dataset_path ${dataset_path} \ | ||
--output_dir ${output_dir} --overwrite_output_dir \ | ||
--image_folder ${image_folder} \ | ||
--custom_vision_model True \ | ||
--llm_model_name_or_path lmsys/vicuna-7b-v1.5 \ | ||
--image_aspect_ratio None \ | ||
--fp16 True \ | ||
--learning_rate 2e-5 \ | ||
--gradient_accumulation_steps 1 \ | ||
--per_device_train_batch_size 2 \ | ||
--learning_rate 2e-3 \ | ||
--weight_decay 0. \ | ||
--warmup_ratio 0.03 \ | ||
--lr_scheduler_type "cosine" \ | ||
--run_name finetune \ | ||
--validation_split_percentage 0 \ | ||
--logging_steps 20 \ | ||
--do_train \ | ||
--ddp_timeout 72000 \ | ||
--save_steps 5000 \ | ||
--dataloader_num_workers 1 \ | ||
--max_steps 1 \ | ||
| tee ${log_dir}/train.log \ | ||
2> ${log_dir}/train.err |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
model=Salesforce/blip2-opt-2.7b | ||
deepspeed examples/vis_chatbot.py --model_name_or_path ${model} \ | ||
--deepspeed configs/ds_config_multimodal.json \ | ||
--deepspeed configs/ds_config_vis_chatbot.json \ | ||
--arch_type vision_encoder_decoder \ | ||
--task vqa \ | ||
${@:1} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
model=/home/qlianab/data1/checkpoints/llava-v1-0719-336px-lora-merge-vicuna-13b-v1.3 | ||
deepspeed_args="--master_port=12000 --include localhost:9" | ||
|
||
deepspeed ${deepspeed_args} \ | ||
examples/vis_chatbot.py \ | ||
--deepspeed configs/ds_config_vis_chatbot.json \ | ||
--arch_type vision_encoder_decoder \ | ||
--task vqa \ | ||
--custom_model \ | ||
--model_name_or_path ${model} \ | ||
--prompt_format llava \ | ||
--prompt_structure '{input_text} ASSISTANT:' \ | ||
--low_resource True \ | ||
--llava_loading True \ | ||
--with_deepspeed False \ | ||
${@:1} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason to check whether to use deepspeed is that when loading the model with 8bit, using deepspeed would raise an error.
huggingface/transformers#24540
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem. Thanks!