xinke-wang commited on
Commit
7da33d3
·
verified ·
1 Parent(s): 1b64530

ModaVerse-7b-v0

Browse files
added_tokens.json ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "</Media>": 32001,
3
+ "<Media>": 32000,
4
+ "[AUDIO]": 32004,
5
+ "[IMAGE]": 32003,
6
+ "[TEXT]": 32002,
7
+ "[VIDEO]": 32005
8
+ }
config.json ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": ".checkpoints/7b_v0",
3
+ "architectures": [
4
+ "LlamaForCausalLM"
5
+ ],
6
+ "attention_bias": false,
7
+ "attention_dropout": 0.0,
8
+ "bos_token_id": 1,
9
+ "eos_token_id": 2,
10
+ "hidden_act": "silu",
11
+ "hidden_size": 4096,
12
+ "initializer_range": 0.02,
13
+ "intermediate_size": 11008,
14
+ "max_position_embeddings": 2048,
15
+ "model_type": "llama",
16
+ "num_attention_heads": 32,
17
+ "num_hidden_layers": 32,
18
+ "num_key_value_heads": 32,
19
+ "pad_token_id": 0,
20
+ "pretraining_tp": 1,
21
+ "rms_norm_eps": 1e-06,
22
+ "rope_scaling": null,
23
+ "rope_theta": 10000.0,
24
+ "tie_word_embeddings": false,
25
+ "torch_dtype": "float16",
26
+ "transformers_version": "4.39.2",
27
+ "use_cache": true,
28
+ "vocab_size": 32006
29
+ }
config.py ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import List
2
+
3
+ import torch
4
+ from peft import LoraConfig, TaskType
5
+ from transformers import StoppingCriteria, StoppingCriteriaList
6
+
7
+
8
+ class StoppingCriteriaSub(StoppingCriteria):
9
+
10
+ def __init__(self, stops: List = None, encounters: int = 1):
11
+ super().__init__()
12
+ self.stops = stops
13
+ self.ENCOUNTERS = encounters
14
+
15
+ def __call__(self, input_ids: torch.LongTensor, scores: torch.FloatTensor):
16
+ stop_count = 0
17
+ for stop in self.stops:
18
+ _stop = torch.tensor(stop).to(input_ids[0].device)
19
+ indices = torch.where(_stop[0] == input_ids)
20
+ for i in indices:
21
+ if len(i) > 0:
22
+ if torch.all(input_ids[0][i:i + len(_stop)] == _stop):
23
+ stop_count += 1
24
+ if stop_count >= self.ENCOUNTERS:
25
+ return True
26
+ return False
27
+
28
+
29
+ prompt_configs = dict(path='assets/prompts/prompt_template.txt',
30
+ media_placeholder='{media}',
31
+ instruction_placeholder='{instruction}')
32
+
33
+ model_configs = dict(
34
+ name='ModaVerse-7b',
35
+ imagebind=dict(hidden_size=1024),
36
+ foundation_llm=dict(type='vicuna-7b', checkpoint='.checkpoints/7b_v0'),
37
+ modaverse=dict(
38
+ max_length=512,
39
+ modality_begin_token='<Media>',
40
+ modality_end_token='</Media>',
41
+ modality_flags=['[TEXT]', '[IMAGE]', '[AUDIO]', '[VIDEO]'],
42
+ target_padding=-100,
43
+ top_p=0.01,
44
+ temperature=1,
45
+ max_new_tokens=246,
46
+ do_sample=True,
47
+ use_cache=True,
48
+ stopping_token=835,
49
+ stopping_criteria=StoppingCriteriaList(
50
+ [StoppingCriteriaSub(stops=[[835]], encounters=1)], ),
51
+ generator=dict(
52
+ image_diffuser=dict(
53
+ type='stable_diffusion',
54
+ # preload=False,
55
+ cfgs=dict(model='runwayml/stable-diffusion-v1-5')),
56
+ video_diffuser=dict(
57
+ type='damo_vilab',
58
+ # preload=False,
59
+ cfgs=dict(model='damo-vilab/text-to-video-ms-1.7b')),
60
+ audio_diffuser=dict(type='audio_ldm',
61
+ cfgs=dict(model='cvssp/audioldm-l-full')),
62
+ ),
63
+ ))
64
+
65
+ training_configs = dict(
66
+ lora_config=LoraConfig(
67
+ task_type=TaskType.CAUSAL_LM,
68
+ inference_mode=False,
69
+ r=32,
70
+ lora_alpha=32,
71
+ lora_dropout=0.1,
72
+ target_modules=['q_proj', 'k_proj', 'v_proj', 'o_proj']),
73
+ deepspeed_cfg=dict(path='configs/dscfg.json', backend='nccl'),
74
+ saving_root='./experiments',
75
+ epochs=1,
76
+ warmup_rate=0.1,
77
+ force_training_layers=['embed_tokens.weight', 'lm_head.weight'],
78
+ report_backend=dict(type='wandb', iterval=10),
79
+ print_prediction=dict(turn_on=True, interval=1000),
80
+ checkpointer=dict(type='iteration', interval=5000))
81
+
82
+ dataset_configs = dict(train=dict(instruction_path='dataset/instructions.json',
83
+ media_root='dataset/'))
pytorch_model.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3ce807340b62e3622cf1e76a2a975ec5388b892be26dae52ecac1b4219179796
3
+ size 599942525
special_tokens_map.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": {
3
+ "content": "<s>",
4
+ "lstrip": false,
5
+ "normalized": true,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "eos_token": {
10
+ "content": "</s>",
11
+ "lstrip": false,
12
+ "normalized": true,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "pad_token": "</s>",
17
+ "unk_token": {
18
+ "content": "<unk>",
19
+ "lstrip": false,
20
+ "normalized": true,
21
+ "rstrip": false,
22
+ "single_word": false
23
+ }
24
+ }
tokenizer.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9e556afd44213b6bd1be2b850ebbbd98f5481437a8021afaf58ee7fb1818d347
3
+ size 499723
tokenizer_config.json ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_bos_token": true,
3
+ "add_eos_token": false,
4
+ "add_prefix_space": true,
5
+ "added_tokens_decoder": {
6
+ "0": {
7
+ "content": "<unk>",
8
+ "lstrip": false,
9
+ "normalized": true,
10
+ "rstrip": false,
11
+ "single_word": false,
12
+ "special": true
13
+ },
14
+ "1": {
15
+ "content": "<s>",
16
+ "lstrip": false,
17
+ "normalized": true,
18
+ "rstrip": false,
19
+ "single_word": false,
20
+ "special": true
21
+ },
22
+ "2": {
23
+ "content": "</s>",
24
+ "lstrip": false,
25
+ "normalized": true,
26
+ "rstrip": false,
27
+ "single_word": false,
28
+ "special": true
29
+ },
30
+ "32000": {
31
+ "content": "<Media>",
32
+ "lstrip": false,
33
+ "normalized": true,
34
+ "rstrip": false,
35
+ "single_word": false,
36
+ "special": false
37
+ },
38
+ "32001": {
39
+ "content": "</Media>",
40
+ "lstrip": false,
41
+ "normalized": true,
42
+ "rstrip": false,
43
+ "single_word": false,
44
+ "special": false
45
+ },
46
+ "32002": {
47
+ "content": "[TEXT]",
48
+ "lstrip": false,
49
+ "normalized": true,
50
+ "rstrip": false,
51
+ "single_word": false,
52
+ "special": false
53
+ },
54
+ "32003": {
55
+ "content": "[IMAGE]",
56
+ "lstrip": false,
57
+ "normalized": true,
58
+ "rstrip": false,
59
+ "single_word": false,
60
+ "special": false
61
+ },
62
+ "32004": {
63
+ "content": "[AUDIO]",
64
+ "lstrip": false,
65
+ "normalized": true,
66
+ "rstrip": false,
67
+ "single_word": false,
68
+ "special": false
69
+ },
70
+ "32005": {
71
+ "content": "[VIDEO]",
72
+ "lstrip": false,
73
+ "normalized": true,
74
+ "rstrip": false,
75
+ "single_word": false,
76
+ "special": false
77
+ }
78
+ },
79
+ "bos_token": "<s>",
80
+ "clean_up_tokenization_spaces": false,
81
+ "eos_token": "</s>",
82
+ "legacy": true,
83
+ "model_max_length": 1000000000000000019884624838656,
84
+ "pad_token": "</s>",
85
+ "sp_model_kwargs": {},
86
+ "spaces_between_special_tokens": false,
87
+ "tokenizer_class": "LlamaTokenizer",
88
+ "unk_token": "<unk>",
89
+ "use_default_system_prompt": false
90
+ }