StarCycle commited on
Commit
d1dcf2d
1 Parent(s): fa08ccc
llava_internlm2_chat_1_8b_clip_vit_large_p14_336_e1_gpu1_pretrain.py ADDED
@@ -0,0 +1,214 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) OpenMMLab. All rights reserved.
2
+ import torch
3
+ from mmengine.dataset import DefaultSampler
4
+ from mmengine.hooks import (CheckpointHook, DistSamplerSeedHook, IterTimerHook,
5
+ LoggerHook, ParamSchedulerHook)
6
+ from mmengine.optim import AmpOptimWrapper, CosineAnnealingLR, LinearLR
7
+ from torch.optim import AdamW
8
+ from transformers import (AutoModelForCausalLM, AutoTokenizer,
9
+ BitsAndBytesConfig, CLIPImageProcessor,
10
+ CLIPVisionModel)
11
+
12
+ from xtuner.dataset import LLaVADataset
13
+ from xtuner.dataset.collate_fns import default_collate_fn
14
+ from xtuner.dataset.map_fns import llava_map_fn, template_map_fn_factory
15
+ from xtuner.engine.hooks import DatasetInfoHook, EvaluateChatHook
16
+ from xtuner.engine.runner import TrainLoop
17
+ from xtuner.model import LLaVAModel
18
+ from xtuner.utils import PROMPT_TEMPLATE
19
+
20
+ #######################################################################
21
+ # PART 1 Settings #
22
+ #######################################################################
23
+ # Model
24
+ llm_name_or_path = 'internlm/internlm2-chat-1_8b'
25
+ visual_encoder_name_or_path = 'openai/clip-vit-large-patch14-336'
26
+
27
+ # Data
28
+ data_root = './data/llava_data/'
29
+ data_path = data_root + 'LLaVA-Pretrain/blip_laion_cc_sbu_558k.json'
30
+ image_folder = data_root + 'LLaVA-Pretrain/images'
31
+ prompt_template = PROMPT_TEMPLATE.internlm2_chat
32
+ max_length = int(2048 - (336 / 14)**2)
33
+
34
+ # Scheduler & Optimizer
35
+ batch_size = 40 # per_device
36
+ accumulative_counts = 7
37
+ dataloader_num_workers = 2
38
+ max_epochs = 1
39
+ optim_type = AdamW
40
+ lr = 1e-3
41
+ betas = (0.9, 0.999)
42
+ weight_decay = 0
43
+ max_norm = 1 # grad clip
44
+ warmup_ratio = 0.03
45
+
46
+ # Save
47
+ save_steps = 500
48
+ save_total_limit = 2 # Maximum checkpoints to keep (-1 means unlimited)
49
+
50
+ # Evaluate the generation performance during the training
51
+ evaluation_freq = 500
52
+ SYSTEM = ''
53
+ evaluation_images = 'https://llava-vl.github.io/static/images/view.jpg'
54
+ evaluation_inputs = ['请描述一下这张照片', 'Please describe this picture']
55
+
56
+ #######################################################################
57
+ # PART 2 Model & Tokenizer & Image Processor #
58
+ #######################################################################
59
+ tokenizer = dict(
60
+ type=AutoTokenizer.from_pretrained,
61
+ pretrained_model_name_or_path=llm_name_or_path,
62
+ trust_remote_code=True,
63
+ padding_side='right')
64
+
65
+ image_processor = dict(
66
+ type=CLIPImageProcessor.from_pretrained,
67
+ pretrained_model_name_or_path=visual_encoder_name_or_path,
68
+ trust_remote_code=True)
69
+
70
+ model = dict(
71
+ type=LLaVAModel,
72
+ freeze_llm=True,
73
+ freeze_visual_encoder=True,
74
+ llm=dict(
75
+ type=AutoModelForCausalLM.from_pretrained,
76
+ pretrained_model_name_or_path=llm_name_or_path,
77
+ trust_remote_code=True,
78
+ torch_dtype=torch.float16,
79
+ quantization_config=dict(
80
+ type=BitsAndBytesConfig,
81
+ load_in_4bit=True,
82
+ load_in_8bit=False,
83
+ llm_int8_threshold=6.0,
84
+ llm_int8_has_fp16_weight=False,
85
+ bnb_4bit_compute_dtype=torch.float16,
86
+ bnb_4bit_use_double_quant=True,
87
+ bnb_4bit_quant_type='nf4')),
88
+ visual_encoder=dict(
89
+ type=CLIPVisionModel.from_pretrained,
90
+ pretrained_model_name_or_path=visual_encoder_name_or_path))
91
+
92
+ #######################################################################
93
+ # PART 3 Dataset & Dataloader #
94
+ #######################################################################
95
+ llava_dataset = dict(
96
+ type=LLaVADataset,
97
+ data_path=data_path,
98
+ image_folder=image_folder,
99
+ tokenizer=tokenizer,
100
+ image_processor=image_processor,
101
+ dataset_map_fn=llava_map_fn,
102
+ template_map_fn=dict(
103
+ type=template_map_fn_factory, template=prompt_template),
104
+ max_length=max_length,
105
+ pad_image_to_square=False)
106
+
107
+ train_dataloader = dict(
108
+ batch_size=batch_size,
109
+ num_workers=dataloader_num_workers,
110
+ dataset=llava_dataset,
111
+ sampler=dict(type=DefaultSampler, shuffle=True),
112
+ collate_fn=dict(type=default_collate_fn))
113
+
114
+ #######################################################################
115
+ # PART 4 Scheduler & Optimizer #
116
+ #######################################################################
117
+ # optimizer
118
+ optim_wrapper = dict(
119
+ type=AmpOptimWrapper,
120
+ optimizer=dict(
121
+ type=optim_type, lr=lr, betas=betas, weight_decay=weight_decay),
122
+ clip_grad=dict(max_norm=max_norm, error_if_nonfinite=False),
123
+ accumulative_counts=accumulative_counts,
124
+ loss_scale='dynamic',
125
+ dtype='float16')
126
+
127
+ # learning policy
128
+ # More information: https://github.com/open-mmlab/mmengine/blob/main/docs/en/tutorials/param_scheduler.md # noqa: E501
129
+ param_scheduler = [
130
+ dict(
131
+ type=LinearLR,
132
+ start_factor=1e-5,
133
+ by_epoch=True,
134
+ begin=0,
135
+ end=warmup_ratio * max_epochs,
136
+ convert_to_iter_based=True),
137
+ dict(
138
+ type=CosineAnnealingLR,
139
+ eta_min=0.0,
140
+ by_epoch=True,
141
+ begin=warmup_ratio * max_epochs,
142
+ end=max_epochs,
143
+ convert_to_iter_based=True)
144
+ ]
145
+
146
+ # train, val, test setting
147
+ train_cfg = dict(type=TrainLoop, max_epochs=max_epochs)
148
+
149
+ #######################################################################
150
+ # PART 5 Runtime #
151
+ #######################################################################
152
+ # Log the dialogue periodically during the training process, optional
153
+ custom_hooks = [
154
+ dict(type=DatasetInfoHook, tokenizer=tokenizer),
155
+ dict(
156
+ type=EvaluateChatHook,
157
+ tokenizer=tokenizer,
158
+ image_processor=image_processor,
159
+ every_n_iters=evaluation_freq,
160
+ evaluation_inputs=evaluation_inputs,
161
+ evaluation_images=evaluation_images,
162
+ system=SYSTEM,
163
+ prompt_template=prompt_template)
164
+ ]
165
+
166
+ # configure default hooks
167
+ default_hooks = dict(
168
+ # record the time of every iteration.
169
+ timer=dict(type=IterTimerHook),
170
+ # print log every 10 iterations.
171
+ logger=dict(type=LoggerHook, log_metric_by_epoch=False, interval=10),
172
+ # enable the parameter scheduler.
173
+ param_scheduler=dict(type=ParamSchedulerHook),
174
+ # save checkpoint per `save_steps`.
175
+ checkpoint=dict(
176
+ type=CheckpointHook,
177
+ by_epoch=False,
178
+ interval=save_steps,
179
+ max_keep_ckpts=save_total_limit),
180
+ # set sampler seed in distributed evrionment.
181
+ sampler_seed=dict(type=DistSamplerSeedHook),
182
+ )
183
+
184
+ # configure environment
185
+ env_cfg = dict(
186
+ # whether to enable cudnn benchmark
187
+ cudnn_benchmark=False,
188
+ # set multi process parameters
189
+ mp_cfg=dict(mp_start_method='fork', opencv_num_threads=0),
190
+ # set distributed parameters
191
+ dist_cfg=dict(backend='nccl'),
192
+ )
193
+
194
+ # set visualizer
195
+ from mmengine.visualization import Visualizer, TensorboardVisBackend
196
+ visualizer = dict(
197
+ type=Visualizer,
198
+ vis_backends=[dict(type=TensorboardVisBackend)]
199
+ )
200
+
201
+ # set log level
202
+ log_level = 'INFO'
203
+
204
+ # load from which checkpoint
205
+ load_from = None
206
+
207
+ # whether to resume training from the loaded checkpoint
208
+ resume = False
209
+
210
+ # Defaults to use random seed and disable `deterministic`
211
+ randomness = dict(seed=None, deterministic=False)
212
+
213
+ # set log processor
214
+ log_processor = dict(by_epoch=False)
llava_internlm2_chat_1_8b_clip_vit_large_p14_336_e1_gpu4_finetune.py ADDED
@@ -0,0 +1,230 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) OpenMMLab. All rights reserved.
2
+ import torch
3
+ from mmengine.hooks import (CheckpointHook, DistSamplerSeedHook, IterTimerHook,
4
+ LoggerHook, ParamSchedulerHook)
5
+ from mmengine.optim import AmpOptimWrapper, CosineAnnealingLR, LinearLR
6
+ from peft import LoraConfig
7
+ from torch.optim import AdamW
8
+ from transformers import (AutoModelForCausalLM, AutoTokenizer,
9
+ BitsAndBytesConfig, CLIPImageProcessor,
10
+ CLIPVisionModel)
11
+
12
+ from xtuner.dataset import LLaVADataset
13
+ from xtuner.dataset.collate_fns import default_collate_fn
14
+ from xtuner.dataset.map_fns import llava_map_fn, template_map_fn_factory
15
+ from xtuner.dataset.samplers import LengthGroupedSampler
16
+ from xtuner.engine.hooks import DatasetInfoHook, EvaluateChatHook
17
+ from xtuner.engine.runner import TrainLoop
18
+ from xtuner.model import LLaVAModel
19
+ from xtuner.utils import PROMPT_TEMPLATE
20
+
21
+ #######################################################################
22
+ # PART 1 Settings #
23
+ #######################################################################
24
+ # Model
25
+ llm_name_or_path = 'internlm/internlm2-chat-1_8b'
26
+ visual_encoder_name_or_path = 'openai/clip-vit-large-patch14-336'
27
+ # Specify the pretrained pth
28
+ pretrained_pth = './work_dirs/llava_internlm2_chat_1_8b_clip_vit_large_p14_336_e1_gpu1_pretrain/iter_13954.pth'
29
+
30
+ # Data
31
+ data_root = './data/llava_data/'
32
+ data_path = data_root + 'LLaVA-Instruct-150K/llava_v1_5_mix665k.json'
33
+ image_folder = data_root + 'llava_images'
34
+ prompt_template = PROMPT_TEMPLATE.internlm2_chat
35
+ max_length = int(2048 - (336 / 14)**2)
36
+
37
+ # Scheduler & Optimizer
38
+ batch_size = 12 # per_device
39
+ accumulative_counts = 3
40
+ dataloader_num_workers = 4
41
+ max_epochs = 1
42
+ optim_type = AdamW
43
+ lr = 2e-4
44
+ betas = (0.9, 0.999)
45
+ weight_decay = 0
46
+ max_norm = 1 # grad clip
47
+ warmup_ratio = 0.03
48
+
49
+ # Save
50
+ save_steps = 500
51
+ save_total_limit = 2 # Maximum checkpoints to keep (-1 means unlimited)
52
+
53
+ # Evaluate the generation performance during the training
54
+ evaluation_freq = 500
55
+ SYSTEM = ''
56
+ evaluation_images = 'https://llava-vl.github.io/static/images/view.jpg'
57
+ evaluation_inputs = ['请描述一下这张照片', 'Please describe this picture']
58
+
59
+ #######################################################################
60
+ # PART 2 Model & Tokenizer & Image Processor #
61
+ #######################################################################
62
+ tokenizer = dict(
63
+ type=AutoTokenizer.from_pretrained,
64
+ pretrained_model_name_or_path=llm_name_or_path,
65
+ trust_remote_code=True,
66
+ padding_side='right')
67
+
68
+ image_processor = dict(
69
+ type=CLIPImageProcessor.from_pretrained,
70
+ pretrained_model_name_or_path=visual_encoder_name_or_path,
71
+ trust_remote_code=True)
72
+
73
+ model = dict(
74
+ type=LLaVAModel,
75
+ freeze_llm=True,
76
+ freeze_visual_encoder=True,
77
+ pretrained_pth=pretrained_pth,
78
+ llm=dict(
79
+ type=AutoModelForCausalLM.from_pretrained,
80
+ pretrained_model_name_or_path=llm_name_or_path,
81
+ trust_remote_code=True,
82
+ torch_dtype=torch.float16,
83
+ quantization_config=dict(
84
+ type=BitsAndBytesConfig,
85
+ load_in_4bit=True,
86
+ load_in_8bit=False,
87
+ llm_int8_threshold=6.0,
88
+ llm_int8_has_fp16_weight=False,
89
+ bnb_4bit_compute_dtype=torch.float16,
90
+ bnb_4bit_use_double_quant=True,
91
+ bnb_4bit_quant_type='nf4')),
92
+ llm_lora=dict(
93
+ type=LoraConfig,
94
+ r=512,
95
+ lora_alpha=256,
96
+ lora_dropout=0.05,
97
+ bias='none',
98
+ task_type='CAUSAL_LM'),
99
+ visual_encoder=dict(
100
+ type=CLIPVisionModel.from_pretrained,
101
+ pretrained_model_name_or_path=visual_encoder_name_or_path),
102
+ visual_encoder_lora=dict(
103
+ type=LoraConfig, r=64, lora_alpha=16, lora_dropout=0.05, bias='none'))
104
+
105
+ #######################################################################
106
+ # PART 3 Dataset & Dataloader #
107
+ #######################################################################
108
+ llava_dataset = dict(
109
+ type=LLaVADataset,
110
+ data_path=data_path,
111
+ image_folder=image_folder,
112
+ tokenizer=tokenizer,
113
+ image_processor=image_processor,
114
+ dataset_map_fn=llava_map_fn,
115
+ template_map_fn=dict(
116
+ type=template_map_fn_factory, template=prompt_template),
117
+ max_length=max_length,
118
+ pad_image_to_square=True)
119
+
120
+ train_dataloader = dict(
121
+ batch_size=batch_size,
122
+ num_workers=dataloader_num_workers,
123
+ dataset=llava_dataset,
124
+ sampler=dict(
125
+ type=LengthGroupedSampler,
126
+ length_property='modality_length',
127
+ per_device_batch_size=batch_size * accumulative_counts),
128
+ collate_fn=dict(type=default_collate_fn))
129
+
130
+ #######################################################################
131
+ # PART 4 Scheduler & Optimizer #
132
+ #######################################################################
133
+ # optimizer
134
+ optim_wrapper = dict(
135
+ type=AmpOptimWrapper,
136
+ optimizer=dict(
137
+ type=optim_type, lr=lr, betas=betas, weight_decay=weight_decay),
138
+ clip_grad=dict(max_norm=max_norm, error_if_nonfinite=False),
139
+ accumulative_counts=accumulative_counts,
140
+ loss_scale='dynamic',
141
+ dtype='float16')
142
+
143
+ # learning policy
144
+ # More information: https://github.com/open-mmlab/mmengine/blob/main/docs/en/tutorials/param_scheduler.md # noqa: E501
145
+ param_scheduler = [
146
+ dict(
147
+ type=LinearLR,
148
+ start_factor=1e-5,
149
+ by_epoch=True,
150
+ begin=0,
151
+ end=warmup_ratio * max_epochs,
152
+ convert_to_iter_based=True),
153
+ dict(
154
+ type=CosineAnnealingLR,
155
+ eta_min=0.0,
156
+ by_epoch=True,
157
+ begin=warmup_ratio * max_epochs,
158
+ end=max_epochs,
159
+ convert_to_iter_based=True)
160
+ ]
161
+
162
+ # train, val, test setting
163
+ train_cfg = dict(type=TrainLoop, max_epochs=max_epochs)
164
+
165
+ #######################################################################
166
+ # PART 5 Runtime #
167
+ #######################################################################
168
+ # Log the dialogue periodically during the training process, optional
169
+ custom_hooks = [
170
+ dict(type=DatasetInfoHook, tokenizer=tokenizer),
171
+ dict(
172
+ type=EvaluateChatHook,
173
+ tokenizer=tokenizer,
174
+ image_processor=image_processor,
175
+ every_n_iters=evaluation_freq,
176
+ evaluation_inputs=evaluation_inputs,
177
+ evaluation_images=evaluation_images,
178
+ system=SYSTEM,
179
+ prompt_template=prompt_template)
180
+ ]
181
+
182
+ # configure default hooks
183
+ default_hooks = dict(
184
+ # record the time of every iteration.
185
+ timer=dict(type=IterTimerHook),
186
+ # print log every 10 iterations.
187
+ logger=dict(type=LoggerHook, log_metric_by_epoch=False, interval=10),
188
+ # enable the parameter scheduler.
189
+ param_scheduler=dict(type=ParamSchedulerHook),
190
+ # save checkpoint per `save_steps`.
191
+ checkpoint=dict(
192
+ type=CheckpointHook,
193
+ by_epoch=False,
194
+ interval=save_steps,
195
+ max_keep_ckpts=save_total_limit),
196
+ # set sampler seed in distributed evrionment.
197
+ sampler_seed=dict(type=DistSamplerSeedHook),
198
+ )
199
+
200
+ # configure environment
201
+ env_cfg = dict(
202
+ # whether to enable cudnn benchmark
203
+ cudnn_benchmark=False,
204
+ # set multi process parameters
205
+ mp_cfg=dict(mp_start_method='fork', opencv_num_threads=0),
206
+ # set distributed parameters
207
+ dist_cfg=dict(backend='nccl'),
208
+ )
209
+
210
+ # set visualizer
211
+ from mmengine.visualization import Visualizer, TensorboardVisBackend
212
+ visualizer = dict(
213
+ type=Visualizer,
214
+ vis_backends=[dict(type=TensorboardVisBackend)]
215
+ )
216
+
217
+ # set log level
218
+ log_level = 'INFO'
219
+
220
+ # load from which checkpoint
221
+ load_from = None
222
+
223
+ # whether to resume training from the loaded checkpoint
224
+ resume = False
225
+
226
+ # Defaults to use random seed and disable `deterministic`
227
+ randomness = dict(seed=None, deterministic=False)
228
+
229
+ # set log processor
230
+ log_processor = dict(by_epoch=False)
lora_and_projector/llm_adapter/README.md ADDED
@@ -0,0 +1,204 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: peft
3
+ base_model: internlm/internlm2-chat-1_8b
4
+ ---
5
+
6
+ # Model Card for Model ID
7
+
8
+ <!-- Provide a quick summary of what the model is/does. -->
9
+
10
+
11
+
12
+ ## Model Details
13
+
14
+ ### Model Description
15
+
16
+ <!-- Provide a longer summary of what this model is. -->
17
+
18
+
19
+
20
+ - **Developed by:** [More Information Needed]
21
+ - **Funded by [optional]:** [More Information Needed]
22
+ - **Shared by [optional]:** [More Information Needed]
23
+ - **Model type:** [More Information Needed]
24
+ - **Language(s) (NLP):** [More Information Needed]
25
+ - **License:** [More Information Needed]
26
+ - **Finetuned from model [optional]:** [More Information Needed]
27
+
28
+ ### Model Sources [optional]
29
+
30
+ <!-- Provide the basic links for the model. -->
31
+
32
+ - **Repository:** [More Information Needed]
33
+ - **Paper [optional]:** [More Information Needed]
34
+ - **Demo [optional]:** [More Information Needed]
35
+
36
+ ## Uses
37
+
38
+ <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
39
+
40
+ ### Direct Use
41
+
42
+ <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
43
+
44
+ [More Information Needed]
45
+
46
+ ### Downstream Use [optional]
47
+
48
+ <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
49
+
50
+ [More Information Needed]
51
+
52
+ ### Out-of-Scope Use
53
+
54
+ <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
55
+
56
+ [More Information Needed]
57
+
58
+ ## Bias, Risks, and Limitations
59
+
60
+ <!-- This section is meant to convey both technical and sociotechnical limitations. -->
61
+
62
+ [More Information Needed]
63
+
64
+ ### Recommendations
65
+
66
+ <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
67
+
68
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
69
+
70
+ ## How to Get Started with the Model
71
+
72
+ Use the code below to get started with the model.
73
+
74
+ [More Information Needed]
75
+
76
+ ## Training Details
77
+
78
+ ### Training Data
79
+
80
+ <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
81
+
82
+ [More Information Needed]
83
+
84
+ ### Training Procedure
85
+
86
+ <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
87
+
88
+ #### Preprocessing [optional]
89
+
90
+ [More Information Needed]
91
+
92
+
93
+ #### Training Hyperparameters
94
+
95
+ - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
96
+
97
+ #### Speeds, Sizes, Times [optional]
98
+
99
+ <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
100
+
101
+ [More Information Needed]
102
+
103
+ ## Evaluation
104
+
105
+ <!-- This section describes the evaluation protocols and provides the results. -->
106
+
107
+ ### Testing Data, Factors & Metrics
108
+
109
+ #### Testing Data
110
+
111
+ <!-- This should link to a Dataset Card if possible. -->
112
+
113
+ [More Information Needed]
114
+
115
+ #### Factors
116
+
117
+ <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
118
+
119
+ [More Information Needed]
120
+
121
+ #### Metrics
122
+
123
+ <!-- These are the evaluation metrics being used, ideally with a description of why. -->
124
+
125
+ [More Information Needed]
126
+
127
+ ### Results
128
+
129
+ [More Information Needed]
130
+
131
+ #### Summary
132
+
133
+
134
+
135
+ ## Model Examination [optional]
136
+
137
+ <!-- Relevant interpretability work for the model goes here -->
138
+
139
+ [More Information Needed]
140
+
141
+ ## Environmental Impact
142
+
143
+ <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
144
+
145
+ Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
146
+
147
+ - **Hardware Type:** [More Information Needed]
148
+ - **Hours used:** [More Information Needed]
149
+ - **Cloud Provider:** [More Information Needed]
150
+ - **Compute Region:** [More Information Needed]
151
+ - **Carbon Emitted:** [More Information Needed]
152
+
153
+ ## Technical Specifications [optional]
154
+
155
+ ### Model Architecture and Objective
156
+
157
+ [More Information Needed]
158
+
159
+ ### Compute Infrastructure
160
+
161
+ [More Information Needed]
162
+
163
+ #### Hardware
164
+
165
+ [More Information Needed]
166
+
167
+ #### Software
168
+
169
+ [More Information Needed]
170
+
171
+ ## Citation [optional]
172
+
173
+ <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
174
+
175
+ **BibTeX:**
176
+
177
+ [More Information Needed]
178
+
179
+ **APA:**
180
+
181
+ [More Information Needed]
182
+
183
+ ## Glossary [optional]
184
+
185
+ <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
186
+
187
+ [More Information Needed]
188
+
189
+ ## More Information [optional]
190
+
191
+ [More Information Needed]
192
+
193
+ ## Model Card Authors [optional]
194
+
195
+ [More Information Needed]
196
+
197
+ ## Model Card Contact
198
+
199
+ [More Information Needed]
200
+
201
+
202
+ ### Framework versions
203
+
204
+ - PEFT 0.8.2
lora_and_projector/llm_adapter/adapter_config.json ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "alpha_pattern": {},
3
+ "auto_mapping": null,
4
+ "base_model_name_or_path": "internlm/internlm2-chat-1_8b",
5
+ "bias": "none",
6
+ "fan_in_fan_out": false,
7
+ "inference_mode": true,
8
+ "init_lora_weights": true,
9
+ "layers_pattern": null,
10
+ "layers_to_transform": null,
11
+ "loftq_config": {},
12
+ "lora_alpha": 256,
13
+ "lora_dropout": 0.05,
14
+ "megatron_config": null,
15
+ "megatron_core": "megatron.core",
16
+ "modules_to_save": null,
17
+ "peft_type": "LORA",
18
+ "r": 512,
19
+ "rank_pattern": {},
20
+ "revision": null,
21
+ "target_modules": [
22
+ "wqkv",
23
+ "w2",
24
+ "w1",
25
+ "w3",
26
+ "output",
27
+ "wo"
28
+ ],
29
+ "task_type": "CAUSAL_LM",
30
+ "use_rslora": false
31
+ }
lora_and_projector/llm_adapter/adapter_model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fbce6e30f0326fbb9507ace17588955706e386b217b72bd69bd3f29779626fdc
3
+ size 1103527968
lora_and_projector/projector/config.json ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "ProjectorModel"
4
+ ],
5
+ "auto_map": {
6
+ "AutoConfig": "configuration_projector.ProjectorConfig",
7
+ "AutoModel": "modeling_projector.ProjectorModel"
8
+ },
9
+ "bias": true,
10
+ "depth": 2,
11
+ "hidden_act": "gelu",
12
+ "llm_hidden_size": 2048,
13
+ "model_type": "projector",
14
+ "torch_dtype": "float32",
15
+ "transformers_version": "4.37.2",
16
+ "visual_hidden_size": 1024
17
+ }
lora_and_projector/projector/configuration_projector.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) OpenMMLab. All rights reserved.
2
+ from transformers import PretrainedConfig
3
+
4
+
5
+ class ProjectorConfig(PretrainedConfig):
6
+ model_type = 'projector'
7
+ _auto_class = 'AutoConfig'
8
+
9
+ def __init__(
10
+ self,
11
+ visual_hidden_size=4096,
12
+ llm_hidden_size=4096,
13
+ depth=2,
14
+ hidden_act='gelu',
15
+ bias=True,
16
+ **kwargs,
17
+ ):
18
+ self.visual_hidden_size = visual_hidden_size
19
+ self.llm_hidden_size = llm_hidden_size
20
+ self.depth = depth
21
+ self.hidden_act = hidden_act
22
+ self.bias = bias
23
+ super().__init__(**kwargs)
lora_and_projector/projector/model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7a6d0cd3071ecbe20435bcdb604b41cd16ba6b00146bc73083966b8478601b5e
3
+ size 25182568
lora_and_projector/projector/modeling_projector.py ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) OpenMMLab. All rights reserved.
2
+ import torch
3
+ import torch.nn as nn
4
+ from transformers import PreTrainedModel
5
+ from transformers.activations import ACT2FN
6
+
7
+ from .configuration_projector import ProjectorConfig
8
+
9
+
10
+ class ProjectorModel(PreTrainedModel):
11
+ _auto_class = 'AutoModel'
12
+ config_class = ProjectorConfig
13
+ base_model_prefix = 'model'
14
+ supports_gradient_checkpointing = True
15
+
16
+ def __init__(self, config: ProjectorConfig) -> None:
17
+ super().__init__(config)
18
+ self.gradient_checkpointing = False
19
+
20
+ modules = [
21
+ nn.Linear(
22
+ config.visual_hidden_size,
23
+ config.llm_hidden_size,
24
+ bias=config.bias)
25
+ ]
26
+ for _ in range(1, config.depth):
27
+ modules.append(ACT2FN[config.hidden_act])
28
+ modules.append(
29
+ nn.Linear(
30
+ config.llm_hidden_size,
31
+ config.llm_hidden_size,
32
+ bias=config.bias))
33
+ self.model = nn.Sequential(*modules)
34
+
35
+ def enable_input_require_grads(self):
36
+
37
+ def make_inputs_require_grad(module, input, output):
38
+ output.requires_grad_(True)
39
+
40
+ self.model.register_forward_hook(make_inputs_require_grad)
41
+
42
+ def _set_gradient_checkpointing(self, module, value=False):
43
+ if isinstance(module, ProjectorModel):
44
+ module.gradient_checkpointing = value
45
+
46
+ def forward(self, x):
47
+ if self.gradient_checkpointing and self.training:
48
+ layer_outputs = torch.utils.checkpoint.checkpoint(self.model, x)
49
+ else:
50
+ layer_outputs = self.model(x)
51
+ return layer_outputs
lora_and_projector/visual_encoder_adapter/README.md ADDED
@@ -0,0 +1,204 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: peft
3
+ base_model: openai/clip-vit-large-patch14-336
4
+ ---
5
+
6
+ # Model Card for Model ID
7
+
8
+ <!-- Provide a quick summary of what the model is/does. -->
9
+
10
+
11
+
12
+ ## Model Details
13
+
14
+ ### Model Description
15
+
16
+ <!-- Provide a longer summary of what this model is. -->
17
+
18
+
19
+
20
+ - **Developed by:** [More Information Needed]
21
+ - **Funded by [optional]:** [More Information Needed]
22
+ - **Shared by [optional]:** [More Information Needed]
23
+ - **Model type:** [More Information Needed]
24
+ - **Language(s) (NLP):** [More Information Needed]
25
+ - **License:** [More Information Needed]
26
+ - **Finetuned from model [optional]:** [More Information Needed]
27
+
28
+ ### Model Sources [optional]
29
+
30
+ <!-- Provide the basic links for the model. -->
31
+
32
+ - **Repository:** [More Information Needed]
33
+ - **Paper [optional]:** [More Information Needed]
34
+ - **Demo [optional]:** [More Information Needed]
35
+
36
+ ## Uses
37
+
38
+ <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
39
+
40
+ ### Direct Use
41
+
42
+ <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
43
+
44
+ [More Information Needed]
45
+
46
+ ### Downstream Use [optional]
47
+
48
+ <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
49
+
50
+ [More Information Needed]
51
+
52
+ ### Out-of-Scope Use
53
+
54
+ <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
55
+
56
+ [More Information Needed]
57
+
58
+ ## Bias, Risks, and Limitations
59
+
60
+ <!-- This section is meant to convey both technical and sociotechnical limitations. -->
61
+
62
+ [More Information Needed]
63
+
64
+ ### Recommendations
65
+
66
+ <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
67
+
68
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
69
+
70
+ ## How to Get Started with the Model
71
+
72
+ Use the code below to get started with the model.
73
+
74
+ [More Information Needed]
75
+
76
+ ## Training Details
77
+
78
+ ### Training Data
79
+
80
+ <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
81
+
82
+ [More Information Needed]
83
+
84
+ ### Training Procedure
85
+
86
+ <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
87
+
88
+ #### Preprocessing [optional]
89
+
90
+ [More Information Needed]
91
+
92
+
93
+ #### Training Hyperparameters
94
+
95
+ - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
96
+
97
+ #### Speeds, Sizes, Times [optional]
98
+
99
+ <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
100
+
101
+ [More Information Needed]
102
+
103
+ ## Evaluation
104
+
105
+ <!-- This section describes the evaluation protocols and provides the results. -->
106
+
107
+ ### Testing Data, Factors & Metrics
108
+
109
+ #### Testing Data
110
+
111
+ <!-- This should link to a Dataset Card if possible. -->
112
+
113
+ [More Information Needed]
114
+
115
+ #### Factors
116
+
117
+ <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
118
+
119
+ [More Information Needed]
120
+
121
+ #### Metrics
122
+
123
+ <!-- These are the evaluation metrics being used, ideally with a description of why. -->
124
+
125
+ [More Information Needed]
126
+
127
+ ### Results
128
+
129
+ [More Information Needed]
130
+
131
+ #### Summary
132
+
133
+
134
+
135
+ ## Model Examination [optional]
136
+
137
+ <!-- Relevant interpretability work for the model goes here -->
138
+
139
+ [More Information Needed]
140
+
141
+ ## Environmental Impact
142
+
143
+ <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
144
+
145
+ Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
146
+
147
+ - **Hardware Type:** [More Information Needed]
148
+ - **Hours used:** [More Information Needed]
149
+ - **Cloud Provider:** [More Information Needed]
150
+ - **Compute Region:** [More Information Needed]
151
+ - **Carbon Emitted:** [More Information Needed]
152
+
153
+ ## Technical Specifications [optional]
154
+
155
+ ### Model Architecture and Objective
156
+
157
+ [More Information Needed]
158
+
159
+ ### Compute Infrastructure
160
+
161
+ [More Information Needed]
162
+
163
+ #### Hardware
164
+
165
+ [More Information Needed]
166
+
167
+ #### Software
168
+
169
+ [More Information Needed]
170
+
171
+ ## Citation [optional]
172
+
173
+ <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
174
+
175
+ **BibTeX:**
176
+
177
+ [More Information Needed]
178
+
179
+ **APA:**
180
+
181
+ [More Information Needed]
182
+
183
+ ## Glossary [optional]
184
+
185
+ <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
186
+
187
+ [More Information Needed]
188
+
189
+ ## More Information [optional]
190
+
191
+ [More Information Needed]
192
+
193
+ ## Model Card Authors [optional]
194
+
195
+ [More Information Needed]
196
+
197
+ ## Model Card Contact
198
+
199
+ [More Information Needed]
200
+
201
+
202
+ ### Framework versions
203
+
204
+ - PEFT 0.8.2
lora_and_projector/visual_encoder_adapter/adapter_config.json ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "alpha_pattern": {},
3
+ "auto_mapping": {
4
+ "base_model_class": "CLIPVisionModel",
5
+ "parent_library": "transformers.models.clip.modeling_clip"
6
+ },
7
+ "base_model_name_or_path": "openai/clip-vit-large-patch14-336",
8
+ "bias": "none",
9
+ "fan_in_fan_out": false,
10
+ "inference_mode": true,
11
+ "init_lora_weights": true,
12
+ "layers_pattern": null,
13
+ "layers_to_transform": null,
14
+ "loftq_config": {},
15
+ "lora_alpha": 16,
16
+ "lora_dropout": 0.05,
17
+ "megatron_config": null,
18
+ "megatron_core": "megatron.core",
19
+ "modules_to_save": null,
20
+ "peft_type": "LORA",
21
+ "r": 64,
22
+ "rank_pattern": {},
23
+ "revision": null,
24
+ "target_modules": [
25
+ "out_proj",
26
+ "q_proj",
27
+ "v_proj",
28
+ "k_proj",
29
+ "fc1",
30
+ "fc2"
31
+ ],
32
+ "task_type": null,
33
+ "use_rslora": false
34
+ }
lora_and_projector/visual_encoder_adapter/adapter_model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a94696a6aa39226ecb69b31aaf14f33264c9d716056485e4a92a4d9880aa53ca
3
+ size 113288576
lora_and_projector/xtuner_config.py ADDED
@@ -0,0 +1,222 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ SYSTEM = ''
2
+ accumulative_counts = 3
3
+ batch_size = 12
4
+ betas = (
5
+ 0.9,
6
+ 0.999,
7
+ )
8
+ custom_hooks = [
9
+ dict(
10
+ tokenizer=dict(
11
+ padding_side='right',
12
+ pretrained_model_name_or_path='internlm/internlm2-chat-1_8b',
13
+ trust_remote_code=True,
14
+ type='transformers.AutoTokenizer.from_pretrained'),
15
+ type='xtuner.engine.hooks.DatasetInfoHook'),
16
+ dict(
17
+ evaluation_images='https://llava-vl.github.io/static/images/view.jpg',
18
+ evaluation_inputs=[
19
+ '请描述一下这张照片',
20
+ 'Please describe this picture',
21
+ ],
22
+ every_n_iters=500,
23
+ image_processor=dict(
24
+ pretrained_model_name_or_path='openai/clip-vit-large-patch14-336',
25
+ trust_remote_code=True,
26
+ type='transformers.CLIPImageProcessor.from_pretrained'),
27
+ prompt_template='xtuner.utils.PROMPT_TEMPLATE.internlm2_chat',
28
+ system='',
29
+ tokenizer=dict(
30
+ padding_side='right',
31
+ pretrained_model_name_or_path='internlm/internlm2-chat-1_8b',
32
+ trust_remote_code=True,
33
+ type='transformers.AutoTokenizer.from_pretrained'),
34
+ type='xtuner.engine.hooks.EvaluateChatHook'),
35
+ ]
36
+ data_path = './data/llava_data/LLaVA-Instruct-150K/llava_v1_5_mix665k.json'
37
+ data_root = './data/llava_data/'
38
+ dataloader_num_workers = 4
39
+ default_hooks = dict(
40
+ checkpoint=dict(
41
+ by_epoch=False,
42
+ interval=500,
43
+ max_keep_ckpts=2,
44
+ type='mmengine.hooks.CheckpointHook'),
45
+ logger=dict(
46
+ interval=10,
47
+ log_metric_by_epoch=False,
48
+ type='mmengine.hooks.LoggerHook'),
49
+ param_scheduler=dict(type='mmengine.hooks.ParamSchedulerHook'),
50
+ sampler_seed=dict(type='mmengine.hooks.DistSamplerSeedHook'),
51
+ timer=dict(type='mmengine.hooks.IterTimerHook'))
52
+ env_cfg = dict(
53
+ cudnn_benchmark=False,
54
+ dist_cfg=dict(backend='nccl'),
55
+ mp_cfg=dict(mp_start_method='fork', opencv_num_threads=0))
56
+ evaluation_freq = 500
57
+ evaluation_images = 'https://llava-vl.github.io/static/images/view.jpg'
58
+ evaluation_inputs = [
59
+ '请描述一下这张照片',
60
+ 'Please describe this picture',
61
+ ]
62
+ image_folder = './data/llava_data/llava_images'
63
+ image_processor = dict(
64
+ pretrained_model_name_or_path='openai/clip-vit-large-patch14-336',
65
+ trust_remote_code=True,
66
+ type='transformers.CLIPImageProcessor.from_pretrained')
67
+ launcher = 'pytorch'
68
+ llava_dataset = dict(
69
+ data_path='./data/llava_data/LLaVA-Instruct-150K/llava_v1_5_mix665k.json',
70
+ dataset_map_fn='xtuner.dataset.map_fns.llava_map_fn',
71
+ image_folder='./data/llava_data/llava_images',
72
+ image_processor=dict(
73
+ pretrained_model_name_or_path='openai/clip-vit-large-patch14-336',
74
+ trust_remote_code=True,
75
+ type='transformers.CLIPImageProcessor.from_pretrained'),
76
+ max_length=1472,
77
+ pad_image_to_square=True,
78
+ template_map_fn=dict(
79
+ template='xtuner.utils.PROMPT_TEMPLATE.internlm2_chat',
80
+ type='xtuner.dataset.map_fns.template_map_fn_factory'),
81
+ tokenizer=dict(
82
+ padding_side='right',
83
+ pretrained_model_name_or_path='internlm/internlm2-chat-1_8b',
84
+ trust_remote_code=True,
85
+ type='transformers.AutoTokenizer.from_pretrained'),
86
+ type='xtuner.dataset.LLaVADataset')
87
+ llm_name_or_path = 'internlm/internlm2-chat-1_8b'
88
+ load_from = None
89
+ log_level = 'INFO'
90
+ log_processor = dict(by_epoch=False)
91
+ lr = 0.0002
92
+ max_epochs = 1
93
+ max_length = 1472
94
+ max_norm = 1
95
+ model = dict(
96
+ freeze_llm=True,
97
+ freeze_visual_encoder=True,
98
+ llm=dict(
99
+ pretrained_model_name_or_path='internlm/internlm2-chat-1_8b',
100
+ quantization_config=dict(
101
+ bnb_4bit_compute_dtype='torch.float16',
102
+ bnb_4bit_quant_type='nf4',
103
+ bnb_4bit_use_double_quant=True,
104
+ llm_int8_has_fp16_weight=False,
105
+ llm_int8_threshold=6.0,
106
+ load_in_4bit=True,
107
+ load_in_8bit=False,
108
+ type='transformers.BitsAndBytesConfig'),
109
+ torch_dtype='torch.float16',
110
+ trust_remote_code=True,
111
+ type='transformers.AutoModelForCausalLM.from_pretrained'),
112
+ llm_lora=dict(
113
+ bias='none',
114
+ lora_alpha=256,
115
+ lora_dropout=0.05,
116
+ r=512,
117
+ task_type='CAUSAL_LM',
118
+ type='peft.LoraConfig'),
119
+ pretrained_pth=
120
+ './work_dirs/llava_internlm2_chat_1_8b_clip_vit_large_p14_336_e1_gpu1_pretrain/iter_13954.pth',
121
+ type='xtuner.model.LLaVAModel',
122
+ visual_encoder=dict(
123
+ pretrained_model_name_or_path='openai/clip-vit-large-patch14-336',
124
+ type='transformers.CLIPVisionModel.from_pretrained'),
125
+ visual_encoder_lora=dict(
126
+ bias='none',
127
+ lora_alpha=16,
128
+ lora_dropout=0.05,
129
+ r=64,
130
+ type='peft.LoraConfig'))
131
+ optim_type = 'torch.optim.AdamW'
132
+ optim_wrapper = dict(
133
+ optimizer=dict(
134
+ betas=(
135
+ 0.9,
136
+ 0.999,
137
+ ),
138
+ lr=0.0002,
139
+ type='torch.optim.AdamW',
140
+ weight_decay=0),
141
+ type='DeepSpeedOptimWrapper')
142
+ param_scheduler = [
143
+ dict(
144
+ begin=0,
145
+ by_epoch=True,
146
+ convert_to_iter_based=True,
147
+ end=0.03,
148
+ start_factor=1e-05,
149
+ type='mmengine.optim.LinearLR'),
150
+ dict(
151
+ begin=0.03,
152
+ by_epoch=True,
153
+ convert_to_iter_based=True,
154
+ end=1,
155
+ eta_min=0.0,
156
+ type='mmengine.optim.CosineAnnealingLR'),
157
+ ]
158
+ pretrained_pth = './work_dirs/llava_internlm2_chat_1_8b_clip_vit_large_p14_336_e1_gpu1_pretrain/iter_13954.pth'
159
+ prompt_template = 'xtuner.utils.PROMPT_TEMPLATE.internlm2_chat'
160
+ randomness = dict(deterministic=False, seed=None)
161
+ resume = False
162
+ runner_type = 'FlexibleRunner'
163
+ save_steps = 500
164
+ save_total_limit = 2
165
+ strategy = dict(
166
+ config=dict(
167
+ bf16=dict(enabled=True),
168
+ fp16=dict(enabled=False, initial_scale_power=16),
169
+ gradient_accumulation_steps='auto',
170
+ gradient_clipping='auto',
171
+ train_micro_batch_size_per_gpu='auto',
172
+ zero_allow_untested_optimizer=True,
173
+ zero_force_ds_cpu_optimizer=False,
174
+ zero_optimization=dict(overlap_comm=True, stage=2)),
175
+ exclude_frozen_parameters=True,
176
+ gradient_accumulation_steps=3,
177
+ gradient_clipping=1,
178
+ train_micro_batch_size_per_gpu=12,
179
+ type='xtuner.engine.DeepSpeedStrategy')
180
+ tokenizer = dict(
181
+ padding_side='right',
182
+ pretrained_model_name_or_path='internlm/internlm2-chat-1_8b',
183
+ trust_remote_code=True,
184
+ type='transformers.AutoTokenizer.from_pretrained')
185
+ train_cfg = dict(max_epochs=1, type='xtuner.engine.runner.TrainLoop')
186
+ train_dataloader = dict(
187
+ batch_size=12,
188
+ collate_fn=dict(type='xtuner.dataset.collate_fns.default_collate_fn'),
189
+ dataset=dict(
190
+ data_path=
191
+ './data/llava_data/LLaVA-Instruct-150K/llava_v1_5_mix665k.json',
192
+ dataset_map_fn='xtuner.dataset.map_fns.llava_map_fn',
193
+ image_folder='./data/llava_data/llava_images',
194
+ image_processor=dict(
195
+ pretrained_model_name_or_path='openai/clip-vit-large-patch14-336',
196
+ trust_remote_code=True,
197
+ type='transformers.CLIPImageProcessor.from_pretrained'),
198
+ max_length=1472,
199
+ pad_image_to_square=True,
200
+ template_map_fn=dict(
201
+ template='xtuner.utils.PROMPT_TEMPLATE.internlm2_chat',
202
+ type='xtuner.dataset.map_fns.template_map_fn_factory'),
203
+ tokenizer=dict(
204
+ padding_side='right',
205
+ pretrained_model_name_or_path='internlm/internlm2-chat-1_8b',
206
+ trust_remote_code=True,
207
+ type='transformers.AutoTokenizer.from_pretrained'),
208
+ type='xtuner.dataset.LLaVADataset'),
209
+ num_workers=4,
210
+ sampler=dict(
211
+ length_property='modality_length',
212
+ per_device_batch_size=36,
213
+ type='xtuner.dataset.samplers.LengthGroupedSampler'))
214
+ visual_encoder_name_or_path = 'openai/clip-vit-large-patch14-336'
215
+ visualizer = dict(
216
+ type='mmengine.visualization.Visualizer',
217
+ vis_backends=[
218
+ dict(type='mmengine.visualization.TensorboardVisBackend'),
219
+ ])
220
+ warmup_ratio = 0.03
221
+ weight_decay = 0
222
+ work_dir = './work_dirs/llava_internlm2_chat_1_8b_clip_vit_large_p14_336_e1_gpu4_finetune'
mmbench_results/ccbench/args.json ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_name_or_path": "internlm/internlm2-chat-1_8b",
3
+ "data_path": "./CCBench.tsv",
4
+ "work_dir": "./mmbench_results",
5
+ "llava": "./my_lora_and_projector",
6
+ "visual_encoder": "openai/CLIP-ViT-Large-patch14-336",
7
+ "visual_select_layer": -2,
8
+ "prompt_template": "internlm2_chat",
9
+ "stop_words": [
10
+ "<|im_end|>"
11
+ ],
12
+ "torch_dtype": "fp16",
13
+ "bits": null,
14
+ "bot_name": "BOT",
15
+ "offload_folder": null,
16
+ "max_new_tokens": 100,
17
+ "seed": 0,
18
+ "launcher": "pytorch"
19
+ }
mmbench_results/ccbench/mmbench_result.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "Average": 0.35294117647058826,
3
+ "Calligraphy Painting": 0.2982456140350877,
4
+ "Cultural Relic": 0.38144329896907214,
5
+ "Food & Clothes": 0.3652173913043478,
6
+ "Historical Figure": 0.02857142857142857,
7
+ "Scenery & Building": 0.3263157894736842,
8
+ "Sketch Reasoning": 0.6,
9
+ "Traditional Show": 0.3787878787878788
10
+ }
mmbench_results/ccbench/mmbench_result.xlsx ADDED
Binary file (115 kB). View file
 
