Upload folder using huggingface_hub
Browse files- added_tokens.json +25 -0
- chat_template.jinja +7 -0
- config.json +153 -0
- configuration_echo.py +336 -0
- generation_config.json +14 -0
- merges.txt +0 -0
- model-00001-of-00004.safetensors +3 -0
- model-00002-of-00004.safetensors +3 -0
- model-00003-of-00004.safetensors +3 -0
- model-00004-of-00004.safetensors +3 -0
- model.safetensors.index.json +737 -0
- modeling_echo.py +1835 -0
- preprocessor_config.json +29 -0
- special_tokens_map.json +38 -0
- tokenizer_config.json +218 -0
- video_preprocessor_config.json +44 -0
- vocab.json +0 -0
added_tokens.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"</tool_call>": 151658,
|
| 3 |
+
"<tool_call>": 151657,
|
| 4 |
+
"<|MASK|>": 151665,
|
| 5 |
+
"<|box_end|>": 151649,
|
| 6 |
+
"<|box_start|>": 151648,
|
| 7 |
+
"<|endoftext|>": 151643,
|
| 8 |
+
"<|file_sep|>": 151664,
|
| 9 |
+
"<|fim_middle|>": 151660,
|
| 10 |
+
"<|fim_pad|>": 151662,
|
| 11 |
+
"<|fim_prefix|>": 151659,
|
| 12 |
+
"<|fim_suffix|>": 151661,
|
| 13 |
+
"<|im_end|>": 151645,
|
| 14 |
+
"<|im_start|>": 151644,
|
| 15 |
+
"<|image_pad|>": 151655,
|
| 16 |
+
"<|object_ref_end|>": 151647,
|
| 17 |
+
"<|object_ref_start|>": 151646,
|
| 18 |
+
"<|quad_end|>": 151651,
|
| 19 |
+
"<|quad_start|>": 151650,
|
| 20 |
+
"<|repo_name|>": 151663,
|
| 21 |
+
"<|video_pad|>": 151656,
|
| 22 |
+
"<|vision_end|>": 151653,
|
| 23 |
+
"<|vision_pad|>": 151654,
|
| 24 |
+
"<|vision_start|>": 151652
|
| 25 |
+
}
|
chat_template.jinja
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{% set image_count = namespace(value=0) %}{% set video_count = namespace(value=0) %}{% for message in messages %}{% if loop.first and message['role'] != 'system' %}<|im_start|>system
|
| 2 |
+
You are a helpful assistant.<|im_end|>
|
| 3 |
+
{% endif %}<|im_start|>{{ message['role'] }}
|
| 4 |
+
{% if message['content'] is string %}{{ message['content'] }}<|im_end|>
|
| 5 |
+
{% else %}{% for content in message['content'] %}{% if content['type'] == 'image' or 'image' in content or 'image_url' in content %}{% set image_count.value = image_count.value + 1 %}{% if add_vision_id %}Picture {{ image_count.value }}: {% endif %}<|vision_start|><|image_pad|><|vision_end|>{% elif content['type'] == 'video' or 'video' in content %}{% set video_count.value = video_count.value + 1 %}{% if add_vision_id %}Video {{ video_count.value }}: {% endif %}<|vision_start|><|video_pad|><|vision_end|>{% elif 'text' in content %}{{ content['text'] }}{% endif %}{% endfor %}<|im_end|>
|
| 6 |
+
{% endif %}{% endfor %}{% if add_generation_prompt %}<|im_start|>assistant
|
| 7 |
+
{% endif %}
|
config.json
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"EchoForConditionalGeneration"
|
| 4 |
+
],
|
| 5 |
+
"attention_dropout": 0.0,
|
| 6 |
+
"auto_map": {
|
| 7 |
+
"AutoConfig": "configuration_echo.EchoConfig",
|
| 8 |
+
"AutoModel": "modeling_echo.EchoForConditionalGeneration",
|
| 9 |
+
"AutoModelForCausalLM": "modeling_echo.EchoForConditionalGeneration"
|
| 10 |
+
},
|
| 11 |
+
"block_size": 8,
|
| 12 |
+
"distill_eos_ce": true,
|
| 13 |
+
"distill_step_weight": true,
|
| 14 |
+
"dtype": "float32",
|
| 15 |
+
"eos_token_id": 151645,
|
| 16 |
+
"hidden_act": "silu",
|
| 17 |
+
"hidden_size": 3584,
|
| 18 |
+
"image_token_id": 151655,
|
| 19 |
+
"initializer_range": 0.02,
|
| 20 |
+
"intermediate_size": 18944,
|
| 21 |
+
"mask_token_id": 151665,
|
| 22 |
+
"max_position_embeddings": 128000,
|
| 23 |
+
"max_window_layers": 28,
|
| 24 |
+
"model_type": "echo",
|
| 25 |
+
"noise_range": [
|
| 26 |
+
1.0,
|
| 27 |
+
1.0
|
| 28 |
+
],
|
| 29 |
+
"num_attention_heads": 28,
|
| 30 |
+
"num_hidden_layers": 28,
|
| 31 |
+
"num_key_value_heads": 4,
|
| 32 |
+
"pad_token_id": 151643,
|
| 33 |
+
"rms_norm_eps": 1e-06,
|
| 34 |
+
"rope_scaling": {
|
| 35 |
+
"mrope_section": [
|
| 36 |
+
16,
|
| 37 |
+
24,
|
| 38 |
+
24
|
| 39 |
+
],
|
| 40 |
+
"rope_type": "default",
|
| 41 |
+
"type": "default"
|
| 42 |
+
},
|
| 43 |
+
"rope_theta": 1000000.0,
|
| 44 |
+
"sliding_window": 32768,
|
| 45 |
+
"text_config": {
|
| 46 |
+
"architectures": [
|
| 47 |
+
"Qwen2_5_VLForConditionalGeneration"
|
| 48 |
+
],
|
| 49 |
+
"attention_dropout": 0.0,
|
| 50 |
+
"bos_token_id": 151643,
|
| 51 |
+
"dtype": "float32",
|
| 52 |
+
"eos_token_id": 151645,
|
| 53 |
+
"hidden_act": "silu",
|
| 54 |
+
"hidden_size": 3584,
|
| 55 |
+
"image_token_id": null,
|
| 56 |
+
"initializer_range": 0.02,
|
| 57 |
+
"intermediate_size": 18944,
|
| 58 |
+
"layer_types": [
|
| 59 |
+
"full_attention",
|
| 60 |
+
"full_attention",
|
| 61 |
+
"full_attention",
|
| 62 |
+
"full_attention",
|
| 63 |
+
"full_attention",
|
| 64 |
+
"full_attention",
|
| 65 |
+
"full_attention",
|
| 66 |
+
"full_attention",
|
| 67 |
+
"full_attention",
|
| 68 |
+
"full_attention",
|
| 69 |
+
"full_attention",
|
| 70 |
+
"full_attention",
|
| 71 |
+
"full_attention",
|
| 72 |
+
"full_attention",
|
| 73 |
+
"full_attention",
|
| 74 |
+
"full_attention",
|
| 75 |
+
"full_attention",
|
| 76 |
+
"full_attention",
|
| 77 |
+
"full_attention",
|
| 78 |
+
"full_attention",
|
| 79 |
+
"full_attention",
|
| 80 |
+
"full_attention",
|
| 81 |
+
"full_attention",
|
| 82 |
+
"full_attention",
|
| 83 |
+
"full_attention",
|
| 84 |
+
"full_attention",
|
| 85 |
+
"full_attention",
|
| 86 |
+
"full_attention"
|
| 87 |
+
],
|
| 88 |
+
"max_position_embeddings": 128000,
|
| 89 |
+
"max_window_layers": 28,
|
| 90 |
+
"model_type": "echo_text",
|
| 91 |
+
"num_attention_heads": 28,
|
| 92 |
+
"num_hidden_layers": 28,
|
| 93 |
+
"num_key_value_heads": 4,
|
| 94 |
+
"pad_token_id": 151643,
|
| 95 |
+
"rms_norm_eps": 1e-06,
|
| 96 |
+
"rope_scaling": {
|
| 97 |
+
"mrope_section": [
|
| 98 |
+
16,
|
| 99 |
+
24,
|
| 100 |
+
24
|
| 101 |
+
],
|
| 102 |
+
"rope_type": "default",
|
| 103 |
+
"type": "default"
|
| 104 |
+
},
|
| 105 |
+
"rope_theta": 1000000.0,
|
| 106 |
+
"sliding_window": null,
|
| 107 |
+
"torch_dtype": "bfloat16",
|
| 108 |
+
"use_cache": false,
|
| 109 |
+
"use_sliding_window": false,
|
| 110 |
+
"video_token_id": null,
|
| 111 |
+
"vision_end_token_id": 151653,
|
| 112 |
+
"vision_start_token_id": 151652,
|
| 113 |
+
"vision_token_id": 151654,
|
| 114 |
+
"vocab_size": 152064
|
| 115 |
+
},
|
| 116 |
+
"tie_word_embeddings": false,
|
| 117 |
+
"torch_dtype": "bfloat16",
|
| 118 |
+
"transformers_version": "4.55.4",
|
| 119 |
+
"use_cache": false,
|
| 120 |
+
"use_sliding_window": false,
|
| 121 |
+
"video_token_id": 151656,
|
| 122 |
+
"vision_config": {
|
| 123 |
+
"depth": 32,
|
| 124 |
+
"dtype": "float32",
|
| 125 |
+
"fullatt_block_indexes": [
|
| 126 |
+
7,
|
| 127 |
+
15,
|
| 128 |
+
23,
|
| 129 |
+
31
|
| 130 |
+
],
|
| 131 |
+
"hidden_act": "silu",
|
| 132 |
+
"hidden_size": 1280,
|
| 133 |
+
"in_channels": 3,
|
| 134 |
+
"in_chans": 3,
|
| 135 |
+
"initializer_range": 0.02,
|
| 136 |
+
"intermediate_size": 3420,
|
| 137 |
+
"model_type": "echo",
|
| 138 |
+
"num_heads": 16,
|
| 139 |
+
"out_hidden_size": 3584,
|
| 140 |
+
"pad_token_id": 151643,
|
| 141 |
+
"patch_size": 14,
|
| 142 |
+
"spatial_merge_size": 2,
|
| 143 |
+
"spatial_patch_size": 14,
|
| 144 |
+
"temporal_patch_size": 2,
|
| 145 |
+
"tokens_per_second": 2,
|
| 146 |
+
"torch_dtype": "bfloat16",
|
| 147 |
+
"window_size": 112
|
| 148 |
+
},
|
| 149 |
+
"vision_end_token_id": 151653,
|
| 150 |
+
"vision_start_token_id": 151652,
|
| 151 |
+
"vision_token_id": 151654,
|
| 152 |
+
"vocab_size": 152064
|
| 153 |
+
}
|
configuration_echo.py
ADDED
|
@@ -0,0 +1,336 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨
|
| 2 |
+
# This file was automatically generated from src/transformers/models/qwen2_5_vl/modular_qwen2_5_vl.py.
|
| 3 |
+
# Do NOT edit this file manually as any edits will be overwritten by the generation of
|
| 4 |
+
# the file from the modular. If any change should be done, please apply the change to the
|
| 5 |
+
# modular_qwen2_5_vl.py file directly. One of our CI enforces this.
|
| 6 |
+
# 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨
|
| 7 |
+
# coding=utf-8
|
| 8 |
+
# Copyright 2025 The Qwen Team and The HuggingFace Inc. team. All rights reserved.
|
| 9 |
+
#
|
| 10 |
+
# This code is based on EleutherAI's GPT-NeoX library and the GPT-NeoX
|
| 11 |
+
# and OPT implementations in this library. It has been modified from its
|
| 12 |
+
# original forms to accommodate minor architectural differences compared
|
| 13 |
+
# to GPT-NeoX and OPT used by the Meta AI team that trained the model.
|
| 14 |
+
#
|
| 15 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 16 |
+
# you may not use this file except in compliance with the License.
|
| 17 |
+
# You may obtain a copy of the License at
|
| 18 |
+
#
|
| 19 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 20 |
+
#
|
| 21 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 22 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 23 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 24 |
+
# See the License for the specific language governing permissions and
|
| 25 |
+
# limitations under the License.
|
| 26 |
+
from transformers.configuration_utils import PretrainedConfig, layer_type_validation
|
| 27 |
+
from transformers.modeling_rope_utils import rope_config_validation
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
class EchoVisionConfig(PretrainedConfig):
|
| 31 |
+
model_type = "echo"
|
| 32 |
+
base_config_key = "vision_config"
|
| 33 |
+
|
| 34 |
+
def __init__(
|
| 35 |
+
self,
|
| 36 |
+
depth=32,
|
| 37 |
+
hidden_size=3584,
|
| 38 |
+
hidden_act="silu",
|
| 39 |
+
intermediate_size=3420,
|
| 40 |
+
num_heads=16,
|
| 41 |
+
in_channels=3,
|
| 42 |
+
patch_size=14,
|
| 43 |
+
spatial_merge_size=2,
|
| 44 |
+
temporal_patch_size=2,
|
| 45 |
+
tokens_per_second=4,
|
| 46 |
+
window_size=112,
|
| 47 |
+
out_hidden_size=3584,
|
| 48 |
+
fullatt_block_indexes=[7, 15, 23, 31],
|
| 49 |
+
initializer_range=0.02,
|
| 50 |
+
**kwargs,
|
| 51 |
+
):
|
| 52 |
+
super().__init__(**kwargs)
|
| 53 |
+
|
| 54 |
+
self.depth = depth
|
| 55 |
+
self.hidden_size = hidden_size
|
| 56 |
+
self.hidden_act = hidden_act
|
| 57 |
+
self.intermediate_size = intermediate_size
|
| 58 |
+
self.num_heads = num_heads
|
| 59 |
+
self.in_channels = in_channels
|
| 60 |
+
self.patch_size = patch_size
|
| 61 |
+
self.spatial_merge_size = spatial_merge_size
|
| 62 |
+
self.temporal_patch_size = temporal_patch_size
|
| 63 |
+
self.tokens_per_second = tokens_per_second
|
| 64 |
+
self.window_size = window_size
|
| 65 |
+
self.fullatt_block_indexes = fullatt_block_indexes
|
| 66 |
+
self.out_hidden_size = out_hidden_size
|
| 67 |
+
self.initializer_range = initializer_range
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
class EchoTextConfig(PretrainedConfig):
|
| 71 |
+
r"""
|
| 72 |
+
This is the configuration class to store the configuration of a [`EchoTextModel`]. It is used to instantiate a
|
| 73 |
+
Qwen2-VL model according to the specified arguments, defining the model architecture. Instantiating a configuration
|
| 74 |
+
with the defaults will yield a similar configuration to that of
|
| 75 |
+
Qwen2-VL-7B-Instruct [Qwen/Qwen2-VL-7B-Instruct](https://huggingface.co/Qwen/Qwen2-VL-7B-Instruct).
|
| 76 |
+
|
| 77 |
+
Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
|
| 78 |
+
documentation from [`PretrainedConfig`] for more information.
|
| 79 |
+
|
| 80 |
+
Args:
|
| 81 |
+
vocab_size (`int`, *optional*, defaults to 152064):
|
| 82 |
+
Vocabulary size of the Echo model. Defines the number of different tokens that can be represented by the
|
| 83 |
+
`inputs_ids` passed when calling [`EchoModel`]
|
| 84 |
+
hidden_size (`int`, *optional*, defaults to 8192):
|
| 85 |
+
Dimension of the hidden representations.
|
| 86 |
+
intermediate_size (`int`, *optional*, defaults to 29568):
|
| 87 |
+
Dimension of the MLP representations.
|
| 88 |
+
num_hidden_layers (`int`, *optional*, defaults to 80):
|
| 89 |
+
Number of hidden layers in the Transformer encoder.
|
| 90 |
+
num_attention_heads (`int`, *optional*, defaults to 64):
|
| 91 |
+
Number of attention heads for each attention layer in the Transformer encoder.
|
| 92 |
+
num_key_value_heads (`int`, *optional*, defaults to 8):
|
| 93 |
+
This is the number of key_value heads that should be used to implement Grouped Query Attention. If
|
| 94 |
+
`num_key_value_heads=num_attention_heads`, the model will use Multi Head Attention (MHA), if
|
| 95 |
+
`num_key_value_heads=1` the model will use Multi Query Attention (MQA) otherwise GQA is used. When
|
| 96 |
+
converting a multi-head checkpoint to a GQA checkpoint, each group key and value head should be constructed
|
| 97 |
+
by meanpooling all the original heads within that group. For more details, check out [this
|
| 98 |
+
paper](https://huggingface.co/papers/2305.13245). If it is not specified, will default to `32`.
|
| 99 |
+
hidden_act (`str` or `function`, *optional*, defaults to `"silu"`):
|
| 100 |
+
The non-linear activation function (function or string) in the decoder.
|
| 101 |
+
max_position_embeddings (`int`, *optional*, defaults to 32768):
|
| 102 |
+
The maximum sequence length that this model might ever be used with.
|
| 103 |
+
initializer_range (`float`, *optional*, defaults to 0.02):
|
| 104 |
+
The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
|
| 105 |
+
rms_norm_eps (`float`, *optional*, defaults to 1e-05):
|
| 106 |
+
The epsilon used by the rms normalization layers.
|
| 107 |
+
use_cache (`bool`, *optional*, defaults to `True`):
|
| 108 |
+
Whether or not the model should return the last key/values attentions (not used by all models). Only
|
| 109 |
+
relevant if `config.is_decoder=True`.
|
| 110 |
+
tie_word_embeddings (`bool`, *optional*, defaults to `False`):
|
| 111 |
+
Whether the model's input and output word embeddings should be tied.
|
| 112 |
+
rope_theta (`float`, *optional*, defaults to 1000000.0):
|
| 113 |
+
The base period of the RoPE embeddings.
|
| 114 |
+
use_sliding_window (`bool`, *optional*, defaults to `False`):
|
| 115 |
+
Whether to use sliding window attention.
|
| 116 |
+
sliding_window (`int`, *optional*, defaults to 4096):
|
| 117 |
+
Sliding window attention (SWA) window size. If not specified, will default to `4096`.
|
| 118 |
+
max_window_layers (`int`, *optional*, defaults to 80):
|
| 119 |
+
The number of layers using full attention. The first `max_window_layers` layers will use full attention, while any
|
| 120 |
+
additional layer afterwards will use SWA (Sliding Window Attention).
|
| 121 |
+
layer_types (`list`, *optional*):
|
| 122 |
+
Attention pattern for each layer.
|
| 123 |
+
attention_dropout (`float`, *optional*, defaults to 0.0):
|
| 124 |
+
The dropout ratio for the attention probabilities.
|
| 125 |
+
rope_scaling (`Dict`, *optional*):
|
| 126 |
+
Dictionary containing the scaling configuration for the RoPE embeddings. NOTE: if you apply new rope type
|
| 127 |
+
and you expect the model to work on longer `max_position_embeddings`, we recommend you to update this value
|
| 128 |
+
accordingly.
|
| 129 |
+
Expected contents:
|
| 130 |
+
`rope_type` (`str`):
|
| 131 |
+
The sub-variant of RoPE to use. Can be one of ['default', 'linear', 'dynamic', 'yarn', 'longrope',
|
| 132 |
+
'llama3'], with 'default' being the original RoPE implementation.
|
| 133 |
+
`factor` (`float`, *optional*):
|
| 134 |
+
Used with all rope types except 'default'. The scaling factor to apply to the RoPE embeddings. In
|
| 135 |
+
most scaling types, a `factor` of x will enable the model to handle sequences of length x *
|
| 136 |
+
original maximum pre-trained length.
|
| 137 |
+
`original_max_position_embeddings` (`int`, *optional*):
|
| 138 |
+
Used with 'dynamic', 'longrope' and 'llama3'. The original max position embeddings used during
|
| 139 |
+
pretraining.
|
| 140 |
+
`attention_factor` (`float`, *optional*):
|
| 141 |
+
Used with 'yarn' and 'longrope'. The scaling factor to be applied on the attention
|
| 142 |
+
computation. If unspecified, it defaults to value recommended by the implementation, using the
|
| 143 |
+
`factor` field to infer the suggested value.
|
| 144 |
+
`beta_fast` (`float`, *optional*):
|
| 145 |
+
Only used with 'yarn'. Parameter to set the boundary for extrapolation (only) in the linear
|
| 146 |
+
ramp function. If unspecified, it defaults to 32.
|
| 147 |
+
`beta_slow` (`float`, *optional*):
|
| 148 |
+
Only used with 'yarn'. Parameter to set the boundary for interpolation (only) in the linear
|
| 149 |
+
ramp function. If unspecified, it defaults to 1.
|
| 150 |
+
`short_factor` (`list[float]`, *optional*):
|
| 151 |
+
Only used with 'longrope'. The scaling factor to be applied to short contexts (<
|
| 152 |
+
`original_max_position_embeddings`). Must be a list of numbers with the same length as the hidden
|
| 153 |
+
size divided by the number of attention heads divided by 2
|
| 154 |
+
`long_factor` (`list[float]`, *optional*):
|
| 155 |
+
Only used with 'longrope'. The scaling factor to be applied to long contexts (<
|
| 156 |
+
`original_max_position_embeddings`). Must be a list of numbers with the same length as the hidden
|
| 157 |
+
size divided by the number of attention heads divided by 2
|
| 158 |
+
`low_freq_factor` (`float`, *optional*):
|
| 159 |
+
Only used with 'llama3'. Scaling factor applied to low frequency components of the RoPE
|
| 160 |
+
`high_freq_factor` (`float`, *optional*):
|
| 161 |
+
Only used with 'llama3'. Scaling factor applied to high frequency components of the RoPE
|
| 162 |
+
image_token_id (`int`, *optional*):
|
| 163 |
+
Token index used as placeholder for image embeddings.
|
| 164 |
+
video_token_id (`int`, *optional*):
|
| 165 |
+
Token index used as placeholder for video embeddings.
|
| 166 |
+
|
| 167 |
+
```python
|
| 168 |
+
>>> from transformers import EchoTextModel, EchoConfig
|
| 169 |
+
|
| 170 |
+
>>> # Initializing a Echo style configuration
|
| 171 |
+
>>> configuration = EchoConfig()
|
| 172 |
+
|
| 173 |
+
>>> # Initializing a model from the Qwen2-VL-7B style configuration
|
| 174 |
+
>>> model = EchoTextModel(configuration)
|
| 175 |
+
|
| 176 |
+
>>> # Accessing the model configuration
|
| 177 |
+
>>> configuration = model.config
|
| 178 |
+
```"""
|
| 179 |
+
|
| 180 |
+
model_type = "echo_text"
|
| 181 |
+
base_config_key = "text_config"
|
| 182 |
+
keys_to_ignore_at_inference = ["past_key_values"]
|
| 183 |
+
# Default tensor parallel plan for base model `Echo`
|
| 184 |
+
base_model_tp_plan = {
|
| 185 |
+
"layers.*.self_attn.q_proj": "colwise",
|
| 186 |
+
"layers.*.self_attn.k_proj": "colwise",
|
| 187 |
+
"layers.*.self_attn.v_proj": "colwise",
|
| 188 |
+
"layers.*.self_attn.o_proj": "rowwise",
|
| 189 |
+
"layers.*.mlp.gate_proj": "colwise",
|
| 190 |
+
"layers.*.mlp.up_proj": "colwise",
|
| 191 |
+
"layers.*.mlp.down_proj": "rowwise",
|
| 192 |
+
}
|
| 193 |
+
base_model_pp_plan = {
|
| 194 |
+
"embed_tokens": (["input_ids"], ["inputs_embeds"]),
|
| 195 |
+
"layers": (["hidden_states", "attention_mask"], ["hidden_states"]),
|
| 196 |
+
"norm": (["hidden_states"], ["hidden_states"]),
|
| 197 |
+
}
|
| 198 |
+
|
| 199 |
+
def __init__(
|
| 200 |
+
self,
|
| 201 |
+
vocab_size=152064,
|
| 202 |
+
hidden_size=8192,
|
| 203 |
+
intermediate_size=29568,
|
| 204 |
+
num_hidden_layers=80,
|
| 205 |
+
num_attention_heads=64,
|
| 206 |
+
num_key_value_heads=8,
|
| 207 |
+
hidden_act="silu",
|
| 208 |
+
max_position_embeddings=32768,
|
| 209 |
+
initializer_range=0.02,
|
| 210 |
+
rms_norm_eps=1e-05,
|
| 211 |
+
use_cache=True,
|
| 212 |
+
tie_word_embeddings=False,
|
| 213 |
+
rope_theta=1000000.0,
|
| 214 |
+
use_sliding_window=False,
|
| 215 |
+
sliding_window=4096,
|
| 216 |
+
max_window_layers=80,
|
| 217 |
+
layer_types=None,
|
| 218 |
+
attention_dropout=0.0,
|
| 219 |
+
rope_scaling=None,
|
| 220 |
+
image_token_id=None,
|
| 221 |
+
video_token_id=None,
|
| 222 |
+
**kwargs,
|
| 223 |
+
):
|
| 224 |
+
self.vocab_size = vocab_size
|
| 225 |
+
self.max_position_embeddings = max_position_embeddings
|
| 226 |
+
self.hidden_size = hidden_size
|
| 227 |
+
self.intermediate_size = intermediate_size
|
| 228 |
+
self.num_hidden_layers = num_hidden_layers
|
| 229 |
+
self.num_attention_heads = num_attention_heads
|
| 230 |
+
self.use_sliding_window = use_sliding_window
|
| 231 |
+
self.sliding_window = sliding_window if self.use_sliding_window else None
|
| 232 |
+
self.max_window_layers = max_window_layers
|
| 233 |
+
|
| 234 |
+
# for backward compatibility
|
| 235 |
+
if num_key_value_heads is None:
|
| 236 |
+
num_key_value_heads = num_attention_heads
|
| 237 |
+
|
| 238 |
+
self.num_key_value_heads = num_key_value_heads
|
| 239 |
+
self.hidden_act = hidden_act
|
| 240 |
+
self.initializer_range = initializer_range
|
| 241 |
+
self.rms_norm_eps = rms_norm_eps
|
| 242 |
+
self.use_cache = use_cache
|
| 243 |
+
self.rope_theta = rope_theta
|
| 244 |
+
self.attention_dropout = attention_dropout
|
| 245 |
+
self.rope_scaling = rope_scaling
|
| 246 |
+
|
| 247 |
+
self.layer_types = layer_types
|
| 248 |
+
if self.layer_types is None:
|
| 249 |
+
self.layer_types = [
|
| 250 |
+
"sliding_attention"
|
| 251 |
+
if self.sliding_window is not None and i >= self.max_window_layers
|
| 252 |
+
else "full_attention"
|
| 253 |
+
for i in range(self.num_hidden_layers)
|
| 254 |
+
]
|
| 255 |
+
layer_type_validation(self.layer_types)
|
| 256 |
+
|
| 257 |
+
# Validate the correctness of rotary position embeddings parameters
|
| 258 |
+
# BC: if there is a 'type' field, move it to 'rope_type'.
|
| 259 |
+
# and change type from 'mrope' to 'default' because `mrope` does default RoPE calculations
|
| 260 |
+
# one can set it to "linear"/"dynamic" etc. to have scaled RoPE
|
| 261 |
+
# TODO: @raushan update config in the hub
|
| 262 |
+
if self.rope_scaling is not None and "type" in self.rope_scaling:
|
| 263 |
+
if self.rope_scaling["type"] == "mrope":
|
| 264 |
+
self.rope_scaling["type"] = "default"
|
| 265 |
+
self.rope_scaling["rope_type"] = self.rope_scaling["type"]
|
| 266 |
+
rope_config_validation(self, ignore_keys={"mrope_section"})
|
| 267 |
+
self.image_token_id = image_token_id
|
| 268 |
+
self.video_token_id = video_token_id
|
| 269 |
+
|
| 270 |
+
super().__init__(tie_word_embeddings=tie_word_embeddings, **kwargs)
|
| 271 |
+
|
| 272 |
+
|
| 273 |
+
class EchoConfig(PretrainedConfig):
|
| 274 |
+
r"""
|
| 275 |
+
This is the configuration class to store the configuration of a [`EchoModel`]. It is used to instantiate a
|
| 276 |
+
Qwen2-VL model according to the specified arguments, defining the model architecture. Instantiating a configuration
|
| 277 |
+
with the defaults will yield a similar configuration to that of
|
| 278 |
+
Qwen2-VL-7B-Instruct [Qwen/Qwen2-VL-7B-Instruct](https://huggingface.co/Qwen/Qwen2-VL-7B-Instruct).
|
| 279 |
+
|
| 280 |
+
Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
|
| 281 |
+
documentation from [`PretrainedConfig`] for more information.
|
| 282 |
+
|
| 283 |
+
|
| 284 |
+
Args:
|
| 285 |
+
text_config (`Union[PreTrainedConfig, dict]`, *optional*, defaults to `EchoTextConfig`):
|
| 286 |
+
The config object or dictionary of the text backbone.
|
| 287 |
+
vision_config (`Union[PreTrainedConfig, dict]`, *optional*, defaults to `EchoVisionConfig`):
|
| 288 |
+
The config object or dictionary of the vision backbone.
|
| 289 |
+
image_token_id (`int`, *optional*, defaults to 151655):
|
| 290 |
+
The image token index to encode the image prompt.
|
| 291 |
+
video_token_id (`int`, *optional*, defaults to 151656):
|
| 292 |
+
The video token index to encode the image prompt.
|
| 293 |
+
|
| 294 |
+
```python
|
| 295 |
+
>>> from transformers import EchoForConditionalGeneration, EchoConfig
|
| 296 |
+
|
| 297 |
+
>>> # Initializing a Echo style configuration
|
| 298 |
+
>>> configuration = EchoConfig()
|
| 299 |
+
|
| 300 |
+
>>> # Initializing a model from the Qwen2-VL-7B style configuration
|
| 301 |
+
>>> model = EchoForConditionalGeneration(configuration)
|
| 302 |
+
|
| 303 |
+
>>> # Accessing the model configuration
|
| 304 |
+
>>> configuration = model.config
|
| 305 |
+
```"""
|
| 306 |
+
|
| 307 |
+
model_type = "echo"
|
| 308 |
+
sub_configs = {"vision_config": EchoVisionConfig, "text_config": EchoTextConfig}
|
| 309 |
+
keys_to_ignore_at_inference = ["past_key_values"]
|
| 310 |
+
|
| 311 |
+
def __init__(
|
| 312 |
+
self,
|
| 313 |
+
text_config=None,
|
| 314 |
+
vision_config=None,
|
| 315 |
+
image_token_id=151655,
|
| 316 |
+
video_token_id=151656,
|
| 317 |
+
**kwargs,
|
| 318 |
+
):
|
| 319 |
+
if isinstance(vision_config, dict):
|
| 320 |
+
self.vision_config = self.sub_configs["vision_config"](**vision_config)
|
| 321 |
+
elif vision_config is None:
|
| 322 |
+
self.vision_config = self.sub_configs["vision_config"]()
|
| 323 |
+
|
| 324 |
+
if isinstance(text_config, dict):
|
| 325 |
+
self.text_config = self.sub_configs["text_config"](**text_config)
|
| 326 |
+
elif text_config is None:
|
| 327 |
+
# For BC use all kwargs to init `TextConfig`
|
| 328 |
+
self.text_config = self.sub_configs["text_config"](**kwargs)
|
| 329 |
+
|
| 330 |
+
self.image_token_id = image_token_id
|
| 331 |
+
self.video_token_id = video_token_id
|
| 332 |
+
|
| 333 |
+
super().__init__(**kwargs)
|
| 334 |
+
|
| 335 |
+
|
| 336 |
+
__all__ = ["EchoConfig", "EchoTextConfig"]
|
generation_config.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"bos_token_id": 151643,
|
| 3 |
+
"do_sample": true,
|
| 4 |
+
"eos_token_id": [
|
| 5 |
+
151645,
|
| 6 |
+
151643
|
| 7 |
+
],
|
| 8 |
+
"pad_token_id": 151643,
|
| 9 |
+
"repetition_penalty": 1.05,
|
| 10 |
+
"temperature": 0.1,
|
| 11 |
+
"top_k": 1,
|
| 12 |
+
"top_p": 0.001,
|
| 13 |
+
"transformers_version": "4.55.4"
|
| 14 |
+
}
|
merges.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
model-00001-of-00004.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9f6c8a7873ae71da28278ebb1fec73723d2ceeab2a16667d51fb02fca75b363b
|
| 3 |
+
size 4968246672
|
model-00002-of-00004.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:04245249555874399b9d7b8a72a0e8e3f1da61ac63d3edbb66dd7ce203f81346
|
| 3 |
+
size 4991497784
|
model-00003-of-00004.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:de3d2f3b51dc18234a89989584ba1109b7ef400cafa3e85b28e534e53e4dd4d0
|
| 3 |
+
size 4932752872
|
model-00004-of-00004.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:459ea4efae267e98e04e5a538b1779c003434cfa4e37a7708cd3c0149f40f6ea
|
| 3 |
+
size 1691924624
|
model.safetensors.index.json
ADDED
|
@@ -0,0 +1,737 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"metadata": {
|
| 3 |
+
"total_parameters": 8292166656,
|
| 4 |
+
"total_size": 16584333312
|
| 5 |
+
},
|
| 6 |
+
"weight_map": {
|
| 7 |
+
"lm_head.weight": "model-00004-of-00004.safetensors",
|
| 8 |
+
"model.language_model.embed_tokens.weight": "model-00001-of-00004.safetensors",
|
| 9 |
+
"model.language_model.layers.0.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 10 |
+
"model.language_model.layers.0.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 11 |
+
"model.language_model.layers.0.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 12 |
+
"model.language_model.layers.0.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 13 |
+
"model.language_model.layers.0.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 14 |
+
"model.language_model.layers.0.self_attn.k_proj.bias": "model-00001-of-00004.safetensors",
|
| 15 |
+
"model.language_model.layers.0.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
|
| 16 |
+
"model.language_model.layers.0.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
|
| 17 |
+
"model.language_model.layers.0.self_attn.q_proj.bias": "model-00001-of-00004.safetensors",
|
| 18 |
+
"model.language_model.layers.0.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
|
| 19 |
+
"model.language_model.layers.0.self_attn.v_proj.bias": "model-00001-of-00004.safetensors",
|
| 20 |
+
"model.language_model.layers.0.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
|
| 21 |
+
"model.language_model.layers.1.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 22 |
+
"model.language_model.layers.1.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 23 |
+
"model.language_model.layers.1.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 24 |
+
"model.language_model.layers.1.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 25 |
+
"model.language_model.layers.1.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 26 |
+
"model.language_model.layers.1.self_attn.k_proj.bias": "model-00001-of-00004.safetensors",
|
| 27 |
+
"model.language_model.layers.1.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
|
| 28 |
+
"model.language_model.layers.1.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
|
| 29 |
+
"model.language_model.layers.1.self_attn.q_proj.bias": "model-00001-of-00004.safetensors",
|
| 30 |
+
"model.language_model.layers.1.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
|
| 31 |
+
"model.language_model.layers.1.self_attn.v_proj.bias": "model-00001-of-00004.safetensors",
|
| 32 |
+
"model.language_model.layers.1.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
|
| 33 |
+
"model.language_model.layers.10.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 34 |
+
"model.language_model.layers.10.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
| 35 |
+
"model.language_model.layers.10.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
| 36 |
+
"model.language_model.layers.10.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
| 37 |
+
"model.language_model.layers.10.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 38 |
+
"model.language_model.layers.10.self_attn.k_proj.bias": "model-00002-of-00004.safetensors",
|
| 39 |
+
"model.language_model.layers.10.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
| 40 |
+
"model.language_model.layers.10.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
| 41 |
+
"model.language_model.layers.10.self_attn.q_proj.bias": "model-00002-of-00004.safetensors",
|
| 42 |
+
"model.language_model.layers.10.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
| 43 |
+
"model.language_model.layers.10.self_attn.v_proj.bias": "model-00002-of-00004.safetensors",
|
| 44 |
+
"model.language_model.layers.10.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
| 45 |
+
"model.language_model.layers.11.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 46 |
+
"model.language_model.layers.11.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
| 47 |
+
"model.language_model.layers.11.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
| 48 |
+
"model.language_model.layers.11.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
| 49 |
+
"model.language_model.layers.11.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 50 |
+
"model.language_model.layers.11.self_attn.k_proj.bias": "model-00002-of-00004.safetensors",
|
| 51 |
+
"model.language_model.layers.11.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
| 52 |
+
"model.language_model.layers.11.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
| 53 |
+
"model.language_model.layers.11.self_attn.q_proj.bias": "model-00002-of-00004.safetensors",
|
| 54 |
+
"model.language_model.layers.11.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
| 55 |
+
"model.language_model.layers.11.self_attn.v_proj.bias": "model-00002-of-00004.safetensors",
|
| 56 |
+
"model.language_model.layers.11.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
| 57 |
+
"model.language_model.layers.12.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 58 |
+
"model.language_model.layers.12.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
| 59 |
+
"model.language_model.layers.12.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
| 60 |
+
"model.language_model.layers.12.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
| 61 |
+
"model.language_model.layers.12.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 62 |
+
"model.language_model.layers.12.self_attn.k_proj.bias": "model-00002-of-00004.safetensors",
|
| 63 |
+
"model.language_model.layers.12.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
| 64 |
+
"model.language_model.layers.12.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
| 65 |
+
"model.language_model.layers.12.self_attn.q_proj.bias": "model-00002-of-00004.safetensors",
|
| 66 |
+
"model.language_model.layers.12.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
| 67 |
+
"model.language_model.layers.12.self_attn.v_proj.bias": "model-00002-of-00004.safetensors",
|
| 68 |
+
"model.language_model.layers.12.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
| 69 |
+
"model.language_model.layers.13.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 70 |
+
"model.language_model.layers.13.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
| 71 |
+
"model.language_model.layers.13.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
| 72 |
+
"model.language_model.layers.13.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
| 73 |
+
"model.language_model.layers.13.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 74 |
+
"model.language_model.layers.13.self_attn.k_proj.bias": "model-00002-of-00004.safetensors",
|
| 75 |
+
"model.language_model.layers.13.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
| 76 |
+
"model.language_model.layers.13.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
| 77 |
+
"model.language_model.layers.13.self_attn.q_proj.bias": "model-00002-of-00004.safetensors",
|
| 78 |
+
"model.language_model.layers.13.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
| 79 |
+
"model.language_model.layers.13.self_attn.v_proj.bias": "model-00002-of-00004.safetensors",
|
| 80 |
+
"model.language_model.layers.13.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
| 81 |
+
"model.language_model.layers.14.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 82 |
+
"model.language_model.layers.14.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
| 83 |
+
"model.language_model.layers.14.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
| 84 |
+
"model.language_model.layers.14.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
| 85 |
+
"model.language_model.layers.14.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 86 |
+
"model.language_model.layers.14.self_attn.k_proj.bias": "model-00002-of-00004.safetensors",
|
| 87 |
+
"model.language_model.layers.14.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
| 88 |
+
"model.language_model.layers.14.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
| 89 |
+
"model.language_model.layers.14.self_attn.q_proj.bias": "model-00002-of-00004.safetensors",
|
| 90 |
+
"model.language_model.layers.14.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
| 91 |
+
"model.language_model.layers.14.self_attn.v_proj.bias": "model-00002-of-00004.safetensors",
|
| 92 |
+
"model.language_model.layers.14.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
| 93 |
+
"model.language_model.layers.15.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 94 |
+
"model.language_model.layers.15.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
| 95 |
+
"model.language_model.layers.15.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
| 96 |
+
"model.language_model.layers.15.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
| 97 |
+
"model.language_model.layers.15.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 98 |
+
"model.language_model.layers.15.self_attn.k_proj.bias": "model-00002-of-00004.safetensors",
|
| 99 |
+
"model.language_model.layers.15.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
| 100 |
+
"model.language_model.layers.15.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
| 101 |
+
"model.language_model.layers.15.self_attn.q_proj.bias": "model-00002-of-00004.safetensors",
|
| 102 |
+
"model.language_model.layers.15.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
| 103 |
+
"model.language_model.layers.15.self_attn.v_proj.bias": "model-00002-of-00004.safetensors",
|
| 104 |
+
"model.language_model.layers.15.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
| 105 |
+
"model.language_model.layers.16.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 106 |
+
"model.language_model.layers.16.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
| 107 |
+
"model.language_model.layers.16.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
| 108 |
+
"model.language_model.layers.16.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
| 109 |
+
"model.language_model.layers.16.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 110 |
+
"model.language_model.layers.16.self_attn.k_proj.bias": "model-00002-of-00004.safetensors",
|
| 111 |
+
"model.language_model.layers.16.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
| 112 |
+
"model.language_model.layers.16.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
| 113 |
+
"model.language_model.layers.16.self_attn.q_proj.bias": "model-00002-of-00004.safetensors",
|
| 114 |
+
"model.language_model.layers.16.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
| 115 |
+
"model.language_model.layers.16.self_attn.v_proj.bias": "model-00002-of-00004.safetensors",
|
| 116 |
+
"model.language_model.layers.16.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
| 117 |
+
"model.language_model.layers.17.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 118 |
+
"model.language_model.layers.17.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
| 119 |
+
"model.language_model.layers.17.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
| 120 |
+
"model.language_model.layers.17.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
| 121 |
+
"model.language_model.layers.17.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 122 |
+
"model.language_model.layers.17.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
|
| 123 |
+
"model.language_model.layers.17.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
| 124 |
+
"model.language_model.layers.17.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
| 125 |
+
"model.language_model.layers.17.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
|
| 126 |
+
"model.language_model.layers.17.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
| 127 |
+
"model.language_model.layers.17.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
|
| 128 |
+
"model.language_model.layers.17.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
| 129 |
+
"model.language_model.layers.18.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 130 |
+
"model.language_model.layers.18.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
| 131 |
+
"model.language_model.layers.18.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
| 132 |
+
"model.language_model.layers.18.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
| 133 |
+
"model.language_model.layers.18.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 134 |
+
"model.language_model.layers.18.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
|
| 135 |
+
"model.language_model.layers.18.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
| 136 |
+
"model.language_model.layers.18.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
| 137 |
+
"model.language_model.layers.18.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
|
| 138 |
+
"model.language_model.layers.18.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
| 139 |
+
"model.language_model.layers.18.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
|
| 140 |
+
"model.language_model.layers.18.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
| 141 |
+
"model.language_model.layers.19.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 142 |
+
"model.language_model.layers.19.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
| 143 |
+
"model.language_model.layers.19.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
| 144 |
+
"model.language_model.layers.19.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
| 145 |
+
"model.language_model.layers.19.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 146 |
+
"model.language_model.layers.19.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
|
| 147 |
+
"model.language_model.layers.19.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
| 148 |
+
"model.language_model.layers.19.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
| 149 |
+
"model.language_model.layers.19.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
|
| 150 |
+
"model.language_model.layers.19.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
| 151 |
+
"model.language_model.layers.19.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
|
| 152 |
+
"model.language_model.layers.19.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
| 153 |
+
"model.language_model.layers.2.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 154 |
+
"model.language_model.layers.2.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 155 |
+
"model.language_model.layers.2.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 156 |
+
"model.language_model.layers.2.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 157 |
+
"model.language_model.layers.2.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 158 |
+
"model.language_model.layers.2.self_attn.k_proj.bias": "model-00001-of-00004.safetensors",
|
| 159 |
+
"model.language_model.layers.2.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
|
| 160 |
+
"model.language_model.layers.2.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
|
| 161 |
+
"model.language_model.layers.2.self_attn.q_proj.bias": "model-00001-of-00004.safetensors",
|
| 162 |
+
"model.language_model.layers.2.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
|
| 163 |
+
"model.language_model.layers.2.self_attn.v_proj.bias": "model-00001-of-00004.safetensors",
|
| 164 |
+
"model.language_model.layers.2.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
|
| 165 |
+
"model.language_model.layers.20.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 166 |
+
"model.language_model.layers.20.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
| 167 |
+
"model.language_model.layers.20.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
| 168 |
+
"model.language_model.layers.20.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
| 169 |
+
"model.language_model.layers.20.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 170 |
+
"model.language_model.layers.20.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
|
| 171 |
+
"model.language_model.layers.20.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
| 172 |
+
"model.language_model.layers.20.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
| 173 |
+
"model.language_model.layers.20.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
|
| 174 |
+
"model.language_model.layers.20.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
| 175 |
+
"model.language_model.layers.20.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
|
| 176 |
+
"model.language_model.layers.20.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
| 177 |
+
"model.language_model.layers.21.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 178 |
+
"model.language_model.layers.21.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
| 179 |
+
"model.language_model.layers.21.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
| 180 |
+
"model.language_model.layers.21.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
| 181 |
+
"model.language_model.layers.21.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 182 |
+
"model.language_model.layers.21.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
|
| 183 |
+
"model.language_model.layers.21.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
| 184 |
+
"model.language_model.layers.21.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
| 185 |
+
"model.language_model.layers.21.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
|
| 186 |
+
"model.language_model.layers.21.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
| 187 |
+
"model.language_model.layers.21.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
|
| 188 |
+
"model.language_model.layers.21.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
| 189 |
+
"model.language_model.layers.22.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 190 |
+
"model.language_model.layers.22.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
| 191 |
+
"model.language_model.layers.22.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
| 192 |
+
"model.language_model.layers.22.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
| 193 |
+
"model.language_model.layers.22.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 194 |
+
"model.language_model.layers.22.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
|
| 195 |
+
"model.language_model.layers.22.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
| 196 |
+
"model.language_model.layers.22.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
| 197 |
+
"model.language_model.layers.22.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
|
| 198 |
+
"model.language_model.layers.22.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
| 199 |
+
"model.language_model.layers.22.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
|
| 200 |
+
"model.language_model.layers.22.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
| 201 |
+
"model.language_model.layers.23.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 202 |
+
"model.language_model.layers.23.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
| 203 |
+
"model.language_model.layers.23.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
| 204 |
+
"model.language_model.layers.23.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
| 205 |
+
"model.language_model.layers.23.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 206 |
+
"model.language_model.layers.23.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
|
| 207 |
+
"model.language_model.layers.23.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
| 208 |
+
"model.language_model.layers.23.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
| 209 |
+
"model.language_model.layers.23.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
|
| 210 |
+
"model.language_model.layers.23.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
| 211 |
+
"model.language_model.layers.23.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
|
| 212 |
+
"model.language_model.layers.23.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
| 213 |
+
"model.language_model.layers.24.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 214 |
+
"model.language_model.layers.24.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
| 215 |
+
"model.language_model.layers.24.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
| 216 |
+
"model.language_model.layers.24.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
| 217 |
+
"model.language_model.layers.24.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 218 |
+
"model.language_model.layers.24.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
|
| 219 |
+
"model.language_model.layers.24.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
| 220 |
+
"model.language_model.layers.24.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
| 221 |
+
"model.language_model.layers.24.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
|
| 222 |
+
"model.language_model.layers.24.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
| 223 |
+
"model.language_model.layers.24.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
|
| 224 |
+
"model.language_model.layers.24.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
| 225 |
+
"model.language_model.layers.25.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 226 |
+
"model.language_model.layers.25.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
| 227 |
+
"model.language_model.layers.25.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
| 228 |
+
"model.language_model.layers.25.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
| 229 |
+
"model.language_model.layers.25.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 230 |
+
"model.language_model.layers.25.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
|
| 231 |
+
"model.language_model.layers.25.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
| 232 |
+
"model.language_model.layers.25.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
| 233 |
+
"model.language_model.layers.25.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
|
| 234 |
+
"model.language_model.layers.25.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
| 235 |
+
"model.language_model.layers.25.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
|
| 236 |
+
"model.language_model.layers.25.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
| 237 |
+
"model.language_model.layers.26.input_layernorm.weight": "model-00004-of-00004.safetensors",
|
| 238 |
+
"model.language_model.layers.26.mlp.down_proj.weight": "model-00004-of-00004.safetensors",
|
| 239 |
+
"model.language_model.layers.26.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
| 240 |
+
"model.language_model.layers.26.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
| 241 |
+
"model.language_model.layers.26.post_attention_layernorm.weight": "model-00004-of-00004.safetensors",
|
| 242 |
+
"model.language_model.layers.26.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
|
| 243 |
+
"model.language_model.layers.26.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
| 244 |
+
"model.language_model.layers.26.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
| 245 |
+
"model.language_model.layers.26.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
|
| 246 |
+
"model.language_model.layers.26.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
| 247 |
+
"model.language_model.layers.26.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
|
| 248 |
+
"model.language_model.layers.26.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
| 249 |
+
"model.language_model.layers.27.input_layernorm.weight": "model-00004-of-00004.safetensors",
|
| 250 |
+
"model.language_model.layers.27.mlp.down_proj.weight": "model-00004-of-00004.safetensors",
|
| 251 |
+
"model.language_model.layers.27.mlp.gate_proj.weight": "model-00004-of-00004.safetensors",
|
| 252 |
+
"model.language_model.layers.27.mlp.up_proj.weight": "model-00004-of-00004.safetensors",
|
| 253 |
+
"model.language_model.layers.27.post_attention_layernorm.weight": "model-00004-of-00004.safetensors",
|
| 254 |
+
"model.language_model.layers.27.self_attn.k_proj.bias": "model-00004-of-00004.safetensors",
|
| 255 |
+
"model.language_model.layers.27.self_attn.k_proj.weight": "model-00004-of-00004.safetensors",
|
| 256 |
+
"model.language_model.layers.27.self_attn.o_proj.weight": "model-00004-of-00004.safetensors",
|
| 257 |
+
"model.language_model.layers.27.self_attn.q_proj.bias": "model-00004-of-00004.safetensors",
|
| 258 |
+
"model.language_model.layers.27.self_attn.q_proj.weight": "model-00004-of-00004.safetensors",
|
| 259 |
+
"model.language_model.layers.27.self_attn.v_proj.bias": "model-00004-of-00004.safetensors",
|
| 260 |
+
"model.language_model.layers.27.self_attn.v_proj.weight": "model-00004-of-00004.safetensors",
|
| 261 |
+
"model.language_model.layers.3.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 262 |
+
"model.language_model.layers.3.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 263 |
+
"model.language_model.layers.3.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 264 |
+
"model.language_model.layers.3.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 265 |
+
"model.language_model.layers.3.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 266 |
+
"model.language_model.layers.3.self_attn.k_proj.bias": "model-00001-of-00004.safetensors",
|
| 267 |
+
"model.language_model.layers.3.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
|
| 268 |
+
"model.language_model.layers.3.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
|
| 269 |
+
"model.language_model.layers.3.self_attn.q_proj.bias": "model-00001-of-00004.safetensors",
|
| 270 |
+
"model.language_model.layers.3.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
|
| 271 |
+
"model.language_model.layers.3.self_attn.v_proj.bias": "model-00001-of-00004.safetensors",
|
| 272 |
+
"model.language_model.layers.3.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
|
| 273 |
+
"model.language_model.layers.4.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 274 |
+
"model.language_model.layers.4.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 275 |
+
"model.language_model.layers.4.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 276 |
+
"model.language_model.layers.4.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 277 |
+
"model.language_model.layers.4.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 278 |
+
"model.language_model.layers.4.self_attn.k_proj.bias": "model-00001-of-00004.safetensors",
|
| 279 |
+
"model.language_model.layers.4.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
|
| 280 |
+
"model.language_model.layers.4.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
|
| 281 |
+
"model.language_model.layers.4.self_attn.q_proj.bias": "model-00001-of-00004.safetensors",
|
| 282 |
+
"model.language_model.layers.4.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
|
| 283 |
+
"model.language_model.layers.4.self_attn.v_proj.bias": "model-00001-of-00004.safetensors",
|
| 284 |
+
"model.language_model.layers.4.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
|
| 285 |
+
"model.language_model.layers.5.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 286 |
+
"model.language_model.layers.5.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
| 287 |
+
"model.language_model.layers.5.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 288 |
+
"model.language_model.layers.5.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
| 289 |
+
"model.language_model.layers.5.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 290 |
+
"model.language_model.layers.5.self_attn.k_proj.bias": "model-00001-of-00004.safetensors",
|
| 291 |
+
"model.language_model.layers.5.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
|
| 292 |
+
"model.language_model.layers.5.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
|
| 293 |
+
"model.language_model.layers.5.self_attn.q_proj.bias": "model-00001-of-00004.safetensors",
|
| 294 |
+
"model.language_model.layers.5.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
|
| 295 |
+
"model.language_model.layers.5.self_attn.v_proj.bias": "model-00001-of-00004.safetensors",
|
| 296 |
+
"model.language_model.layers.5.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
|
| 297 |
+
"model.language_model.layers.6.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 298 |
+
"model.language_model.layers.6.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
| 299 |
+
"model.language_model.layers.6.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
| 300 |
+
"model.language_model.layers.6.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
| 301 |
+
"model.language_model.layers.6.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 302 |
+
"model.language_model.layers.6.self_attn.k_proj.bias": "model-00002-of-00004.safetensors",
|
| 303 |
+
"model.language_model.layers.6.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
| 304 |
+
"model.language_model.layers.6.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
| 305 |
+
"model.language_model.layers.6.self_attn.q_proj.bias": "model-00002-of-00004.safetensors",
|
| 306 |
+
"model.language_model.layers.6.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
| 307 |
+
"model.language_model.layers.6.self_attn.v_proj.bias": "model-00002-of-00004.safetensors",
|
| 308 |
+
"model.language_model.layers.6.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
| 309 |
+
"model.language_model.layers.7.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 310 |
+
"model.language_model.layers.7.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
| 311 |
+
"model.language_model.layers.7.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
| 312 |
+
"model.language_model.layers.7.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
| 313 |
+
"model.language_model.layers.7.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 314 |
+
"model.language_model.layers.7.self_attn.k_proj.bias": "model-00002-of-00004.safetensors",
|
| 315 |
+
"model.language_model.layers.7.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
| 316 |
+
"model.language_model.layers.7.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
| 317 |
+
"model.language_model.layers.7.self_attn.q_proj.bias": "model-00002-of-00004.safetensors",
|
| 318 |
+
"model.language_model.layers.7.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
| 319 |
+
"model.language_model.layers.7.self_attn.v_proj.bias": "model-00002-of-00004.safetensors",
|
| 320 |
+
"model.language_model.layers.7.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
| 321 |
+
"model.language_model.layers.8.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 322 |
+
"model.language_model.layers.8.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
| 323 |
+
"model.language_model.layers.8.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
| 324 |
+
"model.language_model.layers.8.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
| 325 |
+
"model.language_model.layers.8.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 326 |
+
"model.language_model.layers.8.self_attn.k_proj.bias": "model-00002-of-00004.safetensors",
|
| 327 |
+
"model.language_model.layers.8.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
| 328 |
+
"model.language_model.layers.8.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
| 329 |
+
"model.language_model.layers.8.self_attn.q_proj.bias": "model-00002-of-00004.safetensors",
|
| 330 |
+
"model.language_model.layers.8.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
| 331 |
+
"model.language_model.layers.8.self_attn.v_proj.bias": "model-00002-of-00004.safetensors",
|
| 332 |
+
"model.language_model.layers.8.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
| 333 |
+
"model.language_model.layers.9.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 334 |
+
"model.language_model.layers.9.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
| 335 |
+
"model.language_model.layers.9.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
| 336 |
+
"model.language_model.layers.9.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
| 337 |
+
"model.language_model.layers.9.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 338 |
+
"model.language_model.layers.9.self_attn.k_proj.bias": "model-00002-of-00004.safetensors",
|
| 339 |
+
"model.language_model.layers.9.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
| 340 |
+
"model.language_model.layers.9.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
| 341 |
+
"model.language_model.layers.9.self_attn.q_proj.bias": "model-00002-of-00004.safetensors",
|
| 342 |
+
"model.language_model.layers.9.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
| 343 |
+
"model.language_model.layers.9.self_attn.v_proj.bias": "model-00002-of-00004.safetensors",
|
| 344 |
+
"model.language_model.layers.9.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
| 345 |
+
"model.language_model.norm.weight": "model-00004-of-00004.safetensors",
|
| 346 |
+
"model.visual.blocks.0.attn.proj.bias": "model-00001-of-00004.safetensors",
|
| 347 |
+
"model.visual.blocks.0.attn.proj.weight": "model-00001-of-00004.safetensors",
|
| 348 |
+
"model.visual.blocks.0.attn.qkv.bias": "model-00001-of-00004.safetensors",
|
| 349 |
+
"model.visual.blocks.0.attn.qkv.weight": "model-00001-of-00004.safetensors",
|
| 350 |
+
"model.visual.blocks.0.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
|
| 351 |
+
"model.visual.blocks.0.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 352 |
+
"model.visual.blocks.0.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
|
| 353 |
+
"model.visual.blocks.0.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 354 |
+
"model.visual.blocks.0.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
|
| 355 |
+
"model.visual.blocks.0.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 356 |
+
"model.visual.blocks.0.norm1.weight": "model-00001-of-00004.safetensors",
|
| 357 |
+
"model.visual.blocks.0.norm2.weight": "model-00001-of-00004.safetensors",
|
| 358 |
+
"model.visual.blocks.1.attn.proj.bias": "model-00001-of-00004.safetensors",
|
| 359 |
+
"model.visual.blocks.1.attn.proj.weight": "model-00001-of-00004.safetensors",
|
| 360 |
+
"model.visual.blocks.1.attn.qkv.bias": "model-00001-of-00004.safetensors",
|
| 361 |
+
"model.visual.blocks.1.attn.qkv.weight": "model-00001-of-00004.safetensors",
|
| 362 |
+
"model.visual.blocks.1.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
|
| 363 |
+
"model.visual.blocks.1.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 364 |
+
"model.visual.blocks.1.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
|
| 365 |
+
"model.visual.blocks.1.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 366 |
+
"model.visual.blocks.1.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
|
| 367 |
+
"model.visual.blocks.1.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 368 |
+
"model.visual.blocks.1.norm1.weight": "model-00001-of-00004.safetensors",
|
| 369 |
+
"model.visual.blocks.1.norm2.weight": "model-00001-of-00004.safetensors",
|
| 370 |
+
"model.visual.blocks.10.attn.proj.bias": "model-00001-of-00004.safetensors",
|
| 371 |
+
"model.visual.blocks.10.attn.proj.weight": "model-00001-of-00004.safetensors",
|
| 372 |
+
"model.visual.blocks.10.attn.qkv.bias": "model-00001-of-00004.safetensors",
|
| 373 |
+
"model.visual.blocks.10.attn.qkv.weight": "model-00001-of-00004.safetensors",
|
| 374 |
+
"model.visual.blocks.10.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
|
| 375 |
+
"model.visual.blocks.10.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 376 |
+
"model.visual.blocks.10.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
|
| 377 |
+
"model.visual.blocks.10.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 378 |
+
"model.visual.blocks.10.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
|
| 379 |
+
"model.visual.blocks.10.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 380 |
+
"model.visual.blocks.10.norm1.weight": "model-00001-of-00004.safetensors",
|
| 381 |
+
"model.visual.blocks.10.norm2.weight": "model-00001-of-00004.safetensors",
|
| 382 |
+
"model.visual.blocks.11.attn.proj.bias": "model-00001-of-00004.safetensors",
|
| 383 |
+
"model.visual.blocks.11.attn.proj.weight": "model-00001-of-00004.safetensors",
|
| 384 |
+
"model.visual.blocks.11.attn.qkv.bias": "model-00001-of-00004.safetensors",
|
| 385 |
+
"model.visual.blocks.11.attn.qkv.weight": "model-00001-of-00004.safetensors",
|
| 386 |
+
"model.visual.blocks.11.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
|
| 387 |
+
"model.visual.blocks.11.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 388 |
+
"model.visual.blocks.11.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
|
| 389 |
+
"model.visual.blocks.11.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 390 |
+
"model.visual.blocks.11.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
|
| 391 |
+
"model.visual.blocks.11.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 392 |
+
"model.visual.blocks.11.norm1.weight": "model-00001-of-00004.safetensors",
|
| 393 |
+
"model.visual.blocks.11.norm2.weight": "model-00001-of-00004.safetensors",
|
| 394 |
+
"model.visual.blocks.12.attn.proj.bias": "model-00001-of-00004.safetensors",
|
| 395 |
+
"model.visual.blocks.12.attn.proj.weight": "model-00001-of-00004.safetensors",
|
| 396 |
+
"model.visual.blocks.12.attn.qkv.bias": "model-00001-of-00004.safetensors",
|
| 397 |
+
"model.visual.blocks.12.attn.qkv.weight": "model-00001-of-00004.safetensors",
|
| 398 |
+
"model.visual.blocks.12.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
|
| 399 |
+
"model.visual.blocks.12.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 400 |
+
"model.visual.blocks.12.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
|
| 401 |
+
"model.visual.blocks.12.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 402 |
+
"model.visual.blocks.12.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
|
| 403 |
+
"model.visual.blocks.12.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 404 |
+
"model.visual.blocks.12.norm1.weight": "model-00001-of-00004.safetensors",
|
| 405 |
+
"model.visual.blocks.12.norm2.weight": "model-00001-of-00004.safetensors",
|
| 406 |
+
"model.visual.blocks.13.attn.proj.bias": "model-00001-of-00004.safetensors",
|
| 407 |
+
"model.visual.blocks.13.attn.proj.weight": "model-00001-of-00004.safetensors",
|
| 408 |
+
"model.visual.blocks.13.attn.qkv.bias": "model-00001-of-00004.safetensors",
|
| 409 |
+
"model.visual.blocks.13.attn.qkv.weight": "model-00001-of-00004.safetensors",
|
| 410 |
+
"model.visual.blocks.13.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
|
| 411 |
+
"model.visual.blocks.13.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 412 |
+
"model.visual.blocks.13.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
|
| 413 |
+
"model.visual.blocks.13.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 414 |
+
"model.visual.blocks.13.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
|
| 415 |
+
"model.visual.blocks.13.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 416 |
+
"model.visual.blocks.13.norm1.weight": "model-00001-of-00004.safetensors",
|
| 417 |
+
"model.visual.blocks.13.norm2.weight": "model-00001-of-00004.safetensors",
|
| 418 |
+
"model.visual.blocks.14.attn.proj.bias": "model-00001-of-00004.safetensors",
|
| 419 |
+
"model.visual.blocks.14.attn.proj.weight": "model-00001-of-00004.safetensors",
|
| 420 |
+
"model.visual.blocks.14.attn.qkv.bias": "model-00001-of-00004.safetensors",
|
| 421 |
+
"model.visual.blocks.14.attn.qkv.weight": "model-00001-of-00004.safetensors",
|
| 422 |
+
"model.visual.blocks.14.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
|
| 423 |
+
"model.visual.blocks.14.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 424 |
+
"model.visual.blocks.14.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
|
| 425 |
+
"model.visual.blocks.14.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 426 |
+
"model.visual.blocks.14.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
|
| 427 |
+
"model.visual.blocks.14.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 428 |
+
"model.visual.blocks.14.norm1.weight": "model-00001-of-00004.safetensors",
|
| 429 |
+
"model.visual.blocks.14.norm2.weight": "model-00001-of-00004.safetensors",
|
| 430 |
+
"model.visual.blocks.15.attn.proj.bias": "model-00001-of-00004.safetensors",
|
| 431 |
+
"model.visual.blocks.15.attn.proj.weight": "model-00001-of-00004.safetensors",
|
| 432 |
+
"model.visual.blocks.15.attn.qkv.bias": "model-00001-of-00004.safetensors",
|
| 433 |
+
"model.visual.blocks.15.attn.qkv.weight": "model-00001-of-00004.safetensors",
|
| 434 |
+
"model.visual.blocks.15.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
|
| 435 |
+
"model.visual.blocks.15.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 436 |
+
"model.visual.blocks.15.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
|
| 437 |
+
"model.visual.blocks.15.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 438 |
+
"model.visual.blocks.15.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
|
| 439 |
+
"model.visual.blocks.15.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 440 |
+
"model.visual.blocks.15.norm1.weight": "model-00001-of-00004.safetensors",
|
| 441 |
+
"model.visual.blocks.15.norm2.weight": "model-00001-of-00004.safetensors",
|
| 442 |
+
"model.visual.blocks.16.attn.proj.bias": "model-00001-of-00004.safetensors",
|
| 443 |
+
"model.visual.blocks.16.attn.proj.weight": "model-00001-of-00004.safetensors",
|
| 444 |
+
"model.visual.blocks.16.attn.qkv.bias": "model-00001-of-00004.safetensors",
|
| 445 |
+
"model.visual.blocks.16.attn.qkv.weight": "model-00001-of-00004.safetensors",
|
| 446 |
+
"model.visual.blocks.16.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
|
| 447 |
+
"model.visual.blocks.16.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 448 |
+
"model.visual.blocks.16.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
|
| 449 |
+
"model.visual.blocks.16.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 450 |
+
"model.visual.blocks.16.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
|
| 451 |
+
"model.visual.blocks.16.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 452 |
+
"model.visual.blocks.16.norm1.weight": "model-00001-of-00004.safetensors",
|
| 453 |
+
"model.visual.blocks.16.norm2.weight": "model-00001-of-00004.safetensors",
|
| 454 |
+
"model.visual.blocks.17.attn.proj.bias": "model-00001-of-00004.safetensors",
|
| 455 |
+
"model.visual.blocks.17.attn.proj.weight": "model-00001-of-00004.safetensors",
|
| 456 |
+
"model.visual.blocks.17.attn.qkv.bias": "model-00001-of-00004.safetensors",
|
| 457 |
+
"model.visual.blocks.17.attn.qkv.weight": "model-00001-of-00004.safetensors",
|
| 458 |
+
"model.visual.blocks.17.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
|
| 459 |
+
"model.visual.blocks.17.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 460 |
+
"model.visual.blocks.17.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
|
| 461 |
+
"model.visual.blocks.17.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 462 |
+
"model.visual.blocks.17.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
|
| 463 |
+
"model.visual.blocks.17.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 464 |
+
"model.visual.blocks.17.norm1.weight": "model-00001-of-00004.safetensors",
|
| 465 |
+
"model.visual.blocks.17.norm2.weight": "model-00001-of-00004.safetensors",
|
| 466 |
+
"model.visual.blocks.18.attn.proj.bias": "model-00001-of-00004.safetensors",
|
| 467 |
+
"model.visual.blocks.18.attn.proj.weight": "model-00001-of-00004.safetensors",
|
| 468 |
+
"model.visual.blocks.18.attn.qkv.bias": "model-00001-of-00004.safetensors",
|
| 469 |
+
"model.visual.blocks.18.attn.qkv.weight": "model-00001-of-00004.safetensors",
|
| 470 |
+
"model.visual.blocks.18.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
|
| 471 |
+
"model.visual.blocks.18.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 472 |
+
"model.visual.blocks.18.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
|
| 473 |
+
"model.visual.blocks.18.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 474 |
+
"model.visual.blocks.18.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
|
| 475 |
+
"model.visual.blocks.18.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 476 |
+
"model.visual.blocks.18.norm1.weight": "model-00001-of-00004.safetensors",
|
| 477 |
+
"model.visual.blocks.18.norm2.weight": "model-00001-of-00004.safetensors",
|
| 478 |
+
"model.visual.blocks.19.attn.proj.bias": "model-00001-of-00004.safetensors",
|
| 479 |
+
"model.visual.blocks.19.attn.proj.weight": "model-00001-of-00004.safetensors",
|
| 480 |
+
"model.visual.blocks.19.attn.qkv.bias": "model-00001-of-00004.safetensors",
|
| 481 |
+
"model.visual.blocks.19.attn.qkv.weight": "model-00001-of-00004.safetensors",
|
| 482 |
+
"model.visual.blocks.19.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
|
| 483 |
+
"model.visual.blocks.19.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 484 |
+
"model.visual.blocks.19.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
|
| 485 |
+
"model.visual.blocks.19.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 486 |
+
"model.visual.blocks.19.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
|
| 487 |
+
"model.visual.blocks.19.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 488 |
+
"model.visual.blocks.19.norm1.weight": "model-00001-of-00004.safetensors",
|
| 489 |
+
"model.visual.blocks.19.norm2.weight": "model-00001-of-00004.safetensors",
|
| 490 |
+
"model.visual.blocks.2.attn.proj.bias": "model-00001-of-00004.safetensors",
|
| 491 |
+
"model.visual.blocks.2.attn.proj.weight": "model-00001-of-00004.safetensors",
|
| 492 |
+
"model.visual.blocks.2.attn.qkv.bias": "model-00001-of-00004.safetensors",
|
| 493 |
+
"model.visual.blocks.2.attn.qkv.weight": "model-00001-of-00004.safetensors",
|
| 494 |
+
"model.visual.blocks.2.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
|
| 495 |
+
"model.visual.blocks.2.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 496 |
+
"model.visual.blocks.2.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
|
| 497 |
+
"model.visual.blocks.2.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 498 |
+
"model.visual.blocks.2.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
|
| 499 |
+
"model.visual.blocks.2.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 500 |
+
"model.visual.blocks.2.norm1.weight": "model-00001-of-00004.safetensors",
|
| 501 |
+
"model.visual.blocks.2.norm2.weight": "model-00001-of-00004.safetensors",
|
| 502 |
+
"model.visual.blocks.20.attn.proj.bias": "model-00001-of-00004.safetensors",
|
| 503 |
+
"model.visual.blocks.20.attn.proj.weight": "model-00001-of-00004.safetensors",
|
| 504 |
+
"model.visual.blocks.20.attn.qkv.bias": "model-00001-of-00004.safetensors",
|
| 505 |
+
"model.visual.blocks.20.attn.qkv.weight": "model-00001-of-00004.safetensors",
|
| 506 |
+
"model.visual.blocks.20.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
|
| 507 |
+
"model.visual.blocks.20.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 508 |
+
"model.visual.blocks.20.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
|
| 509 |
+
"model.visual.blocks.20.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 510 |
+
"model.visual.blocks.20.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
|
| 511 |
+
"model.visual.blocks.20.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 512 |
+
"model.visual.blocks.20.norm1.weight": "model-00001-of-00004.safetensors",
|
| 513 |
+
"model.visual.blocks.20.norm2.weight": "model-00001-of-00004.safetensors",
|
| 514 |
+
"model.visual.blocks.21.attn.proj.bias": "model-00001-of-00004.safetensors",
|
| 515 |
+
"model.visual.blocks.21.attn.proj.weight": "model-00001-of-00004.safetensors",
|
| 516 |
+
"model.visual.blocks.21.attn.qkv.bias": "model-00001-of-00004.safetensors",
|
| 517 |
+
"model.visual.blocks.21.attn.qkv.weight": "model-00001-of-00004.safetensors",
|
| 518 |
+
"model.visual.blocks.21.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
|
| 519 |
+
"model.visual.blocks.21.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 520 |
+
"model.visual.blocks.21.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
|
| 521 |
+
"model.visual.blocks.21.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 522 |
+
"model.visual.blocks.21.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
|
| 523 |
+
"model.visual.blocks.21.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 524 |
+
"model.visual.blocks.21.norm1.weight": "model-00001-of-00004.safetensors",
|
| 525 |
+
"model.visual.blocks.21.norm2.weight": "model-00001-of-00004.safetensors",
|
| 526 |
+
"model.visual.blocks.22.attn.proj.bias": "model-00001-of-00004.safetensors",
|
| 527 |
+
"model.visual.blocks.22.attn.proj.weight": "model-00001-of-00004.safetensors",
|
| 528 |
+
"model.visual.blocks.22.attn.qkv.bias": "model-00001-of-00004.safetensors",
|
| 529 |
+
"model.visual.blocks.22.attn.qkv.weight": "model-00001-of-00004.safetensors",
|
| 530 |
+
"model.visual.blocks.22.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
|
| 531 |
+
"model.visual.blocks.22.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 532 |
+
"model.visual.blocks.22.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
|
| 533 |
+
"model.visual.blocks.22.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 534 |
+
"model.visual.blocks.22.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
|
| 535 |
+
"model.visual.blocks.22.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 536 |
+
"model.visual.blocks.22.norm1.weight": "model-00001-of-00004.safetensors",
|
| 537 |
+
"model.visual.blocks.22.norm2.weight": "model-00001-of-00004.safetensors",
|
| 538 |
+
"model.visual.blocks.23.attn.proj.bias": "model-00001-of-00004.safetensors",
|
| 539 |
+
"model.visual.blocks.23.attn.proj.weight": "model-00001-of-00004.safetensors",
|
| 540 |
+
"model.visual.blocks.23.attn.qkv.bias": "model-00001-of-00004.safetensors",
|
| 541 |
+
"model.visual.blocks.23.attn.qkv.weight": "model-00001-of-00004.safetensors",
|
| 542 |
+
"model.visual.blocks.23.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
|
| 543 |
+
"model.visual.blocks.23.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 544 |
+
"model.visual.blocks.23.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
|
| 545 |
+
"model.visual.blocks.23.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 546 |
+
"model.visual.blocks.23.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
|
| 547 |
+
"model.visual.blocks.23.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 548 |
+
"model.visual.blocks.23.norm1.weight": "model-00001-of-00004.safetensors",
|
| 549 |
+
"model.visual.blocks.23.norm2.weight": "model-00001-of-00004.safetensors",
|
| 550 |
+
"model.visual.blocks.24.attn.proj.bias": "model-00001-of-00004.safetensors",
|
| 551 |
+
"model.visual.blocks.24.attn.proj.weight": "model-00001-of-00004.safetensors",
|
| 552 |
+
"model.visual.blocks.24.attn.qkv.bias": "model-00001-of-00004.safetensors",
|
| 553 |
+
"model.visual.blocks.24.attn.qkv.weight": "model-00001-of-00004.safetensors",
|
| 554 |
+
"model.visual.blocks.24.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
|
| 555 |
+
"model.visual.blocks.24.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 556 |
+
"model.visual.blocks.24.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
|
| 557 |
+
"model.visual.blocks.24.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 558 |
+
"model.visual.blocks.24.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
|
| 559 |
+
"model.visual.blocks.24.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 560 |
+
"model.visual.blocks.24.norm1.weight": "model-00001-of-00004.safetensors",
|
| 561 |
+
"model.visual.blocks.24.norm2.weight": "model-00001-of-00004.safetensors",
|
| 562 |
+
"model.visual.blocks.25.attn.proj.bias": "model-00001-of-00004.safetensors",
|
| 563 |
+
"model.visual.blocks.25.attn.proj.weight": "model-00001-of-00004.safetensors",
|
| 564 |
+
"model.visual.blocks.25.attn.qkv.bias": "model-00001-of-00004.safetensors",
|
| 565 |
+
"model.visual.blocks.25.attn.qkv.weight": "model-00001-of-00004.safetensors",
|
| 566 |
+
"model.visual.blocks.25.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
|
| 567 |
+
"model.visual.blocks.25.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 568 |
+
"model.visual.blocks.25.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
|
| 569 |
+
"model.visual.blocks.25.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 570 |
+
"model.visual.blocks.25.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
|
| 571 |
+
"model.visual.blocks.25.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 572 |
+
"model.visual.blocks.25.norm1.weight": "model-00001-of-00004.safetensors",
|
| 573 |
+
"model.visual.blocks.25.norm2.weight": "model-00001-of-00004.safetensors",
|
| 574 |
+
"model.visual.blocks.26.attn.proj.bias": "model-00001-of-00004.safetensors",
|
| 575 |
+
"model.visual.blocks.26.attn.proj.weight": "model-00001-of-00004.safetensors",
|
| 576 |
+
"model.visual.blocks.26.attn.qkv.bias": "model-00001-of-00004.safetensors",
|
| 577 |
+
"model.visual.blocks.26.attn.qkv.weight": "model-00001-of-00004.safetensors",
|
| 578 |
+
"model.visual.blocks.26.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
|
| 579 |
+
"model.visual.blocks.26.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 580 |
+
"model.visual.blocks.26.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
|
| 581 |
+
"model.visual.blocks.26.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 582 |
+
"model.visual.blocks.26.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
|
| 583 |
+
"model.visual.blocks.26.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 584 |
+
"model.visual.blocks.26.norm1.weight": "model-00001-of-00004.safetensors",
|
| 585 |
+
"model.visual.blocks.26.norm2.weight": "model-00001-of-00004.safetensors",
|
| 586 |
+
"model.visual.blocks.27.attn.proj.bias": "model-00001-of-00004.safetensors",
|
| 587 |
+
"model.visual.blocks.27.attn.proj.weight": "model-00001-of-00004.safetensors",
|
| 588 |
+
"model.visual.blocks.27.attn.qkv.bias": "model-00001-of-00004.safetensors",
|
| 589 |
+
"model.visual.blocks.27.attn.qkv.weight": "model-00001-of-00004.safetensors",
|
| 590 |
+
"model.visual.blocks.27.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
|
| 591 |
+
"model.visual.blocks.27.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 592 |
+
"model.visual.blocks.27.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
|
| 593 |
+
"model.visual.blocks.27.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 594 |
+
"model.visual.blocks.27.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
|
| 595 |
+
"model.visual.blocks.27.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 596 |
+
"model.visual.blocks.27.norm1.weight": "model-00001-of-00004.safetensors",
|
| 597 |
+
"model.visual.blocks.27.norm2.weight": "model-00001-of-00004.safetensors",
|
| 598 |
+
"model.visual.blocks.28.attn.proj.bias": "model-00001-of-00004.safetensors",
|
| 599 |
+
"model.visual.blocks.28.attn.proj.weight": "model-00001-of-00004.safetensors",
|
| 600 |
+
"model.visual.blocks.28.attn.qkv.bias": "model-00001-of-00004.safetensors",
|
| 601 |
+
"model.visual.blocks.28.attn.qkv.weight": "model-00001-of-00004.safetensors",
|
| 602 |
+
"model.visual.blocks.28.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
|
| 603 |
+
"model.visual.blocks.28.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 604 |
+
"model.visual.blocks.28.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
|
| 605 |
+
"model.visual.blocks.28.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 606 |
+
"model.visual.blocks.28.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
|
| 607 |
+
"model.visual.blocks.28.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 608 |
+
"model.visual.blocks.28.norm1.weight": "model-00001-of-00004.safetensors",
|
| 609 |
+
"model.visual.blocks.28.norm2.weight": "model-00001-of-00004.safetensors",
|
| 610 |
+
"model.visual.blocks.29.attn.proj.bias": "model-00001-of-00004.safetensors",
|
| 611 |
+
"model.visual.blocks.29.attn.proj.weight": "model-00001-of-00004.safetensors",
|
| 612 |
+
"model.visual.blocks.29.attn.qkv.bias": "model-00001-of-00004.safetensors",
|
| 613 |
+
"model.visual.blocks.29.attn.qkv.weight": "model-00001-of-00004.safetensors",
|
| 614 |
+
"model.visual.blocks.29.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
|
| 615 |
+
"model.visual.blocks.29.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 616 |
+
"model.visual.blocks.29.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
|
| 617 |
+
"model.visual.blocks.29.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 618 |
+
"model.visual.blocks.29.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
|
| 619 |
+
"model.visual.blocks.29.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 620 |
+
"model.visual.blocks.29.norm1.weight": "model-00001-of-00004.safetensors",
|
| 621 |
+
"model.visual.blocks.29.norm2.weight": "model-00001-of-00004.safetensors",
|
| 622 |
+
"model.visual.blocks.3.attn.proj.bias": "model-00001-of-00004.safetensors",
|
| 623 |
+
"model.visual.blocks.3.attn.proj.weight": "model-00001-of-00004.safetensors",
|
| 624 |
+
"model.visual.blocks.3.attn.qkv.bias": "model-00001-of-00004.safetensors",
|
| 625 |
+
"model.visual.blocks.3.attn.qkv.weight": "model-00001-of-00004.safetensors",
|
| 626 |
+
"model.visual.blocks.3.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
|
| 627 |
+
"model.visual.blocks.3.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 628 |
+
"model.visual.blocks.3.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
|
| 629 |
+
"model.visual.blocks.3.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 630 |
+
"model.visual.blocks.3.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
|
| 631 |
+
"model.visual.blocks.3.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 632 |
+
"model.visual.blocks.3.norm1.weight": "model-00001-of-00004.safetensors",
|
| 633 |
+
"model.visual.blocks.3.norm2.weight": "model-00001-of-00004.safetensors",
|
| 634 |
+
"model.visual.blocks.30.attn.proj.bias": "model-00001-of-00004.safetensors",
|
| 635 |
+
"model.visual.blocks.30.attn.proj.weight": "model-00001-of-00004.safetensors",
|
| 636 |
+
"model.visual.blocks.30.attn.qkv.bias": "model-00001-of-00004.safetensors",
|
| 637 |
+
"model.visual.blocks.30.attn.qkv.weight": "model-00001-of-00004.safetensors",
|
| 638 |
+
"model.visual.blocks.30.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
|
| 639 |
+
"model.visual.blocks.30.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 640 |
+
"model.visual.blocks.30.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
|
| 641 |
+
"model.visual.blocks.30.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 642 |
+
"model.visual.blocks.30.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
|
| 643 |
+
"model.visual.blocks.30.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 644 |
+
"model.visual.blocks.30.norm1.weight": "model-00001-of-00004.safetensors",
|
| 645 |
+
"model.visual.blocks.30.norm2.weight": "model-00001-of-00004.safetensors",
|
| 646 |
+
"model.visual.blocks.31.attn.proj.bias": "model-00001-of-00004.safetensors",
|
| 647 |
+
"model.visual.blocks.31.attn.proj.weight": "model-00001-of-00004.safetensors",
|
| 648 |
+
"model.visual.blocks.31.attn.qkv.bias": "model-00001-of-00004.safetensors",
|
| 649 |
+
"model.visual.blocks.31.attn.qkv.weight": "model-00001-of-00004.safetensors",
|
| 650 |
+
"model.visual.blocks.31.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
|
| 651 |
+
"model.visual.blocks.31.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 652 |
+
"model.visual.blocks.31.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
|
| 653 |
+
"model.visual.blocks.31.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 654 |
+
"model.visual.blocks.31.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
|
| 655 |
+
"model.visual.blocks.31.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 656 |
+
"model.visual.blocks.31.norm1.weight": "model-00001-of-00004.safetensors",
|
| 657 |
+
"model.visual.blocks.31.norm2.weight": "model-00001-of-00004.safetensors",
|
| 658 |
+
"model.visual.blocks.4.attn.proj.bias": "model-00001-of-00004.safetensors",
|
| 659 |
+
"model.visual.blocks.4.attn.proj.weight": "model-00001-of-00004.safetensors",
|
| 660 |
+
"model.visual.blocks.4.attn.qkv.bias": "model-00001-of-00004.safetensors",
|
| 661 |
+
"model.visual.blocks.4.attn.qkv.weight": "model-00001-of-00004.safetensors",
|
| 662 |
+
"model.visual.blocks.4.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
|
| 663 |
+
"model.visual.blocks.4.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 664 |
+
"model.visual.blocks.4.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
|
| 665 |
+
"model.visual.blocks.4.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 666 |
+
"model.visual.blocks.4.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
|
| 667 |
+
"model.visual.blocks.4.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 668 |
+
"model.visual.blocks.4.norm1.weight": "model-00001-of-00004.safetensors",
|
| 669 |
+
"model.visual.blocks.4.norm2.weight": "model-00001-of-00004.safetensors",
|
| 670 |
+
"model.visual.blocks.5.attn.proj.bias": "model-00001-of-00004.safetensors",
|
| 671 |
+
"model.visual.blocks.5.attn.proj.weight": "model-00001-of-00004.safetensors",
|
| 672 |
+
"model.visual.blocks.5.attn.qkv.bias": "model-00001-of-00004.safetensors",
|
| 673 |
+
"model.visual.blocks.5.attn.qkv.weight": "model-00001-of-00004.safetensors",
|
| 674 |
+
"model.visual.blocks.5.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
|
| 675 |
+
"model.visual.blocks.5.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 676 |
+
"model.visual.blocks.5.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
|
| 677 |
+
"model.visual.blocks.5.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 678 |
+
"model.visual.blocks.5.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
|
| 679 |
+
"model.visual.blocks.5.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 680 |
+
"model.visual.blocks.5.norm1.weight": "model-00001-of-00004.safetensors",
|
| 681 |
+
"model.visual.blocks.5.norm2.weight": "model-00001-of-00004.safetensors",
|
| 682 |
+
"model.visual.blocks.6.attn.proj.bias": "model-00001-of-00004.safetensors",
|
| 683 |
+
"model.visual.blocks.6.attn.proj.weight": "model-00001-of-00004.safetensors",
|
| 684 |
+
"model.visual.blocks.6.attn.qkv.bias": "model-00001-of-00004.safetensors",
|
| 685 |
+
"model.visual.blocks.6.attn.qkv.weight": "model-00001-of-00004.safetensors",
|
| 686 |
+
"model.visual.blocks.6.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
|
| 687 |
+
"model.visual.blocks.6.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 688 |
+
"model.visual.blocks.6.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
|
| 689 |
+
"model.visual.blocks.6.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 690 |
+
"model.visual.blocks.6.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
|
| 691 |
+
"model.visual.blocks.6.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 692 |
+
"model.visual.blocks.6.norm1.weight": "model-00001-of-00004.safetensors",
|
| 693 |
+
"model.visual.blocks.6.norm2.weight": "model-00001-of-00004.safetensors",
|
| 694 |
+
"model.visual.blocks.7.attn.proj.bias": "model-00001-of-00004.safetensors",
|
| 695 |
+
"model.visual.blocks.7.attn.proj.weight": "model-00001-of-00004.safetensors",
|
| 696 |
+
"model.visual.blocks.7.attn.qkv.bias": "model-00001-of-00004.safetensors",
|
| 697 |
+
"model.visual.blocks.7.attn.qkv.weight": "model-00001-of-00004.safetensors",
|
| 698 |
+
"model.visual.blocks.7.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
|
| 699 |
+
"model.visual.blocks.7.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 700 |
+
"model.visual.blocks.7.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
|
| 701 |
+
"model.visual.blocks.7.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 702 |
+
"model.visual.blocks.7.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
|
| 703 |
+
"model.visual.blocks.7.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 704 |
+
"model.visual.blocks.7.norm1.weight": "model-00001-of-00004.safetensors",
|
| 705 |
+
"model.visual.blocks.7.norm2.weight": "model-00001-of-00004.safetensors",
|
| 706 |
+
"model.visual.blocks.8.attn.proj.bias": "model-00001-of-00004.safetensors",
|
| 707 |
+
"model.visual.blocks.8.attn.proj.weight": "model-00001-of-00004.safetensors",
|
| 708 |
+
"model.visual.blocks.8.attn.qkv.bias": "model-00001-of-00004.safetensors",
|
| 709 |
+
"model.visual.blocks.8.attn.qkv.weight": "model-00001-of-00004.safetensors",
|
| 710 |
+
"model.visual.blocks.8.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
|
| 711 |
+
"model.visual.blocks.8.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 712 |
+
"model.visual.blocks.8.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
|
| 713 |
+
"model.visual.blocks.8.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 714 |
+
"model.visual.blocks.8.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
|
| 715 |
+
"model.visual.blocks.8.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 716 |
+
"model.visual.blocks.8.norm1.weight": "model-00001-of-00004.safetensors",
|
| 717 |
+
"model.visual.blocks.8.norm2.weight": "model-00001-of-00004.safetensors",
|
| 718 |
+
"model.visual.blocks.9.attn.proj.bias": "model-00001-of-00004.safetensors",
|
| 719 |
+
"model.visual.blocks.9.attn.proj.weight": "model-00001-of-00004.safetensors",
|
| 720 |
+
"model.visual.blocks.9.attn.qkv.bias": "model-00001-of-00004.safetensors",
|
| 721 |
+
"model.visual.blocks.9.attn.qkv.weight": "model-00001-of-00004.safetensors",
|
| 722 |
+
"model.visual.blocks.9.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
|
| 723 |
+
"model.visual.blocks.9.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 724 |
+
"model.visual.blocks.9.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
|
| 725 |
+
"model.visual.blocks.9.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 726 |
+
"model.visual.blocks.9.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
|
| 727 |
+
"model.visual.blocks.9.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 728 |
+
"model.visual.blocks.9.norm1.weight": "model-00001-of-00004.safetensors",
|
| 729 |
+
"model.visual.blocks.9.norm2.weight": "model-00001-of-00004.safetensors",
|
| 730 |
+
"model.visual.merger.ln_q.weight": "model-00001-of-00004.safetensors",
|
| 731 |
+
"model.visual.merger.mlp.0.bias": "model-00001-of-00004.safetensors",
|
| 732 |
+
"model.visual.merger.mlp.0.weight": "model-00001-of-00004.safetensors",
|
| 733 |
+
"model.visual.merger.mlp.2.bias": "model-00001-of-00004.safetensors",
|
| 734 |
+
"model.visual.merger.mlp.2.weight": "model-00001-of-00004.safetensors",
|
| 735 |
+
"model.visual.patch_embed.proj.weight": "model-00001-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/transformers/models/qwen2_5_vl/modular_qwen2_5_vl.py.
|
| 3 |
+
# Do NOT edit this file manually as any edits will be overwritten by the generation of
|
| 4 |
+
# the file from the modular. If any change should be done, please apply the change to the
|
| 5 |
+
# modular_qwen2_5_vl.py file directly. One of our CI enforces this.
|
| 6 |
+
# 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨
|
| 7 |
+
# coding=utf-8
|
| 8 |
+
# Copyright 2025 The Qwen Team and The HuggingFace Inc. team. All rights reserved.
|
| 9 |
+
#
|
| 10 |
+
# This code is based on EleutherAI's GPT-NeoX library and the GPT-NeoX
|
| 11 |
+
# and OPT implementations in this library. It has been modified from its
|
| 12 |
+
# original forms to accommodate minor architectural differences compared
|
| 13 |
+
# to GPT-NeoX and OPT used by the Meta AI team that trained the model.
|
| 14 |
+
#
|
| 15 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 16 |
+
# you may not use this file except in compliance with the License.
|
| 17 |
+
# You may obtain a copy of the License at
|
| 18 |
+
#
|
| 19 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 20 |
+
#
|
| 21 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 22 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 23 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 24 |
+
# See the License for the specific language governing permissions and
|
| 25 |
+
# limitations under the License.
|
| 26 |
+
|
| 27 |
+
from dataclasses import dataclass
|
| 28 |
+
from typing import Any, Callable, Optional, Union
|
| 29 |
+
|
| 30 |
+
import torch
|
| 31 |
+
import torch.nn as nn
|
| 32 |
+
import torch.nn.functional as F
|
| 33 |
+
|
| 34 |
+
from transformers.activations import ACT2FN
|
| 35 |
+
from transformers.cache_utils import Cache, DynamicCache
|
| 36 |
+
from transformers.generation import GenerationMixin
|
| 37 |
+
from transformers.masking_utils import create_causal_mask, create_sliding_window_causal_mask
|
| 38 |
+
from transformers.modeling_flash_attention_utils import FlashAttentionKwargs
|
| 39 |
+
from transformers.modeling_layers import GradientCheckpointingLayer
|
| 40 |
+
from transformers.modeling_outputs import BaseModelOutputWithPast, ModelOutput
|
| 41 |
+
from transformers.modeling_rope_utils import ROPE_INIT_FUNCTIONS, dynamic_rope_update
|
| 42 |
+
from transformers.modeling_utils import ALL_ATTENTION_FUNCTIONS, PreTrainedModel
|
| 43 |
+
from transformers.processing_utils import Unpack
|
| 44 |
+
from transformers.utils import TransformersKwargs, auto_docstring, can_return_tuple, is_torchdynamo_compiling, logging
|
| 45 |
+
from .configuration_echo import EchoConfig, EchoTextConfig, EchoVisionConfig
|
| 46 |
+
|
| 47 |
+
# Add these imports
|
| 48 |
+
from typing import List, Tuple
|
| 49 |
+
from einops import rearrange
|
| 50 |
+
|
| 51 |
+
try:
|
| 52 |
+
from flash_attn import flash_attn_func, flash_attn_varlen_func
|
| 53 |
+
from flash_attn.bert_padding import index_first_axis, pad_input, unpad_input
|
| 54 |
+
except:
|
| 55 |
+
pass
|
| 56 |
+
|
| 57 |
+
try:
|
| 58 |
+
from liger_kernel.ops.swiglu import LigerSiLUMulFunction # noqa: F401
|
| 59 |
+
liger_kernel_is_available = True
|
| 60 |
+
except ImportError:
|
| 61 |
+
liger_kernel_is_available = False
|
| 62 |
+
|
| 63 |
+
from flash_attn.ops.triton.layer_norm import rms_norm_fn as flash_rms_norm
|
| 64 |
+
|
| 65 |
+
logger = logging.get_logger(__name__)
|
| 66 |
+
|
| 67 |
+
class EchoMLP(nn.Module):
|
| 68 |
+
def __init__(self, config, bias: bool = False):
|
| 69 |
+
super().__init__()
|
| 70 |
+
self.hidden_size = config.hidden_size
|
| 71 |
+
self.intermediate_size = config.intermediate_size
|
| 72 |
+
self.gate_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=bias)
|
| 73 |
+
self.up_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=bias)
|
| 74 |
+
self.down_proj = nn.Linear(self.intermediate_size, self.hidden_size, bias=bias)
|
| 75 |
+
self.act_fn = ACT2FN[config.hidden_act]
|
| 76 |
+
|
| 77 |
+
def forward(self, hidden_state):
|
| 78 |
+
return self.down_proj(self.act_fn(self.gate_proj(hidden_state)) * self.up_proj(hidden_state))
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
class Echo_VisionPatchEmbed(nn.Module):
|
| 82 |
+
def __init__(
|
| 83 |
+
self,
|
| 84 |
+
patch_size: int = 14,
|
| 85 |
+
temporal_patch_size: int = 2,
|
| 86 |
+
in_channels: int = 3,
|
| 87 |
+
embed_dim: int = 1152,
|
| 88 |
+
) -> None:
|
| 89 |
+
super().__init__()
|
| 90 |
+
self.patch_size = patch_size
|
| 91 |
+
self.temporal_patch_size = temporal_patch_size
|
| 92 |
+
self.in_channels = in_channels
|
| 93 |
+
self.embed_dim = embed_dim
|
| 94 |
+
|
| 95 |
+
kernel_size = [temporal_patch_size, patch_size, patch_size]
|
| 96 |
+
self.proj = nn.Conv3d(in_channels, embed_dim, kernel_size=kernel_size, stride=kernel_size, bias=False)
|
| 97 |
+
|
| 98 |
+
def forward(self, hidden_states: torch.Tensor) -> torch.Tensor:
|
| 99 |
+
target_dtype = self.proj.weight.dtype
|
| 100 |
+
hidden_states = hidden_states.view(
|
| 101 |
+
-1, self.in_channels, self.temporal_patch_size, self.patch_size, self.patch_size
|
| 102 |
+
)
|
| 103 |
+
hidden_states = self.proj(hidden_states.to(dtype=target_dtype)).view(-1, self.embed_dim)
|
| 104 |
+
return hidden_states
|
| 105 |
+
|
| 106 |
+
|
| 107 |
+
class Echo_VisionRotaryEmbedding(nn.Module):
|
| 108 |
+
def __init__(self, dim: int, theta: float = 10000.0) -> None:
|
| 109 |
+
super().__init__()
|
| 110 |
+
inv_freq = 1.0 / (theta ** (torch.arange(0, dim, 2, dtype=torch.float) / dim))
|
| 111 |
+
self.register_buffer("inv_freq", inv_freq, persistent=False)
|
| 112 |
+
|
| 113 |
+
def forward(self, seqlen: int) -> torch.Tensor:
|
| 114 |
+
seq = torch.arange(seqlen, device=self.inv_freq.device, dtype=self.inv_freq.dtype)
|
| 115 |
+
freqs = torch.outer(seq, self.inv_freq)
|
| 116 |
+
return freqs
|
| 117 |
+
|
| 118 |
+
|
| 119 |
+
class Qwen2RMSNorm(nn.Module):
|
| 120 |
+
def __init__(self, hidden_size, eps=1e-6):
|
| 121 |
+
"""
|
| 122 |
+
Qwen2RMSNorm is equivalent to T5LayerNorm
|
| 123 |
+
"""
|
| 124 |
+
super().__init__()
|
| 125 |
+
self.weight = nn.Parameter(torch.ones(hidden_size))
|
| 126 |
+
self.variance_epsilon = eps
|
| 127 |
+
|
| 128 |
+
def forward(self, hidden_states):
|
| 129 |
+
input_dtype = hidden_states.dtype
|
| 130 |
+
hidden_states = hidden_states.to(torch.float32)
|
| 131 |
+
variance = hidden_states.pow(2).mean(-1, keepdim=True)
|
| 132 |
+
hidden_states = hidden_states * torch.rsqrt(variance + self.variance_epsilon)
|
| 133 |
+
return self.weight * hidden_states.to(input_dtype)
|
| 134 |
+
|
| 135 |
+
def extra_repr(self):
|
| 136 |
+
return f"{tuple(self.weight.shape)}, eps={self.variance_epsilon}"
|
| 137 |
+
|
| 138 |
+
|
| 139 |
+
class EchoPatchMerger(nn.Module):
|
| 140 |
+
def __init__(self, dim: int, context_dim: int, spatial_merge_size: int = 2) -> None:
|
| 141 |
+
super().__init__()
|
| 142 |
+
self.hidden_size = context_dim * (spatial_merge_size**2)
|
| 143 |
+
self.ln_q = Qwen2RMSNorm(context_dim, eps=1e-6)
|
| 144 |
+
self.mlp = nn.Sequential(
|
| 145 |
+
nn.Linear(self.hidden_size, self.hidden_size),
|
| 146 |
+
nn.GELU(),
|
| 147 |
+
nn.Linear(self.hidden_size, dim),
|
| 148 |
+
)
|
| 149 |
+
|
| 150 |
+
def forward(self, x: torch.Tensor) -> torch.Tensor:
|
| 151 |
+
x = self.mlp(self.ln_q(x).view(-1, self.hidden_size))
|
| 152 |
+
return x
|
| 153 |
+
|
| 154 |
+
|
| 155 |
+
def rotate_half(x):
|
| 156 |
+
"""Rotates half the hidden dims of the input."""
|
| 157 |
+
x1 = x[..., : x.shape[-1] // 2]
|
| 158 |
+
x2 = x[..., x.shape[-1] // 2 :]
|
| 159 |
+
return torch.cat((-x2, x1), dim=-1)
|
| 160 |
+
|
| 161 |
+
|
| 162 |
+
def apply_rotary_pos_emb_vision(
|
| 163 |
+
q: torch.Tensor, k: torch.Tensor, cos: torch.Tensor, sin: torch.Tensor
|
| 164 |
+
) -> tuple[torch.Tensor, torch.Tensor]:
|
| 165 |
+
orig_q_dtype = q.dtype
|
| 166 |
+
orig_k_dtype = k.dtype
|
| 167 |
+
q, k = q.float(), k.float()
|
| 168 |
+
cos, sin = cos.unsqueeze(-2).float(), sin.unsqueeze(-2).float()
|
| 169 |
+
q_embed = (q * cos) + (rotate_half(q) * sin)
|
| 170 |
+
k_embed = (k * cos) + (rotate_half(k) * sin)
|
| 171 |
+
q_embed = q_embed.to(orig_q_dtype)
|
| 172 |
+
k_embed = k_embed.to(orig_k_dtype)
|
| 173 |
+
return q_embed, k_embed
|
| 174 |
+
|
| 175 |
+
|
| 176 |
+
def repeat_kv(hidden_states: torch.Tensor, n_rep: int) -> torch.Tensor:
|
| 177 |
+
"""
|
| 178 |
+
This is the equivalent of torch.repeat_interleave(x, dim=1, repeats=n_rep). The hidden states go from (batch,
|
| 179 |
+
num_key_value_heads, seqlen, head_dim) to (batch, num_attention_heads, seqlen, head_dim)
|
| 180 |
+
"""
|
| 181 |
+
batch, num_key_value_heads, slen, head_dim = hidden_states.shape
|
| 182 |
+
if n_rep == 1:
|
| 183 |
+
return hidden_states
|
| 184 |
+
hidden_states = hidden_states[:, :, None, :, :].expand(batch, num_key_value_heads, n_rep, slen, head_dim)
|
| 185 |
+
return hidden_states.reshape(batch, num_key_value_heads * n_rep, slen, head_dim)
|
| 186 |
+
|
| 187 |
+
|
| 188 |
+
def eager_attention_forward(
|
| 189 |
+
module: nn.Module,
|
| 190 |
+
query: torch.Tensor,
|
| 191 |
+
key: torch.Tensor,
|
| 192 |
+
value: torch.Tensor,
|
| 193 |
+
attention_mask: Optional[torch.Tensor],
|
| 194 |
+
scaling: float,
|
| 195 |
+
dropout: float = 0.0,
|
| 196 |
+
**kwargs,
|
| 197 |
+
):
|
| 198 |
+
key_states = repeat_kv(key, module.num_key_value_groups)
|
| 199 |
+
value_states = repeat_kv(value, module.num_key_value_groups)
|
| 200 |
+
|
| 201 |
+
attn_weights = torch.matmul(query, key_states.transpose(2, 3)) * scaling
|
| 202 |
+
if attention_mask is not None:
|
| 203 |
+
causal_mask = attention_mask[:, :, :, : key_states.shape[-2]]
|
| 204 |
+
attn_weights = attn_weights + causal_mask
|
| 205 |
+
|
| 206 |
+
attn_weights = nn.functional.softmax(attn_weights, dim=-1, dtype=torch.float32).to(query.dtype)
|
| 207 |
+
attn_weights = nn.functional.dropout(attn_weights, p=dropout, training=module.training)
|
| 208 |
+
attn_output = torch.matmul(attn_weights, value_states)
|
| 209 |
+
attn_output = attn_output.transpose(1, 2).contiguous()
|
| 210 |
+
|
| 211 |
+
return attn_output, attn_weights
|
| 212 |
+
|
| 213 |
+
|
| 214 |
+
class EchoVisionAttention(nn.Module):
|
| 215 |
+
def __init__(self, config: EchoVisionConfig) -> None:
|
| 216 |
+
super().__init__()
|
| 217 |
+
self.dim = config.hidden_size
|
| 218 |
+
self.num_heads = config.num_heads
|
| 219 |
+
self.head_dim = self.dim // self.num_heads
|
| 220 |
+
self.num_key_value_groups = 1 # needed for eager attention
|
| 221 |
+
self.qkv = nn.Linear(self.dim, self.dim * 3, bias=True)
|
| 222 |
+
self.proj = nn.Linear(self.dim, self.dim)
|
| 223 |
+
self.scaling = self.head_dim**-0.5
|
| 224 |
+
self.config = config
|
| 225 |
+
self.attention_dropout = 0.0
|
| 226 |
+
self.is_causal = False
|
| 227 |
+
|
| 228 |
+
def forward(
|
| 229 |
+
self,
|
| 230 |
+
hidden_states: torch.Tensor,
|
| 231 |
+
cu_seqlens: torch.Tensor,
|
| 232 |
+
rotary_pos_emb: Optional[torch.Tensor] = None,
|
| 233 |
+
position_embeddings: Optional[tuple[torch.Tensor, torch.Tensor]] = None,
|
| 234 |
+
**kwargs,
|
| 235 |
+
) -> torch.Tensor:
|
| 236 |
+
seq_length = hidden_states.shape[0]
|
| 237 |
+
query_states, key_states, value_states = (
|
| 238 |
+
self.qkv(hidden_states).reshape(seq_length, 3, self.num_heads, -1).permute(1, 0, 2, 3).unbind(0)
|
| 239 |
+
)
|
| 240 |
+
if position_embeddings is None:
|
| 241 |
+
logger.warning_once(
|
| 242 |
+
"The attention layers in this model are transitioning from computing the RoPE embeddings internally "
|
| 243 |
+
"through `rotary_pos_emb` (2D tensor of RoPE theta values), to using externally computed "
|
| 244 |
+
"`position_embeddings` (Tuple of tensors, containing cos and sin). In v4.54 `rotary_pos_emb` will be "
|
| 245 |
+
"removed and `position_embeddings` will be mandatory."
|
| 246 |
+
)
|
| 247 |
+
emb = torch.cat((rotary_pos_emb, rotary_pos_emb), dim=-1)
|
| 248 |
+
cos = emb.cos()
|
| 249 |
+
sin = emb.sin()
|
| 250 |
+
else:
|
| 251 |
+
cos, sin = position_embeddings
|
| 252 |
+
query_states, key_states = apply_rotary_pos_emb_vision(query_states, key_states, cos, sin)
|
| 253 |
+
|
| 254 |
+
query_states = query_states.transpose(0, 1).unsqueeze(0)
|
| 255 |
+
key_states = key_states.transpose(0, 1).unsqueeze(0)
|
| 256 |
+
value_states = value_states.transpose(0, 1).unsqueeze(0)
|
| 257 |
+
|
| 258 |
+
attention_interface: Callable = eager_attention_forward
|
| 259 |
+
if self.config._attn_implementation != "eager":
|
| 260 |
+
attention_interface = ALL_ATTENTION_FUNCTIONS[self.config._attn_implementation]
|
| 261 |
+
|
| 262 |
+
if self.config._attn_implementation == "flash_attention_2":
|
| 263 |
+
# Flash Attention 2: Use cu_seqlens for variable length attention
|
| 264 |
+
max_seqlen = (cu_seqlens[1:] - cu_seqlens[:-1]).max()
|
| 265 |
+
attn_output, _ = attention_interface(
|
| 266 |
+
self,
|
| 267 |
+
query_states,
|
| 268 |
+
key_states,
|
| 269 |
+
value_states,
|
| 270 |
+
attention_mask=None,
|
| 271 |
+
scaling=self.scaling,
|
| 272 |
+
dropout=0.0 if not self.training else self.attention_dropout,
|
| 273 |
+
cu_seq_lens_q=cu_seqlens,
|
| 274 |
+
cu_seq_lens_k=cu_seqlens,
|
| 275 |
+
max_length_q=max_seqlen,
|
| 276 |
+
max_length_k=max_seqlen,
|
| 277 |
+
is_causal=False,
|
| 278 |
+
**kwargs,
|
| 279 |
+
)
|
| 280 |
+
else:
|
| 281 |
+
# Other implementations: Process each chunk separately
|
| 282 |
+
lengths = cu_seqlens[1:] - cu_seqlens[:-1]
|
| 283 |
+
splits = [
|
| 284 |
+
torch.split(tensor, lengths.tolist(), dim=2) for tensor in (query_states, key_states, value_states)
|
| 285 |
+
]
|
| 286 |
+
|
| 287 |
+
attn_outputs = [
|
| 288 |
+
attention_interface(
|
| 289 |
+
self,
|
| 290 |
+
q,
|
| 291 |
+
k,
|
| 292 |
+
v,
|
| 293 |
+
attention_mask=None,
|
| 294 |
+
scaling=self.scaling,
|
| 295 |
+
dropout=0.0 if not self.training else self.attention_dropout,
|
| 296 |
+
is_causal=False,
|
| 297 |
+
**kwargs,
|
| 298 |
+
)[0]
|
| 299 |
+
for q, k, v in zip(*splits)
|
| 300 |
+
]
|
| 301 |
+
attn_output = torch.cat(attn_outputs, dim=1)
|
| 302 |
+
|
| 303 |
+
attn_output = attn_output.reshape(seq_length, -1).contiguous()
|
| 304 |
+
attn_output = self.proj(attn_output)
|
| 305 |
+
return attn_output
|
| 306 |
+
|
| 307 |
+
|
| 308 |
+
class EchoVisionBlock(GradientCheckpointingLayer):
|
| 309 |
+
def __init__(self, config, attn_implementation: str = "sdpa") -> None:
|
| 310 |
+
super().__init__()
|
| 311 |
+
self.norm1 = Qwen2RMSNorm(config.hidden_size, eps=1e-6)
|
| 312 |
+
self.norm2 = Qwen2RMSNorm(config.hidden_size, eps=1e-6)
|
| 313 |
+
self.attn = EchoVisionAttention(config=config)
|
| 314 |
+
self.mlp = EchoMLP(config, bias=True)
|
| 315 |
+
|
| 316 |
+
def forward(
|
| 317 |
+
self,
|
| 318 |
+
hidden_states: torch.Tensor,
|
| 319 |
+
cu_seqlens: torch.Tensor,
|
| 320 |
+
rotary_pos_emb: Optional[torch.Tensor] = None,
|
| 321 |
+
position_embeddings: Optional[tuple[torch.Tensor, torch.Tensor]] = None,
|
| 322 |
+
**kwargs,
|
| 323 |
+
) -> torch.Tensor:
|
| 324 |
+
hidden_states = hidden_states + self.attn(
|
| 325 |
+
self.norm1(hidden_states),
|
| 326 |
+
cu_seqlens=cu_seqlens,
|
| 327 |
+
rotary_pos_emb=rotary_pos_emb,
|
| 328 |
+
position_embeddings=position_embeddings,
|
| 329 |
+
**kwargs,
|
| 330 |
+
)
|
| 331 |
+
hidden_states = hidden_states + self.mlp(self.norm2(hidden_states))
|
| 332 |
+
return hidden_states
|
| 333 |
+
|
| 334 |
+
|
| 335 |
+
@auto_docstring
|
| 336 |
+
class EchoPreTrainedModel(PreTrainedModel):
|
| 337 |
+
config: EchoConfig
|
| 338 |
+
base_model_prefix = "model"
|
| 339 |
+
supports_gradient_checkpointing = True
|
| 340 |
+
_no_split_modules = ["EchoDecoderLayer", "EchoVisionBlock"]
|
| 341 |
+
_skip_keys_device_placement = "past_key_values"
|
| 342 |
+
_supports_flash_attn = True
|
| 343 |
+
_supports_sdpa = True
|
| 344 |
+
|
| 345 |
+
_can_compile_fullgraph = True
|
| 346 |
+
_supports_attention_backend = True
|
| 347 |
+
|
| 348 |
+
|
| 349 |
+
class Echo_VisionTransformerPretrainedModel(EchoPreTrainedModel):
|
| 350 |
+
config: EchoVisionConfig
|
| 351 |
+
_no_split_modules = ["EchoVisionBlock"]
|
| 352 |
+
|
| 353 |
+
def __init__(self, config, *inputs, **kwargs) -> None:
|
| 354 |
+
super().__init__(config, *inputs, **kwargs)
|
| 355 |
+
self.spatial_merge_size = config.spatial_merge_size
|
| 356 |
+
self.patch_size = config.patch_size
|
| 357 |
+
self.fullatt_block_indexes = config.fullatt_block_indexes
|
| 358 |
+
self.window_size = config.window_size
|
| 359 |
+
self.spatial_merge_unit = self.spatial_merge_size * self.spatial_merge_size
|
| 360 |
+
|
| 361 |
+
self.patch_embed = Echo_VisionPatchEmbed(
|
| 362 |
+
patch_size=config.patch_size,
|
| 363 |
+
temporal_patch_size=config.temporal_patch_size,
|
| 364 |
+
in_channels=config.in_channels,
|
| 365 |
+
embed_dim=config.hidden_size,
|
| 366 |
+
)
|
| 367 |
+
|
| 368 |
+
head_dim = config.hidden_size // config.num_heads
|
| 369 |
+
self.rotary_pos_emb = Echo_VisionRotaryEmbedding(head_dim // 2)
|
| 370 |
+
|
| 371 |
+
self.blocks = nn.ModuleList([EchoVisionBlock(config) for _ in range(config.depth)])
|
| 372 |
+
self.merger = EchoPatchMerger(
|
| 373 |
+
dim=config.out_hidden_size,
|
| 374 |
+
context_dim=config.hidden_size,
|
| 375 |
+
spatial_merge_size=config.spatial_merge_size,
|
| 376 |
+
)
|
| 377 |
+
self.gradient_checkpointing = False
|
| 378 |
+
|
| 379 |
+
def rot_pos_emb(self, grid_thw):
|
| 380 |
+
pos_ids = []
|
| 381 |
+
for t, h, w in grid_thw:
|
| 382 |
+
hpos_ids = torch.arange(h).unsqueeze(1).expand(-1, w)
|
| 383 |
+
hpos_ids = hpos_ids.reshape(
|
| 384 |
+
h // self.spatial_merge_size,
|
| 385 |
+
self.spatial_merge_size,
|
| 386 |
+
w // self.spatial_merge_size,
|
| 387 |
+
self.spatial_merge_size,
|
| 388 |
+
)
|
| 389 |
+
hpos_ids = hpos_ids.permute(0, 2, 1, 3)
|
| 390 |
+
hpos_ids = hpos_ids.flatten()
|
| 391 |
+
|
| 392 |
+
wpos_ids = torch.arange(w).unsqueeze(0).expand(h, -1)
|
| 393 |
+
wpos_ids = wpos_ids.reshape(
|
| 394 |
+
h // self.spatial_merge_size,
|
| 395 |
+
self.spatial_merge_size,
|
| 396 |
+
w // self.spatial_merge_size,
|
| 397 |
+
self.spatial_merge_size,
|
| 398 |
+
)
|
| 399 |
+
wpos_ids = wpos_ids.permute(0, 2, 1, 3)
|
| 400 |
+
wpos_ids = wpos_ids.flatten()
|
| 401 |
+
pos_ids.append(torch.stack([hpos_ids, wpos_ids], dim=-1).repeat(t, 1))
|
| 402 |
+
pos_ids = torch.cat(pos_ids, dim=0)
|
| 403 |
+
max_grid_size = grid_thw[:, 1:].max()
|
| 404 |
+
rotary_pos_emb_full = self.rotary_pos_emb(max_grid_size)
|
| 405 |
+
rotary_pos_emb = rotary_pos_emb_full[pos_ids].flatten(1)
|
| 406 |
+
return rotary_pos_emb
|
| 407 |
+
|
| 408 |
+
def get_window_index(self, grid_thw):
|
| 409 |
+
window_index: list = []
|
| 410 |
+
cu_window_seqlens: list = [0]
|
| 411 |
+
window_index_id = 0
|
| 412 |
+
vit_merger_window_size = self.window_size // self.spatial_merge_size // self.patch_size
|
| 413 |
+
|
| 414 |
+
for grid_t, grid_h, grid_w in grid_thw:
|
| 415 |
+
llm_grid_h, llm_grid_w = (
|
| 416 |
+
grid_h // self.spatial_merge_size,
|
| 417 |
+
grid_w // self.spatial_merge_size,
|
| 418 |
+
)
|
| 419 |
+
index = torch.arange(grid_t * llm_grid_h * llm_grid_w).reshape(grid_t, llm_grid_h, llm_grid_w)
|
| 420 |
+
pad_h = vit_merger_window_size - llm_grid_h % vit_merger_window_size
|
| 421 |
+
pad_w = vit_merger_window_size - llm_grid_w % vit_merger_window_size
|
| 422 |
+
num_windows_h = (llm_grid_h + pad_h) // vit_merger_window_size
|
| 423 |
+
num_windows_w = (llm_grid_w + pad_w) // vit_merger_window_size
|
| 424 |
+
index_padded = F.pad(index, (0, pad_w, 0, pad_h), "constant", -100)
|
| 425 |
+
index_padded = index_padded.reshape(
|
| 426 |
+
grid_t,
|
| 427 |
+
num_windows_h,
|
| 428 |
+
vit_merger_window_size,
|
| 429 |
+
num_windows_w,
|
| 430 |
+
vit_merger_window_size,
|
| 431 |
+
)
|
| 432 |
+
index_padded = index_padded.permute(0, 1, 3, 2, 4).reshape(
|
| 433 |
+
grid_t,
|
| 434 |
+
num_windows_h * num_windows_w,
|
| 435 |
+
vit_merger_window_size,
|
| 436 |
+
vit_merger_window_size,
|
| 437 |
+
)
|
| 438 |
+
seqlens = (index_padded != -100).sum([2, 3]).reshape(-1)
|
| 439 |
+
index_padded = index_padded.reshape(-1)
|
| 440 |
+
index_new = index_padded[index_padded != -100]
|
| 441 |
+
window_index.append(index_new + window_index_id)
|
| 442 |
+
cu_seqlens_tmp = seqlens.cumsum(0) * self.spatial_merge_unit + cu_window_seqlens[-1]
|
| 443 |
+
cu_window_seqlens.extend(cu_seqlens_tmp.tolist())
|
| 444 |
+
window_index_id += (grid_t * llm_grid_h * llm_grid_w).item()
|
| 445 |
+
window_index = torch.cat(window_index, dim=0)
|
| 446 |
+
|
| 447 |
+
return window_index, cu_window_seqlens
|
| 448 |
+
|
| 449 |
+
def forward(self, hidden_states: torch.Tensor, grid_thw: torch.Tensor, **kwargs) -> torch.Tensor:
|
| 450 |
+
"""
|
| 451 |
+
Args:
|
| 452 |
+
hidden_states (`torch.Tensor` of shape `(seq_len, hidden_size)`):
|
| 453 |
+
The final hidden states of the model.
|
| 454 |
+
grid_thw (`torch.Tensor` of shape `(num_images_or_videos, 3)`):
|
| 455 |
+
The temporal, height and width of feature shape of each image in LLM.
|
| 456 |
+
|
| 457 |
+
Returns:
|
| 458 |
+
`torch.Tensor`: hidden_states.
|
| 459 |
+
"""
|
| 460 |
+
hidden_states = self.patch_embed(hidden_states)
|
| 461 |
+
rotary_pos_emb = self.rot_pos_emb(grid_thw)
|
| 462 |
+
window_index, cu_window_seqlens = self.get_window_index(grid_thw)
|
| 463 |
+
cu_window_seqlens = torch.tensor(
|
| 464 |
+
cu_window_seqlens,
|
| 465 |
+
device=hidden_states.device,
|
| 466 |
+
dtype=grid_thw.dtype if torch.jit.is_tracing() else torch.int32,
|
| 467 |
+
)
|
| 468 |
+
cu_window_seqlens = torch.unique_consecutive(cu_window_seqlens)
|
| 469 |
+
|
| 470 |
+
seq_len, _ = hidden_states.size()
|
| 471 |
+
hidden_states = hidden_states.reshape(seq_len // self.spatial_merge_unit, self.spatial_merge_unit, -1)
|
| 472 |
+
hidden_states = hidden_states[window_index, :, :]
|
| 473 |
+
hidden_states = hidden_states.reshape(seq_len, -1)
|
| 474 |
+
rotary_pos_emb = rotary_pos_emb.reshape(seq_len // self.spatial_merge_unit, self.spatial_merge_unit, -1)
|
| 475 |
+
rotary_pos_emb = rotary_pos_emb[window_index, :, :]
|
| 476 |
+
rotary_pos_emb = rotary_pos_emb.reshape(seq_len, -1)
|
| 477 |
+
emb = torch.cat((rotary_pos_emb, rotary_pos_emb), dim=-1)
|
| 478 |
+
position_embeddings = (emb.cos(), emb.sin())
|
| 479 |
+
|
| 480 |
+
cu_seqlens = torch.repeat_interleave(grid_thw[:, 1] * grid_thw[:, 2], grid_thw[:, 0]).cumsum(
|
| 481 |
+
dim=0,
|
| 482 |
+
# Select dtype based on the following factors:
|
| 483 |
+
# - FA2 requires that cu_seqlens_q must have dtype int32
|
| 484 |
+
# - torch.onnx.export requires that cu_seqlens_q must have same dtype as grid_thw
|
| 485 |
+
# See https://github.com/huggingface/transformers/pull/34852 for more information
|
| 486 |
+
dtype=grid_thw.dtype if torch.jit.is_tracing() else torch.int32,
|
| 487 |
+
)
|
| 488 |
+
cu_seqlens = F.pad(cu_seqlens, (1, 0), value=0)
|
| 489 |
+
|
| 490 |
+
for layer_num, blk in enumerate(self.blocks):
|
| 491 |
+
if layer_num in self.fullatt_block_indexes:
|
| 492 |
+
cu_seqlens_now = cu_seqlens
|
| 493 |
+
else:
|
| 494 |
+
cu_seqlens_now = cu_window_seqlens
|
| 495 |
+
|
| 496 |
+
hidden_states = blk(
|
| 497 |
+
hidden_states,
|
| 498 |
+
cu_seqlens=cu_seqlens_now,
|
| 499 |
+
position_embeddings=position_embeddings,
|
| 500 |
+
**kwargs,
|
| 501 |
+
)
|
| 502 |
+
|
| 503 |
+
hidden_states = self.merger(hidden_states)
|
| 504 |
+
reverse_indices = torch.argsort(window_index)
|
| 505 |
+
hidden_states = hidden_states[reverse_indices, :]
|
| 506 |
+
|
| 507 |
+
return hidden_states
|
| 508 |
+
|
| 509 |
+
|
| 510 |
+
@dataclass
|
| 511 |
+
@auto_docstring(
|
| 512 |
+
custom_intro="""
|
| 513 |
+
Base class for Llava outputs, with hidden states and attentions.
|
| 514 |
+
"""
|
| 515 |
+
)
|
| 516 |
+
class EchoModelOutputWithPast(ModelOutput):
|
| 517 |
+
r"""
|
| 518 |
+
past_key_values (`Cache`, *optional*, returned when `use_cache=True` is passed or when `config.use_cache=True`):
|
| 519 |
+
Tuple of `tuple(torch.FloatTensor)` of length `config.n_layers`, with each tuple having 2 tensors of shape
|
| 520 |
+
`(batch_size, num_heads, sequence_length, embed_size_per_head)`)
|
| 521 |
+
|
| 522 |
+
Contains pre-computed hidden-states (key and values in the self-attention blocks) that can be used (see
|
| 523 |
+
`past_key_values` input) to speed up sequential decoding.
|
| 524 |
+
rope_deltas (`torch.LongTensor` of shape `(batch_size, )`, *optional*):
|
| 525 |
+
The rope index difference between sequence length and multimodal rope.
|
| 526 |
+
"""
|
| 527 |
+
|
| 528 |
+
last_hidden_state: torch.FloatTensor = None
|
| 529 |
+
past_key_values: Optional[list[torch.FloatTensor]] = None
|
| 530 |
+
hidden_states: Optional[tuple[torch.FloatTensor]] = None
|
| 531 |
+
attentions: Optional[tuple[torch.FloatTensor]] = None
|
| 532 |
+
rope_deltas: Optional[torch.LongTensor] = None
|
| 533 |
+
|
| 534 |
+
|
| 535 |
+
class EchoRotaryEmbedding(nn.Module):
|
| 536 |
+
def __init__(self, config: EchoTextConfig, device=None):
|
| 537 |
+
super().__init__()
|
| 538 |
+
# BC: "rope_type" was originally "type"
|
| 539 |
+
if hasattr(config, "rope_scaling") and config.rope_scaling is not None:
|
| 540 |
+
self.rope_type = config.rope_scaling.get("rope_type", config.rope_scaling.get("type"))
|
| 541 |
+
else:
|
| 542 |
+
self.rope_type = "default"
|
| 543 |
+
self.max_seq_len_cached = config.max_position_embeddings
|
| 544 |
+
self.original_max_seq_len = config.max_position_embeddings
|
| 545 |
+
|
| 546 |
+
self.config = config
|
| 547 |
+
self.rope_init_fn = ROPE_INIT_FUNCTIONS[self.rope_type]
|
| 548 |
+
|
| 549 |
+
inv_freq, self.attention_scaling = self.rope_init_fn(self.config, device)
|
| 550 |
+
self.register_buffer("inv_freq", inv_freq, persistent=False)
|
| 551 |
+
self.original_inv_freq = self.inv_freq
|
| 552 |
+
|
| 553 |
+
@torch.no_grad()
|
| 554 |
+
@dynamic_rope_update # power user: used with advanced RoPE types (e.g. dynamic rope)
|
| 555 |
+
def forward(self, x, position_ids):
|
| 556 |
+
# In contrast to other models, Echo has different position ids for the grids
|
| 557 |
+
# So we expand the inv_freq to shape (3, ...)
|
| 558 |
+
inv_freq_expanded = self.inv_freq[None, None, :, None].float().expand(3, position_ids.shape[1], -1, 1)
|
| 559 |
+
position_ids_expanded = position_ids[:, :, None, :].float() # shape (3, bs, 1, positions)
|
| 560 |
+
|
| 561 |
+
device_type = x.device.type if isinstance(x.device.type, str) and x.device.type != "mps" else "cpu"
|
| 562 |
+
with torch.autocast(device_type=device_type, enabled=False): # Force float32
|
| 563 |
+
freqs = (inv_freq_expanded.float() @ position_ids_expanded.float()).transpose(2, 3)
|
| 564 |
+
emb = torch.cat((freqs, freqs), dim=-1)
|
| 565 |
+
cos = emb.cos() * self.attention_scaling
|
| 566 |
+
sin = emb.sin() * self.attention_scaling
|
| 567 |
+
|
| 568 |
+
return cos.to(dtype=x.dtype), sin.to(dtype=x.dtype)
|
| 569 |
+
|
| 570 |
+
|
| 571 |
+
class Qwen2MLP(nn.Module):
|
| 572 |
+
def __init__(self, config):
|
| 573 |
+
super().__init__()
|
| 574 |
+
self.config = config
|
| 575 |
+
self.hidden_size = config.hidden_size
|
| 576 |
+
self.intermediate_size = config.intermediate_size
|
| 577 |
+
self.gate_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=False)
|
| 578 |
+
self.up_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=False)
|
| 579 |
+
self.down_proj = nn.Linear(self.intermediate_size, self.hidden_size, bias=False)
|
| 580 |
+
self.act_fn = ACT2FN[config.hidden_act]
|
| 581 |
+
|
| 582 |
+
def forward(self, x):
|
| 583 |
+
if liger_kernel_is_available:
|
| 584 |
+
return self.down_proj(LigerSiLUMulFunction.apply(self.gate_proj(x), self.up_proj(x)))
|
| 585 |
+
else:
|
| 586 |
+
down_proj = self.down_proj(self.act_fn(
|
| 587 |
+
self.gate_proj(x)) * self.up_proj(x))
|
| 588 |
+
return down_proj
|
| 589 |
+
|
| 590 |
+
|
| 591 |
+
def apply_multimodal_rotary_pos_emb(q, k, cos, sin, mrope_section, unsqueeze_dim=1):
|
| 592 |
+
"""Applies Rotary Position Embedding with Multimodal Sections to the query and key tensors (https://qwenlm.github.io/blog/qwen2-vl/).
|
| 593 |
+
|
| 594 |
+
Explanation:
|
| 595 |
+
Multimodal 3D rotary position embedding is an extension to 1D rotary position embedding. The input embedding
|
| 596 |
+
sequence contains vision (images / videos) embedding and text embedding or just contains text embedding. For
|
| 597 |
+
vision embedding part, we apply rotary position embedding on temporal, height and width dimension separately.
|
| 598 |
+
Here we split the channel dimension to 3 chunks for the temporal, height and width rotary position embedding.
|
| 599 |
+
For text embedding part, we just apply 1D rotary position embedding. The three rotary position index (temporal,
|
| 600 |
+
height and width) of text embedding is always the same, so the text embedding rotary position embedding has no
|
| 601 |
+
difference with modern LLMs.
|
| 602 |
+
|
| 603 |
+
Args:
|
| 604 |
+
q (`torch.Tensor`): The query tensor.
|
| 605 |
+
k (`torch.Tensor`): The key tensor.
|
| 606 |
+
cos (`torch.Tensor`): The cosine part of the rotary embedding.
|
| 607 |
+
sin (`torch.Tensor`): The sine part of the rotary embedding.
|
| 608 |
+
position_ids (`torch.Tensor`):
|
| 609 |
+
The position indices of the tokens corresponding to the query and key tensors. For example, this can be
|
| 610 |
+
used to pass offsetted position ids when working with a KV-cache.
|
| 611 |
+
mrope_section(`List(int)`):
|
| 612 |
+
Multimodal rope section is for channel dimension of temporal, height and width in rope calculation.
|
| 613 |
+
unsqueeze_dim (`int`, *optional*, defaults to 1):
|
| 614 |
+
The 'unsqueeze_dim' argument specifies the dimension along which to unsqueeze cos[position_ids] and
|
| 615 |
+
sin[position_ids] so that they can be properly broadcasted to the dimensions of q and k. For example, note
|
| 616 |
+
that cos[position_ids] and sin[position_ids] have the shape [batch_size, seq_len, head_dim]. Then, if q and
|
| 617 |
+
k have the shape [batch_size, heads, seq_len, head_dim], then setting unsqueeze_dim=1 makes
|
| 618 |
+
cos[position_ids] and sin[position_ids] broadcastable to the shapes of q and k. Similarly, if q and k have
|
| 619 |
+
the shape [batch_size, seq_len, heads, head_dim], then set unsqueeze_dim=2.
|
| 620 |
+
Returns:
|
| 621 |
+
`tuple(torch.Tensor)` comprising of the query and key tensors rotated using the Rotary Position Embedding.
|
| 622 |
+
"""
|
| 623 |
+
mrope_section = mrope_section * 2
|
| 624 |
+
cos = torch.cat([m[i % 3] for i, m in enumerate(cos.split(mrope_section, dim=-1))], dim=-1).unsqueeze(
|
| 625 |
+
unsqueeze_dim
|
| 626 |
+
)
|
| 627 |
+
sin = torch.cat([m[i % 3] for i, m in enumerate(sin.split(mrope_section, dim=-1))], dim=-1).unsqueeze(
|
| 628 |
+
unsqueeze_dim
|
| 629 |
+
)
|
| 630 |
+
|
| 631 |
+
q_embed = (q * cos) + (rotate_half(q) * sin)
|
| 632 |
+
k_embed = (k * cos) + (rotate_half(k) * sin)
|
| 633 |
+
return q_embed, k_embed
|
| 634 |
+
|
| 635 |
+
|
| 636 |
+
class EchoAttention(nn.Module):
|
| 637 |
+
"""
|
| 638 |
+
Multi-headed attention from 'Attention Is All You Need' paper. Modified to use sliding window attention: Longformer
|
| 639 |
+
and "Generating Long Sequences with Sparse Transformers".
|
| 640 |
+
"""
|
| 641 |
+
|
| 642 |
+
def __init__(self, config: EchoTextConfig, layer_idx: Optional[int] = None):
|
| 643 |
+
super().__init__()
|
| 644 |
+
self.config = config
|
| 645 |
+
self.layer_idx = layer_idx
|
| 646 |
+
if layer_idx is None:
|
| 647 |
+
logger.warning_once(
|
| 648 |
+
f"Instantiating {self.__class__.__name__} without passing `layer_idx` is not recommended and will "
|
| 649 |
+
"to errors during the forward call, if caching is used. Please make sure to provide a `layer_idx` "
|
| 650 |
+
"when creating this class."
|
| 651 |
+
)
|
| 652 |
+
|
| 653 |
+
self.hidden_size = config.hidden_size
|
| 654 |
+
self.num_heads = config.num_attention_heads
|
| 655 |
+
self.head_dim = self.hidden_size // self.num_heads
|
| 656 |
+
self.num_key_value_heads = config.num_key_value_heads
|
| 657 |
+
self.num_key_value_groups = self.num_heads // self.num_key_value_heads
|
| 658 |
+
self.is_causal = True
|
| 659 |
+
self.attention_dropout = config.attention_dropout
|
| 660 |
+
self.rope_scaling = config.rope_scaling
|
| 661 |
+
self.scaling = self.head_dim**-0.5
|
| 662 |
+
|
| 663 |
+
if (self.head_dim * self.num_heads) != self.hidden_size:
|
| 664 |
+
raise ValueError(
|
| 665 |
+
f"hidden_size must be divisible by num_heads (got `hidden_size`: {self.hidden_size}"
|
| 666 |
+
f" and `num_heads`: {self.num_heads})."
|
| 667 |
+
)
|
| 668 |
+
self.q_proj = nn.Linear(self.hidden_size, self.num_heads * self.head_dim, bias=True)
|
| 669 |
+
self.k_proj = nn.Linear(self.hidden_size, self.num_key_value_heads * self.head_dim, bias=True)
|
| 670 |
+
self.v_proj = nn.Linear(self.hidden_size, self.num_key_value_heads * self.head_dim, bias=True)
|
| 671 |
+
self.o_proj = nn.Linear(self.num_heads * self.head_dim, self.hidden_size, bias=False)
|
| 672 |
+
self.sliding_window = config.sliding_window if config.layer_types[layer_idx] == "sliding_attention" else None
|
| 673 |
+
|
| 674 |
+
self.rotary_emb = EchoRotaryEmbedding(config=config)
|
| 675 |
+
|
| 676 |
+
def forward(
|
| 677 |
+
self,
|
| 678 |
+
hidden_states: torch.Tensor,
|
| 679 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 680 |
+
position_ids: Optional[torch.LongTensor] = None,
|
| 681 |
+
past_key_values: Optional[Cache] = None,
|
| 682 |
+
output_attentions: bool = False,
|
| 683 |
+
use_cache: bool = False,
|
| 684 |
+
cache_position: Optional[torch.LongTensor] = None,
|
| 685 |
+
store_kv: Optional[bool] = False,
|
| 686 |
+
store_kv_len: Optional[int] = None,
|
| 687 |
+
position_embeddings: Optional[tuple[torch.Tensor, torch.Tensor]] = None, # necessary, but kept here for BC
|
| 688 |
+
**kwargs: Unpack[FlashAttentionKwargs],
|
| 689 |
+
) -> tuple[torch.Tensor, Optional[torch.Tensor], Optional[tuple[torch.Tensor]]]:
|
| 690 |
+
input_shape = hidden_states.shape[:-1]
|
| 691 |
+
hidden_shape = (*input_shape, -1, self.head_dim)
|
| 692 |
+
bsz, q_len, _ = hidden_states.size()
|
| 693 |
+
|
| 694 |
+
query_states = self.q_proj(hidden_states)
|
| 695 |
+
key_states = self.k_proj(hidden_states)
|
| 696 |
+
value_states = self.v_proj(hidden_states)
|
| 697 |
+
|
| 698 |
+
query_states = query_states.view(bsz, q_len, -1, self.head_dim).transpose(1, 2)
|
| 699 |
+
key_states = key_states.view(bsz, q_len, -1, self.head_dim).transpose(1, 2)
|
| 700 |
+
value_states = value_states.view(bsz, q_len, -1, self.head_dim).transpose(1, 2)
|
| 701 |
+
|
| 702 |
+
cos, sin = position_embeddings
|
| 703 |
+
query_states, key_states = apply_multimodal_rotary_pos_emb(
|
| 704 |
+
query_states, key_states, cos, sin, self.rope_scaling["mrope_section"]
|
| 705 |
+
)
|
| 706 |
+
|
| 707 |
+
|
| 708 |
+
if past_key_values is not None and store_kv:
|
| 709 |
+
if store_kv_len is not None and 0 < store_kv_len < q_len:
|
| 710 |
+
# Partial-store: only cache KV for the first store_kv_len tokens (prev finalized block).
|
| 711 |
+
# The remaining tokens (current masked block) are only used for this forward's attention.
|
| 712 |
+
cache_kwargs = {"sin": sin, "cos": cos, "cache_position": cache_position[:store_kv_len]}
|
| 713 |
+
cached_k, cached_v = past_key_values.update(
|
| 714 |
+
key_states[:, :, :store_kv_len, :],
|
| 715 |
+
value_states[:, :, :store_kv_len, :],
|
| 716 |
+
self.layer_idx,
|
| 717 |
+
cache_kwargs,
|
| 718 |
+
)
|
| 719 |
+
# Attention sees: past KV (now including stored portion) + non-stored tokens
|
| 720 |
+
key_states = torch.cat([cached_k, key_states[:, :, store_kv_len:, :]], dim=-2)
|
| 721 |
+
value_states = torch.cat([cached_v, value_states[:, :, store_kv_len:, :]], dim=-2)
|
| 722 |
+
else:
|
| 723 |
+
cache_kwargs = {"sin": sin, "cos": cos, "cache_position": cache_position}
|
| 724 |
+
key_states, value_states = past_key_values.update(
|
| 725 |
+
key_states, value_states, self.layer_idx, cache_kwargs
|
| 726 |
+
)
|
| 727 |
+
|
| 728 |
+
elif past_key_values is not None and (not store_kv) and len(past_key_values) > self.layer_idx:
|
| 729 |
+
past_key_states, past_value_states = past_key_values[self.layer_idx]
|
| 730 |
+
key_states = torch.cat([past_key_states, key_states], dim=-2)
|
| 731 |
+
value_states = torch.cat([past_value_states, value_states], dim=-2)
|
| 732 |
+
|
| 733 |
+
|
| 734 |
+
attention_interface: Callable = eager_attention_forward
|
| 735 |
+
if self.config._attn_implementation != "eager":
|
| 736 |
+
attention_interface = ALL_ATTENTION_FUNCTIONS[self.config._attn_implementation]
|
| 737 |
+
|
| 738 |
+
attention_mask = attention_mask.bool() if attention_mask is not None else None
|
| 739 |
+
attn_weights = None
|
| 740 |
+
if torch.all(attention_mask): # decoding
|
| 741 |
+
query_states = query_states.transpose(1, 2)
|
| 742 |
+
key_states = key_states.transpose(1, 2)
|
| 743 |
+
value_states = value_states.transpose(1, 2)
|
| 744 |
+
attn_output = flash_attn_func(
|
| 745 |
+
query_states,
|
| 746 |
+
key_states,
|
| 747 |
+
value_states,
|
| 748 |
+
causal=False,
|
| 749 |
+
softmax_scale=self.scaling
|
| 750 |
+
)
|
| 751 |
+
attn_output = rearrange(attn_output, 'b l h d -> b l (h d)')
|
| 752 |
+
else: # prefilling
|
| 753 |
+
attn_output = F.scaled_dot_product_attention(
|
| 754 |
+
query=query_states,
|
| 755 |
+
key=key_states,
|
| 756 |
+
value=value_states,
|
| 757 |
+
attn_mask=attention_mask,
|
| 758 |
+
is_causal=False,
|
| 759 |
+
scale=self.scaling,
|
| 760 |
+
enable_gqa=True
|
| 761 |
+
)
|
| 762 |
+
attn_output = rearrange(attn_output, 'b h l d -> b l (h d)')
|
| 763 |
+
|
| 764 |
+
attn_output = attn_output.reshape(*input_shape, -1).contiguous()
|
| 765 |
+
attn_output = self.o_proj(attn_output)
|
| 766 |
+
return attn_output, attn_weights
|
| 767 |
+
|
| 768 |
+
|
| 769 |
+
class EchoDecoderLayer(GradientCheckpointingLayer):
|
| 770 |
+
def __init__(self, config: EchoTextConfig, layer_idx: int):
|
| 771 |
+
super().__init__()
|
| 772 |
+
self.hidden_size = config.hidden_size
|
| 773 |
+
|
| 774 |
+
if config.use_sliding_window and config._attn_implementation != "flash_attention_2":
|
| 775 |
+
logger.warning_once(
|
| 776 |
+
f"Sliding Window Attention is enabled but not implemented for `{config._attn_implementation}`; "
|
| 777 |
+
"unexpected results may be encountered."
|
| 778 |
+
)
|
| 779 |
+
self.self_attn = EchoAttention(config, layer_idx)
|
| 780 |
+
|
| 781 |
+
self.mlp = Qwen2MLP(config)
|
| 782 |
+
self.input_layernorm = Qwen2RMSNorm(config.hidden_size, eps=config.rms_norm_eps)
|
| 783 |
+
self.post_attention_layernorm = Qwen2RMSNorm(config.hidden_size, eps=config.rms_norm_eps)
|
| 784 |
+
self.attention_type = config.layer_types[layer_idx]
|
| 785 |
+
|
| 786 |
+
def forward(
|
| 787 |
+
self,
|
| 788 |
+
hidden_states: torch.Tensor,
|
| 789 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 790 |
+
position_ids: Optional[torch.LongTensor] = None,
|
| 791 |
+
past_key_values: Optional[tuple[torch.Tensor]] = None,
|
| 792 |
+
output_attentions: Optional[bool] = False,
|
| 793 |
+
use_cache: Optional[bool] = False,
|
| 794 |
+
cache_position: Optional[torch.LongTensor] = None,
|
| 795 |
+
store_kv: Optional[bool] = False,
|
| 796 |
+
store_kv_len: Optional[int] = None,
|
| 797 |
+
position_embeddings: Optional[tuple[torch.Tensor, torch.Tensor]] = None, # necessary, but kept here for BC
|
| 798 |
+
**kwargs: Unpack[FlashAttentionKwargs],
|
| 799 |
+
) -> tuple[torch.FloatTensor, Optional[tuple[torch.FloatTensor, torch.FloatTensor]]]:
|
| 800 |
+
"""
|
| 801 |
+
Args:
|
| 802 |
+
hidden_states (`torch.FloatTensor`): input to the layer of shape `(batch, seq_len, embed_dim)`
|
| 803 |
+
attention_mask (`torch.FloatTensor`, *optional*): attention mask of size
|
| 804 |
+
`(batch, sequence_length)` where padding elements are indicated by 0.
|
| 805 |
+
output_attentions (`bool`, *optional*):
|
| 806 |
+
Whether or not to return the attentions tensors of all attention layers. See `attentions` under
|
| 807 |
+
returned tensors for more detail.
|
| 808 |
+
use_cache (`bool`, *optional*):
|
| 809 |
+
If set to `True`, `past_key_values` key value states are returned and can be used to speed up decoding
|
| 810 |
+
(see `past_key_values`).
|
| 811 |
+
past_key_value (`Tuple(torch.FloatTensor)`, *optional*): cached past key and value projection states
|
| 812 |
+
cache_position (`torch.LongTensor` of shape `(sequence_length)`, *optional*):
|
| 813 |
+
Indices depicting the position of the input sequence tokens in the sequence.
|
| 814 |
+
position_embeddings (`tuple[torch.FloatTensor, torch.FloatTensor]`, *optional*):
|
| 815 |
+
Tuple containing the cosine and sine positional embeddings of shape `(batch_size, seq_len, head_dim)`,
|
| 816 |
+
with `head_dim` being the embedding dimension of each attention head.
|
| 817 |
+
kwargs (`dict`, *optional*):
|
| 818 |
+
Arbitrary kwargs to be ignored, used for FSDP and other methods that injects code
|
| 819 |
+
into the model
|
| 820 |
+
"""
|
| 821 |
+
|
| 822 |
+
residual = hidden_states
|
| 823 |
+
|
| 824 |
+
hidden_states = self.input_layernorm(hidden_states)
|
| 825 |
+
|
| 826 |
+
# Self Attention
|
| 827 |
+
hidden_states, self_attn_weights = self.self_attn(
|
| 828 |
+
hidden_states=hidden_states,
|
| 829 |
+
attention_mask=attention_mask,
|
| 830 |
+
position_ids=position_ids,
|
| 831 |
+
past_key_values=past_key_values,
|
| 832 |
+
output_attentions=output_attentions,
|
| 833 |
+
use_cache=use_cache,
|
| 834 |
+
cache_position=cache_position,
|
| 835 |
+
store_kv=store_kv,
|
| 836 |
+
store_kv_len=store_kv_len,
|
| 837 |
+
position_embeddings=position_embeddings,
|
| 838 |
+
**kwargs,
|
| 839 |
+
)
|
| 840 |
+
hidden_states = residual + hidden_states
|
| 841 |
+
|
| 842 |
+
# Fully Connected
|
| 843 |
+
residual = hidden_states
|
| 844 |
+
hidden_states = self.post_attention_layernorm(hidden_states)
|
| 845 |
+
hidden_states = self.mlp(hidden_states)
|
| 846 |
+
hidden_states = residual + hidden_states
|
| 847 |
+
|
| 848 |
+
outputs = (hidden_states,)
|
| 849 |
+
|
| 850 |
+
if output_attentions:
|
| 851 |
+
outputs += (self_attn_weights,)
|
| 852 |
+
|
| 853 |
+
return outputs
|
| 854 |
+
|
| 855 |
+
|
| 856 |
+
@auto_docstring
|
| 857 |
+
class EchoTextModel(EchoPreTrainedModel):
|
| 858 |
+
config: EchoTextConfig
|
| 859 |
+
|
| 860 |
+
def __init__(self, config: EchoTextConfig):
|
| 861 |
+
super().__init__(config)
|
| 862 |
+
self.padding_idx = config.pad_token_id
|
| 863 |
+
self.vocab_size = config.vocab_size
|
| 864 |
+
|
| 865 |
+
self.embed_tokens = nn.Embedding(config.vocab_size, config.hidden_size, self.padding_idx)
|
| 866 |
+
self.layers = nn.ModuleList(
|
| 867 |
+
[EchoDecoderLayer(config, layer_idx) for layer_idx in range(config.num_hidden_layers)]
|
| 868 |
+
)
|
| 869 |
+
self._attn_implementation = config._attn_implementation
|
| 870 |
+
self.norm = Qwen2RMSNorm(config.hidden_size, eps=config.rms_norm_eps)
|
| 871 |
+
self.rotary_emb = EchoRotaryEmbedding(config=config)
|
| 872 |
+
self.has_sliding_layers = "sliding_attention" in self.config.layer_types
|
| 873 |
+
|
| 874 |
+
self.gradient_checkpointing = False
|
| 875 |
+
# Initialize weights and apply final processing
|
| 876 |
+
self.post_init()
|
| 877 |
+
|
| 878 |
+
@auto_docstring
|
| 879 |
+
def forward(
|
| 880 |
+
self,
|
| 881 |
+
input_ids: Optional[torch.LongTensor] = None,
|
| 882 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 883 |
+
position_ids: Optional[torch.LongTensor] = None,
|
| 884 |
+
past_key_values: Optional[Cache] = None,
|
| 885 |
+
inputs_embeds: Optional[torch.FloatTensor] = None,
|
| 886 |
+
use_cache: Optional[bool] = None,
|
| 887 |
+
output_attentions: Optional[bool] = None,
|
| 888 |
+
output_hidden_states: Optional[bool] = None,
|
| 889 |
+
return_dict: Optional[bool] = None,
|
| 890 |
+
cache_position: Optional[torch.LongTensor] = None,
|
| 891 |
+
store_kv: Optional[bool] = False,
|
| 892 |
+
store_kv_len: Optional[int] = None,
|
| 893 |
+
**kwargs: Unpack[FlashAttentionKwargs],
|
| 894 |
+
) -> Union[tuple, BaseModelOutputWithPast]:
|
| 895 |
+
output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
|
| 896 |
+
output_hidden_states = (
|
| 897 |
+
output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
|
| 898 |
+
)
|
| 899 |
+
use_cache = use_cache if use_cache is not None else self.config.use_cache
|
| 900 |
+
|
| 901 |
+
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
| 902 |
+
|
| 903 |
+
if (input_ids is None) ^ (inputs_embeds is not None):
|
| 904 |
+
raise ValueError("You must specify exactly one of input_ids or inputs_embeds")
|
| 905 |
+
|
| 906 |
+
if self.gradient_checkpointing and self.training:
|
| 907 |
+
if use_cache:
|
| 908 |
+
logger.warning_once(
|
| 909 |
+
"`use_cache=True` is incompatible with gradient checkpointing. Setting `use_cache=False`..."
|
| 910 |
+
)
|
| 911 |
+
use_cache = False
|
| 912 |
+
|
| 913 |
+
# torch.jit.trace() doesn't support cache objects in the output
|
| 914 |
+
if use_cache and past_key_values is None and not torch.jit.is_tracing():
|
| 915 |
+
past_key_values = DynamicCache()
|
| 916 |
+
|
| 917 |
+
if inputs_embeds is None:
|
| 918 |
+
inputs_embeds = self.embed_tokens(input_ids)
|
| 919 |
+
|
| 920 |
+
if cache_position is None:
|
| 921 |
+
past_seen_tokens = past_key_values.get_seq_length() if past_key_values is not None else 0
|
| 922 |
+
cache_position = torch.arange(
|
| 923 |
+
past_seen_tokens, past_seen_tokens + inputs_embeds.shape[1], device=inputs_embeds.device
|
| 924 |
+
)
|
| 925 |
+
|
| 926 |
+
# the hard coded `3` is for temporal, height and width.
|
| 927 |
+
if position_ids is None:
|
| 928 |
+
position_ids = cache_position.view(1, 1, -1).expand(3, inputs_embeds.shape[0], -1)
|
| 929 |
+
elif position_ids.ndim == 2:
|
| 930 |
+
position_ids = position_ids[None, ...].expand(3, position_ids.shape[0], -1)
|
| 931 |
+
|
| 932 |
+
# NOTE: we need to pass text position ids for packing. Qwen2-VL uses 3D positions
|
| 933 |
+
# where each dim indicates visual spatial positions for temporal/height/width grids.
|
| 934 |
+
# There are two scenarios when FA2-like packed masking might be activated.
|
| 935 |
+
# 1. User specifically passed packed `position_ids` and no attention mask.
|
| 936 |
+
# In this case we expect the useer to create correct position ids for all 3 grids
|
| 937 |
+
# and prepend text-only position ids to it. The final tensor will be [4, bs, seq-len]
|
| 938 |
+
# 2. User runs forward with no attention mask and no position ids. In this case, position ids
|
| 939 |
+
# are prepared by the model (`get_rope_index`) as `[4, bs, seq-len]` tensor. Text-only positions are
|
| 940 |
+
# prepended by us when creating positions so that the mask is constructed correctly. NOTE: failing to pass
|
| 941 |
+
# text-only positions will cause incorrect mask construction, do not change `prepare_input_for_generation`
|
| 942 |
+
if position_ids.ndim == 3 and position_ids.shape[0] == 4:
|
| 943 |
+
text_position_ids = position_ids[0]
|
| 944 |
+
position_ids = position_ids[1:]
|
| 945 |
+
else:
|
| 946 |
+
text_position_ids = position_ids[0]
|
| 947 |
+
|
| 948 |
+
# It may already have been prepared by e.g. `generate`
|
| 949 |
+
if not isinstance(causal_mask_mapping := attention_mask, dict):
|
| 950 |
+
# Prepare mask arguments
|
| 951 |
+
mask_kwargs = {
|
| 952 |
+
"config": self.config,
|
| 953 |
+
"input_embeds": inputs_embeds,
|
| 954 |
+
"attention_mask": attention_mask,
|
| 955 |
+
"cache_position": cache_position,
|
| 956 |
+
"past_key_values": past_key_values,
|
| 957 |
+
"position_ids": text_position_ids,
|
| 958 |
+
}
|
| 959 |
+
# Create the masks
|
| 960 |
+
causal_mask_mapping = {
|
| 961 |
+
"full_attention": create_causal_mask(**mask_kwargs),
|
| 962 |
+
}
|
| 963 |
+
# The sliding window alternating layers are not always activated depending on the config
|
| 964 |
+
if self.has_sliding_layers:
|
| 965 |
+
causal_mask_mapping["sliding_attention"] = create_sliding_window_causal_mask(**mask_kwargs)
|
| 966 |
+
|
| 967 |
+
hidden_states = inputs_embeds
|
| 968 |
+
|
| 969 |
+
# create position embeddings to be shared across the decoder layers
|
| 970 |
+
position_embeddings = self.rotary_emb(hidden_states, position_ids)
|
| 971 |
+
|
| 972 |
+
# decoder layers
|
| 973 |
+
all_hidden_states = () if output_hidden_states else None
|
| 974 |
+
all_self_attns = () if output_attentions else None
|
| 975 |
+
|
| 976 |
+
for decoder_layer in self.layers:
|
| 977 |
+
if output_hidden_states:
|
| 978 |
+
all_hidden_states += (hidden_states,)
|
| 979 |
+
|
| 980 |
+
layer_outputs = decoder_layer(
|
| 981 |
+
hidden_states,
|
| 982 |
+
attention_mask=causal_mask_mapping[decoder_layer.attention_type],
|
| 983 |
+
position_ids=text_position_ids,
|
| 984 |
+
past_key_values=past_key_values,
|
| 985 |
+
output_attentions=output_attentions,
|
| 986 |
+
use_cache=use_cache,
|
| 987 |
+
cache_position=cache_position,
|
| 988 |
+
position_embeddings=position_embeddings,
|
| 989 |
+
store_kv=store_kv,
|
| 990 |
+
store_kv_len=store_kv_len,
|
| 991 |
+
**kwargs,
|
| 992 |
+
)
|
| 993 |
+
|
| 994 |
+
hidden_states = layer_outputs[0]
|
| 995 |
+
|
| 996 |
+
if output_attentions:
|
| 997 |
+
all_self_attns += (layer_outputs[1],)
|
| 998 |
+
|
| 999 |
+
hidden_states = self.norm(hidden_states)
|
| 1000 |
+
|
| 1001 |
+
# add hidden states from the last decoder layer
|
| 1002 |
+
if output_hidden_states:
|
| 1003 |
+
all_hidden_states += (hidden_states,)
|
| 1004 |
+
|
| 1005 |
+
if not return_dict:
|
| 1006 |
+
return tuple(
|
| 1007 |
+
v for v in [hidden_states, past_key_values, all_hidden_states, all_self_attns] if v is not None
|
| 1008 |
+
)
|
| 1009 |
+
return BaseModelOutputWithPast(
|
| 1010 |
+
last_hidden_state=hidden_states,
|
| 1011 |
+
past_key_values=past_key_values,
|
| 1012 |
+
hidden_states=all_hidden_states,
|
| 1013 |
+
attentions=all_self_attns,
|
| 1014 |
+
)
|
| 1015 |
+
|
| 1016 |
+
|
| 1017 |
+
@auto_docstring
|
| 1018 |
+
class EchoModel(EchoPreTrainedModel):
|
| 1019 |
+
base_model_prefix = ""
|
| 1020 |
+
_checkpoint_conversion_mapping = {"^model": "language_model"}
|
| 1021 |
+
config: EchoConfig
|
| 1022 |
+
_no_split_modules = ["EchoDecoderLayer", "EchoVisionBlock"]
|
| 1023 |
+
|
| 1024 |
+
def __init__(self, config):
|
| 1025 |
+
super().__init__(config)
|
| 1026 |
+
self.visual = Echo_VisionTransformerPretrainedModel._from_config(config.vision_config)
|
| 1027 |
+
self.language_model = EchoTextModel._from_config(config.text_config)
|
| 1028 |
+
self.rope_deltas = None # cache rope_deltas here
|
| 1029 |
+
|
| 1030 |
+
# Initialize weights and apply final processing
|
| 1031 |
+
self.post_init()
|
| 1032 |
+
|
| 1033 |
+
def get_input_embeddings(self):
|
| 1034 |
+
return self.language_model.get_input_embeddings()
|
| 1035 |
+
|
| 1036 |
+
def set_input_embeddings(self, value):
|
| 1037 |
+
self.language_model.set_input_embeddings(value)
|
| 1038 |
+
|
| 1039 |
+
def set_decoder(self, decoder):
|
| 1040 |
+
self.language_model = decoder
|
| 1041 |
+
|
| 1042 |
+
def get_decoder(self):
|
| 1043 |
+
return self.language_model
|
| 1044 |
+
|
| 1045 |
+
def get_rope_index(
|
| 1046 |
+
self,
|
| 1047 |
+
input_ids: Optional[torch.LongTensor] = None,
|
| 1048 |
+
image_grid_thw: Optional[torch.LongTensor] = None,
|
| 1049 |
+
video_grid_thw: Optional[torch.LongTensor] = None,
|
| 1050 |
+
second_per_grid_ts: Optional[torch.Tensor] = None,
|
| 1051 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 1052 |
+
) -> tuple[torch.Tensor, torch.Tensor]:
|
| 1053 |
+
"""
|
| 1054 |
+
Calculate the 3D rope index based on image and video's temporal, height and width in LLM.
|
| 1055 |
+
|
| 1056 |
+
Explanation:
|
| 1057 |
+
Each embedding sequence contains vision embedding and text embedding or just contains text embedding.
|
| 1058 |
+
|
| 1059 |
+
For pure text embedding sequence, the rotary position embedding has no difference with modern LLMs.
|
| 1060 |
+
Examples:
|
| 1061 |
+
input_ids: [T T T T T], here T is for text.
|
| 1062 |
+
temporal position_ids: [0, 1, 2, 3, 4]
|
| 1063 |
+
height position_ids: [0, 1, 2, 3, 4]
|
| 1064 |
+
width position_ids: [0, 1, 2, 3, 4]
|
| 1065 |
+
|
| 1066 |
+
For vision and text embedding sequence, we calculate 3D rotary position embedding for vision part
|
| 1067 |
+
and 1D rotary position embedding for text part.
|
| 1068 |
+
Examples:
|
| 1069 |
+
Temporal (Time): 3 patches, representing different segments of the video in time.
|
| 1070 |
+
Height: 2 patches, dividing each frame vertically.
|
| 1071 |
+
Width: 2 patches, dividing each frame horizontally.
|
| 1072 |
+
We also have some important parameters:
|
| 1073 |
+
fps (Frames Per Second): The video's frame rate, set to 1. This means one frame is processed each second.
|
| 1074 |
+
tokens_per_second: This is a crucial parameter. It dictates how many "time-steps" or "temporal tokens" are conceptually packed into a one-second interval of the video. In this case, we have 25 tokens per second. So each second of the video will be represented with 25 separate time points. It essentially defines the temporal granularity.
|
| 1075 |
+
temporal_patch_size: The number of frames that compose one temporal patch. Here, it's 2 frames.
|
| 1076 |
+
interval: The step size for the temporal position IDs, calculated as tokens_per_second * temporal_patch_size / fps. In this case, 25 * 2 / 1 = 50. This means that each temporal patch will be have a difference of 50 in the temporal position IDs.
|
| 1077 |
+
input_ids: [V V V V V V V V V V V V T T T T T], here V is for vision.
|
| 1078 |
+
vision temporal position_ids: [0, 0, 0, 0, 50, 50, 50, 50, 100, 100, 100, 100]
|
| 1079 |
+
vision height position_ids: [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1]
|
| 1080 |
+
vision width position_ids: [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]
|
| 1081 |
+
text temporal position_ids: [101, 102, 103, 104, 105]
|
| 1082 |
+
text height position_ids: [101, 102, 103, 104, 105]
|
| 1083 |
+
text width position_ids: [101, 102, 103, 104, 105]
|
| 1084 |
+
Here we calculate the text start position_ids as the max vision position_ids plus 1.
|
| 1085 |
+
|
| 1086 |
+
Args:
|
| 1087 |
+
input_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`):
|
| 1088 |
+
Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you provide
|
| 1089 |
+
it.
|
| 1090 |
+
image_grid_thw (`torch.LongTensor` of shape `(num_images, 3)`, *optional*):
|
| 1091 |
+
The temporal, height and width of feature shape of each image in LLM.
|
| 1092 |
+
video_grid_thw (`torch.LongTensor` of shape `(num_videos, 3)`, *optional*):
|
| 1093 |
+
The temporal, height and width of feature shape of each video in LLM.
|
| 1094 |
+
second_per_grid_ts (`torch.Tensor` of shape `(num_videos)`, *optional*):
|
| 1095 |
+
The time interval (in seconds) for each grid along the temporal dimension in the 3D position IDs.
|
| 1096 |
+
attention_mask (`torch.Tensor` of shape `(batch_size, sequence_length)`, *optional*):
|
| 1097 |
+
Mask to avoid performing attention on padding token indices. Mask values selected in `[0, 1]`:
|
| 1098 |
+
|
| 1099 |
+
- 1 for tokens that are **not masked**,
|
| 1100 |
+
- 0 for tokens that are **masked**.
|
| 1101 |
+
|
| 1102 |
+
Returns:
|
| 1103 |
+
position_ids (`torch.LongTensor` of shape `(3, batch_size, sequence_length)`)
|
| 1104 |
+
mrope_position_deltas (`torch.Tensor` of shape `(batch_size)`)
|
| 1105 |
+
"""
|
| 1106 |
+
spatial_merge_size = self.config.vision_config.spatial_merge_size
|
| 1107 |
+
image_token_id = self.config.image_token_id
|
| 1108 |
+
video_token_id = self.config.video_token_id
|
| 1109 |
+
vision_start_token_id = self.config.vision_start_token_id
|
| 1110 |
+
mrope_position_deltas = []
|
| 1111 |
+
if input_ids is not None and (image_grid_thw is not None or video_grid_thw is not None):
|
| 1112 |
+
total_input_ids = input_ids
|
| 1113 |
+
if attention_mask is None:
|
| 1114 |
+
attention_mask = torch.ones_like(total_input_ids)
|
| 1115 |
+
position_ids = torch.ones(
|
| 1116 |
+
3,
|
| 1117 |
+
input_ids.shape[0],
|
| 1118 |
+
input_ids.shape[1],
|
| 1119 |
+
dtype=input_ids.dtype,
|
| 1120 |
+
device=input_ids.device,
|
| 1121 |
+
)
|
| 1122 |
+
image_index, video_index = 0, 0
|
| 1123 |
+
attention_mask = attention_mask.to(total_input_ids.device)
|
| 1124 |
+
for i, input_ids in enumerate(total_input_ids):
|
| 1125 |
+
input_ids = input_ids[attention_mask[i] == 1]
|
| 1126 |
+
image_nums, video_nums = 0, 0
|
| 1127 |
+
vision_start_indices = torch.argwhere(input_ids == vision_start_token_id).squeeze(1)
|
| 1128 |
+
vision_tokens = input_ids[vision_start_indices + 1]
|
| 1129 |
+
image_nums = (vision_tokens == image_token_id).sum()
|
| 1130 |
+
video_nums = (vision_tokens == video_token_id).sum()
|
| 1131 |
+
input_tokens = input_ids.tolist()
|
| 1132 |
+
llm_pos_ids_list: list = []
|
| 1133 |
+
st = 0
|
| 1134 |
+
remain_images, remain_videos = image_nums, video_nums
|
| 1135 |
+
for _ in range(image_nums + video_nums):
|
| 1136 |
+
if image_token_id in input_tokens and remain_images > 0:
|
| 1137 |
+
ed_image = input_tokens.index(image_token_id, st)
|
| 1138 |
+
else:
|
| 1139 |
+
ed_image = len(input_tokens) + 1
|
| 1140 |
+
if video_token_id in input_tokens and remain_videos > 0:
|
| 1141 |
+
ed_video = input_tokens.index(video_token_id, st)
|
| 1142 |
+
else:
|
| 1143 |
+
ed_video = len(input_tokens) + 1
|
| 1144 |
+
if ed_image < ed_video:
|
| 1145 |
+
t, h, w = (
|
| 1146 |
+
image_grid_thw[image_index][0],
|
| 1147 |
+
image_grid_thw[image_index][1],
|
| 1148 |
+
image_grid_thw[image_index][2],
|
| 1149 |
+
)
|
| 1150 |
+
second_per_grid_t = 0
|
| 1151 |
+
image_index += 1
|
| 1152 |
+
remain_images -= 1
|
| 1153 |
+
ed = ed_image
|
| 1154 |
+
|
| 1155 |
+
else:
|
| 1156 |
+
t, h, w = (
|
| 1157 |
+
video_grid_thw[video_index][0],
|
| 1158 |
+
video_grid_thw[video_index][1],
|
| 1159 |
+
video_grid_thw[video_index][2],
|
| 1160 |
+
)
|
| 1161 |
+
if second_per_grid_ts is not None:
|
| 1162 |
+
second_per_grid_t = second_per_grid_ts[video_index]
|
| 1163 |
+
else:
|
| 1164 |
+
second_per_grid_t = 1.0
|
| 1165 |
+
video_index += 1
|
| 1166 |
+
remain_videos -= 1
|
| 1167 |
+
ed = ed_video
|
| 1168 |
+
llm_grid_t, llm_grid_h, llm_grid_w = (
|
| 1169 |
+
t.item(),
|
| 1170 |
+
h.item() // spatial_merge_size,
|
| 1171 |
+
w.item() // spatial_merge_size,
|
| 1172 |
+
)
|
| 1173 |
+
text_len = ed - st
|
| 1174 |
+
|
| 1175 |
+
st_idx = llm_pos_ids_list[-1].max() + 1 if len(llm_pos_ids_list) > 0 else 0
|
| 1176 |
+
llm_pos_ids_list.append(torch.arange(text_len).view(1, -1).expand(3, -1) + st_idx)
|
| 1177 |
+
|
| 1178 |
+
range_tensor = torch.arange(llm_grid_t).view(-1, 1)
|
| 1179 |
+
expanded_range = range_tensor.expand(-1, llm_grid_h * llm_grid_w)
|
| 1180 |
+
|
| 1181 |
+
## normalize type, send to device.
|
| 1182 |
+
second_per_grid_t = torch.as_tensor(
|
| 1183 |
+
second_per_grid_t, dtype=range_tensor.dtype, device=range_tensor.device
|
| 1184 |
+
)
|
| 1185 |
+
|
| 1186 |
+
time_tensor = expanded_range * second_per_grid_t * self.config.vision_config.tokens_per_second
|
| 1187 |
+
|
| 1188 |
+
time_tensor_long = time_tensor.long()
|
| 1189 |
+
t_index = time_tensor_long.flatten()
|
| 1190 |
+
|
| 1191 |
+
h_index = torch.arange(llm_grid_h).view(1, -1, 1).expand(llm_grid_t, -1, llm_grid_w).flatten()
|
| 1192 |
+
w_index = torch.arange(llm_grid_w).view(1, 1, -1).expand(llm_grid_t, llm_grid_h, -1).flatten()
|
| 1193 |
+
llm_pos_ids_list.append(torch.stack([t_index, h_index, w_index]) + text_len + st_idx)
|
| 1194 |
+
st = ed + llm_grid_t * llm_grid_h * llm_grid_w
|
| 1195 |
+
|
| 1196 |
+
if st < len(input_tokens):
|
| 1197 |
+
st_idx = llm_pos_ids_list[-1].max() + 1 if len(llm_pos_ids_list) > 0 else 0
|
| 1198 |
+
text_len = len(input_tokens) - st
|
| 1199 |
+
llm_pos_ids_list.append(torch.arange(text_len).view(1, -1).expand(3, -1) + st_idx)
|
| 1200 |
+
|
| 1201 |
+
llm_positions = torch.cat(llm_pos_ids_list, dim=1).reshape(3, -1)
|
| 1202 |
+
position_ids[..., i, attention_mask[i] == 1] = llm_positions.to(position_ids.device)
|
| 1203 |
+
mrope_position_deltas.append(llm_positions.max() + 1 - len(total_input_ids[i]))
|
| 1204 |
+
mrope_position_deltas = torch.tensor(mrope_position_deltas, device=input_ids.device).unsqueeze(1)
|
| 1205 |
+
return position_ids, mrope_position_deltas
|
| 1206 |
+
else:
|
| 1207 |
+
if attention_mask is not None:
|
| 1208 |
+
position_ids = attention_mask.long().cumsum(-1) - 1
|
| 1209 |
+
position_ids.masked_fill_(attention_mask == 0, 1)
|
| 1210 |
+
position_ids = position_ids.unsqueeze(0).expand(3, -1, -1).to(attention_mask.device)
|
| 1211 |
+
max_position_ids = position_ids.max(0, keepdim=False)[0].max(-1, keepdim=True)[0]
|
| 1212 |
+
mrope_position_deltas = max_position_ids + 1 - attention_mask.shape[-1]
|
| 1213 |
+
else:
|
| 1214 |
+
position_ids = (
|
| 1215 |
+
torch.arange(input_ids.shape[1], device=input_ids.device)
|
| 1216 |
+
.view(1, 1, -1)
|
| 1217 |
+
.expand(3, input_ids.shape[0], -1)
|
| 1218 |
+
)
|
| 1219 |
+
mrope_position_deltas = torch.zeros(
|
| 1220 |
+
[input_ids.shape[0], 1],
|
| 1221 |
+
device=input_ids.device,
|
| 1222 |
+
dtype=input_ids.dtype,
|
| 1223 |
+
)
|
| 1224 |
+
|
| 1225 |
+
return position_ids, mrope_position_deltas
|
| 1226 |
+
|
| 1227 |
+
def get_video_features(
|
| 1228 |
+
self, pixel_values_videos: torch.FloatTensor, video_grid_thw: Optional[torch.LongTensor] = None
|
| 1229 |
+
):
|
| 1230 |
+
"""
|
| 1231 |
+
Encodes videos into continuous embeddings that can be forwarded to the language model.
|
| 1232 |
+
|
| 1233 |
+
Args:
|
| 1234 |
+
pixel_values_videos (`torch.FloatTensor` of shape `(batch_size, num_channels, image_size, image_size)`):
|
| 1235 |
+
The tensors corresponding to the input videos.
|
| 1236 |
+
video_grid_thw (`torch.LongTensor` of shape `(num_videos, 3)`, *optional*):
|
| 1237 |
+
The temporal, height and width of feature shape of each video in LLM.
|
| 1238 |
+
"""
|
| 1239 |
+
pixel_values_videos = pixel_values_videos.type(self.visual.dtype)
|
| 1240 |
+
video_embeds = self.visual(pixel_values_videos, grid_thw=video_grid_thw)
|
| 1241 |
+
split_sizes = (video_grid_thw.prod(-1) // self.visual.spatial_merge_size**2).tolist()
|
| 1242 |
+
video_embeds = torch.split(video_embeds, split_sizes)
|
| 1243 |
+
return video_embeds
|
| 1244 |
+
|
| 1245 |
+
def get_image_features(self, pixel_values: torch.FloatTensor, image_grid_thw: Optional[torch.LongTensor] = None):
|
| 1246 |
+
"""
|
| 1247 |
+
Encodes images into continuous embeddings that can be forwarded to the language model.
|
| 1248 |
+
|
| 1249 |
+
Args:
|
| 1250 |
+
pixel_values (`torch.FloatTensor` of shape `(batch_size, num_channels, image_size, image_size)`):
|
| 1251 |
+
The tensors corresponding to the input images.
|
| 1252 |
+
image_grid_thw (`torch.LongTensor` of shape `(num_images, 3)`, *optional*):
|
| 1253 |
+
The temporal, height and width of feature shape of each image in LLM.
|
| 1254 |
+
"""
|
| 1255 |
+
pixel_values = pixel_values.type(self.visual.dtype)
|
| 1256 |
+
image_embeds = self.visual(pixel_values, grid_thw=image_grid_thw)
|
| 1257 |
+
split_sizes = (image_grid_thw.prod(-1) // self.visual.spatial_merge_size**2).tolist()
|
| 1258 |
+
image_embeds = torch.split(image_embeds, split_sizes)
|
| 1259 |
+
return image_embeds
|
| 1260 |
+
|
| 1261 |
+
def get_placeholder_mask(
|
| 1262 |
+
self,
|
| 1263 |
+
input_ids: torch.LongTensor,
|
| 1264 |
+
inputs_embeds: torch.FloatTensor,
|
| 1265 |
+
image_features: torch.FloatTensor = None,
|
| 1266 |
+
video_features: torch.FloatTensor = None,
|
| 1267 |
+
):
|
| 1268 |
+
"""
|
| 1269 |
+
Obtains multimodal placeholdr mask from `input_ids` or `inputs_embeds`, and checks that the placeholder token count is
|
| 1270 |
+
equal to the length of multimodal features. If the lengths are different, an error is raised.
|
| 1271 |
+
"""
|
| 1272 |
+
if input_ids is None:
|
| 1273 |
+
special_image_mask = inputs_embeds == self.get_input_embeddings()(
|
| 1274 |
+
torch.tensor(self.config.image_token_id, dtype=torch.long, device=inputs_embeds.device)
|
| 1275 |
+
)
|
| 1276 |
+
special_image_mask = special_image_mask.all(-1)
|
| 1277 |
+
special_video_mask = inputs_embeds == self.get_input_embeddings()(
|
| 1278 |
+
torch.tensor(self.config.video_token_id, dtype=torch.long, device=inputs_embeds.device)
|
| 1279 |
+
)
|
| 1280 |
+
special_video_mask = special_video_mask.all(-1)
|
| 1281 |
+
else:
|
| 1282 |
+
special_image_mask = input_ids == self.config.image_token_id
|
| 1283 |
+
special_video_mask = input_ids == self.config.video_token_id
|
| 1284 |
+
|
| 1285 |
+
n_image_tokens = special_image_mask.sum()
|
| 1286 |
+
special_image_mask = special_image_mask.unsqueeze(-1).expand_as(inputs_embeds).to(inputs_embeds.device)
|
| 1287 |
+
if image_features is not None and inputs_embeds[special_image_mask].numel() != image_features.numel():
|
| 1288 |
+
raise ValueError(
|
| 1289 |
+
f"Image features and image tokens do not match: tokens: {n_image_tokens}, features {image_features.shape[0]}"
|
| 1290 |
+
)
|
| 1291 |
+
|
| 1292 |
+
n_video_tokens = special_video_mask.sum()
|
| 1293 |
+
special_video_mask = special_video_mask.unsqueeze(-1).expand_as(inputs_embeds).to(inputs_embeds.device)
|
| 1294 |
+
if video_features is not None and inputs_embeds[special_video_mask].numel() != video_features.numel():
|
| 1295 |
+
raise ValueError(
|
| 1296 |
+
f"Videos features and video tokens do not match: tokens: {n_video_tokens}, features {video_features.shape[0]}"
|
| 1297 |
+
)
|
| 1298 |
+
|
| 1299 |
+
return special_image_mask, special_video_mask
|
| 1300 |
+
|
| 1301 |
+
@auto_docstring
|
| 1302 |
+
def forward(
|
| 1303 |
+
self,
|
| 1304 |
+
input_ids: torch.LongTensor = None,
|
| 1305 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 1306 |
+
position_ids: Optional[torch.LongTensor] = None,
|
| 1307 |
+
past_key_values: Optional[Cache] = None,
|
| 1308 |
+
inputs_embeds: Optional[torch.FloatTensor] = None,
|
| 1309 |
+
use_cache: Optional[bool] = None,
|
| 1310 |
+
output_attentions: Optional[bool] = None,
|
| 1311 |
+
output_hidden_states: Optional[bool] = None,
|
| 1312 |
+
return_dict: Optional[bool] = None,
|
| 1313 |
+
pixel_values: Optional[torch.Tensor] = None,
|
| 1314 |
+
pixel_values_videos: Optional[torch.FloatTensor] = None,
|
| 1315 |
+
image_grid_thw: Optional[torch.LongTensor] = None,
|
| 1316 |
+
video_grid_thw: Optional[torch.LongTensor] = None,
|
| 1317 |
+
rope_deltas: Optional[torch.LongTensor] = None,
|
| 1318 |
+
cache_position: Optional[torch.LongTensor] = None,
|
| 1319 |
+
second_per_grid_ts: Optional[torch.Tensor] = None,
|
| 1320 |
+
store_kv: Optional[bool] = False,
|
| 1321 |
+
store_kv_len: Optional[int] = None,
|
| 1322 |
+
**kwargs: Unpack[TransformersKwargs],
|
| 1323 |
+
) -> Union[tuple, EchoModelOutputWithPast]:
|
| 1324 |
+
r"""
|
| 1325 |
+
image_grid_thw (`torch.LongTensor` of shape `(num_images, 3)`, *optional*):
|
| 1326 |
+
The temporal, height and width of feature shape of each image in LLM.
|
| 1327 |
+
video_grid_thw (`torch.LongTensor` of shape `(num_videos, 3)`, *optional*):
|
| 1328 |
+
The temporal, height and width of feature shape of each video in LLM.
|
| 1329 |
+
rope_deltas (`torch.LongTensor` of shape `(batch_size, )`, *optional*):
|
| 1330 |
+
The rope index difference between sequence length and multimodal rope.
|
| 1331 |
+
second_per_grid_ts (`torch.Tensor` of shape `(num_videos)`, *optional*):
|
| 1332 |
+
The time interval (in seconds) for each grid along the temporal dimension in the 3D position IDs.
|
| 1333 |
+
"""
|
| 1334 |
+
|
| 1335 |
+
output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
|
| 1336 |
+
output_hidden_states = (
|
| 1337 |
+
output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
|
| 1338 |
+
)
|
| 1339 |
+
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
| 1340 |
+
|
| 1341 |
+
if inputs_embeds is None:
|
| 1342 |
+
inputs_embeds = self.get_input_embeddings()(input_ids)
|
| 1343 |
+
|
| 1344 |
+
if pixel_values is not None:
|
| 1345 |
+
image_embeds = self.get_image_features(pixel_values, image_grid_thw)
|
| 1346 |
+
image_embeds = torch.cat(image_embeds, dim=0).to(inputs_embeds.device, inputs_embeds.dtype)
|
| 1347 |
+
image_mask, _ = self.get_placeholder_mask(
|
| 1348 |
+
input_ids, inputs_embeds=inputs_embeds, image_features=image_embeds
|
| 1349 |
+
)
|
| 1350 |
+
inputs_embeds = inputs_embeds.masked_scatter(image_mask, image_embeds)
|
| 1351 |
+
|
| 1352 |
+
if pixel_values_videos is not None:
|
| 1353 |
+
video_embeds = self.get_video_features(pixel_values_videos, video_grid_thw)
|
| 1354 |
+
video_embeds = torch.cat(video_embeds, dim=0).to(inputs_embeds.device, inputs_embeds.dtype)
|
| 1355 |
+
_, video_mask = self.get_placeholder_mask(
|
| 1356 |
+
input_ids, inputs_embeds=inputs_embeds, video_features=video_embeds
|
| 1357 |
+
)
|
| 1358 |
+
inputs_embeds = inputs_embeds.masked_scatter(video_mask, video_embeds)
|
| 1359 |
+
|
| 1360 |
+
if position_ids is None:
|
| 1361 |
+
attention_mask_tensor = (
|
| 1362 |
+
attention_mask if not isinstance(attention_mask, dict) else attention_mask["full_attention"]
|
| 1363 |
+
)
|
| 1364 |
+
if attention_mask_tensor is not None and attention_mask_tensor.ndim == 4:
|
| 1365 |
+
attention_mask_tensor = torch.diagonal(attention_mask_tensor[:, 0], dim1=1, dim2=2)
|
| 1366 |
+
# Only apply conversion for floating point tensors (inverted masks)
|
| 1367 |
+
if attention_mask_tensor.dtype.is_floating_point:
|
| 1368 |
+
attention_mask_tensor = attention_mask_tensor / torch.finfo(attention_mask_tensor.dtype).min
|
| 1369 |
+
attention_mask_tensor = (1.0 - attention_mask_tensor).int()
|
| 1370 |
+
|
| 1371 |
+
# Calculate RoPE index once per generation in the pre-fill stage only.
|
| 1372 |
+
# When compiling, we can't check tensor values thus we check only input length
|
| 1373 |
+
# It is safe to assume that `length!=1` means we're in pre-fill because compiled
|
| 1374 |
+
# models currently cannot do asssisted decoding
|
| 1375 |
+
prefill_compiled_stage = is_torchdynamo_compiling() and (
|
| 1376 |
+
(input_ids is not None and input_ids.shape[1] != 1)
|
| 1377 |
+
or (inputs_embeds is not None and inputs_embeds.shape[1] != 1)
|
| 1378 |
+
)
|
| 1379 |
+
prefill_noncompiled_stage = not is_torchdynamo_compiling() and (
|
| 1380 |
+
(cache_position is not None and cache_position[0] == 0)
|
| 1381 |
+
or (past_key_values is None or past_key_values.get_seq_length() == 0)
|
| 1382 |
+
)
|
| 1383 |
+
if (prefill_compiled_stage or prefill_noncompiled_stage) or self.rope_deltas is None:
|
| 1384 |
+
position_ids, rope_deltas = self.get_rope_index(
|
| 1385 |
+
input_ids,
|
| 1386 |
+
image_grid_thw,
|
| 1387 |
+
video_grid_thw,
|
| 1388 |
+
second_per_grid_ts=second_per_grid_ts,
|
| 1389 |
+
attention_mask=attention_mask_tensor,
|
| 1390 |
+
)
|
| 1391 |
+
self.rope_deltas = rope_deltas
|
| 1392 |
+
else:
|
| 1393 |
+
batch_size, seq_length, _ = inputs_embeds.shape
|
| 1394 |
+
delta = (
|
| 1395 |
+
(cache_position[0] + self.rope_deltas).to(inputs_embeds.device)
|
| 1396 |
+
if cache_position is not None
|
| 1397 |
+
else 0
|
| 1398 |
+
)
|
| 1399 |
+
position_ids = torch.arange(seq_length, device=inputs_embeds.device)
|
| 1400 |
+
position_ids = position_ids.view(1, -1).expand(batch_size, -1)
|
| 1401 |
+
if cache_position is not None: # otherwise `deltas` is an int `0`
|
| 1402 |
+
delta = delta.repeat_interleave(batch_size // delta.shape[0], dim=0)
|
| 1403 |
+
position_ids = position_ids.add(delta)
|
| 1404 |
+
position_ids = position_ids.unsqueeze(0).expand(3, -1, -1)
|
| 1405 |
+
|
| 1406 |
+
outputs = self.language_model(
|
| 1407 |
+
input_ids=None,
|
| 1408 |
+
position_ids=position_ids,
|
| 1409 |
+
attention_mask=attention_mask,
|
| 1410 |
+
past_key_values=past_key_values,
|
| 1411 |
+
inputs_embeds=inputs_embeds,
|
| 1412 |
+
use_cache=use_cache,
|
| 1413 |
+
output_attentions=output_attentions,
|
| 1414 |
+
output_hidden_states=output_hidden_states,
|
| 1415 |
+
return_dict=True,
|
| 1416 |
+
cache_position=cache_position,
|
| 1417 |
+
store_kv=store_kv,
|
| 1418 |
+
store_kv_len=store_kv_len,
|
| 1419 |
+
**kwargs,
|
| 1420 |
+
)
|
| 1421 |
+
|
| 1422 |
+
output = EchoModelOutputWithPast(
|
| 1423 |
+
last_hidden_state=outputs.last_hidden_state,
|
| 1424 |
+
past_key_values=outputs.past_key_values,
|
| 1425 |
+
hidden_states=outputs.hidden_states,
|
| 1426 |
+
attentions=outputs.attentions,
|
| 1427 |
+
rope_deltas=self.rope_deltas,
|
| 1428 |
+
)
|
| 1429 |
+
return output if return_dict else output.to_tuple()
|
| 1430 |
+
|
| 1431 |
+
|
| 1432 |
+
@dataclass
|
| 1433 |
+
@auto_docstring(
|
| 1434 |
+
custom_intro="""
|
| 1435 |
+
Base class for Echo causal language model (or autoregressive) outputs.
|
| 1436 |
+
"""
|
| 1437 |
+
)
|
| 1438 |
+
class EchoCausalLMOutputWithPast(ModelOutput):
|
| 1439 |
+
r"""
|
| 1440 |
+
loss (`torch.FloatTensor` of shape `(1,)`, *optional*, returned when `labels` is provided):
|
| 1441 |
+
Language modeling loss (for next-token prediction).
|
| 1442 |
+
logits (`torch.FloatTensor` of shape `(batch_size, sequence_length, config.vocab_size)`):
|
| 1443 |
+
Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax).
|
| 1444 |
+
past_key_values (`Cache`, *optional*, returned when `use_cache=True` is passed or when `config.use_cache=True`):
|
| 1445 |
+
Tuple of `tuple(torch.FloatTensor)` of length `config.n_layers`, with each tuple having 2 tensors of shape
|
| 1446 |
+
`(batch_size, num_heads, sequence_length, embed_size_per_head)`)
|
| 1447 |
+
|
| 1448 |
+
Contains pre-computed hidden-states (key and values in the self-attention blocks) that can be used (see
|
| 1449 |
+
`past_key_values` input) to speed up sequential decoding.
|
| 1450 |
+
rope_deltas (`torch.LongTensor` of shape `(batch_size, )`, *optional*):
|
| 1451 |
+
The rope index difference between sequence length and multimodal rope.
|
| 1452 |
+
"""
|
| 1453 |
+
|
| 1454 |
+
loss: Optional[torch.FloatTensor] = None
|
| 1455 |
+
logits: Optional[torch.FloatTensor] = None
|
| 1456 |
+
past_key_values: Optional[list[torch.FloatTensor]] = None
|
| 1457 |
+
hidden_states: Optional[tuple[torch.FloatTensor]] = None
|
| 1458 |
+
attentions: Optional[tuple[torch.FloatTensor]] = None
|
| 1459 |
+
rope_deltas: Optional[torch.LongTensor] = None
|
| 1460 |
+
|
| 1461 |
+
|
| 1462 |
+
class EchoForConditionalGeneration(EchoPreTrainedModel, GenerationMixin):
|
| 1463 |
+
_checkpoint_conversion_mapping = {
|
| 1464 |
+
r"^visual\.": "model.visual.",
|
| 1465 |
+
r"^model\.(?!language_model\.|visual\.)": "model.language_model.",
|
| 1466 |
+
}
|
| 1467 |
+
_tied_weights_keys = ["lm_head.weight"]
|
| 1468 |
+
|
| 1469 |
+
def __init__(self, config):
|
| 1470 |
+
super().__init__(config)
|
| 1471 |
+
self.model = EchoModel(config)
|
| 1472 |
+
self.lm_head = nn.Linear(config.text_config.hidden_size, config.text_config.vocab_size, bias=False)
|
| 1473 |
+
|
| 1474 |
+
self.post_init()
|
| 1475 |
+
|
| 1476 |
+
def get_input_embeddings(self):
|
| 1477 |
+
return self.model.get_input_embeddings()
|
| 1478 |
+
|
| 1479 |
+
def set_input_embeddings(self, value):
|
| 1480 |
+
self.model.set_input_embeddings(value)
|
| 1481 |
+
|
| 1482 |
+
def set_decoder(self, decoder):
|
| 1483 |
+
self.model.set_decoder(decoder)
|
| 1484 |
+
|
| 1485 |
+
def get_decoder(self):
|
| 1486 |
+
return self.model.get_decoder()
|
| 1487 |
+
|
| 1488 |
+
def get_video_features(
|
| 1489 |
+
self, pixel_values_videos: torch.FloatTensor, video_grid_thw: Optional[torch.LongTensor] = None
|
| 1490 |
+
):
|
| 1491 |
+
return self.model.get_video_features(pixel_values_videos, video_grid_thw)
|
| 1492 |
+
|
| 1493 |
+
def get_image_features(self, pixel_values: torch.FloatTensor, image_grid_thw: Optional[torch.LongTensor] = None):
|
| 1494 |
+
return self.model.get_image_features(pixel_values, image_grid_thw)
|
| 1495 |
+
|
| 1496 |
+
# Make modules available throught conditional class for BC
|
| 1497 |
+
@property
|
| 1498 |
+
def language_model(self):
|
| 1499 |
+
return self.model.language_model
|
| 1500 |
+
|
| 1501 |
+
@property
|
| 1502 |
+
def visual(self):
|
| 1503 |
+
return self.model.visual
|
| 1504 |
+
|
| 1505 |
+
@can_return_tuple
|
| 1506 |
+
@auto_docstring
|
| 1507 |
+
def forward(
|
| 1508 |
+
self,
|
| 1509 |
+
input_ids: torch.LongTensor = None,
|
| 1510 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 1511 |
+
position_ids: Optional[torch.LongTensor] = None,
|
| 1512 |
+
past_key_values: Optional[Cache] = None,
|
| 1513 |
+
inputs_embeds: Optional[torch.FloatTensor] = None,
|
| 1514 |
+
use_cache: Optional[bool] = None,
|
| 1515 |
+
output_attentions: Optional[bool] = None,
|
| 1516 |
+
output_hidden_states: Optional[bool] = None,
|
| 1517 |
+
pixel_values: Optional[torch.Tensor] = None,
|
| 1518 |
+
pixel_values_videos: Optional[torch.FloatTensor] = None,
|
| 1519 |
+
image_grid_thw: Optional[torch.LongTensor] = None,
|
| 1520 |
+
video_grid_thw: Optional[torch.LongTensor] = None,
|
| 1521 |
+
rope_deltas: Optional[torch.LongTensor] = None,
|
| 1522 |
+
cache_position: Optional[torch.LongTensor] = None,
|
| 1523 |
+
second_per_grid_ts: Optional[torch.Tensor] = None,
|
| 1524 |
+
logits_to_keep: Union[int, torch.Tensor] = 0,
|
| 1525 |
+
labels: Optional[torch.LongTensor] = None,
|
| 1526 |
+
store_kv: Optional[bool] = False,
|
| 1527 |
+
store_kv_len: Optional[int] = None,
|
| 1528 |
+
**kwargs: Unpack[TransformersKwargs],
|
| 1529 |
+
) -> Union[tuple, EchoCausalLMOutputWithPast]:
|
| 1530 |
+
r"""
|
| 1531 |
+
labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
|
| 1532 |
+
Labels for computing the masked language modeling loss. Indices should either be in `[0, ...,
|
| 1533 |
+
config.vocab_size]` or -100 (see `input_ids` docstring). Tokens with indices set to `-100` are ignored
|
| 1534 |
+
(masked), the loss is only computed for the tokens with labels in `[0, ..., config.vocab_size]`.
|
| 1535 |
+
image_grid_thw (`torch.LongTensor` of shape `(num_images, 3)`, *optional*):
|
| 1536 |
+
The temporal, height and width of feature shape of each image in LLM.
|
| 1537 |
+
video_grid_thw (`torch.LongTensor` of shape `(num_videos, 3)`, *optional*):
|
| 1538 |
+
The temporal, height and width of feature shape of each video in LLM.
|
| 1539 |
+
rope_deltas (`torch.LongTensor` of shape `(batch_size, )`, *optional*):
|
| 1540 |
+
The rope index difference between sequence length and multimodal rope.
|
| 1541 |
+
second_per_grid_ts (`torch.Tensor` of shape `(num_videos)`, *optional*):
|
| 1542 |
+
The time interval (in seconds) for each grid along the temporal dimension in the 3D position IDs.
|
| 1543 |
+
|
| 1544 |
+
Example:
|
| 1545 |
+
|
| 1546 |
+
```python
|
| 1547 |
+
>>> from PIL import Image
|
| 1548 |
+
>>> import requests
|
| 1549 |
+
>>> from transformers import AutoProcessor, EchoForConditionalGeneration
|
| 1550 |
+
|
| 1551 |
+
>>> model = EchoForConditionalGeneration.from_pretrained("Qwen/Qwen2.5-VL-7B-Instruct")
|
| 1552 |
+
>>> processor = AutoProcessor.from_pretrained("Qwen/Qwen2.5-VL-7B-Instruct")
|
| 1553 |
+
|
| 1554 |
+
>>> messages = [
|
| 1555 |
+
{
|
| 1556 |
+
"role": "user",
|
| 1557 |
+
"content": [
|
| 1558 |
+
{"type": "image"},
|
| 1559 |
+
{"type": "text", "text": "What is shown in this image?"},
|
| 1560 |
+
],
|
| 1561 |
+
},
|
| 1562 |
+
]
|
| 1563 |
+
>>> url = "https://www.ilankelman.org/stopsigns/australia.jpg"
|
| 1564 |
+
>>> image = Image.open(requests.get(url, stream=True).raw)
|
| 1565 |
+
|
| 1566 |
+
>>> text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
| 1567 |
+
>>> inputs = processor(text=[text], images=[image], vision_infos=[vision_infos])
|
| 1568 |
+
|
| 1569 |
+
>>> # Generate
|
| 1570 |
+
>>> generate_ids = model.generate(inputs.input_ids, max_length=30)
|
| 1571 |
+
>>> tokenizer.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]
|
| 1572 |
+
"The image shows a street scene with a red stop sign in the foreground. In the background, there is a large red gate with Chinese characters ..."
|
| 1573 |
+
```"""
|
| 1574 |
+
|
| 1575 |
+
output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
|
| 1576 |
+
output_hidden_states = (
|
| 1577 |
+
output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
|
| 1578 |
+
)
|
| 1579 |
+
if not isinstance(attention_mask, dict):
|
| 1580 |
+
attention_mask = {"full_attention": attention_mask}
|
| 1581 |
+
outputs = self.model(
|
| 1582 |
+
input_ids=input_ids,
|
| 1583 |
+
pixel_values=pixel_values,
|
| 1584 |
+
pixel_values_videos=pixel_values_videos,
|
| 1585 |
+
image_grid_thw=image_grid_thw,
|
| 1586 |
+
video_grid_thw=video_grid_thw,
|
| 1587 |
+
second_per_grid_ts=second_per_grid_ts,
|
| 1588 |
+
position_ids=position_ids,
|
| 1589 |
+
attention_mask=attention_mask,
|
| 1590 |
+
past_key_values=past_key_values,
|
| 1591 |
+
inputs_embeds=inputs_embeds,
|
| 1592 |
+
use_cache=use_cache,
|
| 1593 |
+
output_attentions=output_attentions,
|
| 1594 |
+
output_hidden_states=output_hidden_states,
|
| 1595 |
+
return_dict=True,
|
| 1596 |
+
cache_position=cache_position,
|
| 1597 |
+
store_kv=store_kv,
|
| 1598 |
+
store_kv_len=store_kv_len,
|
| 1599 |
+
**kwargs,
|
| 1600 |
+
)
|
| 1601 |
+
|
| 1602 |
+
hidden_states = outputs[0]
|
| 1603 |
+
|
| 1604 |
+
# Only compute necessary logits, and do not upcast them to float if we are not computing the loss
|
| 1605 |
+
slice_indices = slice(-logits_to_keep, None) if isinstance(logits_to_keep, int) else logits_to_keep
|
| 1606 |
+
logits = self.lm_head(hidden_states[:, slice_indices, :])
|
| 1607 |
+
|
| 1608 |
+
loss = None
|
| 1609 |
+
if labels is not None:
|
| 1610 |
+
loss = self.loss_function(logits=logits, labels=labels, vocab_size=self.config.vocab_size)
|
| 1611 |
+
|
| 1612 |
+
return EchoCausalLMOutputWithPast(
|
| 1613 |
+
loss=loss,
|
| 1614 |
+
logits=logits,
|
| 1615 |
+
past_key_values=outputs.past_key_values,
|
| 1616 |
+
hidden_states=outputs.hidden_states,
|
| 1617 |
+
attentions=outputs.attentions,
|
| 1618 |
+
rope_deltas=outputs.rope_deltas,
|
| 1619 |
+
)
|
| 1620 |
+
|
| 1621 |
+
def prepare_inputs_for_generation(
|
| 1622 |
+
self,
|
| 1623 |
+
input_ids,
|
| 1624 |
+
past_key_values=None,
|
| 1625 |
+
attention_mask=None,
|
| 1626 |
+
inputs_embeds=None,
|
| 1627 |
+
cache_position=None,
|
| 1628 |
+
position_ids=None,
|
| 1629 |
+
use_cache=True,
|
| 1630 |
+
pixel_values=None,
|
| 1631 |
+
pixel_values_videos=None,
|
| 1632 |
+
image_grid_thw=None,
|
| 1633 |
+
video_grid_thw=None,
|
| 1634 |
+
second_per_grid_ts=None,
|
| 1635 |
+
**kwargs,
|
| 1636 |
+
):
|
| 1637 |
+
# Overwritten -- in specific circumstances we don't want to forward image inputs to the model
|
| 1638 |
+
|
| 1639 |
+
model_inputs = super().prepare_inputs_for_generation(
|
| 1640 |
+
input_ids,
|
| 1641 |
+
past_key_values=past_key_values,
|
| 1642 |
+
attention_mask=attention_mask,
|
| 1643 |
+
inputs_embeds=inputs_embeds,
|
| 1644 |
+
cache_position=cache_position,
|
| 1645 |
+
position_ids=position_ids,
|
| 1646 |
+
pixel_values=pixel_values,
|
| 1647 |
+
pixel_values_videos=pixel_values_videos,
|
| 1648 |
+
image_grid_thw=image_grid_thw,
|
| 1649 |
+
video_grid_thw=video_grid_thw,
|
| 1650 |
+
second_per_grid_ts=second_per_grid_ts,
|
| 1651 |
+
use_cache=use_cache,
|
| 1652 |
+
**kwargs,
|
| 1653 |
+
)
|
| 1654 |
+
|
| 1655 |
+
# Qwen2-5-VL position_ids are prepared with rope_deltas
|
| 1656 |
+
if position_ids is None:
|
| 1657 |
+
# Calculate RoPE index once per generation in the pre-fill stage only.
|
| 1658 |
+
# When compiling, we can't check tensor values thus we check only input length
|
| 1659 |
+
# It is safe to assume that `length!=1` means we're in pre-fill because compiled
|
| 1660 |
+
# models currently cannot do asssisted decoding
|
| 1661 |
+
if cache_position[0] == 0 or self.model.rope_deltas is None:
|
| 1662 |
+
vision_positions, rope_deltas = self.model.get_rope_index(
|
| 1663 |
+
model_inputs.get("input_ids", None),
|
| 1664 |
+
image_grid_thw=image_grid_thw,
|
| 1665 |
+
video_grid_thw=video_grid_thw,
|
| 1666 |
+
second_per_grid_ts=second_per_grid_ts,
|
| 1667 |
+
attention_mask=attention_mask,
|
| 1668 |
+
)
|
| 1669 |
+
self.model.rope_deltas = rope_deltas
|
| 1670 |
+
# then use the prev pre-calculated rope-deltas to get the correct position ids
|
| 1671 |
+
elif "position_ids" in model_inputs:
|
| 1672 |
+
position_ids = model_inputs["position_ids"][None, ...]
|
| 1673 |
+
delta = self.model.rope_deltas
|
| 1674 |
+
delta = delta.repeat_interleave(position_ids.shape[1] // delta.shape[0], dim=0)
|
| 1675 |
+
vision_positions = position_ids + delta.expand_as(position_ids)
|
| 1676 |
+
vision_positions = vision_positions.expand(3, vision_positions.shape[1], -1)
|
| 1677 |
+
|
| 1678 |
+
# Concatenate "text + vision" positions into [4, bs, seq-len]
|
| 1679 |
+
if "position_ids" not in model_inputs:
|
| 1680 |
+
text_positions = torch.arange(input_ids, device=input_ids.device)[None, None, :]
|
| 1681 |
+
else:
|
| 1682 |
+
text_positions = model_inputs["position_ids"][None, ...]
|
| 1683 |
+
model_inputs["position_ids"] = torch.cat([text_positions, vision_positions], dim=0)
|
| 1684 |
+
|
| 1685 |
+
if cache_position[0] != 0:
|
| 1686 |
+
model_inputs["pixel_values"] = None
|
| 1687 |
+
model_inputs["pixel_values_videos"] = None
|
| 1688 |
+
|
| 1689 |
+
return model_inputs
|
| 1690 |
+
|
| 1691 |
+
def _get_image_nums_and_video_nums(
|
| 1692 |
+
self,
|
| 1693 |
+
input_ids: Optional[torch.LongTensor],
|
| 1694 |
+
inputs_embeds: Optional[torch.Tensor] = None,
|
| 1695 |
+
) -> tuple[torch.Tensor, torch.Tensor]:
|
| 1696 |
+
"""
|
| 1697 |
+
Get the number of images and videos for each sample to calculate the separation length of the sample tensor.
|
| 1698 |
+
These parameters are not passed through the processor to avoid unpredictable impacts from interface modifications.
|
| 1699 |
+
|
| 1700 |
+
Args:
|
| 1701 |
+
input_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`):
|
| 1702 |
+
Indices of input sequence tokens in the vocabulary.
|
| 1703 |
+
|
| 1704 |
+
Returns:
|
| 1705 |
+
image_nums (`torch.LongTensor` of shape `(batch_size, num_images_sample)`)
|
| 1706 |
+
video_nums (`torch.LongTensor` of shape `(batch_size, num_videos_sample)`)
|
| 1707 |
+
"""
|
| 1708 |
+
image_token_id = self.config.image_token_id
|
| 1709 |
+
video_token_id = self.config.video_token_id
|
| 1710 |
+
vision_start_token_id = self.config.vision_start_token_id
|
| 1711 |
+
|
| 1712 |
+
if inputs_embeds is not None:
|
| 1713 |
+
vision_start_mask = (
|
| 1714 |
+
inputs_embeds
|
| 1715 |
+
== self.get_input_embeddings()(
|
| 1716 |
+
torch.tensor(vision_start_token_id, dtype=torch.long, device=inputs_embeds.device)
|
| 1717 |
+
)
|
| 1718 |
+
)[..., 0]
|
| 1719 |
+
image_mask = (
|
| 1720 |
+
inputs_embeds
|
| 1721 |
+
== self.get_input_embeddings()(
|
| 1722 |
+
torch.tensor(image_token_id, dtype=torch.long, device=inputs_embeds.device)
|
| 1723 |
+
)
|
| 1724 |
+
)[..., 0]
|
| 1725 |
+
video_mask = (
|
| 1726 |
+
inputs_embeds
|
| 1727 |
+
== self.get_input_embeddings()(
|
| 1728 |
+
torch.tensor(video_token_id, dtype=torch.long, device=inputs_embeds.device)
|
| 1729 |
+
)
|
| 1730 |
+
)[..., 0]
|
| 1731 |
+
else:
|
| 1732 |
+
vision_start_mask = input_ids == vision_start_token_id
|
| 1733 |
+
image_mask = input_ids == image_token_id
|
| 1734 |
+
video_mask = input_ids == video_token_id
|
| 1735 |
+
|
| 1736 |
+
vision_first_mask = torch.roll(vision_start_mask, shifts=1, dims=1)
|
| 1737 |
+
image_nums = torch.sum(vision_first_mask & image_mask, dim=1)
|
| 1738 |
+
video_nums = torch.sum(vision_first_mask & video_mask, dim=1)
|
| 1739 |
+
|
| 1740 |
+
return image_nums, video_nums
|
| 1741 |
+
|
| 1742 |
+
def _expand_inputs_for_generation(
|
| 1743 |
+
self,
|
| 1744 |
+
expand_size: int = 1,
|
| 1745 |
+
is_encoder_decoder: bool = False,
|
| 1746 |
+
input_ids: Optional[torch.LongTensor] = None,
|
| 1747 |
+
**model_kwargs,
|
| 1748 |
+
) -> tuple[torch.LongTensor, dict[str, Any]]:
|
| 1749 |
+
# Overwritten -- Support for expanding tensors without a batch size dimension
|
| 1750 |
+
# e.g., pixel_values, image_grid_thw, pixel_values_videos, video_grid_thw, second_per_grid_t
|
| 1751 |
+
# pixel_values.shape[0] is sum(seqlen_images for samples)
|
| 1752 |
+
# image_grid_thw.shape[0] is sum(num_images for samples)
|
| 1753 |
+
|
| 1754 |
+
if expand_size == 1:
|
| 1755 |
+
return input_ids, model_kwargs
|
| 1756 |
+
|
| 1757 |
+
visual_keys = ["pixel_values", "image_grid_thw", "pixel_values_videos", "video_grid_thw", "second_per_grid_ts"]
|
| 1758 |
+
|
| 1759 |
+
def _expand_dict_for_generation_visual(dict_to_expand):
|
| 1760 |
+
image_grid_thw = model_kwargs.get("image_grid_thw", None)
|
| 1761 |
+
video_grid_thw = model_kwargs.get("video_grid_thw", None)
|
| 1762 |
+
image_nums, video_nums = self._get_image_nums_and_video_nums(
|
| 1763 |
+
input_ids, inputs_embeds=model_kwargs.get("inputs_embeds", None)
|
| 1764 |
+
)
|
| 1765 |
+
|
| 1766 |
+
def _repeat_interleave_samples(x, lengths, repeat_times):
|
| 1767 |
+
samples = torch.split(x, lengths)
|
| 1768 |
+
repeat_args = [repeat_times] + [1] * (x.dim() - 1)
|
| 1769 |
+
result = torch.cat([sample.repeat(*repeat_args) for sample in samples], dim=0)
|
| 1770 |
+
return result
|
| 1771 |
+
|
| 1772 |
+
for key in dict_to_expand:
|
| 1773 |
+
if key == "pixel_values":
|
| 1774 |
+
# split images into samples
|
| 1775 |
+
samples = torch.split(image_grid_thw, list(image_nums))
|
| 1776 |
+
# compute the sequence length of images for each sample
|
| 1777 |
+
lengths = [torch.prod(sample, dim=1).sum() for sample in samples]
|
| 1778 |
+
dict_to_expand[key] = _repeat_interleave_samples(
|
| 1779 |
+
dict_to_expand[key], lengths=lengths, repeat_times=expand_size
|
| 1780 |
+
)
|
| 1781 |
+
elif key == "image_grid_thw":
|
| 1782 |
+
# get the num of images for each sample
|
| 1783 |
+
lengths = list(image_nums)
|
| 1784 |
+
dict_to_expand[key] = _repeat_interleave_samples(
|
| 1785 |
+
dict_to_expand[key], lengths=lengths, repeat_times=expand_size
|
| 1786 |
+
)
|
| 1787 |
+
elif key == "pixel_values_videos":
|
| 1788 |
+
samples = torch.split(video_grid_thw, list(video_nums))
|
| 1789 |
+
lengths = [torch.prod(sample, dim=1).sum() for sample in samples]
|
| 1790 |
+
dict_to_expand[key] = _repeat_interleave_samples(
|
| 1791 |
+
dict_to_expand[key], lengths=lengths, repeat_times=expand_size
|
| 1792 |
+
)
|
| 1793 |
+
elif key == "video_grid_thw":
|
| 1794 |
+
lengths = list(video_nums)
|
| 1795 |
+
dict_to_expand[key] = _repeat_interleave_samples(
|
| 1796 |
+
dict_to_expand[key], lengths=lengths, repeat_times=expand_size
|
| 1797 |
+
)
|
| 1798 |
+
elif key == "second_per_grid_ts":
|
| 1799 |
+
if not isinstance(dict_to_expand[key], list):
|
| 1800 |
+
raise TypeError(
|
| 1801 |
+
f"Expected value for key '{key}' to be a list, but got {type(dict_to_expand[key])} instead."
|
| 1802 |
+
)
|
| 1803 |
+
tensor = torch.tensor(dict_to_expand[key])
|
| 1804 |
+
lengths = list(video_nums)
|
| 1805 |
+
tensor = _repeat_interleave_samples(tensor, lengths=lengths, repeat_times=expand_size)
|
| 1806 |
+
dict_to_expand[key] = tensor.tolist()
|
| 1807 |
+
return dict_to_expand
|
| 1808 |
+
|
| 1809 |
+
def _expand_dict_for_generation(dict_to_expand):
|
| 1810 |
+
for key in dict_to_expand:
|
| 1811 |
+
if (
|
| 1812 |
+
key != "cache_position"
|
| 1813 |
+
and dict_to_expand[key] is not None
|
| 1814 |
+
and isinstance(dict_to_expand[key], torch.Tensor)
|
| 1815 |
+
and key not in visual_keys
|
| 1816 |
+
):
|
| 1817 |
+
dict_to_expand[key] = dict_to_expand[key].repeat_interleave(expand_size, dim=0)
|
| 1818 |
+
return dict_to_expand
|
| 1819 |
+
|
| 1820 |
+
model_kwargs = _expand_dict_for_generation_visual(model_kwargs)
|
| 1821 |
+
|
| 1822 |
+
if input_ids is not None:
|
| 1823 |
+
input_ids = input_ids.repeat_interleave(expand_size, dim=0)
|
| 1824 |
+
|
| 1825 |
+
model_kwargs = _expand_dict_for_generation(model_kwargs)
|
| 1826 |
+
|
| 1827 |
+
if is_encoder_decoder:
|
| 1828 |
+
if model_kwargs.get("encoder_outputs") is None:
|
| 1829 |
+
raise ValueError("If `is_encoder_decoder` is True, make sure that `encoder_outputs` is defined.")
|
| 1830 |
+
model_kwargs["encoder_outputs"] = _expand_dict_for_generation(model_kwargs["encoder_outputs"])
|
| 1831 |
+
|
| 1832 |
+
return input_ids, model_kwargs
|
| 1833 |
+
|
| 1834 |
+
|
| 1835 |
+
__all__ = ["EchoForConditionalGeneration", "EchoModel", "EchoPreTrainedModel", "EchoTextModel"]
|
preprocessor_config.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"do_convert_rgb": true,
|
| 3 |
+
"do_normalize": true,
|
| 4 |
+
"do_rescale": true,
|
| 5 |
+
"do_resize": true,
|
| 6 |
+
"image_mean": [
|
| 7 |
+
0.48145466,
|
| 8 |
+
0.4578275,
|
| 9 |
+
0.40821073
|
| 10 |
+
],
|
| 11 |
+
"image_processor_type": "Qwen2VLImageProcessor",
|
| 12 |
+
"image_std": [
|
| 13 |
+
0.26862954,
|
| 14 |
+
0.26130258,
|
| 15 |
+
0.27577711
|
| 16 |
+
],
|
| 17 |
+
"max_pixels": 12845056,
|
| 18 |
+
"merge_size": 2,
|
| 19 |
+
"min_pixels": 3136,
|
| 20 |
+
"patch_size": 14,
|
| 21 |
+
"processor_class": "Qwen2_5_VLProcessor",
|
| 22 |
+
"resample": 3,
|
| 23 |
+
"rescale_factor": 0.00392156862745098,
|
| 24 |
+
"size": {
|
| 25 |
+
"longest_edge": 12845056,
|
| 26 |
+
"shortest_edge": 3136
|
| 27 |
+
},
|
| 28 |
+
"temporal_patch_size": 2
|
| 29 |
+
}
|
special_tokens_map.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"additional_special_tokens": [
|
| 3 |
+
"<|im_start|>",
|
| 4 |
+
"<|im_end|>",
|
| 5 |
+
"<|object_ref_start|>",
|
| 6 |
+
"<|object_ref_end|>",
|
| 7 |
+
"<|box_start|>",
|
| 8 |
+
"<|box_end|>",
|
| 9 |
+
"<|quad_start|>",
|
| 10 |
+
"<|quad_end|>",
|
| 11 |
+
"<|vision_start|>",
|
| 12 |
+
"<|vision_end|>",
|
| 13 |
+
"<|vision_pad|>",
|
| 14 |
+
"<|image_pad|>",
|
| 15 |
+
"<|video_pad|>"
|
| 16 |
+
],
|
| 17 |
+
"eos_token": {
|
| 18 |
+
"content": "<|im_end|>",
|
| 19 |
+
"lstrip": false,
|
| 20 |
+
"normalized": false,
|
| 21 |
+
"rstrip": false,
|
| 22 |
+
"single_word": false
|
| 23 |
+
},
|
| 24 |
+
"mask_token": {
|
| 25 |
+
"content": "<|MASK|>",
|
| 26 |
+
"lstrip": false,
|
| 27 |
+
"normalized": false,
|
| 28 |
+
"rstrip": false,
|
| 29 |
+
"single_word": false
|
| 30 |
+
},
|
| 31 |
+
"pad_token": {
|
| 32 |
+
"content": "<|endoftext|>",
|
| 33 |
+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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_bos_token": false,
|
| 3 |
+
"add_prefix_space": false,
|
| 4 |
+
"added_tokens_decoder": {
|
| 5 |
+
"151643": {
|
| 6 |
+
"content": "<|endoftext|>",
|
| 7 |
+
"lstrip": false,
|
| 8 |
+
"normalized": false,
|
| 9 |
+
"rstrip": false,
|
| 10 |
+
"single_word": false,
|
| 11 |
+
"special": true
|
| 12 |
+
},
|
| 13 |
+
"151644": {
|
| 14 |
+
"content": "<|im_start|>",
|
| 15 |
+
"lstrip": false,
|
| 16 |
+
"normalized": false,
|
| 17 |
+
"rstrip": false,
|
| 18 |
+
"single_word": false,
|
| 19 |
+
"special": true
|
| 20 |
+
},
|
| 21 |
+
"151645": {
|
| 22 |
+
"content": "<|im_end|>",
|
| 23 |
+
"lstrip": false,
|
| 24 |
+
"normalized": false,
|
| 25 |
+
"rstrip": false,
|
| 26 |
+
"single_word": false,
|
| 27 |
+
"special": true
|
| 28 |
+
},
|
| 29 |
+
"151646": {
|
| 30 |
+
"content": "<|object_ref_start|>",
|
| 31 |
+
"lstrip": false,
|
| 32 |
+
"normalized": false,
|
| 33 |
+
"rstrip": false,
|
| 34 |
+
"single_word": false,
|
| 35 |
+
"special": true
|
| 36 |
+
},
|
| 37 |
+
"151647": {
|
| 38 |
+
"content": "<|object_ref_end|>",
|
| 39 |
+
"lstrip": false,
|
| 40 |
+
"normalized": false,
|
| 41 |
+
"rstrip": false,
|
| 42 |
+
"single_word": false,
|
| 43 |
+
"special": true
|
| 44 |
+
},
|
| 45 |
+
"151648": {
|
| 46 |
+
"content": "<|box_start|>",
|
| 47 |
+
"lstrip": false,
|
| 48 |
+
"normalized": false,
|
| 49 |
+
"rstrip": false,
|
| 50 |
+
"single_word": false,
|
| 51 |
+
"special": true
|
| 52 |
+
},
|
| 53 |
+
"151649": {
|
| 54 |
+
"content": "<|box_end|>",
|
| 55 |
+
"lstrip": false,
|
| 56 |
+
"normalized": false,
|
| 57 |
+
"rstrip": false,
|
| 58 |
+
"single_word": false,
|
| 59 |
+
"special": true
|
| 60 |
+
},
|
| 61 |
+
"151650": {
|
| 62 |
+
"content": "<|quad_start|>",
|
| 63 |
+
"lstrip": false,
|
| 64 |
+
"normalized": false,
|
| 65 |
+
"rstrip": false,
|
| 66 |
+
"single_word": false,
|
| 67 |
+
"special": true
|
| 68 |
+
},
|
| 69 |
+
"151651": {
|
| 70 |
+
"content": "<|quad_end|>",
|
| 71 |
+
"lstrip": false,
|
| 72 |
+
"normalized": false,
|
| 73 |
+
"rstrip": false,
|
| 74 |
+
"single_word": false,
|
| 75 |
+
"special": true
|
| 76 |
+
},
|
| 77 |
+
"151652": {
|
| 78 |
+
"content": "<|vision_start|>",
|
| 79 |
+
"lstrip": false,
|
| 80 |
+
"normalized": false,
|
| 81 |
+
"rstrip": false,
|
| 82 |
+
"single_word": false,
|
| 83 |
+
"special": true
|
| 84 |
+
},
|
| 85 |
+
"151653": {
|
| 86 |
+
"content": "<|vision_end|>",
|
| 87 |
+
"lstrip": false,
|
| 88 |
+
"normalized": false,
|
| 89 |
+
"rstrip": false,
|
| 90 |
+
"single_word": false,
|
| 91 |
+
"special": true
|
| 92 |
+
},
|
| 93 |
+
"151654": {
|
| 94 |
+
"content": "<|vision_pad|>",
|
| 95 |
+
"lstrip": false,
|
| 96 |
+
"normalized": false,
|
| 97 |
+
"rstrip": false,
|
| 98 |
+
"single_word": false,
|
| 99 |
+
"special": true
|
| 100 |
+
},
|
| 101 |
+
"151655": {
|
| 102 |
+
"content": "<|image_pad|>",
|
| 103 |
+
"lstrip": false,
|
| 104 |
+
"normalized": false,
|
| 105 |
+
"rstrip": false,
|
| 106 |
+
"single_word": false,
|
| 107 |
+
"special": true
|
| 108 |
+
},
|
| 109 |
+
"151656": {
|
| 110 |
+
"content": "<|video_pad|>",
|
| 111 |
+
"lstrip": false,
|
| 112 |
+
"normalized": false,
|
| 113 |
+
"rstrip": false,
|
| 114 |
+
"single_word": false,
|
| 115 |
+
"special": true
|
| 116 |
+
},
|
| 117 |
+
"151657": {
|
| 118 |
+
"content": "<tool_call>",
|
| 119 |
+
"lstrip": false,
|
| 120 |
+
"normalized": false,
|
| 121 |
+
"rstrip": false,
|
| 122 |
+
"single_word": false,
|
| 123 |
+
"special": false
|
| 124 |
+
},
|
| 125 |
+
"151658": {
|
| 126 |
+
"content": "</tool_call>",
|
| 127 |
+
"lstrip": false,
|
| 128 |
+
"normalized": false,
|
| 129 |
+
"rstrip": false,
|
| 130 |
+
"single_word": false,
|
| 131 |
+
"special": false
|
| 132 |
+
},
|
| 133 |
+
"151659": {
|
| 134 |
+
"content": "<|fim_prefix|>",
|
| 135 |
+
"lstrip": false,
|
| 136 |
+
"normalized": false,
|
| 137 |
+
"rstrip": false,
|
| 138 |
+
"single_word": false,
|
| 139 |
+
"special": false
|
| 140 |
+
},
|
| 141 |
+
"151660": {
|
| 142 |
+
"content": "<|fim_middle|>",
|
| 143 |
+
"lstrip": false,
|
| 144 |
+
"normalized": false,
|
| 145 |
+
"rstrip": false,
|
| 146 |
+
"single_word": false,
|
| 147 |
+
"special": false
|
| 148 |
+
},
|
| 149 |
+
"151661": {
|
| 150 |
+
"content": "<|fim_suffix|>",
|
| 151 |
+
"lstrip": false,
|
| 152 |
+
"normalized": false,
|
| 153 |
+
"rstrip": false,
|
| 154 |
+
"single_word": false,
|
| 155 |
+
"special": false
|
| 156 |
+
},
|
| 157 |
+
"151662": {
|
| 158 |
+
"content": "<|fim_pad|>",
|
| 159 |
+
"lstrip": false,
|
| 160 |
+
"normalized": false,
|
| 161 |
+
"rstrip": false,
|
| 162 |
+
"single_word": false,
|
| 163 |
+
"special": false
|
| 164 |
+
},
|
| 165 |
+
"151663": {
|
| 166 |
+
"content": "<|repo_name|>",
|
| 167 |
+
"lstrip": false,
|
| 168 |
+
"normalized": false,
|
| 169 |
+
"rstrip": false,
|
| 170 |
+
"single_word": false,
|
| 171 |
+
"special": false
|
| 172 |
+
},
|
| 173 |
+
"151664": {
|
| 174 |
+
"content": "<|file_sep|>",
|
| 175 |
+
"lstrip": false,
|
| 176 |
+
"normalized": false,
|
| 177 |
+
"rstrip": false,
|
| 178 |
+
"single_word": false,
|
| 179 |
+
"special": false
|
| 180 |
+
},
|
| 181 |
+
"151665": {
|
| 182 |
+
"content": "<|MASK|>",
|
| 183 |
+
"lstrip": false,
|
| 184 |
+
"normalized": false,
|
| 185 |
+
"rstrip": false,
|
| 186 |
+
"single_word": false,
|
| 187 |
+
"special": true
|
| 188 |
+
}
|
| 189 |
+
},
|
| 190 |
+
"additional_special_tokens": [
|
| 191 |
+
"<|im_start|>",
|
| 192 |
+
"<|im_end|>",
|
| 193 |
+
"<|object_ref_start|>",
|
| 194 |
+
"<|object_ref_end|>",
|
| 195 |
+
"<|box_start|>",
|
| 196 |
+
"<|box_end|>",
|
| 197 |
+
"<|quad_start|>",
|
| 198 |
+
"<|quad_end|>",
|
| 199 |
+
"<|vision_start|>",
|
| 200 |
+
"<|vision_end|>",
|
| 201 |
+
"<|vision_pad|>",
|
| 202 |
+
"<|image_pad|>",
|
| 203 |
+
"<|video_pad|>"
|
| 204 |
+
],
|
| 205 |
+
"bos_token": null,
|
| 206 |
+
"clean_up_tokenization_spaces": false,
|
| 207 |
+
"eos_token": "<|im_end|>",
|
| 208 |
+
"errors": "replace",
|
| 209 |
+
"extra_special_tokens": {},
|
| 210 |
+
"mask_token": "<|MASK|>",
|
| 211 |
+
"model_max_length": 131072,
|
| 212 |
+
"pad_token": "<|endoftext|>",
|
| 213 |
+
"padding_side": "right",
|
| 214 |
+
"processor_class": "Qwen2_5_VLProcessor",
|
| 215 |
+
"split_special_tokens": false,
|
| 216 |
+
"tokenizer_class": "Qwen2Tokenizer",
|
| 217 |
+
"unk_token": null
|
| 218 |
+
}
|
video_preprocessor_config.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"crop_size": null,
|
| 3 |
+
"data_format": "channels_first",
|
| 4 |
+
"default_to_square": true,
|
| 5 |
+
"device": null,
|
| 6 |
+
"do_center_crop": null,
|
| 7 |
+
"do_convert_rgb": true,
|
| 8 |
+
"do_normalize": true,
|
| 9 |
+
"do_pad": null,
|
| 10 |
+
"do_rescale": true,
|
| 11 |
+
"do_resize": true,
|
| 12 |
+
"do_sample_frames": false,
|
| 13 |
+
"fps": null,
|
| 14 |
+
"image_mean": [
|
| 15 |
+
0.48145466,
|
| 16 |
+
0.4578275,
|
| 17 |
+
0.40821073
|
| 18 |
+
],
|
| 19 |
+
"image_std": [
|
| 20 |
+
0.26862954,
|
| 21 |
+
0.26130258,
|
| 22 |
+
0.27577711
|
| 23 |
+
],
|
| 24 |
+
"input_data_format": null,
|
| 25 |
+
"max_frames": 768,
|
| 26 |
+
"max_pixels": 12845056,
|
| 27 |
+
"merge_size": 2,
|
| 28 |
+
"min_frames": 4,
|
| 29 |
+
"min_pixels": 3136,
|
| 30 |
+
"num_frames": null,
|
| 31 |
+
"patch_size": 14,
|
| 32 |
+
"processor_class": "Qwen2_5_VLProcessor",
|
| 33 |
+
"resample": 3,
|
| 34 |
+
"rescale_factor": 0.00392156862745098,
|
| 35 |
+
"return_metadata": false,
|
| 36 |
+
"size": {
|
| 37 |
+
"longest_edge": 12845056,
|
| 38 |
+
"shortest_edge": 3136
|
| 39 |
+
},
|
| 40 |
+
"size_divisor": null,
|
| 41 |
+
"temporal_patch_size": 2,
|
| 42 |
+
"video_metadata": null,
|
| 43 |
+
"video_processor_type": "Qwen2VLVideoProcessor"
|
| 44 |
+
}
|
vocab.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|