Upload folder using huggingface_hub
Browse files- config.json +43 -0
- generation_config.json +7 -0
- merges.txt +0 -0
- model.safetensors +3 -0
- optimizer.pt +3 -0
- rng_state.pth +3 -0
- scheduler.pt +3 -0
- special_tokens_map.json +28 -0
- tokenizer.json +0 -0
- tokenizer_config.json +155 -0
- trainer_state.json +712 -0
- training_args.bin +3 -0
- ultravox_config.py +170 -0
- ultravox_model.py +723 -0
- vocab.json +0 -0
config.json
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"architectures": [
|
3 |
+
"UltravoxModel"
|
4 |
+
],
|
5 |
+
"audio_latency_block_size": null,
|
6 |
+
"audio_model_id": "openai/whisper-large-v3-turbo",
|
7 |
+
"audio_model_lora_config": {
|
8 |
+
"lora_alpha": 8,
|
9 |
+
"r": 0,
|
10 |
+
"target_modules": [
|
11 |
+
"k_proj",
|
12 |
+
"q_proj",
|
13 |
+
"linear_k",
|
14 |
+
"linear_q"
|
15 |
+
]
|
16 |
+
},
|
17 |
+
"auto_map": {
|
18 |
+
"AutoConfig": "ultravox_config.UltravoxConfig",
|
19 |
+
"AutoModel": "ultravox_model.UltravoxModel"
|
20 |
+
},
|
21 |
+
"hidden_size": 4096,
|
22 |
+
"ignore_index": -100,
|
23 |
+
"initializer_range": 0.02,
|
24 |
+
"model_type": "ultravox",
|
25 |
+
"norm_init": 0.4,
|
26 |
+
"pad_token_id": 2,
|
27 |
+
"projector_act": "swiglu",
|
28 |
+
"stack_factor": 8,
|
29 |
+
"text_model_id": "HuggingFaceTB/SmolLM2-1.7B-Instruct",
|
30 |
+
"text_model_lora_config": {
|
31 |
+
"lora_alpha": 8,
|
32 |
+
"r": 0,
|
33 |
+
"target_modules": [
|
34 |
+
"k_proj",
|
35 |
+
"q_proj",
|
36 |
+
"linear_k",
|
37 |
+
"linear_q"
|
38 |
+
]
|
39 |
+
},
|
40 |
+
"torch_dtype": "bfloat16",
|
41 |
+
"transformers_version": "4.47.0",
|
42 |
+
"vocab_size": 49152
|
43 |
+
}
|
generation_config.json
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_from_model_config": true,
|
3 |
+
"bos_token_id": 1,
|
4 |
+
"eos_token_id": 2,
|
5 |
+
"pad_token_id": 2,
|
6 |
+
"transformers_version": "4.47.0"
|
7 |
+
}
|
merges.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|
model.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:a8e93b03d2e83320dcc9d1bcabea1d7ce48834a4ac10c87c7e20b90c7f629c98
|
3 |
+
size 92299736
|
optimizer.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ca2a84237b754b634b8f915b57b07e69cdd191cb37d1823838e225178202efab
|
3 |
+
size 184602962
|
rng_state.pth
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:171c449d4b396f9127e9ede85b442294e3914ded97fe428a0e1968cffff78f1b
|
3 |
+
size 14244
|
scheduler.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:14976c1b3dd2b157698f792725a91270a736615d07a5dd5eae32d2ba4a41d313
|
3 |
+
size 1064
|
special_tokens_map.json
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"additional_special_tokens": [
|
3 |
+
"<|im_start|>",
|
4 |
+
"<|im_end|>"
|
5 |
+
],
|
6 |
+
"bos_token": {
|
7 |
+
"content": "<|im_start|>",
|
8 |
+
"lstrip": false,
|
9 |
+
"normalized": false,
|
10 |
+
"rstrip": false,
|
11 |
+
"single_word": false
|
12 |
+
},
|
13 |
+
"eos_token": {
|
14 |
+
"content": "<|im_end|>",
|
15 |
+
"lstrip": false,
|
16 |
+
"normalized": false,
|
17 |
+
"rstrip": false,
|
18 |
+
"single_word": false
|
19 |
+
},
|
20 |
+
"pad_token": "<|im_end|>",
|
21 |
+
"unk_token": {
|
22 |
+
"content": "<|endoftext|>",
|
23 |
+
"lstrip": false,
|
24 |
+
"normalized": false,
|
25 |
+
"rstrip": false,
|
26 |
+
"single_word": false
|
27 |
+
}
|
28 |
+
}
|
tokenizer.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
tokenizer_config.json
ADDED
@@ -0,0 +1,155 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"add_prefix_space": false,
|
3 |
+
"added_tokens_decoder": {
|
4 |
+
"0": {
|
5 |
+
"content": "<|endoftext|>",
|
6 |
+
"lstrip": false,
|
7 |
+
"normalized": false,
|
8 |
+
"rstrip": false,
|
9 |
+
"single_word": false,
|
10 |
+
"special": true
|
11 |
+
},
|
12 |
+
"1": {
|
13 |
+
"content": "<|im_start|>",
|
14 |
+
"lstrip": false,
|
15 |
+
"normalized": false,
|
16 |
+
"rstrip": false,
|
17 |
+
"single_word": false,
|
18 |
+
"special": true
|
19 |
+
},
|
20 |
+
"2": {
|
21 |
+
"content": "<|im_end|>",
|
22 |
+
"lstrip": false,
|
23 |
+
"normalized": false,
|
24 |
+
"rstrip": false,
|
25 |
+
"single_word": false,
|
26 |
+
"special": true
|
27 |
+
},
|
28 |
+
"3": {
|
29 |
+
"content": "<repo_name>",
|
30 |
+
"lstrip": false,
|
31 |
+
"normalized": false,
|
32 |
+
"rstrip": false,
|
33 |
+
"single_word": false,
|
34 |
+
"special": true
|
35 |
+
},
|
36 |
+
"4": {
|
37 |
+
"content": "<reponame>",
|
38 |
+
"lstrip": false,
|
39 |
+
"normalized": false,
|
40 |
+
"rstrip": false,
|
41 |
+
"single_word": false,
|
42 |
+
"special": true
|
43 |
+
},
|
44 |
+
"5": {
|
45 |
+
"content": "<file_sep>",
|
46 |
+
"lstrip": false,
|
47 |
+
"normalized": false,
|
48 |
+
"rstrip": false,
|
49 |
+
"single_word": false,
|
50 |
+
"special": true
|
51 |
+
},
|
52 |
+
"6": {
|
53 |
+
"content": "<filename>",
|
54 |
+
"lstrip": false,
|
55 |
+
"normalized": false,
|
56 |
+
"rstrip": false,
|
57 |
+
"single_word": false,
|
58 |
+
"special": true
|
59 |
+
},
|
60 |
+
"7": {
|
61 |
+
"content": "<gh_stars>",
|
62 |
+
"lstrip": false,
|
63 |
+
"normalized": false,
|
64 |
+
"rstrip": false,
|
65 |
+
"single_word": false,
|
66 |
+
"special": true
|
67 |
+
},
|
68 |
+
"8": {
|
69 |
+
"content": "<issue_start>",
|
70 |
+
"lstrip": false,
|
71 |
+
"normalized": false,
|
72 |
+
"rstrip": false,
|
73 |
+
"single_word": false,
|
74 |
+
"special": true
|
75 |
+
},
|
76 |
+
"9": {
|
77 |
+
"content": "<issue_comment>",
|
78 |
+
"lstrip": false,
|
79 |
+
"normalized": false,
|
80 |
+
"rstrip": false,
|
81 |
+
"single_word": false,
|
82 |
+
"special": true
|
83 |
+
},
|
84 |
+
"10": {
|
85 |
+
"content": "<issue_closed>",
|
86 |
+
"lstrip": false,
|
87 |
+
"normalized": false,
|
88 |
+
"rstrip": false,
|
89 |
+
"single_word": false,
|
90 |
+
"special": true
|
91 |
+
},
|
92 |
+
"11": {
|
93 |
+
"content": "<jupyter_start>",
|
94 |
+
"lstrip": false,
|
95 |
+
"normalized": false,
|
96 |
+
"rstrip": false,
|
97 |
+
"single_word": false,
|
98 |
+
"special": true
|
99 |
+
},
|
100 |
+
"12": {
|
101 |
+
"content": "<jupyter_text>",
|
102 |
+
"lstrip": false,
|
103 |
+
"normalized": false,
|
104 |
+
"rstrip": false,
|
105 |
+
"single_word": false,
|
106 |
+
"special": true
|
107 |
+
},
|
108 |
+
"13": {
|
109 |
+
"content": "<jupyter_code>",
|
110 |
+
"lstrip": false,
|
111 |
+
"normalized": false,
|
112 |
+
"rstrip": false,
|
113 |
+
"single_word": false,
|
114 |
+
"special": true
|
115 |
+
},
|
116 |
+
"14": {
|
117 |
+
"content": "<jupyter_output>",
|
118 |
+
"lstrip": false,
|
119 |
+
"normalized": false,
|
120 |
+
"rstrip": false,
|
121 |
+
"single_word": false,
|
122 |
+
"special": true
|
123 |
+
},
|
124 |
+
"15": {
|
125 |
+
"content": "<jupyter_script>",
|
126 |
+
"lstrip": false,
|
127 |
+
"normalized": false,
|
128 |
+
"rstrip": false,
|
129 |
+
"single_word": false,
|
130 |
+
"special": true
|
131 |
+
},
|
132 |
+
"16": {
|
133 |
+
"content": "<empty_output>",
|
134 |
+
"lstrip": false,
|
135 |
+
"normalized": false,
|
136 |
+
"rstrip": false,
|
137 |
+
"single_word": false,
|
138 |
+
"special": true
|
139 |
+
}
|
140 |
+
},
|
141 |
+
"additional_special_tokens": [
|
142 |
+
"<|im_start|>",
|
143 |
+
"<|im_end|>"
|
144 |
+
],
|
145 |
+
"bos_token": "<|im_start|>",
|
146 |
+
"chat_template": "{% for message in messages %}{% if loop.first and messages[0]['role'] != 'system' %}{{ '<|im_start|>system\nYou are a helpful AI assistant named SmolLM, trained by Hugging Face<|im_end|>\n' }}{% endif %}{{'<|im_start|>' + message['role'] + '\n' + message['content'] + '<|im_end|>' + '\n'}}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>assistant\n' }}{% endif %}",
|
147 |
+
"clean_up_tokenization_spaces": false,
|
148 |
+
"eos_token": "<|im_end|>",
|
149 |
+
"extra_special_tokens": {},
|
150 |
+
"model_max_length": 8192,
|
151 |
+
"pad_token": "<|im_end|>",
|
152 |
+
"tokenizer_class": "GPT2Tokenizer",
|
153 |
+
"unk_token": "<|endoftext|>",
|
154 |
+
"vocab_size": 49152
|
155 |
+
}
|
trainer_state.json
ADDED
@@ -0,0 +1,712 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"best_metric": null,
|
3 |
+
"best_model_checkpoint": null,
|
4 |
+
"epoch": 0.49996528018887576,
|
5 |
+
"eval_steps": 1000,
|
6 |
+
"global_step": 7200,
|
7 |
+
"is_hyper_param_search": false,
|
8 |
+
"is_local_process_zero": true,
|
9 |
+
"is_world_process_zero": true,
|
10 |
+
"log_history": [
|
11 |
+
{
|
12 |
+
"epoch": 6.943962224845496e-05,
|
13 |
+
"grad_norm": 9.8125,
|
14 |
+
"learning_rate": 2e-06,
|
15 |
+
"loss": 0.7188,
|
16 |
+
"step": 1
|
17 |
+
},
|
18 |
+
{
|
19 |
+
"epoch": 0.006943962224845497,
|
20 |
+
"grad_norm": 0.1376953125,
|
21 |
+
"learning_rate": 0.0002,
|
22 |
+
"loss": 0.3907,
|
23 |
+
"step": 100
|
24 |
+
},
|
25 |
+
{
|
26 |
+
"epoch": 0.013887924449690994,
|
27 |
+
"grad_norm": 0.0849609375,
|
28 |
+
"learning_rate": 0.0004,
|
29 |
+
"loss": 0.2341,
|
30 |
+
"step": 200
|
31 |
+
},
|
32 |
+
{
|
33 |
+
"epoch": 0.02083188667453649,
|
34 |
+
"grad_norm": 0.146484375,
|
35 |
+
"learning_rate": 0.0006,
|
36 |
+
"loss": 0.2181,
|
37 |
+
"step": 300
|
38 |
+
},
|
39 |
+
{
|
40 |
+
"epoch": 0.027775848899381988,
|
41 |
+
"grad_norm": 0.10546875,
|
42 |
+
"learning_rate": 0.0008,
|
43 |
+
"loss": 0.197,
|
44 |
+
"step": 400
|
45 |
+
},
|
46 |
+
{
|
47 |
+
"epoch": 0.034719811124227486,
|
48 |
+
"grad_norm": 0.11376953125,
|
49 |
+
"learning_rate": 0.001,
|
50 |
+
"loss": 0.1695,
|
51 |
+
"step": 500
|
52 |
+
},
|
53 |
+
{
|
54 |
+
"epoch": 0.04166377334907298,
|
55 |
+
"grad_norm": 0.0849609375,
|
56 |
+
"learning_rate": 0.0012,
|
57 |
+
"loss": 0.14,
|
58 |
+
"step": 600
|
59 |
+
},
|
60 |
+
{
|
61 |
+
"epoch": 0.04860773557391848,
|
62 |
+
"grad_norm": 0.078125,
|
63 |
+
"learning_rate": 0.0014,
|
64 |
+
"loss": 0.1231,
|
65 |
+
"step": 700
|
66 |
+
},
|
67 |
+
{
|
68 |
+
"epoch": 0.055551697798763976,
|
69 |
+
"grad_norm": 0.0712890625,
|
70 |
+
"learning_rate": 0.0016,
|
71 |
+
"loss": 0.1141,
|
72 |
+
"step": 800
|
73 |
+
},
|
74 |
+
{
|
75 |
+
"epoch": 0.06249566002360947,
|
76 |
+
"grad_norm": 0.06298828125,
|
77 |
+
"learning_rate": 0.0018000000000000002,
|
78 |
+
"loss": 0.1077,
|
79 |
+
"step": 900
|
80 |
+
},
|
81 |
+
{
|
82 |
+
"epoch": 0.06943962224845497,
|
83 |
+
"grad_norm": 0.0615234375,
|
84 |
+
"learning_rate": 0.002,
|
85 |
+
"loss": 0.1045,
|
86 |
+
"step": 1000
|
87 |
+
},
|
88 |
+
{
|
89 |
+
"epoch": 0.06943962224845497,
|
90 |
+
"eval_covost2-en-de_loss": 1.4858413934707642,
|
91 |
+
"eval_covost2-en-de_runtime": 32.1589,
|
92 |
+
"eval_covost2-en-de_samples_per_second": 1.99,
|
93 |
+
"eval_covost2-en-de_steps_per_second": 0.062,
|
94 |
+
"step": 1000
|
95 |
+
},
|
96 |
+
{
|
97 |
+
"epoch": 0.06943962224845497,
|
98 |
+
"eval_covost2-zh-en_loss": 2.7152516841888428,
|
99 |
+
"eval_covost2-zh-en_runtime": 31.3842,
|
100 |
+
"eval_covost2-zh-en_samples_per_second": 2.039,
|
101 |
+
"eval_covost2-zh-en_steps_per_second": 0.064,
|
102 |
+
"step": 1000
|
103 |
+
},
|
104 |
+
{
|
105 |
+
"epoch": 0.06943962224845497,
|
106 |
+
"eval_peoplespeech-clean-transcription_loss": 2.0398874282836914,
|
107 |
+
"eval_peoplespeech-clean-transcription_runtime": 32.088,
|
108 |
+
"eval_peoplespeech-clean-transcription_samples_per_second": 1.995,
|
109 |
+
"eval_peoplespeech-clean-transcription_steps_per_second": 0.062,
|
110 |
+
"step": 1000
|
111 |
+
},
|
112 |
+
{
|
113 |
+
"epoch": 0.07638358447330046,
|
114 |
+
"grad_norm": 0.053955078125,
|
115 |
+
"learning_rate": 0.001999725185109816,
|
116 |
+
"loss": 0.101,
|
117 |
+
"step": 1100
|
118 |
+
},
|
119 |
+
{
|
120 |
+
"epoch": 0.08332754669814596,
|
121 |
+
"grad_norm": 0.0517578125,
|
122 |
+
"learning_rate": 0.0019989008914857113,
|
123 |
+
"loss": 0.0956,
|
124 |
+
"step": 1200
|
125 |
+
},
|
126 |
+
{
|
127 |
+
"epoch": 0.09027150892299146,
|
128 |
+
"grad_norm": 0.04443359375,
|
129 |
+
"learning_rate": 0.00199752757218401,
|
130 |
+
"loss": 0.0936,
|
131 |
+
"step": 1300
|
132 |
+
},
|
133 |
+
{
|
134 |
+
"epoch": 0.09721547114783696,
|
135 |
+
"grad_norm": 0.0390625,
|
136 |
+
"learning_rate": 0.001995605982021898,
|
137 |
+
"loss": 0.0917,
|
138 |
+
"step": 1400
|
139 |
+
},
|
140 |
+
{
|
141 |
+
"epoch": 0.10415943337268245,
|
142 |
+
"grad_norm": 0.0517578125,
|
143 |
+
"learning_rate": 0.0019931371771625545,
|
144 |
+
"loss": 0.0894,
|
145 |
+
"step": 1500
|
146 |
+
},
|
147 |
+
{
|
148 |
+
"epoch": 0.11110339559752795,
|
149 |
+
"grad_norm": 0.0419921875,
|
150 |
+
"learning_rate": 0.001990122514534651,
|
151 |
+
"loss": 0.0868,
|
152 |
+
"step": 1600
|
153 |
+
},
|
154 |
+
{
|
155 |
+
"epoch": 0.11804735782237345,
|
156 |
+
"grad_norm": 0.039306640625,
|
157 |
+
"learning_rate": 0.0019865636510865464,
|
158 |
+
"loss": 0.0861,
|
159 |
+
"step": 1700
|
160 |
+
},
|
161 |
+
{
|
162 |
+
"epoch": 0.12499132004721894,
|
163 |
+
"grad_norm": 0.047119140625,
|
164 |
+
"learning_rate": 0.001982462542875576,
|
165 |
+
"loss": 0.0854,
|
166 |
+
"step": 1800
|
167 |
+
},
|
168 |
+
{
|
169 |
+
"epoch": 0.13193528227206444,
|
170 |
+
"grad_norm": 0.0390625,
|
171 |
+
"learning_rate": 0.001977821443992945,
|
172 |
+
"loss": 0.0837,
|
173 |
+
"step": 1900
|
174 |
+
},
|
175 |
+
{
|
176 |
+
"epoch": 0.13887924449690994,
|
177 |
+
"grad_norm": 0.04052734375,
|
178 |
+
"learning_rate": 0.001972642905324813,
|
179 |
+
"loss": 0.0818,
|
180 |
+
"step": 2000
|
181 |
+
},
|
182 |
+
{
|
183 |
+
"epoch": 0.13887924449690994,
|
184 |
+
"eval_covost2-en-de_loss": 1.4137890338897705,
|
185 |
+
"eval_covost2-en-de_runtime": 32.5714,
|
186 |
+
"eval_covost2-en-de_samples_per_second": 1.965,
|
187 |
+
"eval_covost2-en-de_steps_per_second": 0.061,
|
188 |
+
"step": 2000
|
189 |
+
},
|
190 |
+
{
|
191 |
+
"epoch": 0.13887924449690994,
|
192 |
+
"eval_covost2-zh-en_loss": 2.667837381362915,
|
193 |
+
"eval_covost2-zh-en_runtime": 31.1685,
|
194 |
+
"eval_covost2-zh-en_samples_per_second": 2.053,
|
195 |
+
"eval_covost2-zh-en_steps_per_second": 0.064,
|
196 |
+
"step": 2000
|
197 |
+
},
|
198 |
+
{
|
199 |
+
"epoch": 0.13887924449690994,
|
200 |
+
"eval_peoplespeech-clean-transcription_loss": 1.835880160331726,
|
201 |
+
"eval_peoplespeech-clean-transcription_runtime": 32.0265,
|
202 |
+
"eval_peoplespeech-clean-transcription_samples_per_second": 1.998,
|
203 |
+
"eval_peoplespeech-clean-transcription_steps_per_second": 0.062,
|
204 |
+
"step": 2000
|
205 |
+
},
|
206 |
+
{
|
207 |
+
"epoch": 0.14582320672175544,
|
208 |
+
"grad_norm": 0.039794921875,
|
209 |
+
"learning_rate": 0.0019669297731502505,
|
210 |
+
"loss": 0.0813,
|
211 |
+
"step": 2100
|
212 |
+
},
|
213 |
+
{
|
214 |
+
"epoch": 0.15276716894660092,
|
215 |
+
"grad_norm": 0.03515625,
|
216 |
+
"learning_rate": 0.00196068518757684,
|
217 |
+
"loss": 0.0811,
|
218 |
+
"step": 2200
|
219 |
+
},
|
220 |
+
{
|
221 |
+
"epoch": 0.15971113117144642,
|
222 |
+
"grad_norm": 0.04443359375,
|
223 |
+
"learning_rate": 0.001953912580814779,
|
224 |
+
"loss": 0.0793,
|
225 |
+
"step": 2300
|
226 |
+
},
|
227 |
+
{
|
228 |
+
"epoch": 0.16665509339629192,
|
229 |
+
"grad_norm": 0.037841796875,
|
230 |
+
"learning_rate": 0.0019466156752904343,
|
231 |
+
"loss": 0.0788,
|
232 |
+
"step": 2400
|
233 |
+
},
|
234 |
+
{
|
235 |
+
"epoch": 0.17359905562113742,
|
236 |
+
"grad_norm": 0.04052734375,
|
237 |
+
"learning_rate": 0.0019387984816003866,
|
238 |
+
"loss": 0.0783,
|
239 |
+
"step": 2500
|
240 |
+
},
|
241 |
+
{
|
242 |
+
"epoch": 0.18054301784598292,
|
243 |
+
"grad_norm": 0.03466796875,
|
244 |
+
"learning_rate": 0.0019304652963070869,
|
245 |
+
"loss": 0.0772,
|
246 |
+
"step": 2600
|
247 |
+
},
|
248 |
+
{
|
249 |
+
"epoch": 0.18748698007082842,
|
250 |
+
"grad_norm": 0.036376953125,
|
251 |
+
"learning_rate": 0.0019216206995773372,
|
252 |
+
"loss": 0.0771,
|
253 |
+
"step": 2700
|
254 |
+
},
|
255 |
+
{
|
256 |
+
"epoch": 0.19443094229567393,
|
257 |
+
"grad_norm": 0.0400390625,
|
258 |
+
"learning_rate": 0.0019122695526648968,
|
259 |
+
"loss": 0.0766,
|
260 |
+
"step": 2800
|
261 |
+
},
|
262 |
+
{
|
263 |
+
"epoch": 0.2013749045205194,
|
264 |
+
"grad_norm": 0.0361328125,
|
265 |
+
"learning_rate": 0.0019024169952385887,
|
266 |
+
"loss": 0.0753,
|
267 |
+
"step": 2900
|
268 |
+
},
|
269 |
+
{
|
270 |
+
"epoch": 0.2083188667453649,
|
271 |
+
"grad_norm": 0.03125,
|
272 |
+
"learning_rate": 0.0018920684425573864,
|
273 |
+
"loss": 0.075,
|
274 |
+
"step": 3000
|
275 |
+
},
|
276 |
+
{
|
277 |
+
"epoch": 0.2083188667453649,
|
278 |
+
"eval_covost2-en-de_loss": 1.3828500509262085,
|
279 |
+
"eval_covost2-en-de_runtime": 32.2972,
|
280 |
+
"eval_covost2-en-de_samples_per_second": 1.982,
|
281 |
+
"eval_covost2-en-de_steps_per_second": 0.062,
|
282 |
+
"step": 3000
|
283 |
+
},
|
284 |
+
{
|
285 |
+
"epoch": 0.2083188667453649,
|
286 |
+
"eval_covost2-zh-en_loss": 2.646721839904785,
|
287 |
+
"eval_covost2-zh-en_runtime": 31.0128,
|
288 |
+
"eval_covost2-zh-en_samples_per_second": 2.064,
|
289 |
+
"eval_covost2-zh-en_steps_per_second": 0.064,
|
290 |
+
"step": 3000
|
291 |
+
},
|
292 |
+
{
|
293 |
+
"epoch": 0.2083188667453649,
|
294 |
+
"eval_peoplespeech-clean-transcription_loss": 1.773127555847168,
|
295 |
+
"eval_peoplespeech-clean-transcription_runtime": 32.5192,
|
296 |
+
"eval_peoplespeech-clean-transcription_samples_per_second": 1.968,
|
297 |
+
"eval_peoplespeech-clean-transcription_steps_per_second": 0.062,
|
298 |
+
"step": 3000
|
299 |
+
},
|
300 |
+
{
|
301 |
+
"epoch": 0.2152628289702104,
|
302 |
+
"grad_norm": 0.03369140625,
|
303 |
+
"learning_rate": 0.0018812295824940284,
|
304 |
+
"loss": 0.0743,
|
305 |
+
"step": 3100
|
306 |
+
},
|
307 |
+
{
|
308 |
+
"epoch": 0.2222067911950559,
|
309 |
+
"grad_norm": 0.034912109375,
|
310 |
+
"learning_rate": 0.0018699063724087904,
|
311 |
+
"loss": 0.074,
|
312 |
+
"step": 3200
|
313 |
+
},
|
314 |
+
{
|
315 |
+
"epoch": 0.2291507534199014,
|
316 |
+
"grad_norm": 0.033203125,
|
317 |
+
"learning_rate": 0.0018581050358751443,
|
318 |
+
"loss": 0.0742,
|
319 |
+
"step": 3300
|
320 |
+
},
|
321 |
+
{
|
322 |
+
"epoch": 0.2360947156447469,
|
323 |
+
"grad_norm": 0.03857421875,
|
324 |
+
"learning_rate": 0.0018458320592590974,
|
325 |
+
"loss": 0.0742,
|
326 |
+
"step": 3400
|
327 |
+
},
|
328 |
+
{
|
329 |
+
"epoch": 0.24303867786959238,
|
330 |
+
"grad_norm": 0.033935546875,
|
331 |
+
"learning_rate": 0.0018330941881540914,
|
332 |
+
"loss": 0.0728,
|
333 |
+
"step": 3500
|
334 |
+
},
|
335 |
+
{
|
336 |
+
"epoch": 0.24998264009443788,
|
337 |
+
"grad_norm": 0.031005859375,
|
338 |
+
"learning_rate": 0.0018198984236734246,
|
339 |
+
"loss": 0.0728,
|
340 |
+
"step": 3600
|
341 |
+
},
|
342 |
+
{
|
343 |
+
"epoch": 0.2569266023192834,
|
344 |
+
"grad_norm": 0.030029296875,
|
345 |
+
"learning_rate": 0.0018062520186022297,
|
346 |
+
"loss": 0.0714,
|
347 |
+
"step": 3700
|
348 |
+
},
|
349 |
+
{
|
350 |
+
"epoch": 0.2638705645441289,
|
351 |
+
"grad_norm": 0.02734375,
|
352 |
+
"learning_rate": 0.0017921624734111292,
|
353 |
+
"loss": 0.071,
|
354 |
+
"step": 3800
|
355 |
+
},
|
356 |
+
{
|
357 |
+
"epoch": 0.2708145267689744,
|
358 |
+
"grad_norm": 0.03271484375,
|
359 |
+
"learning_rate": 0.001777637532133752,
|
360 |
+
"loss": 0.0705,
|
361 |
+
"step": 3900
|
362 |
+
},
|
363 |
+
{
|
364 |
+
"epoch": 0.2777584889938199,
|
365 |
+
"grad_norm": 0.035400390625,
|
366 |
+
"learning_rate": 0.0017626851781103819,
|
367 |
+
"loss": 0.0714,
|
368 |
+
"step": 4000
|
369 |
+
},
|
370 |
+
{
|
371 |
+
"epoch": 0.2777584889938199,
|
372 |
+
"eval_covost2-en-de_loss": 1.3778624534606934,
|
373 |
+
"eval_covost2-en-de_runtime": 32.6181,
|
374 |
+
"eval_covost2-en-de_samples_per_second": 1.962,
|
375 |
+
"eval_covost2-en-de_steps_per_second": 0.061,
|
376 |
+
"step": 4000
|
377 |
+
},
|
378 |
+
{
|
379 |
+
"epoch": 0.2777584889938199,
|
380 |
+
"eval_covost2-zh-en_loss": 2.6438870429992676,
|
381 |
+
"eval_covost2-zh-en_runtime": 31.4603,
|
382 |
+
"eval_covost2-zh-en_samples_per_second": 2.034,
|
383 |
+
"eval_covost2-zh-en_steps_per_second": 0.064,
|
384 |
+
"step": 4000
|
385 |
+
},
|
386 |
+
{
|
387 |
+
"epoch": 0.2777584889938199,
|
388 |
+
"eval_peoplespeech-clean-transcription_loss": 1.7361584901809692,
|
389 |
+
"eval_peoplespeech-clean-transcription_runtime": 32.442,
|
390 |
+
"eval_peoplespeech-clean-transcription_samples_per_second": 1.973,
|
391 |
+
"eval_peoplespeech-clean-transcription_steps_per_second": 0.062,
|
392 |
+
"step": 4000
|
393 |
+
},
|
394 |
+
{
|
395 |
+
"epoch": 0.2847024512186654,
|
396 |
+
"grad_norm": 0.0281982421875,
|
397 |
+
"learning_rate": 0.001747313629600077,
|
398 |
+
"loss": 0.0713,
|
399 |
+
"step": 4100
|
400 |
+
},
|
401 |
+
{
|
402 |
+
"epoch": 0.2916464134435109,
|
403 |
+
"grad_norm": 0.028076171875,
|
404 |
+
"learning_rate": 0.001731531335263669,
|
405 |
+
"loss": 0.0699,
|
406 |
+
"step": 4200
|
407 |
+
},
|
408 |
+
{
|
409 |
+
"epoch": 0.2985903756683564,
|
410 |
+
"grad_norm": 0.0277099609375,
|
411 |
+
"learning_rate": 0.0017153469695201276,
|
412 |
+
"loss": 0.0702,
|
413 |
+
"step": 4300
|
414 |
+
},
|
415 |
+
{
|
416 |
+
"epoch": 0.30553433789320184,
|
417 |
+
"grad_norm": 0.031982421875,
|
418 |
+
"learning_rate": 0.0016987694277788418,
|
419 |
+
"loss": 0.0692,
|
420 |
+
"step": 4400
|
421 |
+
},
|
422 |
+
{
|
423 |
+
"epoch": 0.31247830011804734,
|
424 |
+
"grad_norm": 0.02880859375,
|
425 |
+
"learning_rate": 0.001681807821550438,
|
426 |
+
"loss": 0.0686,
|
427 |
+
"step": 4500
|
428 |
+
},
|
429 |
+
{
|
430 |
+
"epoch": 0.31942226234289284,
|
431 |
+
"grad_norm": 0.0289306640625,
|
432 |
+
"learning_rate": 0.0016644714734388218,
|
433 |
+
"loss": 0.0698,
|
434 |
+
"step": 4600
|
435 |
+
},
|
436 |
+
{
|
437 |
+
"epoch": 0.32636622456773834,
|
438 |
+
"grad_norm": 0.029541015625,
|
439 |
+
"learning_rate": 0.0016467699120171987,
|
440 |
+
"loss": 0.0683,
|
441 |
+
"step": 4700
|
442 |
+
},
|
443 |
+
{
|
444 |
+
"epoch": 0.33331018679258384,
|
445 |
+
"grad_norm": 0.034423828125,
|
446 |
+
"learning_rate": 0.001628712866590885,
|
447 |
+
"loss": 0.0687,
|
448 |
+
"step": 4800
|
449 |
+
},
|
450 |
+
{
|
451 |
+
"epoch": 0.34025414901742934,
|
452 |
+
"grad_norm": 0.0289306640625,
|
453 |
+
"learning_rate": 0.0016103102618497923,
|
454 |
+
"loss": 0.0684,
|
455 |
+
"step": 4900
|
456 |
+
},
|
457 |
+
{
|
458 |
+
"epoch": 0.34719811124227484,
|
459 |
+
"grad_norm": 0.0263671875,
|
460 |
+
"learning_rate": 0.0015915722124135226,
|
461 |
+
"loss": 0.0681,
|
462 |
+
"step": 5000
|
463 |
+
},
|
464 |
+
{
|
465 |
+
"epoch": 0.34719811124227484,
|
466 |
+
"eval_covost2-en-de_loss": 1.3711879253387451,
|
467 |
+
"eval_covost2-en-de_runtime": 32.6293,
|
468 |
+
"eval_covost2-en-de_samples_per_second": 1.961,
|
469 |
+
"eval_covost2-en-de_steps_per_second": 0.061,
|
470 |
+
"step": 5000
|
471 |
+
},
|
472 |
+
{
|
473 |
+
"epoch": 0.34719811124227484,
|
474 |
+
"eval_covost2-zh-en_loss": 2.6346511840820312,
|
475 |
+
"eval_covost2-zh-en_runtime": 32.1513,
|
476 |
+
"eval_covost2-zh-en_samples_per_second": 1.991,
|
477 |
+
"eval_covost2-zh-en_steps_per_second": 0.062,
|
478 |
+
"step": 5000
|
479 |
+
},
|
480 |
+
{
|
481 |
+
"epoch": 0.34719811124227484,
|
482 |
+
"eval_peoplespeech-clean-transcription_loss": 1.7350472211837769,
|
483 |
+
"eval_peoplespeech-clean-transcription_runtime": 32.5813,
|
484 |
+
"eval_peoplespeech-clean-transcription_samples_per_second": 1.964,
|
485 |
+
"eval_peoplespeech-clean-transcription_steps_per_second": 0.061,
|
486 |
+
"step": 5000
|
487 |
+
},
|
488 |
+
{
|
489 |
+
"epoch": 0.35414207346712034,
|
490 |
+
"grad_norm": 0.028076171875,
|
491 |
+
"learning_rate": 0.001572509017272072,
|
492 |
+
"loss": 0.0693,
|
493 |
+
"step": 5100
|
494 |
+
},
|
495 |
+
{
|
496 |
+
"epoch": 0.36108603569196585,
|
497 |
+
"grad_norm": 0.030517578125,
|
498 |
+
"learning_rate": 0.0015531311541251993,
|
499 |
+
"loss": 0.0683,
|
500 |
+
"step": 5200
|
501 |
+
},
|
502 |
+
{
|
503 |
+
"epoch": 0.36802999791681135,
|
504 |
+
"grad_norm": 0.031494140625,
|
505 |
+
"learning_rate": 0.0015334492736235703,
|
506 |
+
"loss": 0.0677,
|
507 |
+
"step": 5300
|
508 |
+
},
|
509 |
+
{
|
510 |
+
"epoch": 0.37497396014165685,
|
511 |
+
"grad_norm": 0.0284423828125,
|
512 |
+
"learning_rate": 0.0015134741935148419,
|
513 |
+
"loss": 0.0669,
|
514 |
+
"step": 5400
|
515 |
+
},
|
516 |
+
{
|
517 |
+
"epoch": 0.38191792236650235,
|
518 |
+
"grad_norm": 0.0302734375,
|
519 |
+
"learning_rate": 0.0014932168926979072,
|
520 |
+
"loss": 0.0669,
|
521 |
+
"step": 5500
|
522 |
+
},
|
523 |
+
{
|
524 |
+
"epoch": 0.38886188459134785,
|
525 |
+
"grad_norm": 0.0260009765625,
|
526 |
+
"learning_rate": 0.0014726885051885652,
|
527 |
+
"loss": 0.0666,
|
528 |
+
"step": 5600
|
529 |
+
},
|
530 |
+
{
|
531 |
+
"epoch": 0.3958058468161933,
|
532 |
+
"grad_norm": 0.033447265625,
|
533 |
+
"learning_rate": 0.0014519003139999338,
|
534 |
+
"loss": 0.0659,
|
535 |
+
"step": 5700
|
536 |
+
},
|
537 |
+
{
|
538 |
+
"epoch": 0.4027498090410388,
|
539 |
+
"grad_norm": 0.0283203125,
|
540 |
+
"learning_rate": 0.0014308637449409706,
|
541 |
+
"loss": 0.0653,
|
542 |
+
"step": 5800
|
543 |
+
},
|
544 |
+
{
|
545 |
+
"epoch": 0.4096937712658843,
|
546 |
+
"grad_norm": 0.0283203125,
|
547 |
+
"learning_rate": 0.0014095903603365066,
|
548 |
+
"loss": 0.0662,
|
549 |
+
"step": 5900
|
550 |
+
},
|
551 |
+
{
|
552 |
+
"epoch": 0.4166377334907298,
|
553 |
+
"grad_norm": 0.0267333984375,
|
554 |
+
"learning_rate": 0.0013880918526722496,
|
555 |
+
"loss": 0.0665,
|
556 |
+
"step": 6000
|
557 |
+
},
|
558 |
+
{
|
559 |
+
"epoch": 0.4166377334907298,
|
560 |
+
"eval_covost2-en-de_loss": 1.3651559352874756,
|
561 |
+
"eval_covost2-en-de_runtime": 32.5621,
|
562 |
+
"eval_covost2-en-de_samples_per_second": 1.965,
|
563 |
+
"eval_covost2-en-de_steps_per_second": 0.061,
|
564 |
+
"step": 6000
|
565 |
+
},
|
566 |
+
{
|
567 |
+
"epoch": 0.4166377334907298,
|
568 |
+
"eval_covost2-zh-en_loss": 2.6372551918029785,
|
569 |
+
"eval_covost2-zh-en_runtime": 31.028,
|
570 |
+
"eval_covost2-zh-en_samples_per_second": 2.063,
|
571 |
+
"eval_covost2-zh-en_steps_per_second": 0.064,
|
572 |
+
"step": 6000
|
573 |
+
},
|
574 |
+
{
|
575 |
+
"epoch": 0.4166377334907298,
|
576 |
+
"eval_peoplespeech-clean-transcription_loss": 1.7209596633911133,
|
577 |
+
"eval_peoplespeech-clean-transcription_runtime": 32.6773,
|
578 |
+
"eval_peoplespeech-clean-transcription_samples_per_second": 1.959,
|
579 |
+
"eval_peoplespeech-clean-transcription_steps_per_second": 0.061,
|
580 |
+
"step": 6000
|
581 |
+
},
|
582 |
+
{
|
583 |
+
"epoch": 0.4235816957155753,
|
584 |
+
"grad_norm": 0.028564453125,
|
585 |
+
"learning_rate": 0.0013663800381682463,
|
586 |
+
"loss": 0.0658,
|
587 |
+
"step": 6100
|
588 |
+
},
|
589 |
+
{
|
590 |
+
"epoch": 0.4305256579404208,
|
591 |
+
"grad_norm": 0.0299072265625,
|
592 |
+
"learning_rate": 0.0013444668502843329,
|
593 |
+
"loss": 0.0657,
|
594 |
+
"step": 6200
|
595 |
+
},
|
596 |
+
{
|
597 |
+
"epoch": 0.4374696201652663,
|
598 |
+
"grad_norm": 0.0296630859375,
|
599 |
+
"learning_rate": 0.0013223643331611537,
|
600 |
+
"loss": 0.0655,
|
601 |
+
"step": 6300
|
602 |
+
},
|
603 |
+
{
|
604 |
+
"epoch": 0.4444135823901118,
|
605 |
+
"grad_norm": 0.0286865234375,
|
606 |
+
"learning_rate": 0.001300084635000341,
|
607 |
+
"loss": 0.0654,
|
608 |
+
"step": 6400
|
609 |
+
},
|
610 |
+
{
|
611 |
+
"epoch": 0.4513575446149573,
|
612 |
+
"grad_norm": 0.028564453125,
|
613 |
+
"learning_rate": 0.0012776400013875004,
|
614 |
+
"loss": 0.0655,
|
615 |
+
"step": 6500
|
616 |
+
},
|
617 |
+
{
|
618 |
+
"epoch": 0.4583015068398028,
|
619 |
+
"grad_norm": 0.030029296875,
|
620 |
+
"learning_rate": 0.0012550427685616766,
|
621 |
+
"loss": 0.0648,
|
622 |
+
"step": 6600
|
623 |
+
},
|
624 |
+
{
|
625 |
+
"epoch": 0.4652454690646483,
|
626 |
+
"grad_norm": 0.037109375,
|
627 |
+
"learning_rate": 0.0012323053566349834,
|
628 |
+
"loss": 0.0654,
|
629 |
+
"step": 6700
|
630 |
+
},
|
631 |
+
{
|
632 |
+
"epoch": 0.4721894312894938,
|
633 |
+
"grad_norm": 0.029296875,
|
634 |
+
"learning_rate": 0.0012094402627661448,
|
635 |
+
"loss": 0.0643,
|
636 |
+
"step": 6800
|
637 |
+
},
|
638 |
+
{
|
639 |
+
"epoch": 0.47913339351433926,
|
640 |
+
"grad_norm": 0.030517578125,
|
641 |
+
"learning_rate": 0.0011864600542916813,
|
642 |
+
"loss": 0.0646,
|
643 |
+
"step": 6900
|
644 |
+
},
|
645 |
+
{
|
646 |
+
"epoch": 0.48607735573918476,
|
647 |
+
"grad_norm": 0.037353515625,
|
648 |
+
"learning_rate": 0.0011633773618185302,
|
649 |
+
"loss": 0.0642,
|
650 |
+
"step": 7000
|
651 |
+
},
|
652 |
+
{
|
653 |
+
"epoch": 0.48607735573918476,
|
654 |
+
"eval_covost2-en-de_loss": 1.3594859838485718,
|
655 |
+
"eval_covost2-en-de_runtime": 32.6807,
|
656 |
+
"eval_covost2-en-de_samples_per_second": 1.958,
|
657 |
+
"eval_covost2-en-de_steps_per_second": 0.061,
|
658 |
+
"step": 7000
|
659 |
+
},
|
660 |
+
{
|
661 |
+
"epoch": 0.48607735573918476,
|
662 |
+
"eval_covost2-zh-en_loss": 2.626713514328003,
|
663 |
+
"eval_covost2-zh-en_runtime": 31.0228,
|
664 |
+
"eval_covost2-zh-en_samples_per_second": 2.063,
|
665 |
+
"eval_covost2-zh-en_steps_per_second": 0.064,
|
666 |
+
"step": 7000
|
667 |
+
},
|
668 |
+
{
|
669 |
+
"epoch": 0.48607735573918476,
|
670 |
+
"eval_peoplespeech-clean-transcription_loss": 1.693739652633667,
|
671 |
+
"eval_peoplespeech-clean-transcription_runtime": 31.9776,
|
672 |
+
"eval_peoplespeech-clean-transcription_samples_per_second": 2.001,
|
673 |
+
"eval_peoplespeech-clean-transcription_steps_per_second": 0.063,
|
674 |
+
"step": 7000
|
675 |
+
},
|
676 |
+
{
|
677 |
+
"epoch": 0.49302131796403026,
|
678 |
+
"grad_norm": 0.02978515625,
|
679 |
+
"learning_rate": 0.0011402048722818862,
|
680 |
+
"loss": 0.0656,
|
681 |
+
"step": 7100
|
682 |
+
},
|
683 |
+
{
|
684 |
+
"epoch": 0.49996528018887576,
|
685 |
+
"grad_norm": 0.0281982421875,
|
686 |
+
"learning_rate": 0.0011169553219720827,
|
687 |
+
"loss": 0.064,
|
688 |
+
"step": 7200
|
689 |
+
}
|
690 |
+
],
|
691 |
+
"logging_steps": 100,
|
692 |
+
"max_steps": 14400,
|
693 |
+
"num_input_tokens_seen": 0,
|
694 |
+
"num_train_epochs": 1,
|
695 |
+
"save_steps": 3600,
|
696 |
+
"stateful_callbacks": {
|
697 |
+
"TrainerControl": {
|
698 |
+
"args": {
|
699 |
+
"should_epoch_stop": false,
|
700 |
+
"should_evaluate": false,
|
701 |
+
"should_log": false,
|
702 |
+
"should_save": true,
|
703 |
+
"should_training_stop": false
|
704 |
+
},
|
705 |
+
"attributes": {}
|
706 |
+
}
|
707 |
+
},
|
708 |
+
"total_flos": 1.8942929465072026e+18,
|
709 |
+
"train_batch_size": 96,
|
710 |
+
"trial_name": null,
|
711 |
+
"trial_params": null
|
712 |
+
}
|
training_args.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:526c930de4f2a14f4d9943636fb014003cb001081aed1fbeba40b7395ec5812b
|
3 |
+
size 5688
|
ultravox_config.py
ADDED
@@ -0,0 +1,170 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import dataclasses
|
2 |
+
from enum import Enum
|
3 |
+
from typing import Any, Dict, List, Optional
|
4 |
+
|
5 |
+
import transformers
|
6 |
+
|
7 |
+
|
8 |
+
@dataclasses.dataclass
|
9 |
+
class LoraConfigSimplified:
|
10 |
+
"""
|
11 |
+
Low Rank Approximation (LoRA) configuration.
|
12 |
+
|
13 |
+
Used for language and audio models separately.
|
14 |
+
"""
|
15 |
+
|
16 |
+
# The rank of the approximation
|
17 |
+
r: int = 0
|
18 |
+
lora_alpha: float = 8
|
19 |
+
target_modules: Optional[List[str]] = dataclasses.field(
|
20 |
+
default_factory=lambda: ["k_proj", "q_proj", "linear_k", "linear_q"]
|
21 |
+
)
|
22 |
+
|
23 |
+
|
24 |
+
class LossFunction(str, Enum):
|
25 |
+
CrossEntropy = "ce"
|
26 |
+
KL_Divergence = "kl"
|
27 |
+
|
28 |
+
|
29 |
+
@dataclasses.dataclass
|
30 |
+
class LossConfig:
|
31 |
+
loss_function: LossFunction = LossFunction.KL_Divergence
|
32 |
+
kl_temperature: float = 2.0
|
33 |
+
|
34 |
+
@property
|
35 |
+
def requires_alt_fields(self):
|
36 |
+
return self.loss_function == LossFunction.KL_Divergence
|
37 |
+
|
38 |
+
|
39 |
+
class UltravoxConfig(transformers.PretrainedConfig):
|
40 |
+
r"""
|
41 |
+
This is the configuration class to store the configuration of a [`UltravoxForConditionalGeneration`]. It is used to instantiate an
|
42 |
+
Ultravox model according to the specified arguments, defining the model architecture.
|
43 |
+
|
44 |
+
Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
|
45 |
+
documentation from [`PretrainedConfig`] for more information.
|
46 |
+
|
47 |
+
Args:
|
48 |
+
audio_config (`Wav2Vec2Config`, *optional*):
|
49 |
+
Custom audio config or dict
|
50 |
+
text_config (`Union[AutoConfig, dict]`, *optional*):
|
51 |
+
The config object of the text backbone. Can be any of `LlamaConfig` or `MistralConfig`.
|
52 |
+
ignore_index (`int`, *optional*, defaults to -100):
|
53 |
+
The ignore index for the loss function.
|
54 |
+
audio_token_index (`int`, *optional*, defaults to 32000):
|
55 |
+
The audio token index to encode the audio prompt.
|
56 |
+
stack_factor (`int`, *optional*, defaults to 8):
|
57 |
+
Audio downsampling factor for the multimodal projector.
|
58 |
+
norm_init (`float`, *optional*, defaults to 0.4):
|
59 |
+
The initialization value for the layer normalization.
|
60 |
+
projector_act (`str`, *optional*, defaults to `"swiglu"`):
|
61 |
+
The activation function used by the multimodal projector.
|
62 |
+
text_model_lora_config (`LoraConfigSimplified`, *optional*):
|
63 |
+
The LoRA configuration for finetuning the text model.
|
64 |
+
audio_model_lora_config (`LoraConfigSimplified`, *optional*):
|
65 |
+
The LoRA configuration for finetuning the audio model.
|
66 |
+
audio_latency_block_size (`int`, *optional*, defaults to `None`):
|
67 |
+
The latency block size for simulating audio streaming.
|
68 |
+
|
69 |
+
|
70 |
+
Example:
|
71 |
+
|
72 |
+
```python
|
73 |
+
>>> from transformers import UltravoxForConditionalGeneration, Wav2Vec2Config, UltravoxConfig, LlamaConfig
|
74 |
+
|
75 |
+
>>> # Initializing an audio encoder config
|
76 |
+
>>> audio_config = Wav2Vec2Config()
|
77 |
+
|
78 |
+
>>> # Initializing a Llama config
|
79 |
+
>>> text_config = LlamaConfig()
|
80 |
+
|
81 |
+
>>> # Initializing a default configuration
|
82 |
+
>>> configuration = UltravoxConfig(audio_config, text_config)
|
83 |
+
|
84 |
+
>>> # Initializing a completely untrained model from the configuration
|
85 |
+
>>> model = UltravoxForConditionalGeneration(configuration)
|
86 |
+
|
87 |
+
>>> # Accessing the model configuration
|
88 |
+
>>> configuration = model.config
|
89 |
+
|
90 |
+
>>> # Initialize a model from pretrained checkpoints and random projector weights
|
91 |
+
>>> config = UltravoxConfig(audio_model_id="facebook/wav2vec2-base-960h", text_model_id="meta-llama/Llama-2-7b-chat-hf")
|
92 |
+
```"""
|
93 |
+
|
94 |
+
model_type = "ultravox"
|
95 |
+
is_composition = False
|
96 |
+
|
97 |
+
def __init__(
|
98 |
+
self,
|
99 |
+
audio_config: Optional[Dict[str, Any]] = None,
|
100 |
+
text_config: Optional[Dict[str, Any]] = None,
|
101 |
+
audio_model_id: Optional[str] = None,
|
102 |
+
text_model_id: Optional[str] = None,
|
103 |
+
ignore_index: int = -100,
|
104 |
+
hidden_size: int = 4096,
|
105 |
+
stack_factor: int = 8,
|
106 |
+
norm_init: float = 0.4,
|
107 |
+
projector_act: str = "swiglu",
|
108 |
+
text_model_lora_config: Optional[LoraConfigSimplified] = None,
|
109 |
+
audio_model_lora_config: Optional[LoraConfigSimplified] = None,
|
110 |
+
audio_latency_block_size: Optional[int] = None,
|
111 |
+
**kwargs,
|
112 |
+
):
|
113 |
+
self.ignore_index = ignore_index
|
114 |
+
|
115 |
+
self.audio_model_id = audio_model_id
|
116 |
+
self.text_model_id = text_model_id
|
117 |
+
|
118 |
+
self.hidden_size = hidden_size
|
119 |
+
self.stack_factor = stack_factor
|
120 |
+
self.norm_init = norm_init
|
121 |
+
self.projector_act = projector_act
|
122 |
+
|
123 |
+
if text_model_id is not None:
|
124 |
+
self.text_config: transformers.LlamaConfig = (
|
125 |
+
transformers.AutoConfig.from_pretrained(text_model_id)
|
126 |
+
)
|
127 |
+
else:
|
128 |
+
text_config = text_config or {}
|
129 |
+
self.text_config = transformers.CONFIG_MAPPING[
|
130 |
+
text_config.get("model_type", "llama")
|
131 |
+
](**text_config)
|
132 |
+
|
133 |
+
if audio_model_id is not None:
|
134 |
+
self.audio_config: transformers.PretrainedConfig = (
|
135 |
+
transformers.AutoConfig.from_pretrained(audio_model_id)
|
136 |
+
)
|
137 |
+
else:
|
138 |
+
audio_config = audio_config or {}
|
139 |
+
self.audio_config = transformers.CONFIG_MAPPING[
|
140 |
+
audio_config.get("model_type", "wav2vec2")
|
141 |
+
](**audio_config)
|
142 |
+
|
143 |
+
self.text_model_lora_config = (
|
144 |
+
text_model_lora_config
|
145 |
+
if isinstance(text_model_lora_config, dict)
|
146 |
+
else dataclasses.asdict(text_model_lora_config or LoraConfigSimplified())
|
147 |
+
)
|
148 |
+
self.audio_model_lora_config = (
|
149 |
+
audio_model_lora_config
|
150 |
+
if isinstance(audio_model_lora_config, dict)
|
151 |
+
else dataclasses.asdict(audio_model_lora_config or LoraConfigSimplified())
|
152 |
+
)
|
153 |
+
self.audio_latency_block_size = audio_latency_block_size
|
154 |
+
|
155 |
+
self.vocab_size = self.text_config.vocab_size
|
156 |
+
|
157 |
+
self.initializer_range = self.text_config.initializer_range
|
158 |
+
|
159 |
+
super().__init__(**kwargs)
|
160 |
+
|
161 |
+
def to_diff_dict(self) -> Dict[str, Any]:
|
162 |
+
diff_dict = super().to_diff_dict()
|
163 |
+
|
164 |
+
# remove text_config and audio_config if text_model_id and audio_model_id are present
|
165 |
+
if self.text_model_id is not None:
|
166 |
+
diff_dict.pop("text_config", None)
|
167 |
+
if self.audio_model_id is not None:
|
168 |
+
diff_dict.pop("audio_config", None)
|
169 |
+
|
170 |
+
return diff_dict
|
ultravox_model.py
ADDED
@@ -0,0 +1,723 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import logging
|
2 |
+
from typing import Any, Dict, Optional, Set, Tuple, Union
|
3 |
+
|
4 |
+
import peft
|
5 |
+
import torch
|
6 |
+
import torch.nn as nn
|
7 |
+
import torch.nn.functional as F
|
8 |
+
import transformers
|
9 |
+
import transformers.activations
|
10 |
+
import transformers.modeling_outputs
|
11 |
+
import transformers.models
|
12 |
+
from transformers.models.whisper import modeling_whisper as whisper
|
13 |
+
|
14 |
+
# We must use relative import in this directory to allow uploading to HF Hub
|
15 |
+
# Even "from . import X" pattern doesn't work (undocumented and unclear why)
|
16 |
+
from .ultravox_config import LossConfig
|
17 |
+
from .ultravox_config import LossFunction
|
18 |
+
from .ultravox_config import UltravoxConfig
|
19 |
+
|
20 |
+
|
21 |
+
class UltravoxModel(transformers.LlamaPreTrainedModel):
|
22 |
+
"""
|
23 |
+
The Ultravox model which consists of an audio encoder and a language model.
|
24 |
+
|
25 |
+
Audio input is processed by the audio encoder, then every `stack_factor` frames are stacked together and
|
26 |
+
projected to the language model's embedding space using a few linear layers.
|
27 |
+
The text is embedded by the language model as usual and then the audio and text embeddings are merged together.
|
28 |
+
|
29 |
+
A special token `<|audio|>` is used to indicate the start of the audio embeddings in the merged embeddings.
|
30 |
+
|
31 |
+
Parameters:
|
32 |
+
config: Model configuration class with all the parameters of the model.
|
33 |
+
"""
|
34 |
+
|
35 |
+
config_class = UltravoxConfig
|
36 |
+
config: UltravoxConfig # for type hinting
|
37 |
+
# Usually we load encoder and LLM weights from a pretrained model separately, so they are allowed to be missing
|
38 |
+
_keys_to_ignore_on_load_missing = ["audio_tower.*", "language_model.*"]
|
39 |
+
|
40 |
+
def __init__(self, config: UltravoxConfig):
|
41 |
+
super().__init__(config)
|
42 |
+
self._register_load_state_dict_pre_hook(self._pre_load_state_dict_hook)
|
43 |
+
|
44 |
+
self.keep_params: Set[str] = set()
|
45 |
+
self.vocab_size = config.vocab_size
|
46 |
+
|
47 |
+
self.audio_tower = self._create_audio_tower(config)
|
48 |
+
self.multi_modal_projector = self._create_multi_modal_projector(config)
|
49 |
+
self.language_model = self._create_language_model(config)
|
50 |
+
|
51 |
+
# Determine no_split_modules dynamically to use with FSDP auto_wrap policy.
|
52 |
+
# FSDP throws an error if some of the layer types are not found in the model.
|
53 |
+
# This would be something like ["LlamaDecoderLayer", "WhisperEncoderLayer"]
|
54 |
+
self._no_split_modules = (self.language_model._no_split_modules or []) + (
|
55 |
+
self.audio_tower._no_split_modules or []
|
56 |
+
)
|
57 |
+
|
58 |
+
self.loss_config = LossConfig()
|
59 |
+
self.post_init()
|
60 |
+
|
61 |
+
def get_input_embeddings(self):
|
62 |
+
return self.language_model.get_input_embeddings()
|
63 |
+
|
64 |
+
def set_input_embeddings(self, value):
|
65 |
+
self.language_model.set_input_embeddings(value)
|
66 |
+
|
67 |
+
def get_output_embeddings(self):
|
68 |
+
return self.language_model.get_output_embeddings()
|
69 |
+
|
70 |
+
def set_output_embeddings(self, new_embeddings):
|
71 |
+
self.language_model.set_output_embeddings(new_embeddings)
|
72 |
+
|
73 |
+
def set_decoder(self, decoder):
|
74 |
+
self.language_model.set_decoder(decoder)
|
75 |
+
|
76 |
+
def get_decoder(self):
|
77 |
+
return self.language_model.get_decoder()
|
78 |
+
|
79 |
+
def tie_weights(self):
|
80 |
+
return self.language_model.tie_weights()
|
81 |
+
|
82 |
+
def set_loss_config(self, loss_config: LossConfig):
|
83 |
+
self.loss_config = loss_config
|
84 |
+
|
85 |
+
def _setup_cache(
|
86 |
+
self, cache_cls, max_batch_size: int, max_cache_len: Optional[int] = None
|
87 |
+
):
|
88 |
+
self.language_model._setup_cache(cache_cls, max_batch_size, max_cache_len)
|
89 |
+
|
90 |
+
def _reorder_cache(self, past_key_values, beam_idx):
|
91 |
+
return self.language_model._reorder_cache(past_key_values, beam_idx)
|
92 |
+
|
93 |
+
def resize_token_embeddings(
|
94 |
+
self,
|
95 |
+
new_num_tokens: Optional[int] = None,
|
96 |
+
pad_to_multiple_of: Optional[int] = None,
|
97 |
+
) -> nn.Embedding:
|
98 |
+
model_embeds = self.language_model.resize_token_embeddings(
|
99 |
+
new_num_tokens, pad_to_multiple_of
|
100 |
+
)
|
101 |
+
# update vocab size
|
102 |
+
self.config.text_config.vocab_size = model_embeds.num_embeddings
|
103 |
+
self.config.vocab_size = model_embeds.num_embeddings
|
104 |
+
self.vocab_size = model_embeds.num_embeddings
|
105 |
+
return model_embeds
|
106 |
+
|
107 |
+
def _compute_kl_loss(
|
108 |
+
self,
|
109 |
+
lm_output: transformers.modeling_outputs.CausalLMOutputWithPast,
|
110 |
+
labels: Optional[torch.Tensor] = None,
|
111 |
+
past_key_values: Optional[Union[Tuple, transformers.cache_utils.Cache]] = None,
|
112 |
+
alt_input_ids: Optional[torch.Tensor] = None,
|
113 |
+
alt_attention_mask: Optional[torch.Tensor] = None,
|
114 |
+
alt_labels: Optional[torch.Tensor] = None,
|
115 |
+
**kwargs,
|
116 |
+
):
|
117 |
+
# disable gradient computation for the teacher model
|
118 |
+
with torch.no_grad():
|
119 |
+
# compute the teacher (text-only) model's distribution
|
120 |
+
alt_inputs_embeds = self.get_input_embeddings().forward(alt_input_ids)
|
121 |
+
alt_lm_output = self.language_model.forward(
|
122 |
+
inputs_embeds=alt_inputs_embeds,
|
123 |
+
labels=alt_labels,
|
124 |
+
attention_mask=alt_attention_mask,
|
125 |
+
past_key_values=past_key_values,
|
126 |
+
**kwargs,
|
127 |
+
)
|
128 |
+
# compute the KL divergence loss between the two models
|
129 |
+
kl_loss = F.kl_div(
|
130 |
+
F.log_softmax(
|
131 |
+
lm_output.logits[labels != -100] / self.loss_config.kl_temperature,
|
132 |
+
dim=-1,
|
133 |
+
),
|
134 |
+
F.softmax(
|
135 |
+
alt_lm_output.logits[alt_labels != -100]
|
136 |
+
/ self.loss_config.kl_temperature,
|
137 |
+
dim=-1,
|
138 |
+
),
|
139 |
+
reduction="batchmean",
|
140 |
+
)
|
141 |
+
return {"loss": kl_loss}
|
142 |
+
|
143 |
+
def forward(
|
144 |
+
self,
|
145 |
+
input_ids: torch.Tensor,
|
146 |
+
audio_values: Optional[torch.FloatTensor] = None,
|
147 |
+
inputs_embeds: Optional[torch.FloatTensor] = None,
|
148 |
+
labels: Optional[torch.Tensor] = None,
|
149 |
+
attention_mask: Optional[torch.Tensor] = None,
|
150 |
+
audio_token_start_idx: Optional[torch.Tensor] = None,
|
151 |
+
audio_len: Optional[torch.Tensor] = None,
|
152 |
+
audio_token_len: Optional[torch.Tensor] = None,
|
153 |
+
past_key_values: Optional[Union[Tuple, transformers.cache_utils.Cache]] = None,
|
154 |
+
# the alt_* fields are needed for KL divergence loss
|
155 |
+
alt_input_ids: Optional[torch.Tensor] = None,
|
156 |
+
alt_attention_mask: Optional[torch.Tensor] = None,
|
157 |
+
alt_labels: Optional[torch.Tensor] = None,
|
158 |
+
**kwargs,
|
159 |
+
) -> Union[Tuple, transformers.modeling_outputs.CausalLMOutputWithPast]:
|
160 |
+
"""
|
161 |
+
Forward pass for the Ultravox model.
|
162 |
+
|
163 |
+
`input_ids` are the tokenized text input. They are embedded by the language model as usual.
|
164 |
+
`audio_values` are processed by the audio encoder and then every `stack_factor` frames are stacked together and
|
165 |
+
projected to the language model's embedding space using a few linear layers.
|
166 |
+
The audio and text embeddings are merged together. A special token `<|audio|>` is used to indicate the start
|
167 |
+
of the audio embeddings in the merged embeddings.
|
168 |
+
|
169 |
+
Args:
|
170 |
+
input_ids: The tokenized text input.
|
171 |
+
audio_values: The processed audio values.
|
172 |
+
inputs_embeds: The embeddings for the input tokens.
|
173 |
+
labels: The tokenized text labels.
|
174 |
+
attention_mask: The attention mask for the input.
|
175 |
+
position_ids: The position ids for the input.
|
176 |
+
past_key_values: The past key value cache for the language model attention layers.
|
177 |
+
**kwargs: Additional keyword arguments. Passed directly to the language model.
|
178 |
+
"""
|
179 |
+
if inputs_embeds is None:
|
180 |
+
# B x T -> B x T x D
|
181 |
+
inputs_embeds = self.get_input_embeddings().forward(input_ids)
|
182 |
+
|
183 |
+
if audio_values is not None:
|
184 |
+
assert (
|
185 |
+
audio_token_start_idx is not None and audio_token_len is not None
|
186 |
+
), "audio_token_start_idx and audio_token_len must be provided if audio_values are provided."
|
187 |
+
assert (
|
188 |
+
len(audio_token_start_idx) == len(audio_token_len) == len(audio_values)
|
189 |
+
), "audio_token_start_idx, audio_token_len, and audio_values must have the same batch size."
|
190 |
+
|
191 |
+
# B x A/3200 x D
|
192 |
+
audio_tower_output = self.audio_tower.forward(
|
193 |
+
audio_values.to(self.audio_tower.dtype),
|
194 |
+
audio_len=audio_len,
|
195 |
+
).last_hidden_state
|
196 |
+
audio_tower_output = audio_tower_output.to(inputs_embeds.dtype)
|
197 |
+
|
198 |
+
audio_embeds = self.multi_modal_projector.forward(audio_tower_output)
|
199 |
+
|
200 |
+
# combine audio and text embeddings
|
201 |
+
for i, (audio, start, length) in enumerate(
|
202 |
+
zip(audio_embeds, audio_token_start_idx, audio_token_len)
|
203 |
+
):
|
204 |
+
length = min(length, audio.shape[0])
|
205 |
+
inputs_embeds[i, start : start + length] = audio[:length]
|
206 |
+
|
207 |
+
lm_output = self.language_model.forward(
|
208 |
+
inputs_embeds=inputs_embeds,
|
209 |
+
labels=labels,
|
210 |
+
attention_mask=attention_mask,
|
211 |
+
past_key_values=past_key_values,
|
212 |
+
**kwargs,
|
213 |
+
)
|
214 |
+
if self.training:
|
215 |
+
if self.loss_config.loss_function == LossFunction.CrossEntropy:
|
216 |
+
return lm_output
|
217 |
+
elif self.loss_config.loss_function == LossFunction.KL_Divergence:
|
218 |
+
return self._compute_kl_loss(
|
219 |
+
lm_output=lm_output,
|
220 |
+
labels=labels,
|
221 |
+
past_key_values=past_key_values,
|
222 |
+
alt_input_ids=alt_input_ids,
|
223 |
+
alt_attention_mask=alt_attention_mask,
|
224 |
+
alt_labels=alt_labels,
|
225 |
+
**kwargs,
|
226 |
+
)
|
227 |
+
else:
|
228 |
+
raise ValueError(
|
229 |
+
f"Unsupported loss function: {self.loss_config.loss_function}"
|
230 |
+
)
|
231 |
+
else:
|
232 |
+
return lm_output
|
233 |
+
|
234 |
+
def prepare_inputs_for_generation(
|
235 |
+
self,
|
236 |
+
input_ids: torch.Tensor,
|
237 |
+
audio_values: Optional[torch.FloatTensor] = None,
|
238 |
+
audio_token_start_idx: Optional[torch.Tensor] = None,
|
239 |
+
audio_token_len: Optional[torch.Tensor] = None,
|
240 |
+
audio_len: Optional[torch.Tensor] = None,
|
241 |
+
past_key_values: Optional[Union[Tuple, transformers.cache_utils.Cache]] = None,
|
242 |
+
attention_mask: Optional[torch.Tensor] = None,
|
243 |
+
inputs_embeds: Optional[torch.Tensor] = None,
|
244 |
+
cache_position: Optional[torch.Tensor] = None,
|
245 |
+
**kwargs,
|
246 |
+
) -> Dict[str, Any]:
|
247 |
+
model_input = self.language_model.prepare_inputs_for_generation(
|
248 |
+
input_ids=input_ids,
|
249 |
+
past_key_values=past_key_values,
|
250 |
+
attention_mask=attention_mask,
|
251 |
+
inputs_embeds=inputs_embeds,
|
252 |
+
cache_position=cache_position,
|
253 |
+
**kwargs,
|
254 |
+
)
|
255 |
+
|
256 |
+
# include audio information in model_input only when it is needed during prefilling
|
257 |
+
# audio_token_start_idx should always be relative to the current cache position
|
258 |
+
prefill_start_idx = 0 if cache_position is None else cache_position[0]
|
259 |
+
if (
|
260 |
+
audio_values is not None
|
261 |
+
and audio_token_start_idx is not None
|
262 |
+
and prefill_start_idx <= torch.max(audio_token_start_idx)
|
263 |
+
):
|
264 |
+
model_input["audio_values"] = audio_values
|
265 |
+
model_input["audio_token_start_idx"] = (
|
266 |
+
audio_token_start_idx - prefill_start_idx
|
267 |
+
)
|
268 |
+
model_input["audio_token_len"] = audio_token_len
|
269 |
+
model_input["audio_len"] = audio_len
|
270 |
+
|
271 |
+
return model_input
|
272 |
+
|
273 |
+
@classmethod
|
274 |
+
def _create_multi_modal_projector(
|
275 |
+
cls, config: UltravoxConfig
|
276 |
+
) -> "UltravoxProjector":
|
277 |
+
projector = UltravoxProjector(config)
|
278 |
+
projector.to(config.torch_dtype)
|
279 |
+
return projector
|
280 |
+
|
281 |
+
@classmethod
|
282 |
+
def _create_audio_tower(
|
283 |
+
cls, config: UltravoxConfig
|
284 |
+
) -> Union[transformers.Wav2Vec2Model, "ModifiedWhisperEncoder"]:
|
285 |
+
if config.audio_model_id is not None:
|
286 |
+
if "whisper" in config.audio_model_id is not None:
|
287 |
+
audio_tower = ModifiedWhisperEncoder.from_pretrained(
|
288 |
+
config.audio_model_id, torch_dtype=config.torch_dtype
|
289 |
+
)
|
290 |
+
audio_tower.init_latency_mask(
|
291 |
+
config.audio_latency_block_size, dtype=config.torch_dtype
|
292 |
+
)
|
293 |
+
else:
|
294 |
+
assert config.audio_latency_block_size in (
|
295 |
+
None,
|
296 |
+
0,
|
297 |
+
), "only whisper audio tower supports audio latency masking, got non-zero value for 'audio_latency_block_size'"
|
298 |
+
audio_tower = transformers.AutoModel.from_pretrained(
|
299 |
+
config.audio_model_id, torch_dtype=config.torch_dtype
|
300 |
+
)
|
301 |
+
else:
|
302 |
+
if "whisper" in config.audio_config._name_or_path:
|
303 |
+
audio_tower = ModifiedWhisperEncoder(config.audio_config)
|
304 |
+
audio_tower.init_latency_mask(
|
305 |
+
config.audio_latency_block_size, dtype=config.torch_dtype
|
306 |
+
)
|
307 |
+
else:
|
308 |
+
assert config.audio_latency_block_size in (
|
309 |
+
None,
|
310 |
+
0,
|
311 |
+
), "only whisper audio tower supports audio latency masking, got non-zero value for 'audio_latency_block_size'"
|
312 |
+
with transformers.modeling_utils.no_init_weights():
|
313 |
+
# we only ever use from_config if the weights are retrained, hence initializing is not
|
314 |
+
# required. This makes the model quite creation faster since init on CPU is quite slow.
|
315 |
+
audio_tower = transformers.AutoModel.from_config(
|
316 |
+
config.audio_config
|
317 |
+
)
|
318 |
+
|
319 |
+
if isinstance(
|
320 |
+
audio_tower,
|
321 |
+
(transformers.Wav2Vec2BertModel, transformers.WhisperModel),
|
322 |
+
):
|
323 |
+
# For these models we only need the encoder part
|
324 |
+
# Wav2Vec2BertModel -> Wav2Vec2BertEncoder
|
325 |
+
# WhisperModel -> WhisperEncoder
|
326 |
+
audio_tower = audio_tower.encoder
|
327 |
+
|
328 |
+
audio_tower = apply_lora(audio_tower, config.audio_model_lora_config)
|
329 |
+
return audio_tower
|
330 |
+
|
331 |
+
@classmethod
|
332 |
+
def _create_language_model(
|
333 |
+
cls, config: UltravoxConfig
|
334 |
+
) -> transformers.LlamaForCausalLM:
|
335 |
+
if config.text_model_id is not None:
|
336 |
+
language_model = transformers.AutoModelForCausalLM.from_pretrained(
|
337 |
+
config.text_model_id,
|
338 |
+
attn_implementation=config._attn_implementation,
|
339 |
+
torch_dtype=config.torch_dtype,
|
340 |
+
)
|
341 |
+
else:
|
342 |
+
with transformers.modeling_utils.no_init_weights():
|
343 |
+
# we only ever use from_config if the weights are retrained, hence initializing is not
|
344 |
+
# required. This makes the model quite creation faster since init on CPU is quite slow.
|
345 |
+
language_model = transformers.AutoModelForCausalLM.from_config(
|
346 |
+
config.text_config,
|
347 |
+
attn_implementation=config._attn_implementation,
|
348 |
+
torch_dtype=config.torch_dtype,
|
349 |
+
)
|
350 |
+
|
351 |
+
language_model = apply_lora(language_model, config.text_model_lora_config)
|
352 |
+
return language_model
|
353 |
+
|
354 |
+
def merge_and_unload(self):
|
355 |
+
if isinstance(self.language_model, peft.PeftModel):
|
356 |
+
self.language_model = self.language_model.merge_and_unload()
|
357 |
+
# no need to download base language model weights anymore, so we can remove the id
|
358 |
+
self.config.text_model_id = None
|
359 |
+
self.keep_params.update(
|
360 |
+
set(
|
361 |
+
[
|
362 |
+
f"language_model.{name}"
|
363 |
+
for name, _ in self.language_model.named_parameters()
|
364 |
+
]
|
365 |
+
)
|
366 |
+
)
|
367 |
+
|
368 |
+
if isinstance(self.audio_tower, peft.PeftModel):
|
369 |
+
self.audio_tower = self.audio_tower.merge_and_unload()
|
370 |
+
# no need to download base audio model weights anymore, so we can remove the id
|
371 |
+
self.config.audio_model_id = None
|
372 |
+
self.keep_params.update(
|
373 |
+
set(
|
374 |
+
[
|
375 |
+
f"audio_tower.{name}"
|
376 |
+
for name, _ in self.audio_tower.named_parameters()
|
377 |
+
]
|
378 |
+
)
|
379 |
+
)
|
380 |
+
|
381 |
+
for param in ["text_model_lora_config", "audio_model_lora_config"]:
|
382 |
+
if hasattr(self.config, param):
|
383 |
+
delattr(self.config, param)
|
384 |
+
|
385 |
+
def push_to_hub(self, *args, **kwargs):
|
386 |
+
self.merge_and_unload()
|
387 |
+
self.to(self.language_model.dtype)
|
388 |
+
return super().push_to_hub(*args, **kwargs)
|
389 |
+
|
390 |
+
def save_pretrained(
|
391 |
+
self, *args, state_dict: Optional[Dict[str, Any]] = None, **kwargs
|
392 |
+
):
|
393 |
+
if state_dict is None:
|
394 |
+
state_dict = super().state_dict()
|
395 |
+
|
396 |
+
named_params = dict(self.named_parameters())
|
397 |
+
|
398 |
+
state_dict = {
|
399 |
+
k: v
|
400 |
+
for k, v in state_dict.items()
|
401 |
+
if k in self.keep_params
|
402 |
+
or (k in named_params and named_params[k].requires_grad)
|
403 |
+
}
|
404 |
+
|
405 |
+
super().save_pretrained(*args, state_dict=state_dict, **kwargs)
|
406 |
+
|
407 |
+
def _pre_load_state_dict_hook(self, state_dict: Dict[str, Any], *args, **kwargs):
|
408 |
+
self.keep_params.update(set(state_dict.keys()))
|
409 |
+
|
410 |
+
def print_trainable_parameters(self):
|
411 |
+
"""
|
412 |
+
Prints the number of trainable parameters in the model (reuses Peft model's method)
|
413 |
+
"""
|
414 |
+
count_params = peft.peft_model.PeftModel.get_nb_trainable_parameters
|
415 |
+
|
416 |
+
trainable_params, all_param = count_params(self)
|
417 |
+
|
418 |
+
logging.info(
|
419 |
+
f"trainable params: {trainable_params:,d} || all params: {all_param:,d}"
|
420 |
+
f" || trainable%: {100 * trainable_params / all_param:.1f}%"
|
421 |
+
)
|
422 |
+
|
423 |
+
lm_trainable_params, lm_all_params = count_params(self.language_model)
|
424 |
+
audio_trainable_params, audio_all_params = count_params(self.audio_tower)
|
425 |
+
|
426 |
+
projector_trainable_params = (
|
427 |
+
trainable_params - lm_trainable_params - audio_trainable_params
|
428 |
+
)
|
429 |
+
projector_all_params = all_param - lm_all_params - audio_all_params
|
430 |
+
|
431 |
+
logging.info(
|
432 |
+
f"Trainable%: "
|
433 |
+
f" LLM: {100 * lm_trainable_params / lm_all_params:.1f}%"
|
434 |
+
f" || Audio Encoder: {100 * audio_trainable_params / audio_all_params:.1f}%"
|
435 |
+
f" || Projector: {100 * projector_trainable_params / projector_all_params:.1f}%"
|
436 |
+
)
|
437 |
+
|
438 |
+
|
439 |
+
def is_cache_empty(
|
440 |
+
past_key_values: Optional[Union[Tuple, transformers.cache_utils.Cache]]
|
441 |
+
) -> bool:
|
442 |
+
"""
|
443 |
+
Check if the cache is empty.
|
444 |
+
"""
|
445 |
+
if past_key_values is None:
|
446 |
+
return True
|
447 |
+
if isinstance(past_key_values, tuple):
|
448 |
+
return all(len(c) == 0 for c in past_key_values)
|
449 |
+
return past_key_values.get_seq_length() == 0
|
450 |
+
|
451 |
+
|
452 |
+
def apply_lora(model: torch.nn.Module, lora_config: dict) -> torch.nn.Module:
|
453 |
+
"""
|
454 |
+
Applies LoRA finetuning to the model. If the `r` parameter is set to 0, the model is frozen instead.
|
455 |
+
"""
|
456 |
+
lora_config = peft.LoraConfig(**lora_config or {})
|
457 |
+
|
458 |
+
if lora_config.r == 0:
|
459 |
+
# freeze the model entirely
|
460 |
+
for param in model.parameters():
|
461 |
+
param.requires_grad = False
|
462 |
+
else:
|
463 |
+
model = peft.get_peft_model(model, lora_config)
|
464 |
+
|
465 |
+
return model
|
466 |
+
|
467 |
+
|
468 |
+
class StackAudioFrames(nn.Module):
|
469 |
+
"""
|
470 |
+
Stack the audio embedding frames to reduce the sequence length by a factor of `stack_factor`.
|
471 |
+
|
472 |
+
The number of output frames will be `ceil(T / stack_factor) + 1` where `T` is the number of input frames.
|
473 |
+
NOTE: the extra +1 is intentional: in case the number of audio tokens are over-estimated by the processor,
|
474 |
+
we want to make sure `processor.audio_token_replacement` (i.e. EOS) doesn't get leaked into the middle of embeddings.
|
475 |
+
In most cases this extra padding will get removed in the model's forward function so it has no effect.
|
476 |
+
"""
|
477 |
+
|
478 |
+
def __init__(self, stack_factor: int = 8):
|
479 |
+
super().__init__()
|
480 |
+
self.stack_factor = stack_factor
|
481 |
+
|
482 |
+
def forward(self, audio_embeds: torch.Tensor) -> torch.Tensor:
|
483 |
+
B, T, C = audio_embeds.shape
|
484 |
+
T_pad = (T + self.stack_factor - 1) // self.stack_factor * self.stack_factor
|
485 |
+
audio_embeds = F.pad(audio_embeds, (0, 0, 0, T_pad - T + self.stack_factor))
|
486 |
+
B, T, C = audio_embeds.shape
|
487 |
+
audio_embeds = audio_embeds.view(
|
488 |
+
B, T // self.stack_factor, C * self.stack_factor
|
489 |
+
)
|
490 |
+
return audio_embeds
|
491 |
+
|
492 |
+
|
493 |
+
class RMSNorm(transformers.models.llama.modeling_llama.LlamaRMSNorm):
|
494 |
+
def __init__(self, hidden_size: int, init: float = 1, eps: float = 1e-6):
|
495 |
+
super().__init__(hidden_size=hidden_size, eps=eps)
|
496 |
+
self.weight.data.fill_(init)
|
497 |
+
|
498 |
+
|
499 |
+
class SwiGLU(nn.Module):
|
500 |
+
def forward(self, x):
|
501 |
+
x, gate = x.chunk(2, dim=-1)
|
502 |
+
return F.silu(gate) * x
|
503 |
+
|
504 |
+
|
505 |
+
class UltravoxProjector(nn.Sequential):
|
506 |
+
def __init__(self, config: UltravoxConfig):
|
507 |
+
super().__init__()
|
508 |
+
self.hidden_dim = config.hidden_size
|
509 |
+
self._pad_and_stack = StackAudioFrames(config.stack_factor)
|
510 |
+
dim = config.audio_config.hidden_size * config.stack_factor
|
511 |
+
self.ln_pre = RMSNorm(dim, init=config.norm_init)
|
512 |
+
self.linear_1 = nn.Linear(dim, self.hidden_dim, bias=False)
|
513 |
+
dim = self.hidden_dim
|
514 |
+
self.act = transformers.activations.get_activation(config.projector_act)
|
515 |
+
dim = dim // 2 if config.projector_act == "swiglu" else dim
|
516 |
+
self.linear_2 = nn.Linear(dim, config.text_config.hidden_size, bias=False)
|
517 |
+
self.ln_post = RMSNorm(config.text_config.hidden_size, init=config.norm_init)
|
518 |
+
|
519 |
+
def forward(self, audio_features: torch.Tensor) -> torch.Tensor:
|
520 |
+
audio_features = self._pad_and_stack(audio_features)
|
521 |
+
audio_features = self.ln_pre(audio_features)
|
522 |
+
hidden_states = self.linear_1(audio_features)
|
523 |
+
hidden_states = self.act(hidden_states)
|
524 |
+
hidden_states = self.linear_2(hidden_states)
|
525 |
+
hidden_states = self.ln_post(hidden_states)
|
526 |
+
return hidden_states
|
527 |
+
|
528 |
+
|
529 |
+
class ModifiedWhisperEncoder(
|
530 |
+
whisper.WhisperEncoder, transformers.modeling_utils.ModuleUtilsMixin
|
531 |
+
):
|
532 |
+
"""
|
533 |
+
Encoder portion of OpenAI's Whisper model.
|
534 |
+
|
535 |
+
This implementation is a slightly modified version of HF Transformers' Whisper Encoder, with only a few fixes:
|
536 |
+
1. base_model_prefix updated to allow for doing `.from_pretrained` directly on the encoder
|
537 |
+
2. allow less than 30 second of audio padding to be passed in:
|
538 |
+
- relaxed ValueError check for `input_features` length to be less than or equal to `expected_seq_length` instead of strictly equal
|
539 |
+
- embed_pos is now sliced to match the length of `inputs_embeds`
|
540 |
+
|
541 |
+
Original: https://github.com/huggingface/transformers/blob/main/src/transformers/models/whisper/modeling_whisper.py
|
542 |
+
"""
|
543 |
+
|
544 |
+
base_model_prefix = "model.encoder"
|
545 |
+
_no_split_modules = ["WhisperEncoderLayer"]
|
546 |
+
|
547 |
+
def init_latency_mask(self, audio_latency_block_size: int, dtype: torch.dtype):
|
548 |
+
if audio_latency_block_size is None:
|
549 |
+
self.audio_streaming_mask = None
|
550 |
+
return
|
551 |
+
|
552 |
+
# maximum sequence length
|
553 |
+
max_seqlen = (
|
554 |
+
self.config.max_source_positions
|
555 |
+
* self.conv1.stride[0]
|
556 |
+
* self.conv2.stride[0]
|
557 |
+
)
|
558 |
+
assert (
|
559 |
+
max_seqlen > 0
|
560 |
+
), f"maximum sequence length must be positive, got {max_seqlen}"
|
561 |
+
assert (
|
562 |
+
max_seqlen % audio_latency_block_size == 0
|
563 |
+
), f"audio_latency_block_size {audio_latency_block_size} must divide {max_seqlen} evenly."
|
564 |
+
# Given the block size, we calculate number of blocks.
|
565 |
+
audio_latency_nblocks = max_seqlen // audio_latency_block_size
|
566 |
+
audio_streaming_mask = (
|
567 |
+
torch.tril(
|
568 |
+
torch.ones(audio_latency_nblocks, audio_latency_nblocks),
|
569 |
+
diagonal=0,
|
570 |
+
)
|
571 |
+
.repeat_interleave(audio_latency_block_size, dim=0)
|
572 |
+
.repeat_interleave(audio_latency_block_size, dim=1)
|
573 |
+
)
|
574 |
+
audio_streaming_mask = (1.0 - audio_streaming_mask) * torch.finfo(dtype).min
|
575 |
+
audio_streaming_mask = audio_streaming_mask[None, None, :, :]
|
576 |
+
self.register_buffer(
|
577 |
+
"audio_streaming_mask", audio_streaming_mask, persistent=False
|
578 |
+
)
|
579 |
+
|
580 |
+
def forward(
|
581 |
+
self,
|
582 |
+
input_features,
|
583 |
+
audio_len=None,
|
584 |
+
head_mask=None,
|
585 |
+
output_attentions=None,
|
586 |
+
output_hidden_states=None,
|
587 |
+
return_dict=None,
|
588 |
+
):
|
589 |
+
expected_seq_length = (
|
590 |
+
self.config.max_source_positions
|
591 |
+
* self.conv1.stride[0]
|
592 |
+
* self.conv2.stride[0]
|
593 |
+
)
|
594 |
+
if input_features.shape[-1] > expected_seq_length:
|
595 |
+
raise ValueError(
|
596 |
+
f"Whisper expects the mel input features to be of length {expected_seq_length} or less, but found {input_features.shape[-1]}. Make sure to pad the input mel features to {expected_seq_length}."
|
597 |
+
)
|
598 |
+
|
599 |
+
output_attentions = (
|
600 |
+
output_attentions
|
601 |
+
if output_attentions is not None
|
602 |
+
else self.config.output_attentions
|
603 |
+
)
|
604 |
+
output_hidden_states = (
|
605 |
+
output_hidden_states
|
606 |
+
if output_hidden_states is not None
|
607 |
+
else self.config.output_hidden_states
|
608 |
+
)
|
609 |
+
return_dict = (
|
610 |
+
return_dict if return_dict is not None else self.config.use_return_dict
|
611 |
+
)
|
612 |
+
inputs_embeds = nn.functional.gelu(self.conv1(input_features))
|
613 |
+
inputs_embeds = nn.functional.gelu(self.conv2(inputs_embeds))
|
614 |
+
|
615 |
+
inputs_embeds = inputs_embeds.permute(0, 2, 1)
|
616 |
+
embed_pos = self.embed_positions.weight[: inputs_embeds.size(-2)]
|
617 |
+
|
618 |
+
hidden_states = inputs_embeds + embed_pos
|
619 |
+
hidden_states = nn.functional.dropout(
|
620 |
+
hidden_states, p=self.dropout, training=self.training
|
621 |
+
)
|
622 |
+
|
623 |
+
encoder_states = () if output_hidden_states else None
|
624 |
+
all_attentions = () if output_attentions else None
|
625 |
+
|
626 |
+
# Create attention mask based on audio lengths to mask out padding tokens
|
627 |
+
# For each sample in batch:
|
628 |
+
# - Convert raw audio length to feature length after convolutions
|
629 |
+
# - Create boolean mask that is True for valid positions and False for padding
|
630 |
+
# - Convert to extended attention mask format expected by transformer layers
|
631 |
+
# (1.0 for positions to attend to, large negative for positions to ignore)
|
632 |
+
# This masking ensures consistent behavior between training and inference
|
633 |
+
# by preventing the model from attending to padding tokens in both cases
|
634 |
+
attention_mask = None
|
635 |
+
if audio_len != None:
|
636 |
+
audio_feature_len = self._get_feat_extract_output_lengths(audio_len)
|
637 |
+
max_seq_len = hidden_states.shape[1]
|
638 |
+
attention_mask = torch.arange(max_seq_len, device=hidden_states.device)[
|
639 |
+
None, :
|
640 |
+
].lt(audio_feature_len.view(-1, 1))
|
641 |
+
attention_mask = self.get_extended_attention_mask(
|
642 |
+
attention_mask,
|
643 |
+
None,
|
644 |
+
device=hidden_states.device,
|
645 |
+
dtype=hidden_states.dtype,
|
646 |
+
)
|
647 |
+
|
648 |
+
if self.audio_streaming_mask is not None:
|
649 |
+
seqlen = hidden_states.size(-2)
|
650 |
+
if attention_mask is not None:
|
651 |
+
attention_mask = torch.minimum(
|
652 |
+
self.audio_streaming_mask[:, :, :seqlen, :seqlen], attention_mask
|
653 |
+
) # merge
|
654 |
+
else:
|
655 |
+
attention_mask = self.audio_streaming_mask[:, :, :seqlen, :seqlen]
|
656 |
+
attention_mask = attention_mask.to(hidden_states.dtype)
|
657 |
+
|
658 |
+
# check if head_mask has a correct number of layers specified if desired
|
659 |
+
if head_mask is not None:
|
660 |
+
assert head_mask.size()[0] == (
|
661 |
+
len(self.layers)
|
662 |
+
), f"The head_mask should be specified for {len(self.layers)} layers, but it is for {head_mask.size()[0]}."
|
663 |
+
|
664 |
+
for idx, encoder_layer in enumerate(self.layers):
|
665 |
+
if output_hidden_states:
|
666 |
+
encoder_states = encoder_states + (hidden_states,)
|
667 |
+
# add LayerDrop (see https://arxiv.org/abs/1909.11556 for description)
|
668 |
+
to_drop = False
|
669 |
+
if self.training:
|
670 |
+
dropout_probability = torch.rand([])
|
671 |
+
if dropout_probability < self.layerdrop: # skip the layer
|
672 |
+
to_drop = True
|
673 |
+
|
674 |
+
if to_drop:
|
675 |
+
layer_outputs = (None, None)
|
676 |
+
else:
|
677 |
+
if self.gradient_checkpointing and self.training:
|
678 |
+
layer_outputs = self._gradient_checkpointing_func(
|
679 |
+
encoder_layer.__call__,
|
680 |
+
hidden_states,
|
681 |
+
attention_mask,
|
682 |
+
(head_mask[idx] if head_mask is not None else None),
|
683 |
+
output_attentions,
|
684 |
+
)
|
685 |
+
else:
|
686 |
+
layer_outputs = encoder_layer(
|
687 |
+
hidden_states,
|
688 |
+
attention_mask,
|
689 |
+
layer_head_mask=(
|
690 |
+
head_mask[idx] if head_mask is not None else None
|
691 |
+
),
|
692 |
+
output_attentions=output_attentions,
|
693 |
+
)
|
694 |
+
|
695 |
+
hidden_states = layer_outputs[0]
|
696 |
+
|
697 |
+
if output_attentions:
|
698 |
+
all_attentions = all_attentions + (layer_outputs[1],)
|
699 |
+
|
700 |
+
hidden_states = self.layer_norm(hidden_states)
|
701 |
+
if output_hidden_states:
|
702 |
+
encoder_states = encoder_states + (hidden_states,)
|
703 |
+
|
704 |
+
if not return_dict:
|
705 |
+
return tuple(
|
706 |
+
v
|
707 |
+
for v in [hidden_states, encoder_states, all_attentions]
|
708 |
+
if v is not None
|
709 |
+
)
|
710 |
+
return transformers.modeling_outputs.BaseModelOutput(
|
711 |
+
last_hidden_state=hidden_states,
|
712 |
+
hidden_states=encoder_states,
|
713 |
+
attentions=all_attentions,
|
714 |
+
)
|
715 |
+
|
716 |
+
|
717 |
+
UltravoxConfig.register_for_auto_class()
|
718 |
+
UltravoxModel.register_for_auto_class()
|
719 |
+
|
720 |
+
transformers.AutoConfig.register("ultravox", UltravoxConfig)
|
721 |
+
transformers.AutoModel.register(UltravoxConfig, UltravoxModel)
|
722 |
+
|
723 |
+
transformers.activations.ACT2FN["swiglu"] = SwiGLU
|
vocab.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|