mmbench_results/dev_cn/args.json ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_name_or_path": "internlm/internlm2-chat-1_8b",
3
+ "data_path": "./MMBench_DEV_CN.tsv",
4
+ "work_dir": "./mmbench_results",
5
+ "llava": "./my_lora_and_projector",
6
+ "visual_encoder": "openai/CLIP-ViT-Large-patch14-336",
7
+ "visual_select_layer": -2,
8
+ "prompt_template": "internlm2_chat",
9
+ "stop_words": [
10
+ "<|im_end|>"
11
+ ],
12
+ "torch_dtype": "fp16",
13
+ "bits": null,
14
+ "bot_name": "BOT",
15
+ "offload_folder": null,
16
+ "max_new_tokens": 100,
17
+ "seed": 0,
18
+ "launcher": "pytorch"
19
+ }
mmbench_results/dev_cn/mmbench_result.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "Average": 0.6168384879725086,
3
+ "AR": 0.6834170854271356,
4
+ "CP": 0.7398648648648649,
5
+ "FP-C": 0.5384615384615384,
6
+ "FP-S": 0.5836177474402731,
7
+ "LR": 0.4152542372881356,
8
+ "RR": 0.5739130434782609
9
+ }
mmbench_results/dev_cn/mmbench_result.xlsx ADDED
Binary file (429 kB). View file
 
