init
Browse files- .gitattributes +1 -34
- added_tokens.json +24 -0
- chat_template.jinja +54 -0
- config.json +83 -0
- configuration_moss_speech.py +258 -0
- generation_config.json +4 -0
- merges.txt +0 -0
- model-00001-of-00004.safetensors +3 -0
- model-00002-of-00004.safetensors +3 -0
- model-00003-of-00004.safetensors +3 -0
- model-00004-of-00004.safetensors +3 -0
- model.safetensors.index.json +454 -0
- modeling_moss_speech.py +1132 -0
- processing_moss_speech.py +419 -0
- special_tokens_map.json +31 -0
- tokenizer.json +3 -0
- tokenizer_config.json +207 -0
- vocab.json +0 -0
.gitattributes
CHANGED
|
@@ -1,35 +1,2 @@
|
|
| 1 |
-
*.7z filter=lfs diff=lfs merge=lfs -text
|
| 2 |
-
*.arrow filter=lfs diff=lfs merge=lfs -text
|
| 3 |
-
*.bin filter=lfs diff=lfs merge=lfs -text
|
| 4 |
-
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
| 5 |
-
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
| 6 |
-
*.ftz filter=lfs diff=lfs merge=lfs -text
|
| 7 |
-
*.gz filter=lfs diff=lfs merge=lfs -text
|
| 8 |
-
*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 9 |
-
*.joblib filter=lfs diff=lfs merge=lfs -text
|
| 10 |
-
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
| 11 |
-
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
| 12 |
-
*.model filter=lfs diff=lfs merge=lfs -text
|
| 13 |
-
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
| 14 |
-
*.npy filter=lfs diff=lfs merge=lfs -text
|
| 15 |
-
*.npz filter=lfs diff=lfs merge=lfs -text
|
| 16 |
-
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 17 |
-
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 18 |
-
*.parquet filter=lfs diff=lfs merge=lfs -text
|
| 19 |
-
*.pb filter=lfs diff=lfs merge=lfs -text
|
| 20 |
-
*.pickle filter=lfs diff=lfs merge=lfs -text
|
| 21 |
-
*.pkl filter=lfs diff=lfs merge=lfs -text
|
| 22 |
-
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 23 |
-
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 24 |
-
*.rar filter=lfs diff=lfs merge=lfs -text
|
| 25 |
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 26 |
-
|
| 27 |
-
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
| 28 |
-
*.tar filter=lfs diff=lfs merge=lfs -text
|
| 29 |
-
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 30 |
-
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 31 |
-
*.wasm filter=lfs diff=lfs merge=lfs -text
|
| 32 |
-
*.xz filter=lfs diff=lfs merge=lfs -text
|
| 33 |
-
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
-
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
-
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 2 |
+
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 Qwen, created by Alibaba Cloud. 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 Qwen, created by Alibaba Cloud. You 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,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"MossSpeechForCausalLM"
|
| 4 |
+
],
|
| 5 |
+
"attention_bias": false,
|
| 6 |
+
"attention_dropout": 0.0,
|
| 7 |
+
"audio_pad_token_id": 512,
|
| 8 |
+
"audio_vocab_size": 16512,
|
| 9 |
+
"auto_map": {
|
| 10 |
+
"AutoConfig": "configuration_moss_speech.MossSpeechConfig",
|
| 11 |
+
"AutoModel": "modeling_moss_speech.MossSpeechForCausalLM"
|
| 12 |
+
},
|
| 13 |
+
"channels": 2,
|
| 14 |
+
"dtype": "bfloat16",
|
| 15 |
+
"eos_token_id": 151645,
|
| 16 |
+
"eosp_token_id": 16384,
|
| 17 |
+
"head_dim": 128,
|
| 18 |
+
"hidden_act": "silu",
|
| 19 |
+
"hidden_size": 4096,
|
| 20 |
+
"initializer_range": 0.02,
|
| 21 |
+
"intermediate_size": 12288,
|
| 22 |
+
"layer_types": [
|
| 23 |
+
"full_attention",
|
| 24 |
+
"full_attention",
|
| 25 |
+
"full_attention",
|
| 26 |
+
"full_attention",
|
| 27 |
+
"full_attention",
|
| 28 |
+
"full_attention",
|
| 29 |
+
"full_attention",
|
| 30 |
+
"full_attention",
|
| 31 |
+
"full_attention",
|
| 32 |
+
"full_attention",
|
| 33 |
+
"full_attention",
|
| 34 |
+
"full_attention",
|
| 35 |
+
"full_attention",
|
| 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 |
+
],
|
| 60 |
+
"max_position_embeddings": 40960,
|
| 61 |
+
"max_window_layers": null,
|
| 62 |
+
"modality_pad_token_id": 151667,
|
| 63 |
+
"model_type": "moss_speech",
|
| 64 |
+
"num_attention_heads": 32,
|
| 65 |
+
"num_hidden_layers": 36,
|
| 66 |
+
"num_key_value_heads": 8,
|
| 67 |
+
"num_modality_layers": 4,
|
| 68 |
+
"num_shared_layers": 32,
|
| 69 |
+
"rms_norm_eps": 1e-06,
|
| 70 |
+
"rope_scaling": null,
|
| 71 |
+
"rope_theta": 1000000,
|
| 72 |
+
"sliding_window": null,
|
| 73 |
+
"sosp_token_id": 151646,
|
| 74 |
+
"tie_word_embeddings": false,
|
| 75 |
+
"transformers_version": "4.57.0.dev0",
|
| 76 |
+
"use_cache": true,
|
| 77 |
+
"use_sliding_window": false,
|
| 78 |
+
"vocab_size": 151680,
|
| 79 |
+
"vocab_size_list": [
|
| 80 |
+
151680,
|
| 81 |
+
16512
|
| 82 |
+
]
|
| 83 |
+
}
|
configuration_moss_speech.py
ADDED
|
@@ -0,0 +1,258 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨
|
| 2 |
+
# This file was automatically generated from src/transformers/models/moss_speech/modular_moss_speech.py.
|
| 3 |
+
# Do NOT edit this file manually as any edits will be overwritten by the generation of
|
| 4 |
+
# the file from the modular. If any change should be done, please apply the change to the
|
| 5 |
+
# modular_moss_speech.py file directly. One of our CI enforces this.
|
| 6 |
+
# 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨
|
| 7 |
+
# coding=utf-8
|
| 8 |
+
# Copyright 2025 the HuggingFace Team. All rights reserved.
|
| 9 |
+
#
|
| 10 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 11 |
+
# you may not use this file except in compliance with the License.
|
| 12 |
+
# You may obtain a copy of the License at
|
| 13 |
+
#
|
| 14 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 15 |
+
#
|
| 16 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 17 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 18 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 19 |
+
# See the License for the specific language governing permissions and
|
| 20 |
+
# limitations under the License.
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
from transformers.configuration_utils import PretrainedConfig, layer_type_validation
|
| 24 |
+
from transformers.modeling_rope_utils import rope_config_validation
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
class MossSpeechConfig(PretrainedConfig):
|
| 28 |
+
r"""
|
| 29 |
+
This is the configuration class to store the configuration of a [`MossSpeechModel`]. It is used to instantiate a
|
| 30 |
+
MossSpeech model according to the specified arguments, defining the model architecture. Instantiating a configuration
|
| 31 |
+
with the defaults will yield a similar configuration to that of
|
| 32 |
+
MossSpeech-8B [Qwen/MossSpeech-8B](https://huggingface.co/Qwen/MossSpeech-8B).
|
| 33 |
+
|
| 34 |
+
Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
|
| 35 |
+
documentation from [`PretrainedConfig`] for more information.
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
Args:
|
| 39 |
+
vocab_size (`int`, *optional*, defaults to 151680):
|
| 40 |
+
Vocabulary size of the MossSpeech model. Defines the number of different tokens that can be represented by the
|
| 41 |
+
`inputs_ids` passed when calling [`MossSpeechModel`].
|
| 42 |
+
hidden_size (`int`, *optional*, defaults to 4096):
|
| 43 |
+
Dimension of the hidden representations.
|
| 44 |
+
intermediate_size (`int`, *optional*, defaults to 12288):
|
| 45 |
+
Dimension of the MLP representations.
|
| 46 |
+
num_hidden_layers (`int`, *optional*, defaults to 36):
|
| 47 |
+
Number of hidden layers in the Transformer encoder.
|
| 48 |
+
num_attention_heads (`int`, *optional*, defaults to 32):
|
| 49 |
+
Number of attention heads for each attention layer in the Transformer encoder.
|
| 50 |
+
num_key_value_heads (`int`, *optional*, defaults to 8):
|
| 51 |
+
This is the number of key_value heads that should be used to implement Grouped Query Attention. If
|
| 52 |
+
`num_key_value_heads=num_attention_heads`, the model will use Multi Head Attention (MHA), if
|
| 53 |
+
`num_key_value_heads=1` the model will use Multi Query Attention (MQA) otherwise GQA is used. When
|
| 54 |
+
converting a multi-head checkpoint to a GQA checkpoint, each group key and value head should be constructed
|
| 55 |
+
by meanpooling all the original heads within that group. For more details, check out [this
|
| 56 |
+
paper](https://huggingface.co/papers/2305.13245). If it is not specified, will default to `32`.
|
| 57 |
+
head_dim (`int`, *optional*, defaults to 128):
|
| 58 |
+
The attention head dimension.
|
| 59 |
+
hidden_act (`str` or `function`, *optional*, defaults to `"silu"`):
|
| 60 |
+
The non-linear activation function (function or string) in the decoder.
|
| 61 |
+
max_position_embeddings (`int`, *optional*, defaults to 40960):
|
| 62 |
+
The maximum sequence length that this model might ever be used with.
|
| 63 |
+
initializer_range (`float`, *optional*, defaults to 0.02):
|
| 64 |
+
The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
|
| 65 |
+
rms_norm_eps (`float`, *optional*, defaults to 1e-06):
|
| 66 |
+
The epsilon used by the rms normalization layers.
|
| 67 |
+
use_cache (`bool`, *optional*, defaults to `True`):
|
| 68 |
+
Whether or not the model should return the last key/values attentions (not used by all models). Only
|
| 69 |
+
relevant if `config.is_decoder=True`.
|
| 70 |
+
tie_word_embeddings (`bool`, *optional*, defaults to `False`):
|
| 71 |
+
Whether the model's input and output word embeddings should be tied.
|
| 72 |
+
rope_theta (`float`, *optional*, defaults to 10000.0):
|
| 73 |
+
The base period of the RoPE embeddings.
|
| 74 |
+
rope_scaling (`Dict`, *optional*):
|
| 75 |
+
Dictionary containing the scaling configuration for the RoPE embeddings. NOTE: if you apply new rope type
|
| 76 |
+
and you expect the model to work on longer `max_position_embeddings`, we recommend you to update this value
|
| 77 |
+
accordingly.
|
| 78 |
+
Expected contents:
|
| 79 |
+
`rope_type` (`str`):
|
| 80 |
+
The sub-variant of RoPE to use. Can be one of ['default', 'linear', 'dynamic', 'yarn', 'longrope',
|
| 81 |
+
'llama3'], with 'default' being the original RoPE implementation.
|
| 82 |
+
`factor` (`float`, *optional*):
|
| 83 |
+
Used with all rope types except 'default'. The scaling factor to apply to the RoPE embeddings. In
|
| 84 |
+
most scaling types, a `factor` of x will enable the model to handle sequences of length x *
|
| 85 |
+
original maximum pre-trained length.
|
| 86 |
+
`original_max_position_embeddings` (`int`, *optional*):
|
| 87 |
+
Used with 'dynamic', 'longrope' and 'llama3'. The original max position embeddings used during
|
| 88 |
+
pretraining.
|
| 89 |
+
`attention_factor` (`float`, *optional*):
|
| 90 |
+
Used with 'yarn' and 'longrope'. The scaling factor to be applied on the attention
|
| 91 |
+
computation. If unspecified, it defaults to value recommended by the implementation, using the
|
| 92 |
+
`factor` field to infer the suggested value.
|
| 93 |
+
`beta_fast` (`float`, *optional*):
|
| 94 |
+
Only used with 'yarn'. Parameter to set the boundary for extrapolation (only) in the linear
|
| 95 |
+
ramp function. If unspecified, it defaults to 32.
|
| 96 |
+
`beta_slow` (`float`, *optional*):
|
| 97 |
+
Only used with 'yarn'. Parameter to set the boundary for interpolation (only) in the linear
|
| 98 |
+
ramp function. If unspecified, it defaults to 1.
|
| 99 |
+
`short_factor` (`list[float]`, *optional*):
|
| 100 |
+
Only used with 'longrope'. The scaling factor to be applied to short contexts (<
|
| 101 |
+
`original_max_position_embeddings`). Must be a list of numbers with the same length as the hidden
|
| 102 |
+
size divided by the number of attention heads divided by 2
|
| 103 |
+
`long_factor` (`list[float]`, *optional*):
|
| 104 |
+
Only used with 'longrope'. The scaling factor to be applied to long contexts (<
|
| 105 |
+
`original_max_position_embeddings`). Must be a list of numbers with the same length as the hidden
|
| 106 |
+
size divided by the number of attention heads divided by 2
|
| 107 |
+
`low_freq_factor` (`float`, *optional*):
|
| 108 |
+
Only used with 'llama3'. Scaling factor applied to low frequency components of the RoPE
|
| 109 |
+
`high_freq_factor` (`float`, *optional*):
|
| 110 |
+
Only used with 'llama3'. Scaling factor applied to high frequency components of the RoPE
|
| 111 |
+
attention_bias (`bool`, *optional*, defaults to `False`):
|
| 112 |
+
Whether to use a bias in the query, key, value and output projection layers during self-attention.
|
| 113 |
+
use_sliding_window (`bool`, *optional*, defaults to `False`):
|
| 114 |
+
Whether to use sliding window attention.
|
| 115 |
+
sliding_window (`int`, *optional*):
|
| 116 |
+
Sliding window attention (SWA) window size. Only used when `use_sliding_window=True`.
|
| 117 |
+
max_window_layers (`int`, *optional*):
|
| 118 |
+
Number of initial layers using full attention. Layers after `max_window_layers` (if any) use SWA.
|
| 119 |
+
layer_types (`list`, *optional*):
|
| 120 |
+
Attention pattern for each layer.
|
| 121 |
+
attention_dropout (`float`, *optional*, defaults to 0.0):
|
| 122 |
+
The dropout ratio for the attention probabilities.
|
| 123 |
+
|
| 124 |
+
audio_vocab_size (`int`, *optional*):
|
| 125 |
+
Vocabulary size for the audio branch used by the audio language modeling head.
|
| 126 |
+
modality_pad_token_id (`int`, *optional*, defaults to 0):
|
| 127 |
+
Token id used to pad the inactive modality channel when generating.
|
| 128 |
+
sosp_token_id (`int`, *optional*):
|
| 129 |
+
Start-of-speech special token id used by the processor and generation logic.
|
| 130 |
+
eosp_token_id (`int`, *optional*):
|
| 131 |
+
End-of-speech special token id used by the processor and generation logic.
|
| 132 |
+
num_shared_layers (`int`, *optional*, defaults to 32):
|
| 133 |
+
Number of shared decoder layers applied before splitting into modality-specific blocks.
|
| 134 |
+
num_modality_layers (`int`, *optional*, defaults to 4):
|
| 135 |
+
Number of decoder layers per modality after the shared block.
|
| 136 |
+
|
| 137 |
+
```python
|
| 138 |
+
>>> from transformers import MossSpeechModel, MossSpeechConfig
|
| 139 |
+
|
| 140 |
+
>>> # Initializing a MossSpeech style configuration
|
| 141 |
+
>>> configuration = MossSpeechConfig()
|
| 142 |
+
|
| 143 |
+
>>> # Initializing a model from the MossSpeech-8B style configuration
|
| 144 |
+
>>> model = MossSpeechModel(configuration)
|
| 145 |
+
|
| 146 |
+
>>> # Accessing the model configuration
|
| 147 |
+
>>> configuration = model.config
|
| 148 |
+
```"""
|
| 149 |
+
|
| 150 |
+
model_type = "moss_speech"
|
| 151 |
+
keys_to_ignore_at_inference = ["past_key_values"]
|
| 152 |
+
|
| 153 |
+
# Default tensor parallel plan for base model `MossSpeech`
|
| 154 |
+
base_model_tp_plan = {
|
| 155 |
+
"layers.*.self_attn.q_proj": "colwise",
|
| 156 |
+
"layers.*.self_attn.k_proj": "colwise",
|
| 157 |
+
"layers.*.self_attn.v_proj": "colwise",
|
| 158 |
+
"layers.*.self_attn.o_proj": "rowwise",
|
| 159 |
+
"layers.*.mlp.gate_proj": "colwise",
|
| 160 |
+
"layers.*.mlp.up_proj": "colwise",
|
| 161 |
+
"layers.*.mlp.down_proj": "rowwise",
|
| 162 |
+
}
|
| 163 |
+
base_model_pp_plan = {
|
| 164 |
+
"embed_tokens": (["input_ids"], ["inputs_embeds"]),
|
| 165 |
+
"layers": (["hidden_states", "attention_mask"], ["hidden_states"]),
|
| 166 |
+
"norm": (["hidden_states"], ["hidden_states"]),
|
| 167 |
+
}
|
| 168 |
+
|
| 169 |
+
def __init__(
|
| 170 |
+
self,
|
| 171 |
+
vocab_size=151680,
|
| 172 |
+
hidden_size=4096,
|
| 173 |
+
intermediate_size=12288,
|
| 174 |
+
num_hidden_layers=36,
|
| 175 |
+
num_attention_heads=32,
|
| 176 |
+
num_key_value_heads=8,
|
| 177 |
+
head_dim=128,
|
| 178 |
+
hidden_act="silu",
|
| 179 |
+
max_position_embeddings=40960,
|
| 180 |
+
initializer_range=0.02,
|
| 181 |
+
rms_norm_eps=1e-6,
|
| 182 |
+
use_cache=True,
|
| 183 |
+
tie_word_embeddings=False,
|
| 184 |
+
rope_theta=10000.0,
|
| 185 |
+
rope_scaling=None,
|
| 186 |
+
attention_bias=False,
|
| 187 |
+
use_sliding_window=False,
|
| 188 |
+
sliding_window=None,
|
| 189 |
+
max_window_layers=None,
|
| 190 |
+
layer_types=None,
|
| 191 |
+
attention_dropout=0.0,
|
| 192 |
+
audio_vocab_size=None,
|
| 193 |
+
modality_pad_token_id=0,
|
| 194 |
+
sosp_token_id=None,
|
| 195 |
+
eosp_token_id=None,
|
| 196 |
+
num_shared_layers=32,
|
| 197 |
+
num_modality_layers=4,
|
| 198 |
+
**kwargs,
|
| 199 |
+
):
|
| 200 |
+
assert num_shared_layers + num_modality_layers == num_hidden_layers, (
|
| 201 |
+
f"num_shared_layers ({num_shared_layers}) + num_modality_layers ({num_modality_layers}) must equal to num_hidden_layers ({num_hidden_layers})"
|
| 202 |
+
)
|
| 203 |
+
self.vocab_size = vocab_size
|
| 204 |
+
self.max_position_embeddings = max_position_embeddings
|
| 205 |
+
self.hidden_size = hidden_size
|
| 206 |
+
self.intermediate_size = intermediate_size
|
| 207 |
+
self.num_hidden_layers = num_hidden_layers
|
| 208 |
+
self.num_attention_heads = num_attention_heads
|
| 209 |
+
self.use_sliding_window = use_sliding_window
|
| 210 |
+
self.sliding_window = sliding_window if self.use_sliding_window else None
|
| 211 |
+
self.max_window_layers = max_window_layers
|
| 212 |
+
|
| 213 |
+
self.audio_vocab_size = audio_vocab_size
|
| 214 |
+
self.modality_pad_token_id = int(modality_pad_token_id)
|
| 215 |
+
self.sosp_token_id = None if sosp_token_id is None else int(sosp_token_id)
|
| 216 |
+
self.eosp_token_id = None if eosp_token_id is None else int(eosp_token_id)
|
| 217 |
+
self.num_shared_layers = int(num_shared_layers)
|
| 218 |
+
self.num_modality_layers = int(num_modality_layers)
|
| 219 |
+
|
| 220 |
+
# for backward compatibility
|
| 221 |
+
if num_key_value_heads is None:
|
| 222 |
+
num_key_value_heads = num_attention_heads
|
| 223 |
+
|
| 224 |
+
self.num_key_value_heads = num_key_value_heads
|
| 225 |
+
self.head_dim = head_dim
|
| 226 |
+
self.hidden_act = hidden_act
|
| 227 |
+
self.initializer_range = initializer_range
|
| 228 |
+
self.rms_norm_eps = rms_norm_eps
|
| 229 |
+
self.use_cache = use_cache
|
| 230 |
+
self.rope_theta = rope_theta
|
| 231 |
+
self.rope_scaling = rope_scaling
|
| 232 |
+
self.attention_bias = attention_bias
|
| 233 |
+
self.attention_dropout = attention_dropout
|
| 234 |
+
# Validate the correctness of rotary position embeddings parameters
|
| 235 |
+
# BC: if there is a 'type' field, move it to 'rope_type'.
|
| 236 |
+
if self.rope_scaling is not None and "type" in self.rope_scaling:
|
| 237 |
+
self.rope_scaling["rope_type"] = self.rope_scaling["type"]
|
| 238 |
+
rope_config_validation(self)
|
| 239 |
+
|
| 240 |
+
self.layer_types = layer_types
|
| 241 |
+
if self.layer_types is None:
|
| 242 |
+
self.layer_types = [
|
| 243 |
+
(
|
| 244 |
+
"sliding_attention"
|
| 245 |
+
if self.sliding_window is not None and i >= self.max_window_layers
|
| 246 |
+
else "full_attention"
|
| 247 |
+
)
|
| 248 |
+
for i in range(self.num_hidden_layers)
|
| 249 |
+
]
|
| 250 |
+
layer_type_validation(self.layer_types)
|
| 251 |
+
|
| 252 |
+
super().__init__(
|
| 253 |
+
tie_word_embeddings=tie_word_embeddings,
|
| 254 |
+
**kwargs,
|
| 255 |
+
)
|
| 256 |
+
|
| 257 |
+
|
| 258 |
+
__all__ = ["MossSpeechConfig"]
|
generation_config.json
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_from_model_config": true,
|
| 3 |
+
"transformers_version": "4.57.0.dev0"
|
| 4 |
+
}
|
merges.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
model-00001-of-00004.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0b0908b83517a51a1ae3eb2bc56432c61fc780318bc00502df8bfb189031c2d4
|
| 3 |
+
size 4934764904
|
model-00002-of-00004.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:24c9ebe8c47ac0d5feaf303fc927150442a19cfd818d82fda5be11cf225a063f
|
| 3 |
+
size 4983070312
|
model-00003-of-00004.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c64e43975193f66dbf5c36178c186a31450edf13250686eff7a381e3d4181826
|
| 3 |
+
size 4999848064
|
model-00004-of-00004.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c8aaf874776836e639c0682c854427eb65cb1b74eea670d885917d54d4d05983
|
| 3 |
+
size 3273762360
|
model.safetensors.index.json
ADDED
|
@@ -0,0 +1,454 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
| 7 |
+
"audio_lm_head.weight": "model-00004-of-00004.safetensors",
|
| 8 |
+
"model.audio_block.layers.0.input_layernorm.weight": "model-00004-of-00004.safetensors",
|
| 9 |
+
"model.audio_block.layers.0.mlp.down_proj.weight": "model-00004-of-00004.safetensors",
|
| 10 |
+
"model.audio_block.layers.0.mlp.gate_proj.weight": "model-00004-of-00004.safetensors",
|
| 11 |
+
"model.audio_block.layers.0.mlp.up_proj.weight": "model-00004-of-00004.safetensors",
|
| 12 |
+
"model.audio_block.layers.0.post_attention_layernorm.weight": "model-00004-of-00004.safetensors",
|
| 13 |
+
"model.audio_block.layers.0.self_attn.k_norm.weight": "model-00004-of-00004.safetensors",
|
| 14 |
+
"model.audio_block.layers.0.self_attn.k_proj.weight": "model-00004-of-00004.safetensors",
|
| 15 |
+
"model.audio_block.layers.0.self_attn.o_proj.weight": "model-00004-of-00004.safetensors",
|
| 16 |
+
"model.audio_block.layers.0.self_attn.q_norm.weight": "model-00004-of-00004.safetensors",
|
| 17 |
+
"model.audio_block.layers.0.self_attn.q_proj.weight": "model-00004-of-00004.safetensors",
|
| 18 |
+
"model.audio_block.layers.0.self_attn.v_proj.weight": "model-00004-of-00004.safetensors",
|
| 19 |
+
"model.audio_block.layers.1.input_layernorm.weight": "model-00004-of-00004.safetensors",
|
| 20 |
+
"model.audio_block.layers.1.mlp.down_proj.weight": "model-00004-of-00004.safetensors",
|
| 21 |
+
"model.audio_block.layers.1.mlp.gate_proj.weight": "model-00004-of-00004.safetensors",
|
| 22 |
+
"model.audio_block.layers.1.mlp.up_proj.weight": "model-00004-of-00004.safetensors",
|
| 23 |
+
"model.audio_block.layers.1.post_attention_layernorm.weight": "model-00004-of-00004.safetensors",
|
| 24 |
+
"model.audio_block.layers.1.self_attn.k_norm.weight": "model-00004-of-00004.safetensors",
|
| 25 |
+
"model.audio_block.layers.1.self_attn.k_proj.weight": "model-00004-of-00004.safetensors",
|
| 26 |
+
"model.audio_block.layers.1.self_attn.o_proj.weight": "model-00004-of-00004.safetensors",
|
| 27 |
+
"model.audio_block.layers.1.self_attn.q_norm.weight": "model-00004-of-00004.safetensors",
|
| 28 |
+
"model.audio_block.layers.1.self_attn.q_proj.weight": "model-00004-of-00004.safetensors",
|
| 29 |
+
"model.audio_block.layers.1.self_attn.v_proj.weight": "model-00004-of-00004.safetensors",
|
| 30 |
+
"model.audio_block.layers.2.input_layernorm.weight": "model-00004-of-00004.safetensors",
|
| 31 |
+
"model.audio_block.layers.2.mlp.down_proj.weight": "model-00004-of-00004.safetensors",
|
| 32 |
+
"model.audio_block.layers.2.mlp.gate_proj.weight": "model-00004-of-00004.safetensors",
|
| 33 |
+
"model.audio_block.layers.2.mlp.up_proj.weight": "model-00004-of-00004.safetensors",
|
| 34 |
+
"model.audio_block.layers.2.post_attention_layernorm.weight": "model-00004-of-00004.safetensors",
|
| 35 |
+
"model.audio_block.layers.2.self_attn.k_norm.weight": "model-00004-of-00004.safetensors",
|
| 36 |
+
"model.audio_block.layers.2.self_attn.k_proj.weight": "model-00004-of-00004.safetensors",
|
| 37 |
+
"model.audio_block.layers.2.self_attn.o_proj.weight": "model-00004-of-00004.safetensors",
|
| 38 |
+
"model.audio_block.layers.2.self_attn.q_norm.weight": "model-00004-of-00004.safetensors",
|
| 39 |
+
"model.audio_block.layers.2.self_attn.q_proj.weight": "model-00004-of-00004.safetensors",
|
| 40 |
+
"model.audio_block.layers.2.self_attn.v_proj.weight": "model-00004-of-00004.safetensors",
|
| 41 |
+
"model.audio_block.layers.3.input_layernorm.weight": "model-00004-of-00004.safetensors",
|
| 42 |
+
"model.audio_block.layers.3.mlp.down_proj.weight": "model-00004-of-00004.safetensors",
|
| 43 |
+
"model.audio_block.layers.3.mlp.gate_proj.weight": "model-00004-of-00004.safetensors",
|
| 44 |
+
"model.audio_block.layers.3.mlp.up_proj.weight": "model-00004-of-00004.safetensors",
|
| 45 |
+
"model.audio_block.layers.3.post_attention_layernorm.weight": "model-00004-of-00004.safetensors",
|
| 46 |
+
"model.audio_block.layers.3.self_attn.k_norm.weight": "model-00004-of-00004.safetensors",
|
| 47 |
+
"model.audio_block.layers.3.self_attn.k_proj.weight": "model-00004-of-00004.safetensors",
|
| 48 |
+
"model.audio_block.layers.3.self_attn.o_proj.weight": "model-00004-of-00004.safetensors",
|
| 49 |
+
"model.audio_block.layers.3.self_attn.q_norm.weight": "model-00004-of-00004.safetensors",
|
| 50 |
+
"model.audio_block.layers.3.self_attn.q_proj.weight": "model-00004-of-00004.safetensors",
|
| 51 |
+
"model.audio_block.layers.3.self_attn.v_proj.weight": "model-00004-of-00004.safetensors",
|
| 52 |
+
"model.audio_embed.weight": "model-00001-of-00004.safetensors",
|
| 53 |
+
"model.audio_norm.weight": "model-00004-of-00004.safetensors",
|
| 54 |
+
"model.embed_tokens.weight": "model-00001-of-00004.safetensors",
|
| 55 |
+
"model.shared_block.layers.0.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 56 |
+
"model.shared_block.layers.0.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 57 |
+
"model.shared_block.layers.0.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 58 |
+
"model.shared_block.layers.0.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 59 |
+
"model.shared_block.layers.0.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 60 |
+
"model.shared_block.layers.0.self_attn.k_norm.weight": "model-00001-of-00004.safetensors",
|
| 61 |
+
"model.shared_block.layers.0.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
|
| 62 |
+
"model.shared_block.layers.0.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
|
| 63 |
+
"model.shared_block.layers.0.self_attn.q_norm.weight": "model-00001-of-00004.safetensors",
|
| 64 |
+
"model.shared_block.layers.0.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
|
| 65 |
+
"model.shared_block.layers.0.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
|
| 66 |
+
"model.shared_block.layers.1.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 67 |
+
"model.shared_block.layers.1.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 68 |
+
"model.shared_block.layers.1.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 69 |
+
"model.shared_block.layers.1.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 70 |
+
"model.shared_block.layers.1.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 71 |
+
"model.shared_block.layers.1.self_attn.k_norm.weight": "model-00001-of-00004.safetensors",
|
| 72 |
+
"model.shared_block.layers.1.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
|
| 73 |
+
"model.shared_block.layers.1.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
|
| 74 |
+
"model.shared_block.layers.1.self_attn.q_norm.weight": "model-00001-of-00004.safetensors",
|
| 75 |
+
"model.shared_block.layers.1.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
|
| 76 |
+
"model.shared_block.layers.1.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
|
| 77 |
+
"model.shared_block.layers.10.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 78 |
+
"model.shared_block.layers.10.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
| 79 |
+
"model.shared_block.layers.10.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
| 80 |
+
"model.shared_block.layers.10.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
| 81 |
+
"model.shared_block.layers.10.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 82 |
+
"model.shared_block.layers.10.self_attn.k_norm.weight": "model-00002-of-00004.safetensors",
|
| 83 |
+
"model.shared_block.layers.10.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
| 84 |
+
"model.shared_block.layers.10.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
| 85 |
+
"model.shared_block.layers.10.self_attn.q_norm.weight": "model-00002-of-00004.safetensors",
|
| 86 |
+
"model.shared_block.layers.10.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
| 87 |
+
"model.shared_block.layers.10.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
| 88 |
+
"model.shared_block.layers.11.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 89 |
+
"model.shared_block.layers.11.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
| 90 |
+
"model.shared_block.layers.11.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
| 91 |
+
"model.shared_block.layers.11.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
| 92 |
+
"model.shared_block.layers.11.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 93 |
+
"model.shared_block.layers.11.self_attn.k_norm.weight": "model-00002-of-00004.safetensors",
|
| 94 |
+
"model.shared_block.layers.11.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
| 95 |
+
"model.shared_block.layers.11.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
| 96 |
+
"model.shared_block.layers.11.self_attn.q_norm.weight": "model-00002-of-00004.safetensors",
|
| 97 |
+
"model.shared_block.layers.11.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
| 98 |
+
"model.shared_block.layers.11.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
| 99 |
+
"model.shared_block.layers.12.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 100 |
+
"model.shared_block.layers.12.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
| 101 |
+
"model.shared_block.layers.12.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
| 102 |
+
"model.shared_block.layers.12.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
| 103 |
+
"model.shared_block.layers.12.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 104 |
+
"model.shared_block.layers.12.self_attn.k_norm.weight": "model-00002-of-00004.safetensors",
|
| 105 |
+
"model.shared_block.layers.12.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
| 106 |
+
"model.shared_block.layers.12.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
| 107 |
+
"model.shared_block.layers.12.self_attn.q_norm.weight": "model-00002-of-00004.safetensors",
|
| 108 |
+
"model.shared_block.layers.12.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
| 109 |
+
"model.shared_block.layers.12.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
| 110 |
+
"model.shared_block.layers.13.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 111 |
+
"model.shared_block.layers.13.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
| 112 |
+
"model.shared_block.layers.13.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
| 113 |
+
"model.shared_block.layers.13.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
| 114 |
+
"model.shared_block.layers.13.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 115 |
+
"model.shared_block.layers.13.self_attn.k_norm.weight": "model-00002-of-00004.safetensors",
|
| 116 |
+
"model.shared_block.layers.13.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
| 117 |
+
"model.shared_block.layers.13.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
| 118 |
+
"model.shared_block.layers.13.self_attn.q_norm.weight": "model-00002-of-00004.safetensors",
|
| 119 |
+
"model.shared_block.layers.13.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
| 120 |
+
"model.shared_block.layers.13.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
| 121 |
+
"model.shared_block.layers.14.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 122 |
+
"model.shared_block.layers.14.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
| 123 |
+
"model.shared_block.layers.14.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
| 124 |
+
"model.shared_block.layers.14.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
| 125 |
+
"model.shared_block.layers.14.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 126 |
+
"model.shared_block.layers.14.self_attn.k_norm.weight": "model-00002-of-00004.safetensors",
|
| 127 |
+
"model.shared_block.layers.14.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
| 128 |
+
"model.shared_block.layers.14.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
| 129 |
+
"model.shared_block.layers.14.self_attn.q_norm.weight": "model-00002-of-00004.safetensors",
|
| 130 |
+
"model.shared_block.layers.14.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
| 131 |
+
"model.shared_block.layers.14.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
| 132 |
+
"model.shared_block.layers.15.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 133 |
+
"model.shared_block.layers.15.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
| 134 |
+
"model.shared_block.layers.15.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
| 135 |
+
"model.shared_block.layers.15.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
| 136 |
+
"model.shared_block.layers.15.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 137 |
+
"model.shared_block.layers.15.self_attn.k_norm.weight": "model-00002-of-00004.safetensors",
|
| 138 |
+
"model.shared_block.layers.15.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
| 139 |
+
"model.shared_block.layers.15.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
| 140 |
+
"model.shared_block.layers.15.self_attn.q_norm.weight": "model-00002-of-00004.safetensors",
|
| 141 |
+
"model.shared_block.layers.15.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
| 142 |
+
"model.shared_block.layers.15.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
| 143 |
+
"model.shared_block.layers.16.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 144 |
+
"model.shared_block.layers.16.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
| 145 |
+
"model.shared_block.layers.16.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
| 146 |
+
"model.shared_block.layers.16.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
| 147 |
+
"model.shared_block.layers.16.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 148 |
+
"model.shared_block.layers.16.self_attn.k_norm.weight": "model-00002-of-00004.safetensors",
|
| 149 |
+
"model.shared_block.layers.16.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
| 150 |
+
"model.shared_block.layers.16.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
| 151 |
+
"model.shared_block.layers.16.self_attn.q_norm.weight": "model-00002-of-00004.safetensors",
|
| 152 |
+
"model.shared_block.layers.16.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
| 153 |
+
"model.shared_block.layers.16.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
| 154 |
+
"model.shared_block.layers.17.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 155 |
+
"model.shared_block.layers.17.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
| 156 |
+
"model.shared_block.layers.17.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
| 157 |
+
"model.shared_block.layers.17.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
| 158 |
+
"model.shared_block.layers.17.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 159 |
+
"model.shared_block.layers.17.self_attn.k_norm.weight": "model-00002-of-00004.safetensors",
|
| 160 |
+
"model.shared_block.layers.17.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
| 161 |
+
"model.shared_block.layers.17.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
| 162 |
+
"model.shared_block.layers.17.self_attn.q_norm.weight": "model-00002-of-00004.safetensors",
|
| 163 |
+
"model.shared_block.layers.17.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
| 164 |
+
"model.shared_block.layers.17.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
| 165 |
+
"model.shared_block.layers.18.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 166 |
+
"model.shared_block.layers.18.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
| 167 |
+
"model.shared_block.layers.18.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
| 168 |
+
"model.shared_block.layers.18.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
| 169 |
+
"model.shared_block.layers.18.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 170 |
+
"model.shared_block.layers.18.self_attn.k_norm.weight": "model-00002-of-00004.safetensors",
|
| 171 |
+
"model.shared_block.layers.18.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
| 172 |
+
"model.shared_block.layers.18.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
| 173 |
+
"model.shared_block.layers.18.self_attn.q_norm.weight": "model-00002-of-00004.safetensors",
|
| 174 |
+
"model.shared_block.layers.18.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
| 175 |
+
"model.shared_block.layers.18.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
| 176 |
+
"model.shared_block.layers.19.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 177 |
+
"model.shared_block.layers.19.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
| 178 |
+
"model.shared_block.layers.19.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
| 179 |
+
"model.shared_block.layers.19.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
| 180 |
+
"model.shared_block.layers.19.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 181 |
+
"model.shared_block.layers.19.self_attn.k_norm.weight": "model-00002-of-00004.safetensors",
|
| 182 |
+
"model.shared_block.layers.19.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
| 183 |
+
"model.shared_block.layers.19.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
| 184 |
+
"model.shared_block.layers.19.self_attn.q_norm.weight": "model-00002-of-00004.safetensors",
|
| 185 |
+
"model.shared_block.layers.19.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
| 186 |
+
"model.shared_block.layers.19.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
| 187 |
+
"model.shared_block.layers.2.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 188 |
+
"model.shared_block.layers.2.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 189 |
+
"model.shared_block.layers.2.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 190 |
+
"model.shared_block.layers.2.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 191 |
+
"model.shared_block.layers.2.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 192 |
+
"model.shared_block.layers.2.self_attn.k_norm.weight": "model-00001-of-00004.safetensors",
|
| 193 |
+
"model.shared_block.layers.2.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
|
| 194 |
+
"model.shared_block.layers.2.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
|
| 195 |
+
"model.shared_block.layers.2.self_attn.q_norm.weight": "model-00001-of-00004.safetensors",
|
| 196 |
+
"model.shared_block.layers.2.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
|
| 197 |
+
"model.shared_block.layers.2.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
|
| 198 |
+
"model.shared_block.layers.20.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 199 |
+
"model.shared_block.layers.20.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
| 200 |
+
"model.shared_block.layers.20.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
| 201 |
+
"model.shared_block.layers.20.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
| 202 |
+
"model.shared_block.layers.20.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 203 |
+
"model.shared_block.layers.20.self_attn.k_norm.weight": "model-00002-of-00004.safetensors",
|
| 204 |
+
"model.shared_block.layers.20.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
| 205 |
+
"model.shared_block.layers.20.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
| 206 |
+
"model.shared_block.layers.20.self_attn.q_norm.weight": "model-00002-of-00004.safetensors",
|
| 207 |
+
"model.shared_block.layers.20.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
| 208 |
+
"model.shared_block.layers.20.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
| 209 |
+
"model.shared_block.layers.21.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 210 |
+
"model.shared_block.layers.21.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
| 211 |
+
"model.shared_block.layers.21.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
| 212 |
+
"model.shared_block.layers.21.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
| 213 |
+
"model.shared_block.layers.21.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 214 |
+
"model.shared_block.layers.21.self_attn.k_norm.weight": "model-00002-of-00004.safetensors",
|
| 215 |
+
"model.shared_block.layers.21.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
| 216 |
+
"model.shared_block.layers.21.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
| 217 |
+
"model.shared_block.layers.21.self_attn.q_norm.weight": "model-00002-of-00004.safetensors",
|
| 218 |
+
"model.shared_block.layers.21.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
| 219 |
+
"model.shared_block.layers.21.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
| 220 |
+
"model.shared_block.layers.22.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 221 |
+
"model.shared_block.layers.22.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
| 222 |
+
"model.shared_block.layers.22.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
| 223 |
+
"model.shared_block.layers.22.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
| 224 |
+
"model.shared_block.layers.22.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 225 |
+
"model.shared_block.layers.22.self_attn.k_norm.weight": "model-00003-of-00004.safetensors",
|
| 226 |
+
"model.shared_block.layers.22.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
| 227 |
+
"model.shared_block.layers.22.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
| 228 |
+
"model.shared_block.layers.22.self_attn.q_norm.weight": "model-00003-of-00004.safetensors",
|
| 229 |
+
"model.shared_block.layers.22.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
| 230 |
+
"model.shared_block.layers.22.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
| 231 |
+
"model.shared_block.layers.23.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 232 |
+
"model.shared_block.layers.23.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
| 233 |
+
"model.shared_block.layers.23.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
| 234 |
+
"model.shared_block.layers.23.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
| 235 |
+
"model.shared_block.layers.23.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 236 |
+
"model.shared_block.layers.23.self_attn.k_norm.weight": "model-00003-of-00004.safetensors",
|
| 237 |
+
"model.shared_block.layers.23.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
| 238 |
+
"model.shared_block.layers.23.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
| 239 |
+
"model.shared_block.layers.23.self_attn.q_norm.weight": "model-00003-of-00004.safetensors",
|
| 240 |
+
"model.shared_block.layers.23.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
| 241 |
+
"model.shared_block.layers.23.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
| 242 |
+
"model.shared_block.layers.24.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 243 |
+
"model.shared_block.layers.24.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
| 244 |
+
"model.shared_block.layers.24.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
| 245 |
+
"model.shared_block.layers.24.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
| 246 |
+
"model.shared_block.layers.24.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 247 |
+
"model.shared_block.layers.24.self_attn.k_norm.weight": "model-00003-of-00004.safetensors",
|
| 248 |
+
"model.shared_block.layers.24.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
| 249 |
+
"model.shared_block.layers.24.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
| 250 |
+
"model.shared_block.layers.24.self_attn.q_norm.weight": "model-00003-of-00004.safetensors",
|
| 251 |
+
"model.shared_block.layers.24.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
| 252 |
+
"model.shared_block.layers.24.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
| 253 |
+
"model.shared_block.layers.25.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 254 |
+
"model.shared_block.layers.25.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
| 255 |
+
"model.shared_block.layers.25.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
| 256 |
+
"model.shared_block.layers.25.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
| 257 |
+
"model.shared_block.layers.25.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 258 |
+
"model.shared_block.layers.25.self_attn.k_norm.weight": "model-00003-of-00004.safetensors",
|
| 259 |
+
"model.shared_block.layers.25.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
| 260 |
+
"model.shared_block.layers.25.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
| 261 |
+
"model.shared_block.layers.25.self_attn.q_norm.weight": "model-00003-of-00004.safetensors",
|
| 262 |
+
"model.shared_block.layers.25.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
| 263 |
+
"model.shared_block.layers.25.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
| 264 |
+
"model.shared_block.layers.26.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 265 |
+
"model.shared_block.layers.26.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
| 266 |
+
"model.shared_block.layers.26.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
| 267 |
+
"model.shared_block.layers.26.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
| 268 |
+
"model.shared_block.layers.26.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 269 |
+
"model.shared_block.layers.26.self_attn.k_norm.weight": "model-00003-of-00004.safetensors",
|
| 270 |
+
"model.shared_block.layers.26.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
| 271 |
+
"model.shared_block.layers.26.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
| 272 |
+
"model.shared_block.layers.26.self_attn.q_norm.weight": "model-00003-of-00004.safetensors",
|
| 273 |
+
"model.shared_block.layers.26.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
| 274 |
+
"model.shared_block.layers.26.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
| 275 |
+
"model.shared_block.layers.27.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 276 |
+
"model.shared_block.layers.27.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
| 277 |
+
"model.shared_block.layers.27.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
| 278 |
+
"model.shared_block.layers.27.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
| 279 |
+
"model.shared_block.layers.27.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 280 |
+
"model.shared_block.layers.27.self_attn.k_norm.weight": "model-00003-of-00004.safetensors",
|
| 281 |
+
"model.shared_block.layers.27.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
| 282 |
+
"model.shared_block.layers.27.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
| 283 |
+
"model.shared_block.layers.27.self_attn.q_norm.weight": "model-00003-of-00004.safetensors",
|
| 284 |
+
"model.shared_block.layers.27.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
| 285 |
+
"model.shared_block.layers.27.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
| 286 |
+
"model.shared_block.layers.28.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 287 |
+
"model.shared_block.layers.28.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
| 288 |
+
"model.shared_block.layers.28.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
| 289 |
+
"model.shared_block.layers.28.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
| 290 |
+
"model.shared_block.layers.28.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 291 |
+
"model.shared_block.layers.28.self_attn.k_norm.weight": "model-00003-of-00004.safetensors",
|
| 292 |
+
"model.shared_block.layers.28.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
| 293 |
+
"model.shared_block.layers.28.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
| 294 |
+
"model.shared_block.layers.28.self_attn.q_norm.weight": "model-00003-of-00004.safetensors",
|
| 295 |
+
"model.shared_block.layers.28.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
| 296 |
+
"model.shared_block.layers.28.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
| 297 |
+
"model.shared_block.layers.29.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 298 |
+
"model.shared_block.layers.29.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
| 299 |
+
"model.shared_block.layers.29.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
| 300 |
+
"model.shared_block.layers.29.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
| 301 |
+
"model.shared_block.layers.29.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 302 |
+
"model.shared_block.layers.29.self_attn.k_norm.weight": "model-00003-of-00004.safetensors",
|
| 303 |
+
"model.shared_block.layers.29.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
| 304 |
+
"model.shared_block.layers.29.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
| 305 |
+
"model.shared_block.layers.29.self_attn.q_norm.weight": "model-00003-of-00004.safetensors",
|
| 306 |
+
"model.shared_block.layers.29.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
| 307 |
+
"model.shared_block.layers.29.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
| 308 |
+
"model.shared_block.layers.3.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 309 |
+
"model.shared_block.layers.3.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 310 |
+
"model.shared_block.layers.3.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 311 |
+
"model.shared_block.layers.3.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 312 |
+
"model.shared_block.layers.3.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 313 |
+
"model.shared_block.layers.3.self_attn.k_norm.weight": "model-00001-of-00004.safetensors",
|
| 314 |
+
"model.shared_block.layers.3.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
|
| 315 |
+
"model.shared_block.layers.3.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
|
| 316 |
+
"model.shared_block.layers.3.self_attn.q_norm.weight": "model-00001-of-00004.safetensors",
|
| 317 |
+
"model.shared_block.layers.3.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
|
| 318 |
+
"model.shared_block.layers.3.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
|
| 319 |
+
"model.shared_block.layers.30.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 320 |
+
"model.shared_block.layers.30.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
| 321 |
+
"model.shared_block.layers.30.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
| 322 |
+
"model.shared_block.layers.30.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
| 323 |
+
"model.shared_block.layers.30.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 324 |
+
"model.shared_block.layers.30.self_attn.k_norm.weight": "model-00003-of-00004.safetensors",
|
| 325 |
+
"model.shared_block.layers.30.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
| 326 |
+
"model.shared_block.layers.30.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
| 327 |
+
"model.shared_block.layers.30.self_attn.q_norm.weight": "model-00003-of-00004.safetensors",
|
| 328 |
+
"model.shared_block.layers.30.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
| 329 |
+
"model.shared_block.layers.30.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
| 330 |
+
"model.shared_block.layers.31.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 331 |
+
"model.shared_block.layers.31.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
| 332 |
+
"model.shared_block.layers.31.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
| 333 |
+
"model.shared_block.layers.31.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
| 334 |
+
"model.shared_block.layers.31.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 335 |
+
"model.shared_block.layers.31.self_attn.k_norm.weight": "model-00003-of-00004.safetensors",
|
| 336 |
+
"model.shared_block.layers.31.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
| 337 |
+
"model.shared_block.layers.31.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
| 338 |
+
"model.shared_block.layers.31.self_attn.q_norm.weight": "model-00003-of-00004.safetensors",
|
| 339 |
+
"model.shared_block.layers.31.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
| 340 |
+
"model.shared_block.layers.31.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
| 341 |
+
"model.shared_block.layers.4.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 342 |
+
"model.shared_block.layers.4.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 343 |
+
"model.shared_block.layers.4.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 344 |
+
"model.shared_block.layers.4.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 345 |
+
"model.shared_block.layers.4.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 346 |
+
"model.shared_block.layers.4.self_attn.k_norm.weight": "model-00001-of-00004.safetensors",
|
| 347 |
+
"model.shared_block.layers.4.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
|
| 348 |
+
"model.shared_block.layers.4.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
|
| 349 |
+
"model.shared_block.layers.4.self_attn.q_norm.weight": "model-00001-of-00004.safetensors",
|
| 350 |
+
"model.shared_block.layers.4.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
|
| 351 |
+
"model.shared_block.layers.4.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
|
| 352 |
+
"model.shared_block.layers.5.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 353 |
+
"model.shared_block.layers.5.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 354 |
+
"model.shared_block.layers.5.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 355 |
+
"model.shared_block.layers.5.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 356 |
+
"model.shared_block.layers.5.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 357 |
+
"model.shared_block.layers.5.self_attn.k_norm.weight": "model-00001-of-00004.safetensors",
|
| 358 |
+
"model.shared_block.layers.5.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
|
| 359 |
+
"model.shared_block.layers.5.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
|
| 360 |
+
"model.shared_block.layers.5.self_attn.q_norm.weight": "model-00001-of-00004.safetensors",
|
| 361 |
+
"model.shared_block.layers.5.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
|
| 362 |
+
"model.shared_block.layers.5.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
|
| 363 |
+
"model.shared_block.layers.6.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 364 |
+
"model.shared_block.layers.6.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 365 |
+
"model.shared_block.layers.6.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 366 |
+
"model.shared_block.layers.6.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 367 |
+
"model.shared_block.layers.6.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 368 |
+
"model.shared_block.layers.6.self_attn.k_norm.weight": "model-00001-of-00004.safetensors",
|
| 369 |
+
"model.shared_block.layers.6.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
|
| 370 |
+
"model.shared_block.layers.6.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
|
| 371 |
+
"model.shared_block.layers.6.self_attn.q_norm.weight": "model-00001-of-00004.safetensors",
|
| 372 |
+
"model.shared_block.layers.6.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
|
| 373 |
+
"model.shared_block.layers.6.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
|
| 374 |
+
"model.shared_block.layers.7.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 375 |
+
"model.shared_block.layers.7.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 376 |
+
"model.shared_block.layers.7.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 377 |
+
"model.shared_block.layers.7.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 378 |
+
"model.shared_block.layers.7.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 379 |
+
"model.shared_block.layers.7.self_attn.k_norm.weight": "model-00001-of-00004.safetensors",
|
| 380 |
+
"model.shared_block.layers.7.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
|
| 381 |
+
"model.shared_block.layers.7.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
|
| 382 |
+
"model.shared_block.layers.7.self_attn.q_norm.weight": "model-00001-of-00004.safetensors",
|
| 383 |
+
"model.shared_block.layers.7.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
|
| 384 |
+
"model.shared_block.layers.7.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
|
| 385 |
+
"model.shared_block.layers.8.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 386 |
+
"model.shared_block.layers.8.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
| 387 |
+
"model.shared_block.layers.8.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
| 388 |
+
"model.shared_block.layers.8.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
| 389 |
+
"model.shared_block.layers.8.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
|
| 390 |
+
"model.shared_block.layers.8.self_attn.k_norm.weight": "model-00001-of-00004.safetensors",
|
| 391 |
+
"model.shared_block.layers.8.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
|
| 392 |
+
"model.shared_block.layers.8.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
|
| 393 |
+
"model.shared_block.layers.8.self_attn.q_norm.weight": "model-00001-of-00004.safetensors",
|
| 394 |
+
"model.shared_block.layers.8.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
|
| 395 |
+
"model.shared_block.layers.8.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
|
| 396 |
+
"model.shared_block.layers.9.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 397 |
+
"model.shared_block.layers.9.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
| 398 |
+
"model.shared_block.layers.9.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
| 399 |
+
"model.shared_block.layers.9.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
| 400 |
+
"model.shared_block.layers.9.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
| 401 |
+
"model.shared_block.layers.9.self_attn.k_norm.weight": "model-00001-of-00004.safetensors",
|
| 402 |
+
"model.shared_block.layers.9.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
|
| 403 |
+
"model.shared_block.layers.9.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
|
| 404 |
+
"model.shared_block.layers.9.self_attn.q_norm.weight": "model-00001-of-00004.safetensors",
|
| 405 |
+
"model.shared_block.layers.9.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
|
| 406 |
+
"model.shared_block.layers.9.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
|
| 407 |
+
"model.text_block.layers.0.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 408 |
+
"model.text_block.layers.0.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
| 409 |
+
"model.text_block.layers.0.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
| 410 |
+
"model.text_block.layers.0.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
| 411 |
+
"model.text_block.layers.0.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 412 |
+
"model.text_block.layers.0.self_attn.k_norm.weight": "model-00003-of-00004.safetensors",
|
| 413 |
+
"model.text_block.layers.0.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
| 414 |
+
"model.text_block.layers.0.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
| 415 |
+
"model.text_block.layers.0.self_attn.q_norm.weight": "model-00003-of-00004.safetensors",
|
| 416 |
+
"model.text_block.layers.0.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
| 417 |
+
"model.text_block.layers.0.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
| 418 |
+
"model.text_block.layers.1.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 419 |
+
"model.text_block.layers.1.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
| 420 |
+
"model.text_block.layers.1.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
| 421 |
+
"model.text_block.layers.1.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
| 422 |
+
"model.text_block.layers.1.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 423 |
+
"model.text_block.layers.1.self_attn.k_norm.weight": "model-00003-of-00004.safetensors",
|
| 424 |
+
"model.text_block.layers.1.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
| 425 |
+
"model.text_block.layers.1.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
| 426 |
+
"model.text_block.layers.1.self_attn.q_norm.weight": "model-00003-of-00004.safetensors",
|
| 427 |
+
"model.text_block.layers.1.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
| 428 |
+
"model.text_block.layers.1.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
| 429 |
+
"model.text_block.layers.2.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 430 |
+
"model.text_block.layers.2.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
| 431 |
+
"model.text_block.layers.2.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
| 432 |
+
"model.text_block.layers.2.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
| 433 |
+
"model.text_block.layers.2.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
| 434 |
+
"model.text_block.layers.2.self_attn.k_norm.weight": "model-00003-of-00004.safetensors",
|
| 435 |
+
"model.text_block.layers.2.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
| 436 |
+
"model.text_block.layers.2.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
| 437 |
+
"model.text_block.layers.2.self_attn.q_norm.weight": "model-00003-of-00004.safetensors",
|
| 438 |
+
"model.text_block.layers.2.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
| 439 |
+
"model.text_block.layers.2.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
| 440 |
+
"model.text_block.layers.3.input_layernorm.weight": "model-00004-of-00004.safetensors",
|
| 441 |
+
"model.text_block.layers.3.mlp.down_proj.weight": "model-00004-of-00004.safetensors",
|
| 442 |
+
"model.text_block.layers.3.mlp.gate_proj.weight": "model-00004-of-00004.safetensors",
|
| 443 |
+
"model.text_block.layers.3.mlp.up_proj.weight": "model-00004-of-00004.safetensors",
|
| 444 |
+
"model.text_block.layers.3.post_attention_layernorm.weight": "model-00004-of-00004.safetensors",
|
| 445 |
+
"model.text_block.layers.3.self_attn.k_norm.weight": "model-00004-of-00004.safetensors",
|
| 446 |
+
"model.text_block.layers.3.self_attn.k_proj.weight": "model-00004-of-00004.safetensors",
|
| 447 |
+
"model.text_block.layers.3.self_attn.o_proj.weight": "model-00004-of-00004.safetensors",
|
| 448 |
+
"model.text_block.layers.3.self_attn.q_norm.weight": "model-00004-of-00004.safetensors",
|
| 449 |
+
"model.text_block.layers.3.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
| 450 |
+
"model.text_block.layers.3.self_attn.v_proj.weight": "model-00004-of-00004.safetensors",
|
| 451 |
+
"model.text_norm.weight": "model-00004-of-00004.safetensors",
|
| 452 |
+
"text_lm_head.weight": "model-00004-of-00004.safetensors"
|
| 453 |
+
}
|
| 454 |
+
}
|
modeling_moss_speech.py
ADDED
|
@@ -0,0 +1,1132 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# coding=utf-8
|
| 2 |
+
# Copyright 2025 OpenMOSS and HuggingFace Inc. teams. 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 |
+
|
| 16 |
+
import copy
|
| 17 |
+
from dataclasses import dataclass
|
| 18 |
+
from typing import Any, Callable, Optional, Union
|
| 19 |
+
|
| 20 |
+
import torch
|
| 21 |
+
from torch import nn
|
| 22 |
+
|
| 23 |
+
from transformers.activations import ACT2FN
|
| 24 |
+
from transformers.cache_utils import Cache, DynamicCache
|
| 25 |
+
from transformers.generation import GenerationMixin
|
| 26 |
+
from transformers.generation.configuration_utils import GenerationConfig
|
| 27 |
+
from transformers.generation.logits_process import (
|
| 28 |
+
LogitsProcessorList,
|
| 29 |
+
RepetitionPenaltyLogitsProcessor,
|
| 30 |
+
TemperatureLogitsWarper,
|
| 31 |
+
TopKLogitsWarper,
|
| 32 |
+
TopPLogitsWarper,
|
| 33 |
+
)
|
| 34 |
+
from transformers.generation.stopping_criteria import StoppingCriteriaList
|
| 35 |
+
from transformers.generation.streamers import BaseStreamer
|
| 36 |
+
from transformers.generation.utils import GenerateDecoderOnlyOutput
|
| 37 |
+
from transformers.integrations import use_kernel_forward_from_hub
|
| 38 |
+
from transformers.masking_utils import (
|
| 39 |
+
create_causal_mask,
|
| 40 |
+
create_sliding_window_causal_mask,
|
| 41 |
+
)
|
| 42 |
+
from transformers.modeling_flash_attention_utils import FlashAttentionKwargs
|
| 43 |
+
from transformers.modeling_layers import (
|
| 44 |
+
GenericForQuestionAnswering,
|
| 45 |
+
GenericForSequenceClassification,
|
| 46 |
+
GenericForTokenClassification,
|
| 47 |
+
GradientCheckpointingLayer,
|
| 48 |
+
)
|
| 49 |
+
from transformers.modeling_outputs import (
|
| 50 |
+
ModelOutput,
|
| 51 |
+
)
|
| 52 |
+
from transformers.modeling_rope_utils import ROPE_INIT_FUNCTIONS, dynamic_rope_update
|
| 53 |
+
from transformers.modeling_utils import ALL_ATTENTION_FUNCTIONS, PreTrainedModel
|
| 54 |
+
from transformers.processing_utils import Unpack
|
| 55 |
+
from transformers.pytorch_utils import isin_mps_friendly
|
| 56 |
+
from transformers.utils import TransformersKwargs, auto_docstring, can_return_tuple
|
| 57 |
+
from transformers.utils.deprecation import deprecate_kwarg
|
| 58 |
+
from transformers.utils.generic import check_model_inputs
|
| 59 |
+
|
| 60 |
+
from .configuration_moss_speech import MossSpeechConfig
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
@dataclass
|
| 64 |
+
class MossSpeechModelOutputWithPast(ModelOutput):
|
| 65 |
+
"""MossSpeech model output that includes per-modality last_hidden_state dict
|
| 66 |
+
|
| 67 |
+
Args:
|
| 68 |
+
last_hidden_state (`torch.FloatTensor` of shape `(batch_size, sequence_length, hidden_size)`):
|
| 69 |
+
Sequence of hidden-states at the output of the last layer of the model.
|
| 70 |
+
past_key_values (`tuple(tuple(torch.FloatTensor))`, *optional*, returned when `use_cache=True` is passed
|
| 71 |
+
or when `config.use_cache=True`): Tuple of `tuple(torch.FloatTensor)` of length `config.n_layers`, with
|
| 72 |
+
each tuple having 2 tensors of shape `(batch_size, num_heads, sequence_length, embed_size_per_head)`.
|
| 73 |
+
last_hidden_state_dict (`Dict[str, torch.FloatTensor]`, *optional*):
|
| 74 |
+
Dictionary containing hidden states for each modality. Keys are modality names (e.g., "text", "audio")
|
| 75 |
+
and values are tensors of shape `(batch_size, sequence_length, hidden_size)`.
|
| 76 |
+
attentions (`tuple(torch.FloatTensor)`, *optional*):
|
| 77 |
+
Tuple of `torch.FloatTensor` (one for each layer) of shape
|
| 78 |
+
`(batch_size, num_heads, sequence_length, sequence_length)`.
|
| 79 |
+
"""
|
| 80 |
+
|
| 81 |
+
last_hidden_state: torch.FloatTensor = None
|
| 82 |
+
past_key_values: Optional[tuple] = None
|
| 83 |
+
hidden_states: Optional[tuple] = None
|
| 84 |
+
attentions: Optional[tuple] = None
|
| 85 |
+
last_hidden_state_dict: Optional[dict[str, torch.Tensor]] = None
|
| 86 |
+
past_key_values_dict: Optional[dict] = None
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
@dataclass
|
| 90 |
+
class MossSpeechCausalLMOutputWithPast(ModelOutput):
|
| 91 |
+
"""MossSpeech causal language modeling output, includes per-modality hidden_states dict
|
| 92 |
+
|
| 93 |
+
Args:
|
| 94 |
+
loss (`torch.FloatTensor` of shape `(1,)`, *optional*, returned when `labels` is provided):
|
| 95 |
+
Language modeling loss (for next-token prediction).
|
| 96 |
+
logits (`torch.FloatTensor` of shape `(batch_size, sequence_length, config.vocab_size)`):
|
| 97 |
+
Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax).
|
| 98 |
+
past_key_values (`tuple(tuple(torch.FloatTensor))`, *optional*, returned when `use_cache=True` is passed or when `config.use_cache=True`):
|
| 99 |
+
Tuple of `tuple(torch.FloatTensor)` of length `config.n_layers`, with each tuple having 2 tensors of shape
|
| 100 |
+
`(batch_size, num_heads, sequence_length, embed_size_per_head)`)
|
| 101 |
+
Contains pre-computed hidden-states (key and values in the self-attention blocks) that can be used (see
|
| 102 |
+
`past_key_values` input) to speed up sequential decoding.
|
| 103 |
+
hidden_states (`Dict[str, torch.FloatTensor]`, *optional*):
|
| 104 |
+
Dictionary containing hidden states for each modality. Keys are modality names (e.g., "text", "audio")
|
| 105 |
+
and values are tensors of shape `(batch_size, sequence_length, hidden_size)`.
|
| 106 |
+
attentions (`tuple(torch.FloatTensor)`, *optional*):
|
| 107 |
+
Tuple of `torch.FloatTensor` (one for each layer) of shape `(batch_size, num_heads, sequence_length, sequence_length)`.
|
| 108 |
+
"""
|
| 109 |
+
|
| 110 |
+
hidden_states: Optional[dict[str, torch.Tensor]] = None
|
| 111 |
+
past_key_values: Optional[tuple] = None
|
| 112 |
+
attentions: Optional[tuple] = None
|
| 113 |
+
last_hidden_state_dict: Optional[dict[str, torch.Tensor]] = None
|
| 114 |
+
audio_loss: Optional[torch.FloatTensor] = None
|
| 115 |
+
audio_logits: Optional[torch.FloatTensor] = None
|
| 116 |
+
text_loss: Optional[torch.FloatTensor] = None
|
| 117 |
+
text_logits: Optional[torch.FloatTensor] = None
|
| 118 |
+
text_hidden_states: Optional[torch.FloatTensor] = None
|
| 119 |
+
audio_hidden_states: Optional[torch.FloatTensor] = None
|
| 120 |
+
logits_all: Optional[tuple] = None
|
| 121 |
+
past_key_values_dict: Optional[dict] = None
|
| 122 |
+
|
| 123 |
+
|
| 124 |
+
@use_kernel_forward_from_hub("RMSNorm")
|
| 125 |
+
class MossSpeechRMSNorm(nn.Module):
|
| 126 |
+
# Copied from transformers.models.llama.modeling_llama.LlamaRMSNorm with Llama->MossSpeech
|
| 127 |
+
def __init__(self, hidden_size, eps: float = 1e-6) -> None:
|
| 128 |
+
"""Root Mean Square LayerNorm used in MossSpeech."""
|
| 129 |
+
super().__init__()
|
| 130 |
+
self.weight = nn.Parameter(torch.ones(hidden_size))
|
| 131 |
+
self.variance_epsilon = eps
|
| 132 |
+
|
| 133 |
+
def forward(self, hidden_states: torch.Tensor) -> torch.Tensor:
|
| 134 |
+
input_dtype = hidden_states.dtype
|
| 135 |
+
hidden_states = hidden_states.to(torch.float32)
|
| 136 |
+
variance = hidden_states.pow(2).mean(-1, keepdim=True)
|
| 137 |
+
hidden_states = hidden_states * torch.rsqrt(variance + self.variance_epsilon)
|
| 138 |
+
return self.weight * hidden_states.to(input_dtype)
|
| 139 |
+
|
| 140 |
+
def extra_repr(self):
|
| 141 |
+
return f"{tuple(self.weight.shape)}, eps={self.variance_epsilon}"
|
| 142 |
+
|
| 143 |
+
|
| 144 |
+
class MossSpeechMLP(nn.Module):
|
| 145 |
+
def __init__(self, config):
|
| 146 |
+
super().__init__()
|
| 147 |
+
self.config = config
|
| 148 |
+
self.hidden_size = config.hidden_size
|
| 149 |
+
self.intermediate_size = config.intermediate_size
|
| 150 |
+
self.gate_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=False)
|
| 151 |
+
self.up_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=False)
|
| 152 |
+
self.down_proj = nn.Linear(self.intermediate_size, self.hidden_size, bias=False)
|
| 153 |
+
self.act_fn = ACT2FN[config.hidden_act]
|
| 154 |
+
|
| 155 |
+
def forward(self, x):
|
| 156 |
+
down_proj = self.down_proj(self.act_fn(self.gate_proj(x)) * self.up_proj(x))
|
| 157 |
+
return down_proj
|
| 158 |
+
|
| 159 |
+
|
| 160 |
+
def rotate_half(x):
|
| 161 |
+
# Copied from transformers.models.llama.modeling_llama.rotate_half
|
| 162 |
+
"""Rotate half the hidden dims of the input."""
|
| 163 |
+
x1 = x[..., : x.shape[-1] // 2]
|
| 164 |
+
x2 = x[..., x.shape[-1] // 2 :]
|
| 165 |
+
return torch.cat((-x2, x1), dim=-1)
|
| 166 |
+
|
| 167 |
+
|
| 168 |
+
def apply_rotary_pos_emb(q, k, cos, sin, position_ids=None, unsqueeze_dim=1):
|
| 169 |
+
# Copied from transformers.models.llama.modeling_llama.apply_rotary_pos_emb
|
| 170 |
+
"""Apply Rotary Position Embeddings to the query and key tensors.
|
| 171 |
+
|
| 172 |
+
Args:
|
| 173 |
+
q (`torch.Tensor`): The query tensor.
|
| 174 |
+
k (`torch.Tensor`): The key tensor.
|
| 175 |
+
cos (`torch.Tensor`): The cosine part of the rotary embedding.
|
| 176 |
+
sin (`torch.Tensor`): The sine part of the rotary embedding.
|
| 177 |
+
position_ids (`torch.Tensor`, *optional*): Deprecated and unused.
|
| 178 |
+
unsqueeze_dim (`int`, *optional*, defaults to 1):
|
| 179 |
+
Dimension along which to unsqueeze cos[position_ids] and sin[position_ids] for broadcasting to `q`/`k`.
|
| 180 |
+
Returns:
|
| 181 |
+
`tuple(torch.Tensor)` comprising of the rotated query and key tensors.
|
| 182 |
+
"""
|
| 183 |
+
cos = cos.unsqueeze(unsqueeze_dim)
|
| 184 |
+
sin = sin.unsqueeze(unsqueeze_dim)
|
| 185 |
+
q_embed = (q * cos) + (rotate_half(q) * sin)
|
| 186 |
+
k_embed = (k * cos) + (rotate_half(k) * sin)
|
| 187 |
+
return q_embed, k_embed
|
| 188 |
+
|
| 189 |
+
|
| 190 |
+
def repeat_kv(hidden_states: torch.Tensor, n_rep: int) -> torch.Tensor:
|
| 191 |
+
# Copied from transformers.models.llama.modeling_llama.repeat_kv
|
| 192 |
+
"""Repeat key/value heads to match attention heads.
|
| 193 |
+
|
| 194 |
+
Equivalent to `torch.repeat_interleave(x, dim=1, repeats=n_rep)` transforming
|
| 195 |
+
(batch, num_key_value_heads, seqlen, head_dim) -> (batch, num_attention_heads, seqlen, head_dim).
|
| 196 |
+
"""
|
| 197 |
+
batch, num_key_value_heads, slen, head_dim = hidden_states.shape
|
| 198 |
+
if n_rep == 1:
|
| 199 |
+
return hidden_states
|
| 200 |
+
hidden_states = hidden_states[:, :, None, :, :].expand(batch, num_key_value_heads, n_rep, slen, head_dim)
|
| 201 |
+
return hidden_states.reshape(batch, num_key_value_heads * n_rep, slen, head_dim)
|
| 202 |
+
|
| 203 |
+
|
| 204 |
+
def eager_attention_forward(
|
| 205 |
+
module: nn.Module,
|
| 206 |
+
query: torch.Tensor,
|
| 207 |
+
key: torch.Tensor,
|
| 208 |
+
value: torch.Tensor,
|
| 209 |
+
attention_mask: Optional[torch.Tensor],
|
| 210 |
+
scaling: float,
|
| 211 |
+
dropout: float = 0.0,
|
| 212 |
+
**kwargs: Unpack[TransformersKwargs],
|
| 213 |
+
):
|
| 214 |
+
# Copied from transformers.models.llama.modeling_llama.eager_attention_forward
|
| 215 |
+
key_states = repeat_kv(key, module.num_key_value_groups)
|
| 216 |
+
value_states = repeat_kv(value, module.num_key_value_groups)
|
| 217 |
+
|
| 218 |
+
attn_weights = torch.matmul(query, key_states.transpose(2, 3)) * scaling
|
| 219 |
+
if attention_mask is not None:
|
| 220 |
+
causal_mask = attention_mask[:, :, :, : key_states.shape[-2]]
|
| 221 |
+
attn_weights = attn_weights + causal_mask
|
| 222 |
+
|
| 223 |
+
attn_weights = nn.functional.softmax(attn_weights, dim=-1, dtype=torch.float32).to(query.dtype)
|
| 224 |
+
attn_weights = nn.functional.dropout(attn_weights, p=dropout, training=module.training)
|
| 225 |
+
attn_output = torch.matmul(attn_weights, value_states)
|
| 226 |
+
attn_output = attn_output.transpose(1, 2).contiguous()
|
| 227 |
+
|
| 228 |
+
return attn_output, attn_weights
|
| 229 |
+
|
| 230 |
+
|
| 231 |
+
class MossSpeechAttention(nn.Module):
|
| 232 |
+
"""Multi-headed attention from 'Attention Is All You Need'."""
|
| 233 |
+
|
| 234 |
+
def __init__(self, config: MossSpeechConfig, layer_idx: int):
|
| 235 |
+
super().__init__()
|
| 236 |
+
self.config = config
|
| 237 |
+
self.layer_idx = layer_idx
|
| 238 |
+
self.head_dim = getattr(config, "head_dim", config.hidden_size // config.num_attention_heads)
|
| 239 |
+
self.num_key_value_groups = config.num_attention_heads // config.num_key_value_heads
|
| 240 |
+
self.scaling = self.head_dim**-0.5
|
| 241 |
+
self.attention_dropout = config.attention_dropout
|
| 242 |
+
self.is_causal = True
|
| 243 |
+
|
| 244 |
+
self.q_proj = nn.Linear(
|
| 245 |
+
config.hidden_size,
|
| 246 |
+
config.num_attention_heads * self.head_dim,
|
| 247 |
+
bias=config.attention_bias,
|
| 248 |
+
)
|
| 249 |
+
self.k_proj = nn.Linear(
|
| 250 |
+
config.hidden_size,
|
| 251 |
+
config.num_key_value_heads * self.head_dim,
|
| 252 |
+
bias=config.attention_bias,
|
| 253 |
+
)
|
| 254 |
+
self.v_proj = nn.Linear(
|
| 255 |
+
config.hidden_size,
|
| 256 |
+
config.num_key_value_heads * self.head_dim,
|
| 257 |
+
bias=config.attention_bias,
|
| 258 |
+
)
|
| 259 |
+
self.o_proj = nn.Linear(
|
| 260 |
+
config.num_attention_heads * self.head_dim,
|
| 261 |
+
config.hidden_size,
|
| 262 |
+
bias=config.attention_bias,
|
| 263 |
+
)
|
| 264 |
+
self.q_norm = MossSpeechRMSNorm(self.head_dim, eps=config.rms_norm_eps)
|
| 265 |
+
self.k_norm = MossSpeechRMSNorm(self.head_dim, eps=config.rms_norm_eps)
|
| 266 |
+
self.sliding_window = config.sliding_window if config.layer_types[layer_idx] == "sliding_attention" else None
|
| 267 |
+
|
| 268 |
+
@deprecate_kwarg("past_key_value", new_name="past_key_values", version="4.58")
|
| 269 |
+
def forward(
|
| 270 |
+
self,
|
| 271 |
+
hidden_states: torch.Tensor,
|
| 272 |
+
position_embeddings: tuple[torch.Tensor, torch.Tensor],
|
| 273 |
+
attention_mask: Optional[torch.Tensor],
|
| 274 |
+
past_key_values: Optional[Cache] = None,
|
| 275 |
+
cache_position: Optional[torch.LongTensor] = None,
|
| 276 |
+
**kwargs: Unpack[FlashAttentionKwargs],
|
| 277 |
+
) -> tuple[torch.Tensor, Optional[torch.Tensor]]:
|
| 278 |
+
input_shape = hidden_states.shape[:-1]
|
| 279 |
+
hidden_shape = (*input_shape, -1, self.head_dim)
|
| 280 |
+
|
| 281 |
+
query_states = self.q_norm(self.q_proj(hidden_states).view(hidden_shape)).transpose(1, 2)
|
| 282 |
+
key_states = self.k_norm(self.k_proj(hidden_states).view(hidden_shape)).transpose(1, 2)
|
| 283 |
+
value_states = self.v_proj(hidden_states).view(hidden_shape).transpose(1, 2)
|
| 284 |
+
|
| 285 |
+
cos, sin = position_embeddings
|
| 286 |
+
|
| 287 |
+
query_states, key_states = apply_rotary_pos_emb(query_states, key_states, cos, sin)
|
| 288 |
+
if past_key_values is not None:
|
| 289 |
+
# sin and cos are specific to RoPE models; cache_position needed for the static cache
|
| 290 |
+
cache_kwargs = {"sin": sin, "cos": cos, "cache_position": cache_position}
|
| 291 |
+
key_states, value_states = past_key_values.update(key_states, value_states, self.layer_idx, cache_kwargs)
|
| 292 |
+
|
| 293 |
+
attention_interface: Callable = eager_attention_forward
|
| 294 |
+
if self.config._attn_implementation != "eager":
|
| 295 |
+
attention_interface = ALL_ATTENTION_FUNCTIONS[self.config._attn_implementation]
|
| 296 |
+
|
| 297 |
+
attn_output, attn_weights = attention_interface(
|
| 298 |
+
self,
|
| 299 |
+
query_states,
|
| 300 |
+
key_states,
|
| 301 |
+
value_states,
|
| 302 |
+
attention_mask,
|
| 303 |
+
dropout=0.0 if not self.training else self.attention_dropout,
|
| 304 |
+
scaling=self.scaling,
|
| 305 |
+
sliding_window=self.sliding_window,
|
| 306 |
+
**kwargs,
|
| 307 |
+
)
|
| 308 |
+
|
| 309 |
+
attn_output = attn_output.reshape(*input_shape, -1).contiguous()
|
| 310 |
+
attn_output = self.o_proj(attn_output)
|
| 311 |
+
return attn_output, attn_weights
|
| 312 |
+
|
| 313 |
+
|
| 314 |
+
class MossSpeechDecoderLayer(GradientCheckpointingLayer):
|
| 315 |
+
"""Single decoder layer used in the MossSpeech transformer."""
|
| 316 |
+
|
| 317 |
+
def __init__(self, config: MossSpeechConfig, layer_idx: int):
|
| 318 |
+
super().__init__()
|
| 319 |
+
self.hidden_size = config.hidden_size
|
| 320 |
+
|
| 321 |
+
self.self_attn = MossSpeechAttention(config=config, layer_idx=layer_idx)
|
| 322 |
+
|
| 323 |
+
self.mlp = MossSpeechMLP(config)
|
| 324 |
+
self.input_layernorm = MossSpeechRMSNorm(config.hidden_size, eps=config.rms_norm_eps)
|
| 325 |
+
self.post_attention_layernorm = MossSpeechRMSNorm(config.hidden_size, eps=config.rms_norm_eps)
|
| 326 |
+
self.attention_type = config.layer_types[layer_idx]
|
| 327 |
+
|
| 328 |
+
@deprecate_kwarg("past_key_value", new_name="past_key_values", version="4.58")
|
| 329 |
+
def forward(
|
| 330 |
+
self,
|
| 331 |
+
hidden_states: torch.Tensor,
|
| 332 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 333 |
+
position_ids: Optional[torch.LongTensor] = None,
|
| 334 |
+
past_key_values: Optional[Cache] = None,
|
| 335 |
+
use_cache: Optional[bool] = False,
|
| 336 |
+
cache_position: Optional[torch.LongTensor] = None,
|
| 337 |
+
position_embeddings: Optional[tuple[torch.Tensor, torch.Tensor]] = None, # necessary, but kept here for BC
|
| 338 |
+
**kwargs: Unpack[TransformersKwargs],
|
| 339 |
+
) -> torch.Tensor:
|
| 340 |
+
residual = hidden_states
|
| 341 |
+
hidden_states = self.input_layernorm(hidden_states)
|
| 342 |
+
# Self Attention
|
| 343 |
+
hidden_states, _ = self.self_attn(
|
| 344 |
+
hidden_states=hidden_states,
|
| 345 |
+
attention_mask=attention_mask,
|
| 346 |
+
position_ids=position_ids,
|
| 347 |
+
past_key_values=past_key_values,
|
| 348 |
+
use_cache=use_cache,
|
| 349 |
+
cache_position=cache_position,
|
| 350 |
+
position_embeddings=position_embeddings,
|
| 351 |
+
**kwargs,
|
| 352 |
+
)
|
| 353 |
+
hidden_states = residual + hidden_states
|
| 354 |
+
|
| 355 |
+
# Fully Connected
|
| 356 |
+
residual = hidden_states
|
| 357 |
+
hidden_states = self.post_attention_layernorm(hidden_states)
|
| 358 |
+
hidden_states = self.mlp(hidden_states)
|
| 359 |
+
hidden_states = residual + hidden_states
|
| 360 |
+
return hidden_states
|
| 361 |
+
|
| 362 |
+
|
| 363 |
+
class MossSpeechTransformerBlock(nn.Module):
|
| 364 |
+
"""A contiguous stack of decoder layers that handles attention types and cache offsets."""
|
| 365 |
+
|
| 366 |
+
def __init__(self, config: MossSpeechConfig, start_idx: int, num_layers: int):
|
| 367 |
+
super().__init__()
|
| 368 |
+
self.start_idx = start_idx
|
| 369 |
+
self.num_layers = num_layers
|
| 370 |
+
self.layers = nn.ModuleList(
|
| 371 |
+
[MossSpeechDecoderLayer(config, layer_idx=start_idx + i) for i in range(num_layers)]
|
| 372 |
+
)
|
| 373 |
+
self.config = config
|
| 374 |
+
self.has_sliding_layers = "sliding_attention" in config.layer_types
|
| 375 |
+
|
| 376 |
+
def _mask_for_layer(self, causal_masks: dict[str, torch.Tensor], layer_type: str) -> torch.Tensor:
|
| 377 |
+
return causal_masks[("sliding_attention" if layer_type == "sliding_attention" else "full_attention")]
|
| 378 |
+
|
| 379 |
+
def forward(
|
| 380 |
+
self,
|
| 381 |
+
hidden_states: torch.Tensor,
|
| 382 |
+
*,
|
| 383 |
+
causal_masks: dict[str, torch.Tensor],
|
| 384 |
+
position_ids: torch.LongTensor,
|
| 385 |
+
position_embeddings: tuple[torch.Tensor, torch.Tensor],
|
| 386 |
+
past_key_values: Optional[Cache],
|
| 387 |
+
use_cache: bool,
|
| 388 |
+
cache_position: torch.LongTensor,
|
| 389 |
+
**kwargs: Unpack[TransformersKwargs],
|
| 390 |
+
) -> torch.Tensor:
|
| 391 |
+
for i, decoder_layer in enumerate(self.layers):
|
| 392 |
+
layer_type = self.config.layer_types[self.start_idx + i]
|
| 393 |
+
hidden_states = decoder_layer(
|
| 394 |
+
hidden_states,
|
| 395 |
+
attention_mask=self._mask_for_layer(causal_masks, layer_type),
|
| 396 |
+
position_ids=position_ids,
|
| 397 |
+
past_key_values=past_key_values,
|
| 398 |
+
use_cache=use_cache,
|
| 399 |
+
cache_position=cache_position,
|
| 400 |
+
position_embeddings=position_embeddings,
|
| 401 |
+
**kwargs,
|
| 402 |
+
)
|
| 403 |
+
return hidden_states
|
| 404 |
+
|
| 405 |
+
|
| 406 |
+
@auto_docstring
|
| 407 |
+
class MossSpeechPreTrainedModel(PreTrainedModel):
|
| 408 |
+
config: MossSpeechConfig
|
| 409 |
+
base_model_prefix = "model"
|
| 410 |
+
supports_gradient_checkpointing = True
|
| 411 |
+
_no_split_modules = ["MossSpeechDecoderLayer"]
|
| 412 |
+
_skip_keys_device_placement = ["past_key_values"]
|
| 413 |
+
_supports_flash_attn = True
|
| 414 |
+
_supports_sdpa = True
|
| 415 |
+
_supports_flex_attn = True
|
| 416 |
+
|
| 417 |
+
_can_compile_fullgraph = True
|
| 418 |
+
_supports_attention_backend = True
|
| 419 |
+
_can_record_outputs = {
|
| 420 |
+
"hidden_states": MossSpeechDecoderLayer,
|
| 421 |
+
"attentions": MossSpeechAttention,
|
| 422 |
+
}
|
| 423 |
+
|
| 424 |
+
|
| 425 |
+
class MossSpeechRotaryEmbedding(nn.Module):
|
| 426 |
+
inv_freq: torch.Tensor # fix linting for `register_buffer`
|
| 427 |
+
|
| 428 |
+
def __init__(self, config: MossSpeechConfig, device=None):
|
| 429 |
+
super().__init__()
|
| 430 |
+
# BC: "rope_type" was originally "type"
|
| 431 |
+
if hasattr(config, "rope_scaling") and isinstance(config.rope_scaling, dict):
|
| 432 |
+
self.rope_type = config.rope_scaling.get("rope_type", config.rope_scaling.get("type"))
|
| 433 |
+
else:
|
| 434 |
+
self.rope_type = "default"
|
| 435 |
+
self.max_seq_len_cached = config.max_position_embeddings
|
| 436 |
+
self.original_max_seq_len = config.max_position_embeddings
|
| 437 |
+
|
| 438 |
+
self.config = config
|
| 439 |
+
self.rope_init_fn = ROPE_INIT_FUNCTIONS[self.rope_type]
|
| 440 |
+
|
| 441 |
+
inv_freq, self.attention_scaling = self.rope_init_fn(self.config, device)
|
| 442 |
+
self.register_buffer("inv_freq", inv_freq, persistent=False)
|
| 443 |
+
self.original_inv_freq = self.inv_freq
|
| 444 |
+
|
| 445 |
+
@torch.no_grad()
|
| 446 |
+
@dynamic_rope_update # power user: used with advanced RoPE types (e.g. dynamic rope)
|
| 447 |
+
def forward(self, x, position_ids):
|
| 448 |
+
inv_freq_expanded = self.inv_freq[None, :, None].float().expand(position_ids.shape[0], -1, 1).to(x.device)
|
| 449 |
+
position_ids_expanded = position_ids[:, None, :].float()
|
| 450 |
+
|
| 451 |
+
seq_len = position_ids_expanded.max().item() + 1
|
| 452 |
+
if seq_len > self.max_seq_len_cached:
|
| 453 |
+
self.max_seq_len_cached = int(seq_len)
|
| 454 |
+
|
| 455 |
+
device_type = x.device.type if isinstance(x.device.type, str) and x.device.type != "mps" else "cpu"
|
| 456 |
+
|
| 457 |
+
with torch.autocast(device_type=device_type, enabled=False):
|
| 458 |
+
freqs = (inv_freq_expanded.float() @ position_ids_expanded.float()).transpose(1, 2)
|
| 459 |
+
emb = torch.cat((freqs, freqs), dim=-1)
|
| 460 |
+
cos = emb.cos() * self.attention_scaling
|
| 461 |
+
sin = emb.sin() * self.attention_scaling
|
| 462 |
+
|
| 463 |
+
return cos.to(dtype=x.dtype), sin.to(dtype=x.dtype)
|
| 464 |
+
|
| 465 |
+
|
| 466 |
+
class MossSpeechModel(MossSpeechPreTrainedModel):
|
| 467 |
+
"""The bare MossSpeech decoder-only Transformer with shared and modality-specific blocks.
|
| 468 |
+
|
| 469 |
+
This model outputs a dictionary of per-modality hidden states in addition to the shared hidden states.
|
| 470 |
+
"""
|
| 471 |
+
|
| 472 |
+
def __init__(self, config: MossSpeechConfig):
|
| 473 |
+
super().__init__(config)
|
| 474 |
+
pad_idx = (
|
| 475 |
+
config.pad_token_id if getattr(config, "pad_token_id", None) is not None else config.modality_pad_token_id
|
| 476 |
+
)
|
| 477 |
+
self.padding_idx = pad_idx
|
| 478 |
+
self.vocab_size = config.vocab_size
|
| 479 |
+
|
| 480 |
+
# Shared embed + trunk
|
| 481 |
+
self.embed_tokens = nn.Embedding(config.vocab_size, config.hidden_size, padding_idx=self.padding_idx)
|
| 482 |
+
self.audio_embed = nn.Embedding(config.audio_vocab_size, config.hidden_size)
|
| 483 |
+
self.rotary_emb = MossSpeechRotaryEmbedding(config)
|
| 484 |
+
self.gradient_checkpointing = False
|
| 485 |
+
self.has_sliding_layers = "sliding_attention" in config.layer_types
|
| 486 |
+
|
| 487 |
+
self.shared_block = MossSpeechTransformerBlock(config, start_idx=0, num_layers=config.num_shared_layers)
|
| 488 |
+
|
| 489 |
+
# Modality-specific blocks (route after the shared trunk)
|
| 490 |
+
self.text_block = MossSpeechTransformerBlock(
|
| 491 |
+
config,
|
| 492 |
+
start_idx=0,
|
| 493 |
+
num_layers=config.num_modality_layers,
|
| 494 |
+
)
|
| 495 |
+
self.audio_block = MossSpeechTransformerBlock(
|
| 496 |
+
config,
|
| 497 |
+
start_idx=0,
|
| 498 |
+
num_layers=config.num_modality_layers,
|
| 499 |
+
)
|
| 500 |
+
|
| 501 |
+
# Modality-specific final norms
|
| 502 |
+
self.text_norm = MossSpeechRMSNorm(config.hidden_size, eps=config.rms_norm_eps)
|
| 503 |
+
self.audio_norm = MossSpeechRMSNorm(config.hidden_size, eps=config.rms_norm_eps)
|
| 504 |
+
|
| 505 |
+
# register
|
| 506 |
+
self.modality_blocks = nn.ModuleDict(
|
| 507 |
+
{
|
| 508 |
+
"text": self.text_block,
|
| 509 |
+
"audio": self.audio_block,
|
| 510 |
+
}
|
| 511 |
+
)
|
| 512 |
+
self.modality_norms = nn.ModuleDict(
|
| 513 |
+
{
|
| 514 |
+
"text": self.text_norm,
|
| 515 |
+
"audio": self.audio_norm,
|
| 516 |
+
}
|
| 517 |
+
)
|
| 518 |
+
|
| 519 |
+
# Initialize weights and apply final processing
|
| 520 |
+
self.post_init()
|
| 521 |
+
|
| 522 |
+
def _route_block(self, modality: str):
|
| 523 |
+
"""Return the Transformer block for the given modality."""
|
| 524 |
+
if modality in self.modality_blocks:
|
| 525 |
+
return self.modality_blocks[modality]
|
| 526 |
+
else:
|
| 527 |
+
raise ValueError(f"Unknown modality: {modality}")
|
| 528 |
+
|
| 529 |
+
def _route_final_layer_norm(self, modality: str):
|
| 530 |
+
"""Return the final layer normalization for the given modality."""
|
| 531 |
+
if modality in self.modality_norms:
|
| 532 |
+
return self.modality_norms[modality]
|
| 533 |
+
else:
|
| 534 |
+
raise ValueError(f"Unknown modality: {modality}")
|
| 535 |
+
|
| 536 |
+
@check_model_inputs
|
| 537 |
+
@auto_docstring
|
| 538 |
+
def forward(
|
| 539 |
+
self,
|
| 540 |
+
modalities: list[str],
|
| 541 |
+
input_ids: Optional[torch.LongTensor] = None,
|
| 542 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 543 |
+
position_ids: Optional[torch.LongTensor] = None,
|
| 544 |
+
past_key_values: Optional[dict] = None,
|
| 545 |
+
past_key_values_dict: Optional[dict] = None,
|
| 546 |
+
inputs_embeds: Optional[torch.FloatTensor] = None,
|
| 547 |
+
use_cache: Optional[bool] = None,
|
| 548 |
+
cache_position: Optional[torch.LongTensor] = None,
|
| 549 |
+
**kwargs: Unpack[TransformersKwargs],
|
| 550 |
+
) -> MossSpeechModelOutputWithPast:
|
| 551 |
+
r"""
|
| 552 |
+
Args:
|
| 553 |
+
modalities (List[str]): Modalities to compute in this forward pass.
|
| 554 |
+
past_key_values_dict (Optional[dict]): KV cache per block when using `use_cache=True`.
|
| 555 |
+
"""
|
| 556 |
+
|
| 557 |
+
if (input_ids is None) ^ (inputs_embeds is not None):
|
| 558 |
+
raise ValueError("You must specify exactly one of input_ids or inputs_embeds")
|
| 559 |
+
|
| 560 |
+
if inputs_embeds is None:
|
| 561 |
+
if input_ids is None:
|
| 562 |
+
raise ValueError("require input_ids (packed or text-only)")
|
| 563 |
+
|
| 564 |
+
if input_ids.dim() == 3 and input_ids.shape[1] == 2:
|
| 565 |
+
text_ids = input_ids[:, 0, :]
|
| 566 |
+
audio_ids_packed = input_ids[:, 1, :]
|
| 567 |
+
pad_id = int(getattr(self.config, "modality_pad_token_id", 0))
|
| 568 |
+
if pad_id == 0:
|
| 569 |
+
raise ValueError("Expected a non-zero modality_pad_token_id for packed inputs")
|
| 570 |
+
# Safely replace pad tokens before embedding lookup
|
| 571 |
+
text_ids_safe = text_ids.masked_fill(text_ids == pad_id, 0)
|
| 572 |
+
|
| 573 |
+
text_embeds = self.embed_tokens(text_ids_safe)
|
| 574 |
+
audio_embeds = self.audio_embed(audio_ids_packed)
|
| 575 |
+
selection_mask = (text_ids != pad_id).unsqueeze(-1).to(dtype=text_embeds.dtype)
|
| 576 |
+
inputs_embeds = text_embeds * selection_mask + audio_embeds * (1 - selection_mask)
|
| 577 |
+
elif input_ids.dim() == 2:
|
| 578 |
+
# text-only input
|
| 579 |
+
inputs_embeds = self.embed_tokens(input_ids)
|
| 580 |
+
else:
|
| 581 |
+
raise ValueError("invalid inputs for embedding construction")
|
| 582 |
+
|
| 583 |
+
past_key_values_dict = {} if past_key_values_dict is None else dict(past_key_values_dict)
|
| 584 |
+
|
| 585 |
+
shared_cache: Optional[Cache] = None
|
| 586 |
+
if isinstance(past_key_values, dict):
|
| 587 |
+
# Accept dictionaries passed via either `past_key_values` or `past_key_values_dict`.
|
| 588 |
+
past_key_values_dict.update(past_key_values)
|
| 589 |
+
shared_cache = past_key_values.get("shared")
|
| 590 |
+
elif isinstance(past_key_values, Cache):
|
| 591 |
+
shared_cache = past_key_values
|
| 592 |
+
elif past_key_values is not None:
|
| 593 |
+
raise TypeError("past_key_values must be either a Cache instance, a dict of caches, or None")
|
| 594 |
+
|
| 595 |
+
if shared_cache is None:
|
| 596 |
+
shared_cache = past_key_values_dict.get("shared")
|
| 597 |
+
|
| 598 |
+
if use_cache:
|
| 599 |
+
if shared_cache is None:
|
| 600 |
+
shared_cache_config = copy.deepcopy(self.config)
|
| 601 |
+
shared_cache_config.layer_types = shared_cache_config.layer_types[: self.config.num_shared_layers]
|
| 602 |
+
shared_cache = DynamicCache(config=shared_cache_config)
|
| 603 |
+
|
| 604 |
+
past_key_values_dict = dict(past_key_values_dict)
|
| 605 |
+
past_key_values_dict["shared"] = shared_cache
|
| 606 |
+
|
| 607 |
+
for modality in self.modality_blocks:
|
| 608 |
+
cache = past_key_values_dict.get(modality)
|
| 609 |
+
if not isinstance(cache, Cache):
|
| 610 |
+
modality_config = copy.deepcopy(self.config)
|
| 611 |
+
modality_config.layer_types = modality_config.layer_types[-self.config.num_modality_layers :]
|
| 612 |
+
past_key_values_dict[modality] = DynamicCache(config=modality_config)
|
| 613 |
+
else:
|
| 614 |
+
shared_cache = None
|
| 615 |
+
|
| 616 |
+
if cache_position is None:
|
| 617 |
+
past_seen_tokens = 0
|
| 618 |
+
if isinstance(shared_cache, Cache):
|
| 619 |
+
past_seen_tokens = shared_cache.get_seq_length()
|
| 620 |
+
cache_position = torch.arange(
|
| 621 |
+
past_seen_tokens,
|
| 622 |
+
past_seen_tokens + inputs_embeds.shape[1],
|
| 623 |
+
device=inputs_embeds.device,
|
| 624 |
+
)
|
| 625 |
+
|
| 626 |
+
if position_ids is None:
|
| 627 |
+
position_ids = cache_position.unsqueeze(0)
|
| 628 |
+
|
| 629 |
+
# It may already have been prepared by e.g. `generate`
|
| 630 |
+
if not isinstance(causal_mask_mapping := attention_mask, dict):
|
| 631 |
+
# Prepare mask arguments
|
| 632 |
+
# For mask creation, we use the shared cache or None
|
| 633 |
+
mask_past_key_values = shared_cache if isinstance(shared_cache, Cache) else None
|
| 634 |
+
# attention_mask = None
|
| 635 |
+
mask_kwargs = {
|
| 636 |
+
"config": self.config,
|
| 637 |
+
"input_embeds": inputs_embeds,
|
| 638 |
+
"attention_mask": attention_mask,
|
| 639 |
+
"cache_position": cache_position,
|
| 640 |
+
"past_key_values": mask_past_key_values,
|
| 641 |
+
"position_ids": position_ids,
|
| 642 |
+
}
|
| 643 |
+
|
| 644 |
+
# Create the masks
|
| 645 |
+
causal_mask_mapping = {
|
| 646 |
+
"full_attention": create_causal_mask(**mask_kwargs),
|
| 647 |
+
}
|
| 648 |
+
# The sliding window alternating layers are not always activated depending on the config
|
| 649 |
+
if self.has_sliding_layers:
|
| 650 |
+
causal_mask_mapping["sliding_attention"] = create_sliding_window_causal_mask(**mask_kwargs)
|
| 651 |
+
|
| 652 |
+
hidden_states = inputs_embeds
|
| 653 |
+
|
| 654 |
+
# create position embeddings to be shared across the decoder layers
|
| 655 |
+
position_embeddings = self.rotary_emb(hidden_states, position_ids)
|
| 656 |
+
|
| 657 |
+
# shared block
|
| 658 |
+
hidden_states = self.shared_block(
|
| 659 |
+
hidden_states,
|
| 660 |
+
causal_masks=causal_mask_mapping,
|
| 661 |
+
position_ids=position_ids,
|
| 662 |
+
position_embeddings=position_embeddings,
|
| 663 |
+
past_key_values=shared_cache if use_cache else None,
|
| 664 |
+
use_cache=bool(use_cache),
|
| 665 |
+
cache_position=cache_position,
|
| 666 |
+
**kwargs,
|
| 667 |
+
)
|
| 668 |
+
|
| 669 |
+
# Compute hidden states for each modality
|
| 670 |
+
last_hidden_state_dict = {}
|
| 671 |
+
for modality in modalities:
|
| 672 |
+
mod_block = self._route_block(modality)
|
| 673 |
+
mod_norm = self._route_final_layer_norm(modality)
|
| 674 |
+
mod_cache = past_key_values_dict.get(modality) if use_cache else None
|
| 675 |
+
|
| 676 |
+
# Build modality-specific hidden_states starting from the same shared input
|
| 677 |
+
mod_hidden_states = mod_block(
|
| 678 |
+
hidden_states,
|
| 679 |
+
causal_masks=causal_mask_mapping,
|
| 680 |
+
position_ids=position_ids,
|
| 681 |
+
position_embeddings=position_embeddings,
|
| 682 |
+
past_key_values=mod_cache,
|
| 683 |
+
use_cache=bool(use_cache),
|
| 684 |
+
cache_position=cache_position,
|
| 685 |
+
**kwargs,
|
| 686 |
+
)
|
| 687 |
+
mod_hidden_states = mod_norm(mod_hidden_states)
|
| 688 |
+
last_hidden_state_dict[modality] = mod_hidden_states
|
| 689 |
+
|
| 690 |
+
return MossSpeechModelOutputWithPast(
|
| 691 |
+
last_hidden_state=hidden_states,
|
| 692 |
+
last_hidden_state_dict=last_hidden_state_dict,
|
| 693 |
+
past_key_values=shared_cache if use_cache else None,
|
| 694 |
+
past_key_values_dict=past_key_values_dict if use_cache else None,
|
| 695 |
+
)
|
| 696 |
+
|
| 697 |
+
|
| 698 |
+
class MossSpeechGenerationMixin(GenerationMixin):
|
| 699 |
+
"""Generation mixin for MossSpeech model with two-channel (text/audio) support."""
|
| 700 |
+
|
| 701 |
+
def _setup_processors(self, generation_config: GenerationConfig, modalities: int) -> list[LogitsProcessorList]:
|
| 702 |
+
"""Setup per-channel logits processors based on the generation config."""
|
| 703 |
+
realprocessor = [LogitsProcessorList() for _ in range(modalities)]
|
| 704 |
+
|
| 705 |
+
if hasattr(generation_config, "layers"):
|
| 706 |
+
for i, layer_config in enumerate(generation_config.layers):
|
| 707 |
+
if i >= len(realprocessor):
|
| 708 |
+
break
|
| 709 |
+
|
| 710 |
+
if layer_config.get("repetition_penalty") is not None:
|
| 711 |
+
realprocessor[i].append(
|
| 712 |
+
RepetitionPenaltyLogitsProcessor(penalty=layer_config.get("repetition_penalty"))
|
| 713 |
+
)
|
| 714 |
+
if layer_config.get("temperature") is not None:
|
| 715 |
+
realprocessor[i].append(TemperatureLogitsWarper(temperature=layer_config.get("temperature")))
|
| 716 |
+
if layer_config.get("top_k") is not None:
|
| 717 |
+
realprocessor[i].append(TopKLogitsWarper(top_k=layer_config.get("top_k")))
|
| 718 |
+
if layer_config.get("top_p") is not None:
|
| 719 |
+
realprocessor[i].append(TopPLogitsWarper(top_p=layer_config.get("top_p")))
|
| 720 |
+
|
| 721 |
+
return realprocessor
|
| 722 |
+
|
| 723 |
+
def _generate_next_tokens_with_scores(
|
| 724 |
+
self,
|
| 725 |
+
logits_all: tuple[torch.Tensor, ...],
|
| 726 |
+
input_ids: torch.LongTensor,
|
| 727 |
+
realprocessor: list[LogitsProcessorList],
|
| 728 |
+
do_samples: list[bool],
|
| 729 |
+
generation_config: GenerationConfig,
|
| 730 |
+
generating_length: int,
|
| 731 |
+
) -> tuple[torch.LongTensor, tuple[torch.Tensor, ...], tuple[torch.Tensor, ...]]:
|
| 732 |
+
"""Generate next tokens for all channels with scores and logits."""
|
| 733 |
+
# Get next token logits
|
| 734 |
+
next_token_logits = tuple(logits[:, -1, :].clone().float().to(input_ids.device) for logits in logits_all)
|
| 735 |
+
|
| 736 |
+
# Apply audio-channel-specific constraints
|
| 737 |
+
next_token_logits[1][:, 16385:] = -torch.inf
|
| 738 |
+
if hasattr(generation_config, "min_new_tokens") and generating_length < generation_config.min_new_tokens:
|
| 739 |
+
next_token_logits[1][:, 16384] = -torch.inf
|
| 740 |
+
|
| 741 |
+
# Process logits
|
| 742 |
+
next_token_scores = tuple(
|
| 743 |
+
realprocessor[i](input_ids[:, :, i], logits) for i, logits in enumerate(next_token_logits)
|
| 744 |
+
)
|
| 745 |
+
|
| 746 |
+
# Sample or select tokens
|
| 747 |
+
next_tokens = []
|
| 748 |
+
for i, channel_score in enumerate(next_token_scores):
|
| 749 |
+
if do_samples[i]:
|
| 750 |
+
channel_ntk = torch.multinomial(nn.functional.softmax(channel_score, dim=-1), num_samples=1).squeeze(1)
|
| 751 |
+
else:
|
| 752 |
+
channel_ntk = torch.argmax(channel_score, dim=-1)
|
| 753 |
+
next_tokens.append(channel_ntk)
|
| 754 |
+
|
| 755 |
+
return torch.stack(next_tokens, dim=-1), next_token_scores, next_token_logits
|
| 756 |
+
|
| 757 |
+
def _process_multi_modality_tokens(
|
| 758 |
+
self,
|
| 759 |
+
next_tokens: torch.LongTensor,
|
| 760 |
+
current_modality: torch.Tensor,
|
| 761 |
+
modality_pad_token: Union[int, torch.Tensor],
|
| 762 |
+
) -> torch.LongTensor:
|
| 763 |
+
"""Process tokens for MossSpeech generation."""
|
| 764 |
+
|
| 765 |
+
mask = current_modality == 1
|
| 766 |
+
if mask.any():
|
| 767 |
+
pad_value = modality_pad_token.item() if torch.is_tensor(modality_pad_token) else modality_pad_token
|
| 768 |
+
next_tokens[mask, 0] = int(pad_value)
|
| 769 |
+
|
| 770 |
+
return next_tokens
|
| 771 |
+
|
| 772 |
+
def _sample(
|
| 773 |
+
self,
|
| 774 |
+
input_ids: torch.LongTensor,
|
| 775 |
+
logits_processor: LogitsProcessorList,
|
| 776 |
+
stopping_criteria: StoppingCriteriaList,
|
| 777 |
+
generation_config: GenerationConfig,
|
| 778 |
+
synced_gpus: bool,
|
| 779 |
+
streamer: Optional[BaseStreamer],
|
| 780 |
+
**model_kwargs,
|
| 781 |
+
) -> Union[GenerateDecoderOnlyOutput, torch.LongTensor]:
|
| 782 |
+
"""Sampling implementation for MossSpeech with text and audio modalities."""
|
| 783 |
+
|
| 784 |
+
# Determine the pad token used to mask the text channel when the audio modality is active.
|
| 785 |
+
modality_pad_token = generation_config._pad_token_tensor
|
| 786 |
+
if modality_pad_token is None:
|
| 787 |
+
pad_fallback = getattr(self.config, "modality_pad_token_id", None)
|
| 788 |
+
if pad_fallback is None:
|
| 789 |
+
pad_fallback = getattr(self.config, "pad_token_id", None)
|
| 790 |
+
if pad_fallback is None:
|
| 791 |
+
raise ValueError(
|
| 792 |
+
"MossSpeech generation requires a pad token id; please set it on the config or generation config."
|
| 793 |
+
)
|
| 794 |
+
modality_pad_token = torch.tensor(
|
| 795 |
+
pad_fallback,
|
| 796 |
+
device=input_ids.device,
|
| 797 |
+
dtype=input_ids.dtype,
|
| 798 |
+
)
|
| 799 |
+
else:
|
| 800 |
+
modality_pad_token = modality_pad_token.to(device=input_ids.device, dtype=input_ids.dtype)
|
| 801 |
+
|
| 802 |
+
audio_pad_token_id = getattr(self.config, "audio_pad_token_id", None)
|
| 803 |
+
sosp_token_id = getattr(self.config, "sosp_token_id", None)
|
| 804 |
+
eosp_token_id = getattr(self.config, "eosp_token_id", None)
|
| 805 |
+
|
| 806 |
+
output_attentions = generation_config.output_attentions
|
| 807 |
+
output_hidden_states = generation_config.output_hidden_states
|
| 808 |
+
output_scores = generation_config.output_scores
|
| 809 |
+
output_logits = generation_config.output_logits
|
| 810 |
+
return_dict_in_generate = generation_config.return_dict_in_generate
|
| 811 |
+
global_do_sample = generation_config.do_sample
|
| 812 |
+
|
| 813 |
+
scores = () if (return_dict_in_generate and output_scores) else None
|
| 814 |
+
raw_logits = () if (return_dict_in_generate and output_logits) else None
|
| 815 |
+
decoder_attentions = () if (return_dict_in_generate and output_attentions) else None
|
| 816 |
+
decoder_hidden_states = () if (return_dict_in_generate and output_hidden_states) else None
|
| 817 |
+
|
| 818 |
+
batch_size, cur_len, input_modalities = input_ids.shape
|
| 819 |
+
this_peer_finished = False
|
| 820 |
+
unfinished_sequences = torch.ones(batch_size, dtype=torch.long, device=input_ids.device)
|
| 821 |
+
|
| 822 |
+
model_kwargs = self._get_initial_cache_position(cur_len, input_ids.device, model_kwargs)
|
| 823 |
+
|
| 824 |
+
if hasattr(generation_config, "do_samples") and generation_config.do_samples is not None:
|
| 825 |
+
per_modality_do_sample = generation_config.do_samples
|
| 826 |
+
logits_processors = self._setup_processors(generation_config, input_modalities)
|
| 827 |
+
else:
|
| 828 |
+
per_modality_do_sample = [global_do_sample for _ in range(input_modalities)]
|
| 829 |
+
logits_processors = [logits_processor for _ in range(input_modalities)]
|
| 830 |
+
|
| 831 |
+
current_modality = torch.zeros((batch_size,), dtype=torch.long, device=input_ids.device)
|
| 832 |
+
|
| 833 |
+
# Infer starting modality: text channel uses index 0, audio channel index 1
|
| 834 |
+
if self.config.modality_pad_token_id is not None:
|
| 835 |
+
audio_mask = input_ids[:, -1, 0] == self.config.modality_pad_token_id
|
| 836 |
+
current_modality[audio_mask] = 1
|
| 837 |
+
if audio_pad_token_id is not None:
|
| 838 |
+
text_mask = input_ids[:, -1, 1] == audio_pad_token_id
|
| 839 |
+
current_modality[text_mask] = 0
|
| 840 |
+
|
| 841 |
+
generating_length = 0
|
| 842 |
+
while self._has_unfinished_sequences(this_peer_finished, synced_gpus, device=input_ids.device):
|
| 843 |
+
generating_length += 1
|
| 844 |
+
model_inputs = self.prepare_inputs_for_generation(input_ids, **model_kwargs)
|
| 845 |
+
if output_attentions:
|
| 846 |
+
model_inputs["output_attentions"] = output_attentions
|
| 847 |
+
if output_hidden_states:
|
| 848 |
+
model_inputs["output_hidden_states"] = output_hidden_states
|
| 849 |
+
if "past_key_values_dict" in model_kwargs:
|
| 850 |
+
model_inputs["past_key_values_dict"] = model_kwargs["past_key_values_dict"]
|
| 851 |
+
|
| 852 |
+
if sosp_token_id is not None:
|
| 853 |
+
text_mode_mask = current_modality == 0
|
| 854 |
+
text_to_audio_mask = text_mode_mask & (input_ids[:, -1, 0] == sosp_token_id)
|
| 855 |
+
current_modality[text_to_audio_mask] = 1
|
| 856 |
+
if eosp_token_id is not None:
|
| 857 |
+
audio_mode_mask = current_modality == 1
|
| 858 |
+
audio_to_text_mask = audio_mode_mask & (input_ids[:, -1, 1] == eosp_token_id)
|
| 859 |
+
current_modality[audio_to_text_mask] = 0
|
| 860 |
+
|
| 861 |
+
outputs = self(**model_inputs, return_dict=True)
|
| 862 |
+
model_kwargs = self._update_model_kwargs_for_generation(outputs, model_kwargs, is_encoder_decoder=False)
|
| 863 |
+
if outputs.past_key_values_dict is not None:
|
| 864 |
+
model_kwargs["past_key_values_dict"] = outputs.past_key_values_dict
|
| 865 |
+
|
| 866 |
+
if synced_gpus and this_peer_finished:
|
| 867 |
+
continue
|
| 868 |
+
|
| 869 |
+
next_tokens, next_token_scores, next_token_logits = self._generate_next_tokens_with_scores(
|
| 870 |
+
outputs.logits_all,
|
| 871 |
+
input_ids,
|
| 872 |
+
logits_processors,
|
| 873 |
+
per_modality_do_sample,
|
| 874 |
+
generation_config,
|
| 875 |
+
generating_length,
|
| 876 |
+
)
|
| 877 |
+
next_tokens = self._process_multi_modality_tokens(
|
| 878 |
+
next_tokens,
|
| 879 |
+
current_modality,
|
| 880 |
+
modality_pad_token,
|
| 881 |
+
)
|
| 882 |
+
|
| 883 |
+
input_ids = torch.cat([input_ids, next_tokens[:, None, :]], dim=1)
|
| 884 |
+
if streamer is not None:
|
| 885 |
+
streamer.put(next_tokens[:, 0].cpu())
|
| 886 |
+
|
| 887 |
+
stopping = stopping_criteria(input_ids[:, :, 0], scores)
|
| 888 |
+
|
| 889 |
+
unfinished_sequences = unfinished_sequences & ~stopping
|
| 890 |
+
this_peer_finished = unfinished_sequences.max() == 0
|
| 891 |
+
|
| 892 |
+
if return_dict_in_generate:
|
| 893 |
+
if output_scores:
|
| 894 |
+
scores += (next_token_scores,)
|
| 895 |
+
if output_logits:
|
| 896 |
+
raw_logits += (next_token_logits,)
|
| 897 |
+
if output_attentions:
|
| 898 |
+
decoder_attentions += (outputs.attentions,)
|
| 899 |
+
if output_hidden_states:
|
| 900 |
+
decoder_hidden_states += (outputs.hidden_states,)
|
| 901 |
+
|
| 902 |
+
cur_len += 1
|
| 903 |
+
|
| 904 |
+
if streamer is not None:
|
| 905 |
+
streamer.end()
|
| 906 |
+
|
| 907 |
+
if return_dict_in_generate:
|
| 908 |
+
return GenerateDecoderOnlyOutput(
|
| 909 |
+
sequences=input_ids,
|
| 910 |
+
scores=scores,
|
| 911 |
+
logits=raw_logits,
|
| 912 |
+
attentions=decoder_attentions,
|
| 913 |
+
hidden_states=decoder_hidden_states,
|
| 914 |
+
past_key_values=model_kwargs.get("past_key_values"),
|
| 915 |
+
)
|
| 916 |
+
|
| 917 |
+
return input_ids
|
| 918 |
+
|
| 919 |
+
def generate(
|
| 920 |
+
self,
|
| 921 |
+
input_ids: Optional[torch.Tensor] = None,
|
| 922 |
+
output_only: bool = True,
|
| 923 |
+
**kwargs,
|
| 924 |
+
):
|
| 925 |
+
batch_size, seq_len, modalities = input_ids.shape
|
| 926 |
+
start_id = seq_len
|
| 927 |
+
outputs = super().generate(input_ids, **kwargs)
|
| 928 |
+
return_dict_in_generate = kwargs.get("return_dict_in_generate", False)
|
| 929 |
+
if return_dict_in_generate:
|
| 930 |
+
output_ids = outputs["sequences"]
|
| 931 |
+
else:
|
| 932 |
+
output_ids = outputs
|
| 933 |
+
if output_only:
|
| 934 |
+
output_ids = output_ids[:, start_id:, :]
|
| 935 |
+
if return_dict_in_generate:
|
| 936 |
+
outputs["sequences"] = output_ids
|
| 937 |
+
else:
|
| 938 |
+
outputs = output_ids
|
| 939 |
+
return outputs
|
| 940 |
+
|
| 941 |
+
def _prepare_attention_mask_for_generation(
|
| 942 |
+
self,
|
| 943 |
+
inputs_tensor: torch.Tensor,
|
| 944 |
+
generation_config: GenerationConfig,
|
| 945 |
+
model_kwargs: dict[str, Any],
|
| 946 |
+
) -> torch.LongTensor:
|
| 947 |
+
pad_token_id = generation_config._pad_token_tensor
|
| 948 |
+
eos_token_id = generation_config._eos_token_tensor
|
| 949 |
+
|
| 950 |
+
# `input_ids` may be present in the model kwargs, instead of being the main input (e.g. multimodal model)
|
| 951 |
+
if "input_ids" in model_kwargs and model_kwargs["input_ids"].shape[1] > 0:
|
| 952 |
+
inputs_tensor = model_kwargs["input_ids"]
|
| 953 |
+
|
| 954 |
+
# No information for attention mask inference -> return default attention mask
|
| 955 |
+
if len(inputs_tensor.shape) == 3 and inputs_tensor.shape[1] == 2:
|
| 956 |
+
# For (B, 2, seq_len) inputs, create a (B, seq_len) attention mask
|
| 957 |
+
default_attention_mask = torch.ones(
|
| 958 |
+
(inputs_tensor.shape[0], inputs_tensor.shape[2]), # (B, seq_len)
|
| 959 |
+
dtype=torch.long,
|
| 960 |
+
device=inputs_tensor.device,
|
| 961 |
+
)
|
| 962 |
+
else:
|
| 963 |
+
# Keep the original logic for (B, seq_len) inputs
|
| 964 |
+
default_attention_mask = torch.ones(
|
| 965 |
+
inputs_tensor.shape[:2], # (B, seq_len)
|
| 966 |
+
dtype=torch.long,
|
| 967 |
+
device=inputs_tensor.device,
|
| 968 |
+
)
|
| 969 |
+
if pad_token_id is None:
|
| 970 |
+
return default_attention_mask
|
| 971 |
+
|
| 972 |
+
is_input_ids = len(inputs_tensor.shape) == 2 and inputs_tensor.dtype in [torch.int, torch.long]
|
| 973 |
+
if not is_input_ids:
|
| 974 |
+
return default_attention_mask
|
| 975 |
+
|
| 976 |
+
is_pad_token_in_inputs = (pad_token_id is not None) and (
|
| 977 |
+
isin_mps_friendly(elements=inputs_tensor, test_elements=pad_token_id).any()
|
| 978 |
+
)
|
| 979 |
+
is_pad_token_not_equal_to_eos_token_id = (eos_token_id is None) or ~(
|
| 980 |
+
isin_mps_friendly(elements=eos_token_id, test_elements=pad_token_id).any()
|
| 981 |
+
)
|
| 982 |
+
can_infer_attention_mask = is_pad_token_in_inputs * is_pad_token_not_equal_to_eos_token_id
|
| 983 |
+
attention_mask_from_padding = inputs_tensor.ne(pad_token_id).long()
|
| 984 |
+
|
| 985 |
+
attention_mask = (
|
| 986 |
+
attention_mask_from_padding * can_infer_attention_mask + default_attention_mask * ~can_infer_attention_mask
|
| 987 |
+
)
|
| 988 |
+
return attention_mask
|
| 989 |
+
|
| 990 |
+
|
| 991 |
+
@auto_docstring
|
| 992 |
+
class MossSpeechForCausalLM(MossSpeechPreTrainedModel, MossSpeechGenerationMixin):
|
| 993 |
+
_tied_weights_keys = ["text_lm_head.weight", "audio_lm_head.weight"]
|
| 994 |
+
_tp_plan = {"text_lm_head": "colwise_rep", "audio_lm_head": "colwise_rep"}
|
| 995 |
+
_pp_plan = {
|
| 996 |
+
"text_lm_head": (["hidden_states"], ["logits"]),
|
| 997 |
+
"audio_lm_head": (["hidden_states"], ["logits"]),
|
| 998 |
+
}
|
| 999 |
+
|
| 1000 |
+
def __init__(self, config):
|
| 1001 |
+
super().__init__(config)
|
| 1002 |
+
self.model = MossSpeechModel(config)
|
| 1003 |
+
self.vocab_size = config.vocab_size
|
| 1004 |
+
self.text_lm_head = nn.Linear(config.hidden_size, config.vocab_size, bias=False)
|
| 1005 |
+
self.audio_lm_head = nn.Linear(config.hidden_size, config.audio_vocab_size, bias=False)
|
| 1006 |
+
self.modality_lm_head = {
|
| 1007 |
+
"text": self.text_lm_head,
|
| 1008 |
+
"audio": self.audio_lm_head,
|
| 1009 |
+
}
|
| 1010 |
+
|
| 1011 |
+
# Initialize weights and apply final processing
|
| 1012 |
+
self.post_init()
|
| 1013 |
+
|
| 1014 |
+
@can_return_tuple
|
| 1015 |
+
@auto_docstring
|
| 1016 |
+
def forward(
|
| 1017 |
+
self,
|
| 1018 |
+
input_ids: Optional[torch.LongTensor] = None,
|
| 1019 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 1020 |
+
position_ids: Optional[torch.LongTensor] = None,
|
| 1021 |
+
past_key_values: Optional[torch.Tensor] = None,
|
| 1022 |
+
past_key_values_dict: Optional[dict] = None,
|
| 1023 |
+
inputs_embeds: Optional[torch.FloatTensor] = None,
|
| 1024 |
+
labels: Optional[torch.LongTensor] = None,
|
| 1025 |
+
use_cache: Optional[bool] = None,
|
| 1026 |
+
cache_position: Optional[torch.LongTensor] = None,
|
| 1027 |
+
logits_to_keep: Union[int, torch.Tensor] = 0,
|
| 1028 |
+
**kwargs: Unpack[TransformersKwargs],
|
| 1029 |
+
) -> MossSpeechCausalLMOutputWithPast:
|
| 1030 |
+
r"""
|
| 1031 |
+
labels (`torch.LongTensor` of shape `(batch_size, 2, sequence_length)` or `(batch_size, 2*sequence_length)`, *optional*):
|
| 1032 |
+
Labels for computing the masked language modeling loss. Indices should either be in `[0, ...,
|
| 1033 |
+
config.vocab_size]` or -100 (see `input_ids` docstring). Tokens with indices set to `-100` are ignored
|
| 1034 |
+
(masked), the loss is only computed for the tokens with labels in `[0, ..., config.vocab_size]`.
|
| 1035 |
+
|
| 1036 |
+
past_key_values_dict (Optional[dict]): KV cache for each block.
|
| 1037 |
+
|
| 1038 |
+
Example:
|
| 1039 |
+
|
| 1040 |
+
```python
|
| 1041 |
+
>>> from transformers import AutoTokenizer, MossSpeechForCausalLM
|
| 1042 |
+
|
| 1043 |
+
>>> model = MossSpeechForCausalLM.from_pretrained("Qwen/MossSpeech-8B")
|
| 1044 |
+
>>> tokenizer = AutoTokenizer.from_pretrained("Qwen/MossSpeech-8B")
|
| 1045 |
+
|
| 1046 |
+
>>> prompt = "Hey, are you conscious? Can you talk to me?"
|
| 1047 |
+
>>> inputs = tokenizer(prompt, return_tensors="pt")
|
| 1048 |
+
|
| 1049 |
+
>>> # Generate
|
| 1050 |
+
>>> generate_ids = model.generate(inputs.input_ids, max_length=30)
|
| 1051 |
+
>>> tokenizer.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]
|
| 1052 |
+
"Hey, are you conscious? Can you talk to me?\nI'm not conscious, but I can talk to you."
|
| 1053 |
+
```
|
| 1054 |
+
"""
|
| 1055 |
+
if input_ids is not None and input_ids.dim() == 2:
|
| 1056 |
+
B = input_ids.shape[0]
|
| 1057 |
+
input_ids = input_ids.reshape([B, 2, -1])
|
| 1058 |
+
|
| 1059 |
+
input_ids = input_ids.transpose(1, 2)
|
| 1060 |
+
outputs: MossSpeechModelOutputWithPast = self.model(
|
| 1061 |
+
modalities=["text", "audio"],
|
| 1062 |
+
input_ids=input_ids,
|
| 1063 |
+
attention_mask=attention_mask,
|
| 1064 |
+
position_ids=position_ids,
|
| 1065 |
+
past_key_values=past_key_values,
|
| 1066 |
+
past_key_values_dict=past_key_values_dict,
|
| 1067 |
+
inputs_embeds=inputs_embeds,
|
| 1068 |
+
use_cache=use_cache,
|
| 1069 |
+
cache_position=cache_position,
|
| 1070 |
+
**kwargs,
|
| 1071 |
+
)
|
| 1072 |
+
text_hidden_states = outputs.last_hidden_state_dict["text"]
|
| 1073 |
+
audio_hidden_states = outputs.last_hidden_state_dict["audio"]
|
| 1074 |
+
# Only compute necessary logits, and do not upcast them to float if we are not computing the loss
|
| 1075 |
+
slice_indices = slice(-logits_to_keep, None) if isinstance(logits_to_keep, int) else logits_to_keep
|
| 1076 |
+
text_logits = self.modality_lm_head["text"](text_hidden_states[:, slice_indices, :])
|
| 1077 |
+
audio_logits = self.modality_lm_head["audio"](audio_hidden_states[:, slice_indices, :])
|
| 1078 |
+
|
| 1079 |
+
text_loss = None
|
| 1080 |
+
audio_loss = None
|
| 1081 |
+
if labels is not None:
|
| 1082 |
+
if labels.dim() == 2:
|
| 1083 |
+
B = labels.shape[0]
|
| 1084 |
+
labels.reshape([B, 2, -1])
|
| 1085 |
+
text_labels = labels[:, 0, :]
|
| 1086 |
+
audio_labels = labels[:, 1, :]
|
| 1087 |
+
text_loss = self.loss_function(
|
| 1088 |
+
logits=text_logits,
|
| 1089 |
+
labels=text_labels,
|
| 1090 |
+
vocab_size=self.config.vocab_size,
|
| 1091 |
+
**kwargs,
|
| 1092 |
+
)
|
| 1093 |
+
audio_loss = self.loss_function(
|
| 1094 |
+
logits=audio_logits,
|
| 1095 |
+
labels=audio_labels,
|
| 1096 |
+
vocab_size=self.config.vocab_size,
|
| 1097 |
+
**kwargs,
|
| 1098 |
+
)
|
| 1099 |
+
return MossSpeechCausalLMOutputWithPast(
|
| 1100 |
+
text_loss=text_loss,
|
| 1101 |
+
audio_loss=audio_loss,
|
| 1102 |
+
text_logits=text_logits,
|
| 1103 |
+
audio_logits=audio_logits,
|
| 1104 |
+
logits_all=(text_logits, audio_logits),
|
| 1105 |
+
past_key_values=outputs.past_key_values,
|
| 1106 |
+
past_key_values_dict=outputs.past_key_values_dict,
|
| 1107 |
+
text_hidden_states=text_hidden_states,
|
| 1108 |
+
audio_hidden_states=audio_hidden_states,
|
| 1109 |
+
attentions=outputs.attentions,
|
| 1110 |
+
)
|
| 1111 |
+
|
| 1112 |
+
|
| 1113 |
+
class MossSpeechForSequenceClassification(GenericForSequenceClassification, MossSpeechPreTrainedModel):
|
| 1114 |
+
pass
|
| 1115 |
+
|
| 1116 |
+
|
| 1117 |
+
class MossSpeechForTokenClassification(GenericForTokenClassification, MossSpeechPreTrainedModel):
|
| 1118 |
+
pass
|
| 1119 |
+
|
| 1120 |
+
|
| 1121 |
+
class MossSpeechForQuestionAnswering(GenericForQuestionAnswering, MossSpeechPreTrainedModel):
|
| 1122 |
+
base_model_prefix = "transformer" # For BC, where `transformer` was used instead of `model`
|
| 1123 |
+
|
| 1124 |
+
|
| 1125 |
+
__all__ = [
|
| 1126 |
+
"MossSpeechForCausalLM",
|
| 1127 |
+
"MossSpeechForQuestionAnswering",
|
| 1128 |
+
"MossSpeechPreTrainedModel",
|
| 1129 |
+
"MossSpeechModel",
|
| 1130 |
+
"MossSpeechForSequenceClassification",
|
| 1131 |
+
"MossSpeechForTokenClassification",
|
| 1132 |
+
]
|
processing_moss_speech.py
ADDED
|
@@ -0,0 +1,419 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# coding=utf-8
|
| 2 |
+
# Copyright 2025 OpenMOSS and the HuggingFace Inc. team. All rights
|
| 3 |
+
# reserved.
|
| 4 |
+
#
|
| 5 |
+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
| 6 |
+
# not use this file except in compliance with the License. You may obtain a
|
| 7 |
+
# copy of the License at
|
| 8 |
+
#
|
| 9 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 10 |
+
#
|
| 11 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 12 |
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
| 13 |
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
| 14 |
+
# License for the specific language governing permissions and limitations
|
| 15 |
+
# under the License.
|
| 16 |
+
"""Processor class for MossSpeech."""
|
| 17 |
+
|
| 18 |
+
from __future__ import annotations
|
| 19 |
+
|
| 20 |
+
import os
|
| 21 |
+
import re
|
| 22 |
+
from dataclasses import asdict, dataclass
|
| 23 |
+
from typing import Any, Mapping, Optional, Sequence, Union
|
| 24 |
+
|
| 25 |
+
from transformers import AutoTokenizer
|
| 26 |
+
from transformers.processing_utils import ProcessingKwargs, ProcessorMixin
|
| 27 |
+
from transformers.tokenization_utils_base import BatchEncoding
|
| 28 |
+
from transformers.utils import OptionalDependencyNotAvailable, is_torch_available, logging
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
logger = logging.get_logger(__name__)
|
| 32 |
+
|
| 33 |
+
if is_torch_available():
|
| 34 |
+
import torch
|
| 35 |
+
else: # pragma: no cover
|
| 36 |
+
torch = None # type: ignore[assignment]
|
| 37 |
+
|
| 38 |
+
MossSpeechCodec = None
|
| 39 |
+
_MOSS_CODEC_IMPORT_ERROR: Optional[Exception] = None
|
| 40 |
+
|
| 41 |
+
_TEXT_PLACEHOLDER_TOKEN_ID = 151667
|
| 42 |
+
_AUDIO_PAD_TOKEN_ID = 512
|
| 43 |
+
_SOSP_TOKEN_ID = 151646
|
| 44 |
+
_EOSP_TOKEN_ID = 16384
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
def _ensure_dependencies() -> None:
|
| 48 |
+
global MossSpeechCodec, _MOSS_CODEC_IMPORT_ERROR
|
| 49 |
+
|
| 50 |
+
if torch is None:
|
| 51 |
+
raise OptionalDependencyNotAvailable()
|
| 52 |
+
|
| 53 |
+
if MossSpeechCodec is None:
|
| 54 |
+
try:
|
| 55 |
+
from MossSpeechCodec import MossSpeechCodec as _Codec # type: ignore
|
| 56 |
+
except ImportError as import_error: # pragma: no cover
|
| 57 |
+
_MOSS_CODEC_IMPORT_ERROR = import_error
|
| 58 |
+
raise OptionalDependencyNotAvailable() from import_error
|
| 59 |
+
else:
|
| 60 |
+
MossSpeechCodec = _Codec
|
| 61 |
+
_MOSS_CODEC_IMPORT_ERROR = None
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
class MossSpeechProcessorKwargs(ProcessingKwargs, total=False):
|
| 65 |
+
"""Default keyword argument groups supported by :class:`MossSpeechProcessor`."""
|
| 66 |
+
|
| 67 |
+
_defaults = {
|
| 68 |
+
"common_kwargs": {
|
| 69 |
+
"return_tensors": "pt",
|
| 70 |
+
"padding": True,
|
| 71 |
+
}
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
@dataclass
|
| 76 |
+
class MossSpeechChatSample:
|
| 77 |
+
"""Per-sample MossSpeech input with two-channel token grid."""
|
| 78 |
+
|
| 79 |
+
input_ids_2d: "torch.LongTensor"
|
| 80 |
+
label_ids_2d: Optional["torch.LongTensor"] = None
|
| 81 |
+
|
| 82 |
+
|
| 83 |
+
@dataclass
|
| 84 |
+
class MossSpeechBatchInput:
|
| 85 |
+
"""Batched MossSpeech tensors returned by the processor."""
|
| 86 |
+
|
| 87 |
+
input_ids: "torch.LongTensor"
|
| 88 |
+
attention_mask: "torch.LongTensor"
|
| 89 |
+
labels: Optional["torch.LongTensor"] = None
|
| 90 |
+
|
| 91 |
+
|
| 92 |
+
@dataclass
|
| 93 |
+
class MossSpeechResponse:
|
| 94 |
+
"""Decoded MossSpeech output item containing text and optional audio."""
|
| 95 |
+
|
| 96 |
+
audio: Optional["torch.Tensor"] = None
|
| 97 |
+
generated_text: str = ""
|
| 98 |
+
sampling_rate: Optional[int] = None
|
| 99 |
+
|
| 100 |
+
|
| 101 |
+
@dataclass
|
| 102 |
+
class _MossSpeechInputSegment:
|
| 103 |
+
"""Internal helper representing either text or audio tokens."""
|
| 104 |
+
|
| 105 |
+
text: Optional[str] = None
|
| 106 |
+
audio_tokens: Optional["torch.Tensor"] = None
|
| 107 |
+
tokenized_text: Optional["torch.Tensor"] = None
|
| 108 |
+
|
| 109 |
+
def __post_init__(self) -> None:
|
| 110 |
+
if self.text is None and self.tokenized_text is None:
|
| 111 |
+
raise ValueError("A segment must provide text or tokenized_text content.")
|
| 112 |
+
if self.audio_tokens is not None and self.audio_tokens.dim() != 1:
|
| 113 |
+
raise ValueError("`audio_tokens` must be a 1D tensor of codec token ids.")
|
| 114 |
+
|
| 115 |
+
def to_tensor(self, tokenizer: AutoTokenizer) -> "torch.Tensor":
|
| 116 |
+
_ensure_dependencies()
|
| 117 |
+
if self.tokenized_text is None:
|
| 118 |
+
tokenized = tokenizer(
|
| 119 |
+
self.text,
|
| 120 |
+
return_tensors="pt",
|
| 121 |
+
truncation=True,
|
| 122 |
+
max_length=999999,
|
| 123 |
+
padding=False,
|
| 124 |
+
add_special_tokens=False,
|
| 125 |
+
)["input_ids"].to(dtype=torch.long)
|
| 126 |
+
else:
|
| 127 |
+
tokenized = self.tokenized_text.unsqueeze(0).to(dtype=torch.long)
|
| 128 |
+
|
| 129 |
+
if self.audio_tokens is None:
|
| 130 |
+
audio_channel = torch.full_like(tokenized, _AUDIO_PAD_TOKEN_ID)
|
| 131 |
+
return torch.cat([tokenized, audio_channel], dim=0)
|
| 132 |
+
|
| 133 |
+
audio_tokens = self.audio_tokens.reshape(1, -1).to(dtype=torch.long)
|
| 134 |
+
text_channel = torch.full((1, audio_tokens.shape[1]), _TEXT_PLACEHOLDER_TOKEN_ID, dtype=torch.long)
|
| 135 |
+
|
| 136 |
+
sosp = torch.tensor([[_SOSP_TOKEN_ID]], dtype=torch.long)
|
| 137 |
+
text_pad = torch.tensor([[_TEXT_PLACEHOLDER_TOKEN_ID]], dtype=torch.long)
|
| 138 |
+
eosp = torch.tensor([[_EOSP_TOKEN_ID]], dtype=torch.long)
|
| 139 |
+
audio_pad = torch.tensor([[_AUDIO_PAD_TOKEN_ID]], dtype=torch.long)
|
| 140 |
+
|
| 141 |
+
text_channel = torch.cat([sosp, text_channel, text_pad], dim=1)
|
| 142 |
+
audio_channel = torch.cat([audio_pad, audio_tokens, eosp], dim=1)
|
| 143 |
+
return torch.cat([text_channel, audio_channel], dim=0)
|
| 144 |
+
|
| 145 |
+
|
| 146 |
+
class MossSpeechSampleProcessor:
|
| 147 |
+
"""Formats a structured conversation into MossSpeech grid tokens."""
|
| 148 |
+
|
| 149 |
+
def __init__(
|
| 150 |
+
self,
|
| 151 |
+
tokenizer: AutoTokenizer,
|
| 152 |
+
audio_codec: MossSpeechCodec,
|
| 153 |
+
default_system_prompts: Mapping[str, str],
|
| 154 |
+
) -> None:
|
| 155 |
+
self.tokenizer = tokenizer
|
| 156 |
+
self.audio_codec = audio_codec
|
| 157 |
+
self.default_system_prompts = default_system_prompts
|
| 158 |
+
|
| 159 |
+
def prepare_sample(
|
| 160 |
+
self,
|
| 161 |
+
conversation: Sequence[Mapping[str, Any]],
|
| 162 |
+
output_modality: str,
|
| 163 |
+
) -> MossSpeechChatSample:
|
| 164 |
+
_ensure_dependencies()
|
| 165 |
+
if len(conversation) == 0:
|
| 166 |
+
raise ValueError("`conversation` must contain at least one turn.")
|
| 167 |
+
|
| 168 |
+
segments: list[_MossSpeechInputSegment] = []
|
| 169 |
+
for turn in conversation:
|
| 170 |
+
role = turn.get("role")
|
| 171 |
+
if role not in {"user", "assistant", "system"}:
|
| 172 |
+
raise ValueError(f"Unsupported role `{role}` detected.")
|
| 173 |
+
|
| 174 |
+
segments.append(_MossSpeechInputSegment(text=f"<|im_start|>{role}\n"))
|
| 175 |
+
content = turn.get("content")
|
| 176 |
+
if isinstance(content, Mapping):
|
| 177 |
+
audio_path = content.get("path")
|
| 178 |
+
if audio_path is None:
|
| 179 |
+
raise ValueError("Audio turn content must include a `path` entry.")
|
| 180 |
+
encoded = self.audio_codec.encode([audio_path])[0]
|
| 181 |
+
segments.append(_MossSpeechInputSegment(audio_tokens=torch.tensor(encoded, dtype=torch.long)))
|
| 182 |
+
else:
|
| 183 |
+
segments.append(_MossSpeechInputSegment(text=str(content)))
|
| 184 |
+
segments.append(_MossSpeechInputSegment(text="<|im_end|>\n"))
|
| 185 |
+
|
| 186 |
+
if conversation[0].get("role") != "system":
|
| 187 |
+
system_prompt = self.default_system_prompts.get(output_modality)
|
| 188 |
+
if system_prompt is None:
|
| 189 |
+
raise KeyError(f"Missing default system prompt for modality `{output_modality}`.")
|
| 190 |
+
segments.extend(
|
| 191 |
+
[
|
| 192 |
+
_MossSpeechInputSegment(text="<|im_start|>system\n"),
|
| 193 |
+
_MossSpeechInputSegment(text=system_prompt),
|
| 194 |
+
_MossSpeechInputSegment(text="<|im_end|>\n"),
|
| 195 |
+
]
|
| 196 |
+
)
|
| 197 |
+
|
| 198 |
+
if output_modality == "text":
|
| 199 |
+
segments.append(_MossSpeechInputSegment(text="<|im_start|>assistant\n"))
|
| 200 |
+
elif output_modality == "audio":
|
| 201 |
+
segments.append(_MossSpeechInputSegment(text="<|im_start|>assistant\n<|object_ref_start|>"))
|
| 202 |
+
else:
|
| 203 |
+
raise NotImplementedError("Supported modalities are `text` and `audio`.")
|
| 204 |
+
|
| 205 |
+
input_tensors = [segment.to_tensor(self.tokenizer) for segment in segments]
|
| 206 |
+
input_ids = torch.cat(input_tensors, dim=1)
|
| 207 |
+
return MossSpeechChatSample(input_ids_2d=input_ids)
|
| 208 |
+
|
| 209 |
+
def collate(
|
| 210 |
+
self,
|
| 211 |
+
samples: Sequence[MossSpeechChatSample],
|
| 212 |
+
*,
|
| 213 |
+
pad_token_id: int,
|
| 214 |
+
audio_pad_token_id: int,
|
| 215 |
+
) -> MossSpeechBatchInput:
|
| 216 |
+
_ensure_dependencies()
|
| 217 |
+
if len(samples) == 0:
|
| 218 |
+
raise ValueError("`samples` must not be empty.")
|
| 219 |
+
|
| 220 |
+
channel_count = samples[0].input_ids_2d.shape[0]
|
| 221 |
+
max_length = max(sample.input_ids_2d.shape[1] for sample in samples)
|
| 222 |
+
|
| 223 |
+
padded_inputs: list["torch.Tensor"] = []
|
| 224 |
+
attention_masks: list["torch.Tensor"] = []
|
| 225 |
+
|
| 226 |
+
for sample in samples:
|
| 227 |
+
seq_len = sample.input_ids_2d.shape[1]
|
| 228 |
+
pad_len = max_length - seq_len
|
| 229 |
+
|
| 230 |
+
pad_grid = torch.full((channel_count, pad_len), audio_pad_token_id, dtype=torch.long)
|
| 231 |
+
pad_grid[0] = pad_grid[0].fill_(pad_token_id)
|
| 232 |
+
padded_inputs.append(torch.cat([pad_grid, sample.input_ids_2d], dim=1))
|
| 233 |
+
|
| 234 |
+
attention_prefix = torch.zeros(pad_len, dtype=torch.long)
|
| 235 |
+
attention_body = torch.ones(seq_len, dtype=torch.long)
|
| 236 |
+
attention_masks.append(torch.cat([attention_prefix, attention_body], dim=0))
|
| 237 |
+
|
| 238 |
+
input_ids = torch.stack(padded_inputs).permute(0, 2, 1)
|
| 239 |
+
attention_mask = torch.stack(attention_masks)
|
| 240 |
+
|
| 241 |
+
return MossSpeechBatchInput(
|
| 242 |
+
input_ids=input_ids,
|
| 243 |
+
attention_mask=attention_mask,
|
| 244 |
+
labels=None,
|
| 245 |
+
)
|
| 246 |
+
|
| 247 |
+
|
| 248 |
+
class MossSpeechProcessor(ProcessorMixin):
|
| 249 |
+
r"""Combines MossSpeech tokenizer and codec for unified text/audio processing."""
|
| 250 |
+
|
| 251 |
+
tokenizer_class = "AutoTokenizer"
|
| 252 |
+
audio_codec_class = "PreTrainedModel"
|
| 253 |
+
attributes = ["tokenizer", "audio_codec"]
|
| 254 |
+
|
| 255 |
+
def __init__(
|
| 256 |
+
self,
|
| 257 |
+
tokenizer,
|
| 258 |
+
audio_codec,
|
| 259 |
+
**kwargs,
|
| 260 |
+
) -> None:
|
| 261 |
+
_ensure_dependencies()
|
| 262 |
+
super().__init__(tokenizer=tokenizer, audio_codec=audio_codec, **kwargs)
|
| 263 |
+
self.default_system_prompts = {
|
| 264 |
+
"text": "You are a helpful assistant. Respond with text outputs.",
|
| 265 |
+
"audio": "You are a helpful assistant. Respond with spoken outputs.",
|
| 266 |
+
}
|
| 267 |
+
self.sample_processor = MossSpeechSampleProcessor(
|
| 268 |
+
tokenizer=self.tokenizer,
|
| 269 |
+
audio_codec=self.audio_codec,
|
| 270 |
+
default_system_prompts=self.default_system_prompts,
|
| 271 |
+
)
|
| 272 |
+
self.sosp_token_id = _SOSP_TOKEN_ID
|
| 273 |
+
self.eosp_token_id = _EOSP_TOKEN_ID
|
| 274 |
+
|
| 275 |
+
@classmethod
|
| 276 |
+
def from_pretrained(
|
| 277 |
+
cls,
|
| 278 |
+
pretrained_model_name_or_path: Union[str, os.PathLike[str]],
|
| 279 |
+
trust_remote_code: bool = True,
|
| 280 |
+
**kwargs: Any,
|
| 281 |
+
) -> "MossSpeechProcessor":
|
| 282 |
+
kwargs.pop("_from_auto", None)
|
| 283 |
+
codec_path = kwargs.pop("codec_path", None)
|
| 284 |
+
if codec_path is None:
|
| 285 |
+
raise ValueError("`codec_path` must be supplied to load the MossSpeech codec.")
|
| 286 |
+
|
| 287 |
+
device = kwargs.pop("device", None) or "cpu"
|
| 288 |
+
tokenizer = AutoTokenizer.from_pretrained(
|
| 289 |
+
pretrained_model_name_or_path,
|
| 290 |
+
trust_remote_code=trust_remote_code,
|
| 291 |
+
**kwargs,
|
| 292 |
+
)
|
| 293 |
+
_ensure_dependencies()
|
| 294 |
+
audio_codec = MossSpeechCodec.from_pretrained(codec_path, trust_remote_code=True).to(device)
|
| 295 |
+
return cls(tokenizer=tokenizer, audio_codec=audio_codec)
|
| 296 |
+
|
| 297 |
+
def __call__(
|
| 298 |
+
self,
|
| 299 |
+
data: Union[Mapping[str, Any], Sequence[Sequence[Mapping[str, Any]]]],
|
| 300 |
+
output_modalities: Union[str, Sequence[str]],
|
| 301 |
+
**kwargs: Any,
|
| 302 |
+
) -> BatchEncoding:
|
| 303 |
+
_ensure_dependencies()
|
| 304 |
+
if isinstance(data, Mapping):
|
| 305 |
+
samples: list[Sequence[Mapping[str, Any]]] = [data] # type: ignore[list-item]
|
| 306 |
+
elif isinstance(data, Sequence):
|
| 307 |
+
if len(data) == 0:
|
| 308 |
+
raise ValueError("`data` must contain at least one sample.")
|
| 309 |
+
if all(isinstance(turn, Mapping) for turn in data):
|
| 310 |
+
samples = [data] # type: ignore[list-item]
|
| 311 |
+
else:
|
| 312 |
+
samples = list(data) # type: ignore[list-item]
|
| 313 |
+
else:
|
| 314 |
+
raise TypeError("`data` must be a conversation dictionary or a sequence of conversations.")
|
| 315 |
+
|
| 316 |
+
if isinstance(output_modalities, str):
|
| 317 |
+
output_modalities = [output_modalities] * len(samples)
|
| 318 |
+
elif len(output_modalities) != len(samples):
|
| 319 |
+
raise ValueError("`output_modalities` length must match number of samples.")
|
| 320 |
+
|
| 321 |
+
merged_kwargs = self._merge_kwargs(MossSpeechProcessorKwargs, **kwargs)
|
| 322 |
+
common_kwargs = merged_kwargs["common_kwargs"]
|
| 323 |
+
padding = common_kwargs.get("padding", True)
|
| 324 |
+
if not padding:
|
| 325 |
+
raise NotImplementedError("Only padded batches are currently supported.")
|
| 326 |
+
return_tensors = common_kwargs.get("return_tensors", "pt")
|
| 327 |
+
|
| 328 |
+
chat_samples = [
|
| 329 |
+
self.sample_processor.prepare_sample(conversation, modality)
|
| 330 |
+
for conversation, modality in zip(samples, output_modalities)
|
| 331 |
+
]
|
| 332 |
+
|
| 333 |
+
pad_token_id = self.tokenizer.pad_token_id
|
| 334 |
+
if pad_token_id is None:
|
| 335 |
+
raise ValueError("Tokenizer must define `pad_token_id` for MossSpeech processing.")
|
| 336 |
+
|
| 337 |
+
batch_inputs = self.sample_processor.collate(
|
| 338 |
+
chat_samples,
|
| 339 |
+
pad_token_id=pad_token_id,
|
| 340 |
+
audio_pad_token_id=_AUDIO_PAD_TOKEN_ID,
|
| 341 |
+
)
|
| 342 |
+
payload = {key: value for key, value in asdict(batch_inputs).items() if value is not None}
|
| 343 |
+
return BatchEncoding(payload, tensor_type=return_tensors)
|
| 344 |
+
|
| 345 |
+
def decode(
|
| 346 |
+
self,
|
| 347 |
+
token_ids: "torch.Tensor",
|
| 348 |
+
output_modalities: Union[str, Sequence[str]],
|
| 349 |
+
*args: Any,
|
| 350 |
+
**kwargs: Any,
|
| 351 |
+
) -> list[MossSpeechResponse]:
|
| 352 |
+
_ensure_dependencies()
|
| 353 |
+
if token_ids.dim() != 3:
|
| 354 |
+
raise ValueError("`token_ids` must be shaped as (batch, sequence_length, channels).")
|
| 355 |
+
|
| 356 |
+
if isinstance(output_modalities, str):
|
| 357 |
+
output_modalities = [output_modalities] * token_ids.shape[0]
|
| 358 |
+
elif len(output_modalities) != token_ids.shape[0]:
|
| 359 |
+
raise ValueError("`output_modalities` length must equal the batch size.")
|
| 360 |
+
|
| 361 |
+
if token_ids.shape[0] != 1:
|
| 362 |
+
raise NotImplementedError("Batch decoding is not yet implemented for MossSpeech.")
|
| 363 |
+
|
| 364 |
+
responses: list[MossSpeechResponse] = []
|
| 365 |
+
for batch_index, modality in enumerate(output_modalities):
|
| 366 |
+
tokens = token_ids[batch_index].int().cpu()
|
| 367 |
+
if tokens.shape[1] != 2:
|
| 368 |
+
tokens = tokens.transpose(0, 1)
|
| 369 |
+
if tokens.shape[0] != 2:
|
| 370 |
+
raise ValueError("Decoded tensor must contain exactly two channels (text and audio).")
|
| 371 |
+
|
| 372 |
+
if modality == "audio":
|
| 373 |
+
prefix = torch.tensor([[_SOSP_TOKEN_ID], [_AUDIO_PAD_TOKEN_ID]], dtype=torch.long)
|
| 374 |
+
tokens = torch.cat([prefix, tokens], dim=1)
|
| 375 |
+
|
| 376 |
+
text_channel = tokens[0, :-1]
|
| 377 |
+
audio_channel = tokens[1, :-1]
|
| 378 |
+
decoded_text = (
|
| 379 |
+
self.tokenizer.decode(text_channel, skip_special_tokens=True)
|
| 380 |
+
.replace("<|empty|>", ".")
|
| 381 |
+
.replace("<|end_empty|>", ":")
|
| 382 |
+
)
|
| 383 |
+
|
| 384 |
+
sosp_indices = (text_channel == self.sosp_token_id).nonzero(as_tuple=True)[0]
|
| 385 |
+
eosp_indices = (audio_channel == self.eosp_token_id).nonzero(as_tuple=True)[0]
|
| 386 |
+
|
| 387 |
+
waveform: Optional["torch.Tensor"] = None
|
| 388 |
+
if len(sosp_indices) > 0:
|
| 389 |
+
start_idx = sosp_indices[0].item() + 1
|
| 390 |
+
stop_idx = eosp_indices[0].item() if len(eosp_indices) > 0 else text_channel.shape[0]
|
| 391 |
+
audio_tokens = tokens[:, start_idx:stop_idx]
|
| 392 |
+
flattened_audio_tokens = audio_tokens[1].reshape(-1).tolist()
|
| 393 |
+
|
| 394 |
+
continuation = "".join(f"<{token}>" for token in flattened_audio_tokens)
|
| 395 |
+
codec_tokens = [int(match) for match in re.findall(r"(\d+)>", continuation)]
|
| 396 |
+
codec_tensor = torch.tensor(codec_tokens, dtype=torch.long).reshape(1, 1, -1)
|
| 397 |
+
|
| 398 |
+
prompt_path = kwargs.get("decoder_audio_prompt_path")
|
| 399 |
+
if prompt_path is None:
|
| 400 |
+
raise ValueError("`decoder_audio_prompt_path` must be provided to decode audio outputs.")
|
| 401 |
+
codec_output = self.audio_codec.decode(codec_tensor, prompt_speech=prompt_path)
|
| 402 |
+
waveform = codec_output["syn_wav_list"][0].reshape(1, -1).detach().cpu()
|
| 403 |
+
|
| 404 |
+
responses.append(
|
| 405 |
+
MossSpeechResponse(
|
| 406 |
+
audio=waveform,
|
| 407 |
+
generated_text=decoded_text,
|
| 408 |
+
sampling_rate=24000 if waveform is not None else None,
|
| 409 |
+
)
|
| 410 |
+
)
|
| 411 |
+
|
| 412 |
+
return responses
|
| 413 |
+
|
| 414 |
+
|
| 415 |
+
__all__ = [
|
| 416 |
+
"MossSpeechProcessor",
|
| 417 |
+
"MossSpeechProcessorKwargs",
|
| 418 |
+
"MossSpeechResponse",
|
| 419 |
+
]
|
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 |
+
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_bos_token": false,
|
| 3 |
+
"add_prefix_space": false,
|
| 4 |
+
"added_tokens_decoder": {
|
| 5 |
+
"151643": {
|
| 6 |
+
"content": "<|endoftext|>",
|
| 7 |
+
"lstrip": false,
|
| 8 |
+
"normalized": false,
|
| 9 |
+
"rstrip": false,
|
| 10 |
+
"single_word": false,
|
| 11 |
+
"special": true
|
| 12 |
+
},
|
| 13 |
+
"151644": {
|
| 14 |
+
"content": "<|im_start|>",
|
| 15 |
+
"lstrip": false,
|
| 16 |
+
"normalized": false,
|
| 17 |
+
"rstrip": false,
|
| 18 |
+
"single_word": false,
|
| 19 |
+
"special": true
|
| 20 |
+
},
|
| 21 |
+
"151645": {
|
| 22 |
+
"content": "<|im_end|>",
|
| 23 |
+
"lstrip": false,
|
| 24 |
+
"normalized": false,
|
| 25 |
+
"rstrip": false,
|
| 26 |
+
"single_word": false,
|
| 27 |
+
"special": true
|
| 28 |
+
},
|
| 29 |
+
"151646": {
|
| 30 |
+
"content": "<|object_ref_start|>",
|
| 31 |
+
"lstrip": false,
|
| 32 |
+
"normalized": false,
|
| 33 |
+
"rstrip": false,
|
| 34 |
+
"single_word": false,
|
| 35 |
+
"special": true
|
| 36 |
+
},
|
| 37 |
+
"151647": {
|
| 38 |
+
"content": "<|object_ref_end|>",
|
| 39 |
+
"lstrip": false,
|
| 40 |
+
"normalized": false,
|
| 41 |
+
"rstrip": false,
|
| 42 |
+
"single_word": false,
|
| 43 |
+
"special": true
|
| 44 |
+
},
|
| 45 |
+
"151648": {
|
| 46 |
+
"content": "<|box_start|>",
|
| 47 |
+
"lstrip": false,
|
| 48 |
+
"normalized": false,
|
| 49 |
+
"rstrip": false,
|
| 50 |
+
"single_word": false,
|
| 51 |
+
"special": true
|
| 52 |
+
},
|
| 53 |
+
"151649": {
|
| 54 |
+
"content": "<|box_end|>",
|
| 55 |
+
"lstrip": false,
|
| 56 |
+
"normalized": false,
|
| 57 |
+
"rstrip": false,
|
| 58 |
+
"single_word": false,
|
| 59 |
+
"special": true
|
| 60 |
+
},
|
| 61 |
+
"151650": {
|
| 62 |
+
"content": "<|quad_start|>",
|
| 63 |
+
"lstrip": false,
|
| 64 |
+
"normalized": false,
|
| 65 |
+
"rstrip": false,
|
| 66 |
+
"single_word": false,
|
| 67 |
+
"special": true
|
| 68 |
+
},
|
| 69 |
+
"151651": {
|
| 70 |
+
"content": "<|quad_end|>",
|
| 71 |
+
"lstrip": false,
|
| 72 |
+
"normalized": false,
|
| 73 |
+
"rstrip": false,
|
| 74 |
+
"single_word": false,
|
| 75 |
+
"special": true
|
| 76 |
+
},
|
| 77 |
+
"151652": {
|
| 78 |
+
"content": "<|vision_start|>",
|
| 79 |
+
"lstrip": false,
|
| 80 |
+
"normalized": false,
|
| 81 |
+
"rstrip": false,
|
| 82 |
+
"single_word": false,
|
| 83 |
+
"special": true
|
| 84 |
+
},
|
| 85 |
+
"151653": {
|
| 86 |
+
"content": "<|vision_end|>",
|
| 87 |
+
"lstrip": false,
|
| 88 |
+
"normalized": false,
|
| 89 |
+
"rstrip": false,
|
| 90 |
+
"single_word": false,
|
| 91 |
+
"special": true
|
| 92 |
+
},
|
| 93 |
+
"151654": {
|
| 94 |
+
"content": "<|vision_pad|>",
|
| 95 |
+
"lstrip": false,
|
| 96 |
+
"normalized": false,
|
| 97 |
+
"rstrip": false,
|
| 98 |
+
"single_word": false,
|
| 99 |
+
"special": true
|
| 100 |
+
},
|
| 101 |
+
"151655": {
|
| 102 |
+
"content": "<|image_pad|>",
|
| 103 |
+
"lstrip": false,
|
| 104 |
+
"normalized": false,
|
| 105 |
+
"rstrip": false,
|
| 106 |
+
"single_word": false,
|
| 107 |
+
"special": true
|
| 108 |
+
},
|
| 109 |
+
"151656": {
|
| 110 |
+
"content": "<|video_pad|>",
|
| 111 |
+
"lstrip": false,
|
| 112 |
+
"normalized": false,
|
| 113 |
+
"rstrip": false,
|
| 114 |
+
"single_word": false,
|
| 115 |
+
"special": true
|
| 116 |
+
},
|
| 117 |
+
"151657": {
|
| 118 |
+
"content": "<tool_call>",
|
| 119 |
+
"lstrip": false,
|
| 120 |
+
"normalized": false,
|
| 121 |
+
"rstrip": false,
|
| 122 |
+
"single_word": false,
|
| 123 |
+
"special": false
|
| 124 |
+
},
|
| 125 |
+
"151658": {
|
| 126 |
+
"content": "</tool_call>",
|
| 127 |
+
"lstrip": false,
|
| 128 |
+
"normalized": false,
|
| 129 |
+
"rstrip": false,
|
| 130 |
+
"single_word": false,
|
| 131 |
+
"special": false
|
| 132 |
+
},
|
| 133 |
+
"151659": {
|
| 134 |
+
"content": "<|fim_prefix|>",
|
| 135 |
+
"lstrip": false,
|
| 136 |
+
"normalized": false,
|
| 137 |
+
"rstrip": false,
|
| 138 |
+
"single_word": false,
|
| 139 |
+
"special": false
|
| 140 |
+
},
|
| 141 |
+
"151660": {
|
| 142 |
+
"content": "<|fim_middle|>",
|
| 143 |
+
"lstrip": false,
|
| 144 |
+
"normalized": false,
|
| 145 |
+
"rstrip": false,
|
| 146 |
+
"single_word": false,
|
| 147 |
+
"special": false
|
| 148 |
+
},
|
| 149 |
+
"151661": {
|
| 150 |
+
"content": "<|fim_suffix|>",
|
| 151 |
+
"lstrip": false,
|
| 152 |
+
"normalized": false,
|
| 153 |
+
"rstrip": false,
|
| 154 |
+
"single_word": false,
|
| 155 |
+
"special": false
|
| 156 |
+
},
|
| 157 |
+
"151662": {
|
| 158 |
+
"content": "<|fim_pad|>",
|
| 159 |
+
"lstrip": false,
|
| 160 |
+
"normalized": false,
|
| 161 |
+
"rstrip": false,
|
| 162 |
+
"single_word": false,
|
| 163 |
+
"special": false
|
| 164 |
+
},
|
| 165 |
+
"151663": {
|
| 166 |
+
"content": "<|repo_name|>",
|
| 167 |
+
"lstrip": false,
|
| 168 |
+
"normalized": false,
|
| 169 |
+
"rstrip": false,
|
| 170 |
+
"single_word": false,
|
| 171 |
+
"special": false
|
| 172 |
+
},
|
| 173 |
+
"151664": {
|
| 174 |
+
"content": "<|file_sep|>",
|
| 175 |
+
"lstrip": false,
|
| 176 |
+
"normalized": false,
|
| 177 |
+
"rstrip": false,
|
| 178 |
+
"single_word": false,
|
| 179 |
+
"special": false
|
| 180 |
+
}
|
| 181 |
+
},
|
| 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 |
+
"split_special_tokens": false,
|
| 205 |
+
"tokenizer_class": "Qwen2Tokenizer",
|
| 206 |
+
"unk_token": null
|
| 207 |
+
}
|
vocab.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|