Commit ·
587cab5
0
Parent(s):
Duplicate from greyAll/testModel
Browse filesCo-authored-by: Grey Darp <greyAll@users.noreply.huggingface.co>
- .gitattributes +36 -0
- config.json +90 -0
- configuration_qwen3_5.py +311 -0
- eval_only_512.json +8 -0
- generation_config.json +8 -0
- model.safetensors +3 -0
- modeling_qwen3_5.py +0 -0
- tokenizer.json +3 -0
- tokenizer_config.json +32 -0
.gitattributes
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
| 2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
| 3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
| 4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
| 5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
| 6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
| 7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
| 8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
| 10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
| 11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
| 12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
| 13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
| 14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
| 15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
| 16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
| 19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
| 20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
| 21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
| 22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
| 25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
| 28 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
| 29 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 30 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 31 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
| 32 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
| 33 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
config.json
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_name_or_path": "dendrite/teutonic-x",
|
| 3 |
+
"architectures": [
|
| 4 |
+
"QuasarForCausalLM"
|
| 5 |
+
],
|
| 6 |
+
"attention_bias": false,
|
| 7 |
+
"attention_dropout": 0.0,
|
| 8 |
+
"attn_output_gate": true,
|
| 9 |
+
"auto_map": {
|
| 10 |
+
"AutoConfig": "configuration_qwen3_5.QuasarConfig",
|
| 11 |
+
"AutoModelForCausalLM": "modeling_qwen3_5.QuasarForCausalLM"
|
| 12 |
+
},
|
| 13 |
+
"bos_token_id": null,
|
| 14 |
+
"dtype": "bfloat16",
|
| 15 |
+
"eos_token_id": 248044,
|
| 16 |
+
"full_attention_interval": 4,
|
| 17 |
+
"head_dim": 256,
|
| 18 |
+
"hidden_act": "silu",
|
| 19 |
+
"hidden_size": 4096,
|
| 20 |
+
"initializer_range": 0.02,
|
| 21 |
+
"intermediate_size": 12288,
|
| 22 |
+
"layer_types": [
|
| 23 |
+
"linear_attention",
|
| 24 |
+
"linear_attention",
|
| 25 |
+
"linear_attention",
|
| 26 |
+
"full_attention",
|
| 27 |
+
"linear_attention",
|
| 28 |
+
"linear_attention",
|
| 29 |
+
"linear_attention",
|
| 30 |
+
"full_attention",
|
| 31 |
+
"linear_attention",
|
| 32 |
+
"linear_attention",
|
| 33 |
+
"linear_attention",
|
| 34 |
+
"full_attention",
|
| 35 |
+
"linear_attention",
|
| 36 |
+
"linear_attention",
|
| 37 |
+
"linear_attention",
|
| 38 |
+
"full_attention",
|
| 39 |
+
"linear_attention",
|
| 40 |
+
"linear_attention",
|
| 41 |
+
"linear_attention",
|
| 42 |
+
"full_attention",
|
| 43 |
+
"linear_attention",
|
| 44 |
+
"linear_attention",
|
| 45 |
+
"linear_attention",
|
| 46 |
+
"full_attention",
|
| 47 |
+
"linear_attention",
|
| 48 |
+
"linear_attention",
|
| 49 |
+
"linear_attention",
|
| 50 |
+
"full_attention",
|
| 51 |
+
"linear_attention",
|
| 52 |
+
"linear_attention",
|
| 53 |
+
"linear_attention",
|
| 54 |
+
"full_attention"
|
| 55 |
+
],
|
| 56 |
+
"linear_conv_kernel_dim": 4,
|
| 57 |
+
"linear_key_head_dim": 128,
|
| 58 |
+
"linear_num_key_heads": 16,
|
| 59 |
+
"linear_num_value_heads": 32,
|
| 60 |
+
"linear_value_head_dim": 128,
|
| 61 |
+
"mamba_ssm_dtype": "float32",
|
| 62 |
+
"max_position_embeddings": 2097152,
|
| 63 |
+
"mlp_only_layers": [],
|
| 64 |
+
"model_type": "quasar_text",
|
| 65 |
+
"mtp_num_hidden_layers": 1,
|
| 66 |
+
"mtp_use_dedicated_embeddings": false,
|
| 67 |
+
"num_attention_heads": 16,
|
| 68 |
+
"num_hidden_layers": 32,
|
| 69 |
+
"num_key_value_heads": 4,
|
| 70 |
+
"pad_token_id": null,
|
| 71 |
+
"partial_rotary_factor": 0.25,
|
| 72 |
+
"rms_norm_eps": 1e-06,
|
| 73 |
+
"rope_parameters": {
|
| 74 |
+
"mrope_interleaved": true,
|
| 75 |
+
"mrope_section": [
|
| 76 |
+
11,
|
| 77 |
+
11,
|
| 78 |
+
10
|
| 79 |
+
],
|
| 80 |
+
"partial_rotary_factor": 0.25,
|
| 81 |
+
"rope_theta": 10000000,
|
| 82 |
+
"rope_type": "default"
|
| 83 |
+
},
|
| 84 |
+
"tie_word_embeddings": false,
|
| 85 |
+
"transformers_version": "5.9.0",
|
| 86 |
+
"use_cache": true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🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨
|
| 2 |
+
# This file was automatically generated from src/transformers/models/quasar/modular_quasar.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_quasar.py file directly. One of our CI enforces this.
|
| 6 |
+
# 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨
|
| 7 |
+
# Copyright 2025 The Qwen Team and The HuggingFace Inc. team. All rights reserved.
|
| 8 |
+
#
|
| 9 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 10 |
+
# you may not use this file except in compliance with the License.
|
| 11 |
+
# You may obtain a copy of the License at
|
| 12 |
+
#
|
| 13 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 14 |
+
#
|
| 15 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 16 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 17 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 18 |
+
# See the License for the specific language governing permissions and
|
| 19 |
+
# limitations under the License.
|
| 20 |
+
from transformers.configuration_utils import PreTrainedConfig, layer_type_validation
|
| 21 |
+
from transformers.modeling_rope_utils import RopeParameters
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
class QuasarTextConfig(PreTrainedConfig):
|
| 25 |
+
r"""
|
| 26 |
+
This is the configuration class to store the configuration of a [`QuasarTextModel`]. It is used to instantiate a
|
| 27 |
+
Quasar model according to the specified arguments, defining the model architecture.
|
| 28 |
+
Instantiating a configuration with the defaults will yield a similar configuration to that of
|
| 29 |
+
Qwen3.5-9B-Instruct [Qwen/Qwen3.5-9B-Instruct](https://huggingface.co/Qwen/Qwen3.5-9B-Instruct).
|
| 30 |
+
|
| 31 |
+
Configuration objects inherit from [`PreTrainedConfig`] and can be used to control the model outputs. Read the
|
| 32 |
+
documentation from [`PreTrainedConfig`] for more information.
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
Args:
|
| 36 |
+
vocab_size (`int`, *optional*, defaults to 248320):
|
| 37 |
+
Vocabulary size of the model. Defines the number of different tokens that can be represented by the
|
| 38 |
+
`inputs_ids`.
|
| 39 |
+
hidden_size (`int`, *optional*, defaults to 4096):
|
| 40 |
+
Dimension of the hidden representations.
|
| 41 |
+
intermediate_size (`int`, *optional*, defaults to 12288):
|
| 42 |
+
Dimension of the MLP representations.
|
| 43 |
+
num_hidden_layers (`int`, *optional*, defaults to 32):
|
| 44 |
+
Number of hidden layers in the Transformer encoder.
|
| 45 |
+
num_attention_heads (`int`, *optional*, defaults to 16):
|
| 46 |
+
Number of attention heads for each attention layer in the Transformer encoder.
|
| 47 |
+
num_key_value_heads (`int`, *optional*, defaults to 4):
|
| 48 |
+
This is the number of key_value heads that should be used to implement Grouped Query Attention. If
|
| 49 |
+
`num_key_value_heads=num_attention_heads`, the model will use Multi Head Attention (MHA), if
|
| 50 |
+
`num_key_value_heads=1` the model will use Multi Query Attention (MQA) otherwise GQA is used. When
|
| 51 |
+
converting a multi-head checkpoint to a GQA checkpoint, each group key and value head should be constructed
|
| 52 |
+
by meanpooling all the original heads within that group. For more details checkout [this
|
| 53 |
+
paper](https://arxiv.org/pdf/2305.13245.pdf). If it is not specified, will default to `32`.
|
| 54 |
+
hidden_act (`str`, *optional*, defaults to `"silu"`):
|
| 55 |
+
The non-linear activation function in the decoder.
|
| 56 |
+
max_position_embeddings (`int`, *optional*, defaults to 32768):
|
| 57 |
+
The maximum sequence length that this model might ever be used with.
|
| 58 |
+
initializer_range (`float`, *optional*, defaults to 0.02):
|
| 59 |
+
The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
|
| 60 |
+
rms_norm_eps (`float`, *optional*, defaults to 1e-06):
|
| 61 |
+
The epsilon used by the rms normalization layers.
|
| 62 |
+
use_cache (`bool`, *optional*, defaults to `True`):
|
| 63 |
+
Whether or not the model should return the last key/values attentions (not used by all models). Only
|
| 64 |
+
relevant if `config.is_decoder=True`.
|
| 65 |
+
tie_word_embeddings (`bool`, *optional*, defaults to `False`):
|
| 66 |
+
Whether the model's input and output word embeddings should be tied.
|
| 67 |
+
rope_parameters (`RopeParameters`, *optional*):
|
| 68 |
+
Dictionary containing the configuration parameters for the RoPE embeddings. The dictionary should contain
|
| 69 |
+
a value for `rope_theta` and optionally parameters used for scaling in case you want to use RoPE
|
| 70 |
+
with longer `max_position_embeddings`.
|
| 71 |
+
attention_bias (`bool`, *optional*, defaults to `False`):
|
| 72 |
+
Whether to use a bias in the query, key, value and output projection layers during self-attention.
|
| 73 |
+
attention_dropout (`float`, *optional*, defaults to 0.0):
|
| 74 |
+
The dropout ratio for the attention probabilities.
|
| 75 |
+
head_dim (`int`, *optional*, defaults to 256):
|
| 76 |
+
Projection weights dimension in multi-head attention.
|
| 77 |
+
linear_conv_kernel_dim (`int`, *optional*, defaults to 4):
|
| 78 |
+
Kernel size of the convolution used in linear attention layers.
|
| 79 |
+
linear_key_head_dim (`int`, *optional*, defaults to 128):
|
| 80 |
+
Dimension of each key head in linear attention.
|
| 81 |
+
linear_value_head_dim (`int`, *optional*, defaults to 128):
|
| 82 |
+
Dimension of each value head in linear attention.
|
| 83 |
+
linear_num_key_heads (`int`, *optional*, defaults to 16):
|
| 84 |
+
Number of key heads used in linear attention layers.
|
| 85 |
+
linear_num_value_heads (`int`, *optional*, defaults to 32):
|
| 86 |
+
Number of value heads used in linear attention layers.
|
| 87 |
+
layer_types (`list[str]`, *optional*):
|
| 88 |
+
Types of each layer (attention or linear).
|
| 89 |
+
pad_token_id (`int`, *optional*):
|
| 90 |
+
Padding token id.
|
| 91 |
+
bos_token_id (`int`, *optional*):
|
| 92 |
+
Beginning of stream token id.
|
| 93 |
+
eos_token_id (`int`, *optional*):
|
| 94 |
+
End of stream token id.
|
| 95 |
+
|
| 96 |
+
```python
|
| 97 |
+
>>> from transformers import QuasarTextModel, QuasarTextConfig
|
| 98 |
+
|
| 99 |
+
>>> # Initializing a Qwen3.5 style configuration
|
| 100 |
+
>>> configuration = QuasarTextConfig()
|
| 101 |
+
|
| 102 |
+
>>> # Initializing a model from the Qwen3.5-9B style configuration
|
| 103 |
+
>>> model = QuasarTextModel(configuration)
|
| 104 |
+
|
| 105 |
+
>>> # Accessing the model configuration
|
| 106 |
+
>>> configuration = model.config
|
| 107 |
+
```
|
| 108 |
+
"""
|
| 109 |
+
|
| 110 |
+
model_type = "quasar_text"
|
| 111 |
+
keys_to_ignore_at_inference = ["past_key_values"]
|
| 112 |
+
|
| 113 |
+
base_model_tp_plan = {
|
| 114 |
+
"layers.*.self_attn.q_proj": "colwise",
|
| 115 |
+
"layers.*.self_attn.k_proj": "colwise",
|
| 116 |
+
"layers.*.self_attn.v_proj": "colwise",
|
| 117 |
+
"layers.*.self_attn.o_proj": "rowwise",
|
| 118 |
+
"layers.*.mlp.gate_proj": "colwise",
|
| 119 |
+
"layers.*.mlp.up_proj": "colwise",
|
| 120 |
+
"layers.*.mlp.down_proj": "rowwise",
|
| 121 |
+
}
|
| 122 |
+
base_model_pp_plan = {
|
| 123 |
+
"embed_tokens": (["input_ids"], ["inputs_embeds"]),
|
| 124 |
+
"layers": (["hidden_states", "attention_mask"], ["hidden_states"]),
|
| 125 |
+
"norm": (["hidden_states"], ["hidden_states"]),
|
| 126 |
+
}
|
| 127 |
+
base_config_key = "text_config"
|
| 128 |
+
|
| 129 |
+
def __init__(
|
| 130 |
+
self,
|
| 131 |
+
vocab_size=248320,
|
| 132 |
+
hidden_size=4096,
|
| 133 |
+
intermediate_size=12288,
|
| 134 |
+
num_hidden_layers=32,
|
| 135 |
+
num_attention_heads=16,
|
| 136 |
+
num_key_value_heads=4,
|
| 137 |
+
hidden_act="silu",
|
| 138 |
+
max_position_embeddings=32768,
|
| 139 |
+
initializer_range=0.02,
|
| 140 |
+
rms_norm_eps=1e-6,
|
| 141 |
+
use_cache=True,
|
| 142 |
+
tie_word_embeddings=False,
|
| 143 |
+
rope_parameters: RopeParameters | dict[str, RopeParameters] | None = None,
|
| 144 |
+
attention_bias=False,
|
| 145 |
+
attention_dropout=0.0,
|
| 146 |
+
head_dim=256,
|
| 147 |
+
linear_conv_kernel_dim=4,
|
| 148 |
+
linear_key_head_dim=128,
|
| 149 |
+
linear_value_head_dim=128,
|
| 150 |
+
linear_num_key_heads=16,
|
| 151 |
+
linear_num_value_heads=32,
|
| 152 |
+
layer_types=None,
|
| 153 |
+
pad_token_id: int | None = None,
|
| 154 |
+
bos_token_id: int | None = None,
|
| 155 |
+
eos_token_id: int | None = None,
|
| 156 |
+
use_gla: bool = False,
|
| 157 |
+
use_nope: bool = False,
|
| 158 |
+
**kwargs,
|
| 159 |
+
):
|
| 160 |
+
kwargs["ignore_keys_at_rope_validation"] = {"mrope_section", "mrope_interleaved"}
|
| 161 |
+
self.pad_token_id = pad_token_id
|
| 162 |
+
self.bos_token_id = bos_token_id
|
| 163 |
+
self.eos_token_id = eos_token_id
|
| 164 |
+
self.tie_word_embeddings = tie_word_embeddings
|
| 165 |
+
self.vocab_size = vocab_size
|
| 166 |
+
self.max_position_embeddings = max_position_embeddings
|
| 167 |
+
self.hidden_size = hidden_size
|
| 168 |
+
self.intermediate_size = intermediate_size
|
| 169 |
+
self.num_hidden_layers = num_hidden_layers
|
| 170 |
+
self.num_attention_heads = num_attention_heads
|
| 171 |
+
self.num_key_value_heads = num_key_value_heads
|
| 172 |
+
self.hidden_act = hidden_act
|
| 173 |
+
self.initializer_range = initializer_range
|
| 174 |
+
self.rms_norm_eps = rms_norm_eps
|
| 175 |
+
self.use_cache = use_cache
|
| 176 |
+
self.attention_bias = attention_bias
|
| 177 |
+
self.attention_dropout = attention_dropout
|
| 178 |
+
self.head_dim = head_dim
|
| 179 |
+
self.rope_parameters = rope_parameters
|
| 180 |
+
self.use_gla = use_gla
|
| 181 |
+
self.use_nope = use_nope
|
| 182 |
+
kwargs.setdefault("partial_rotary_factor", 0.25) # assign default for BC
|
| 183 |
+
|
| 184 |
+
self.layer_types = layer_types
|
| 185 |
+
if self.layer_types is None:
|
| 186 |
+
interval_pattern = kwargs.get("full_attention_interval", 4)
|
| 187 |
+
self.layer_types = [
|
| 188 |
+
"linear_attention" if bool((i + 1) % interval_pattern) else "full_attention"
|
| 189 |
+
for i in range(self.num_hidden_layers)
|
| 190 |
+
]
|
| 191 |
+
layer_type_validation(self.layer_types, self.num_hidden_layers)
|
| 192 |
+
|
| 193 |
+
# linear attention part
|
| 194 |
+
self.linear_conv_kernel_dim = linear_conv_kernel_dim
|
| 195 |
+
self.linear_key_head_dim = linear_key_head_dim
|
| 196 |
+
self.linear_value_head_dim = linear_value_head_dim
|
| 197 |
+
self.linear_num_key_heads = linear_num_key_heads
|
| 198 |
+
self.linear_num_value_heads = linear_num_value_heads
|
| 199 |
+
super().__init__(**kwargs)
|
| 200 |
+
|
| 201 |
+
|
| 202 |
+
class QuasarVisionConfig(PreTrainedConfig):
|
| 203 |
+
model_type = "quasar"
|
| 204 |
+
base_config_key = "vision_config"
|
| 205 |
+
|
| 206 |
+
def __init__(
|
| 207 |
+
self,
|
| 208 |
+
depth=27,
|
| 209 |
+
hidden_size=1152,
|
| 210 |
+
hidden_act="gelu_pytorch_tanh",
|
| 211 |
+
intermediate_size=4304,
|
| 212 |
+
num_heads=16,
|
| 213 |
+
in_channels=3,
|
| 214 |
+
patch_size=16,
|
| 215 |
+
spatial_merge_size=2,
|
| 216 |
+
temporal_patch_size=2,
|
| 217 |
+
out_hidden_size=3584,
|
| 218 |
+
num_position_embeddings=2304,
|
| 219 |
+
initializer_range=0.02,
|
| 220 |
+
**kwargs,
|
| 221 |
+
):
|
| 222 |
+
super().__init__(**kwargs)
|
| 223 |
+
|
| 224 |
+
self.depth = depth
|
| 225 |
+
self.hidden_size = hidden_size
|
| 226 |
+
self.hidden_act = hidden_act
|
| 227 |
+
self.intermediate_size = intermediate_size
|
| 228 |
+
self.num_heads = num_heads
|
| 229 |
+
self.in_channels = in_channels
|
| 230 |
+
self.patch_size = patch_size
|
| 231 |
+
self.spatial_merge_size = spatial_merge_size
|
| 232 |
+
self.temporal_patch_size = temporal_patch_size
|
| 233 |
+
self.out_hidden_size = out_hidden_size
|
| 234 |
+
self.num_position_embeddings = num_position_embeddings
|
| 235 |
+
self.initializer_range = initializer_range
|
| 236 |
+
|
| 237 |
+
|
| 238 |
+
class QuasarConfig(PreTrainedConfig):
|
| 239 |
+
r"""
|
| 240 |
+
This is the configuration class to store the configuration of a [`QuasarModel`]. It is used to instantiate a
|
| 241 |
+
Qwen3.5 model according to the specified arguments, defining the model architecture. Instantiating a configuration
|
| 242 |
+
with the defaults will yield a similar configuration to that of
|
| 243 |
+
Qwen3.5-9B-Instruct [Qwen/Qwen3.5-9B-Instruct](https://huggingface.co/Qwen/Qwen3.5-9B-Instruct).
|
| 244 |
+
|
| 245 |
+
Configuration objects inherit from [`PreTrainedConfig`] and can be used to control the model outputs. Read the
|
| 246 |
+
documentation from [`PreTrainedConfig`] for more information.
|
| 247 |
+
|
| 248 |
+
|
| 249 |
+
Args:
|
| 250 |
+
text_config (`Union[PreTrainedConfig, dict]`, *optional*, defaults to `QuasarTextConfig`):
|
| 251 |
+
The config object or dictionary of the text backbone.
|
| 252 |
+
vision_config (`Union[PreTrainedConfig, dict]`, *optional*, defaults to `QuasarVisionConfig`):
|
| 253 |
+
The config object or dictionary of the vision backbone.
|
| 254 |
+
image_token_id (`int`, *optional*, defaults to 248056):
|
| 255 |
+
The image token index to encode the image prompt.
|
| 256 |
+
video_token_id (`int`, *optional*, defaults to 248057):
|
| 257 |
+
The video token index to encode the image prompt.
|
| 258 |
+
vision_start_token_id (`int`, *optional*, defaults to 248053):
|
| 259 |
+
The start token index to encode the image prompt.
|
| 260 |
+
vision_end_token_id (`int`, *optional*, defaults to 248054):
|
| 261 |
+
The end token index to encode the image prompt.
|
| 262 |
+
tie_word_embeddings (`bool`, *optional*, defaults to `False`):
|
| 263 |
+
Whether to tie the word embeddings.
|
| 264 |
+
|
| 265 |
+
```python
|
| 266 |
+
>>> from transformers import QuasarForConditionalGeneration, QuasarConfig
|
| 267 |
+
|
| 268 |
+
>>> # Initializing a Qwen3.5 style configuration
|
| 269 |
+
>>> configuration = QuasarConfig()
|
| 270 |
+
|
| 271 |
+
>>> # Initializing a model from the Qwen3.5-9B style configuration
|
| 272 |
+
>>> model = QuasarForConditionalGeneration(configuration)
|
| 273 |
+
|
| 274 |
+
>>> # Accessing the model configuration
|
| 275 |
+
>>> configuration = model.config
|
| 276 |
+
```"""
|
| 277 |
+
|
| 278 |
+
model_type = "quasar"
|
| 279 |
+
sub_configs = {"vision_config": QuasarVisionConfig, "text_config": QuasarTextConfig}
|
| 280 |
+
keys_to_ignore_at_inference = ["past_key_values"]
|
| 281 |
+
|
| 282 |
+
def __init__(
|
| 283 |
+
self,
|
| 284 |
+
text_config=None,
|
| 285 |
+
vision_config=None,
|
| 286 |
+
image_token_id=248056,
|
| 287 |
+
video_token_id=248057,
|
| 288 |
+
vision_start_token_id=248053,
|
| 289 |
+
vision_end_token_id=248054,
|
| 290 |
+
tie_word_embeddings=False,
|
| 291 |
+
**kwargs,
|
| 292 |
+
):
|
| 293 |
+
if isinstance(vision_config, dict):
|
| 294 |
+
self.vision_config = self.sub_configs["vision_config"](**vision_config)
|
| 295 |
+
elif vision_config is None:
|
| 296 |
+
self.vision_config = self.sub_configs["vision_config"]()
|
| 297 |
+
|
| 298 |
+
if isinstance(text_config, dict):
|
| 299 |
+
self.text_config = self.sub_configs["text_config"](**text_config)
|
| 300 |
+
elif text_config is None:
|
| 301 |
+
self.text_config = self.sub_configs["text_config"]()
|
| 302 |
+
|
| 303 |
+
self.image_token_id = image_token_id
|
| 304 |
+
self.video_token_id = video_token_id
|
| 305 |
+
self.vision_start_token_id = vision_start_token_id
|
| 306 |
+
self.vision_end_token_id = vision_end_token_id
|
| 307 |
+
self.tie_word_embeddings = tie_word_embeddings
|
| 308 |
+
super().__init__(**kwargs)
|
| 309 |
+
|
| 310 |
+
|
| 311 |
+
__all__ = ["QuasarConfig", "QuasarTextConfig"]
|
eval_only_512.json
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"epoch": 0,
|
| 3 |
+
"eval_loss": 13.217705726623535,
|
| 4 |
+
"eval_model_preparation_time": 0.0044,
|
| 5 |
+
"eval_runtime": 64.9388,
|
| 6 |
+
"eval_samples_per_second": 15.769,
|
| 7 |
+
"eval_steps_per_second": 15.769
|
| 8 |
+
}
|
generation_config.json
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_from_model_config": true,
|
| 3 |
+
"eos_token_id": 248044,
|
| 4 |
+
"output_attentions": false,
|
| 5 |
+
"output_hidden_states": false,
|
| 6 |
+
"transformers_version": "5.9.0",
|
| 7 |
+
"use_cache": true
|
| 8 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:079380385e8e5f9868edd3eace9c02c66de8de01863687d5fb89b0f0b0ef6085
|
| 3 |
+
size 17204127784
|
modeling_qwen3_5.py
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tokenizer.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:87a7830d63fcf43bf241c3c5242e96e62dd3fdc29224ca26fed8ea333db72de4
|
| 3 |
+
size 19989343
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_prefix_space": false,
|
| 3 |
+
"audio_bos_token": "<|audio_start|>",
|
| 4 |
+
"audio_eos_token": "<|audio_end|>",
|
| 5 |
+
"audio_token": "<|audio_pad|>",
|
| 6 |
+
"backend": "tokenizers",
|
| 7 |
+
"bos_token": null,
|
| 8 |
+
"clean_up_tokenization_spaces": false,
|
| 9 |
+
"eos_token": "<|endoftext|>",
|
| 10 |
+
"errors": "replace",
|
| 11 |
+
"image_token": "<|image_pad|>",
|
| 12 |
+
"is_local": false,
|
| 13 |
+
"local_files_only": false,
|
| 14 |
+
"model_max_length": 262144,
|
| 15 |
+
"model_specific_special_tokens": {
|
| 16 |
+
"audio_bos_token": "<|audio_start|>",
|
| 17 |
+
"audio_eos_token": "<|audio_end|>",
|
| 18 |
+
"audio_token": "<|audio_pad|>",
|
| 19 |
+
"image_token": "<|image_pad|>",
|
| 20 |
+
"video_token": "<|video_pad|>",
|
| 21 |
+
"vision_bos_token": "<|vision_start|>",
|
| 22 |
+
"vision_eos_token": "<|vision_end|>"
|
| 23 |
+
},
|
| 24 |
+
"pad_token": "<|endoftext|>",
|
| 25 |
+
"pretokenize_regex": "(?i:'s|'t|'re|'ve|'m|'ll|'d)|[^\\r\\n\\p{L}\\p{N}]?[\\p{L}\\p{M}]+|\\p{N}| ?[^\\s\\p{L}\\p{M}\\p{N}]+[\\r\\n]*|\\s*[\\r\\n]+|\\s+(?!\\S)|\\s+",
|
| 26 |
+
"split_special_tokens": false,
|
| 27 |
+
"tokenizer_class": "TokenizersBackend",
|
| 28 |
+
"unk_token": null,
|
| 29 |
+
"video_token": "<|video_pad|>",
|
| 30 |
+
"vision_bos_token": "<|vision_start|>",
|
| 31 |
+
"vision_eos_token": "<|vision_end|>"
|
| 32 |
+
}
|