mmbench_results/dev_en/args.json ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_name_or_path": "internlm/internlm2-chat-1_8b",
3
+ "data_path": "./MMBench_DEV_EN.tsv",
4
+ "work_dir": "./mmbench_results",
5
+ "llava": "./my_lora_and_projector",
6
+ "visual_encoder": "openai/CLIP-ViT-Large-patch14-336",
7
+ "visual_select_layer": -2,
8
+ "prompt_template": "internlm2_chat",
9
+ "stop_words": [
10
+ "<|im_end|>"
11
+ ],
12
+ "torch_dtype": "fp16",
13
+ "bits": null,
14
+ "bot_name": "BOT",
15
+ "offload_folder": null,
16
+ "max_new_tokens": 100,
17
+ "seed": 0,
18
+ "launcher": "pytorch"
19
+ }
mmbench_results/dev_en/mmbench_result.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "Average": 0.6305841924398625,
3
+ "AR": 0.6884422110552764,
4
+ "CP": 0.75,
5
+ "FP-C": 0.5804195804195804,
6
+ "FP-S": 0.6075085324232082,
7
+ "LR": 0.3728813559322034,
8
+ "RR": 0.6086956521739131
9
+ }
mmbench_results/dev_en/mmbench_result.xlsx ADDED
Binary file (366 kB). View file
 
