Upload folder using huggingface_hub
Browse files- .gitattributes +1 -0
- added_tokens.json +24 -0
- chat_template.jinja +54 -0
- config.json +103 -0
- configuration_wedlm.py +248 -0
- generation_config.json +10 -0
- merges.txt +0 -0
- model-00001-of-00005.safetensors +3 -0
- model-00002-of-00005.safetensors +3 -0
- model-00003-of-00005.safetensors +3 -0
- model-00004-of-00005.safetensors +3 -0
- model-00005-of-00005.safetensors +3 -0
- model.safetensors.index.json +544 -0
- modeling_wedlm.py +1413 -0
- rng_state.pth +3 -0
- scheduler.pt +3 -0
- special_tokens_map.json +31 -0
- tokenizer.json +3 -0
- tokenizer_config.json +208 -0
- trainer_state.json +0 -0
- training_args.bin +3 -0
- vocab.json +0 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* 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
|
|
|
|
|
|
| 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
|
added_tokens.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"</tool_call>": 151658,
|
| 3 |
+
"<tool_call>": 151657,
|
| 4 |
+
"<|box_end|>": 151649,
|
| 5 |
+
"<|box_start|>": 151648,
|
| 6 |
+
"<|endoftext|>": 151643,
|
| 7 |
+
"<|file_sep|>": 151664,
|
| 8 |
+
"<|fim_middle|>": 151660,
|
| 9 |
+
"<|fim_pad|>": 151662,
|
| 10 |
+
"<|fim_prefix|>": 151659,
|
| 11 |
+
"<|fim_suffix|>": 151661,
|
| 12 |
+
"<|im_end|>": 151645,
|
| 13 |
+
"<|im_start|>": 151644,
|
| 14 |
+
"<|image_pad|>": 151655,
|
| 15 |
+
"<|object_ref_end|>": 151647,
|
| 16 |
+
"<|object_ref_start|>": 151646,
|
| 17 |
+
"<|quad_end|>": 151651,
|
| 18 |
+
"<|quad_start|>": 151650,
|
| 19 |
+
"<|repo_name|>": 151663,
|
| 20 |
+
"<|video_pad|>": 151656,
|
| 21 |
+
"<|vision_end|>": 151653,
|
| 22 |
+
"<|vision_pad|>": 151654,
|
| 23 |
+
"<|vision_start|>": 151652
|
| 24 |
+
}
|
chat_template.jinja
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{%- if tools %}
|
| 2 |
+
{{- '<|im_start|>system\n' }}
|
| 3 |
+
{%- if messages[0]['role'] == 'system' %}
|
| 4 |
+
{{- messages[0]['content'] }}
|
| 5 |
+
{%- else %}
|
| 6 |
+
{{- 'You are a helpful assistant.' }}
|
| 7 |
+
{%- endif %}
|
| 8 |
+
{{- "\n\n# Tools\n\nYou may call one or more functions to assist with the user query.\n\nYou are provided with function signatures within <tools></tools> XML tags:\n<tools>" }}
|
| 9 |
+
{%- for tool in tools %}
|
| 10 |
+
{{- "\n" }}
|
| 11 |
+
{{- tool | tojson }}
|
| 12 |
+
{%- endfor %}
|
| 13 |
+
{{- "\n</tools>\n\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\n<tool_call>\n{\"name\": <function-name>, \"arguments\": <args-json-object>}\n</tool_call><|im_end|>\n" }}
|
| 14 |
+
{%- else %}
|
| 15 |
+
{%- if messages[0]['role'] == 'system' %}
|
| 16 |
+
{{- '<|im_start|>system\n' + messages[0]['content'] + '<|im_end|>\n' }}
|
| 17 |
+
{%- else %}
|
| 18 |
+
{{- '<|im_start|>system\nYou are a helpful assistant.<|im_end|>\n' }}
|
| 19 |
+
{%- endif %}
|
| 20 |
+
{%- endif %}
|
| 21 |
+
{%- for message in messages %}
|
| 22 |
+
{%- if (message.role == "user") or (message.role == "system" and not loop.first) or (message.role == "assistant" and not message.tool_calls) %}
|
| 23 |
+
{{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>' + '\n' }}
|
| 24 |
+
{%- elif message.role == "assistant" %}
|
| 25 |
+
{{- '<|im_start|>' + message.role }}
|
| 26 |
+
{%- if message.content %}
|
| 27 |
+
{{- '\n' + message.content }}
|
| 28 |
+
{%- endif %}
|
| 29 |
+
{%- for tool_call in message.tool_calls %}
|
| 30 |
+
{%- if tool_call.function is defined %}
|
| 31 |
+
{%- set tool_call = tool_call.function %}
|
| 32 |
+
{%- endif %}
|
| 33 |
+
{{- '\n<tool_call>\n{"name": "' }}
|
| 34 |
+
{{- tool_call.name }}
|
| 35 |
+
{{- '", "arguments": ' }}
|
| 36 |
+
{{- tool_call.arguments | tojson }}
|
| 37 |
+
{{- '}\n</tool_call>' }}
|
| 38 |
+
{%- endfor %}
|
| 39 |
+
{{- '<|im_end|>\n' }}
|
| 40 |
+
{%- elif message.role == "tool" %}
|
| 41 |
+
{%- if (loop.index0 == 0) or (messages[loop.index0 - 1].role != "tool") %}
|
| 42 |
+
{{- '<|im_start|>user' }}
|
| 43 |
+
{%- endif %}
|
| 44 |
+
{{- '\n<tool_response>\n' }}
|
| 45 |
+
{{- message.content }}
|
| 46 |
+
{{- '\n</tool_response>' }}
|
| 47 |
+
{%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
|
| 48 |
+
{{- '<|im_end|>\n' }}
|
| 49 |
+
{%- endif %}
|
| 50 |
+
{%- endif %}
|
| 51 |
+
{%- endfor %}
|
| 52 |
+
{%- if add_generation_prompt %}
|
| 53 |
+
{{- '<|im_start|>assistant\n' }}
|
| 54 |
+
{%- endif %}
|
config.json
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"WeDLMForCausalLM"
|
| 4 |
+
],
|
| 5 |
+
"attention_bias": false,
|
| 6 |
+
"attention_dropout": 0.0,
|
| 7 |
+
"auto_map": {
|
| 8 |
+
"AutoConfig": "configuration_wedlm.WeDLMConfig",
|
| 9 |
+
"AutoModel": "modeling_wedlm.WeDLMForCausalLM",
|
| 10 |
+
"AutoModelForCausalLM": "modeling_wedlm.WeDLMForCausalLM"
|
| 11 |
+
},
|
| 12 |
+
"dtype": "bfloat16",
|
| 13 |
+
"eos_token_id": 151645,
|
| 14 |
+
"flow_block_size": 64,
|
| 15 |
+
"flow_discretization": "argmax",
|
| 16 |
+
"flow_inference_steps": 8,
|
| 17 |
+
"flow_init_sigma": 1.0,
|
| 18 |
+
"flow_loss_weight": 1.0,
|
| 19 |
+
"flow_temperature": 1.0,
|
| 20 |
+
"flow_time_embedding_dim": 256,
|
| 21 |
+
"flow_time_embedding_max_period": 10000,
|
| 22 |
+
"flow_time_scale": 1000.0,
|
| 23 |
+
"flow_top_k": 0,
|
| 24 |
+
"flow_top_p": 1.0,
|
| 25 |
+
"flow_train_block_size": 64,
|
| 26 |
+
"flow_train_mask_ratio": 0.15,
|
| 27 |
+
"flow_train_min_target_tokens": 1,
|
| 28 |
+
"flow_train_strategy": "suffix_block",
|
| 29 |
+
"flow_type": "rectified_flow",
|
| 30 |
+
"head_dim": 128,
|
| 31 |
+
"hidden_act": "silu",
|
| 32 |
+
"hidden_size": 4096,
|
| 33 |
+
"initializer_range": 0.02,
|
| 34 |
+
"intermediate_size": 12288,
|
| 35 |
+
"layer_types": [
|
| 36 |
+
"full_attention",
|
| 37 |
+
"full_attention",
|
| 38 |
+
"full_attention",
|
| 39 |
+
"full_attention",
|
| 40 |
+
"full_attention",
|
| 41 |
+
"full_attention",
|
| 42 |
+
"full_attention",
|
| 43 |
+
"full_attention",
|
| 44 |
+
"full_attention",
|
| 45 |
+
"full_attention",
|
| 46 |
+
"full_attention",
|
| 47 |
+
"full_attention",
|
| 48 |
+
"full_attention",
|
| 49 |
+
"full_attention",
|
| 50 |
+
"full_attention",
|
| 51 |
+
"full_attention",
|
| 52 |
+
"full_attention",
|
| 53 |
+
"full_attention",
|
| 54 |
+
"full_attention",
|
| 55 |
+
"full_attention",
|
| 56 |
+
"full_attention",
|
| 57 |
+
"full_attention",
|
| 58 |
+
"full_attention",
|
| 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 |
+
],
|
| 85 |
+
"mask_token_id": null,
|
| 86 |
+
"max_position_embeddings": 16384,
|
| 87 |
+
"max_window_layers": 48,
|
| 88 |
+
"model_type": "wedlm",
|
| 89 |
+
"num_attention_heads": 32,
|
| 90 |
+
"num_hidden_layers": 48,
|
| 91 |
+
"num_key_value_heads": 8,
|
| 92 |
+
"pad_token_id": 151643,
|
| 93 |
+
"qk_norm": true,
|
| 94 |
+
"rms_norm_eps": 1e-06,
|
| 95 |
+
"rope_scaling": null,
|
| 96 |
+
"rope_theta": 1000000.0,
|
| 97 |
+
"sliding_window": null,
|
| 98 |
+
"tie_word_embeddings": false,
|
| 99 |
+
"transformers_version": "4.57.1",
|
| 100 |
+
"use_cache": false,
|
| 101 |
+
"use_sliding_window": false,
|
| 102 |
+
"vocab_size": 151936
|
| 103 |
+
}
|
configuration_wedlm.py
ADDED
|
@@ -0,0 +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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# coding=utf-8
|
| 2 |
+
# Copyright 2024 The WeDLM team and the HuggingFace Inc. team. All rights reserved.
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
"""WeDLM model configuration"""
|
| 16 |
+
|
| 17 |
+
from transformers.configuration_utils import PretrainedConfig
|
| 18 |
+
from transformers.modeling_rope_utils import rope_config_validation
|
| 19 |
+
from transformers.utils import logging
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
logger = logging.get_logger(__name__)
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
class WeDLMConfig(PretrainedConfig):
|
| 26 |
+
r"""
|
| 27 |
+
This is the configuration class to store the configuration of a [`WeDLMModel`]. It is used to instantiate a
|
| 28 |
+
WeDLM model according to the specified arguments, defining the model architecture.
|
| 29 |
+
|
| 30 |
+
Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
|
| 31 |
+
documentation from [`PretrainedConfig`] for more information.
|
| 32 |
+
|
| 33 |
+
Args:
|
| 34 |
+
vocab_size (`int`, *optional*, defaults to 151936):
|
| 35 |
+
Vocabulary size of the WeDLM model. Defines the number of different tokens that can be represented by the
|
| 36 |
+
`inputs_ids` passed when calling [`WeDLMModel`]
|
| 37 |
+
hidden_size (`int`, *optional*, defaults to 4096):
|
| 38 |
+
Dimension of the hidden representations.
|
| 39 |
+
intermediate_size (`int`, *optional*, defaults to 22016):
|
| 40 |
+
Dimension of the MLP representations.
|
| 41 |
+
num_hidden_layers (`int`, *optional*, defaults to 32):
|
| 42 |
+
Number of hidden layers in the Transformer decoder.
|
| 43 |
+
num_attention_heads (`int`, *optional*, defaults to 32):
|
| 44 |
+
Number of attention heads for each attention layer in the Transformer decoder.
|
| 45 |
+
num_key_value_heads (`int`, *optional*, defaults to 32):
|
| 46 |
+
This is the number of key_value heads that should be used to implement Grouped Query Attention. If
|
| 47 |
+
`num_key_value_heads=num_attention_heads`, the model will use Multi Head Attention (MHA), if
|
| 48 |
+
`num_key_value_heads=1` the model will use Multi Query Attention (MQA) otherwise GQA is used.
|
| 49 |
+
hidden_act (`str` or `function`, *optional*, defaults to `"silu"`):
|
| 50 |
+
The non-linear activation function (function or string) in the decoder.
|
| 51 |
+
max_position_embeddings (`int`, *optional*, defaults to 32768):
|
| 52 |
+
The maximum sequence length that this model might ever be used with.
|
| 53 |
+
initializer_range (`float`, *optional*, defaults to 0.02):
|
| 54 |
+
The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
|
| 55 |
+
rms_norm_eps (`float`, *optional*, defaults to 1e-06):
|
| 56 |
+
The epsilon used by the rms normalization layers.
|
| 57 |
+
use_cache (`bool`, *optional*, defaults to `True`):
|
| 58 |
+
Whether or not the model should return the last key/values attentions (not used by all models). Only
|
| 59 |
+
relevant if `config.is_decoder=True`.
|
| 60 |
+
tie_word_embeddings (`bool`, *optional*, defaults to `False`):
|
| 61 |
+
Whether the model's input and output word embeddings should be tied.
|
| 62 |
+
rope_theta (`float`, *optional*, defaults to 10000.0):
|
| 63 |
+
The base period of the RoPE embeddings.
|
| 64 |
+
rope_scaling (`Dict`, *optional*):
|
| 65 |
+
Dictionary containing the scaling configuration for the RoPE embeddings.
|
| 66 |
+
use_sliding_window (`bool`, *optional*, defaults to `False`):
|
| 67 |
+
Whether to use sliding window attention.
|
| 68 |
+
sliding_window (`int`, *optional*, defaults to 4096):
|
| 69 |
+
Sliding window attention (SWA) window size. If not specified, will default to `4096`.
|
| 70 |
+
max_window_layers (`int`, *optional*, defaults to 28):
|
| 71 |
+
The number of layers using full attention.
|
| 72 |
+
attention_dropout (`float`, *optional*, defaults to 0.0):
|
| 73 |
+
The dropout ratio for the attention probabilities.
|
| 74 |
+
attention_bias (`bool`, *optional*, defaults to `True`):
|
| 75 |
+
Whether to use bias in QKV projections. Set to `True` for Qwen2.5 compatibility,
|
| 76 |
+
`False` for Qwen3 compatibility.
|
| 77 |
+
qk_norm (`bool`, *optional*, defaults to `False`):
|
| 78 |
+
Whether to use QK normalization. Set to `True` for Qwen3 compatibility.
|
| 79 |
+
head_dim (`int`, *optional*):
|
| 80 |
+
The dimension of each attention head. If not specified, defaults to hidden_size // num_attention_heads.
|
| 81 |
+
|
| 82 |
+
mask_token_id (`int`, *optional*):
|
| 83 |
+
Token id used by upstream discrete diffusion-style block decoding as the MASK placeholder.
|
| 84 |
+
(Kept for backward compatibility; not used by Flow-Matching decoding.)
|
| 85 |
+
|
| 86 |
+
----------------------------------------------------------------------
|
| 87 |
+
Flow Matching / Rectified Flow (primary training & decoding)
|
| 88 |
+
----------------------------------------------------------------------
|
| 89 |
+
flow_type (`str`, *optional*, defaults to `"rectified_flow"`):
|
| 90 |
+
Flow family. Currently `"rectified_flow"` is implemented (straight-line probability paths).
|
| 91 |
+
flow_time_embedding_dim (`int`, *optional*, defaults to 256):
|
| 92 |
+
Dimensionality of the sinusoidal timestep embedding before projection.
|
| 93 |
+
flow_time_embedding_max_period (`int`, *optional*, defaults to 10000):
|
| 94 |
+
Max period for sinusoidal timestep embeddings.
|
| 95 |
+
flow_time_scale (`float`, *optional*, defaults to 1000.0):
|
| 96 |
+
Scalar multiplier applied to normalized timesteps (t in [0,1]) before sinusoidal embedding.
|
| 97 |
+
flow_init_sigma (`float`, *optional*, defaults to 1.0):
|
| 98 |
+
Standard deviation of the Gaussian base distribution used for flow sampling/training in embedding space.
|
| 99 |
+
flow_loss_weight (`float`, *optional*, defaults to 1.0):
|
| 100 |
+
Weight for Flow Matching loss.
|
| 101 |
+
|
| 102 |
+
flow_train_strategy (`str`, *optional*, defaults to `"suffix_block"`):
|
| 103 |
+
Training target selection strategy when `flow_target_mask` is not provided to `forward`.
|
| 104 |
+
- `"suffix_block"`: use a suffix contiguous block as flow targets (aligned with block decoding).
|
| 105 |
+
- `"random"`: random Bernoulli masking by `flow_train_mask_ratio`.
|
| 106 |
+
flow_train_block_size (`int`, *optional*, defaults to 64):
|
| 107 |
+
Target block size for `"suffix_block"` strategy.
|
| 108 |
+
flow_train_min_target_tokens (`int`, *optional*, defaults to 1):
|
| 109 |
+
Minimum number of flow targets per sample (after filtering pads / ignored labels).
|
| 110 |
+
flow_train_mask_ratio (`float`, *optional*, defaults to 0.15):
|
| 111 |
+
Target masking ratio for `"random"` strategy.
|
| 112 |
+
|
| 113 |
+
flow_inference_steps (`int`, *optional*, defaults to 8):
|
| 114 |
+
Default number of Euler steps per block for `generate_wedlm`.
|
| 115 |
+
flow_block_size (`int`, *optional*, defaults to 64):
|
| 116 |
+
Default block size (new tokens per block) for `generate_wedlm`.
|
| 117 |
+
flow_discretization (`str`, *optional*, defaults to `"argmax"`):
|
| 118 |
+
Discretization method from final embeddings to token IDs:
|
| 119 |
+
- `"argmax"`: argmax over vocabulary logits.
|
| 120 |
+
- `"sample"`: temperature + (top-k/top-p) sampling from vocabulary logits.
|
| 121 |
+
flow_temperature (`float`, *optional*, defaults to 1.0):
|
| 122 |
+
Temperature for `"sample"` discretization.
|
| 123 |
+
flow_top_p (`float`, *optional*, defaults to 1.0):
|
| 124 |
+
Top-p (nucleus) sampling for `"sample"` discretization.
|
| 125 |
+
flow_top_k (`int`, *optional*, defaults to 0):
|
| 126 |
+
Top-k sampling for `"sample"` discretization. 0 disables top-k filtering.
|
| 127 |
+
"""
|
| 128 |
+
|
| 129 |
+
model_type = "wedlm"
|
| 130 |
+
keys_to_ignore_at_inference = ["past_key_values"]
|
| 131 |
+
|
| 132 |
+
def __init__(
|
| 133 |
+
self,
|
| 134 |
+
vocab_size=151936,
|
| 135 |
+
hidden_size=4096,
|
| 136 |
+
intermediate_size=22016,
|
| 137 |
+
num_hidden_layers=32,
|
| 138 |
+
num_attention_heads=32,
|
| 139 |
+
num_key_value_heads=32,
|
| 140 |
+
hidden_act="silu",
|
| 141 |
+
max_position_embeddings=32768,
|
| 142 |
+
initializer_range=0.02,
|
| 143 |
+
rms_norm_eps=1e-6,
|
| 144 |
+
use_cache=True,
|
| 145 |
+
tie_word_embeddings=False,
|
| 146 |
+
rope_theta=10000.0,
|
| 147 |
+
rope_scaling=None,
|
| 148 |
+
use_sliding_window=False,
|
| 149 |
+
sliding_window=4096,
|
| 150 |
+
max_window_layers=28,
|
| 151 |
+
attention_dropout=0.0,
|
| 152 |
+
attention_bias=True,
|
| 153 |
+
qk_norm=False,
|
| 154 |
+
head_dim=None,
|
| 155 |
+
mask_token_id=None,
|
| 156 |
+
# Flow Matching / Rectified Flow (primary)
|
| 157 |
+
flow_type="rectified_flow",
|
| 158 |
+
flow_time_embedding_dim=256,
|
| 159 |
+
flow_time_embedding_max_period=10000,
|
| 160 |
+
flow_time_scale=1000.0,
|
| 161 |
+
flow_init_sigma=1.0,
|
| 162 |
+
flow_loss_weight=1.0,
|
| 163 |
+
flow_train_strategy="suffix_block",
|
| 164 |
+
flow_train_block_size=64,
|
| 165 |
+
flow_train_min_target_tokens=1,
|
| 166 |
+
flow_train_mask_ratio=0.15,
|
| 167 |
+
flow_inference_steps=8,
|
| 168 |
+
flow_block_size=64,
|
| 169 |
+
flow_discretization="argmax",
|
| 170 |
+
flow_temperature=1.0,
|
| 171 |
+
flow_top_p=1.0,
|
| 172 |
+
flow_top_k=0,
|
| 173 |
+
**kwargs,
|
| 174 |
+
):
|
| 175 |
+
self.vocab_size = vocab_size
|
| 176 |
+
self.max_position_embeddings = max_position_embeddings
|
| 177 |
+
self.hidden_size = hidden_size
|
| 178 |
+
self.intermediate_size = intermediate_size
|
| 179 |
+
self.num_hidden_layers = num_hidden_layers
|
| 180 |
+
self.num_attention_heads = num_attention_heads
|
| 181 |
+
self.use_sliding_window = use_sliding_window
|
| 182 |
+
self.sliding_window = sliding_window if self.use_sliding_window else None
|
| 183 |
+
self.max_window_layers = max_window_layers
|
| 184 |
+
|
| 185 |
+
# for backward compatibility
|
| 186 |
+
if num_key_value_heads is None:
|
| 187 |
+
num_key_value_heads = num_attention_heads
|
| 188 |
+
|
| 189 |
+
self.num_key_value_heads = num_key_value_heads
|
| 190 |
+
self.hidden_act = hidden_act
|
| 191 |
+
self.initializer_range = initializer_range
|
| 192 |
+
self.rms_norm_eps = rms_norm_eps
|
| 193 |
+
self.use_cache = use_cache
|
| 194 |
+
self.rope_theta = rope_theta
|
| 195 |
+
self.rope_scaling = rope_scaling
|
| 196 |
+
self.attention_dropout = attention_dropout
|
| 197 |
+
self.attention_bias = attention_bias
|
| 198 |
+
self.qk_norm = qk_norm
|
| 199 |
+
self.mask_token_id = mask_token_id
|
| 200 |
+
|
| 201 |
+
if head_dim is None:
|
| 202 |
+
self.head_dim = hidden_size // num_attention_heads
|
| 203 |
+
else:
|
| 204 |
+
self.head_dim = head_dim
|
| 205 |
+
|
| 206 |
+
# ----------------------------
|
| 207 |
+
# Flow Matching configuration
|
| 208 |
+
# ----------------------------
|
| 209 |
+
self.flow_type = flow_type
|
| 210 |
+
self.flow_time_embedding_dim = flow_time_embedding_dim
|
| 211 |
+
self.flow_time_embedding_max_period = flow_time_embedding_max_period
|
| 212 |
+
self.flow_time_scale = flow_time_scale
|
| 213 |
+
self.flow_init_sigma = flow_init_sigma
|
| 214 |
+
self.flow_loss_weight = flow_loss_weight
|
| 215 |
+
|
| 216 |
+
self.flow_train_strategy = flow_train_strategy
|
| 217 |
+
self.flow_train_block_size = flow_train_block_size
|
| 218 |
+
self.flow_train_min_target_tokens = flow_train_min_target_tokens
|
| 219 |
+
self.flow_train_mask_ratio = flow_train_mask_ratio
|
| 220 |
+
|
| 221 |
+
self.flow_inference_steps = flow_inference_steps
|
| 222 |
+
self.flow_block_size = flow_block_size
|
| 223 |
+
self.flow_discretization = flow_discretization
|
| 224 |
+
self.flow_temperature = flow_temperature
|
| 225 |
+
self.flow_top_p = flow_top_p
|
| 226 |
+
self.flow_top_k = flow_top_k
|
| 227 |
+
|
| 228 |
+
# Validate the correctness of rotary position embeddings parameters
|
| 229 |
+
# BC: if there is a 'type' field, move it to 'rope_type'.
|
| 230 |
+
if self.rope_scaling is not None and "type" in self.rope_scaling:
|
| 231 |
+
self.rope_scaling["rope_type"] = self.rope_scaling["type"]
|
| 232 |
+
rope_config_validation(self)
|
| 233 |
+
|
| 234 |
+
# Generate layer_types based on sliding window configuration
|
| 235 |
+
self.layer_types = [
|
| 236 |
+
"sliding_attention"
|
| 237 |
+
if self.sliding_window is not None and i >= self.max_window_layers
|
| 238 |
+
else "full_attention"
|
| 239 |
+
for i in range(self.num_hidden_layers)
|
| 240 |
+
]
|
| 241 |
+
|
| 242 |
+
super().__init__(
|
| 243 |
+
tie_word_embeddings=tie_word_embeddings,
|
| 244 |
+
**kwargs,
|
| 245 |
+
)
|
| 246 |
+
|
| 247 |
+
|
| 248 |
+
__all__ = ["WeDLMConfig"]
|
generation_config.json
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_from_model_config": true,
|
| 3 |
+
"eos_token_id": [
|
| 4 |
+
151645,
|
| 5 |
+
151643
|
| 6 |
+
],
|
| 7 |
+
"pad_token_id": 151643,
|
| 8 |
+
"transformers_version": "4.57.1",
|
| 9 |
+
"use_cache": false
|
| 10 |
+
}
|
merges.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
model-00001-of-00005.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9c18451221d67cad682cb689bcc20ba658bbdf60b3d2fa02c908ef53e9893a10
|
| 3 |
+
size 4902257696
|
model-00002-of-00005.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:db1baa8d63057e5c6201b87dc7d0d9af8df6b2a5f6f4a571b4a3326d28c43084
|
| 3 |
+
size 4915960368
|
model-00003-of-00005.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f28b5cb9d15387370661a4d67bd558cf3687324f3f747235913de11c9ffe6fcd
|
| 3 |
+
size 4983068496
|
model-00004-of-00005.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:889f46b47dac87fb0d747781c28b984ba38c1d6fea1b08349ec118bcf11d1e06
|
| 3 |
+
size 4966300072
|
model-00005-of-00005.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:44a1a84800d42417fde11e8481eeea144214cc3015bb3dd066d1f1ed3c16b311
|
| 3 |
+
size 1313882744
|
model.safetensors.index.json
ADDED
|
@@ -0,0 +1,544 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"metadata": {
|
| 3 |
+
"total_parameters": 10540703744,
|
| 4 |
+
"total_size": 21081407488
|
| 5 |
+
},
|
| 6 |
+
"weight_map": {
|
| 7 |
+
"flow_head.weight": "model-00005-of-00005.safetensors",
|
| 8 |
+
"flow_time_embed.linear_1.bias": "model-00005-of-00005.safetensors",
|
| 9 |
+
"flow_time_embed.linear_1.weight": "model-00005-of-00005.safetensors",
|
| 10 |
+
"flow_time_embed.linear_2.bias": "model-00005-of-00005.safetensors",
|
| 11 |
+
"flow_time_embed.linear_2.weight": "model-00005-of-00005.safetensors",
|
| 12 |
+
"lm_head.weight": "model-00005-of-00005.safetensors",
|
| 13 |
+
"model.embed_tokens.weight": "model-00001-of-00005.safetensors",
|
| 14 |
+
"model.layers.0.input_layernorm.weight": "model-00001-of-00005.safetensors",
|
| 15 |
+
"model.layers.0.mlp.down_proj.weight": "model-00001-of-00005.safetensors",
|
| 16 |
+
"model.layers.0.mlp.gate_proj.weight": "model-00001-of-00005.safetensors",
|
| 17 |
+
"model.layers.0.mlp.up_proj.weight": "model-00001-of-00005.safetensors",
|
| 18 |
+
"model.layers.0.post_attention_layernorm.weight": "model-00001-of-00005.safetensors",
|
| 19 |
+
"model.layers.0.self_attn.k_norm.weight": "model-00001-of-00005.safetensors",
|
| 20 |
+
"model.layers.0.self_attn.k_proj.weight": "model-00001-of-00005.safetensors",
|
| 21 |
+
"model.layers.0.self_attn.o_proj.weight": "model-00001-of-00005.safetensors",
|
| 22 |
+
"model.layers.0.self_attn.q_norm.weight": "model-00001-of-00005.safetensors",
|
| 23 |
+
"model.layers.0.self_attn.q_proj.weight": "model-00001-of-00005.safetensors",
|
| 24 |
+
"model.layers.0.self_attn.v_proj.weight": "model-00001-of-00005.safetensors",
|
| 25 |
+
"model.layers.1.input_layernorm.weight": "model-00001-of-00005.safetensors",
|
| 26 |
+
"model.layers.1.mlp.down_proj.weight": "model-00001-of-00005.safetensors",
|
| 27 |
+
"model.layers.1.mlp.gate_proj.weight": "model-00001-of-00005.safetensors",
|
| 28 |
+
"model.layers.1.mlp.up_proj.weight": "model-00001-of-00005.safetensors",
|
| 29 |
+
"model.layers.1.post_attention_layernorm.weight": "model-00001-of-00005.safetensors",
|
| 30 |
+
"model.layers.1.self_attn.k_norm.weight": "model-00001-of-00005.safetensors",
|
| 31 |
+
"model.layers.1.self_attn.k_proj.weight": "model-00001-of-00005.safetensors",
|
| 32 |
+
"model.layers.1.self_attn.o_proj.weight": "model-00001-of-00005.safetensors",
|
| 33 |
+
"model.layers.1.self_attn.q_norm.weight": "model-00001-of-00005.safetensors",
|
| 34 |
+
"model.layers.1.self_attn.q_proj.weight": "model-00001-of-00005.safetensors",
|
| 35 |
+
"model.layers.1.self_attn.v_proj.weight": "model-00001-of-00005.safetensors",
|
| 36 |
+
"model.layers.10.input_layernorm.weight": "model-00002-of-00005.safetensors",
|
| 37 |
+
"model.layers.10.mlp.down_proj.weight": "model-00002-of-00005.safetensors",
|
| 38 |
+
"model.layers.10.mlp.gate_proj.weight": "model-00002-of-00005.safetensors",
|
| 39 |
+
"model.layers.10.mlp.up_proj.weight": "model-00002-of-00005.safetensors",
|
| 40 |
+
"model.layers.10.post_attention_layernorm.weight": "model-00002-of-00005.safetensors",
|
| 41 |
+
"model.layers.10.self_attn.k_norm.weight": "model-00002-of-00005.safetensors",
|
| 42 |
+
"model.layers.10.self_attn.k_proj.weight": "model-00002-of-00005.safetensors",
|
| 43 |
+
"model.layers.10.self_attn.o_proj.weight": "model-00002-of-00005.safetensors",
|
| 44 |
+
"model.layers.10.self_attn.q_norm.weight": "model-00002-of-00005.safetensors",
|
| 45 |
+
"model.layers.10.self_attn.q_proj.weight": "model-00002-of-00005.safetensors",
|
| 46 |
+
"model.layers.10.self_attn.v_proj.weight": "model-00002-of-00005.safetensors",
|
| 47 |
+
"model.layers.11.input_layernorm.weight": "model-00002-of-00005.safetensors",
|
| 48 |
+
"model.layers.11.mlp.down_proj.weight": "model-00002-of-00005.safetensors",
|
| 49 |
+
"model.layers.11.mlp.gate_proj.weight": "model-00002-of-00005.safetensors",
|
| 50 |
+
"model.layers.11.mlp.up_proj.weight": "model-00002-of-00005.safetensors",
|
| 51 |
+
"model.layers.11.post_attention_layernorm.weight": "model-00002-of-00005.safetensors",
|
| 52 |
+
"model.layers.11.self_attn.k_norm.weight": "model-00002-of-00005.safetensors",
|
| 53 |
+
"model.layers.11.self_attn.k_proj.weight": "model-00002-of-00005.safetensors",
|
| 54 |
+
"model.layers.11.self_attn.o_proj.weight": "model-00002-of-00005.safetensors",
|
| 55 |
+
"model.layers.11.self_attn.q_norm.weight": "model-00002-of-00005.safetensors",
|
| 56 |
+
"model.layers.11.self_attn.q_proj.weight": "model-00002-of-00005.safetensors",
|
| 57 |
+
"model.layers.11.self_attn.v_proj.weight": "model-00002-of-00005.safetensors",
|
| 58 |
+
"model.layers.12.input_layernorm.weight": "model-00002-of-00005.safetensors",
|
| 59 |
+
"model.layers.12.mlp.down_proj.weight": "model-00002-of-00005.safetensors",
|
| 60 |
+
"model.layers.12.mlp.gate_proj.weight": "model-00002-of-00005.safetensors",
|
| 61 |
+
"model.layers.12.mlp.up_proj.weight": "model-00002-of-00005.safetensors",
|
| 62 |
+
"model.layers.12.post_attention_layernorm.weight": "model-00002-of-00005.safetensors",
|
| 63 |
+
"model.layers.12.self_attn.k_norm.weight": "model-00002-of-00005.safetensors",
|
| 64 |
+
"model.layers.12.self_attn.k_proj.weight": "model-00002-of-00005.safetensors",
|
| 65 |
+
"model.layers.12.self_attn.o_proj.weight": "model-00002-of-00005.safetensors",
|
| 66 |
+
"model.layers.12.self_attn.q_norm.weight": "model-00002-of-00005.safetensors",
|
| 67 |
+
"model.layers.12.self_attn.q_proj.weight": "model-00002-of-00005.safetensors",
|
| 68 |
+
"model.layers.12.self_attn.v_proj.weight": "model-00002-of-00005.safetensors",
|
| 69 |
+
"model.layers.13.input_layernorm.weight": "model-00002-of-00005.safetensors",
|
| 70 |
+
"model.layers.13.mlp.down_proj.weight": "model-00002-of-00005.safetensors",
|
| 71 |
+
"model.layers.13.mlp.gate_proj.weight": "model-00002-of-00005.safetensors",
|
| 72 |
+
"model.layers.13.mlp.up_proj.weight": "model-00002-of-00005.safetensors",
|
| 73 |
+
"model.layers.13.post_attention_layernorm.weight": "model-00002-of-00005.safetensors",
|
| 74 |
+
"model.layers.13.self_attn.k_norm.weight": "model-00002-of-00005.safetensors",
|
| 75 |
+
"model.layers.13.self_attn.k_proj.weight": "model-00002-of-00005.safetensors",
|
| 76 |
+
"model.layers.13.self_attn.o_proj.weight": "model-00002-of-00005.safetensors",
|
| 77 |
+
"model.layers.13.self_attn.q_norm.weight": "model-00002-of-00005.safetensors",
|
| 78 |
+
"model.layers.13.self_attn.q_proj.weight": "model-00002-of-00005.safetensors",
|
| 79 |
+
"model.layers.13.self_attn.v_proj.weight": "model-00002-of-00005.safetensors",
|
| 80 |
+
"model.layers.14.input_layernorm.weight": "model-00002-of-00005.safetensors",
|
| 81 |
+
"model.layers.14.mlp.down_proj.weight": "model-00002-of-00005.safetensors",
|
| 82 |
+
"model.layers.14.mlp.gate_proj.weight": "model-00002-of-00005.safetensors",
|
| 83 |
+
"model.layers.14.mlp.up_proj.weight": "model-00002-of-00005.safetensors",
|
| 84 |
+
"model.layers.14.post_attention_layernorm.weight": "model-00002-of-00005.safetensors",
|
| 85 |
+
"model.layers.14.self_attn.k_norm.weight": "model-00002-of-00005.safetensors",
|
| 86 |
+
"model.layers.14.self_attn.k_proj.weight": "model-00002-of-00005.safetensors",
|
| 87 |
+
"model.layers.14.self_attn.o_proj.weight": "model-00002-of-00005.safetensors",
|
| 88 |
+
"model.layers.14.self_attn.q_norm.weight": "model-00002-of-00005.safetensors",
|
| 89 |
+
"model.layers.14.self_attn.q_proj.weight": "model-00002-of-00005.safetensors",
|
| 90 |
+
"model.layers.14.self_attn.v_proj.weight": "model-00002-of-00005.safetensors",
|
| 91 |
+
"model.layers.15.input_layernorm.weight": "model-00002-of-00005.safetensors",
|
| 92 |
+
"model.layers.15.mlp.down_proj.weight": "model-00002-of-00005.safetensors",
|
| 93 |
+
"model.layers.15.mlp.gate_proj.weight": "model-00002-of-00005.safetensors",
|
| 94 |
+
"model.layers.15.mlp.up_proj.weight": "model-00002-of-00005.safetensors",
|
| 95 |
+
"model.layers.15.post_attention_layernorm.weight": "model-00002-of-00005.safetensors",
|
| 96 |
+
"model.layers.15.self_attn.k_norm.weight": "model-00002-of-00005.safetensors",
|
| 97 |
+
"model.layers.15.self_attn.k_proj.weight": "model-00002-of-00005.safetensors",
|
| 98 |
+
"model.layers.15.self_attn.o_proj.weight": "model-00002-of-00005.safetensors",
|
| 99 |
+
"model.layers.15.self_attn.q_norm.weight": "model-00002-of-00005.safetensors",
|
| 100 |
+
"model.layers.15.self_attn.q_proj.weight": "model-00002-of-00005.safetensors",
|
| 101 |
+
"model.layers.15.self_attn.v_proj.weight": "model-00002-of-00005.safetensors",
|
| 102 |
+
"model.layers.16.input_layernorm.weight": "model-00002-of-00005.safetensors",
|
| 103 |
+
"model.layers.16.mlp.down_proj.weight": "model-00002-of-00005.safetensors",
|
| 104 |
+
"model.layers.16.mlp.gate_proj.weight": "model-00002-of-00005.safetensors",
|
| 105 |
+
"model.layers.16.mlp.up_proj.weight": "model-00002-of-00005.safetensors",
|
| 106 |
+
"model.layers.16.post_attention_layernorm.weight": "model-00002-of-00005.safetensors",
|
| 107 |
+
"model.layers.16.self_attn.k_norm.weight": "model-00002-of-00005.safetensors",
|
| 108 |
+
"model.layers.16.self_attn.k_proj.weight": "model-00002-of-00005.safetensors",
|
| 109 |
+
"model.layers.16.self_attn.o_proj.weight": "model-00002-of-00005.safetensors",
|
| 110 |
+
"model.layers.16.self_attn.q_norm.weight": "model-00002-of-00005.safetensors",
|
| 111 |
+
"model.layers.16.self_attn.q_proj.weight": "model-00002-of-00005.safetensors",
|
| 112 |
+
"model.layers.16.self_attn.v_proj.weight": "model-00002-of-00005.safetensors",
|
| 113 |
+
"model.layers.17.input_layernorm.weight": "model-00002-of-00005.safetensors",
|
| 114 |
+
"model.layers.17.mlp.down_proj.weight": "model-00002-of-00005.safetensors",
|
| 115 |
+
"model.layers.17.mlp.gate_proj.weight": "model-00002-of-00005.safetensors",
|
| 116 |
+
"model.layers.17.mlp.up_proj.weight": "model-00002-of-00005.safetensors",
|
| 117 |
+
"model.layers.17.post_attention_layernorm.weight": "model-00002-of-00005.safetensors",
|
| 118 |
+
"model.layers.17.self_attn.k_norm.weight": "model-00002-of-00005.safetensors",
|
| 119 |
+
"model.layers.17.self_attn.k_proj.weight": "model-00002-of-00005.safetensors",
|
| 120 |
+
"model.layers.17.self_attn.o_proj.weight": "model-00002-of-00005.safetensors",
|
| 121 |
+
"model.layers.17.self_attn.q_norm.weight": "model-00002-of-00005.safetensors",
|
| 122 |
+
"model.layers.17.self_attn.q_proj.weight": "model-00002-of-00005.safetensors",
|
| 123 |
+
"model.layers.17.self_attn.v_proj.weight": "model-00002-of-00005.safetensors",
|
| 124 |
+
"model.layers.18.input_layernorm.weight": "model-00002-of-00005.safetensors",
|
| 125 |
+
"model.layers.18.mlp.down_proj.weight": "model-00002-of-00005.safetensors",
|
| 126 |
+
"model.layers.18.mlp.gate_proj.weight": "model-00002-of-00005.safetensors",
|
| 127 |
+
"model.layers.18.mlp.up_proj.weight": "model-00002-of-00005.safetensors",
|
| 128 |
+
"model.layers.18.post_attention_layernorm.weight": "model-00002-of-00005.safetensors",
|
| 129 |
+
"model.layers.18.self_attn.k_norm.weight": "model-00002-of-00005.safetensors",
|
| 130 |
+
"model.layers.18.self_attn.k_proj.weight": "model-00002-of-00005.safetensors",
|
| 131 |
+
"model.layers.18.self_attn.o_proj.weight": "model-00002-of-00005.safetensors",
|
| 132 |
+
"model.layers.18.self_attn.q_norm.weight": "model-00002-of-00005.safetensors",
|
| 133 |
+
"model.layers.18.self_attn.q_proj.weight": "model-00002-of-00005.safetensors",
|
| 134 |
+
"model.layers.18.self_attn.v_proj.weight": "model-00002-of-00005.safetensors",
|
| 135 |
+
"model.layers.19.input_layernorm.weight": "model-00002-of-00005.safetensors",
|
| 136 |
+
"model.layers.19.mlp.down_proj.weight": "model-00002-of-00005.safetensors",
|
| 137 |
+
"model.layers.19.mlp.gate_proj.weight": "model-00002-of-00005.safetensors",
|
| 138 |
+
"model.layers.19.mlp.up_proj.weight": "model-00002-of-00005.safetensors",
|
| 139 |
+
"model.layers.19.post_attention_layernorm.weight": "model-00002-of-00005.safetensors",
|
| 140 |
+
"model.layers.19.self_attn.k_norm.weight": "model-00002-of-00005.safetensors",
|
| 141 |
+
"model.layers.19.self_attn.k_proj.weight": "model-00002-of-00005.safetensors",
|
| 142 |
+
"model.layers.19.self_attn.o_proj.weight": "model-00002-of-00005.safetensors",
|
| 143 |
+
"model.layers.19.self_attn.q_norm.weight": "model-00002-of-00005.safetensors",
|
| 144 |
+
"model.layers.19.self_attn.q_proj.weight": "model-00002-of-00005.safetensors",
|
| 145 |
+
"model.layers.19.self_attn.v_proj.weight": "model-00002-of-00005.safetensors",
|
| 146 |
+
"model.layers.2.input_layernorm.weight": "model-00001-of-00005.safetensors",
|
| 147 |
+
"model.layers.2.mlp.down_proj.weight": "model-00001-of-00005.safetensors",
|
| 148 |
+
"model.layers.2.mlp.gate_proj.weight": "model-00001-of-00005.safetensors",
|
| 149 |
+
"model.layers.2.mlp.up_proj.weight": "model-00001-of-00005.safetensors",
|
| 150 |
+
"model.layers.2.post_attention_layernorm.weight": "model-00001-of-00005.safetensors",
|
| 151 |
+
"model.layers.2.self_attn.k_norm.weight": "model-00001-of-00005.safetensors",
|
| 152 |
+
"model.layers.2.self_attn.k_proj.weight": "model-00001-of-00005.safetensors",
|
| 153 |
+
"model.layers.2.self_attn.o_proj.weight": "model-00001-of-00005.safetensors",
|
| 154 |
+
"model.layers.2.self_attn.q_norm.weight": "model-00001-of-00005.safetensors",
|
| 155 |
+
"model.layers.2.self_attn.q_proj.weight": "model-00001-of-00005.safetensors",
|
| 156 |
+
"model.layers.2.self_attn.v_proj.weight": "model-00001-of-00005.safetensors",
|
| 157 |
+
"model.layers.20.input_layernorm.weight": "model-00002-of-00005.safetensors",
|
| 158 |
+
"model.layers.20.mlp.down_proj.weight": "model-00002-of-00005.safetensors",
|
| 159 |
+
"model.layers.20.mlp.gate_proj.weight": "model-00002-of-00005.safetensors",
|
| 160 |
+
"model.layers.20.mlp.up_proj.weight": "model-00002-of-00005.safetensors",
|
| 161 |
+
"model.layers.20.post_attention_layernorm.weight": "model-00002-of-00005.safetensors",
|
| 162 |
+
"model.layers.20.self_attn.k_norm.weight": "model-00002-of-00005.safetensors",
|
| 163 |
+
"model.layers.20.self_attn.k_proj.weight": "model-00002-of-00005.safetensors",
|
| 164 |
+
"model.layers.20.self_attn.o_proj.weight": "model-00002-of-00005.safetensors",
|
| 165 |
+
"model.layers.20.self_attn.q_norm.weight": "model-00002-of-00005.safetensors",
|
| 166 |
+
"model.layers.20.self_attn.q_proj.weight": "model-00002-of-00005.safetensors",
|
| 167 |
+
"model.layers.20.self_attn.v_proj.weight": "model-00002-of-00005.safetensors",
|
| 168 |
+
"model.layers.21.input_layernorm.weight": "model-00002-of-00005.safetensors",
|
| 169 |
+
"model.layers.21.mlp.down_proj.weight": "model-00002-of-00005.safetensors",
|
| 170 |
+
"model.layers.21.mlp.gate_proj.weight": "model-00002-of-00005.safetensors",
|
| 171 |
+
"model.layers.21.mlp.up_proj.weight": "model-00002-of-00005.safetensors",
|
| 172 |
+
"model.layers.21.post_attention_layernorm.weight": "model-00002-of-00005.safetensors",
|
| 173 |
+
"model.layers.21.self_attn.k_norm.weight": "model-00002-of-00005.safetensors",
|
| 174 |
+
"model.layers.21.self_attn.k_proj.weight": "model-00002-of-00005.safetensors",
|
| 175 |
+
"model.layers.21.self_attn.o_proj.weight": "model-00002-of-00005.safetensors",
|
| 176 |
+
"model.layers.21.self_attn.q_norm.weight": "model-00002-of-00005.safetensors",
|
| 177 |
+
"model.layers.21.self_attn.q_proj.weight": "model-00002-of-00005.safetensors",
|
| 178 |
+
"model.layers.21.self_attn.v_proj.weight": "model-00002-of-00005.safetensors",
|
| 179 |
+
"model.layers.22.input_layernorm.weight": "model-00003-of-00005.safetensors",
|
| 180 |
+
"model.layers.22.mlp.down_proj.weight": "model-00003-of-00005.safetensors",
|
| 181 |
+
"model.layers.22.mlp.gate_proj.weight": "model-00003-of-00005.safetensors",
|
| 182 |
+
"model.layers.22.mlp.up_proj.weight": "model-00003-of-00005.safetensors",
|
| 183 |
+
"model.layers.22.post_attention_layernorm.weight": "model-00003-of-00005.safetensors",
|
| 184 |
+
"model.layers.22.self_attn.k_norm.weight": "model-00002-of-00005.safetensors",
|
| 185 |
+
"model.layers.22.self_attn.k_proj.weight": "model-00002-of-00005.safetensors",
|
| 186 |
+
"model.layers.22.self_attn.o_proj.weight": "model-00002-of-00005.safetensors",
|
| 187 |
+
"model.layers.22.self_attn.q_norm.weight": "model-00002-of-00005.safetensors",
|
| 188 |
+
"model.layers.22.self_attn.q_proj.weight": "model-00002-of-00005.safetensors",
|
| 189 |
+
"model.layers.22.self_attn.v_proj.weight": "model-00002-of-00005.safetensors",
|
| 190 |
+
"model.layers.23.input_layernorm.weight": "model-00003-of-00005.safetensors",
|
| 191 |
+
"model.layers.23.mlp.down_proj.weight": "model-00003-of-00005.safetensors",
|
| 192 |
+
"model.layers.23.mlp.gate_proj.weight": "model-00003-of-00005.safetensors",
|
| 193 |
+
"model.layers.23.mlp.up_proj.weight": "model-00003-of-00005.safetensors",
|
| 194 |
+
"model.layers.23.post_attention_layernorm.weight": "model-00003-of-00005.safetensors",
|
| 195 |
+
"model.layers.23.self_attn.k_norm.weight": "model-00003-of-00005.safetensors",
|
| 196 |
+
"model.layers.23.self_attn.k_proj.weight": "model-00003-of-00005.safetensors",
|
| 197 |
+
"model.layers.23.self_attn.o_proj.weight": "model-00003-of-00005.safetensors",
|
| 198 |
+
"model.layers.23.self_attn.q_norm.weight": "model-00003-of-00005.safetensors",
|
| 199 |
+
"model.layers.23.self_attn.q_proj.weight": "model-00003-of-00005.safetensors",
|
| 200 |
+
"model.layers.23.self_attn.v_proj.weight": "model-00003-of-00005.safetensors",
|
| 201 |
+
"model.layers.24.input_layernorm.weight": "model-00003-of-00005.safetensors",
|
| 202 |
+
"model.layers.24.mlp.down_proj.weight": "model-00003-of-00005.safetensors",
|
| 203 |
+
"model.layers.24.mlp.gate_proj.weight": "model-00003-of-00005.safetensors",
|
| 204 |
+
"model.layers.24.mlp.up_proj.weight": "model-00003-of-00005.safetensors",
|
| 205 |
+
"model.layers.24.post_attention_layernorm.weight": "model-00003-of-00005.safetensors",
|
| 206 |
+
"model.layers.24.self_attn.k_norm.weight": "model-00003-of-00005.safetensors",
|
| 207 |
+
"model.layers.24.self_attn.k_proj.weight": "model-00003-of-00005.safetensors",
|
| 208 |
+
"model.layers.24.self_attn.o_proj.weight": "model-00003-of-00005.safetensors",
|
| 209 |
+
"model.layers.24.self_attn.q_norm.weight": "model-00003-of-00005.safetensors",
|
| 210 |
+
"model.layers.24.self_attn.q_proj.weight": "model-00003-of-00005.safetensors",
|
| 211 |
+
"model.layers.24.self_attn.v_proj.weight": "model-00003-of-00005.safetensors",
|
| 212 |
+
"model.layers.25.input_layernorm.weight": "model-00003-of-00005.safetensors",
|
| 213 |
+
"model.layers.25.mlp.down_proj.weight": "model-00003-of-00005.safetensors",
|
| 214 |
+
"model.layers.25.mlp.gate_proj.weight": "model-00003-of-00005.safetensors",
|
| 215 |
+
"model.layers.25.mlp.up_proj.weight": "model-00003-of-00005.safetensors",
|
| 216 |
+
"model.layers.25.post_attention_layernorm.weight": "model-00003-of-00005.safetensors",
|
| 217 |
+
"model.layers.25.self_attn.k_norm.weight": "model-00003-of-00005.safetensors",
|
| 218 |
+
"model.layers.25.self_attn.k_proj.weight": "model-00003-of-00005.safetensors",
|
| 219 |
+
"model.layers.25.self_attn.o_proj.weight": "model-00003-of-00005.safetensors",
|
| 220 |
+
"model.layers.25.self_attn.q_norm.weight": "model-00003-of-00005.safetensors",
|
| 221 |
+
"model.layers.25.self_attn.q_proj.weight": "model-00003-of-00005.safetensors",
|
| 222 |
+
"model.layers.25.self_attn.v_proj.weight": "model-00003-of-00005.safetensors",
|
| 223 |
+
"model.layers.26.input_layernorm.weight": "model-00003-of-00005.safetensors",
|
| 224 |
+
"model.layers.26.mlp.down_proj.weight": "model-00003-of-00005.safetensors",
|
| 225 |
+
"model.layers.26.mlp.gate_proj.weight": "model-00003-of-00005.safetensors",
|
| 226 |
+
"model.layers.26.mlp.up_proj.weight": "model-00003-of-00005.safetensors",
|
| 227 |
+
"model.layers.26.post_attention_layernorm.weight": "model-00003-of-00005.safetensors",
|
| 228 |
+
"model.layers.26.self_attn.k_norm.weight": "model-00003-of-00005.safetensors",
|
| 229 |
+
"model.layers.26.self_attn.k_proj.weight": "model-00003-of-00005.safetensors",
|
| 230 |
+
"model.layers.26.self_attn.o_proj.weight": "model-00003-of-00005.safetensors",
|
| 231 |
+
"model.layers.26.self_attn.q_norm.weight": "model-00003-of-00005.safetensors",
|
| 232 |
+
"model.layers.26.self_attn.q_proj.weight": "model-00003-of-00005.safetensors",
|
| 233 |
+
"model.layers.26.self_attn.v_proj.weight": "model-00003-of-00005.safetensors",
|
| 234 |
+
"model.layers.27.input_layernorm.weight": "model-00003-of-00005.safetensors",
|
| 235 |
+
"model.layers.27.mlp.down_proj.weight": "model-00003-of-00005.safetensors",
|
| 236 |
+
"model.layers.27.mlp.gate_proj.weight": "model-00003-of-00005.safetensors",
|
| 237 |
+
"model.layers.27.mlp.up_proj.weight": "model-00003-of-00005.safetensors",
|
| 238 |
+
"model.layers.27.post_attention_layernorm.weight": "model-00003-of-00005.safetensors",
|
| 239 |
+
"model.layers.27.self_attn.k_norm.weight": "model-00003-of-00005.safetensors",
|
| 240 |
+
"model.layers.27.self_attn.k_proj.weight": "model-00003-of-00005.safetensors",
|
| 241 |
+
"model.layers.27.self_attn.o_proj.weight": "model-00003-of-00005.safetensors",
|
| 242 |
+
"model.layers.27.self_attn.q_norm.weight": "model-00003-of-00005.safetensors",
|
| 243 |
+
"model.layers.27.self_attn.q_proj.weight": "model-00003-of-00005.safetensors",
|
| 244 |
+
"model.layers.27.self_attn.v_proj.weight": "model-00003-of-00005.safetensors",
|
| 245 |
+
"model.layers.28.input_layernorm.weight": "model-00003-of-00005.safetensors",
|
| 246 |
+
"model.layers.28.mlp.down_proj.weight": "model-00003-of-00005.safetensors",
|
| 247 |
+
"model.layers.28.mlp.gate_proj.weight": "model-00003-of-00005.safetensors",
|
| 248 |
+
"model.layers.28.mlp.up_proj.weight": "model-00003-of-00005.safetensors",
|
| 249 |
+
"model.layers.28.post_attention_layernorm.weight": "model-00003-of-00005.safetensors",
|
| 250 |
+
"model.layers.28.self_attn.k_norm.weight": "model-00003-of-00005.safetensors",
|
| 251 |
+
"model.layers.28.self_attn.k_proj.weight": "model-00003-of-00005.safetensors",
|
| 252 |
+
"model.layers.28.self_attn.o_proj.weight": "model-00003-of-00005.safetensors",
|
| 253 |
+
"model.layers.28.self_attn.q_norm.weight": "model-00003-of-00005.safetensors",
|
| 254 |
+
"model.layers.28.self_attn.q_proj.weight": "model-00003-of-00005.safetensors",
|
| 255 |
+
"model.layers.28.self_attn.v_proj.weight": "model-00003-of-00005.safetensors",
|
| 256 |
+
"model.layers.29.input_layernorm.weight": "model-00003-of-00005.safetensors",
|
| 257 |
+
"model.layers.29.mlp.down_proj.weight": "model-00003-of-00005.safetensors",
|
| 258 |
+
"model.layers.29.mlp.gate_proj.weight": "model-00003-of-00005.safetensors",
|
| 259 |
+
"model.layers.29.mlp.up_proj.weight": "model-00003-of-00005.safetensors",
|
| 260 |
+
"model.layers.29.post_attention_layernorm.weight": "model-00003-of-00005.safetensors",
|
| 261 |
+
"model.layers.29.self_attn.k_norm.weight": "model-00003-of-00005.safetensors",
|
| 262 |
+
"model.layers.29.self_attn.k_proj.weight": "model-00003-of-00005.safetensors",
|
| 263 |
+
"model.layers.29.self_attn.o_proj.weight": "model-00003-of-00005.safetensors",
|
| 264 |
+
"model.layers.29.self_attn.q_norm.weight": "model-00003-of-00005.safetensors",
|
| 265 |
+
"model.layers.29.self_attn.q_proj.weight": "model-00003-of-00005.safetensors",
|
| 266 |
+
"model.layers.29.self_attn.v_proj.weight": "model-00003-of-00005.safetensors",
|
| 267 |
+
"model.layers.3.input_layernorm.weight": "model-00001-of-00005.safetensors",
|
| 268 |
+
"model.layers.3.mlp.down_proj.weight": "model-00001-of-00005.safetensors",
|
| 269 |
+
"model.layers.3.mlp.gate_proj.weight": "model-00001-of-00005.safetensors",
|
| 270 |
+
"model.layers.3.mlp.up_proj.weight": "model-00001-of-00005.safetensors",
|
| 271 |
+
"model.layers.3.post_attention_layernorm.weight": "model-00001-of-00005.safetensors",
|
| 272 |
+
"model.layers.3.self_attn.k_norm.weight": "model-00001-of-00005.safetensors",
|
| 273 |
+
"model.layers.3.self_attn.k_proj.weight": "model-00001-of-00005.safetensors",
|
| 274 |
+
"model.layers.3.self_attn.o_proj.weight": "model-00001-of-00005.safetensors",
|
| 275 |
+
"model.layers.3.self_attn.q_norm.weight": "model-00001-of-00005.safetensors",
|
| 276 |
+
"model.layers.3.self_attn.q_proj.weight": "model-00001-of-00005.safetensors",
|
| 277 |
+
"model.layers.3.self_attn.v_proj.weight": "model-00001-of-00005.safetensors",
|
| 278 |
+
"model.layers.30.input_layernorm.weight": "model-00003-of-00005.safetensors",
|
| 279 |
+
"model.layers.30.mlp.down_proj.weight": "model-00003-of-00005.safetensors",
|
| 280 |
+
"model.layers.30.mlp.gate_proj.weight": "model-00003-of-00005.safetensors",
|
| 281 |
+
"model.layers.30.mlp.up_proj.weight": "model-00003-of-00005.safetensors",
|
| 282 |
+
"model.layers.30.post_attention_layernorm.weight": "model-00003-of-00005.safetensors",
|
| 283 |
+
"model.layers.30.self_attn.k_norm.weight": "model-00003-of-00005.safetensors",
|
| 284 |
+
"model.layers.30.self_attn.k_proj.weight": "model-00003-of-00005.safetensors",
|
| 285 |
+
"model.layers.30.self_attn.o_proj.weight": "model-00003-of-00005.safetensors",
|
| 286 |
+
"model.layers.30.self_attn.q_norm.weight": "model-00003-of-00005.safetensors",
|
| 287 |
+
"model.layers.30.self_attn.q_proj.weight": "model-00003-of-00005.safetensors",
|
| 288 |
+
"model.layers.30.self_attn.v_proj.weight": "model-00003-of-00005.safetensors",
|
| 289 |
+
"model.layers.31.input_layernorm.weight": "model-00003-of-00005.safetensors",
|
| 290 |
+
"model.layers.31.mlp.down_proj.weight": "model-00003-of-00005.safetensors",
|
| 291 |
+
"model.layers.31.mlp.gate_proj.weight": "model-00003-of-00005.safetensors",
|
| 292 |
+
"model.layers.31.mlp.up_proj.weight": "model-00003-of-00005.safetensors",
|
| 293 |
+
"model.layers.31.post_attention_layernorm.weight": "model-00003-of-00005.safetensors",
|
| 294 |
+
"model.layers.31.self_attn.k_norm.weight": "model-00003-of-00005.safetensors",
|
| 295 |
+
"model.layers.31.self_attn.k_proj.weight": "model-00003-of-00005.safetensors",
|
| 296 |
+
"model.layers.31.self_attn.o_proj.weight": "model-00003-of-00005.safetensors",
|
| 297 |
+
"model.layers.31.self_attn.q_norm.weight": "model-00003-of-00005.safetensors",
|
| 298 |
+
"model.layers.31.self_attn.q_proj.weight": "model-00003-of-00005.safetensors",
|
| 299 |
+
"model.layers.31.self_attn.v_proj.weight": "model-00003-of-00005.safetensors",
|
| 300 |
+
"model.layers.32.input_layernorm.weight": "model-00003-of-00005.safetensors",
|
| 301 |
+
"model.layers.32.mlp.down_proj.weight": "model-00003-of-00005.safetensors",
|
| 302 |
+
"model.layers.32.mlp.gate_proj.weight": "model-00003-of-00005.safetensors",
|
| 303 |
+
"model.layers.32.mlp.up_proj.weight": "model-00003-of-00005.safetensors",
|
| 304 |
+
"model.layers.32.post_attention_layernorm.weight": "model-00003-of-00005.safetensors",
|
| 305 |
+
"model.layers.32.self_attn.k_norm.weight": "model-00003-of-00005.safetensors",
|
| 306 |
+
"model.layers.32.self_attn.k_proj.weight": "model-00003-of-00005.safetensors",
|
| 307 |
+
"model.layers.32.self_attn.o_proj.weight": "model-00003-of-00005.safetensors",
|
| 308 |
+
"model.layers.32.self_attn.q_norm.weight": "model-00003-of-00005.safetensors",
|
| 309 |
+
"model.layers.32.self_attn.q_proj.weight": "model-00003-of-00005.safetensors",
|
| 310 |
+
"model.layers.32.self_attn.v_proj.weight": "model-00003-of-00005.safetensors",
|
| 311 |
+
"model.layers.33.input_layernorm.weight": "model-00003-of-00005.safetensors",
|
| 312 |
+
"model.layers.33.mlp.down_proj.weight": "model-00003-of-00005.safetensors",
|
| 313 |
+
"model.layers.33.mlp.gate_proj.weight": "model-00003-of-00005.safetensors",
|
| 314 |
+
"model.layers.33.mlp.up_proj.weight": "model-00003-of-00005.safetensors",
|
| 315 |
+
"model.layers.33.post_attention_layernorm.weight": "model-00003-of-00005.safetensors",
|
| 316 |
+
"model.layers.33.self_attn.k_norm.weight": "model-00003-of-00005.safetensors",
|
| 317 |
+
"model.layers.33.self_attn.k_proj.weight": "model-00003-of-00005.safetensors",
|
| 318 |
+
"model.layers.33.self_attn.o_proj.weight": "model-00003-of-00005.safetensors",
|
| 319 |
+
"model.layers.33.self_attn.q_norm.weight": "model-00003-of-00005.safetensors",
|
| 320 |
+
"model.layers.33.self_attn.q_proj.weight": "model-00003-of-00005.safetensors",
|
| 321 |
+
"model.layers.33.self_attn.v_proj.weight": "model-00003-of-00005.safetensors",
|
| 322 |
+
"model.layers.34.input_layernorm.weight": "model-00003-of-00005.safetensors",
|
| 323 |
+
"model.layers.34.mlp.down_proj.weight": "model-00003-of-00005.safetensors",
|
| 324 |
+
"model.layers.34.mlp.gate_proj.weight": "model-00003-of-00005.safetensors",
|
| 325 |
+
"model.layers.34.mlp.up_proj.weight": "model-00003-of-00005.safetensors",
|
| 326 |
+
"model.layers.34.post_attention_layernorm.weight": "model-00003-of-00005.safetensors",
|
| 327 |
+
"model.layers.34.self_attn.k_norm.weight": "model-00003-of-00005.safetensors",
|
| 328 |
+
"model.layers.34.self_attn.k_proj.weight": "model-00003-of-00005.safetensors",
|
| 329 |
+
"model.layers.34.self_attn.o_proj.weight": "model-00003-of-00005.safetensors",
|
| 330 |
+
"model.layers.34.self_attn.q_norm.weight": "model-00003-of-00005.safetensors",
|
| 331 |
+
"model.layers.34.self_attn.q_proj.weight": "model-00003-of-00005.safetensors",
|
| 332 |
+
"model.layers.34.self_attn.v_proj.weight": "model-00003-of-00005.safetensors",
|
| 333 |
+
"model.layers.35.input_layernorm.weight": "model-00004-of-00005.safetensors",
|
| 334 |
+
"model.layers.35.mlp.down_proj.weight": "model-00004-of-00005.safetensors",
|
| 335 |
+
"model.layers.35.mlp.gate_proj.weight": "model-00004-of-00005.safetensors",
|
| 336 |
+
"model.layers.35.mlp.up_proj.weight": "model-00004-of-00005.safetensors",
|
| 337 |
+
"model.layers.35.post_attention_layernorm.weight": "model-00004-of-00005.safetensors",
|
| 338 |
+
"model.layers.35.self_attn.k_norm.weight": "model-00004-of-00005.safetensors",
|
| 339 |
+
"model.layers.35.self_attn.k_proj.weight": "model-00003-of-00005.safetensors",
|
| 340 |
+
"model.layers.35.self_attn.o_proj.weight": "model-00004-of-00005.safetensors",
|
| 341 |
+
"model.layers.35.self_attn.q_norm.weight": "model-00004-of-00005.safetensors",
|
| 342 |
+
"model.layers.35.self_attn.q_proj.weight": "model-00003-of-00005.safetensors",
|
| 343 |
+
"model.layers.35.self_attn.v_proj.weight": "model-00003-of-00005.safetensors",
|
| 344 |
+
"model.layers.36.input_layernorm.weight": "model-00004-of-00005.safetensors",
|
| 345 |
+
"model.layers.36.mlp.down_proj.weight": "model-00004-of-00005.safetensors",
|
| 346 |
+
"model.layers.36.mlp.gate_proj.weight": "model-00004-of-00005.safetensors",
|
| 347 |
+
"model.layers.36.mlp.up_proj.weight": "model-00004-of-00005.safetensors",
|
| 348 |
+
"model.layers.36.post_attention_layernorm.weight": "model-00004-of-00005.safetensors",
|
| 349 |
+
"model.layers.36.self_attn.k_norm.weight": "model-00004-of-00005.safetensors",
|
| 350 |
+
"model.layers.36.self_attn.k_proj.weight": "model-00004-of-00005.safetensors",
|
| 351 |
+
"model.layers.36.self_attn.o_proj.weight": "model-00004-of-00005.safetensors",
|
| 352 |
+
"model.layers.36.self_attn.q_norm.weight": "model-00004-of-00005.safetensors",
|
| 353 |
+
"model.layers.36.self_attn.q_proj.weight": "model-00004-of-00005.safetensors",
|
| 354 |
+
"model.layers.36.self_attn.v_proj.weight": "model-00004-of-00005.safetensors",
|
| 355 |
+
"model.layers.37.input_layernorm.weight": "model-00004-of-00005.safetensors",
|
| 356 |
+
"model.layers.37.mlp.down_proj.weight": "model-00004-of-00005.safetensors",
|
| 357 |
+
"model.layers.37.mlp.gate_proj.weight": "model-00004-of-00005.safetensors",
|
| 358 |
+
"model.layers.37.mlp.up_proj.weight": "model-00004-of-00005.safetensors",
|
| 359 |
+
"model.layers.37.post_attention_layernorm.weight": "model-00004-of-00005.safetensors",
|
| 360 |
+
"model.layers.37.self_attn.k_norm.weight": "model-00004-of-00005.safetensors",
|
| 361 |
+
"model.layers.37.self_attn.k_proj.weight": "model-00004-of-00005.safetensors",
|
| 362 |
+
"model.layers.37.self_attn.o_proj.weight": "model-00004-of-00005.safetensors",
|
| 363 |
+
"model.layers.37.self_attn.q_norm.weight": "model-00004-of-00005.safetensors",
|
| 364 |
+
"model.layers.37.self_attn.q_proj.weight": "model-00004-of-00005.safetensors",
|
| 365 |
+
"model.layers.37.self_attn.v_proj.weight": "model-00004-of-00005.safetensors",
|
| 366 |
+
"model.layers.38.input_layernorm.weight": "model-00004-of-00005.safetensors",
|
| 367 |
+
"model.layers.38.mlp.down_proj.weight": "model-00004-of-00005.safetensors",
|
| 368 |
+
"model.layers.38.mlp.gate_proj.weight": "model-00004-of-00005.safetensors",
|
| 369 |
+
"model.layers.38.mlp.up_proj.weight": "model-00004-of-00005.safetensors",
|
| 370 |
+
"model.layers.38.post_attention_layernorm.weight": "model-00004-of-00005.safetensors",
|
| 371 |
+
"model.layers.38.self_attn.k_norm.weight": "model-00004-of-00005.safetensors",
|
| 372 |
+
"model.layers.38.self_attn.k_proj.weight": "model-00004-of-00005.safetensors",
|
| 373 |
+
"model.layers.38.self_attn.o_proj.weight": "model-00004-of-00005.safetensors",
|
| 374 |
+
"model.layers.38.self_attn.q_norm.weight": "model-00004-of-00005.safetensors",
|
| 375 |
+
"model.layers.38.self_attn.q_proj.weight": "model-00004-of-00005.safetensors",
|
| 376 |
+
"model.layers.38.self_attn.v_proj.weight": "model-00004-of-00005.safetensors",
|
| 377 |
+
"model.layers.39.input_layernorm.weight": "model-00004-of-00005.safetensors",
|
| 378 |
+
"model.layers.39.mlp.down_proj.weight": "model-00004-of-00005.safetensors",
|
| 379 |
+
"model.layers.39.mlp.gate_proj.weight": "model-00004-of-00005.safetensors",
|
| 380 |
+
"model.layers.39.mlp.up_proj.weight": "model-00004-of-00005.safetensors",
|
| 381 |
+
"model.layers.39.post_attention_layernorm.weight": "model-00004-of-00005.safetensors",
|
| 382 |
+
"model.layers.39.self_attn.k_norm.weight": "model-00004-of-00005.safetensors",
|
| 383 |
+
"model.layers.39.self_attn.k_proj.weight": "model-00004-of-00005.safetensors",
|
| 384 |
+
"model.layers.39.self_attn.o_proj.weight": "model-00004-of-00005.safetensors",
|
| 385 |
+
"model.layers.39.self_attn.q_norm.weight": "model-00004-of-00005.safetensors",
|
| 386 |
+
"model.layers.39.self_attn.q_proj.weight": "model-00004-of-00005.safetensors",
|
| 387 |
+
"model.layers.39.self_attn.v_proj.weight": "model-00004-of-00005.safetensors",
|
| 388 |
+
"model.layers.4.input_layernorm.weight": "model-00001-of-00005.safetensors",
|
| 389 |
+
"model.layers.4.mlp.down_proj.weight": "model-00001-of-00005.safetensors",
|
| 390 |
+
"model.layers.4.mlp.gate_proj.weight": "model-00001-of-00005.safetensors",
|
| 391 |
+
"model.layers.4.mlp.up_proj.weight": "model-00001-of-00005.safetensors",
|
| 392 |
+
"model.layers.4.post_attention_layernorm.weight": "model-00001-of-00005.safetensors",
|
| 393 |
+
"model.layers.4.self_attn.k_norm.weight": "model-00001-of-00005.safetensors",
|
| 394 |
+
"model.layers.4.self_attn.k_proj.weight": "model-00001-of-00005.safetensors",
|
| 395 |
+
"model.layers.4.self_attn.o_proj.weight": "model-00001-of-00005.safetensors",
|
| 396 |
+
"model.layers.4.self_attn.q_norm.weight": "model-00001-of-00005.safetensors",
|
| 397 |
+
"model.layers.4.self_attn.q_proj.weight": "model-00001-of-00005.safetensors",
|
| 398 |
+
"model.layers.4.self_attn.v_proj.weight": "model-00001-of-00005.safetensors",
|
| 399 |
+
"model.layers.40.input_layernorm.weight": "model-00004-of-00005.safetensors",
|
| 400 |
+
"model.layers.40.mlp.down_proj.weight": "model-00004-of-00005.safetensors",
|
| 401 |
+
"model.layers.40.mlp.gate_proj.weight": "model-00004-of-00005.safetensors",
|
| 402 |
+
"model.layers.40.mlp.up_proj.weight": "model-00004-of-00005.safetensors",
|
| 403 |
+
"model.layers.40.post_attention_layernorm.weight": "model-00004-of-00005.safetensors",
|
| 404 |
+
"model.layers.40.self_attn.k_norm.weight": "model-00004-of-00005.safetensors",
|
| 405 |
+
"model.layers.40.self_attn.k_proj.weight": "model-00004-of-00005.safetensors",
|
| 406 |
+
"model.layers.40.self_attn.o_proj.weight": "model-00004-of-00005.safetensors",
|
| 407 |
+
"model.layers.40.self_attn.q_norm.weight": "model-00004-of-00005.safetensors",
|
| 408 |
+
"model.layers.40.self_attn.q_proj.weight": "model-00004-of-00005.safetensors",
|
| 409 |
+
"model.layers.40.self_attn.v_proj.weight": "model-00004-of-00005.safetensors",
|
| 410 |
+
"model.layers.41.input_layernorm.weight": "model-00004-of-00005.safetensors",
|
| 411 |
+
"model.layers.41.mlp.down_proj.weight": "model-00004-of-00005.safetensors",
|
| 412 |
+
"model.layers.41.mlp.gate_proj.weight": "model-00004-of-00005.safetensors",
|
| 413 |
+
"model.layers.41.mlp.up_proj.weight": "model-00004-of-00005.safetensors",
|
| 414 |
+
"model.layers.41.post_attention_layernorm.weight": "model-00004-of-00005.safetensors",
|
| 415 |
+
"model.layers.41.self_attn.k_norm.weight": "model-00004-of-00005.safetensors",
|
| 416 |
+
"model.layers.41.self_attn.k_proj.weight": "model-00004-of-00005.safetensors",
|
| 417 |
+
"model.layers.41.self_attn.o_proj.weight": "model-00004-of-00005.safetensors",
|
| 418 |
+
"model.layers.41.self_attn.q_norm.weight": "model-00004-of-00005.safetensors",
|
| 419 |
+
"model.layers.41.self_attn.q_proj.weight": "model-00004-of-00005.safetensors",
|
| 420 |
+
"model.layers.41.self_attn.v_proj.weight": "model-00004-of-00005.safetensors",
|
| 421 |
+
"model.layers.42.input_layernorm.weight": "model-00004-of-00005.safetensors",
|
| 422 |
+
"model.layers.42.mlp.down_proj.weight": "model-00004-of-00005.safetensors",
|
| 423 |
+
"model.layers.42.mlp.gate_proj.weight": "model-00004-of-00005.safetensors",
|
| 424 |
+
"model.layers.42.mlp.up_proj.weight": "model-00004-of-00005.safetensors",
|
| 425 |
+
"model.layers.42.post_attention_layernorm.weight": "model-00004-of-00005.safetensors",
|
| 426 |
+
"model.layers.42.self_attn.k_norm.weight": "model-00004-of-00005.safetensors",
|
| 427 |
+
"model.layers.42.self_attn.k_proj.weight": "model-00004-of-00005.safetensors",
|
| 428 |
+
"model.layers.42.self_attn.o_proj.weight": "model-00004-of-00005.safetensors",
|
| 429 |
+
"model.layers.42.self_attn.q_norm.weight": "model-00004-of-00005.safetensors",
|
| 430 |
+
"model.layers.42.self_attn.q_proj.weight": "model-00004-of-00005.safetensors",
|
| 431 |
+
"model.layers.42.self_attn.v_proj.weight": "model-00004-of-00005.safetensors",
|
| 432 |
+
"model.layers.43.input_layernorm.weight": "model-00004-of-00005.safetensors",
|
| 433 |
+
"model.layers.43.mlp.down_proj.weight": "model-00004-of-00005.safetensors",
|
| 434 |
+
"model.layers.43.mlp.gate_proj.weight": "model-00004-of-00005.safetensors",
|
| 435 |
+
"model.layers.43.mlp.up_proj.weight": "model-00004-of-00005.safetensors",
|
| 436 |
+
"model.layers.43.post_attention_layernorm.weight": "model-00004-of-00005.safetensors",
|
| 437 |
+
"model.layers.43.self_attn.k_norm.weight": "model-00004-of-00005.safetensors",
|
| 438 |
+
"model.layers.43.self_attn.k_proj.weight": "model-00004-of-00005.safetensors",
|
| 439 |
+
"model.layers.43.self_attn.o_proj.weight": "model-00004-of-00005.safetensors",
|
| 440 |
+
"model.layers.43.self_attn.q_norm.weight": "model-00004-of-00005.safetensors",
|
| 441 |
+
"model.layers.43.self_attn.q_proj.weight": "model-00004-of-00005.safetensors",
|
| 442 |
+
"model.layers.43.self_attn.v_proj.weight": "model-00004-of-00005.safetensors",
|
| 443 |
+
"model.layers.44.input_layernorm.weight": "model-00004-of-00005.safetensors",
|
| 444 |
+
"model.layers.44.mlp.down_proj.weight": "model-00004-of-00005.safetensors",
|
| 445 |
+
"model.layers.44.mlp.gate_proj.weight": "model-00004-of-00005.safetensors",
|
| 446 |
+
"model.layers.44.mlp.up_proj.weight": "model-00004-of-00005.safetensors",
|
| 447 |
+
"model.layers.44.post_attention_layernorm.weight": "model-00004-of-00005.safetensors",
|
| 448 |
+
"model.layers.44.self_attn.k_norm.weight": "model-00004-of-00005.safetensors",
|
| 449 |
+
"model.layers.44.self_attn.k_proj.weight": "model-00004-of-00005.safetensors",
|
| 450 |
+
"model.layers.44.self_attn.o_proj.weight": "model-00004-of-00005.safetensors",
|
| 451 |
+
"model.layers.44.self_attn.q_norm.weight": "model-00004-of-00005.safetensors",
|
| 452 |
+
"model.layers.44.self_attn.q_proj.weight": "model-00004-of-00005.safetensors",
|
| 453 |
+
"model.layers.44.self_attn.v_proj.weight": "model-00004-of-00005.safetensors",
|
| 454 |
+
"model.layers.45.input_layernorm.weight": "model-00004-of-00005.safetensors",
|
| 455 |
+
"model.layers.45.mlp.down_proj.weight": "model-00004-of-00005.safetensors",
|
| 456 |
+
"model.layers.45.mlp.gate_proj.weight": "model-00004-of-00005.safetensors",
|
| 457 |
+
"model.layers.45.mlp.up_proj.weight": "model-00004-of-00005.safetensors",
|
| 458 |
+
"model.layers.45.post_attention_layernorm.weight": "model-00004-of-00005.safetensors",
|
| 459 |
+
"model.layers.45.self_attn.k_norm.weight": "model-00004-of-00005.safetensors",
|
| 460 |
+
"model.layers.45.self_attn.k_proj.weight": "model-00004-of-00005.safetensors",
|
| 461 |
+
"model.layers.45.self_attn.o_proj.weight": "model-00004-of-00005.safetensors",
|
| 462 |
+
"model.layers.45.self_attn.q_norm.weight": "model-00004-of-00005.safetensors",
|
| 463 |
+
"model.layers.45.self_attn.q_proj.weight": "model-00004-of-00005.safetensors",
|
| 464 |
+
"model.layers.45.self_attn.v_proj.weight": "model-00004-of-00005.safetensors",
|
| 465 |
+
"model.layers.46.input_layernorm.weight": "model-00004-of-00005.safetensors",
|
| 466 |
+
"model.layers.46.mlp.down_proj.weight": "model-00004-of-00005.safetensors",
|
| 467 |
+
"model.layers.46.mlp.gate_proj.weight": "model-00004-of-00005.safetensors",
|
| 468 |
+
"model.layers.46.mlp.up_proj.weight": "model-00004-of-00005.safetensors",
|
| 469 |
+
"model.layers.46.post_attention_layernorm.weight": "model-00004-of-00005.safetensors",
|
| 470 |
+
"model.layers.46.self_attn.k_norm.weight": "model-00004-of-00005.safetensors",
|
| 471 |
+
"model.layers.46.self_attn.k_proj.weight": "model-00004-of-00005.safetensors",
|
| 472 |
+
"model.layers.46.self_attn.o_proj.weight": "model-00004-of-00005.safetensors",
|
| 473 |
+
"model.layers.46.self_attn.q_norm.weight": "model-00004-of-00005.safetensors",
|
| 474 |
+
"model.layers.46.self_attn.q_proj.weight": "model-00004-of-00005.safetensors",
|
| 475 |
+
"model.layers.46.self_attn.v_proj.weight": "model-00004-of-00005.safetensors",
|
| 476 |
+
"model.layers.47.input_layernorm.weight": "model-00004-of-00005.safetensors",
|
| 477 |
+
"model.layers.47.mlp.down_proj.weight": "model-00004-of-00005.safetensors",
|
| 478 |
+
"model.layers.47.mlp.gate_proj.weight": "model-00004-of-00005.safetensors",
|
| 479 |
+
"model.layers.47.mlp.up_proj.weight": "model-00004-of-00005.safetensors",
|
| 480 |
+
"model.layers.47.post_attention_layernorm.weight": "model-00004-of-00005.safetensors",
|
| 481 |
+
"model.layers.47.self_attn.k_norm.weight": "model-00004-of-00005.safetensors",
|
| 482 |
+
"model.layers.47.self_attn.k_proj.weight": "model-00004-of-00005.safetensors",
|
| 483 |
+
"model.layers.47.self_attn.o_proj.weight": "model-00004-of-00005.safetensors",
|
| 484 |
+
"model.layers.47.self_attn.q_norm.weight": "model-00004-of-00005.safetensors",
|
| 485 |
+
"model.layers.47.self_attn.q_proj.weight": "model-00004-of-00005.safetensors",
|
| 486 |
+
"model.layers.47.self_attn.v_proj.weight": "model-00004-of-00005.safetensors",
|
| 487 |
+
"model.layers.5.input_layernorm.weight": "model-00001-of-00005.safetensors",
|
| 488 |
+
"model.layers.5.mlp.down_proj.weight": "model-00001-of-00005.safetensors",
|
| 489 |
+
"model.layers.5.mlp.gate_proj.weight": "model-00001-of-00005.safetensors",
|
| 490 |
+
"model.layers.5.mlp.up_proj.weight": "model-00001-of-00005.safetensors",
|
| 491 |
+
"model.layers.5.post_attention_layernorm.weight": "model-00001-of-00005.safetensors",
|
| 492 |
+
"model.layers.5.self_attn.k_norm.weight": "model-00001-of-00005.safetensors",
|
| 493 |
+
"model.layers.5.self_attn.k_proj.weight": "model-00001-of-00005.safetensors",
|
| 494 |
+
"model.layers.5.self_attn.o_proj.weight": "model-00001-of-00005.safetensors",
|
| 495 |
+
"model.layers.5.self_attn.q_norm.weight": "model-00001-of-00005.safetensors",
|
| 496 |
+
"model.layers.5.self_attn.q_proj.weight": "model-00001-of-00005.safetensors",
|
| 497 |
+
"model.layers.5.self_attn.v_proj.weight": "model-00001-of-00005.safetensors",
|
| 498 |
+
"model.layers.6.input_layernorm.weight": "model-00001-of-00005.safetensors",
|
| 499 |
+
"model.layers.6.mlp.down_proj.weight": "model-00001-of-00005.safetensors",
|
| 500 |
+
"model.layers.6.mlp.gate_proj.weight": "model-00001-of-00005.safetensors",
|
| 501 |
+
"model.layers.6.mlp.up_proj.weight": "model-00001-of-00005.safetensors",
|
| 502 |
+
"model.layers.6.post_attention_layernorm.weight": "model-00001-of-00005.safetensors",
|
| 503 |
+
"model.layers.6.self_attn.k_norm.weight": "model-00001-of-00005.safetensors",
|
| 504 |
+
"model.layers.6.self_attn.k_proj.weight": "model-00001-of-00005.safetensors",
|
| 505 |
+
"model.layers.6.self_attn.o_proj.weight": "model-00001-of-00005.safetensors",
|
| 506 |
+
"model.layers.6.self_attn.q_norm.weight": "model-00001-of-00005.safetensors",
|
| 507 |
+
"model.layers.6.self_attn.q_proj.weight": "model-00001-of-00005.safetensors",
|
| 508 |
+
"model.layers.6.self_attn.v_proj.weight": "model-00001-of-00005.safetensors",
|
| 509 |
+
"model.layers.7.input_layernorm.weight": "model-00001-of-00005.safetensors",
|
| 510 |
+
"model.layers.7.mlp.down_proj.weight": "model-00001-of-00005.safetensors",
|
| 511 |
+
"model.layers.7.mlp.gate_proj.weight": "model-00001-of-00005.safetensors",
|
| 512 |
+
"model.layers.7.mlp.up_proj.weight": "model-00001-of-00005.safetensors",
|
| 513 |
+
"model.layers.7.post_attention_layernorm.weight": "model-00001-of-00005.safetensors",
|
| 514 |
+
"model.layers.7.self_attn.k_norm.weight": "model-00001-of-00005.safetensors",
|
| 515 |
+
"model.layers.7.self_attn.k_proj.weight": "model-00001-of-00005.safetensors",
|
| 516 |
+
"model.layers.7.self_attn.o_proj.weight": "model-00001-of-00005.safetensors",
|
| 517 |
+
"model.layers.7.self_attn.q_norm.weight": "model-00001-of-00005.safetensors",
|
| 518 |
+
"model.layers.7.self_attn.q_proj.weight": "model-00001-of-00005.safetensors",
|
| 519 |
+
"model.layers.7.self_attn.v_proj.weight": "model-00001-of-00005.safetensors",
|
| 520 |
+
"model.layers.8.input_layernorm.weight": "model-00001-of-00005.safetensors",
|
| 521 |
+
"model.layers.8.mlp.down_proj.weight": "model-00001-of-00005.safetensors",
|
| 522 |
+
"model.layers.8.mlp.gate_proj.weight": "model-00001-of-00005.safetensors",
|
| 523 |
+
"model.layers.8.mlp.up_proj.weight": "model-00001-of-00005.safetensors",
|
| 524 |
+
"model.layers.8.post_attention_layernorm.weight": "model-00001-of-00005.safetensors",
|
| 525 |
+
"model.layers.8.self_attn.k_norm.weight": "model-00001-of-00005.safetensors",
|
| 526 |
+
"model.layers.8.self_attn.k_proj.weight": "model-00001-of-00005.safetensors",
|
| 527 |
+
"model.layers.8.self_attn.o_proj.weight": "model-00001-of-00005.safetensors",
|
| 528 |
+
"model.layers.8.self_attn.q_norm.weight": "model-00001-of-00005.safetensors",
|
| 529 |
+
"model.layers.8.self_attn.q_proj.weight": "model-00001-of-00005.safetensors",
|
| 530 |
+
"model.layers.8.self_attn.v_proj.weight": "model-00001-of-00005.safetensors",
|
| 531 |
+
"model.layers.9.input_layernorm.weight": "model-00002-of-00005.safetensors",
|
| 532 |
+
"model.layers.9.mlp.down_proj.weight": "model-00002-of-00005.safetensors",
|
| 533 |
+
"model.layers.9.mlp.gate_proj.weight": "model-00001-of-00005.safetensors",
|
| 534 |
+
"model.layers.9.mlp.up_proj.weight": "model-00002-of-00005.safetensors",
|
| 535 |
+
"model.layers.9.post_attention_layernorm.weight": "model-00002-of-00005.safetensors",
|
| 536 |
+
"model.layers.9.self_attn.k_norm.weight": "model-00001-of-00005.safetensors",
|
| 537 |
+
"model.layers.9.self_attn.k_proj.weight": "model-00001-of-00005.safetensors",
|
| 538 |
+
"model.layers.9.self_attn.o_proj.weight": "model-00001-of-00005.safetensors",
|
| 539 |
+
"model.layers.9.self_attn.q_norm.weight": "model-00001-of-00005.safetensors",
|
| 540 |
+
"model.layers.9.self_attn.q_proj.weight": "model-00001-of-00005.safetensors",
|
| 541 |
+
"model.layers.9.self_attn.v_proj.weight": "model-00001-of-00005.safetensors",
|
| 542 |
+
"model.norm.weight": "model-00004-of-00005.safetensors"
|
| 543 |
+
}
|
| 544 |
+
}
|
modeling_wedlm.py
ADDED
|
@@ -0,0 +1,1413 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# coding=utf-8
|
| 2 |
+
# Copyright 2024 The WeDLM team and the HuggingFace Inc. team. All rights reserved.
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
"""PyTorch WeDLM model."""
|
| 16 |
+
|
| 17 |
+
from typing import Optional, Tuple, Union, Dict, List, Callable
|
| 18 |
+
|
| 19 |
+
import math
|
| 20 |
+
|
| 21 |
+
import torch
|
| 22 |
+
from torch import nn
|
| 23 |
+
import torch.nn.functional as F
|
| 24 |
+
|
| 25 |
+
from transformers import PreTrainedModel, GenerationMixin
|
| 26 |
+
from transformers.activations import ACT2FN
|
| 27 |
+
from transformers.cache_utils import Cache, DynamicCache
|
| 28 |
+
from transformers.modeling_outputs import BaseModelOutputWithPast, CausalLMOutputWithPast
|
| 29 |
+
from transformers.processing_utils import Unpack
|
| 30 |
+
from transformers.utils import TransformersKwargs, auto_docstring, can_return_tuple
|
| 31 |
+
from transformers.utils.generic import check_model_inputs
|
| 32 |
+
from transformers.masking_utils import create_causal_mask, create_sliding_window_causal_mask
|
| 33 |
+
from transformers.modeling_layers import GradientCheckpointingLayer
|
| 34 |
+
from transformers.modeling_rope_utils import ROPE_INIT_FUNCTIONS
|
| 35 |
+
from transformers.modeling_utils import ALL_ATTENTION_FUNCTIONS
|
| 36 |
+
# Import attention-related utilities
|
| 37 |
+
try:
|
| 38 |
+
from transformers.modeling_flash_attention_utils import FlashAttentionKwargs
|
| 39 |
+
except ImportError:
|
| 40 |
+
FlashAttentionKwargs = dict
|
| 41 |
+
|
| 42 |
+
from .configuration_wedlm import WeDLMConfig
|
| 43 |
+
|
| 44 |
+
import logging
|
| 45 |
+
|
| 46 |
+
logger = logging.getLogger(__name__)
|
| 47 |
+
logger.setLevel(logging.DEBUG)
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
# ============================================================================
|
| 51 |
+
# Flow Matching / Rectified Flow helpers
|
| 52 |
+
# ============================================================================
|
| 53 |
+
|
| 54 |
+
class WeDLMFlowTimeEmbedding(nn.Module):
|
| 55 |
+
"""Sinusoidal timestep embedding + MLP, used to condition Flow Matching / Rectified Flow.
|
| 56 |
+
|
| 57 |
+
The module is intentionally lightweight and conditions the velocity field on continuous timesteps.
|
| 58 |
+
Timesteps are assumed to be normalized to [0, 1] (float). Internally, a configurable scale is applied
|
| 59 |
+
before sinusoidal features are computed.
|
| 60 |
+
"""
|
| 61 |
+
|
| 62 |
+
def __init__(self, config: WeDLMConfig):
|
| 63 |
+
super().__init__()
|
| 64 |
+
self.hidden_size = config.hidden_size
|
| 65 |
+
self.time_embed_dim = int(getattr(config, "flow_time_embedding_dim", 256))
|
| 66 |
+
self.max_period = int(getattr(config, "flow_time_embedding_max_period", 10000))
|
| 67 |
+
self.time_scale = float(getattr(config, "flow_time_scale", 1000.0))
|
| 68 |
+
|
| 69 |
+
self.linear_1 = nn.Linear(self.time_embed_dim, self.hidden_size)
|
| 70 |
+
self.act = nn.SiLU()
|
| 71 |
+
self.linear_2 = nn.Linear(self.hidden_size, self.hidden_size)
|
| 72 |
+
|
| 73 |
+
@staticmethod
|
| 74 |
+
def _sinusoidal_embedding(timesteps: torch.Tensor, dim: int, max_period: int) -> torch.Tensor:
|
| 75 |
+
"""Create sinusoidal timestep embeddings.
|
| 76 |
+
|
| 77 |
+
timesteps: (batch,) float tensor.
|
| 78 |
+
Returns: (batch, dim) float tensor.
|
| 79 |
+
"""
|
| 80 |
+
if timesteps.ndim != 1:
|
| 81 |
+
timesteps = timesteps.view(-1)
|
| 82 |
+
half = dim // 2
|
| 83 |
+
device = timesteps.device
|
| 84 |
+
dtype = torch.float32
|
| 85 |
+
|
| 86 |
+
freqs = torch.exp(
|
| 87 |
+
-math.log(max_period) * torch.arange(0, half, device=device, dtype=dtype) / max(half, 1)
|
| 88 |
+
)
|
| 89 |
+
args = timesteps.to(dtype)[:, None] * freqs[None]
|
| 90 |
+
emb = torch.cat([torch.cos(args), torch.sin(args)], dim=-1)
|
| 91 |
+
if dim % 2 == 1:
|
| 92 |
+
emb = torch.cat([emb, torch.zeros((emb.shape[0], 1), device=device, dtype=dtype)], dim=-1)
|
| 93 |
+
return emb
|
| 94 |
+
|
| 95 |
+
def forward(self, timesteps: torch.Tensor) -> torch.Tensor:
|
| 96 |
+
# timesteps expected in [0,1]; scale to a more typical diffusion timestep range.
|
| 97 |
+
t = timesteps.to(dtype=torch.float32)
|
| 98 |
+
if t.ndim == 0:
|
| 99 |
+
t = t[None]
|
| 100 |
+
if t.ndim != 1:
|
| 101 |
+
t = t.view(-1)
|
| 102 |
+
t = t.clamp(0.0, 1.0) * self.time_scale
|
| 103 |
+
|
| 104 |
+
emb = self._sinusoidal_embedding(t, self.time_embed_dim, self.max_period)
|
| 105 |
+
|
| 106 |
+
# NOTE: In bf16/fp16 training (and especially under PEFT/LoRA), the wrapped Linear's base weights
|
| 107 |
+
# can be low-precision (e.g. bfloat16) while the sinusoidal features are float32.
|
| 108 |
+
# Torch's F.linear requires the input and weight dtypes to match, so we explicitly cast here
|
| 109 |
+
# to the *base* layer's weight dtype.
|
| 110 |
+
base_linear_1 = getattr(self.linear_1, "base_layer", self.linear_1)
|
| 111 |
+
w1 = getattr(base_linear_1, "weight", None)
|
| 112 |
+
if w1 is not None:
|
| 113 |
+
emb = emb.to(dtype=w1.dtype)
|
| 114 |
+
emb = self.linear_1(emb)
|
| 115 |
+
emb = self.act(emb)
|
| 116 |
+
|
| 117 |
+
base_linear_2 = getattr(self.linear_2, "base_layer", self.linear_2)
|
| 118 |
+
w2 = getattr(base_linear_2, "weight", None)
|
| 119 |
+
if w2 is not None:
|
| 120 |
+
emb = emb.to(dtype=w2.dtype)
|
| 121 |
+
emb = self.linear_2(emb)
|
| 122 |
+
return emb
|
| 123 |
+
|
| 124 |
+
|
| 125 |
+
# ============================================================================
|
| 126 |
+
# ============================================================================
|
| 127 |
+
# Core Components (self-contained, no Qwen2 dependency)
|
| 128 |
+
# ============================================================================
|
| 129 |
+
|
| 130 |
+
class WeDLMMLP(nn.Module):
|
| 131 |
+
"""WeDLM MLP module with SwiGLU activation."""
|
| 132 |
+
|
| 133 |
+
def __init__(self, config: WeDLMConfig):
|
| 134 |
+
super().__init__()
|
| 135 |
+
self.config = config
|
| 136 |
+
self.hidden_size = config.hidden_size
|
| 137 |
+
self.intermediate_size = config.intermediate_size
|
| 138 |
+
self.gate_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=False)
|
| 139 |
+
self.up_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=False)
|
| 140 |
+
self.down_proj = nn.Linear(self.intermediate_size, self.hidden_size, bias=False)
|
| 141 |
+
self.act_fn = ACT2FN[config.hidden_act]
|
| 142 |
+
|
| 143 |
+
def forward(self, x: torch.Tensor) -> torch.Tensor:
|
| 144 |
+
down_proj = self.down_proj(self.act_fn(self.gate_proj(x)) * self.up_proj(x))
|
| 145 |
+
return down_proj
|
| 146 |
+
|
| 147 |
+
|
| 148 |
+
class WeDLMRMSNorm(nn.Module):
|
| 149 |
+
"""WeDLM RMSNorm, equivalent to T5LayerNorm."""
|
| 150 |
+
|
| 151 |
+
def __init__(self, hidden_size: int, eps: float = 1e-6) -> None:
|
| 152 |
+
super().__init__()
|
| 153 |
+
self.weight = nn.Parameter(torch.ones(hidden_size))
|
| 154 |
+
self.variance_epsilon = eps
|
| 155 |
+
|
| 156 |
+
def forward(self, hidden_states: torch.Tensor) -> torch.Tensor:
|
| 157 |
+
input_dtype = hidden_states.dtype
|
| 158 |
+
hidden_states = hidden_states.to(torch.float32)
|
| 159 |
+
variance = hidden_states.pow(2).mean(-1, keepdim=True)
|
| 160 |
+
hidden_states = hidden_states * torch.rsqrt(variance + self.variance_epsilon)
|
| 161 |
+
return self.weight * hidden_states.to(input_dtype)
|
| 162 |
+
|
| 163 |
+
def extra_repr(self) -> str:
|
| 164 |
+
return f"{tuple(self.weight.shape)}, eps={self.variance_epsilon}"
|
| 165 |
+
|
| 166 |
+
|
| 167 |
+
class WeDLMRotaryEmbedding(nn.Module):
|
| 168 |
+
"""WeDLM Rotary Position Embedding."""
|
| 169 |
+
|
| 170 |
+
def __init__(self, config: WeDLMConfig, device=None):
|
| 171 |
+
super().__init__()
|
| 172 |
+
# Determine rope_type from config
|
| 173 |
+
if hasattr(config, "rope_scaling") and isinstance(config.rope_scaling, dict):
|
| 174 |
+
self.rope_type = config.rope_scaling.get("rope_type", config.rope_scaling.get("type", "default"))
|
| 175 |
+
else:
|
| 176 |
+
self.rope_type = "default"
|
| 177 |
+
|
| 178 |
+
self.max_seq_len_cached = config.max_position_embeddings
|
| 179 |
+
self.original_max_seq_len = config.max_position_embeddings
|
| 180 |
+
self.config = config
|
| 181 |
+
|
| 182 |
+
# Get initialization function
|
| 183 |
+
if self.rope_type == "default":
|
| 184 |
+
inv_freq, self.attention_scaling = self._compute_default_rope_parameters(config, device)
|
| 185 |
+
else:
|
| 186 |
+
rope_init_fn = ROPE_INIT_FUNCTIONS[self.rope_type]
|
| 187 |
+
inv_freq, self.attention_scaling = rope_init_fn(config, device)
|
| 188 |
+
|
| 189 |
+
self.register_buffer("inv_freq", inv_freq, persistent=False)
|
| 190 |
+
self.original_inv_freq = self.inv_freq
|
| 191 |
+
|
| 192 |
+
@staticmethod
|
| 193 |
+
def _compute_default_rope_parameters(
|
| 194 |
+
config: WeDLMConfig,
|
| 195 |
+
device: Optional[torch.device] = None,
|
| 196 |
+
) -> Tuple[torch.Tensor, float]:
|
| 197 |
+
"""
|
| 198 |
+
Computes the inverse frequencies for default RoPE.
|
| 199 |
+
|
| 200 |
+
Args:
|
| 201 |
+
config: Model configuration
|
| 202 |
+
device: Device to place the tensors on
|
| 203 |
+
|
| 204 |
+
Returns:
|
| 205 |
+
Tuple of (inv_freq tensor, attention_scaling factor)
|
| 206 |
+
"""
|
| 207 |
+
base = config.rope_theta
|
| 208 |
+
dim = getattr(config, "head_dim", None) or config.hidden_size // config.num_attention_heads
|
| 209 |
+
|
| 210 |
+
# Compute the inverse frequencies
|
| 211 |
+
inv_freq = 1.0 / (
|
| 212 |
+
base ** (torch.arange(0, dim, 2, dtype=torch.int64).to(device=device, dtype=torch.float) / dim)
|
| 213 |
+
)
|
| 214 |
+
attention_factor = 1.0
|
| 215 |
+
return inv_freq, attention_factor
|
| 216 |
+
|
| 217 |
+
@torch.no_grad()
|
| 218 |
+
def forward(self, x: torch.Tensor, position_ids: torch.Tensor) -> Tuple[torch.Tensor, torch.Tensor]:
|
| 219 |
+
"""
|
| 220 |
+
Compute rotary position embeddings.
|
| 221 |
+
|
| 222 |
+
Args:
|
| 223 |
+
x: Input tensor, used for dtype and device
|
| 224 |
+
position_ids: Position indices
|
| 225 |
+
|
| 226 |
+
Returns:
|
| 227 |
+
Tuple of (cos, sin) tensors
|
| 228 |
+
"""
|
| 229 |
+
inv_freq_expanded = self.inv_freq[None, :, None].float().expand(position_ids.shape[0], -1, 1).to(x.device)
|
| 230 |
+
position_ids_expanded = position_ids[:, None, :].float()
|
| 231 |
+
|
| 232 |
+
device_type = x.device.type if isinstance(x.device.type, str) and x.device.type != "mps" else "cpu"
|
| 233 |
+
|
| 234 |
+
# Force float32 computation for numerical stability
|
| 235 |
+
with torch.amp.autocast(device_type=device_type, enabled=False):
|
| 236 |
+
freqs = (inv_freq_expanded.float() @ position_ids_expanded.float()).transpose(1, 2)
|
| 237 |
+
emb = torch.cat((freqs, freqs), dim=-1)
|
| 238 |
+
cos = emb.cos() * self.attention_scaling
|
| 239 |
+
sin = emb.sin() * self.attention_scaling
|
| 240 |
+
|
| 241 |
+
return cos.to(dtype=x.dtype), sin.to(dtype=x.dtype)
|
| 242 |
+
|
| 243 |
+
|
| 244 |
+
# ============================================================================
|
| 245 |
+
# Attention Utilities
|
| 246 |
+
# ============================================================================
|
| 247 |
+
|
| 248 |
+
def rotate_half(x: torch.Tensor) -> torch.Tensor:
|
| 249 |
+
"""Rotates half the hidden dims of the input."""
|
| 250 |
+
x1 = x[..., : x.shape[-1] // 2]
|
| 251 |
+
x2 = x[..., x.shape[-1] // 2 :]
|
| 252 |
+
return torch.cat((-x2, x1), dim=-1)
|
| 253 |
+
|
| 254 |
+
|
| 255 |
+
def apply_rotary_pos_emb(
|
| 256 |
+
q: torch.Tensor,
|
| 257 |
+
k: torch.Tensor,
|
| 258 |
+
cos: torch.Tensor,
|
| 259 |
+
sin: torch.Tensor,
|
| 260 |
+
position_ids: Optional[torch.Tensor] = None,
|
| 261 |
+
unsqueeze_dim: int = 1
|
| 262 |
+
) -> Tuple[torch.Tensor, torch.Tensor]:
|
| 263 |
+
"""Applies Rotary Position Embedding to the query and key tensors."""
|
| 264 |
+
cos = cos.unsqueeze(unsqueeze_dim)
|
| 265 |
+
sin = sin.unsqueeze(unsqueeze_dim)
|
| 266 |
+
q_embed = (q * cos) + (rotate_half(q) * sin)
|
| 267 |
+
k_embed = (k * cos) + (rotate_half(k) * sin)
|
| 268 |
+
return q_embed, k_embed
|
| 269 |
+
|
| 270 |
+
|
| 271 |
+
def repeat_kv(hidden_states: torch.Tensor, n_rep: int) -> torch.Tensor:
|
| 272 |
+
"""
|
| 273 |
+
Repeats key/value heads to match the number of query heads (for GQA).
|
| 274 |
+
|
| 275 |
+
Equivalent of torch.repeat_interleave(x, dim=1, repeats=n_rep).
|
| 276 |
+
"""
|
| 277 |
+
batch, num_key_value_heads, slen, head_dim = hidden_states.shape
|
| 278 |
+
if n_rep == 1:
|
| 279 |
+
return hidden_states
|
| 280 |
+
hidden_states = hidden_states[:, :, None, :, :].expand(batch, num_key_value_heads, n_rep, slen, head_dim)
|
| 281 |
+
return hidden_states.reshape(batch, num_key_value_heads * n_rep, slen, head_dim)
|
| 282 |
+
|
| 283 |
+
|
| 284 |
+
def eager_attention_forward(
|
| 285 |
+
module: nn.Module,
|
| 286 |
+
query: torch.Tensor,
|
| 287 |
+
key: torch.Tensor,
|
| 288 |
+
value: torch.Tensor,
|
| 289 |
+
attention_mask: Optional[torch.Tensor],
|
| 290 |
+
scaling: float,
|
| 291 |
+
dropout: float = 0.0,
|
| 292 |
+
**kwargs,
|
| 293 |
+
) -> Tuple[torch.Tensor, torch.Tensor]:
|
| 294 |
+
"""Eager (standard) attention implementation."""
|
| 295 |
+
key_states = repeat_kv(key, module.num_key_value_groups)
|
| 296 |
+
value_states = repeat_kv(value, module.num_key_value_groups)
|
| 297 |
+
|
| 298 |
+
attn_weights = torch.matmul(query, key_states.transpose(2, 3)) * scaling
|
| 299 |
+
|
| 300 |
+
if attention_mask is not None:
|
| 301 |
+
causal_mask = attention_mask[:, :, :, : key_states.shape[-2]]
|
| 302 |
+
attn_weights = attn_weights + causal_mask
|
| 303 |
+
|
| 304 |
+
attn_weights = nn.functional.softmax(attn_weights, dim=-1, dtype=torch.float32).to(query.dtype)
|
| 305 |
+
attn_weights = nn.functional.dropout(attn_weights, p=dropout, training=module.training)
|
| 306 |
+
attn_output = torch.matmul(attn_weights, value_states)
|
| 307 |
+
attn_output = attn_output.transpose(1, 2).contiguous()
|
| 308 |
+
|
| 309 |
+
return attn_output, attn_weights
|
| 310 |
+
|
| 311 |
+
|
| 312 |
+
# ============================================================================
|
| 313 |
+
# Attention Layer
|
| 314 |
+
# ============================================================================
|
| 315 |
+
|
| 316 |
+
class WeDLMAttention(nn.Module):
|
| 317 |
+
"""
|
| 318 |
+
WeDLM Attention module.
|
| 319 |
+
|
| 320 |
+
Supports both:
|
| 321 |
+
- Qwen2.5 style: with QKV bias, no QK Norm
|
| 322 |
+
- Qwen3 style: configurable QKV bias, with QK Norm
|
| 323 |
+
"""
|
| 324 |
+
|
| 325 |
+
def __init__(self, config: WeDLMConfig, layer_idx: int):
|
| 326 |
+
super().__init__()
|
| 327 |
+
self.layer_type = config.layer_types[layer_idx] if hasattr(config, "layer_types") else None
|
| 328 |
+
self.config = config
|
| 329 |
+
self.layer_idx = layer_idx
|
| 330 |
+
self.head_dim = getattr(config, "head_dim", config.hidden_size // config.num_attention_heads)
|
| 331 |
+
self.num_key_value_groups = config.num_attention_heads // config.num_key_value_heads
|
| 332 |
+
self.scaling = self.head_dim ** -0.5
|
| 333 |
+
self.attention_dropout = config.attention_dropout
|
| 334 |
+
self.is_causal = True
|
| 335 |
+
|
| 336 |
+
# Support configurable attention_bias (Qwen2.5: True, Qwen3: False by default)
|
| 337 |
+
attention_bias = getattr(config, "attention_bias", True)
|
| 338 |
+
|
| 339 |
+
self.q_proj = nn.Linear(config.hidden_size, config.num_attention_heads * self.head_dim, bias=attention_bias)
|
| 340 |
+
self.k_proj = nn.Linear(config.hidden_size, config.num_key_value_heads * self.head_dim, bias=attention_bias)
|
| 341 |
+
self.v_proj = nn.Linear(config.hidden_size, config.num_key_value_heads * self.head_dim, bias=attention_bias)
|
| 342 |
+
self.o_proj = nn.Linear(config.num_attention_heads * self.head_dim, config.hidden_size, bias=False)
|
| 343 |
+
|
| 344 |
+
# Support optional QK Norm (Qwen3 feature)
|
| 345 |
+
self.qk_norm = getattr(config, "qk_norm", False)
|
| 346 |
+
if self.qk_norm:
|
| 347 |
+
self.q_norm = WeDLMRMSNorm(self.head_dim, eps=config.rms_norm_eps)
|
| 348 |
+
self.k_norm = WeDLMRMSNorm(self.head_dim, eps=config.rms_norm_eps)
|
| 349 |
+
|
| 350 |
+
self.sliding_window = config.sliding_window if self.layer_type == "sliding_attention" else None
|
| 351 |
+
|
| 352 |
+
def forward(
|
| 353 |
+
self,
|
| 354 |
+
hidden_states: torch.Tensor,
|
| 355 |
+
position_embeddings: Tuple[torch.Tensor, torch.Tensor],
|
| 356 |
+
attention_mask: Optional[torch.Tensor],
|
| 357 |
+
past_key_values: Optional[Cache] = None,
|
| 358 |
+
cache_position: Optional[torch.LongTensor] = None,
|
| 359 |
+
**kwargs,
|
| 360 |
+
) -> Tuple[torch.Tensor, Optional[torch.Tensor]]:
|
| 361 |
+
input_shape = hidden_states.shape[:-1]
|
| 362 |
+
hidden_shape = (*input_shape, -1, self.head_dim)
|
| 363 |
+
|
| 364 |
+
if self.qk_norm:
|
| 365 |
+
# Qwen3 style: apply norm after projection, before transpose
|
| 366 |
+
query_states = self.q_norm(self.q_proj(hidden_states).view(hidden_shape)).transpose(1, 2)
|
| 367 |
+
key_states = self.k_norm(self.k_proj(hidden_states).view(hidden_shape)).transpose(1, 2)
|
| 368 |
+
else:
|
| 369 |
+
# Qwen2 style: no norm
|
| 370 |
+
query_states = self.q_proj(hidden_states).view(hidden_shape).transpose(1, 2)
|
| 371 |
+
key_states = self.k_proj(hidden_states).view(hidden_shape).transpose(1, 2)
|
| 372 |
+
|
| 373 |
+
value_states = self.v_proj(hidden_states).view(hidden_shape).transpose(1, 2)
|
| 374 |
+
|
| 375 |
+
cos, sin = position_embeddings
|
| 376 |
+
query_states, key_states = apply_rotary_pos_emb(query_states, key_states, cos, sin)
|
| 377 |
+
|
| 378 |
+
if past_key_values is not None:
|
| 379 |
+
# sin and cos are specific to RoPE models; cache_position needed for the static cache
|
| 380 |
+
cache_kwargs = {"sin": sin, "cos": cos, "cache_position": cache_position}
|
| 381 |
+
key_states, value_states = past_key_values.update(key_states, value_states, self.layer_idx, cache_kwargs)
|
| 382 |
+
|
| 383 |
+
# Select attention implementation
|
| 384 |
+
attention_interface: Callable = eager_attention_forward
|
| 385 |
+
if self.config._attn_implementation != "eager" and self.config._attn_implementation in ALL_ATTENTION_FUNCTIONS:
|
| 386 |
+
attention_interface = ALL_ATTENTION_FUNCTIONS[self.config._attn_implementation]
|
| 387 |
+
|
| 388 |
+
attn_output, attn_weights = attention_interface(
|
| 389 |
+
self,
|
| 390 |
+
query_states,
|
| 391 |
+
key_states,
|
| 392 |
+
value_states,
|
| 393 |
+
attention_mask,
|
| 394 |
+
dropout=0.0 if not self.training else self.attention_dropout,
|
| 395 |
+
scaling=self.scaling,
|
| 396 |
+
sliding_window=self.sliding_window,
|
| 397 |
+
**kwargs,
|
| 398 |
+
)
|
| 399 |
+
|
| 400 |
+
attn_output = attn_output.reshape(*input_shape, -1).contiguous()
|
| 401 |
+
attn_output = self.o_proj(attn_output)
|
| 402 |
+
return attn_output, attn_weights
|
| 403 |
+
|
| 404 |
+
|
| 405 |
+
# ============================================================================
|
| 406 |
+
# Decoder Layer
|
| 407 |
+
# ============================================================================
|
| 408 |
+
|
| 409 |
+
class WeDLMDecoderLayer(GradientCheckpointingLayer):
|
| 410 |
+
"""WeDLM Decoder Layer with pre-norm architecture."""
|
| 411 |
+
|
| 412 |
+
def __init__(self, config: WeDLMConfig, layer_idx: int):
|
| 413 |
+
super().__init__()
|
| 414 |
+
self.hidden_size = config.hidden_size
|
| 415 |
+
|
| 416 |
+
self.self_attn = WeDLMAttention(config=config, layer_idx=layer_idx)
|
| 417 |
+
self.mlp = WeDLMMLP(config)
|
| 418 |
+
self.input_layernorm = WeDLMRMSNorm(config.hidden_size, eps=config.rms_norm_eps)
|
| 419 |
+
self.post_attention_layernorm = WeDLMRMSNorm(config.hidden_size, eps=config.rms_norm_eps)
|
| 420 |
+
self.attention_type = config.layer_types[layer_idx]
|
| 421 |
+
|
| 422 |
+
def forward(
|
| 423 |
+
self,
|
| 424 |
+
hidden_states: torch.Tensor,
|
| 425 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 426 |
+
position_ids: Optional[torch.LongTensor] = None,
|
| 427 |
+
past_key_values: Optional[Cache] = None,
|
| 428 |
+
output_attentions: Optional[bool] = False,
|
| 429 |
+
use_cache: Optional[bool] = False,
|
| 430 |
+
cache_position: Optional[torch.LongTensor] = None,
|
| 431 |
+
position_embeddings: Optional[Tuple[torch.Tensor, torch.Tensor]] = None,
|
| 432 |
+
**kwargs: Unpack[TransformersKwargs],
|
| 433 |
+
) -> Tuple[torch.FloatTensor, Optional[Tuple[torch.FloatTensor, torch.FloatTensor]]]:
|
| 434 |
+
"""
|
| 435 |
+
Args:
|
| 436 |
+
hidden_states: Input tensor of shape `(batch, seq_len, embed_dim)`
|
| 437 |
+
attention_mask: Attention mask of size `(batch, sequence_length)`
|
| 438 |
+
position_ids: Position indices
|
| 439 |
+
past_key_values: Cached past key and value projection states
|
| 440 |
+
output_attentions: Whether to return attention weights
|
| 441 |
+
use_cache: Whether to use KV cache
|
| 442 |
+
cache_position: Position in the cache
|
| 443 |
+
position_embeddings: Tuple of (cos, sin) for rotary embeddings
|
| 444 |
+
"""
|
| 445 |
+
residual = hidden_states
|
| 446 |
+
hidden_states = self.input_layernorm(hidden_states)
|
| 447 |
+
|
| 448 |
+
# Self Attention
|
| 449 |
+
hidden_states, self_attn_weights = self.self_attn(
|
| 450 |
+
hidden_states=hidden_states,
|
| 451 |
+
position_embeddings=position_embeddings,
|
| 452 |
+
attention_mask=attention_mask,
|
| 453 |
+
past_key_values=past_key_values,
|
| 454 |
+
cache_position=cache_position,
|
| 455 |
+
**kwargs,
|
| 456 |
+
)
|
| 457 |
+
hidden_states = residual + hidden_states
|
| 458 |
+
|
| 459 |
+
# Feed Forward
|
| 460 |
+
residual = hidden_states
|
| 461 |
+
hidden_states = self.post_attention_layernorm(hidden_states)
|
| 462 |
+
hidden_states = self.mlp(hidden_states)
|
| 463 |
+
hidden_states = residual + hidden_states
|
| 464 |
+
|
| 465 |
+
outputs = (hidden_states,)
|
| 466 |
+
|
| 467 |
+
if output_attentions:
|
| 468 |
+
outputs += (self_attn_weights,)
|
| 469 |
+
|
| 470 |
+
return outputs
|
| 471 |
+
|
| 472 |
+
|
| 473 |
+
# ============================================================================
|
| 474 |
+
# Model Classes
|
| 475 |
+
# ============================================================================
|
| 476 |
+
|
| 477 |
+
@auto_docstring
|
| 478 |
+
class WeDLMPreTrainedModel(PreTrainedModel):
|
| 479 |
+
"""Base class for WeDLM models."""
|
| 480 |
+
|
| 481 |
+
config_class = WeDLMConfig
|
| 482 |
+
base_model_prefix = "model"
|
| 483 |
+
supports_gradient_checkpointing = True
|
| 484 |
+
_no_split_modules = ["WeDLMDecoderLayer"]
|
| 485 |
+
_skip_keys_device_placement = ["past_key_values"]
|
| 486 |
+
_supports_flash_attn = True
|
| 487 |
+
_supports_sdpa = True
|
| 488 |
+
_supports_flex_attn = True
|
| 489 |
+
_can_compile_fullgraph = True
|
| 490 |
+
_supports_attention_backend = True
|
| 491 |
+
_can_record_outputs = {
|
| 492 |
+
"hidden_states": WeDLMDecoderLayer,
|
| 493 |
+
"attentions": WeDLMAttention,
|
| 494 |
+
}
|
| 495 |
+
|
| 496 |
+
|
| 497 |
+
@auto_docstring
|
| 498 |
+
class WeDLMModel(WeDLMPreTrainedModel):
|
| 499 |
+
"""
|
| 500 |
+
WeDLM base model outputting raw hidden states.
|
| 501 |
+
"""
|
| 502 |
+
|
| 503 |
+
def __init__(self, config: WeDLMConfig):
|
| 504 |
+
super().__init__(config)
|
| 505 |
+
self.padding_idx = config.pad_token_id
|
| 506 |
+
self.vocab_size = config.vocab_size
|
| 507 |
+
|
| 508 |
+
self.embed_tokens = nn.Embedding(config.vocab_size, config.hidden_size, self.padding_idx)
|
| 509 |
+
self.layers = nn.ModuleList(
|
| 510 |
+
[WeDLMDecoderLayer(config, layer_idx) for layer_idx in range(config.num_hidden_layers)]
|
| 511 |
+
)
|
| 512 |
+
self.norm = WeDLMRMSNorm(config.hidden_size, eps=config.rms_norm_eps)
|
| 513 |
+
self.rotary_emb = WeDLMRotaryEmbedding(config=config)
|
| 514 |
+
self.gradient_checkpointing = False
|
| 515 |
+
self.has_sliding_layers = "sliding_attention" in self.config.layer_types
|
| 516 |
+
|
| 517 |
+
# Initialize weights and apply final processing
|
| 518 |
+
self.post_init()
|
| 519 |
+
|
| 520 |
+
def get_input_embeddings(self):
|
| 521 |
+
return self.embed_tokens
|
| 522 |
+
|
| 523 |
+
def set_input_embeddings(self, value):
|
| 524 |
+
self.embed_tokens = value
|
| 525 |
+
|
| 526 |
+
@check_model_inputs
|
| 527 |
+
@auto_docstring
|
| 528 |
+
def forward(
|
| 529 |
+
self,
|
| 530 |
+
input_ids: Optional[torch.LongTensor] = None,
|
| 531 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 532 |
+
position_ids: Optional[torch.LongTensor] = None,
|
| 533 |
+
past_key_values: Optional[Cache] = None,
|
| 534 |
+
inputs_embeds: Optional[torch.FloatTensor] = None,
|
| 535 |
+
use_cache: Optional[bool] = None,
|
| 536 |
+
output_attentions: Optional[bool] = None,
|
| 537 |
+
output_hidden_states: Optional[bool] = None,
|
| 538 |
+
return_dict: Optional[bool] = None,
|
| 539 |
+
cache_position: Optional[torch.LongTensor] = None,
|
| 540 |
+
**kwargs: Unpack[TransformersKwargs],
|
| 541 |
+
) -> Union[Tuple, BaseModelOutputWithPast]:
|
| 542 |
+
output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
|
| 543 |
+
output_hidden_states = (
|
| 544 |
+
output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
|
| 545 |
+
)
|
| 546 |
+
use_cache = use_cache if use_cache is not None else self.config.use_cache
|
| 547 |
+
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
| 548 |
+
|
| 549 |
+
if (input_ids is None) ^ (inputs_embeds is not None):
|
| 550 |
+
raise ValueError("You must specify exactly one of input_ids or inputs_embeds")
|
| 551 |
+
|
| 552 |
+
if inputs_embeds is None:
|
| 553 |
+
inputs_embeds = self.embed_tokens(input_ids)
|
| 554 |
+
|
| 555 |
+
if use_cache and past_key_values is None:
|
| 556 |
+
past_key_values = DynamicCache(config=self.config)
|
| 557 |
+
|
| 558 |
+
if cache_position is None:
|
| 559 |
+
past_seen_tokens = past_key_values.get_seq_length() if past_key_values is not None else 0
|
| 560 |
+
cache_position = torch.arange(
|
| 561 |
+
past_seen_tokens, past_seen_tokens + inputs_embeds.shape[1], device=inputs_embeds.device
|
| 562 |
+
)
|
| 563 |
+
|
| 564 |
+
if position_ids is None:
|
| 565 |
+
position_ids = cache_position.unsqueeze(0)
|
| 566 |
+
|
| 567 |
+
# Prepare attention masks
|
| 568 |
+
if not isinstance(causal_mask_mapping := attention_mask, dict):
|
| 569 |
+
mask_kwargs = {
|
| 570 |
+
"config": self.config,
|
| 571 |
+
"input_embeds": inputs_embeds,
|
| 572 |
+
"attention_mask": attention_mask,
|
| 573 |
+
"cache_position": cache_position,
|
| 574 |
+
"past_key_values": past_key_values,
|
| 575 |
+
"position_ids": position_ids,
|
| 576 |
+
}
|
| 577 |
+
causal_mask_mapping = {
|
| 578 |
+
"full_attention": create_causal_mask(**mask_kwargs),
|
| 579 |
+
}
|
| 580 |
+
if self.has_sliding_layers:
|
| 581 |
+
causal_mask_mapping["sliding_attention"] = create_sliding_window_causal_mask(**mask_kwargs)
|
| 582 |
+
|
| 583 |
+
hidden_states = inputs_embeds
|
| 584 |
+
|
| 585 |
+
# Create position embeddings to be shared across the decoder layers
|
| 586 |
+
position_embeddings = self.rotary_emb(hidden_states, position_ids)
|
| 587 |
+
|
| 588 |
+
# Decoder layers
|
| 589 |
+
all_hidden_states = () if output_hidden_states else None
|
| 590 |
+
all_self_attns = () if output_attentions else None
|
| 591 |
+
|
| 592 |
+
for decoder_layer in self.layers[: self.config.num_hidden_layers]:
|
| 593 |
+
if output_hidden_states:
|
| 594 |
+
all_hidden_states += (hidden_states,)
|
| 595 |
+
|
| 596 |
+
layer_outputs = decoder_layer(
|
| 597 |
+
hidden_states,
|
| 598 |
+
attention_mask=causal_mask_mapping[decoder_layer.attention_type],
|
| 599 |
+
position_ids=position_ids,
|
| 600 |
+
past_key_values=past_key_values,
|
| 601 |
+
output_attentions=output_attentions,
|
| 602 |
+
use_cache=use_cache,
|
| 603 |
+
cache_position=cache_position,
|
| 604 |
+
position_embeddings=position_embeddings,
|
| 605 |
+
**kwargs,
|
| 606 |
+
)
|
| 607 |
+
|
| 608 |
+
hidden_states = layer_outputs[0]
|
| 609 |
+
|
| 610 |
+
if output_attentions:
|
| 611 |
+
all_self_attns += (layer_outputs[1],)
|
| 612 |
+
|
| 613 |
+
hidden_states = self.norm(hidden_states)
|
| 614 |
+
|
| 615 |
+
if output_hidden_states:
|
| 616 |
+
all_hidden_states += (hidden_states,)
|
| 617 |
+
|
| 618 |
+
if not return_dict:
|
| 619 |
+
return tuple(v for v in [hidden_states, past_key_values, all_hidden_states, all_self_attns] if v is not None)
|
| 620 |
+
|
| 621 |
+
return BaseModelOutputWithPast(
|
| 622 |
+
last_hidden_state=hidden_states,
|
| 623 |
+
past_key_values=past_key_values if use_cache else None,
|
| 624 |
+
hidden_states=all_hidden_states,
|
| 625 |
+
attentions=all_self_attns,
|
| 626 |
+
)
|
| 627 |
+
|
| 628 |
+
|
| 629 |
+
@auto_docstring
|
| 630 |
+
class WeDLMForCausalLM(WeDLMPreTrainedModel, GenerationMixin):
|
| 631 |
+
"""
|
| 632 |
+
WeDLM Model for Flow-Matching language modeling (Rectified Flow in token-embedding space).
|
| 633 |
+
|
| 634 |
+
- Training (`labels` provided): optimizes a Flow Matching objective on a selected subset of token positions.
|
| 635 |
+
Large-vocabulary projection (`lm_head`) is skipped by default during training for lower cost.
|
| 636 |
+
- Inference (no `labels`): behaves like a standard causal LM (returns logits).
|
| 637 |
+
- Fast decoding: use `generate_wedlm` (Flow-Matching block decoding).
|
| 638 |
+
"""
|
| 639 |
+
_tied_weights_keys = ["lm_head.weight"]
|
| 640 |
+
|
| 641 |
+
def __init__(self, config: WeDLMConfig):
|
| 642 |
+
super().__init__(config)
|
| 643 |
+
self.model = WeDLMModel(config)
|
| 644 |
+
self.vocab_size = config.vocab_size
|
| 645 |
+
|
| 646 |
+
# Token discretization head (used for inference / evaluation / discretization at the end of each flow block)
|
| 647 |
+
self.lm_head = nn.Linear(config.hidden_size, config.vocab_size, bias=False)
|
| 648 |
+
|
| 649 |
+
# Flow Matching modules
|
| 650 |
+
self.flow_time_embed = WeDLMFlowTimeEmbedding(config)
|
| 651 |
+
self.flow_head = nn.Linear(config.hidden_size, config.hidden_size, bias=False)
|
| 652 |
+
|
| 653 |
+
# Initialize weights and apply final processing
|
| 654 |
+
self.post_init()
|
| 655 |
+
|
| 656 |
+
# ----------------------------
|
| 657 |
+
# Embedding plumbing
|
| 658 |
+
# ----------------------------
|
| 659 |
+
def get_input_embeddings(self):
|
| 660 |
+
return self.model.embed_tokens
|
| 661 |
+
|
| 662 |
+
def set_input_embeddings(self, value):
|
| 663 |
+
self.model.embed_tokens = value
|
| 664 |
+
|
| 665 |
+
def get_output_embeddings(self):
|
| 666 |
+
return self.lm_head
|
| 667 |
+
|
| 668 |
+
def set_output_embeddings(self, new_embeddings):
|
| 669 |
+
self.lm_head = new_embeddings
|
| 670 |
+
|
| 671 |
+
def set_decoder(self, decoder):
|
| 672 |
+
self.model = decoder
|
| 673 |
+
|
| 674 |
+
def get_decoder(self):
|
| 675 |
+
return self.model
|
| 676 |
+
|
| 677 |
+
# ----------------------------
|
| 678 |
+
# Flow Matching utilities
|
| 679 |
+
# ----------------------------
|
| 680 |
+
def _select_flow_targets(
|
| 681 |
+
self,
|
| 682 |
+
input_ids: torch.LongTensor,
|
| 683 |
+
attention_mask: Optional[torch.Tensor],
|
| 684 |
+
labels: Optional[torch.LongTensor],
|
| 685 |
+
flow_target_mask: Optional[torch.BoolTensor],
|
| 686 |
+
) -> torch.BoolTensor:
|
| 687 |
+
"""
|
| 688 |
+
Determine which token positions participate in Flow Matching loss.
|
| 689 |
+
|
| 690 |
+
Priority:
|
| 691 |
+
1) `flow_target_mask` argument
|
| 692 |
+
2) `config.flow_train_strategy`
|
| 693 |
+
"""
|
| 694 |
+
bsz, seq_len = input_ids.shape
|
| 695 |
+
device = input_ids.device
|
| 696 |
+
|
| 697 |
+
if attention_mask is not None:
|
| 698 |
+
valid = attention_mask.to(dtype=torch.bool, device=device)
|
| 699 |
+
else:
|
| 700 |
+
# Best-effort fallback: treat non-pad as valid.
|
| 701 |
+
pad_id = getattr(self.config, "pad_token_id", None)
|
| 702 |
+
if pad_id is None:
|
| 703 |
+
valid = torch.ones((bsz, seq_len), dtype=torch.bool, device=device)
|
| 704 |
+
else:
|
| 705 |
+
valid = input_ids.ne(pad_id)
|
| 706 |
+
|
| 707 |
+
if labels is not None:
|
| 708 |
+
valid = valid & labels.ne(-100)
|
| 709 |
+
|
| 710 |
+
if flow_target_mask is not None:
|
| 711 |
+
target = flow_target_mask.to(dtype=torch.bool, device=device)
|
| 712 |
+
return target & valid
|
| 713 |
+
|
| 714 |
+
strategy = str(getattr(self.config, "flow_train_strategy", "suffix_block")).lower()
|
| 715 |
+
min_targets = int(getattr(self.config, "flow_train_min_target_tokens", 1))
|
| 716 |
+
|
| 717 |
+
if strategy == "random":
|
| 718 |
+
ratio = float(getattr(self.config, "flow_train_mask_ratio", 0.15))
|
| 719 |
+
# Sample only from valid positions; guarantee at least `min_targets` if possible.
|
| 720 |
+
rand = torch.rand((bsz, seq_len), device=device)
|
| 721 |
+
target = (rand < ratio) & valid
|
| 722 |
+
if min_targets > 0:
|
| 723 |
+
for b in range(bsz):
|
| 724 |
+
if valid[b].any() and target[b].sum().item() < min_targets:
|
| 725 |
+
valid_idx = valid[b].nonzero(as_tuple=True)[0]
|
| 726 |
+
# Select the last positions (deterministic tie-break) to fill up.
|
| 727 |
+
need = min(min_targets - target[b].sum().item(), valid_idx.numel())
|
| 728 |
+
if need > 0:
|
| 729 |
+
target[b, valid_idx[-need:]] = True
|
| 730 |
+
return target
|
| 731 |
+
|
| 732 |
+
# Default: suffix_block
|
| 733 |
+
block_size = int(getattr(self.config, "flow_train_block_size", 64))
|
| 734 |
+
target = torch.zeros((bsz, seq_len), dtype=torch.bool, device=device)
|
| 735 |
+
for b in range(bsz):
|
| 736 |
+
valid_idx = valid[b].nonzero(as_tuple=True)[0]
|
| 737 |
+
if valid_idx.numel() == 0:
|
| 738 |
+
continue
|
| 739 |
+
# Do not target the very first valid token by default (no context); if needed, user can pass flow_target_mask.
|
| 740 |
+
if valid_idx.numel() == 1:
|
| 741 |
+
continue
|
| 742 |
+
# Suffix contiguous block among valid positions.
|
| 743 |
+
k = min(block_size, valid_idx.numel() - 1)
|
| 744 |
+
k = max(k, min_targets)
|
| 745 |
+
k = min(k, valid_idx.numel() - 1) # ensure at least one context token remains
|
| 746 |
+
if k <= 0:
|
| 747 |
+
continue
|
| 748 |
+
target_pos = valid_idx[-k:]
|
| 749 |
+
target[b, target_pos] = True
|
| 750 |
+
return target
|
| 751 |
+
|
| 752 |
+
def _normalize_timesteps(
|
| 753 |
+
self,
|
| 754 |
+
timesteps: Optional[torch.FloatTensor],
|
| 755 |
+
target_mask: torch.BoolTensor,
|
| 756 |
+
) -> torch.FloatTensor:
|
| 757 |
+
"""
|
| 758 |
+
Returns per-token normalized timesteps t in [0, 1], shape (bsz, seq_len).
|
| 759 |
+
"""
|
| 760 |
+
device = target_mask.device
|
| 761 |
+
bsz, seq_len = target_mask.shape
|
| 762 |
+
|
| 763 |
+
if timesteps is None:
|
| 764 |
+
t = torch.rand((bsz, seq_len), device=device, dtype=torch.float32)
|
| 765 |
+
# Non-target positions: t=1.0 (data endpoint) so that any accidental use is benign.
|
| 766 |
+
t = torch.where(target_mask, t, torch.ones_like(t))
|
| 767 |
+
return t
|
| 768 |
+
|
| 769 |
+
t_in = timesteps.to(device=device, dtype=torch.float32)
|
| 770 |
+
if t_in.ndim == 0:
|
| 771 |
+
t = t_in.view(1, 1).expand(bsz, seq_len)
|
| 772 |
+
elif t_in.ndim == 1:
|
| 773 |
+
if t_in.shape[0] == 1 and bsz > 1:
|
| 774 |
+
t = t_in.view(1, 1).expand(bsz, seq_len)
|
| 775 |
+
elif t_in.shape[0] == bsz:
|
| 776 |
+
t = t_in.view(bsz, 1).expand(bsz, seq_len)
|
| 777 |
+
else:
|
| 778 |
+
raise ValueError(
|
| 779 |
+
f"flow_timesteps must be scalar, shape (bsz,), or shape (bsz, seq_len); got {tuple(t_in.shape)}"
|
| 780 |
+
)
|
| 781 |
+
elif t_in.ndim == 2:
|
| 782 |
+
if t_in.shape != (bsz, seq_len):
|
| 783 |
+
raise ValueError(
|
| 784 |
+
f"flow_timesteps must have shape (bsz, seq_len) == {(bsz, seq_len)}; got {tuple(t_in.shape)}"
|
| 785 |
+
)
|
| 786 |
+
t = t_in
|
| 787 |
+
else:
|
| 788 |
+
raise ValueError(
|
| 789 |
+
f"flow_timesteps must be scalar, 1D, or 2D; got ndim={t_in.ndim} with shape {tuple(t_in.shape)}"
|
| 790 |
+
)
|
| 791 |
+
|
| 792 |
+
# Clamp into [0,1] for numerical safety.
|
| 793 |
+
t = torch.clamp(t, 0.0, 1.0)
|
| 794 |
+
t = torch.where(target_mask, t, torch.ones_like(t))
|
| 795 |
+
return t
|
| 796 |
+
|
| 797 |
+
def _build_flow_inputs(
|
| 798 |
+
self,
|
| 799 |
+
input_ids: torch.LongTensor,
|
| 800 |
+
attention_mask: Optional[torch.Tensor],
|
| 801 |
+
labels: Optional[torch.LongTensor],
|
| 802 |
+
flow_target_mask: Optional[torch.BoolTensor],
|
| 803 |
+
flow_timesteps: Optional[torch.FloatTensor],
|
| 804 |
+
flow_noise: Optional[torch.FloatTensor],
|
| 805 |
+
) -> Tuple[torch.FloatTensor, torch.BoolTensor, torch.FloatTensor, torch.FloatTensor, torch.FloatTensor]:
|
| 806 |
+
"""
|
| 807 |
+
Prepare (inputs_embeds, target_mask, t, noise, clean_embeds) for Flow Matching training.
|
| 808 |
+
"""
|
| 809 |
+
clean_embeds = self.model.embed_tokens(input_ids)
|
| 810 |
+
bsz, seq_len, hidden = clean_embeds.shape
|
| 811 |
+
device = clean_embeds.device
|
| 812 |
+
|
| 813 |
+
target_mask = self._select_flow_targets(
|
| 814 |
+
input_ids=input_ids,
|
| 815 |
+
attention_mask=attention_mask,
|
| 816 |
+
labels=labels,
|
| 817 |
+
flow_target_mask=flow_target_mask,
|
| 818 |
+
)
|
| 819 |
+
|
| 820 |
+
t = self._normalize_timesteps(flow_timesteps, target_mask=target_mask)
|
| 821 |
+
|
| 822 |
+
sigma = float(getattr(self.config, "flow_init_sigma", 1.0))
|
| 823 |
+
if flow_noise is None:
|
| 824 |
+
noise = torch.randn_like(clean_embeds, dtype=torch.float32) * sigma
|
| 825 |
+
else:
|
| 826 |
+
noise = flow_noise.to(device=device, dtype=torch.float32)
|
| 827 |
+
if noise.shape != clean_embeds.shape:
|
| 828 |
+
raise ValueError(
|
| 829 |
+
f"flow_noise must have the same shape as token embeddings {tuple(clean_embeds.shape)}; got {tuple(noise.shape)}"
|
| 830 |
+
)
|
| 831 |
+
|
| 832 |
+
# Rectified Flow path: X_t = (1 - t) * X_0 + t * X_1
|
| 833 |
+
# Here X_0 is noise, X_1 is data (token embeddings).
|
| 834 |
+
t_exp = t.unsqueeze(-1)
|
| 835 |
+
x_t = (1.0 - t_exp) * noise + t_exp * clean_embeds.to(dtype=torch.float32)
|
| 836 |
+
|
| 837 |
+
# Time conditioning is provided by adding a learned timestep embedding to the *input embeddings*
|
| 838 |
+
# for flow-target positions (so the Transformer can use t).
|
| 839 |
+
inputs_embeds = clean_embeds.to(dtype=torch.float32)
|
| 840 |
+
if target_mask.any():
|
| 841 |
+
# Compute time embedding only for targets to reduce overhead.
|
| 842 |
+
t_flat = t[target_mask].reshape(-1)
|
| 843 |
+
time_cond = self.flow_time_embed(t_flat).to(dtype=inputs_embeds.dtype)
|
| 844 |
+
inputs_embeds = inputs_embeds.clone()
|
| 845 |
+
inputs_embeds[target_mask] = x_t[target_mask] + time_cond
|
| 846 |
+
else:
|
| 847 |
+
inputs_embeds = inputs_embeds.clone()
|
| 848 |
+
|
| 849 |
+
return inputs_embeds.to(dtype=clean_embeds.dtype), target_mask, t, noise, clean_embeds
|
| 850 |
+
|
| 851 |
+
# ----------------------------
|
| 852 |
+
# Decoding: Flow Matching block decoding
|
| 853 |
+
# ----------------------------
|
| 854 |
+
def _top_k_top_p_filtering(
|
| 855 |
+
self,
|
| 856 |
+
logits: torch.Tensor,
|
| 857 |
+
top_k: int = 0,
|
| 858 |
+
top_p: float = 1.0,
|
| 859 |
+
filter_value: float = -float("inf"),
|
| 860 |
+
) -> torch.Tensor:
|
| 861 |
+
"""Apply top-k and/or nucleus (top-p) filtering to logits."""
|
| 862 |
+
if top_k is not None and top_k > 0:
|
| 863 |
+
top_k = min(top_k, logits.size(-1))
|
| 864 |
+
indices_to_remove = logits < torch.topk(logits, top_k, dim=-1).values[..., -1, None]
|
| 865 |
+
logits = logits.masked_fill(indices_to_remove, filter_value)
|
| 866 |
+
|
| 867 |
+
if top_p is not None and 0.0 < top_p < 1.0:
|
| 868 |
+
sorted_logits, sorted_indices = torch.sort(logits, descending=True, dim=-1)
|
| 869 |
+
cumulative_probs = torch.cumsum(F.softmax(sorted_logits, dim=-1), dim=-1)
|
| 870 |
+
|
| 871 |
+
sorted_indices_to_remove = cumulative_probs > top_p
|
| 872 |
+
sorted_indices_to_remove[..., 1:] = sorted_indices_to_remove[..., :-1].clone()
|
| 873 |
+
sorted_indices_to_remove[..., 0] = False
|
| 874 |
+
|
| 875 |
+
indices_to_remove = sorted_indices_to_remove.scatter(-1, sorted_indices, sorted_indices_to_remove)
|
| 876 |
+
logits = logits.masked_fill(indices_to_remove, filter_value)
|
| 877 |
+
|
| 878 |
+
return logits
|
| 879 |
+
|
| 880 |
+
def _sample_from_logits(
|
| 881 |
+
self,
|
| 882 |
+
logits: torch.Tensor,
|
| 883 |
+
temperature: float = 1.0,
|
| 884 |
+
top_p: float = 1.0,
|
| 885 |
+
top_k: int = 0,
|
| 886 |
+
) -> torch.Tensor:
|
| 887 |
+
"""Sample token IDs from logits with temperature + (top-k, top-p) filtering."""
|
| 888 |
+
if temperature is None or temperature <= 0:
|
| 889 |
+
temperature = 1.0
|
| 890 |
+
logits = logits / float(temperature)
|
| 891 |
+
logits = self._top_k_top_p_filtering(logits, top_k=top_k, top_p=top_p)
|
| 892 |
+
probs = F.softmax(logits, dim=-1)
|
| 893 |
+
return torch.multinomial(probs, num_samples=1).squeeze(-1)
|
| 894 |
+
|
| 895 |
+
@torch.no_grad()
|
| 896 |
+
def generate_wedlm(
|
| 897 |
+
self,
|
| 898 |
+
input_ids: torch.LongTensor,
|
| 899 |
+
max_new_tokens: int,
|
| 900 |
+
block_size: Optional[int] = None,
|
| 901 |
+
num_steps: Optional[int] = None,
|
| 902 |
+
flow_init_sigma: Optional[float] = None,
|
| 903 |
+
discretization: Optional[str] = None,
|
| 904 |
+
temperature: Optional[float] = None,
|
| 905 |
+
top_p: Optional[float] = None,
|
| 906 |
+
top_k: Optional[int] = None,
|
| 907 |
+
pad_token_id: Optional[int] = None,
|
| 908 |
+
eos_token_id: Optional[int] = None,
|
| 909 |
+
return_stats: bool = True,
|
| 910 |
+
**kwargs,
|
| 911 |
+
) -> Union[torch.LongTensor, Dict]:
|
| 912 |
+
"""
|
| 913 |
+
Flow-Matching block decoding.
|
| 914 |
+
|
| 915 |
+
Generates `block_size` tokens per block using `num_steps` Euler steps, and runs the vocabulary projection
|
| 916 |
+
(`lm_head`) only once per block (final discretization).
|
| 917 |
+
"""
|
| 918 |
+
device = input_ids.device
|
| 919 |
+
if pad_token_id is None:
|
| 920 |
+
pad_token_id = self.config.pad_token_id
|
| 921 |
+
if eos_token_id is None:
|
| 922 |
+
eos_token_id = getattr(self.config, "eos_token_id", None)
|
| 923 |
+
|
| 924 |
+
if block_size is None:
|
| 925 |
+
block_size = int(getattr(self.config, "flow_block_size", 64))
|
| 926 |
+
if num_steps is None:
|
| 927 |
+
num_steps = int(getattr(self.config, "flow_inference_steps", 8))
|
| 928 |
+
if flow_init_sigma is None:
|
| 929 |
+
flow_init_sigma = float(getattr(self.config, "flow_init_sigma", 1.0))
|
| 930 |
+
|
| 931 |
+
if discretization is None:
|
| 932 |
+
discretization = str(getattr(self.config, "flow_discretization", "argmax")).lower()
|
| 933 |
+
if temperature is None:
|
| 934 |
+
temperature = float(getattr(self.config, "flow_temperature", 1.0))
|
| 935 |
+
if top_p is None:
|
| 936 |
+
top_p = float(getattr(self.config, "flow_top_p", 1.0))
|
| 937 |
+
if top_k is None:
|
| 938 |
+
top_k = int(getattr(self.config, "flow_top_k", 0))
|
| 939 |
+
|
| 940 |
+
batch_size = input_ids.shape[0]
|
| 941 |
+
all_generated: List[torch.Tensor] = []
|
| 942 |
+
all_sample_stats: List[Dict] = []
|
| 943 |
+
|
| 944 |
+
num_blocks = (max_new_tokens + block_size - 1) // block_size
|
| 945 |
+
|
| 946 |
+
for batch_idx in range(batch_size):
|
| 947 |
+
sample_ids = input_ids[batch_idx]
|
| 948 |
+
if pad_token_id is not None:
|
| 949 |
+
pad_mask = sample_ids.ne(pad_token_id)
|
| 950 |
+
if pad_mask.any():
|
| 951 |
+
valid_length = int(pad_mask.sum().item())
|
| 952 |
+
prefix_ids = sample_ids[:valid_length]
|
| 953 |
+
else:
|
| 954 |
+
prefix_ids = sample_ids
|
| 955 |
+
else:
|
| 956 |
+
prefix_ids = sample_ids
|
| 957 |
+
|
| 958 |
+
prefix_ids = prefix_ids.clone()
|
| 959 |
+
prefix_length = prefix_ids.shape[0]
|
| 960 |
+
|
| 961 |
+
sample_stats = {
|
| 962 |
+
"input_length": prefix_length,
|
| 963 |
+
"num_blocks": num_blocks,
|
| 964 |
+
"block_size": block_size,
|
| 965 |
+
"num_steps": num_steps,
|
| 966 |
+
"sigma": float(flow_init_sigma),
|
| 967 |
+
"generated_tokens": 0,
|
| 968 |
+
"blocks": [],
|
| 969 |
+
}
|
| 970 |
+
|
| 971 |
+
current_ids = prefix_ids
|
| 972 |
+
|
| 973 |
+
for block_idx in range(num_blocks):
|
| 974 |
+
remaining = max_new_tokens - block_idx * block_size
|
| 975 |
+
cur_block = min(block_size, remaining)
|
| 976 |
+
if cur_block <= 0:
|
| 977 |
+
break
|
| 978 |
+
|
| 979 |
+
# State variable: current embedding estimates for the block (initialized from Gaussian noise)
|
| 980 |
+
x = torch.randn((cur_block, self.config.hidden_size), device=device, dtype=torch.float32) * float(flow_init_sigma)
|
| 981 |
+
|
| 982 |
+
dt = 1.0 / float(num_steps)
|
| 983 |
+
# Euler integration from t=0 (noise) to t=1 (data)
|
| 984 |
+
for step in range(num_steps):
|
| 985 |
+
t = float(step) / float(num_steps)
|
| 986 |
+
# Create per-token timesteps matching training behavior (all same t for this step)
|
| 987 |
+
t_tensor = torch.full((cur_block,), t, device=device, dtype=torch.float32)
|
| 988 |
+
# Build embeddings in *model dtype* to avoid dtype mismatch in Linear layers when AMP is off.
|
| 989 |
+
context_embeds = self.model.embed_tokens(current_ids.unsqueeze(0))
|
| 990 |
+
ctx_dtype = context_embeds.dtype
|
| 991 |
+
# Per-token time conditioning (cur_block,) -> (cur_block, H)
|
| 992 |
+
t_cond = self.flow_time_embed(t_tensor).to(dtype=ctx_dtype) # (cur_block, H)
|
| 993 |
+
|
| 994 |
+
# Context tokens are discrete; block tokens are continuous (x) + time conditioning.
|
| 995 |
+
block_embeds = x.to(dtype=ctx_dtype) + t_cond # (cur_block, H)
|
| 996 |
+
block_embeds = block_embeds.view(1, cur_block, -1) # (1, cur_block, H)
|
| 997 |
+
inputs_embeds = torch.cat([context_embeds, block_embeds], dim=1)
|
| 998 |
+
|
| 999 |
+
seq_len = inputs_embeds.shape[1]
|
| 1000 |
+
attention_mask = torch.ones((1, seq_len), dtype=torch.long, device=device)
|
| 1001 |
+
position_ids = torch.arange(seq_len, dtype=torch.long, device=device).unsqueeze(0)
|
| 1002 |
+
|
| 1003 |
+
outputs = self.model(
|
| 1004 |
+
input_ids=None,
|
| 1005 |
+
inputs_embeds=inputs_embeds,
|
| 1006 |
+
attention_mask=attention_mask,
|
| 1007 |
+
position_ids=position_ids,
|
| 1008 |
+
use_cache=False,
|
| 1009 |
+
return_dict=True,
|
| 1010 |
+
)
|
| 1011 |
+
h_new = outputs.last_hidden_state[:, -cur_block:, :] # (1, cur_block, H)
|
| 1012 |
+
|
| 1013 |
+
# Predict velocity in a dtype-compatible way, then accumulate in fp32.
|
| 1014 |
+
h_in = h_new
|
| 1015 |
+
base_flow = getattr(self.flow_head, "base_layer", self.flow_head)
|
| 1016 |
+
w_flow = getattr(base_flow, "weight", None)
|
| 1017 |
+
if w_flow is not None:
|
| 1018 |
+
h_in = h_in.to(dtype=w_flow.dtype)
|
| 1019 |
+
v = self.flow_head(h_in).to(dtype=torch.float32).squeeze(0) # (cur_block, H)
|
| 1020 |
+
x = x + dt * v
|
| 1021 |
+
|
| 1022 |
+
# Discretize final embeddings into token IDs
|
| 1023 |
+
base_lm = getattr(self.lm_head, "base_layer", self.lm_head)
|
| 1024 |
+
w_lm = getattr(base_lm, "weight", None)
|
| 1025 |
+
x_lm = x
|
| 1026 |
+
if w_lm is not None:
|
| 1027 |
+
x_lm = x_lm.to(dtype=w_lm.dtype)
|
| 1028 |
+
logits = self.lm_head(x_lm).to(dtype=torch.float32) # (cur_block, vocab)
|
| 1029 |
+
if discretization == "sample":
|
| 1030 |
+
next_ids = self._sample_from_logits(logits, temperature=temperature, top_p=top_p, top_k=top_k)
|
| 1031 |
+
else:
|
| 1032 |
+
next_ids = torch.argmax(logits, dim=-1)
|
| 1033 |
+
|
| 1034 |
+
# Optional early stop on EOS within the block
|
| 1035 |
+
if eos_token_id is not None:
|
| 1036 |
+
eos_positions = (next_ids == eos_token_id).nonzero(as_tuple=True)[0]
|
| 1037 |
+
if eos_positions.numel() > 0:
|
| 1038 |
+
cut = int(eos_positions[0].item()) + 1
|
| 1039 |
+
next_ids = next_ids[:cut]
|
| 1040 |
+
|
| 1041 |
+
current_ids = torch.cat([current_ids, next_ids.to(dtype=torch.long)], dim=0)
|
| 1042 |
+
sample_stats["generated_tokens"] += int(next_ids.numel())
|
| 1043 |
+
sample_stats["blocks"].append(
|
| 1044 |
+
{
|
| 1045 |
+
"block_idx": block_idx,
|
| 1046 |
+
"target_block_size": int(cur_block),
|
| 1047 |
+
"actual_block_tokens": int(next_ids.numel()),
|
| 1048 |
+
}
|
| 1049 |
+
)
|
| 1050 |
+
|
| 1051 |
+
if eos_token_id is not None and next_ids.numel() > 0 and next_ids[-1].item() == int(eos_token_id):
|
| 1052 |
+
break
|
| 1053 |
+
|
| 1054 |
+
sample_stats["output_length"] = int(current_ids.numel())
|
| 1055 |
+
all_generated.append(current_ids)
|
| 1056 |
+
all_sample_stats.append(sample_stats)
|
| 1057 |
+
|
| 1058 |
+
# Pad to max length
|
| 1059 |
+
max_len = max(seq.numel() for seq in all_generated) if all_generated else 0
|
| 1060 |
+
padded = []
|
| 1061 |
+
for seq in all_generated:
|
| 1062 |
+
if seq.numel() < max_len:
|
| 1063 |
+
pad = torch.full(
|
| 1064 |
+
(max_len - seq.numel(),),
|
| 1065 |
+
int(pad_token_id) if pad_token_id is not None else 0,
|
| 1066 |
+
dtype=torch.long,
|
| 1067 |
+
device=device,
|
| 1068 |
+
)
|
| 1069 |
+
seq = torch.cat([seq, pad], dim=0)
|
| 1070 |
+
padded.append(seq)
|
| 1071 |
+
sequences = torch.stack(padded, dim=0) if padded else torch.empty((0, 0), dtype=torch.long, device=device)
|
| 1072 |
+
|
| 1073 |
+
if not return_stats:
|
| 1074 |
+
return sequences
|
| 1075 |
+
|
| 1076 |
+
total_steps = int(num_steps) * int(num_blocks) * int(batch_size)
|
| 1077 |
+
return {
|
| 1078 |
+
"sequences": sequences,
|
| 1079 |
+
"stats": {
|
| 1080 |
+
"batch_size": int(batch_size),
|
| 1081 |
+
"max_new_tokens": int(max_new_tokens),
|
| 1082 |
+
"block_size": int(block_size),
|
| 1083 |
+
"num_steps": int(num_steps),
|
| 1084 |
+
"discretization": discretization,
|
| 1085 |
+
"temperature": float(temperature),
|
| 1086 |
+
"top_p": float(top_p),
|
| 1087 |
+
"top_k": int(top_k),
|
| 1088 |
+
"total_flow_evals": total_steps,
|
| 1089 |
+
"per_sample_stats": all_sample_stats,
|
| 1090 |
+
},
|
| 1091 |
+
}
|
| 1092 |
+
|
| 1093 |
+
# ----------------------------
|
| 1094 |
+
# Generate (override to use Flow Matching by default)
|
| 1095 |
+
# ----------------------------
|
| 1096 |
+
@torch.no_grad()
|
| 1097 |
+
def generate(
|
| 1098 |
+
self,
|
| 1099 |
+
input_ids: Optional[torch.LongTensor] = None,
|
| 1100 |
+
generation_config=None,
|
| 1101 |
+
max_new_tokens: Optional[int] = None,
|
| 1102 |
+
max_length: Optional[int] = None,
|
| 1103 |
+
do_sample: Optional[bool] = None,
|
| 1104 |
+
temperature: Optional[float] = None,
|
| 1105 |
+
top_p: Optional[float] = None,
|
| 1106 |
+
top_k: Optional[int] = None,
|
| 1107 |
+
pad_token_id: Optional[int] = None,
|
| 1108 |
+
eos_token_id: Optional[int] = None,
|
| 1109 |
+
use_flow_matching: bool = True,
|
| 1110 |
+
block_size: Optional[int] = None,
|
| 1111 |
+
num_steps: Optional[int] = None,
|
| 1112 |
+
flow_init_sigma: Optional[float] = None,
|
| 1113 |
+
streamer=None,
|
| 1114 |
+
**kwargs,
|
| 1115 |
+
):
|
| 1116 |
+
"""
|
| 1117 |
+
Override generate() to use Flow Matching decoding by default.
|
| 1118 |
+
|
| 1119 |
+
Set `use_flow_matching=False` to fall back to standard AR generation.
|
| 1120 |
+
"""
|
| 1121 |
+
# Fall back to standard AR generation if requested
|
| 1122 |
+
if not use_flow_matching:
|
| 1123 |
+
return super().generate(
|
| 1124 |
+
input_ids=input_ids,
|
| 1125 |
+
generation_config=generation_config,
|
| 1126 |
+
max_new_tokens=max_new_tokens,
|
| 1127 |
+
max_length=max_length,
|
| 1128 |
+
do_sample=do_sample,
|
| 1129 |
+
temperature=temperature,
|
| 1130 |
+
top_p=top_p,
|
| 1131 |
+
top_k=top_k,
|
| 1132 |
+
pad_token_id=pad_token_id,
|
| 1133 |
+
eos_token_id=eos_token_id,
|
| 1134 |
+
streamer=streamer,
|
| 1135 |
+
**kwargs,
|
| 1136 |
+
)
|
| 1137 |
+
|
| 1138 |
+
# Extract parameters from generation_config if provided
|
| 1139 |
+
if generation_config is not None:
|
| 1140 |
+
if max_new_tokens is None:
|
| 1141 |
+
max_new_tokens = getattr(generation_config, "max_new_tokens", None)
|
| 1142 |
+
if max_length is None:
|
| 1143 |
+
max_length = getattr(generation_config, "max_length", None)
|
| 1144 |
+
if do_sample is None:
|
| 1145 |
+
do_sample = getattr(generation_config, "do_sample", None)
|
| 1146 |
+
if temperature is None:
|
| 1147 |
+
temperature = getattr(generation_config, "temperature", None)
|
| 1148 |
+
if top_p is None:
|
| 1149 |
+
top_p = getattr(generation_config, "top_p", None)
|
| 1150 |
+
if top_k is None:
|
| 1151 |
+
top_k = getattr(generation_config, "top_k", None)
|
| 1152 |
+
if pad_token_id is None:
|
| 1153 |
+
pad_token_id = getattr(generation_config, "pad_token_id", None)
|
| 1154 |
+
if eos_token_id is None:
|
| 1155 |
+
eos_token_id = getattr(generation_config, "eos_token_id", None)
|
| 1156 |
+
|
| 1157 |
+
# Determine max_new_tokens
|
| 1158 |
+
if max_new_tokens is None:
|
| 1159 |
+
if max_length is not None and input_ids is not None:
|
| 1160 |
+
max_new_tokens = max_length - input_ids.shape[1]
|
| 1161 |
+
else:
|
| 1162 |
+
max_new_tokens = 256 # Default
|
| 1163 |
+
|
| 1164 |
+
max_new_tokens = max(1, max_new_tokens)
|
| 1165 |
+
|
| 1166 |
+
# Map do_sample to discretization
|
| 1167 |
+
discretization = "sample" if do_sample else "argmax"
|
| 1168 |
+
|
| 1169 |
+
# Use config defaults for flow parameters
|
| 1170 |
+
if block_size is None:
|
| 1171 |
+
block_size = getattr(self.config, "flow_block_size", 64)
|
| 1172 |
+
if num_steps is None:
|
| 1173 |
+
num_steps = getattr(self.config, "flow_inference_steps", 8)
|
| 1174 |
+
if flow_init_sigma is None:
|
| 1175 |
+
flow_init_sigma = getattr(self.config, "flow_init_sigma", 1.0)
|
| 1176 |
+
if temperature is None:
|
| 1177 |
+
temperature = getattr(self.config, "flow_temperature", 1.0)
|
| 1178 |
+
if top_p is None:
|
| 1179 |
+
top_p = getattr(self.config, "flow_top_p", 1.0)
|
| 1180 |
+
if top_k is None:
|
| 1181 |
+
top_k = getattr(self.config, "flow_top_k", 0)
|
| 1182 |
+
if pad_token_id is None:
|
| 1183 |
+
pad_token_id = self.config.pad_token_id
|
| 1184 |
+
if eos_token_id is None:
|
| 1185 |
+
eos_token_id = self.config.eos_token_id
|
| 1186 |
+
|
| 1187 |
+
# Call Flow Matching generation
|
| 1188 |
+
result = self.generate_wedlm(
|
| 1189 |
+
input_ids=input_ids,
|
| 1190 |
+
max_new_tokens=max_new_tokens,
|
| 1191 |
+
block_size=block_size,
|
| 1192 |
+
num_steps=num_steps,
|
| 1193 |
+
flow_init_sigma=flow_init_sigma,
|
| 1194 |
+
discretization=discretization,
|
| 1195 |
+
temperature=temperature,
|
| 1196 |
+
top_p=top_p,
|
| 1197 |
+
top_k=top_k,
|
| 1198 |
+
pad_token_id=pad_token_id,
|
| 1199 |
+
eos_token_id=eos_token_id,
|
| 1200 |
+
return_stats=False,
|
| 1201 |
+
)
|
| 1202 |
+
|
| 1203 |
+
# Handle streamer if provided (basic support)
|
| 1204 |
+
if streamer is not None:
|
| 1205 |
+
for token_id in result[0, input_ids.shape[1]:]:
|
| 1206 |
+
streamer.put(token_id.unsqueeze(0).unsqueeze(0))
|
| 1207 |
+
streamer.end()
|
| 1208 |
+
|
| 1209 |
+
return result
|
| 1210 |
+
|
| 1211 |
+
# ----------------------------
|
| 1212 |
+
# Forward
|
| 1213 |
+
# ----------------------------
|
| 1214 |
+
@can_return_tuple
|
| 1215 |
+
@auto_docstring
|
| 1216 |
+
def forward(
|
| 1217 |
+
self,
|
| 1218 |
+
input_ids: Optional[torch.LongTensor] = None,
|
| 1219 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 1220 |
+
position_ids: Optional[torch.LongTensor] = None,
|
| 1221 |
+
past_key_values: Optional[Cache] = None,
|
| 1222 |
+
inputs_embeds: Optional[torch.FloatTensor] = None,
|
| 1223 |
+
labels: Optional[torch.LongTensor] = None,
|
| 1224 |
+
use_cache: Optional[bool] = None,
|
| 1225 |
+
output_attentions: Optional[bool] = None,
|
| 1226 |
+
output_hidden_states: Optional[bool] = None,
|
| 1227 |
+
return_dict: Optional[bool] = None,
|
| 1228 |
+
cache_position: Optional[torch.LongTensor] = None,
|
| 1229 |
+
logits_to_keep: Union[int, torch.Tensor] = 0,
|
| 1230 |
+
# Flow Matching controls (training-time)
|
| 1231 |
+
flow_target_mask: Optional[torch.BoolTensor] = None,
|
| 1232 |
+
flow_timesteps: Optional[torch.FloatTensor] = None,
|
| 1233 |
+
flow_noise: Optional[torch.FloatTensor] = None,
|
| 1234 |
+
return_logits: bool = False,
|
| 1235 |
+
**kwargs: Unpack[TransformersKwargs],
|
| 1236 |
+
) -> Union[Tuple, CausalLMOutputWithPast]:
|
| 1237 |
+
"""
|
| 1238 |
+
When `labels` is provided: computes Flow Matching loss.
|
| 1239 |
+
Otherwise: returns logits like a standard causal LM.
|
| 1240 |
+
|
| 1241 |
+
Args:
|
| 1242 |
+
flow_target_mask (`torch.BoolTensor`, *optional*):
|
| 1243 |
+
Boolean mask indicating which positions are flow targets.
|
| 1244 |
+
flow_timesteps (`torch.FloatTensor`, *optional*):
|
| 1245 |
+
Timesteps for flow matching, in range [0, 1].
|
| 1246 |
+
flow_noise (`torch.FloatTensor`, *optional*):
|
| 1247 |
+
Noise tensor for flow matching interpolation.
|
| 1248 |
+
return_logits (`bool`, defaults to `False`):
|
| 1249 |
+
If True, also compute vocabulary logits during Flow-Matching training.
|
| 1250 |
+
"""
|
| 1251 |
+
output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
|
| 1252 |
+
output_hidden_states = (
|
| 1253 |
+
output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
|
| 1254 |
+
)
|
| 1255 |
+
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
| 1256 |
+
|
| 1257 |
+
# ------------------------------------------------------------
|
| 1258 |
+
# Flow Matching training path (primary)
|
| 1259 |
+
# ------------------------------------------------------------
|
| 1260 |
+
if labels is not None:
|
| 1261 |
+
if input_ids is None:
|
| 1262 |
+
raise ValueError("Flow-Matching training requires input_ids (token IDs) when labels is provided.")
|
| 1263 |
+
|
| 1264 |
+
if inputs_embeds is not None:
|
| 1265 |
+
raise ValueError("Do not pass inputs_embeds when training with labels; Flow-Matching builds embeds internally.")
|
| 1266 |
+
|
| 1267 |
+
inputs_embeds, target_mask, t, noise, clean_embeds = self._build_flow_inputs(
|
| 1268 |
+
input_ids=input_ids,
|
| 1269 |
+
attention_mask=attention_mask,
|
| 1270 |
+
labels=labels,
|
| 1271 |
+
flow_target_mask=flow_target_mask,
|
| 1272 |
+
flow_timesteps=flow_timesteps,
|
| 1273 |
+
flow_noise=flow_noise,
|
| 1274 |
+
)
|
| 1275 |
+
|
| 1276 |
+
outputs = self.model(
|
| 1277 |
+
input_ids=None,
|
| 1278 |
+
attention_mask=attention_mask,
|
| 1279 |
+
position_ids=position_ids,
|
| 1280 |
+
past_key_values=past_key_values,
|
| 1281 |
+
inputs_embeds=inputs_embeds,
|
| 1282 |
+
use_cache=use_cache,
|
| 1283 |
+
output_attentions=output_attentions,
|
| 1284 |
+
output_hidden_states=output_hidden_states,
|
| 1285 |
+
return_dict=True,
|
| 1286 |
+
cache_position=cache_position,
|
| 1287 |
+
**kwargs,
|
| 1288 |
+
)
|
| 1289 |
+
|
| 1290 |
+
hidden_states = outputs.last_hidden_state
|
| 1291 |
+
loss = None
|
| 1292 |
+
logits = None
|
| 1293 |
+
|
| 1294 |
+
if target_mask.any():
|
| 1295 |
+
# Target velocity: d/dt X_t = X_1 - X_0 (data - noise) on straight-line path.
|
| 1296 |
+
v_target = (clean_embeds.to(dtype=torch.float32) - noise.to(dtype=torch.float32))[target_mask]
|
| 1297 |
+
# PEFT/LoRA can wrap `flow_head` and keep base weights in bf16/fp16.
|
| 1298 |
+
# Ensure dtype alignment for the Linear matmul.
|
| 1299 |
+
hs = hidden_states[target_mask]
|
| 1300 |
+
base_flow = getattr(self.flow_head, "base_layer", self.flow_head)
|
| 1301 |
+
w_flow = getattr(base_flow, "weight", None)
|
| 1302 |
+
if w_flow is not None:
|
| 1303 |
+
hs = hs.to(dtype=w_flow.dtype)
|
| 1304 |
+
v_pred = self.flow_head(hs).to(dtype=torch.float32)
|
| 1305 |
+
flow_loss = F.mse_loss(v_pred, v_target, reduction="mean")
|
| 1306 |
+
|
| 1307 |
+
w = float(getattr(self.config, "flow_loss_weight", 1.0))
|
| 1308 |
+
loss = w * flow_loss
|
| 1309 |
+
else:
|
| 1310 |
+
# No valid targets -> zero loss (avoid NaNs).
|
| 1311 |
+
loss = hidden_states.new_tensor(0.0)
|
| 1312 |
+
|
| 1313 |
+
if return_logits:
|
| 1314 |
+
slice_indices = slice(-logits_to_keep, None) if isinstance(logits_to_keep, int) else logits_to_keep
|
| 1315 |
+
logits = self.lm_head(hidden_states[:, slice_indices, :])
|
| 1316 |
+
|
| 1317 |
+
if not return_dict:
|
| 1318 |
+
output = (logits,) + (outputs.past_key_values, outputs.hidden_states, outputs.attentions)
|
| 1319 |
+
return (loss,) + output
|
| 1320 |
+
|
| 1321 |
+
return CausalLMOutputWithPast(
|
| 1322 |
+
loss=loss,
|
| 1323 |
+
logits=logits,
|
| 1324 |
+
past_key_values=outputs.past_key_values,
|
| 1325 |
+
hidden_states=outputs.hidden_states,
|
| 1326 |
+
attentions=outputs.attentions,
|
| 1327 |
+
)
|
| 1328 |
+
|
| 1329 |
+
# ------------------------------------------------------------
|
| 1330 |
+
# Standard causal LM path (no labels): logits for evaluation / AR generation
|
| 1331 |
+
# ------------------------------------------------------------
|
| 1332 |
+
outputs = self.model(
|
| 1333 |
+
input_ids=input_ids,
|
| 1334 |
+
attention_mask=attention_mask,
|
| 1335 |
+
position_ids=position_ids,
|
| 1336 |
+
past_key_values=past_key_values,
|
| 1337 |
+
inputs_embeds=inputs_embeds,
|
| 1338 |
+
use_cache=use_cache,
|
| 1339 |
+
output_attentions=output_attentions,
|
| 1340 |
+
output_hidden_states=output_hidden_states,
|
| 1341 |
+
return_dict=True,
|
| 1342 |
+
cache_position=cache_position,
|
| 1343 |
+
**kwargs,
|
| 1344 |
+
)
|
| 1345 |
+
|
| 1346 |
+
hidden_states = outputs.last_hidden_state
|
| 1347 |
+
slice_indices = slice(-logits_to_keep, None) if isinstance(logits_to_keep, int) else logits_to_keep
|
| 1348 |
+
logits = self.lm_head(hidden_states[:, slice_indices, :])
|
| 1349 |
+
|
| 1350 |
+
if not return_dict:
|
| 1351 |
+
output = (logits,) + (outputs.past_key_values, outputs.hidden_states, outputs.attentions)
|
| 1352 |
+
return output
|
| 1353 |
+
|
| 1354 |
+
return CausalLMOutputWithPast(
|
| 1355 |
+
loss=None,
|
| 1356 |
+
logits=logits,
|
| 1357 |
+
past_key_values=outputs.past_key_values,
|
| 1358 |
+
hidden_states=outputs.hidden_states,
|
| 1359 |
+
attentions=outputs.attentions,
|
| 1360 |
+
)
|
| 1361 |
+
|
| 1362 |
+
def prepare_inputs_for_generation(
|
| 1363 |
+
self,
|
| 1364 |
+
input_ids,
|
| 1365 |
+
past_key_values=None,
|
| 1366 |
+
attention_mask=None,
|
| 1367 |
+
inputs_embeds=None,
|
| 1368 |
+
cache_position=None,
|
| 1369 |
+
position_ids=None,
|
| 1370 |
+
use_cache=True,
|
| 1371 |
+
**kwargs,
|
| 1372 |
+
):
|
| 1373 |
+
if past_key_values is not None:
|
| 1374 |
+
if inputs_embeds is not None:
|
| 1375 |
+
input_ids = input_ids[:, -cache_position.shape[0] :]
|
| 1376 |
+
elif input_ids.shape[1] != cache_position.shape[0]:
|
| 1377 |
+
input_ids = input_ids[:, cache_position]
|
| 1378 |
+
|
| 1379 |
+
if attention_mask is not None and position_ids is None:
|
| 1380 |
+
position_ids = attention_mask.long().cumsum(-1) - 1
|
| 1381 |
+
position_ids.masked_fill_(attention_mask == 0, 1)
|
| 1382 |
+
if past_key_values:
|
| 1383 |
+
position_ids = position_ids[:, -input_ids.shape[1] :]
|
| 1384 |
+
|
| 1385 |
+
if inputs_embeds is not None and cache_position is not None and cache_position[0] == 0:
|
| 1386 |
+
model_inputs = {"inputs_embeds": inputs_embeds, "input_ids": None}
|
| 1387 |
+
else:
|
| 1388 |
+
model_inputs = {"input_ids": input_ids.clone(memory_format=torch.contiguous_format), "inputs_embeds": None}
|
| 1389 |
+
|
| 1390 |
+
if isinstance(past_key_values, DynamicCache) and attention_mask is not None and attention_mask.ndim == 2:
|
| 1391 |
+
model_inputs["cache_position"] = cache_position
|
| 1392 |
+
model_inputs["past_key_values"] = past_key_values
|
| 1393 |
+
model_inputs["use_cache"] = use_cache
|
| 1394 |
+
model_inputs["position_ids"] = position_ids
|
| 1395 |
+
model_inputs["attention_mask"] = attention_mask
|
| 1396 |
+
return model_inputs
|
| 1397 |
+
|
| 1398 |
+
model_inputs.update(
|
| 1399 |
+
{
|
| 1400 |
+
"position_ids": position_ids,
|
| 1401 |
+
"cache_position": cache_position,
|
| 1402 |
+
"past_key_values": past_key_values,
|
| 1403 |
+
"use_cache": use_cache,
|
| 1404 |
+
"attention_mask": attention_mask,
|
| 1405 |
+
}
|
| 1406 |
+
)
|
| 1407 |
+
return model_inputs
|
| 1408 |
+
__all__ = [
|
| 1409 |
+
"WeDLMConfig",
|
| 1410 |
+
"WeDLMPreTrainedModel",
|
| 1411 |
+
"WeDLMModel",
|
| 1412 |
+
"WeDLMForCausalLM",
|
| 1413 |
+
]
|
rng_state.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:108db0d4e8d8ed107b35f6ffdcd77ee19afcbe48dc85028d0a1e8183711f9f09
|
| 3 |
+
size 14645
|
scheduler.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:42e9219815c2d61b06323505ac5005df2ca14a06cf5c78e49b16fb6955b87d0a
|
| 3 |
+
size 1465
|
special_tokens_map.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
"pad_token": {
|
| 25 |
+
"content": "<|endoftext|>",
|
| 26 |
+
"lstrip": false,
|
| 27 |
+
"normalized": false,
|
| 28 |
+
"rstrip": false,
|
| 29 |
+
"single_word": false
|
| 30 |
+
}
|
| 31 |
+
}
|
tokenizer.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9c5ae00e602b8860cbd784ba82a8aa14e8feecec692e7076590d014d7b7fdafa
|
| 3 |
+
size 11421896
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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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 |
+
},
|
| 182 |
+
"additional_special_tokens": [
|
| 183 |
+
"<|im_start|>",
|
| 184 |
+
"<|im_end|>",
|
| 185 |
+
"<|object_ref_start|>",
|
| 186 |
+
"<|object_ref_end|>",
|
| 187 |
+
"<|box_start|>",
|
| 188 |
+
"<|box_end|>",
|
| 189 |
+
"<|quad_start|>",
|
| 190 |
+
"<|quad_end|>",
|
| 191 |
+
"<|vision_start|>",
|
| 192 |
+
"<|vision_end|>",
|
| 193 |
+
"<|vision_pad|>",
|
| 194 |
+
"<|image_pad|>",
|
| 195 |
+
"<|video_pad|>"
|
| 196 |
+
],
|
| 197 |
+
"bos_token": null,
|
| 198 |
+
"clean_up_tokenization_spaces": false,
|
| 199 |
+
"eos_token": "<|im_end|>",
|
| 200 |
+
"errors": "replace",
|
| 201 |
+
"extra_special_tokens": {},
|
| 202 |
+
"model_max_length": 131072,
|
| 203 |
+
"pad_token": "<|endoftext|>",
|
| 204 |
+
"padding_side": "right",
|
| 205 |
+
"split_special_tokens": false,
|
| 206 |
+
"tokenizer_class": "Qwen2Tokenizer",
|
| 207 |
+
"unk_token": null
|
| 208 |
+
}
|
trainer_state.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
training_args.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:21750e26594e68a9f7abef3a2a5ab962cd29d4f70adcc6082fab5de2ffe0cdcd
|
| 3 |
+
size 6289
|
vocab.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|