mmbench_results/test_cn/args.json ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_name_or_path": "internlm/internlm2-chat-1_8b",
3
+ "data_path": "./MMBench_TEST_CN.tsv",
4
+ "work_dir": "./mmbench_results",
5
+ "llava": "./my_lora_and_projector",
6
+ "visual_encoder": "openai/CLIP-ViT-Large-patch14-336",
7
+ "visual_select_layer": -2,
8
+ "prompt_template": "internlm2_chat",
9
+ "stop_words": [
10
+ "<|im_end|>"
11
+ ],
12
+ "torch_dtype": "fp16",
13
+ "bits": null,
14
+ "bot_name": "BOT",
15
+ "offload_folder": null,
16
+ "max_new_tokens": 100,
17
+ "seed": 0,
18
+ "launcher": "pytorch"
19
+ }
mmbench_results/test_cn/mmbench_result.xlsx ADDED
Binary file (610 kB). View file
 
mmbench_results/test_en/args.json ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_name_or_path": "internlm/internlm2-chat-1_8b",
3
+ "data_path": "./MMBench_TEST_EN.tsv",
4
+ "work_dir": "./mmbench_results",
5
+ "llava": "./my_lora_and_projector",
6
+ "visual_encoder": "openai/CLIP-ViT-Large-patch14-336",
7
+ "visual_select_layer": -2,
8
+ "prompt_template": "internlm2_chat",
9
+ "stop_words": [
10
+ "<|im_end|>"
11
+ ],
12
+ "torch_dtype": "fp16",
13
+ "bits": null,
14
+ "bot_name": "BOT",
15
+ "offload_folder": null,
16
+ "max_new_tokens": 100,
17
+ "seed": 0,
18
+ "launcher": "pytorch"
19
+ }
mmbench_results/test_en/mmbench_result.xlsx ADDED
Binary file (547 kB). View file