Upload folder using huggingface_hub
Browse files- __init__.py +30 -0
- config.json +41 -0
- configuration_iquestcoder.py +182 -0
- generation_config.json +6 -0
- model-00001-of-00002.safetensors +3 -0
- model-00002-of-00002.safetensors +3 -0
- model.safetensors.index.json +730 -0
- modeling_iquestcoder.py +1051 -0
- tokenization_iquestcoder.py +552 -0
- tokenizer.model +3 -0
- tokenizer_config.json +242 -0
__init__.py
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""IQuestCoder model package."""
|
| 2 |
+
|
| 3 |
+
from .configuration_iquestcoder import IQuestCoderConfig
|
| 4 |
+
from .modeling_iquestcoder import (
|
| 5 |
+
IQuestCoderPreTrainedModel,
|
| 6 |
+
IQuestCoderModel,
|
| 7 |
+
IQuestCoderForCausalLM,
|
| 8 |
+
IQuestCoderForSequenceClassification,
|
| 9 |
+
IQuestCoderForTokenClassification,
|
| 10 |
+
IQuestCoderForQuestionAnswering,
|
| 11 |
+
)
|
| 12 |
+
from .tokenization_iquestcoder import IQuestCoderTokenizer
|
| 13 |
+
|
| 14 |
+
try:
|
| 15 |
+
from .tokenization_iquestcoder import IQuestCoderTokenizerFast
|
| 16 |
+
except ImportError:
|
| 17 |
+
IQuestCoderTokenizerFast = None
|
| 18 |
+
|
| 19 |
+
__all__ = [
|
| 20 |
+
"IQuestCoderConfig",
|
| 21 |
+
"IQuestCoderPreTrainedModel",
|
| 22 |
+
"IQuestCoderModel",
|
| 23 |
+
"IQuestCoderForCausalLM",
|
| 24 |
+
"IQuestCoderForSequenceClassification",
|
| 25 |
+
"IQuestCoderForTokenClassification",
|
| 26 |
+
"IQuestCoderForQuestionAnswering",
|
| 27 |
+
"IQuestCoderTokenizer",
|
| 28 |
+
"IQuestCoderTokenizerFast",
|
| 29 |
+
]
|
| 30 |
+
|
config.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"IQuestCoderForCausalLM"
|
| 4 |
+
],
|
| 5 |
+
"attention_bias": false,
|
| 6 |
+
"attention_dropout": 0.0,
|
| 7 |
+
"bos_token_id": 1,
|
| 8 |
+
"eos_token_id": [2, 75864, 75869],
|
| 9 |
+
"head_dim": 128,
|
| 10 |
+
"hidden_act": "silu",
|
| 11 |
+
"hidden_size": 5120,
|
| 12 |
+
"initializer_range": 0.02,
|
| 13 |
+
"intermediate_size": 27648,
|
| 14 |
+
"max_position_embeddings": 131072,
|
| 15 |
+
"mlp_bias": false,
|
| 16 |
+
"model_type": "iquestcoder",
|
| 17 |
+
"num_attention_heads": 40,
|
| 18 |
+
"num_hidden_layers": 80,
|
| 19 |
+
"num_key_value_heads": 8,
|
| 20 |
+
"pretraining_tp": 1,
|
| 21 |
+
"rms_norm_eps": 1e-05,
|
| 22 |
+
"rope_scaling": null,
|
| 23 |
+
"rope_theta": 500000.0,
|
| 24 |
+
"tie_word_embeddings": false,
|
| 25 |
+
"torch_dtype": "bfloat16",
|
| 26 |
+
"transformers_version": "4.55.4",
|
| 27 |
+
"use_cache": true,
|
| 28 |
+
"vocab_size": 76800,
|
| 29 |
+
"clip_qkv": null,
|
| 30 |
+
"use_sliding_window": false,
|
| 31 |
+
"sliding_window": null,
|
| 32 |
+
"max_window_layers": 0,
|
| 33 |
+
"auto_map": {
|
| 34 |
+
"AutoConfig": "configuration_iquestcoder.IQuestCoderConfig",
|
| 35 |
+
"AutoModel": "modeling_iquestcoder.IQuestCoderModel",
|
| 36 |
+
"AutoModelForCausalLM": "modeling_iquestcoder.IQuestCoderForCausalLM",
|
| 37 |
+
"AutoModelForSequenceClassification": "modeling_iquestcoder.IQuestCoderForSequenceClassification",
|
| 38 |
+
"AutoModelForTokenClassification": "modeling_iquestcoder.IQuestCoderForTokenClassification",
|
| 39 |
+
"AutoModelForQuestionAnswering": "modeling_iquestcoder.IQuestCoderForQuestionAnswering"
|
| 40 |
+
}
|
| 41 |
+
}
|
configuration_iquestcoder.py
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""IQuestCoder model configuration."""
|
| 2 |
+
|
| 3 |
+
from transformers.configuration_utils import PretrainedConfig
|
| 4 |
+
from transformers.utils import logging
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
logger = logging.get_logger(__name__)
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
class IQuestCoderConfig(PretrainedConfig):
|
| 11 |
+
r"""
|
| 12 |
+
This is the configuration class to store the configuration of a [`IQuestCoderModel`]. It is used to instantiate
|
| 13 |
+
an IQuestCoder model according to the specified arguments, defining the model architecture.
|
| 14 |
+
|
| 15 |
+
Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
|
| 16 |
+
documentation from [`PretrainedConfig`] for more information.
|
| 17 |
+
|
| 18 |
+
Args:
|
| 19 |
+
vocab_size (`int`, *optional*, defaults to 76800):
|
| 20 |
+
Vocabulary size of the IQuestCoder model. Defines the number of different tokens that can be represented
|
| 21 |
+
by the `inputs_ids` passed when calling [`IQuestCoderModel`].
|
| 22 |
+
hidden_size (`int`, *optional*, defaults to 5120):
|
| 23 |
+
Dimension of the hidden representations.
|
| 24 |
+
intermediate_size (`int`, *optional*, defaults to 27648):
|
| 25 |
+
Dimension of the MLP representations.
|
| 26 |
+
num_hidden_layers (`int`, *optional*, defaults to 80):
|
| 27 |
+
Number of hidden layers in the Transformer decoder.
|
| 28 |
+
num_attention_heads (`int`, *optional*, defaults to 40):
|
| 29 |
+
Number of attention heads for each attention layer in the Transformer decoder.
|
| 30 |
+
num_key_value_heads (`int`, *optional*, defaults to 8):
|
| 31 |
+
This is the number of key_value heads that should be used to implement Grouped Query Attention (GQA).
|
| 32 |
+
If `num_key_value_heads=num_attention_heads`, the model will use Multi Head Attention (MHA).
|
| 33 |
+
If `num_key_value_heads=1`, the model will use Multi Query Attention (MQA).
|
| 34 |
+
head_dim (`int`, *optional*, defaults to 128):
|
| 35 |
+
The dimension of each attention head. If not specified, defaults to `hidden_size // num_attention_heads`.
|
| 36 |
+
hidden_act (`str` or `function`, *optional*, defaults to `"silu"`):
|
| 37 |
+
The non-linear activation function (function or string) in the decoder.
|
| 38 |
+
max_position_embeddings (`int`, *optional*, defaults to 16384):
|
| 39 |
+
The maximum sequence length that this model might ever be used with.
|
| 40 |
+
initializer_range (`float`, *optional*, defaults to 0.02):
|
| 41 |
+
The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
|
| 42 |
+
rms_norm_eps (`float`, *optional*, defaults to 1e-05):
|
| 43 |
+
The epsilon used by the rms normalization layers.
|
| 44 |
+
use_cache (`bool`, *optional*, defaults to `True`):
|
| 45 |
+
Whether or not the model should return the last key/values attentions (not used by all models).
|
| 46 |
+
pad_token_id (`int`, *optional*):
|
| 47 |
+
Padding token id.
|
| 48 |
+
bos_token_id (`int`, *optional*, defaults to 1):
|
| 49 |
+
Beginning of stream token id.
|
| 50 |
+
eos_token_id (`int`, *optional*, defaults to 2):
|
| 51 |
+
End of stream token id.
|
| 52 |
+
tie_word_embeddings (`bool`, *optional*, defaults to `False`):
|
| 53 |
+
Whether to tie weight embeddings.
|
| 54 |
+
rope_theta (`float`, *optional*, defaults to 500000.0):
|
| 55 |
+
The base period of the RoPE embeddings.
|
| 56 |
+
rope_scaling (`Dict`, *optional*):
|
| 57 |
+
Dictionary containing the scaling configuration for the RoPE embeddings. Supports various RoPE scaling
|
| 58 |
+
types including "linear", "dynamic", "yarn", "longrope", etc.
|
| 59 |
+
attention_bias (`bool`, *optional*, defaults to `False`):
|
| 60 |
+
Whether to use a bias in the query, key, value and output projection layers during self-attention.
|
| 61 |
+
attention_dropout (`float`, *optional*, defaults to 0.0):
|
| 62 |
+
The dropout ratio for the attention probabilities.
|
| 63 |
+
mlp_bias (`bool`, *optional*, defaults to `False`):
|
| 64 |
+
Whether to use a bias in up_proj, down_proj and gate_proj layers in the MLP layers.
|
| 65 |
+
clip_qkv (`float`, *optional*):
|
| 66 |
+
If set, clip the query, key, and value tensors to this value. Borrowed from OLMo for training stability.
|
| 67 |
+
use_sliding_window (`bool`, *optional*, defaults to `False`):
|
| 68 |
+
Whether to use sliding window attention. Borrowed from Qwen2.
|
| 69 |
+
sliding_window (`int`, *optional*):
|
| 70 |
+
The sliding window size. Only effective when `use_sliding_window=True`.
|
| 71 |
+
max_window_layers (`int`, *optional*, defaults to 0):
|
| 72 |
+
The number of layers that don't use sliding window attention. Borrowed from Qwen2.
|
| 73 |
+
|
| 74 |
+
Example:
|
| 75 |
+
```python
|
| 76 |
+
>>> from configuration_iquestcoder import IQuestCoderConfig
|
| 77 |
+
>>> from modeling_iquestcoder import IQuestCoderModel
|
| 78 |
+
|
| 79 |
+
>>> # Initializing a IQuestCoder configuration
|
| 80 |
+
>>> configuration = IQuestCoderConfig()
|
| 81 |
+
|
| 82 |
+
>>> # Initializing a model from the configuration
|
| 83 |
+
>>> model = IQuestCoderModel(configuration)
|
| 84 |
+
|
| 85 |
+
>>> # Accessing the model configuration
|
| 86 |
+
>>> configuration = model.config
|
| 87 |
+
```
|
| 88 |
+
"""
|
| 89 |
+
|
| 90 |
+
model_type = "iquestcoder"
|
| 91 |
+
keys_to_ignore_at_inference = ["past_key_values"]
|
| 92 |
+
|
| 93 |
+
def __init__(
|
| 94 |
+
self,
|
| 95 |
+
vocab_size=76800,
|
| 96 |
+
hidden_size=5120,
|
| 97 |
+
intermediate_size=27648,
|
| 98 |
+
num_hidden_layers=80,
|
| 99 |
+
num_attention_heads=40,
|
| 100 |
+
num_key_value_heads=8,
|
| 101 |
+
head_dim=128,
|
| 102 |
+
hidden_act="silu",
|
| 103 |
+
max_position_embeddings=16384,
|
| 104 |
+
initializer_range=0.02,
|
| 105 |
+
rms_norm_eps=1e-5,
|
| 106 |
+
use_cache=True,
|
| 107 |
+
pad_token_id=None,
|
| 108 |
+
bos_token_id=1,
|
| 109 |
+
eos_token_id=2,
|
| 110 |
+
tie_word_embeddings=False,
|
| 111 |
+
rope_theta=500000.0,
|
| 112 |
+
rope_scaling=None,
|
| 113 |
+
attention_bias=False,
|
| 114 |
+
attention_dropout=0.0,
|
| 115 |
+
mlp_bias=False,
|
| 116 |
+
# IQuestCoder specific (borrowed from OLMo)
|
| 117 |
+
clip_qkv=None,
|
| 118 |
+
# IQuestCoder specific (borrowed from Qwen2)
|
| 119 |
+
use_sliding_window=False,
|
| 120 |
+
sliding_window=None,
|
| 121 |
+
max_window_layers=0,
|
| 122 |
+
**kwargs,
|
| 123 |
+
):
|
| 124 |
+
self.vocab_size = vocab_size
|
| 125 |
+
self.max_position_embeddings = max_position_embeddings
|
| 126 |
+
self.hidden_size = hidden_size
|
| 127 |
+
self.intermediate_size = intermediate_size
|
| 128 |
+
self.num_hidden_layers = num_hidden_layers
|
| 129 |
+
self.num_attention_heads = num_attention_heads
|
| 130 |
+
self.num_key_value_heads = num_key_value_heads
|
| 131 |
+
self.head_dim = head_dim
|
| 132 |
+
self.hidden_act = hidden_act
|
| 133 |
+
self.initializer_range = initializer_range
|
| 134 |
+
self.rms_norm_eps = rms_norm_eps
|
| 135 |
+
self.use_cache = use_cache
|
| 136 |
+
self.rope_theta = rope_theta
|
| 137 |
+
self.rope_scaling = rope_scaling
|
| 138 |
+
self.attention_bias = attention_bias
|
| 139 |
+
self.attention_dropout = attention_dropout
|
| 140 |
+
self.mlp_bias = mlp_bias
|
| 141 |
+
# IQuestCoder specific
|
| 142 |
+
self.clip_qkv = clip_qkv
|
| 143 |
+
self.use_sliding_window = use_sliding_window
|
| 144 |
+
self.sliding_window = sliding_window
|
| 145 |
+
self.max_window_layers = max_window_layers
|
| 146 |
+
|
| 147 |
+
# Validate rope_scaling configuration
|
| 148 |
+
self._rope_scaling_validation()
|
| 149 |
+
|
| 150 |
+
super().__init__(
|
| 151 |
+
pad_token_id=pad_token_id,
|
| 152 |
+
bos_token_id=bos_token_id,
|
| 153 |
+
eos_token_id=eos_token_id,
|
| 154 |
+
tie_word_embeddings=tie_word_embeddings,
|
| 155 |
+
**kwargs,
|
| 156 |
+
)
|
| 157 |
+
|
| 158 |
+
def _rope_scaling_validation(self):
|
| 159 |
+
"""Validate the `rope_scaling` configuration."""
|
| 160 |
+
if self.rope_scaling is None:
|
| 161 |
+
return
|
| 162 |
+
|
| 163 |
+
if not isinstance(self.rope_scaling, dict) or len(self.rope_scaling) < 1:
|
| 164 |
+
raise ValueError(
|
| 165 |
+
"`rope_scaling` must be a dictionary with a minimum of one field, `type` or `rope_type`."
|
| 166 |
+
)
|
| 167 |
+
|
| 168 |
+
rope_scaling_type = self.rope_scaling.get("type", None) or self.rope_scaling.get("rope_type", None)
|
| 169 |
+
if rope_scaling_type is None:
|
| 170 |
+
raise ValueError(
|
| 171 |
+
"`rope_scaling` must have a `type` or `rope_type` field."
|
| 172 |
+
)
|
| 173 |
+
|
| 174 |
+
valid_rope_types = ["linear", "dynamic", "yarn", "longrope", "llama3"]
|
| 175 |
+
if rope_scaling_type not in valid_rope_types:
|
| 176 |
+
raise ValueError(
|
| 177 |
+
f"`rope_scaling`'s type field must be one of {valid_rope_types}, got {rope_scaling_type}"
|
| 178 |
+
)
|
| 179 |
+
|
| 180 |
+
|
| 181 |
+
__all__ = ["IQuestCoderConfig"]
|
| 182 |
+
|
generation_config.json
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_from_model_config": true,
|
| 3 |
+
"bos_token_id": 1,
|
| 4 |
+
"eos_token_id": [2, 75864, 75869],
|
| 5 |
+
"transformers_version": "4.55.4"
|
| 6 |
+
}
|
model-00001-of-00002.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b1f30e024054516b1edd92d87d045e72fd7a0cfa53649bac57338c831e1503f4
|
| 3 |
+
size 42845763008
|
model-00002-of-00002.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8dc75e3c2a7f534af0a704f65f6f56c8095f5db1662b4474bd6ee6cdd789a20f
|
| 3 |
+
size 36742889432
|
model.safetensors.index.json
ADDED
|
@@ -0,0 +1,730 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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safetensors",
|
| 7 |
+
"model.layers.0.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 8 |
+
"model.layers.0.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 9 |
+
"model.layers.0.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 10 |
+
"model.layers.0.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 11 |
+
"model.layers.0.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 12 |
+
"model.layers.0.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 13 |
+
"model.layers.0.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 14 |
+
"model.layers.0.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 15 |
+
"model.layers.0.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 16 |
+
"model.layers.1.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 17 |
+
"model.layers.1.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 18 |
+
"model.layers.1.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 19 |
+
"model.layers.1.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 20 |
+
"model.layers.1.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 21 |
+
"model.layers.1.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 22 |
+
"model.layers.1.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 23 |
+
"model.layers.1.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 24 |
+
"model.layers.1.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 25 |
+
"model.layers.2.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 26 |
+
"model.layers.2.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 27 |
+
"model.layers.2.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 28 |
+
"model.layers.2.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 29 |
+
"model.layers.2.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 30 |
+
"model.layers.2.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 31 |
+
"model.layers.2.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 32 |
+
"model.layers.2.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 33 |
+
"model.layers.2.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 34 |
+
"model.layers.3.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 35 |
+
"model.layers.3.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 36 |
+
"model.layers.3.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 37 |
+
"model.layers.3.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 38 |
+
"model.layers.3.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 39 |
+
"model.layers.3.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 40 |
+
"model.layers.3.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 41 |
+
"model.layers.3.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 42 |
+
"model.layers.3.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 43 |
+
"model.layers.4.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 44 |
+
"model.layers.4.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 45 |
+
"model.layers.4.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 46 |
+
"model.layers.4.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 47 |
+
"model.layers.4.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 48 |
+
"model.layers.4.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 49 |
+
"model.layers.4.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 50 |
+
"model.layers.4.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 51 |
+
"model.layers.4.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 52 |
+
"model.layers.5.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 53 |
+
"model.layers.5.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 54 |
+
"model.layers.5.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 55 |
+
"model.layers.5.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 56 |
+
"model.layers.5.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 57 |
+
"model.layers.5.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 58 |
+
"model.layers.5.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 59 |
+
"model.layers.5.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 60 |
+
"model.layers.5.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 61 |
+
"model.layers.6.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 62 |
+
"model.layers.6.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 63 |
+
"model.layers.6.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 64 |
+
"model.layers.6.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 65 |
+
"model.layers.6.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 66 |
+
"model.layers.6.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 67 |
+
"model.layers.6.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 68 |
+
"model.layers.6.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 69 |
+
"model.layers.6.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 70 |
+
"model.layers.7.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 71 |
+
"model.layers.7.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 72 |
+
"model.layers.7.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 73 |
+
"model.layers.7.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 74 |
+
"model.layers.7.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 75 |
+
"model.layers.7.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 76 |
+
"model.layers.7.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 77 |
+
"model.layers.7.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 78 |
+
"model.layers.7.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 79 |
+
"model.layers.8.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 80 |
+
"model.layers.8.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 81 |
+
"model.layers.8.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 82 |
+
"model.layers.8.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 83 |
+
"model.layers.8.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 84 |
+
"model.layers.8.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 85 |
+
"model.layers.8.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 86 |
+
"model.layers.8.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 87 |
+
"model.layers.8.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 88 |
+
"model.layers.9.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 89 |
+
"model.layers.9.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 90 |
+
"model.layers.9.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 91 |
+
"model.layers.9.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 92 |
+
"model.layers.9.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 93 |
+
"model.layers.9.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 94 |
+
"model.layers.9.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 95 |
+
"model.layers.9.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 96 |
+
"model.layers.9.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 97 |
+
"model.layers.10.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 98 |
+
"model.layers.10.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 99 |
+
"model.layers.10.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 100 |
+
"model.layers.10.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 101 |
+
"model.layers.10.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 102 |
+
"model.layers.10.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 103 |
+
"model.layers.10.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 104 |
+
"model.layers.10.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 105 |
+
"model.layers.10.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 106 |
+
"model.layers.11.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 107 |
+
"model.layers.11.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 108 |
+
"model.layers.11.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 109 |
+
"model.layers.11.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 110 |
+
"model.layers.11.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 111 |
+
"model.layers.11.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 112 |
+
"model.layers.11.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 113 |
+
"model.layers.11.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 114 |
+
"model.layers.11.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 115 |
+
"model.layers.12.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 116 |
+
"model.layers.12.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 117 |
+
"model.layers.12.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 118 |
+
"model.layers.12.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 119 |
+
"model.layers.12.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 120 |
+
"model.layers.12.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 121 |
+
"model.layers.12.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 122 |
+
"model.layers.12.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 123 |
+
"model.layers.12.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 124 |
+
"model.layers.13.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 125 |
+
"model.layers.13.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 126 |
+
"model.layers.13.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 127 |
+
"model.layers.13.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 128 |
+
"model.layers.13.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 129 |
+
"model.layers.13.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 130 |
+
"model.layers.13.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 131 |
+
"model.layers.13.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 132 |
+
"model.layers.13.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 133 |
+
"model.layers.14.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 134 |
+
"model.layers.14.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 135 |
+
"model.layers.14.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 136 |
+
"model.layers.14.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 137 |
+
"model.layers.14.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 138 |
+
"model.layers.14.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 139 |
+
"model.layers.14.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 140 |
+
"model.layers.14.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 141 |
+
"model.layers.14.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 142 |
+
"model.layers.15.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 143 |
+
"model.layers.15.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 144 |
+
"model.layers.15.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 145 |
+
"model.layers.15.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 146 |
+
"model.layers.15.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 147 |
+
"model.layers.15.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 148 |
+
"model.layers.15.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 149 |
+
"model.layers.15.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 150 |
+
"model.layers.15.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 151 |
+
"model.layers.16.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 152 |
+
"model.layers.16.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 153 |
+
"model.layers.16.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 154 |
+
"model.layers.16.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 155 |
+
"model.layers.16.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 156 |
+
"model.layers.16.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 157 |
+
"model.layers.16.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 158 |
+
"model.layers.16.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 159 |
+
"model.layers.16.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 160 |
+
"model.layers.17.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 161 |
+
"model.layers.17.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 162 |
+
"model.layers.17.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 163 |
+
"model.layers.17.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 164 |
+
"model.layers.17.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 165 |
+
"model.layers.17.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 166 |
+
"model.layers.17.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 167 |
+
"model.layers.17.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 168 |
+
"model.layers.17.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 169 |
+
"model.layers.18.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 170 |
+
"model.layers.18.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 171 |
+
"model.layers.18.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 172 |
+
"model.layers.18.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 173 |
+
"model.layers.18.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 174 |
+
"model.layers.18.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 175 |
+
"model.layers.18.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 176 |
+
"model.layers.18.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 177 |
+
"model.layers.18.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 178 |
+
"model.layers.19.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 179 |
+
"model.layers.19.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 180 |
+
"model.layers.19.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 181 |
+
"model.layers.19.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 182 |
+
"model.layers.19.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 183 |
+
"model.layers.19.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 184 |
+
"model.layers.19.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 185 |
+
"model.layers.19.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 186 |
+
"model.layers.19.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 187 |
+
"model.layers.20.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 188 |
+
"model.layers.20.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 189 |
+
"model.layers.20.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 190 |
+
"model.layers.20.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 191 |
+
"model.layers.20.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 192 |
+
"model.layers.20.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 193 |
+
"model.layers.20.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 194 |
+
"model.layers.20.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 195 |
+
"model.layers.20.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 196 |
+
"model.layers.21.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 197 |
+
"model.layers.21.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 198 |
+
"model.layers.21.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 199 |
+
"model.layers.21.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 200 |
+
"model.layers.21.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 201 |
+
"model.layers.21.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 202 |
+
"model.layers.21.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 203 |
+
"model.layers.21.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 204 |
+
"model.layers.21.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 205 |
+
"model.layers.22.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 206 |
+
"model.layers.22.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 207 |
+
"model.layers.22.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 208 |
+
"model.layers.22.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 209 |
+
"model.layers.22.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 210 |
+
"model.layers.22.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 211 |
+
"model.layers.22.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 212 |
+
"model.layers.22.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 213 |
+
"model.layers.22.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 214 |
+
"model.layers.23.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 215 |
+
"model.layers.23.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 216 |
+
"model.layers.23.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 217 |
+
"model.layers.23.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 218 |
+
"model.layers.23.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 219 |
+
"model.layers.23.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 220 |
+
"model.layers.23.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 221 |
+
"model.layers.23.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 222 |
+
"model.layers.23.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 223 |
+
"model.layers.24.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 224 |
+
"model.layers.24.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 225 |
+
"model.layers.24.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 226 |
+
"model.layers.24.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 227 |
+
"model.layers.24.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 228 |
+
"model.layers.24.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 229 |
+
"model.layers.24.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 230 |
+
"model.layers.24.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 231 |
+
"model.layers.24.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 232 |
+
"model.layers.25.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 233 |
+
"model.layers.25.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 234 |
+
"model.layers.25.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 235 |
+
"model.layers.25.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 236 |
+
"model.layers.25.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 237 |
+
"model.layers.25.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 238 |
+
"model.layers.25.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 239 |
+
"model.layers.25.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 240 |
+
"model.layers.25.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 241 |
+
"model.layers.26.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 242 |
+
"model.layers.26.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 243 |
+
"model.layers.26.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 244 |
+
"model.layers.26.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 245 |
+
"model.layers.26.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 246 |
+
"model.layers.26.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 247 |
+
"model.layers.26.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 248 |
+
"model.layers.26.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 249 |
+
"model.layers.26.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 250 |
+
"model.layers.27.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 251 |
+
"model.layers.27.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 252 |
+
"model.layers.27.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 253 |
+
"model.layers.27.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 254 |
+
"model.layers.27.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 255 |
+
"model.layers.27.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 256 |
+
"model.layers.27.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 257 |
+
"model.layers.27.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 258 |
+
"model.layers.27.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 259 |
+
"model.layers.28.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 260 |
+
"model.layers.28.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 261 |
+
"model.layers.28.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 262 |
+
"model.layers.28.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 263 |
+
"model.layers.28.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 264 |
+
"model.layers.28.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 265 |
+
"model.layers.28.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 266 |
+
"model.layers.28.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 267 |
+
"model.layers.28.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 268 |
+
"model.layers.29.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 269 |
+
"model.layers.29.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 270 |
+
"model.layers.29.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 271 |
+
"model.layers.29.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 272 |
+
"model.layers.29.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 273 |
+
"model.layers.29.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 274 |
+
"model.layers.29.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 275 |
+
"model.layers.29.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 276 |
+
"model.layers.29.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 277 |
+
"model.layers.30.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 278 |
+
"model.layers.30.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 279 |
+
"model.layers.30.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 280 |
+
"model.layers.30.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 281 |
+
"model.layers.30.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 282 |
+
"model.layers.30.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 283 |
+
"model.layers.30.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 284 |
+
"model.layers.30.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 285 |
+
"model.layers.30.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 286 |
+
"model.layers.31.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 287 |
+
"model.layers.31.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 288 |
+
"model.layers.31.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 289 |
+
"model.layers.31.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 290 |
+
"model.layers.31.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 291 |
+
"model.layers.31.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 292 |
+
"model.layers.31.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 293 |
+
"model.layers.31.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 294 |
+
"model.layers.31.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 295 |
+
"model.layers.32.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 296 |
+
"model.layers.32.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 297 |
+
"model.layers.32.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 298 |
+
"model.layers.32.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 299 |
+
"model.layers.32.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 300 |
+
"model.layers.32.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 301 |
+
"model.layers.32.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 302 |
+
"model.layers.32.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 303 |
+
"model.layers.32.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 304 |
+
"model.layers.33.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 305 |
+
"model.layers.33.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 306 |
+
"model.layers.33.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 307 |
+
"model.layers.33.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 308 |
+
"model.layers.33.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 309 |
+
"model.layers.33.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 310 |
+
"model.layers.33.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 311 |
+
"model.layers.33.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 312 |
+
"model.layers.33.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 313 |
+
"model.layers.34.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 314 |
+
"model.layers.34.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 315 |
+
"model.layers.34.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 316 |
+
"model.layers.34.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 317 |
+
"model.layers.34.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 318 |
+
"model.layers.34.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 319 |
+
"model.layers.34.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 320 |
+
"model.layers.34.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 321 |
+
"model.layers.34.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 322 |
+
"model.layers.35.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 323 |
+
"model.layers.35.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 324 |
+
"model.layers.35.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 325 |
+
"model.layers.35.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 326 |
+
"model.layers.35.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 327 |
+
"model.layers.35.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 328 |
+
"model.layers.35.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 329 |
+
"model.layers.35.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 330 |
+
"model.layers.35.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 331 |
+
"model.layers.36.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 332 |
+
"model.layers.36.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 333 |
+
"model.layers.36.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 334 |
+
"model.layers.36.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 335 |
+
"model.layers.36.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 336 |
+
"model.layers.36.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 337 |
+
"model.layers.36.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 338 |
+
"model.layers.36.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 339 |
+
"model.layers.36.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 340 |
+
"model.layers.37.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 341 |
+
"model.layers.37.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 342 |
+
"model.layers.37.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 343 |
+
"model.layers.37.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 344 |
+
"model.layers.37.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 345 |
+
"model.layers.37.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 346 |
+
"model.layers.37.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 347 |
+
"model.layers.37.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 348 |
+
"model.layers.37.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 349 |
+
"model.layers.38.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 350 |
+
"model.layers.38.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 351 |
+
"model.layers.38.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 352 |
+
"model.layers.38.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 353 |
+
"model.layers.38.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 354 |
+
"model.layers.38.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 355 |
+
"model.layers.38.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 356 |
+
"model.layers.38.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 357 |
+
"model.layers.38.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 358 |
+
"model.layers.39.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 359 |
+
"model.layers.39.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 360 |
+
"model.layers.39.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 361 |
+
"model.layers.39.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 362 |
+
"model.layers.39.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 363 |
+
"model.layers.39.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 364 |
+
"model.layers.39.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 365 |
+
"model.layers.39.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 366 |
+
"model.layers.39.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 367 |
+
"model.layers.40.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 368 |
+
"model.layers.40.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 369 |
+
"model.layers.40.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 370 |
+
"model.layers.40.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 371 |
+
"model.layers.40.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 372 |
+
"model.layers.40.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 373 |
+
"model.layers.40.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 374 |
+
"model.layers.40.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 375 |
+
"model.layers.40.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 376 |
+
"model.layers.41.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 377 |
+
"model.layers.41.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 378 |
+
"model.layers.41.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 379 |
+
"model.layers.41.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 380 |
+
"model.layers.41.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 381 |
+
"model.layers.41.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 382 |
+
"model.layers.41.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 383 |
+
"model.layers.41.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 384 |
+
"model.layers.41.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 385 |
+
"model.layers.42.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 386 |
+
"model.layers.42.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 387 |
+
"model.layers.42.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 388 |
+
"model.layers.42.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 389 |
+
"model.layers.42.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 390 |
+
"model.layers.42.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 391 |
+
"model.layers.42.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 392 |
+
"model.layers.42.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 393 |
+
"model.layers.42.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 394 |
+
"model.layers.43.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 395 |
+
"model.layers.43.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 396 |
+
"model.layers.43.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 397 |
+
"model.layers.43.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 398 |
+
"model.layers.43.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 399 |
+
"model.layers.43.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 400 |
+
"model.layers.43.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
| 401 |
+
"model.layers.43.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
| 402 |
+
"model.layers.43.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
| 403 |
+
"model.layers.44.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 404 |
+
"model.layers.44.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
| 405 |
+
"model.layers.44.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
| 406 |
+
"model.layers.44.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
| 407 |
+
"model.layers.44.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
| 408 |
+
"model.layers.44.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 409 |
+
"model.layers.44.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
| 410 |
+
"model.layers.44.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
| 411 |
+
"model.layers.44.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
| 412 |
+
"model.layers.45.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 413 |
+
"model.layers.45.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
| 414 |
+
"model.layers.45.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
| 415 |
+
"model.layers.45.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
| 416 |
+
"model.layers.45.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
| 417 |
+
"model.layers.45.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 418 |
+
"model.layers.45.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
| 419 |
+
"model.layers.45.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
| 420 |
+
"model.layers.45.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
| 421 |
+
"model.layers.46.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 422 |
+
"model.layers.46.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
| 423 |
+
"model.layers.46.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
| 424 |
+
"model.layers.46.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
| 425 |
+
"model.layers.46.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
| 426 |
+
"model.layers.46.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 427 |
+
"model.layers.46.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
| 428 |
+
"model.layers.46.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
| 429 |
+
"model.layers.46.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
| 430 |
+
"model.layers.47.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 431 |
+
"model.layers.47.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
| 432 |
+
"model.layers.47.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
| 433 |
+
"model.layers.47.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
| 434 |
+
"model.layers.47.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
| 435 |
+
"model.layers.47.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 436 |
+
"model.layers.47.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
| 437 |
+
"model.layers.47.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
| 438 |
+
"model.layers.47.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
| 439 |
+
"model.layers.48.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 440 |
+
"model.layers.48.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
| 441 |
+
"model.layers.48.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
| 442 |
+
"model.layers.48.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
| 443 |
+
"model.layers.48.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
| 444 |
+
"model.layers.48.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 445 |
+
"model.layers.48.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
| 446 |
+
"model.layers.48.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
| 447 |
+
"model.layers.48.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
| 448 |
+
"model.layers.49.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 449 |
+
"model.layers.49.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
| 450 |
+
"model.layers.49.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
| 451 |
+
"model.layers.49.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
| 452 |
+
"model.layers.49.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
| 453 |
+
"model.layers.49.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 454 |
+
"model.layers.49.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
| 455 |
+
"model.layers.49.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
| 456 |
+
"model.layers.49.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
| 457 |
+
"model.layers.50.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 458 |
+
"model.layers.50.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
| 459 |
+
"model.layers.50.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
| 460 |
+
"model.layers.50.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
| 461 |
+
"model.layers.50.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
| 462 |
+
"model.layers.50.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 463 |
+
"model.layers.50.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
| 464 |
+
"model.layers.50.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
| 465 |
+
"model.layers.50.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
| 466 |
+
"model.layers.51.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 467 |
+
"model.layers.51.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
| 468 |
+
"model.layers.51.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
| 469 |
+
"model.layers.51.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
| 470 |
+
"model.layers.51.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
| 471 |
+
"model.layers.51.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 472 |
+
"model.layers.51.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
| 473 |
+
"model.layers.51.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
| 474 |
+
"model.layers.51.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
| 475 |
+
"model.layers.52.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 476 |
+
"model.layers.52.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
| 477 |
+
"model.layers.52.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
| 478 |
+
"model.layers.52.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
| 479 |
+
"model.layers.52.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
| 480 |
+
"model.layers.52.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 481 |
+
"model.layers.52.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
| 482 |
+
"model.layers.52.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
| 483 |
+
"model.layers.52.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
| 484 |
+
"model.layers.53.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 485 |
+
"model.layers.53.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
| 486 |
+
"model.layers.53.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
| 487 |
+
"model.layers.53.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
| 488 |
+
"model.layers.53.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
| 489 |
+
"model.layers.53.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 490 |
+
"model.layers.53.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
| 491 |
+
"model.layers.53.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
| 492 |
+
"model.layers.53.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
| 493 |
+
"model.layers.54.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 494 |
+
"model.layers.54.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
| 495 |
+
"model.layers.54.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
| 496 |
+
"model.layers.54.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
| 497 |
+
"model.layers.54.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
| 498 |
+
"model.layers.54.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 499 |
+
"model.layers.54.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
| 500 |
+
"model.layers.54.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
| 501 |
+
"model.layers.54.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
| 502 |
+
"model.layers.55.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 503 |
+
"model.layers.55.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
| 504 |
+
"model.layers.55.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
| 505 |
+
"model.layers.55.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
| 506 |
+
"model.layers.55.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
| 507 |
+
"model.layers.55.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 508 |
+
"model.layers.55.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
| 509 |
+
"model.layers.55.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
| 510 |
+
"model.layers.55.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
| 511 |
+
"model.layers.56.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 512 |
+
"model.layers.56.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
| 513 |
+
"model.layers.56.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
| 514 |
+
"model.layers.56.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
| 515 |
+
"model.layers.56.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
| 516 |
+
"model.layers.56.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 517 |
+
"model.layers.56.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
| 518 |
+
"model.layers.56.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
| 519 |
+
"model.layers.56.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
| 520 |
+
"model.layers.57.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 521 |
+
"model.layers.57.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
| 522 |
+
"model.layers.57.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
| 523 |
+
"model.layers.57.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
| 524 |
+
"model.layers.57.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
| 525 |
+
"model.layers.57.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 526 |
+
"model.layers.57.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
| 527 |
+
"model.layers.57.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
| 528 |
+
"model.layers.57.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
| 529 |
+
"model.layers.58.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 530 |
+
"model.layers.58.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
| 531 |
+
"model.layers.58.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
| 532 |
+
"model.layers.58.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
| 533 |
+
"model.layers.58.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
| 534 |
+
"model.layers.58.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 535 |
+
"model.layers.58.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
| 536 |
+
"model.layers.58.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
| 537 |
+
"model.layers.58.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
| 538 |
+
"model.layers.59.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 539 |
+
"model.layers.59.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
| 540 |
+
"model.layers.59.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
| 541 |
+
"model.layers.59.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
| 542 |
+
"model.layers.59.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
| 543 |
+
"model.layers.59.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 544 |
+
"model.layers.59.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
| 545 |
+
"model.layers.59.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
| 546 |
+
"model.layers.59.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
| 547 |
+
"model.layers.60.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 548 |
+
"model.layers.60.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
| 549 |
+
"model.layers.60.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
| 550 |
+
"model.layers.60.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
| 551 |
+
"model.layers.60.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
| 552 |
+
"model.layers.60.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 553 |
+
"model.layers.60.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
| 554 |
+
"model.layers.60.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
| 555 |
+
"model.layers.60.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
| 556 |
+
"model.layers.61.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 557 |
+
"model.layers.61.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
| 558 |
+
"model.layers.61.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
| 559 |
+
"model.layers.61.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
| 560 |
+
"model.layers.61.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
| 561 |
+
"model.layers.61.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 562 |
+
"model.layers.61.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
| 563 |
+
"model.layers.61.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
| 564 |
+
"model.layers.61.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
| 565 |
+
"model.layers.62.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 566 |
+
"model.layers.62.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
| 567 |
+
"model.layers.62.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
| 568 |
+
"model.layers.62.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
| 569 |
+
"model.layers.62.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
| 570 |
+
"model.layers.62.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 571 |
+
"model.layers.62.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
| 572 |
+
"model.layers.62.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
| 573 |
+
"model.layers.62.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
| 574 |
+
"model.layers.63.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 575 |
+
"model.layers.63.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
| 576 |
+
"model.layers.63.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
| 577 |
+
"model.layers.63.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
| 578 |
+
"model.layers.63.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
| 579 |
+
"model.layers.63.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 580 |
+
"model.layers.63.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
| 581 |
+
"model.layers.63.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
| 582 |
+
"model.layers.63.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
| 583 |
+
"model.layers.64.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 584 |
+
"model.layers.64.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
| 585 |
+
"model.layers.64.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
| 586 |
+
"model.layers.64.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
| 587 |
+
"model.layers.64.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
| 588 |
+
"model.layers.64.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 589 |
+
"model.layers.64.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
| 590 |
+
"model.layers.64.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
| 591 |
+
"model.layers.64.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
| 592 |
+
"model.layers.65.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 593 |
+
"model.layers.65.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
| 594 |
+
"model.layers.65.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
| 595 |
+
"model.layers.65.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
| 596 |
+
"model.layers.65.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
| 597 |
+
"model.layers.65.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 598 |
+
"model.layers.65.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
| 599 |
+
"model.layers.65.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
| 600 |
+
"model.layers.65.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
| 601 |
+
"model.layers.66.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 602 |
+
"model.layers.66.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
| 603 |
+
"model.layers.66.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
| 604 |
+
"model.layers.66.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
| 605 |
+
"model.layers.66.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
| 606 |
+
"model.layers.66.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 607 |
+
"model.layers.66.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
| 608 |
+
"model.layers.66.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
| 609 |
+
"model.layers.66.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
| 610 |
+
"model.layers.67.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 611 |
+
"model.layers.67.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
| 612 |
+
"model.layers.67.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
| 613 |
+
"model.layers.67.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
| 614 |
+
"model.layers.67.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
| 615 |
+
"model.layers.67.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 616 |
+
"model.layers.67.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
| 617 |
+
"model.layers.67.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
| 618 |
+
"model.layers.67.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
| 619 |
+
"model.layers.68.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 620 |
+
"model.layers.68.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
| 621 |
+
"model.layers.68.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
| 622 |
+
"model.layers.68.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
| 623 |
+
"model.layers.68.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
| 624 |
+
"model.layers.68.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 625 |
+
"model.layers.68.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
| 626 |
+
"model.layers.68.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
| 627 |
+
"model.layers.68.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
| 628 |
+
"model.layers.69.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 629 |
+
"model.layers.69.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
| 630 |
+
"model.layers.69.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
| 631 |
+
"model.layers.69.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
| 632 |
+
"model.layers.69.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
| 633 |
+
"model.layers.69.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 634 |
+
"model.layers.69.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
| 635 |
+
"model.layers.69.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
| 636 |
+
"model.layers.69.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
| 637 |
+
"model.layers.70.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 638 |
+
"model.layers.70.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
| 639 |
+
"model.layers.70.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
| 640 |
+
"model.layers.70.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
| 641 |
+
"model.layers.70.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
| 642 |
+
"model.layers.70.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 643 |
+
"model.layers.70.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
| 644 |
+
"model.layers.70.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
| 645 |
+
"model.layers.70.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
| 646 |
+
"model.layers.71.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 647 |
+
"model.layers.71.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
| 648 |
+
"model.layers.71.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
| 649 |
+
"model.layers.71.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
| 650 |
+
"model.layers.71.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
| 651 |
+
"model.layers.71.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 652 |
+
"model.layers.71.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
| 653 |
+
"model.layers.71.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
| 654 |
+
"model.layers.71.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
| 655 |
+
"model.layers.72.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 656 |
+
"model.layers.72.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
| 657 |
+
"model.layers.72.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
| 658 |
+
"model.layers.72.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
| 659 |
+
"model.layers.72.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
| 660 |
+
"model.layers.72.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 661 |
+
"model.layers.72.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
| 662 |
+
"model.layers.72.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
| 663 |
+
"model.layers.72.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
| 664 |
+
"model.layers.73.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 665 |
+
"model.layers.73.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
| 666 |
+
"model.layers.73.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
| 667 |
+
"model.layers.73.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
| 668 |
+
"model.layers.73.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
| 669 |
+
"model.layers.73.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 670 |
+
"model.layers.73.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
| 671 |
+
"model.layers.73.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
| 672 |
+
"model.layers.73.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
| 673 |
+
"model.layers.74.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 674 |
+
"model.layers.74.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
| 675 |
+
"model.layers.74.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
| 676 |
+
"model.layers.74.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
| 677 |
+
"model.layers.74.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
| 678 |
+
"model.layers.74.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 679 |
+
"model.layers.74.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
| 680 |
+
"model.layers.74.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
| 681 |
+
"model.layers.74.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
| 682 |
+
"model.layers.75.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 683 |
+
"model.layers.75.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
| 684 |
+
"model.layers.75.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
| 685 |
+
"model.layers.75.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
| 686 |
+
"model.layers.75.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
| 687 |
+
"model.layers.75.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 688 |
+
"model.layers.75.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
| 689 |
+
"model.layers.75.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
| 690 |
+
"model.layers.75.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
| 691 |
+
"model.layers.76.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 692 |
+
"model.layers.76.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
| 693 |
+
"model.layers.76.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
| 694 |
+
"model.layers.76.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
| 695 |
+
"model.layers.76.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
| 696 |
+
"model.layers.76.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 697 |
+
"model.layers.76.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
| 698 |
+
"model.layers.76.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
| 699 |
+
"model.layers.76.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
| 700 |
+
"model.layers.77.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 701 |
+
"model.layers.77.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
| 702 |
+
"model.layers.77.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
| 703 |
+
"model.layers.77.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
| 704 |
+
"model.layers.77.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
| 705 |
+
"model.layers.77.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 706 |
+
"model.layers.77.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
| 707 |
+
"model.layers.77.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
| 708 |
+
"model.layers.77.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
| 709 |
+
"model.layers.78.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 710 |
+
"model.layers.78.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
| 711 |
+
"model.layers.78.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
| 712 |
+
"model.layers.78.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
| 713 |
+
"model.layers.78.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
| 714 |
+
"model.layers.78.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 715 |
+
"model.layers.78.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
| 716 |
+
"model.layers.78.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
| 717 |
+
"model.layers.78.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
| 718 |
+
"model.layers.79.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 719 |
+
"model.layers.79.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
| 720 |
+
"model.layers.79.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
| 721 |
+
"model.layers.79.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
| 722 |
+
"model.layers.79.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
| 723 |
+
"model.layers.79.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 724 |
+
"model.layers.79.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
| 725 |
+
"model.layers.79.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
| 726 |
+
"model.layers.79.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
| 727 |
+
"model.norm.weight": "model-00002-of-00002.safetensors",
|
| 728 |
+
"lm_head.weight": "model-00002-of-00002.safetensors"
|
| 729 |
+
}
|
| 730 |
+
}
|
modeling_iquestcoder.py
ADDED
|
@@ -0,0 +1,1051 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""IQuestCoder model implementation.
|
| 2 |
+
|
| 3 |
+
This implementation combines ideas from:
|
| 4 |
+
- LLaMA: Core architecture and forward pass (for compatibility)
|
| 5 |
+
- OLMo: QKV clipping for training stability
|
| 6 |
+
- Qwen2: Sliding window attention support
|
| 7 |
+
|
| 8 |
+
The forward pass is fully compatible with LLaMA weights.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
from typing import Callable, List, Optional, Tuple, Union
|
| 12 |
+
|
| 13 |
+
import torch
|
| 14 |
+
import torch.nn as nn
|
| 15 |
+
import torch.nn.functional as F
|
| 16 |
+
|
| 17 |
+
from transformers.activations import ACT2FN
|
| 18 |
+
from transformers.cache_utils import Cache, DynamicCache, SlidingWindowCache, StaticCache
|
| 19 |
+
from transformers.generation import GenerationMixin
|
| 20 |
+
from transformers.modeling_attn_mask_utils import AttentionMaskConverter
|
| 21 |
+
from transformers.modeling_flash_attention_utils import FlashAttentionKwargs
|
| 22 |
+
from transformers.modeling_layers import GradientCheckpointingLayer
|
| 23 |
+
from transformers.modeling_outputs import (
|
| 24 |
+
BaseModelOutputWithPast,
|
| 25 |
+
CausalLMOutputWithPast,
|
| 26 |
+
QuestionAnsweringModelOutput,
|
| 27 |
+
SequenceClassifierOutputWithPast,
|
| 28 |
+
TokenClassifierOutput,
|
| 29 |
+
)
|
| 30 |
+
from transformers.modeling_rope_utils import ROPE_INIT_FUNCTIONS, dynamic_rope_update
|
| 31 |
+
from transformers.modeling_utils import ALL_ATTENTION_FUNCTIONS, PreTrainedModel
|
| 32 |
+
from transformers.processing_utils import Unpack
|
| 33 |
+
from transformers.utils import (
|
| 34 |
+
LossKwargs,
|
| 35 |
+
auto_docstring,
|
| 36 |
+
can_return_tuple,
|
| 37 |
+
is_torch_flex_attn_available,
|
| 38 |
+
logging,
|
| 39 |
+
)
|
| 40 |
+
|
| 41 |
+
from .configuration_iquestcoder import IQuestCoderConfig
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
if is_torch_flex_attn_available():
|
| 45 |
+
from torch.nn.attention.flex_attention import BlockMask
|
| 46 |
+
from transformers.integrations.flex_attention import make_flex_block_causal_mask
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
logger = logging.get_logger(__name__)
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
# =============================================================================
|
| 53 |
+
# Helper Functions
|
| 54 |
+
# =============================================================================
|
| 55 |
+
|
| 56 |
+
def rotate_half(x: torch.Tensor) -> torch.Tensor:
|
| 57 |
+
"""Rotates half the hidden dims of the input."""
|
| 58 |
+
x1 = x[..., : x.shape[-1] // 2]
|
| 59 |
+
x2 = x[..., x.shape[-1] // 2 :]
|
| 60 |
+
return torch.cat((-x2, x1), dim=-1)
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
def apply_rotary_pos_emb(
|
| 64 |
+
q: torch.Tensor,
|
| 65 |
+
k: torch.Tensor,
|
| 66 |
+
cos: torch.Tensor,
|
| 67 |
+
sin: torch.Tensor,
|
| 68 |
+
position_ids: Optional[torch.Tensor] = None,
|
| 69 |
+
unsqueeze_dim: int = 1,
|
| 70 |
+
) -> Tuple[torch.Tensor, torch.Tensor]:
|
| 71 |
+
"""Applies Rotary Position Embedding to the query and key tensors.
|
| 72 |
+
|
| 73 |
+
Args:
|
| 74 |
+
q: The query tensor.
|
| 75 |
+
k: The key tensor.
|
| 76 |
+
cos: The cosine part of the rotary embedding.
|
| 77 |
+
sin: The sine part of the rotary embedding.
|
| 78 |
+
position_ids: Deprecated and unused.
|
| 79 |
+
unsqueeze_dim: The dimension along which to unsqueeze cos and sin.
|
| 80 |
+
|
| 81 |
+
Returns:
|
| 82 |
+
Tuple of query and key tensors rotated using the Rotary Position Embedding.
|
| 83 |
+
"""
|
| 84 |
+
# Borrowed from OLMo: preserve original dtypes for numerical stability
|
| 85 |
+
q_dtype, k_dtype = q.dtype, k.dtype
|
| 86 |
+
cos = cos.unsqueeze(unsqueeze_dim)
|
| 87 |
+
sin = sin.unsqueeze(unsqueeze_dim)
|
| 88 |
+
q_embed = (q * cos) + (rotate_half(q) * sin)
|
| 89 |
+
k_embed = (k * cos) + (rotate_half(k) * sin)
|
| 90 |
+
return q_embed.to(q_dtype), k_embed.to(k_dtype)
|
| 91 |
+
|
| 92 |
+
|
| 93 |
+
def repeat_kv(hidden_states: torch.Tensor, n_rep: int) -> torch.Tensor:
|
| 94 |
+
"""
|
| 95 |
+
Expands key/value heads for Grouped Query Attention.
|
| 96 |
+
|
| 97 |
+
This is the equivalent of torch.repeat_interleave(x, dim=1, repeats=n_rep).
|
| 98 |
+
The hidden states go from (batch, num_key_value_heads, seqlen, head_dim) to
|
| 99 |
+
(batch, num_attention_heads, seqlen, head_dim).
|
| 100 |
+
"""
|
| 101 |
+
batch, num_key_value_heads, slen, head_dim = hidden_states.shape
|
| 102 |
+
if n_rep == 1:
|
| 103 |
+
return hidden_states
|
| 104 |
+
hidden_states = hidden_states[:, :, None, :, :].expand(batch, num_key_value_heads, n_rep, slen, head_dim)
|
| 105 |
+
return hidden_states.reshape(batch, num_key_value_heads * n_rep, slen, head_dim)
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
def eager_attention_forward(
|
| 109 |
+
module: nn.Module,
|
| 110 |
+
query: torch.Tensor,
|
| 111 |
+
key: torch.Tensor,
|
| 112 |
+
value: torch.Tensor,
|
| 113 |
+
attention_mask: Optional[torch.Tensor],
|
| 114 |
+
scaling: float,
|
| 115 |
+
dropout: float = 0.0,
|
| 116 |
+
**kwargs,
|
| 117 |
+
) -> Tuple[torch.Tensor, torch.Tensor]:
|
| 118 |
+
"""Standard eager attention implementation."""
|
| 119 |
+
key_states = repeat_kv(key, module.num_key_value_groups)
|
| 120 |
+
value_states = repeat_kv(value, module.num_key_value_groups)
|
| 121 |
+
|
| 122 |
+
attn_weights = torch.matmul(query, key_states.transpose(2, 3)) * scaling
|
| 123 |
+
if attention_mask is not None:
|
| 124 |
+
causal_mask = attention_mask[:, :, :, : key_states.shape[-2]]
|
| 125 |
+
attn_weights = attn_weights + causal_mask
|
| 126 |
+
|
| 127 |
+
attn_weights = F.softmax(attn_weights, dim=-1, dtype=torch.float32).to(query.dtype)
|
| 128 |
+
attn_weights = F.dropout(attn_weights, p=dropout, training=module.training)
|
| 129 |
+
attn_output = torch.matmul(attn_weights, value_states)
|
| 130 |
+
attn_output = attn_output.transpose(1, 2).contiguous()
|
| 131 |
+
|
| 132 |
+
return attn_output, attn_weights
|
| 133 |
+
|
| 134 |
+
|
| 135 |
+
# =============================================================================
|
| 136 |
+
# Model Components
|
| 137 |
+
# =============================================================================
|
| 138 |
+
|
| 139 |
+
class IQuestCoderRMSNorm(nn.Module):
|
| 140 |
+
"""Root Mean Square Layer Normalization.
|
| 141 |
+
|
| 142 |
+
RMSNorm is computationally simpler than LayerNorm while achieving similar
|
| 143 |
+
performance. It normalizes the input by its RMS value.
|
| 144 |
+
"""
|
| 145 |
+
|
| 146 |
+
def __init__(self, hidden_size: int, eps: float = 1e-6):
|
| 147 |
+
super().__init__()
|
| 148 |
+
self.weight = nn.Parameter(torch.ones(hidden_size))
|
| 149 |
+
self.variance_epsilon = eps
|
| 150 |
+
|
| 151 |
+
def forward(self, hidden_states: torch.Tensor) -> torch.Tensor:
|
| 152 |
+
input_dtype = hidden_states.dtype
|
| 153 |
+
hidden_states = hidden_states.to(torch.float32)
|
| 154 |
+
variance = hidden_states.pow(2).mean(-1, keepdim=True)
|
| 155 |
+
hidden_states = hidden_states * torch.rsqrt(variance + self.variance_epsilon)
|
| 156 |
+
return self.weight * hidden_states.to(input_dtype)
|
| 157 |
+
|
| 158 |
+
def extra_repr(self) -> str:
|
| 159 |
+
return f"{tuple(self.weight.shape)}, eps={self.variance_epsilon}"
|
| 160 |
+
|
| 161 |
+
|
| 162 |
+
class IQuestCoderRotaryEmbedding(nn.Module):
|
| 163 |
+
"""Rotary Position Embedding (RoPE).
|
| 164 |
+
|
| 165 |
+
Implements rotary positional embeddings as described in the RoFormer paper.
|
| 166 |
+
Supports various RoPE scaling methods for extended context lengths.
|
| 167 |
+
"""
|
| 168 |
+
|
| 169 |
+
def __init__(self, config: IQuestCoderConfig, device=None):
|
| 170 |
+
super().__init__()
|
| 171 |
+
# BC: "rope_type" was originally "type"
|
| 172 |
+
if hasattr(config, "rope_scaling") and config.rope_scaling is not None:
|
| 173 |
+
self.rope_type = config.rope_scaling.get("rope_type", config.rope_scaling.get("type"))
|
| 174 |
+
else:
|
| 175 |
+
self.rope_type = "default"
|
| 176 |
+
self.max_seq_len_cached = config.max_position_embeddings
|
| 177 |
+
self.original_max_seq_len = config.max_position_embeddings
|
| 178 |
+
|
| 179 |
+
self.config = config
|
| 180 |
+
self.rope_init_fn = ROPE_INIT_FUNCTIONS[self.rope_type]
|
| 181 |
+
|
| 182 |
+
inv_freq, self.attention_scaling = self.rope_init_fn(self.config, device)
|
| 183 |
+
self.register_buffer("inv_freq", inv_freq, persistent=False)
|
| 184 |
+
self.original_inv_freq = self.inv_freq
|
| 185 |
+
|
| 186 |
+
@torch.no_grad()
|
| 187 |
+
@dynamic_rope_update
|
| 188 |
+
def forward(self, x: torch.Tensor, position_ids: torch.Tensor) -> Tuple[torch.Tensor, torch.Tensor]:
|
| 189 |
+
inv_freq_expanded = self.inv_freq[None, :, None].float().expand(position_ids.shape[0], -1, 1).to(x.device)
|
| 190 |
+
position_ids_expanded = position_ids[:, None, :].float()
|
| 191 |
+
|
| 192 |
+
device_type = x.device.type if isinstance(x.device.type, str) and x.device.type != "mps" else "cpu"
|
| 193 |
+
with torch.autocast(device_type=device_type, enabled=False):
|
| 194 |
+
freqs = (inv_freq_expanded.float() @ position_ids_expanded.float()).transpose(1, 2)
|
| 195 |
+
emb = torch.cat((freqs, freqs), dim=-1)
|
| 196 |
+
cos = emb.cos() * self.attention_scaling
|
| 197 |
+
sin = emb.sin() * self.attention_scaling
|
| 198 |
+
|
| 199 |
+
return cos.to(dtype=x.dtype), sin.to(dtype=x.dtype)
|
| 200 |
+
|
| 201 |
+
|
| 202 |
+
class IQuestCoderMLP(nn.Module):
|
| 203 |
+
"""Feed-forward network with SwiGLU activation.
|
| 204 |
+
|
| 205 |
+
Uses the gated linear unit variant with SiLU activation for improved
|
| 206 |
+
performance compared to standard FFN.
|
| 207 |
+
"""
|
| 208 |
+
|
| 209 |
+
def __init__(self, config: IQuestCoderConfig):
|
| 210 |
+
super().__init__()
|
| 211 |
+
self.config = config
|
| 212 |
+
self.hidden_size = config.hidden_size
|
| 213 |
+
self.intermediate_size = config.intermediate_size
|
| 214 |
+
self.gate_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=config.mlp_bias)
|
| 215 |
+
self.up_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=config.mlp_bias)
|
| 216 |
+
self.down_proj = nn.Linear(self.intermediate_size, self.hidden_size, bias=config.mlp_bias)
|
| 217 |
+
self.act_fn = ACT2FN[config.hidden_act]
|
| 218 |
+
|
| 219 |
+
def forward(self, x: torch.Tensor) -> torch.Tensor:
|
| 220 |
+
# SwiGLU: down_proj(act_fn(gate_proj(x)) * up_proj(x))
|
| 221 |
+
return self.down_proj(self.act_fn(self.gate_proj(x)) * self.up_proj(x))
|
| 222 |
+
|
| 223 |
+
|
| 224 |
+
class IQuestCoderAttention(nn.Module):
|
| 225 |
+
"""Multi-headed attention with support for Grouped Query Attention (GQA).
|
| 226 |
+
|
| 227 |
+
Features:
|
| 228 |
+
- Grouped Query Attention for memory efficiency
|
| 229 |
+
- Optional QKV clipping for training stability (from OLMo)
|
| 230 |
+
- Optional sliding window attention (from Qwen2)
|
| 231 |
+
- Rotary Position Embeddings
|
| 232 |
+
"""
|
| 233 |
+
|
| 234 |
+
def __init__(self, config: IQuestCoderConfig, 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 |
+
# Projection layers
|
| 245 |
+
self.q_proj = nn.Linear(
|
| 246 |
+
config.hidden_size, config.num_attention_heads * self.head_dim, bias=config.attention_bias
|
| 247 |
+
)
|
| 248 |
+
self.k_proj = nn.Linear(
|
| 249 |
+
config.hidden_size, config.num_key_value_heads * self.head_dim, bias=config.attention_bias
|
| 250 |
+
)
|
| 251 |
+
self.v_proj = nn.Linear(
|
| 252 |
+
config.hidden_size, config.num_key_value_heads * self.head_dim, bias=config.attention_bias
|
| 253 |
+
)
|
| 254 |
+
self.o_proj = nn.Linear(
|
| 255 |
+
config.num_attention_heads * self.head_dim, config.hidden_size, bias=config.attention_bias
|
| 256 |
+
)
|
| 257 |
+
|
| 258 |
+
def forward(
|
| 259 |
+
self,
|
| 260 |
+
hidden_states: torch.Tensor,
|
| 261 |
+
position_embeddings: Tuple[torch.Tensor, torch.Tensor],
|
| 262 |
+
attention_mask: Optional[torch.Tensor],
|
| 263 |
+
past_key_value: Optional[Cache] = None,
|
| 264 |
+
cache_position: Optional[torch.LongTensor] = None,
|
| 265 |
+
**kwargs: Unpack[FlashAttentionKwargs],
|
| 266 |
+
) -> Tuple[torch.Tensor, Optional[torch.Tensor], Optional[Tuple[torch.Tensor]]]:
|
| 267 |
+
input_shape = hidden_states.shape[:-1]
|
| 268 |
+
hidden_shape = (*input_shape, -1, self.head_dim)
|
| 269 |
+
|
| 270 |
+
# Compute Q, K, V projections
|
| 271 |
+
query_states = self.q_proj(hidden_states)
|
| 272 |
+
key_states = self.k_proj(hidden_states)
|
| 273 |
+
value_states = self.v_proj(hidden_states)
|
| 274 |
+
|
| 275 |
+
# [OLMo Feature] Optional QKV clipping for training stability
|
| 276 |
+
if self.config.clip_qkv is not None:
|
| 277 |
+
query_states = query_states.clamp(min=-self.config.clip_qkv, max=self.config.clip_qkv)
|
| 278 |
+
key_states = key_states.clamp(min=-self.config.clip_qkv, max=self.config.clip_qkv)
|
| 279 |
+
value_states = value_states.clamp(min=-self.config.clip_qkv, max=self.config.clip_qkv)
|
| 280 |
+
|
| 281 |
+
# Reshape to (batch, heads, seq_len, head_dim)
|
| 282 |
+
query_states = query_states.view(hidden_shape).transpose(1, 2)
|
| 283 |
+
key_states = key_states.view(hidden_shape).transpose(1, 2)
|
| 284 |
+
value_states = value_states.view(hidden_shape).transpose(1, 2)
|
| 285 |
+
|
| 286 |
+
# Apply rotary position embeddings
|
| 287 |
+
cos, sin = position_embeddings
|
| 288 |
+
query_states, key_states = apply_rotary_pos_emb(query_states, key_states, cos, sin)
|
| 289 |
+
|
| 290 |
+
# Update KV cache if provided
|
| 291 |
+
if past_key_value is not None:
|
| 292 |
+
cache_kwargs = {"sin": sin, "cos": cos, "cache_position": cache_position}
|
| 293 |
+
key_states, value_states = past_key_value.update(key_states, value_states, self.layer_idx, cache_kwargs)
|
| 294 |
+
|
| 295 |
+
# [Qwen2 Feature] Sliding window attention
|
| 296 |
+
sliding_window = None
|
| 297 |
+
if (
|
| 298 |
+
self.config.use_sliding_window
|
| 299 |
+
and getattr(self.config, "sliding_window", None) is not None
|
| 300 |
+
and self.layer_idx >= self.config.max_window_layers
|
| 301 |
+
):
|
| 302 |
+
sliding_window = self.config.sliding_window
|
| 303 |
+
|
| 304 |
+
# Select attention implementation
|
| 305 |
+
attention_interface: Callable = eager_attention_forward
|
| 306 |
+
if self.config._attn_implementation != "eager":
|
| 307 |
+
if self.config._attn_implementation == "sdpa" and kwargs.get("output_attentions", False):
|
| 308 |
+
logger.warning_once(
|
| 309 |
+
"`torch.nn.functional.scaled_dot_product_attention` does not support `output_attentions=True`. "
|
| 310 |
+
'Falling back to eager attention. This warning can be removed using the argument '
|
| 311 |
+
'`attn_implementation="eager"` when loading the model.'
|
| 312 |
+
)
|
| 313 |
+
else:
|
| 314 |
+
attention_interface = ALL_ATTENTION_FUNCTIONS[self.config._attn_implementation]
|
| 315 |
+
|
| 316 |
+
# Compute attention
|
| 317 |
+
attn_output, attn_weights = attention_interface(
|
| 318 |
+
self,
|
| 319 |
+
query_states,
|
| 320 |
+
key_states,
|
| 321 |
+
value_states,
|
| 322 |
+
attention_mask,
|
| 323 |
+
dropout=0.0 if not self.training else self.attention_dropout,
|
| 324 |
+
scaling=self.scaling,
|
| 325 |
+
sliding_window=sliding_window,
|
| 326 |
+
**kwargs,
|
| 327 |
+
)
|
| 328 |
+
|
| 329 |
+
# Reshape and project output
|
| 330 |
+
attn_output = attn_output.reshape(*input_shape, -1).contiguous()
|
| 331 |
+
attn_output = self.o_proj(attn_output)
|
| 332 |
+
|
| 333 |
+
return attn_output, attn_weights
|
| 334 |
+
|
| 335 |
+
|
| 336 |
+
class IQuestCoderDecoderLayer(GradientCheckpointingLayer):
|
| 337 |
+
"""Transformer decoder layer with pre-normalization.
|
| 338 |
+
|
| 339 |
+
Architecture: Pre-RMSNorm -> Attention -> Residual -> Pre-RMSNorm -> MLP -> Residual
|
| 340 |
+
"""
|
| 341 |
+
|
| 342 |
+
def __init__(self, config: IQuestCoderConfig, layer_idx: int):
|
| 343 |
+
super().__init__()
|
| 344 |
+
self.hidden_size = config.hidden_size
|
| 345 |
+
self.self_attn = IQuestCoderAttention(config=config, layer_idx=layer_idx)
|
| 346 |
+
self.mlp = IQuestCoderMLP(config)
|
| 347 |
+
self.input_layernorm = IQuestCoderRMSNorm(config.hidden_size, eps=config.rms_norm_eps)
|
| 348 |
+
self.post_attention_layernorm = IQuestCoderRMSNorm(config.hidden_size, eps=config.rms_norm_eps)
|
| 349 |
+
|
| 350 |
+
# Warn if sliding window is enabled but not properly supported
|
| 351 |
+
if config.use_sliding_window and config._attn_implementation != "flash_attention_2":
|
| 352 |
+
logger.warning_once(
|
| 353 |
+
f"Sliding Window Attention is enabled but not implemented for `{config._attn_implementation}`; "
|
| 354 |
+
"unexpected results may be encountered."
|
| 355 |
+
)
|
| 356 |
+
|
| 357 |
+
def forward(
|
| 358 |
+
self,
|
| 359 |
+
hidden_states: torch.Tensor,
|
| 360 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 361 |
+
position_ids: Optional[torch.LongTensor] = None,
|
| 362 |
+
past_key_value: Optional[Cache] = None,
|
| 363 |
+
output_attentions: Optional[bool] = False,
|
| 364 |
+
use_cache: Optional[bool] = False,
|
| 365 |
+
cache_position: Optional[torch.LongTensor] = None,
|
| 366 |
+
position_embeddings: Optional[Tuple[torch.Tensor, torch.Tensor]] = None,
|
| 367 |
+
**kwargs: Unpack[FlashAttentionKwargs],
|
| 368 |
+
) -> Tuple[torch.FloatTensor, Optional[Tuple[torch.FloatTensor, torch.FloatTensor]]]:
|
| 369 |
+
# Pre-norm + Self Attention
|
| 370 |
+
residual = hidden_states
|
| 371 |
+
hidden_states = self.input_layernorm(hidden_states)
|
| 372 |
+
|
| 373 |
+
hidden_states, self_attn_weights = self.self_attn(
|
| 374 |
+
hidden_states=hidden_states,
|
| 375 |
+
attention_mask=attention_mask,
|
| 376 |
+
position_ids=position_ids,
|
| 377 |
+
past_key_value=past_key_value,
|
| 378 |
+
output_attentions=output_attentions,
|
| 379 |
+
use_cache=use_cache,
|
| 380 |
+
cache_position=cache_position,
|
| 381 |
+
position_embeddings=position_embeddings,
|
| 382 |
+
**kwargs,
|
| 383 |
+
)
|
| 384 |
+
hidden_states = residual + hidden_states
|
| 385 |
+
|
| 386 |
+
# Pre-norm + MLP
|
| 387 |
+
residual = hidden_states
|
| 388 |
+
hidden_states = self.post_attention_layernorm(hidden_states)
|
| 389 |
+
hidden_states = self.mlp(hidden_states)
|
| 390 |
+
hidden_states = residual + hidden_states
|
| 391 |
+
|
| 392 |
+
outputs = (hidden_states,)
|
| 393 |
+
if output_attentions:
|
| 394 |
+
outputs += (self_attn_weights,)
|
| 395 |
+
|
| 396 |
+
return outputs
|
| 397 |
+
|
| 398 |
+
|
| 399 |
+
# =============================================================================
|
| 400 |
+
# Base Model
|
| 401 |
+
# =============================================================================
|
| 402 |
+
|
| 403 |
+
@auto_docstring
|
| 404 |
+
class IQuestCoderPreTrainedModel(PreTrainedModel):
|
| 405 |
+
"""Base class for IQuestCoder models."""
|
| 406 |
+
|
| 407 |
+
config_class = IQuestCoderConfig
|
| 408 |
+
base_model_prefix = "model"
|
| 409 |
+
supports_gradient_checkpointing = True
|
| 410 |
+
_no_split_modules = ["IQuestCoderDecoderLayer"]
|
| 411 |
+
_skip_keys_device_placement = ["past_key_values"]
|
| 412 |
+
_supports_flash_attn_2 = True
|
| 413 |
+
_supports_sdpa = True
|
| 414 |
+
_supports_flex_attn = True
|
| 415 |
+
_supports_cache_class = True
|
| 416 |
+
_supports_quantized_cache = True
|
| 417 |
+
_supports_static_cache = True
|
| 418 |
+
_supports_attention_backend = True
|
| 419 |
+
|
| 420 |
+
def _init_weights(self, module: nn.Module):
|
| 421 |
+
std = self.config.initializer_range
|
| 422 |
+
if isinstance(module, nn.Linear):
|
| 423 |
+
module.weight.data.normal_(mean=0.0, std=std)
|
| 424 |
+
if module.bias is not None:
|
| 425 |
+
module.bias.data.zero_()
|
| 426 |
+
elif isinstance(module, nn.Embedding):
|
| 427 |
+
module.weight.data.normal_(mean=0.0, std=std)
|
| 428 |
+
if module.padding_idx is not None:
|
| 429 |
+
module.weight.data[module.padding_idx].zero_()
|
| 430 |
+
elif isinstance(module, IQuestCoderRMSNorm):
|
| 431 |
+
module.weight.data.fill_(1.0)
|
| 432 |
+
|
| 433 |
+
|
| 434 |
+
@auto_docstring
|
| 435 |
+
class IQuestCoderModel(IQuestCoderPreTrainedModel):
|
| 436 |
+
"""
|
| 437 |
+
IQuestCoder Model outputting raw hidden-states without any specific head on top.
|
| 438 |
+
|
| 439 |
+
This model is compatible with LLaMA weights while incorporating features from OLMo and Qwen2.
|
| 440 |
+
"""
|
| 441 |
+
|
| 442 |
+
def __init__(self, config: IQuestCoderConfig):
|
| 443 |
+
super().__init__(config)
|
| 444 |
+
self.padding_idx = config.pad_token_id
|
| 445 |
+
self.vocab_size = config.vocab_size
|
| 446 |
+
|
| 447 |
+
self.embed_tokens = nn.Embedding(config.vocab_size, config.hidden_size, self.padding_idx)
|
| 448 |
+
self.layers = nn.ModuleList(
|
| 449 |
+
[IQuestCoderDecoderLayer(config, layer_idx) for layer_idx in range(config.num_hidden_layers)]
|
| 450 |
+
)
|
| 451 |
+
self.norm = IQuestCoderRMSNorm(config.hidden_size, eps=config.rms_norm_eps)
|
| 452 |
+
self.rotary_emb = IQuestCoderRotaryEmbedding(config=config)
|
| 453 |
+
self.gradient_checkpointing = False
|
| 454 |
+
|
| 455 |
+
# Initialize weights and apply final processing
|
| 456 |
+
self.post_init()
|
| 457 |
+
|
| 458 |
+
def get_input_embeddings(self) -> nn.Embedding:
|
| 459 |
+
return self.embed_tokens
|
| 460 |
+
|
| 461 |
+
def set_input_embeddings(self, value: nn.Embedding):
|
| 462 |
+
self.embed_tokens = value
|
| 463 |
+
|
| 464 |
+
@can_return_tuple
|
| 465 |
+
@auto_docstring
|
| 466 |
+
def forward(
|
| 467 |
+
self,
|
| 468 |
+
input_ids: Optional[torch.LongTensor] = None,
|
| 469 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 470 |
+
position_ids: Optional[torch.LongTensor] = None,
|
| 471 |
+
past_key_values: Optional[Cache] = None,
|
| 472 |
+
inputs_embeds: Optional[torch.FloatTensor] = None,
|
| 473 |
+
use_cache: Optional[bool] = None,
|
| 474 |
+
output_attentions: Optional[bool] = None,
|
| 475 |
+
output_hidden_states: Optional[bool] = None,
|
| 476 |
+
cache_position: Optional[torch.LongTensor] = None,
|
| 477 |
+
**flash_attn_kwargs: Unpack[FlashAttentionKwargs],
|
| 478 |
+
) -> BaseModelOutputWithPast:
|
| 479 |
+
output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
|
| 480 |
+
output_hidden_states = (
|
| 481 |
+
output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
|
| 482 |
+
)
|
| 483 |
+
use_cache = use_cache if use_cache is not None else self.config.use_cache
|
| 484 |
+
|
| 485 |
+
if (input_ids is None) ^ (inputs_embeds is not None):
|
| 486 |
+
raise ValueError("You must specify exactly one of input_ids or inputs_embeds")
|
| 487 |
+
|
| 488 |
+
if self.gradient_checkpointing and self.training and use_cache:
|
| 489 |
+
logger.warning_once(
|
| 490 |
+
"`use_cache=True` is incompatible with gradient checkpointing. Setting `use_cache=False`."
|
| 491 |
+
)
|
| 492 |
+
use_cache = False
|
| 493 |
+
|
| 494 |
+
if not isinstance(past_key_values, (type(None), Cache)):
|
| 495 |
+
raise ValueError("The `past_key_values` should be either a `Cache` object or `None`.")
|
| 496 |
+
|
| 497 |
+
if inputs_embeds is None:
|
| 498 |
+
inputs_embeds = self.embed_tokens(input_ids)
|
| 499 |
+
|
| 500 |
+
if use_cache and past_key_values is None:
|
| 501 |
+
past_key_values = DynamicCache()
|
| 502 |
+
|
| 503 |
+
if cache_position is None:
|
| 504 |
+
past_seen_tokens = past_key_values.get_seq_length() if past_key_values is not None else 0
|
| 505 |
+
cache_position = torch.arange(
|
| 506 |
+
past_seen_tokens, past_seen_tokens + inputs_embeds.shape[1], device=inputs_embeds.device
|
| 507 |
+
)
|
| 508 |
+
|
| 509 |
+
if position_ids is None:
|
| 510 |
+
position_ids = cache_position.unsqueeze(0)
|
| 511 |
+
|
| 512 |
+
causal_mask = self._update_causal_mask(
|
| 513 |
+
attention_mask, inputs_embeds, cache_position, past_key_values, output_attentions
|
| 514 |
+
)
|
| 515 |
+
|
| 516 |
+
hidden_states = inputs_embeds
|
| 517 |
+
|
| 518 |
+
# Create position embeddings to be shared across the decoder layers
|
| 519 |
+
position_embeddings = self.rotary_emb(hidden_states, position_ids)
|
| 520 |
+
|
| 521 |
+
# Decoder layers
|
| 522 |
+
all_hidden_states = () if output_hidden_states else None
|
| 523 |
+
all_self_attns = () if output_attentions else None
|
| 524 |
+
|
| 525 |
+
for decoder_layer in self.layers[: self.config.num_hidden_layers]:
|
| 526 |
+
if output_hidden_states:
|
| 527 |
+
all_hidden_states += (hidden_states,)
|
| 528 |
+
|
| 529 |
+
layer_outputs = decoder_layer(
|
| 530 |
+
hidden_states,
|
| 531 |
+
attention_mask=causal_mask,
|
| 532 |
+
position_ids=position_ids,
|
| 533 |
+
past_key_value=past_key_values,
|
| 534 |
+
output_attentions=output_attentions,
|
| 535 |
+
use_cache=use_cache,
|
| 536 |
+
cache_position=cache_position,
|
| 537 |
+
position_embeddings=position_embeddings,
|
| 538 |
+
**flash_attn_kwargs,
|
| 539 |
+
)
|
| 540 |
+
|
| 541 |
+
hidden_states = layer_outputs[0]
|
| 542 |
+
|
| 543 |
+
if output_attentions:
|
| 544 |
+
all_self_attns += (layer_outputs[1],)
|
| 545 |
+
|
| 546 |
+
hidden_states = self.norm(hidden_states)
|
| 547 |
+
|
| 548 |
+
# Add hidden states from the last decoder layer
|
| 549 |
+
if output_hidden_states:
|
| 550 |
+
all_hidden_states += (hidden_states,)
|
| 551 |
+
|
| 552 |
+
return BaseModelOutputWithPast(
|
| 553 |
+
last_hidden_state=hidden_states,
|
| 554 |
+
past_key_values=past_key_values if use_cache else None,
|
| 555 |
+
hidden_states=all_hidden_states,
|
| 556 |
+
attentions=all_self_attns,
|
| 557 |
+
)
|
| 558 |
+
|
| 559 |
+
def _update_causal_mask(
|
| 560 |
+
self,
|
| 561 |
+
attention_mask: Union[torch.Tensor, "BlockMask"],
|
| 562 |
+
input_tensor: torch.Tensor,
|
| 563 |
+
cache_position: torch.Tensor,
|
| 564 |
+
past_key_values: Cache,
|
| 565 |
+
output_attentions: bool = False,
|
| 566 |
+
):
|
| 567 |
+
if self.config._attn_implementation == "flash_attention_2":
|
| 568 |
+
if attention_mask is not None and past_key_values is not None:
|
| 569 |
+
is_padding_right = attention_mask[:, -1].sum().item() != input_tensor.size()[0]
|
| 570 |
+
if is_padding_right:
|
| 571 |
+
raise ValueError(
|
| 572 |
+
"You are attempting to perform batched generation with padding_side='right'. "
|
| 573 |
+
"This may lead to unexpected behaviour for Flash Attention version of IQuestCoder. "
|
| 574 |
+
"Make sure to call `tokenizer.padding_side = 'left'` before tokenizing the input."
|
| 575 |
+
)
|
| 576 |
+
if attention_mask is not None and 0.0 in attention_mask:
|
| 577 |
+
return attention_mask
|
| 578 |
+
return None
|
| 579 |
+
|
| 580 |
+
if self.config._attn_implementation == "flex_attention":
|
| 581 |
+
if isinstance(attention_mask, torch.Tensor):
|
| 582 |
+
attention_mask = make_flex_block_causal_mask(attention_mask)
|
| 583 |
+
return attention_mask
|
| 584 |
+
|
| 585 |
+
past_seen_tokens = past_key_values.get_seq_length() if past_key_values is not None else 0
|
| 586 |
+
using_static_cache = isinstance(past_key_values, StaticCache)
|
| 587 |
+
using_sliding_window_cache = isinstance(past_key_values, SlidingWindowCache)
|
| 588 |
+
|
| 589 |
+
if (
|
| 590 |
+
self.config._attn_implementation == "sdpa"
|
| 591 |
+
and not (using_static_cache or using_sliding_window_cache)
|
| 592 |
+
and not output_attentions
|
| 593 |
+
):
|
| 594 |
+
if AttentionMaskConverter._ignore_causal_mask_sdpa(
|
| 595 |
+
attention_mask,
|
| 596 |
+
inputs_embeds=input_tensor,
|
| 597 |
+
past_key_values_length=past_seen_tokens,
|
| 598 |
+
sliding_window=self.config.sliding_window if self.config.use_sliding_window else None,
|
| 599 |
+
is_training=self.training,
|
| 600 |
+
):
|
| 601 |
+
return None
|
| 602 |
+
|
| 603 |
+
dtype = input_tensor.dtype
|
| 604 |
+
min_dtype = torch.finfo(dtype).min
|
| 605 |
+
sequence_length = input_tensor.shape[1]
|
| 606 |
+
|
| 607 |
+
if using_sliding_window_cache or using_static_cache:
|
| 608 |
+
target_length = past_key_values.get_max_cache_shape()
|
| 609 |
+
else:
|
| 610 |
+
target_length = (
|
| 611 |
+
attention_mask.shape[-1]
|
| 612 |
+
if isinstance(attention_mask, torch.Tensor)
|
| 613 |
+
else past_seen_tokens + sequence_length + 1
|
| 614 |
+
)
|
| 615 |
+
|
| 616 |
+
causal_mask = self._prepare_4d_causal_attention_mask_with_cache_position(
|
| 617 |
+
attention_mask,
|
| 618 |
+
sequence_length=sequence_length,
|
| 619 |
+
target_length=target_length,
|
| 620 |
+
dtype=dtype,
|
| 621 |
+
cache_position=cache_position,
|
| 622 |
+
batch_size=input_tensor.shape[0],
|
| 623 |
+
config=self.config,
|
| 624 |
+
past_key_values=past_key_values,
|
| 625 |
+
)
|
| 626 |
+
|
| 627 |
+
if (
|
| 628 |
+
self.config._attn_implementation == "sdpa"
|
| 629 |
+
and attention_mask is not None
|
| 630 |
+
and attention_mask.device.type in ["cuda", "xpu", "npu"]
|
| 631 |
+
and not output_attentions
|
| 632 |
+
):
|
| 633 |
+
causal_mask = AttentionMaskConverter._unmask_unattended(causal_mask, min_dtype)
|
| 634 |
+
|
| 635 |
+
return causal_mask
|
| 636 |
+
|
| 637 |
+
@staticmethod
|
| 638 |
+
def _prepare_4d_causal_attention_mask_with_cache_position(
|
| 639 |
+
attention_mask: torch.Tensor,
|
| 640 |
+
sequence_length: int,
|
| 641 |
+
target_length: int,
|
| 642 |
+
dtype: torch.dtype,
|
| 643 |
+
cache_position: torch.Tensor,
|
| 644 |
+
batch_size: int,
|
| 645 |
+
config: IQuestCoderConfig,
|
| 646 |
+
past_key_values: Cache,
|
| 647 |
+
):
|
| 648 |
+
"""Creates a causal 4D mask from a 2D mask, or returns the 4D mask if already provided."""
|
| 649 |
+
if attention_mask is not None and attention_mask.dim() == 4:
|
| 650 |
+
causal_mask = attention_mask
|
| 651 |
+
else:
|
| 652 |
+
min_dtype = torch.finfo(dtype).min
|
| 653 |
+
causal_mask = torch.full(
|
| 654 |
+
(sequence_length, target_length), fill_value=min_dtype, dtype=dtype, device=cache_position.device
|
| 655 |
+
)
|
| 656 |
+
diagonal_attend_mask = torch.arange(target_length, device=cache_position.device) > cache_position.reshape(
|
| 657 |
+
-1, 1
|
| 658 |
+
)
|
| 659 |
+
|
| 660 |
+
# [Qwen2 Feature] Handle sliding window mask
|
| 661 |
+
if getattr(config, "use_sliding_window", False) and config.sliding_window is not None:
|
| 662 |
+
if not isinstance(past_key_values, SlidingWindowCache) or sequence_length > target_length:
|
| 663 |
+
sliding_attend_mask = torch.arange(target_length, device=cache_position.device) <= (
|
| 664 |
+
cache_position.reshape(-1, 1) - config.sliding_window
|
| 665 |
+
)
|
| 666 |
+
diagonal_attend_mask.bitwise_or_(sliding_attend_mask)
|
| 667 |
+
|
| 668 |
+
causal_mask *= diagonal_attend_mask
|
| 669 |
+
causal_mask = causal_mask[None, None, :, :].expand(batch_size, 1, -1, -1)
|
| 670 |
+
|
| 671 |
+
if attention_mask is not None:
|
| 672 |
+
causal_mask = causal_mask.clone()
|
| 673 |
+
if attention_mask.shape[-1] > target_length:
|
| 674 |
+
attention_mask = attention_mask[:, :target_length]
|
| 675 |
+
mask_length = attention_mask.shape[-1]
|
| 676 |
+
padding_mask = causal_mask[:, :, :, :mask_length] + attention_mask[:, None, None, :].to(
|
| 677 |
+
causal_mask.device
|
| 678 |
+
)
|
| 679 |
+
padding_mask = padding_mask == 0
|
| 680 |
+
causal_mask[:, :, :, :mask_length] = causal_mask[:, :, :, :mask_length].masked_fill(
|
| 681 |
+
padding_mask, min_dtype
|
| 682 |
+
)
|
| 683 |
+
|
| 684 |
+
return causal_mask
|
| 685 |
+
|
| 686 |
+
|
| 687 |
+
# =============================================================================
|
| 688 |
+
# Model Heads
|
| 689 |
+
# =============================================================================
|
| 690 |
+
|
| 691 |
+
class KwargsForCausalLM(FlashAttentionKwargs, LossKwargs):
|
| 692 |
+
...
|
| 693 |
+
|
| 694 |
+
|
| 695 |
+
@auto_docstring
|
| 696 |
+
class IQuestCoderForCausalLM(IQuestCoderPreTrainedModel, GenerationMixin):
|
| 697 |
+
"""IQuestCoder Model with a language modeling head on top for causal LM."""
|
| 698 |
+
|
| 699 |
+
_tied_weights_keys = ["lm_head.weight"]
|
| 700 |
+
_tp_plan = {"lm_head": "colwise_rep"}
|
| 701 |
+
_pp_plan = {"lm_head": (["hidden_states"], ["logits"])}
|
| 702 |
+
|
| 703 |
+
def __init__(self, config: IQuestCoderConfig):
|
| 704 |
+
super().__init__(config)
|
| 705 |
+
self.model = IQuestCoderModel(config)
|
| 706 |
+
self.vocab_size = config.vocab_size
|
| 707 |
+
self.lm_head = nn.Linear(config.hidden_size, config.vocab_size, bias=False)
|
| 708 |
+
|
| 709 |
+
# Initialize weights and apply final processing
|
| 710 |
+
self.post_init()
|
| 711 |
+
|
| 712 |
+
def get_input_embeddings(self) -> nn.Embedding:
|
| 713 |
+
return self.model.embed_tokens
|
| 714 |
+
|
| 715 |
+
def set_input_embeddings(self, value: nn.Embedding):
|
| 716 |
+
self.model.embed_tokens = value
|
| 717 |
+
|
| 718 |
+
def get_output_embeddings(self) -> nn.Linear:
|
| 719 |
+
return self.lm_head
|
| 720 |
+
|
| 721 |
+
def set_output_embeddings(self, new_embeddings: nn.Linear):
|
| 722 |
+
self.lm_head = new_embeddings
|
| 723 |
+
|
| 724 |
+
def set_decoder(self, decoder: IQuestCoderModel):
|
| 725 |
+
self.model = decoder
|
| 726 |
+
|
| 727 |
+
def get_decoder(self) -> IQuestCoderModel:
|
| 728 |
+
return self.model
|
| 729 |
+
|
| 730 |
+
@can_return_tuple
|
| 731 |
+
@auto_docstring
|
| 732 |
+
def forward(
|
| 733 |
+
self,
|
| 734 |
+
input_ids: Optional[torch.LongTensor] = None,
|
| 735 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 736 |
+
position_ids: Optional[torch.LongTensor] = None,
|
| 737 |
+
past_key_values: Optional[Cache] = None,
|
| 738 |
+
inputs_embeds: Optional[torch.FloatTensor] = None,
|
| 739 |
+
labels: Optional[torch.LongTensor] = None,
|
| 740 |
+
use_cache: Optional[bool] = None,
|
| 741 |
+
output_attentions: Optional[bool] = None,
|
| 742 |
+
output_hidden_states: Optional[bool] = None,
|
| 743 |
+
cache_position: Optional[torch.LongTensor] = None,
|
| 744 |
+
logits_to_keep: Union[int, torch.Tensor] = 0,
|
| 745 |
+
**kwargs: Unpack[KwargsForCausalLM],
|
| 746 |
+
) -> CausalLMOutputWithPast:
|
| 747 |
+
r"""
|
| 748 |
+
Args:
|
| 749 |
+
labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
|
| 750 |
+
Labels for computing the masked language modeling loss. Indices should either be in `[0, ...,
|
| 751 |
+
config.vocab_size]` or -100 (see `input_ids` docstring). Tokens with indices set to `-100` are ignored
|
| 752 |
+
(masked), the loss is only computed for the tokens with labels in `[0, ..., config.vocab_size]`.
|
| 753 |
+
|
| 754 |
+
Example:
|
| 755 |
+
```python
|
| 756 |
+
>>> from transformers import AutoTokenizer
|
| 757 |
+
>>> from modeling_iquestcoder import IQuestCoderForCausalLM
|
| 758 |
+
|
| 759 |
+
>>> model = IQuestCoderForCausalLM.from_pretrained("path/to/IQuestCoder")
|
| 760 |
+
>>> tokenizer = AutoTokenizer.from_pretrained("path/to/IQuestCoder")
|
| 761 |
+
|
| 762 |
+
>>> prompt = "Hey, are you conscious? Can you talk to me?"
|
| 763 |
+
>>> inputs = tokenizer(prompt, return_tensors="pt")
|
| 764 |
+
|
| 765 |
+
>>> # Generate
|
| 766 |
+
>>> generate_ids = model.generate(inputs.input_ids, max_length=30)
|
| 767 |
+
>>> tokenizer.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]
|
| 768 |
+
"Hey, are you conscious? Can you talk to me?\\nI'm not conscious, but I can talk to you."
|
| 769 |
+
```
|
| 770 |
+
"""
|
| 771 |
+
output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
|
| 772 |
+
output_hidden_states = (
|
| 773 |
+
output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
|
| 774 |
+
)
|
| 775 |
+
|
| 776 |
+
# Decoder outputs consists of (dec_features, layer_state, dec_hidden, dec_attn)
|
| 777 |
+
outputs: BaseModelOutputWithPast = self.model(
|
| 778 |
+
input_ids=input_ids,
|
| 779 |
+
attention_mask=attention_mask,
|
| 780 |
+
position_ids=position_ids,
|
| 781 |
+
past_key_values=past_key_values,
|
| 782 |
+
inputs_embeds=inputs_embeds,
|
| 783 |
+
use_cache=use_cache,
|
| 784 |
+
output_attentions=output_attentions,
|
| 785 |
+
output_hidden_states=output_hidden_states,
|
| 786 |
+
cache_position=cache_position,
|
| 787 |
+
**kwargs,
|
| 788 |
+
)
|
| 789 |
+
|
| 790 |
+
hidden_states = outputs.last_hidden_state
|
| 791 |
+
# Only compute necessary logits, and do not upcast them to float if we are not computing the loss
|
| 792 |
+
slice_indices = slice(-logits_to_keep, None) if isinstance(logits_to_keep, int) else logits_to_keep
|
| 793 |
+
logits = self.lm_head(hidden_states[:, slice_indices, :])
|
| 794 |
+
|
| 795 |
+
loss = None
|
| 796 |
+
if labels is not None:
|
| 797 |
+
loss = self.loss_function(logits=logits, labels=labels, vocab_size=self.config.vocab_size, **kwargs)
|
| 798 |
+
|
| 799 |
+
return CausalLMOutputWithPast(
|
| 800 |
+
loss=loss,
|
| 801 |
+
logits=logits,
|
| 802 |
+
past_key_values=outputs.past_key_values,
|
| 803 |
+
hidden_states=outputs.hidden_states,
|
| 804 |
+
attentions=outputs.attentions,
|
| 805 |
+
)
|
| 806 |
+
|
| 807 |
+
|
| 808 |
+
@auto_docstring(
|
| 809 |
+
custom_intro="""
|
| 810 |
+
The IQuestCoder Model transformer with a sequence classification head on top (linear layer).
|
| 811 |
+
|
| 812 |
+
[`IQuestCoderForSequenceClassification`] uses the last token in order to do the classification, as other causal
|
| 813 |
+
models (e.g. GPT-2) do.
|
| 814 |
+
|
| 815 |
+
Since it does classification on the last token, it requires to know the position of the last token. If a
|
| 816 |
+
`pad_token_id` is defined in the configuration, it finds the last token that is not a padding token in each row.
|
| 817 |
+
If no `pad_token_id` is defined, it simply takes the last value in each row of the batch.
|
| 818 |
+
"""
|
| 819 |
+
)
|
| 820 |
+
class IQuestCoderForSequenceClassification(IQuestCoderPreTrainedModel):
|
| 821 |
+
"""IQuestCoder Model with a sequence classification head."""
|
| 822 |
+
|
| 823 |
+
def __init__(self, config: IQuestCoderConfig):
|
| 824 |
+
super().__init__(config)
|
| 825 |
+
self.num_labels = config.num_labels
|
| 826 |
+
self.model = IQuestCoderModel(config)
|
| 827 |
+
self.score = nn.Linear(config.hidden_size, self.num_labels, bias=False)
|
| 828 |
+
|
| 829 |
+
# Initialize weights and apply final processing
|
| 830 |
+
self.post_init()
|
| 831 |
+
|
| 832 |
+
def get_input_embeddings(self) -> nn.Embedding:
|
| 833 |
+
return self.model.embed_tokens
|
| 834 |
+
|
| 835 |
+
def set_input_embeddings(self, value: nn.Embedding):
|
| 836 |
+
self.model.embed_tokens = value
|
| 837 |
+
|
| 838 |
+
@can_return_tuple
|
| 839 |
+
@auto_docstring
|
| 840 |
+
def forward(
|
| 841 |
+
self,
|
| 842 |
+
input_ids: Optional[torch.LongTensor] = None,
|
| 843 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 844 |
+
position_ids: Optional[torch.LongTensor] = None,
|
| 845 |
+
past_key_values: Optional[Cache] = None,
|
| 846 |
+
inputs_embeds: Optional[torch.FloatTensor] = None,
|
| 847 |
+
labels: Optional[torch.LongTensor] = None,
|
| 848 |
+
use_cache: Optional[bool] = None,
|
| 849 |
+
output_attentions: Optional[bool] = None,
|
| 850 |
+
output_hidden_states: Optional[bool] = None,
|
| 851 |
+
) -> SequenceClassifierOutputWithPast:
|
| 852 |
+
r"""
|
| 853 |
+
labels (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
|
| 854 |
+
Labels for computing the sequence classification/regression loss. Indices should be in `[0, ...,
|
| 855 |
+
config.num_labels - 1]`. If `config.num_labels == 1` a regression loss is computed (Mean-Square loss),
|
| 856 |
+
If `config.num_labels > 1` a classification loss is computed (Cross-Entropy).
|
| 857 |
+
"""
|
| 858 |
+
transformer_outputs: BaseModelOutputWithPast = self.model(
|
| 859 |
+
input_ids,
|
| 860 |
+
attention_mask=attention_mask,
|
| 861 |
+
position_ids=position_ids,
|
| 862 |
+
past_key_values=past_key_values,
|
| 863 |
+
inputs_embeds=inputs_embeds,
|
| 864 |
+
use_cache=use_cache,
|
| 865 |
+
output_attentions=output_attentions,
|
| 866 |
+
output_hidden_states=output_hidden_states,
|
| 867 |
+
)
|
| 868 |
+
hidden_states = transformer_outputs.last_hidden_state
|
| 869 |
+
logits = self.score(hidden_states)
|
| 870 |
+
|
| 871 |
+
if input_ids is not None:
|
| 872 |
+
batch_size = input_ids.shape[0]
|
| 873 |
+
else:
|
| 874 |
+
batch_size = inputs_embeds.shape[0]
|
| 875 |
+
|
| 876 |
+
if self.config.pad_token_id is None and batch_size != 1:
|
| 877 |
+
raise ValueError("Cannot handle batch sizes > 1 if no padding token is defined.")
|
| 878 |
+
if self.config.pad_token_id is None:
|
| 879 |
+
last_non_pad_token = -1
|
| 880 |
+
elif input_ids is not None:
|
| 881 |
+
non_pad_mask = (input_ids != self.config.pad_token_id).to(logits.device, torch.int32)
|
| 882 |
+
token_indices = torch.arange(input_ids.shape[-1], device=logits.device, dtype=torch.int32)
|
| 883 |
+
last_non_pad_token = (token_indices * non_pad_mask).argmax(-1)
|
| 884 |
+
else:
|
| 885 |
+
last_non_pad_token = -1
|
| 886 |
+
logger.warning_once(
|
| 887 |
+
f"{self.__class__.__name__} will not detect padding tokens in `inputs_embeds`. Results may be "
|
| 888 |
+
"unexpected if using padding tokens in conjunction with `inputs_embeds.`"
|
| 889 |
+
)
|
| 890 |
+
|
| 891 |
+
pooled_logits = logits[torch.arange(batch_size, device=logits.device), last_non_pad_token]
|
| 892 |
+
|
| 893 |
+
loss = None
|
| 894 |
+
if labels is not None:
|
| 895 |
+
loss = self.loss_function(logits=logits, labels=labels, pooled_logits=pooled_logits, config=self.config)
|
| 896 |
+
|
| 897 |
+
return SequenceClassifierOutputWithPast(
|
| 898 |
+
loss=loss,
|
| 899 |
+
logits=pooled_logits,
|
| 900 |
+
past_key_values=transformer_outputs.past_key_values,
|
| 901 |
+
hidden_states=transformer_outputs.hidden_states,
|
| 902 |
+
attentions=transformer_outputs.attentions,
|
| 903 |
+
)
|
| 904 |
+
|
| 905 |
+
|
| 906 |
+
@auto_docstring
|
| 907 |
+
class IQuestCoderForTokenClassification(IQuestCoderPreTrainedModel):
|
| 908 |
+
"""IQuestCoder Model with a token classification head."""
|
| 909 |
+
|
| 910 |
+
def __init__(self, config: IQuestCoderConfig):
|
| 911 |
+
super().__init__(config)
|
| 912 |
+
self.num_labels = config.num_labels
|
| 913 |
+
self.model = IQuestCoderModel(config)
|
| 914 |
+
if getattr(config, "classifier_dropout", None) is not None:
|
| 915 |
+
classifier_dropout = config.classifier_dropout
|
| 916 |
+
elif getattr(config, "hidden_dropout", None) is not None:
|
| 917 |
+
classifier_dropout = config.hidden_dropout
|
| 918 |
+
else:
|
| 919 |
+
classifier_dropout = 0.1
|
| 920 |
+
self.dropout = nn.Dropout(classifier_dropout)
|
| 921 |
+
self.score = nn.Linear(config.hidden_size, config.num_labels)
|
| 922 |
+
|
| 923 |
+
# Initialize weights and apply final processing
|
| 924 |
+
self.post_init()
|
| 925 |
+
|
| 926 |
+
def get_input_embeddings(self) -> nn.Embedding:
|
| 927 |
+
return self.model.embed_tokens
|
| 928 |
+
|
| 929 |
+
def set_input_embeddings(self, value: nn.Embedding):
|
| 930 |
+
self.model.embed_tokens = value
|
| 931 |
+
|
| 932 |
+
@can_return_tuple
|
| 933 |
+
@auto_docstring
|
| 934 |
+
def forward(
|
| 935 |
+
self,
|
| 936 |
+
input_ids: Optional[torch.LongTensor] = None,
|
| 937 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 938 |
+
position_ids: Optional[torch.LongTensor] = None,
|
| 939 |
+
past_key_values: Optional[Cache] = None,
|
| 940 |
+
inputs_embeds: Optional[torch.FloatTensor] = None,
|
| 941 |
+
labels: Optional[torch.LongTensor] = None,
|
| 942 |
+
use_cache: Optional[bool] = None,
|
| 943 |
+
output_attentions: Optional[bool] = None,
|
| 944 |
+
output_hidden_states: Optional[bool] = None,
|
| 945 |
+
) -> TokenClassifierOutput:
|
| 946 |
+
r"""
|
| 947 |
+
labels (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
|
| 948 |
+
Labels for computing the sequence classification/regression loss. Indices should be in `[0, ...,
|
| 949 |
+
config.num_labels - 1]`. If `config.num_labels == 1` a regression loss is computed (Mean-Square loss),
|
| 950 |
+
If `config.num_labels > 1` a classification loss is computed (Cross-Entropy).
|
| 951 |
+
"""
|
| 952 |
+
outputs: BaseModelOutputWithPast = self.model(
|
| 953 |
+
input_ids,
|
| 954 |
+
attention_mask=attention_mask,
|
| 955 |
+
position_ids=position_ids,
|
| 956 |
+
past_key_values=past_key_values,
|
| 957 |
+
inputs_embeds=inputs_embeds,
|
| 958 |
+
use_cache=use_cache,
|
| 959 |
+
output_attentions=output_attentions,
|
| 960 |
+
output_hidden_states=output_hidden_states,
|
| 961 |
+
)
|
| 962 |
+
sequence_output = outputs.last_hidden_state
|
| 963 |
+
sequence_output = self.dropout(sequence_output)
|
| 964 |
+
logits = self.score(sequence_output)
|
| 965 |
+
|
| 966 |
+
loss = None
|
| 967 |
+
if labels is not None:
|
| 968 |
+
loss = self.loss_function(logits, labels, self.config)
|
| 969 |
+
|
| 970 |
+
return TokenClassifierOutput(
|
| 971 |
+
loss=loss,
|
| 972 |
+
logits=logits,
|
| 973 |
+
hidden_states=outputs.hidden_states,
|
| 974 |
+
attentions=outputs.attentions,
|
| 975 |
+
)
|
| 976 |
+
|
| 977 |
+
|
| 978 |
+
@auto_docstring
|
| 979 |
+
class IQuestCoderForQuestionAnswering(IQuestCoderPreTrainedModel):
|
| 980 |
+
"""IQuestCoder Model with a span classification head for extractive question-answering."""
|
| 981 |
+
|
| 982 |
+
base_model_prefix = "transformer"
|
| 983 |
+
|
| 984 |
+
def __init__(self, config: IQuestCoderConfig):
|
| 985 |
+
super().__init__(config)
|
| 986 |
+
self.transformer = IQuestCoderModel(config)
|
| 987 |
+
self.qa_outputs = nn.Linear(config.hidden_size, 2)
|
| 988 |
+
|
| 989 |
+
# Initialize weights and apply final processing
|
| 990 |
+
self.post_init()
|
| 991 |
+
|
| 992 |
+
def get_input_embeddings(self) -> nn.Embedding:
|
| 993 |
+
return self.transformer.embed_tokens
|
| 994 |
+
|
| 995 |
+
def set_input_embeddings(self, value: nn.Embedding):
|
| 996 |
+
self.transformer.embed_tokens = value
|
| 997 |
+
|
| 998 |
+
@can_return_tuple
|
| 999 |
+
@auto_docstring
|
| 1000 |
+
def forward(
|
| 1001 |
+
self,
|
| 1002 |
+
input_ids: Optional[torch.LongTensor] = None,
|
| 1003 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 1004 |
+
position_ids: Optional[torch.LongTensor] = None,
|
| 1005 |
+
past_key_values: Optional[Cache] = None,
|
| 1006 |
+
inputs_embeds: Optional[torch.FloatTensor] = None,
|
| 1007 |
+
start_positions: Optional[torch.LongTensor] = None,
|
| 1008 |
+
end_positions: Optional[torch.LongTensor] = None,
|
| 1009 |
+
output_attentions: Optional[bool] = None,
|
| 1010 |
+
output_hidden_states: Optional[bool] = None,
|
| 1011 |
+
**kwargs,
|
| 1012 |
+
) -> QuestionAnsweringModelOutput:
|
| 1013 |
+
outputs: BaseModelOutputWithPast = self.transformer(
|
| 1014 |
+
input_ids,
|
| 1015 |
+
attention_mask=attention_mask,
|
| 1016 |
+
position_ids=position_ids,
|
| 1017 |
+
past_key_values=past_key_values,
|
| 1018 |
+
inputs_embeds=inputs_embeds,
|
| 1019 |
+
output_attentions=output_attentions,
|
| 1020 |
+
output_hidden_states=output_hidden_states,
|
| 1021 |
+
)
|
| 1022 |
+
|
| 1023 |
+
sequence_output = outputs.last_hidden_state
|
| 1024 |
+
|
| 1025 |
+
logits = self.qa_outputs(sequence_output)
|
| 1026 |
+
start_logits, end_logits = logits.split(1, dim=-1)
|
| 1027 |
+
start_logits = start_logits.squeeze(-1).contiguous()
|
| 1028 |
+
end_logits = end_logits.squeeze(-1).contiguous()
|
| 1029 |
+
|
| 1030 |
+
loss = None
|
| 1031 |
+
if start_positions is not None and end_positions is not None:
|
| 1032 |
+
loss = self.loss_function(start_logits, end_logits, start_positions, end_positions, **kwargs)
|
| 1033 |
+
|
| 1034 |
+
return QuestionAnsweringModelOutput(
|
| 1035 |
+
loss=loss,
|
| 1036 |
+
start_logits=start_logits,
|
| 1037 |
+
end_logits=end_logits,
|
| 1038 |
+
hidden_states=outputs.hidden_states,
|
| 1039 |
+
attentions=outputs.attentions,
|
| 1040 |
+
)
|
| 1041 |
+
|
| 1042 |
+
|
| 1043 |
+
__all__ = [
|
| 1044 |
+
"IQuestCoderPreTrainedModel",
|
| 1045 |
+
"IQuestCoderModel",
|
| 1046 |
+
"IQuestCoderForCausalLM",
|
| 1047 |
+
"IQuestCoderForSequenceClass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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Tokenization classes for IQuestCoder."""
|
| 2 |
+
|
| 3 |
+
import os
|
| 4 |
+
from shutil import copyfile
|
| 5 |
+
from typing import Any, Dict, List, Optional, Tuple, Union
|
| 6 |
+
|
| 7 |
+
import sentencepiece as spm
|
| 8 |
+
|
| 9 |
+
from transformers.tokenization_utils import AddedToken, PreTrainedTokenizer
|
| 10 |
+
from transformers.utils import logging
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
logger = logging.get_logger(__name__)
|
| 14 |
+
|
| 15 |
+
VOCAB_FILES_NAMES = {"vocab_file": "tokenizer.model"}
|
| 16 |
+
|
| 17 |
+
PRETRAINED_VOCAB_FILES_MAP = {
|
| 18 |
+
"vocab_file": {},
|
| 19 |
+
"tokenizer_file": {},
|
| 20 |
+
}
|
| 21 |
+
PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES = {}
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
class IQuestCoderTokenizer(PreTrainedTokenizer):
|
| 26 |
+
|
| 27 |
+
vocab_files_names = VOCAB_FILES_NAMES
|
| 28 |
+
pretrained_vocab_files_map = PRETRAINED_VOCAB_FILES_MAP
|
| 29 |
+
max_model_input_sizes = PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
|
| 30 |
+
model_input_names = ["input_ids", "attention_mask"]
|
| 31 |
+
|
| 32 |
+
def __init__(
|
| 33 |
+
self,
|
| 34 |
+
vocab_file,
|
| 35 |
+
unk_token="<unk>",
|
| 36 |
+
bos_token="<s>",
|
| 37 |
+
eos_token="</s>",
|
| 38 |
+
pad_token=None,
|
| 39 |
+
sp_model_kwargs: Optional[Dict[str, Any]] = None,
|
| 40 |
+
add_bos_token=True,
|
| 41 |
+
add_eos_token=False,
|
| 42 |
+
clean_up_tokenization_spaces=False,
|
| 43 |
+
add_prefix_space=False,
|
| 44 |
+
legacy=None,
|
| 45 |
+
use_default_system_prompt=False,
|
| 46 |
+
chat_template=None,
|
| 47 |
+
**kwargs,
|
| 48 |
+
):
|
| 49 |
+
self.sp_model_kwargs = {} if sp_model_kwargs is None else sp_model_kwargs
|
| 50 |
+
bos_token = AddedToken(bos_token, lstrip=False, rstrip=False) if isinstance(bos_token, str) else bos_token
|
| 51 |
+
eos_token = AddedToken(eos_token, lstrip=False, rstrip=False) if isinstance(eos_token, str) else eos_token
|
| 52 |
+
unk_token = AddedToken(unk_token, lstrip=False, rstrip=False) if isinstance(unk_token, str) else unk_token
|
| 53 |
+
pad_token = AddedToken(pad_token, lstrip=False, rstrip=False) if isinstance(pad_token, str) else pad_token
|
| 54 |
+
|
| 55 |
+
# Legacy behavior handling
|
| 56 |
+
if legacy is None:
|
| 57 |
+
logger.warning_once(
|
| 58 |
+
f"You are using the default legacy behaviour of the {self.__class__.__name__}. This is"
|
| 59 |
+
" expected, and simply means that the `legacy` (previous) behavior will be used so nothing changes for you."
|
| 60 |
+
" If you want to use the new behaviour, set `legacy=False`. This should only be set if you understand what it"
|
| 61 |
+
" means, and thoroughly read the reason why this was added as explained in"
|
| 62 |
+
" https://github.com/huggingface/transformers/pull/24565"
|
| 63 |
+
)
|
| 64 |
+
legacy = True
|
| 65 |
+
|
| 66 |
+
self.legacy = legacy
|
| 67 |
+
self.vocab_file = vocab_file
|
| 68 |
+
self.add_bos_token = add_bos_token
|
| 69 |
+
self.add_eos_token = add_eos_token
|
| 70 |
+
self.add_prefix_space = add_prefix_space
|
| 71 |
+
self.use_default_system_prompt = use_default_system_prompt
|
| 72 |
+
self.sp_model = spm.SentencePieceProcessor(**self.sp_model_kwargs)
|
| 73 |
+
self.sp_model.Load(vocab_file)
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
super().__init__(
|
| 78 |
+
bos_token=bos_token,
|
| 79 |
+
eos_token=eos_token,
|
| 80 |
+
unk_token=unk_token,
|
| 81 |
+
pad_token=pad_token,
|
| 82 |
+
add_bos_token=add_bos_token,
|
| 83 |
+
add_eos_token=add_eos_token,
|
| 84 |
+
sp_model_kwargs=self.sp_model_kwargs,
|
| 85 |
+
clean_up_tokenization_spaces=clean_up_tokenization_spaces,
|
| 86 |
+
add_prefix_space=add_prefix_space,
|
| 87 |
+
legacy=legacy,
|
| 88 |
+
use_default_system_prompt=use_default_system_prompt,
|
| 89 |
+
chat_template=chat_template,
|
| 90 |
+
**kwargs,
|
| 91 |
+
)
|
| 92 |
+
|
| 93 |
+
def __getstate__(self):
|
| 94 |
+
state = self.__dict__.copy()
|
| 95 |
+
state["sp_model"] = None
|
| 96 |
+
return state
|
| 97 |
+
|
| 98 |
+
def __setstate__(self, d):
|
| 99 |
+
self.__dict__ = d
|
| 100 |
+
self.sp_model = spm.SentencePieceProcessor(**self.sp_model_kwargs)
|
| 101 |
+
self.sp_model.Load(self.vocab_file)
|
| 102 |
+
|
| 103 |
+
@property
|
| 104 |
+
def vocab_size(self) -> int:
|
| 105 |
+
"""Returns the vocabulary size."""
|
| 106 |
+
return self.sp_model.get_piece_size()
|
| 107 |
+
|
| 108 |
+
def get_vocab(self) -> Dict[str, int]:
|
| 109 |
+
"""Returns the vocabulary as a dictionary of token to index."""
|
| 110 |
+
vocab = {self.convert_ids_to_tokens(i): i for i in range(self.vocab_size)}
|
| 111 |
+
vocab.update(self.added_tokens_encoder)
|
| 112 |
+
return vocab
|
| 113 |
+
|
| 114 |
+
def _tokenize(self, text: str) -> List[str]:
|
| 115 |
+
"""
|
| 116 |
+
Tokenize a string.
|
| 117 |
+
|
| 118 |
+
Args:
|
| 119 |
+
text (`str`): The text to tokenize.
|
| 120 |
+
|
| 121 |
+
Returns:
|
| 122 |
+
`List[str]`: The list of tokens.
|
| 123 |
+
"""
|
| 124 |
+
if self.add_prefix_space:
|
| 125 |
+
text = " " + text
|
| 126 |
+
|
| 127 |
+
if self.legacy:
|
| 128 |
+
return self.sp_model.encode(text, out_type=str)
|
| 129 |
+
|
| 130 |
+
# Non-legacy behavior: handle special tokens properly
|
| 131 |
+
return self.sp_model.encode(text, out_type=str)
|
| 132 |
+
|
| 133 |
+
def _convert_token_to_id(self, token: str) -> int:
|
| 134 |
+
"""Converts a token (str) to an id using the vocab."""
|
| 135 |
+
return self.sp_model.piece_to_id(token)
|
| 136 |
+
|
| 137 |
+
def _convert_id_to_token(self, index: int) -> str:
|
| 138 |
+
"""Converts an index (integer) to a token (str) using the vocab."""
|
| 139 |
+
token = self.sp_model.IdToPiece(index)
|
| 140 |
+
return token
|
| 141 |
+
|
| 142 |
+
def convert_tokens_to_string(self, tokens: List[str]) -> str:
|
| 143 |
+
"""
|
| 144 |
+
Converts a sequence of tokens (strings) to a single string.
|
| 145 |
+
|
| 146 |
+
This method handles special tokens separately to ensure they are not
|
| 147 |
+
decoded using the SentencePiece model.
|
| 148 |
+
|
| 149 |
+
Args:
|
| 150 |
+
tokens (`List[str]`): The list of tokens to convert.
|
| 151 |
+
|
| 152 |
+
Returns:
|
| 153 |
+
`str`: The decoded string.
|
| 154 |
+
"""
|
| 155 |
+
current_sub_tokens = []
|
| 156 |
+
out_string = ""
|
| 157 |
+
prev_is_special = False
|
| 158 |
+
for i, token in enumerate(tokens):
|
| 159 |
+
# make sure that special tokens are not decoded using sentencepiece model
|
| 160 |
+
if token in self.all_special_tokens:
|
| 161 |
+
if not prev_is_special and i != 0:
|
| 162 |
+
out_string += " "
|
| 163 |
+
out_string += self.sp_model.decode(current_sub_tokens) + token
|
| 164 |
+
prev_is_special = True
|
| 165 |
+
current_sub_tokens = []
|
| 166 |
+
else:
|
| 167 |
+
current_sub_tokens.append(token)
|
| 168 |
+
prev_is_special = False
|
| 169 |
+
out_string += self.sp_model.decode(current_sub_tokens)
|
| 170 |
+
return out_string
|
| 171 |
+
|
| 172 |
+
def save_vocabulary(self, save_directory: str, filename_prefix: Optional[str] = None) -> Tuple[str]:
|
| 173 |
+
"""
|
| 174 |
+
Save the vocabulary and special tokens file to a directory.
|
| 175 |
+
|
| 176 |
+
Args:
|
| 177 |
+
save_directory (`str`):
|
| 178 |
+
The directory in which to save the vocabulary.
|
| 179 |
+
filename_prefix (`str`, *optional*):
|
| 180 |
+
An optional prefix to add to the named of the saved files.
|
| 181 |
+
|
| 182 |
+
Returns:
|
| 183 |
+
`Tuple(str)`: Paths to the files saved.
|
| 184 |
+
"""
|
| 185 |
+
if not os.path.isdir(save_directory):
|
| 186 |
+
logger.error(f"Vocabulary path ({save_directory}) should be a directory")
|
| 187 |
+
return
|
| 188 |
+
out_vocab_file = os.path.join(
|
| 189 |
+
save_directory, (filename_prefix + "-" if filename_prefix else "") + VOCAB_FILES_NAMES["vocab_file"]
|
| 190 |
+
)
|
| 191 |
+
|
| 192 |
+
if os.path.abspath(self.vocab_file) != os.path.abspath(out_vocab_file) and os.path.isfile(self.vocab_file):
|
| 193 |
+
copyfile(self.vocab_file, out_vocab_file)
|
| 194 |
+
elif not os.path.isfile(self.vocab_file):
|
| 195 |
+
with open(out_vocab_file, "wb") as fi:
|
| 196 |
+
content_spiece_model = self.sp_model.serialized_model_proto()
|
| 197 |
+
fi.write(content_spiece_model)
|
| 198 |
+
|
| 199 |
+
return (out_vocab_file,)
|
| 200 |
+
|
| 201 |
+
def build_inputs_with_special_tokens(
|
| 202 |
+
self,
|
| 203 |
+
token_ids_0: List[int],
|
| 204 |
+
token_ids_1: Optional[List[int]] = None
|
| 205 |
+
) -> List[int]:
|
| 206 |
+
"""
|
| 207 |
+
Build model inputs from a sequence or a pair of sequences for sequence classification tasks by concatenating
|
| 208 |
+
and adding special tokens.
|
| 209 |
+
|
| 210 |
+
An IQuestCoder sequence has the following format:
|
| 211 |
+
|
| 212 |
+
- single sequence: `<s> X </s>` (if add_eos_token is True) or `<s> X` (default)
|
| 213 |
+
- pair of sequences: `<s> A </s> <s> B </s>` (if add_eos_token is True) or `<s> A <s> B` (default)
|
| 214 |
+
|
| 215 |
+
Args:
|
| 216 |
+
token_ids_0 (`List[int]`):
|
| 217 |
+
List of IDs to which the special tokens will be added.
|
| 218 |
+
token_ids_1 (`List[int]`, *optional*):
|
| 219 |
+
Optional second list of IDs for sequence pairs.
|
| 220 |
+
|
| 221 |
+
Returns:
|
| 222 |
+
`List[int]`: List of input IDs with the appropriate special tokens.
|
| 223 |
+
"""
|
| 224 |
+
bos_token_id = [self.bos_token_id] if self.add_bos_token else []
|
| 225 |
+
eos_token_id = [self.eos_token_id] if self.add_eos_token else []
|
| 226 |
+
|
| 227 |
+
output = bos_token_id + token_ids_0 + eos_token_id
|
| 228 |
+
|
| 229 |
+
if token_ids_1 is not None:
|
| 230 |
+
output = output + bos_token_id + token_ids_1 + eos_token_id
|
| 231 |
+
|
| 232 |
+
return output
|
| 233 |
+
|
| 234 |
+
def get_special_tokens_mask(
|
| 235 |
+
self,
|
| 236 |
+
token_ids_0: List[int],
|
| 237 |
+
token_ids_1: Optional[List[int]] = None,
|
| 238 |
+
already_has_special_tokens: bool = False
|
| 239 |
+
) -> List[int]:
|
| 240 |
+
"""
|
| 241 |
+
Retrieve sequence ids from a token list that has no special tokens added. This method is called when adding
|
| 242 |
+
special tokens using the tokenizer `prepare_for_model` method.
|
| 243 |
+
|
| 244 |
+
Args:
|
| 245 |
+
token_ids_0 (`List[int]`):
|
| 246 |
+
List of IDs.
|
| 247 |
+
token_ids_1 (`List[int]`, *optional*):
|
| 248 |
+
Optional second list of IDs for sequence pairs.
|
| 249 |
+
already_has_special_tokens (`bool`, *optional*, defaults to `False`):
|
| 250 |
+
Whether or not the token list is already formatted with special tokens for the model.
|
| 251 |
+
|
| 252 |
+
Returns:
|
| 253 |
+
`List[int]`: A list of integers in the range [0, 1]: 1 for a special token, 0 for a sequence token.
|
| 254 |
+
"""
|
| 255 |
+
if already_has_special_tokens:
|
| 256 |
+
return super().get_special_tokens_mask(
|
| 257 |
+
token_ids_0=token_ids_0, token_ids_1=token_ids_1, already_has_special_tokens=True
|
| 258 |
+
)
|
| 259 |
+
|
| 260 |
+
bos_token_id = [1] if self.add_bos_token else []
|
| 261 |
+
eos_token_id = [1] if self.add_eos_token else []
|
| 262 |
+
|
| 263 |
+
if token_ids_1 is None:
|
| 264 |
+
return bos_token_id + ([0] * len(token_ids_0)) + eos_token_id
|
| 265 |
+
return (
|
| 266 |
+
bos_token_id
|
| 267 |
+
+ ([0] * len(token_ids_0))
|
| 268 |
+
+ eos_token_id
|
| 269 |
+
+ bos_token_id
|
| 270 |
+
+ ([0] * len(token_ids_1))
|
| 271 |
+
+ eos_token_id
|
| 272 |
+
)
|
| 273 |
+
|
| 274 |
+
def create_token_type_ids_from_sequences(
|
| 275 |
+
self,
|
| 276 |
+
token_ids_0: List[int],
|
| 277 |
+
token_ids_1: Optional[List[int]] = None
|
| 278 |
+
) -> List[int]:
|
| 279 |
+
"""
|
| 280 |
+
Create a mask from the two sequences passed to be used in a sequence-pair classification task.
|
| 281 |
+
|
| 282 |
+
An IQuestCoder sequence pair mask has the following format:
|
| 283 |
+
|
| 284 |
+
```
|
| 285 |
+
0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1
|
| 286 |
+
| first sequence | second sequence |
|
| 287 |
+
```
|
| 288 |
+
|
| 289 |
+
If `token_ids_1` is `None`, this method only returns the first portion of the mask (0s).
|
| 290 |
+
|
| 291 |
+
Args:
|
| 292 |
+
token_ids_0 (`List[int]`):
|
| 293 |
+
List of IDs.
|
| 294 |
+
token_ids_1 (`List[int]`, *optional*):
|
| 295 |
+
Optional second list of IDs for sequence pairs.
|
| 296 |
+
|
| 297 |
+
Returns:
|
| 298 |
+
`List[int]`: List of token type IDs according to the given sequence(s).
|
| 299 |
+
"""
|
| 300 |
+
bos_token_id = [self.bos_token_id] if self.add_bos_token else []
|
| 301 |
+
eos_token_id = [self.eos_token_id] if self.add_eos_token else []
|
| 302 |
+
|
| 303 |
+
output = [0] * len(bos_token_id + token_ids_0 + eos_token_id)
|
| 304 |
+
|
| 305 |
+
if token_ids_1 is not None:
|
| 306 |
+
output += [1] * len(bos_token_id + token_ids_1 + eos_token_id)
|
| 307 |
+
|
| 308 |
+
return output
|
| 309 |
+
|
| 310 |
+
@property
|
| 311 |
+
def default_chat_template(self) -> str:
|
| 312 |
+
"""
|
| 313 |
+
Returns the default chat template for IQuestCoder.
|
| 314 |
+
|
| 315 |
+
This template formats conversations with system, user, and assistant roles.
|
| 316 |
+
"""
|
| 317 |
+
return DEFAULT_CHAT_TEMPLATE
|
| 318 |
+
|
| 319 |
+
def apply_chat_template(
|
| 320 |
+
self,
|
| 321 |
+
conversation: Union[List[Dict[str, str]], "Conversation"],
|
| 322 |
+
chat_template: Optional[str] = None,
|
| 323 |
+
add_generation_prompt: bool = False,
|
| 324 |
+
tokenize: bool = True,
|
| 325 |
+
padding: bool = False,
|
| 326 |
+
truncation: bool = False,
|
| 327 |
+
max_length: Optional[int] = None,
|
| 328 |
+
return_tensors: Optional[str] = None,
|
| 329 |
+
return_dict: bool = False,
|
| 330 |
+
**tokenizer_kwargs,
|
| 331 |
+
):
|
| 332 |
+
"""
|
| 333 |
+
Apply a chat template to format a conversation.
|
| 334 |
+
|
| 335 |
+
Args:
|
| 336 |
+
conversation (`List[Dict[str, str]]` or `Conversation`):
|
| 337 |
+
A list of dicts with "role" and "content" keys, representing the conversation history.
|
| 338 |
+
chat_template (`str`, *optional*):
|
| 339 |
+
A Jinja template to use for formatting. If not provided, the tokenizer's default will be used.
|
| 340 |
+
add_generation_prompt (`bool`, *optional*, defaults to `False`):
|
| 341 |
+
Whether to add a generation prompt at the end for the assistant to continue.
|
| 342 |
+
tokenize (`bool`, *optional*, defaults to `True`):
|
| 343 |
+
Whether to tokenize the output. If `False`, returns a string.
|
| 344 |
+
padding (`bool`, *optional*, defaults to `False`):
|
| 345 |
+
Whether to pad sequences.
|
| 346 |
+
truncation (`bool`, *optional*, defaults to `False`):
|
| 347 |
+
Whether to truncate sequences.
|
| 348 |
+
max_length (`int`, *optional*):
|
| 349 |
+
Maximum length of the output.
|
| 350 |
+
return_tensors (`str`, *optional*):
|
| 351 |
+
The type of tensors to return ("pt", "tf", "np", or None).
|
| 352 |
+
return_dict (`bool`, *optional*, defaults to `False`):
|
| 353 |
+
Whether to return a dictionary with additional information.
|
| 354 |
+
**tokenizer_kwargs:
|
| 355 |
+
Additional keyword arguments passed to the tokenizer.
|
| 356 |
+
|
| 357 |
+
Returns:
|
| 358 |
+
`Union[str, List[int], BatchEncoding]`: The formatted (and optionally tokenized) conversation.
|
| 359 |
+
|
| 360 |
+
Example:
|
| 361 |
+
```python
|
| 362 |
+
>>> tokenizer = IQuestCoderTokenizer.from_pretrained("path/to/model")
|
| 363 |
+
>>> conversation = [
|
| 364 |
+
... {"role": "system", "content": "You are a helpful assistant."},
|
| 365 |
+
... {"role": "user", "content": "Hello!"},
|
| 366 |
+
... {"role": "assistant", "content": "Hi there! How can I help you today?"},
|
| 367 |
+
... {"role": "user", "content": "What's the weather like?"},
|
| 368 |
+
... ]
|
| 369 |
+
>>> tokenizer.apply_chat_template(conversation, add_generation_prompt=True, tokenize=False)
|
| 370 |
+
'<|system|>\\nYou are a helpful assistant.\\n</|system|><|user|>\\nHello!\\n</|user|>...'
|
| 371 |
+
```
|
| 372 |
+
"""
|
| 373 |
+
# Use parent class implementation with our template
|
| 374 |
+
return super().apply_chat_template(
|
| 375 |
+
conversation,
|
| 376 |
+
chat_template=chat_template,
|
| 377 |
+
add_generation_prompt=add_generation_prompt,
|
| 378 |
+
tokenize=tokenize,
|
| 379 |
+
padding=padding,
|
| 380 |
+
truncation=truncation,
|
| 381 |
+
max_length=max_length,
|
| 382 |
+
return_tensors=return_tensors,
|
| 383 |
+
return_dict=return_dict,
|
| 384 |
+
**tokenizer_kwargs,
|
| 385 |
+
)
|
| 386 |
+
|
| 387 |
+
|
| 388 |
+
# Try to import and create Fast tokenizer version
|
| 389 |
+
try:
|
| 390 |
+
from transformers import PreTrainedTokenizerFast
|
| 391 |
+
from tokenizers import Tokenizer, decoders, models, normalizers, pre_tokenizers, processors
|
| 392 |
+
|
| 393 |
+
class IQuestCoderTokenizerFast(PreTrainedTokenizerFast):
|
| 394 |
+
"""
|
| 395 |
+
Construct a "fast" IQuestCoder tokenizer (backed by HuggingFace's *tokenizers* library).
|
| 396 |
+
|
| 397 |
+
This is a fast implementation of [`IQuestCoderTokenizer`] using the 🤗 Tokenizers library.
|
| 398 |
+
|
| 399 |
+
Args:
|
| 400 |
+
vocab_file (`str`, *optional*):
|
| 401 |
+
Path to the vocabulary file (SentencePiece model).
|
| 402 |
+
tokenizer_file (`str`, *optional*):
|
| 403 |
+
Path to a tokenizer JSON file.
|
| 404 |
+
unk_token (`str`, *optional*, defaults to `"<unk>"`):
|
| 405 |
+
The unknown token.
|
| 406 |
+
bos_token (`str`, *optional*, defaults to `"<s>"`):
|
| 407 |
+
The beginning of sequence token.
|
| 408 |
+
eos_token (`str`, *optional*, defaults to `"</s>"`):
|
| 409 |
+
The end of sequence token.
|
| 410 |
+
pad_token (`str`, *optional*):
|
| 411 |
+
The token used for padding.
|
| 412 |
+
add_bos_token (`bool`, *optional*, defaults to `True`):
|
| 413 |
+
Whether to add a BOS token at the start of sequences.
|
| 414 |
+
add_eos_token (`bool`, *optional*, defaults to `False`):
|
| 415 |
+
Whether to add an EOS token at the end of sequences.
|
| 416 |
+
add_prefix_space (`bool`, *optional*, defaults to `False`):
|
| 417 |
+
Whether to add an initial space to the input.
|
| 418 |
+
use_default_system_prompt (`bool`, *optional*, defaults to `False`):
|
| 419 |
+
Whether to use the default system prompt.
|
| 420 |
+
chat_template (`str`, *optional*):
|
| 421 |
+
A Jinja template for formatting conversations.
|
| 422 |
+
|
| 423 |
+
Example:
|
| 424 |
+
```python
|
| 425 |
+
>>> from tokenization_iquestcoder import IQuestCoderTokenizerFast
|
| 426 |
+
|
| 427 |
+
>>> tokenizer = IQuestCoderTokenizerFast.from_pretrained("path/to/model")
|
| 428 |
+
>>> tokenizer.encode("Hello, world!")
|
| 429 |
+
[1, 15043, 29892, 3186, 29991]
|
| 430 |
+
```
|
| 431 |
+
"""
|
| 432 |
+
|
| 433 |
+
vocab_files_names = VOCAB_FILES_NAMES
|
| 434 |
+
pretrained_vocab_files_map = PRETRAINED_VOCAB_FILES_MAP
|
| 435 |
+
max_model_input_sizes = PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
|
| 436 |
+
model_input_names = ["input_ids", "attention_mask"]
|
| 437 |
+
slow_tokenizer_class = IQuestCoderTokenizer
|
| 438 |
+
|
| 439 |
+
def __init__(
|
| 440 |
+
self,
|
| 441 |
+
vocab_file=None,
|
| 442 |
+
tokenizer_file=None,
|
| 443 |
+
unk_token="<unk>",
|
| 444 |
+
bos_token="<s>",
|
| 445 |
+
eos_token="</s>",
|
| 446 |
+
pad_token=None,
|
| 447 |
+
add_bos_token=True,
|
| 448 |
+
add_eos_token=False,
|
| 449 |
+
add_prefix_space=False,
|
| 450 |
+
use_default_system_prompt=False,
|
| 451 |
+
chat_template=None,
|
| 452 |
+
**kwargs,
|
| 453 |
+
):
|
| 454 |
+
self.add_bos_token = add_bos_token
|
| 455 |
+
self.add_eos_token = add_eos_token
|
| 456 |
+
self.add_prefix_space = add_prefix_space
|
| 457 |
+
self.use_default_system_prompt = use_default_system_prompt
|
| 458 |
+
|
| 459 |
+
if chat_template is None:
|
| 460 |
+
chat_template = DEFAULT_CHAT_TEMPLATE
|
| 461 |
+
|
| 462 |
+
super().__init__(
|
| 463 |
+
vocab_file=vocab_file,
|
| 464 |
+
tokenizer_file=tokenizer_file,
|
| 465 |
+
unk_token=unk_token,
|
| 466 |
+
bos_token=bos_token,
|
| 467 |
+
eos_token=eos_token,
|
| 468 |
+
pad_token=pad_token,
|
| 469 |
+
add_bos_token=add_bos_token,
|
| 470 |
+
add_eos_token=add_eos_token,
|
| 471 |
+
add_prefix_space=add_prefix_space,
|
| 472 |
+
use_default_system_prompt=use_default_system_prompt,
|
| 473 |
+
chat_template=chat_template,
|
| 474 |
+
**kwargs,
|
| 475 |
+
)
|
| 476 |
+
|
| 477 |
+
@property
|
| 478 |
+
def can_save_slow_tokenizer(self) -> bool:
|
| 479 |
+
return os.path.isfile(self.vocab_file) if self.vocab_file else False
|
| 480 |
+
|
| 481 |
+
@property
|
| 482 |
+
def default_chat_template(self) -> str:
|
| 483 |
+
"""Returns the default chat template."""
|
| 484 |
+
return DEFAULT_CHAT_TEMPLATE
|
| 485 |
+
|
| 486 |
+
def build_inputs_with_special_tokens(
|
| 487 |
+
self,
|
| 488 |
+
token_ids_0: List[int],
|
| 489 |
+
token_ids_1: Optional[List[int]] = None
|
| 490 |
+
) -> List[int]:
|
| 491 |
+
"""Build model inputs with special tokens."""
|
| 492 |
+
bos_token_id = [self.bos_token_id] if self.add_bos_token else []
|
| 493 |
+
eos_token_id = [self.eos_token_id] if self.add_eos_token else []
|
| 494 |
+
|
| 495 |
+
output = bos_token_id + token_ids_0 + eos_token_id
|
| 496 |
+
|
| 497 |
+
if token_ids_1 is not None:
|
| 498 |
+
output = output + bos_token_id + token_ids_1 + eos_token_id
|
| 499 |
+
|
| 500 |
+
return output
|
| 501 |
+
|
| 502 |
+
def get_special_tokens_mask(
|
| 503 |
+
self,
|
| 504 |
+
token_ids_0: List[int],
|
| 505 |
+
token_ids_1: Optional[List[int]] = None,
|
| 506 |
+
already_has_special_tokens: bool = False
|
| 507 |
+
) -> List[int]:
|
| 508 |
+
"""Retrieve special tokens mask."""
|
| 509 |
+
if already_has_special_tokens:
|
| 510 |
+
return super().get_special_tokens_mask(
|
| 511 |
+
token_ids_0=token_ids_0, token_ids_1=token_ids_1, already_has_special_tokens=True
|
| 512 |
+
)
|
| 513 |
+
|
| 514 |
+
bos_token_id = [1] if self.add_bos_token else []
|
| 515 |
+
eos_token_id = [1] if self.add_eos_token else []
|
| 516 |
+
|
| 517 |
+
if token_ids_1 is None:
|
| 518 |
+
return bos_token_id + ([0] * len(token_ids_0)) + eos_token_id
|
| 519 |
+
return (
|
| 520 |
+
bos_token_id
|
| 521 |
+
+ ([0] * len(token_ids_0))
|
| 522 |
+
+ eos_token_id
|
| 523 |
+
+ bos_token_id
|
| 524 |
+
+ ([0] * len(token_ids_1))
|
| 525 |
+
+ eos_token_id
|
| 526 |
+
)
|
| 527 |
+
|
| 528 |
+
def create_token_type_ids_from_sequences(
|
| 529 |
+
self,
|
| 530 |
+
token_ids_0: List[int],
|
| 531 |
+
token_ids_1: Optional[List[int]] = None
|
| 532 |
+
) -> List[int]:
|
| 533 |
+
"""Create token type IDs from sequences."""
|
| 534 |
+
bos_token_id = [self.bos_token_id] if self.add_bos_token else []
|
| 535 |
+
eos_token_id = [self.eos_token_id] if self.add_eos_token else []
|
| 536 |
+
|
| 537 |
+
output = [0] * len(bos_token_id + token_ids_0 + eos_token_id)
|
| 538 |
+
|
| 539 |
+
if token_ids_1 is not None:
|
| 540 |
+
output += [1] * len(bos_token_id + token_ids_1 + eos_token_id)
|
| 541 |
+
|
| 542 |
+
return output
|
| 543 |
+
|
| 544 |
+
except ImportError:
|
| 545 |
+
# tokenizers library not available, Fast tokenizer not supported
|
| 546 |
+
IQuestCoderTokenizerFast = None
|
| 547 |
+
logger.info(
|
| 548 |
+
"The `tokenizers` library is not installed. "
|
| 549 |
+
"IQuestCoderTokenizerFast will not be available. "
|
| 550 |
+
"Install it with `pip install tokenizers`."
|
| 551 |
+
)
|
| 552 |
+
|
tokenizer.model
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_bos_token": false,
|
| 3 |
+
"add_eos_token": false,
|
| 4 |
+
"added_tokens_decoder": {
|
| 5 |
+
"0": {
|
| 6 |
+
"content": "<unk>",
|
| 7 |
+
"lstrip": false,
|
| 8 |
+
"normalized": true,
|
| 9 |
+
"rstrip": false,
|
| 10 |
+
"single_word": true,
|
| 11 |
+
"special": true
|
| 12 |
+
},
|
| 13 |
+
"1": {
|
| 14 |
+
"content": "<s>",
|
| 15 |
+
"lstrip": false,
|
| 16 |
+
"normalized": true,
|
| 17 |
+
"rstrip": false,
|
| 18 |
+
"single_word": false,
|
| 19 |
+
"special": true
|
| 20 |
+
},
|
| 21 |
+
"2": {
|
| 22 |
+
"content": "</s>",
|
| 23 |
+
"lstrip": false,
|
| 24 |
+
"normalized": true,
|
| 25 |
+
"rstrip": false,
|
| 26 |
+
"single_word": true,
|
| 27 |
+
"special": true
|
| 28 |
+
},
|
| 29 |
+
"75858": {
|
| 30 |
+
"content": "<CLS>",
|
| 31 |
+
"lstrip": false,
|
| 32 |
+
"normalized": false,
|
| 33 |
+
"rstrip": false,
|
| 34 |
+
"single_word": false,
|
| 35 |
+
"special": true
|
| 36 |
+
},
|
| 37 |
+
"75859": {
|
| 38 |
+
"content": "<SEP>",
|
| 39 |
+
"lstrip": false,
|
| 40 |
+
"normalized": false,
|
| 41 |
+
"rstrip": false,
|
| 42 |
+
"single_word": false,
|
| 43 |
+
"special": true
|
| 44 |
+
},
|
| 45 |
+
"75860": {
|
| 46 |
+
"content": "<EOD>",
|
| 47 |
+
"lstrip": false,
|
| 48 |
+
"normalized": false,
|
| 49 |
+
"rstrip": false,
|
| 50 |
+
"single_word": false,
|
| 51 |
+
"special": true
|
| 52 |
+
},
|
| 53 |
+
"75861": {
|
| 54 |
+
"content": "<MASK>",
|
| 55 |
+
"lstrip": false,
|
| 56 |
+
"normalized": false,
|
| 57 |
+
"rstrip": false,
|
| 58 |
+
"single_word": false,
|
| 59 |
+
"special": true
|
| 60 |
+
},
|
| 61 |
+
"75862": {
|
| 62 |
+
"content": "<PAD>",
|
| 63 |
+
"lstrip": false,
|
| 64 |
+
"normalized": false,
|
| 65 |
+
"rstrip": false,
|
| 66 |
+
"single_word": false,
|
| 67 |
+
"special": true
|
| 68 |
+
},
|
| 69 |
+
"75863": {
|
| 70 |
+
"content": "<|im_start|>",
|
| 71 |
+
"lstrip": false,
|
| 72 |
+
"normalized": false,
|
| 73 |
+
"rstrip": false,
|
| 74 |
+
"single_word": false,
|
| 75 |
+
"special": true
|
| 76 |
+
},
|
| 77 |
+
"75864": {
|
| 78 |
+
"content": "<|im_end|>",
|
| 79 |
+
"lstrip": false,
|
| 80 |
+
"normalized": false,
|
| 81 |
+
"rstrip": false,
|
| 82 |
+
"single_word": false,
|
| 83 |
+
"special": true
|
| 84 |
+
},
|
| 85 |
+
"75865": {
|
| 86 |
+
"content": "<|fim_prefix|>",
|
| 87 |
+
"lstrip": false,
|
| 88 |
+
"normalized": false,
|
| 89 |
+
"rstrip": false,
|
| 90 |
+
"single_word": false,
|
| 91 |
+
"special": true
|
| 92 |
+
},
|
| 93 |
+
"75866": {
|
| 94 |
+
"content": "<|fim_middle|>",
|
| 95 |
+
"lstrip": false,
|
| 96 |
+
"normalized": false,
|
| 97 |
+
"rstrip": false,
|
| 98 |
+
"single_word": false,
|
| 99 |
+
"special": true
|
| 100 |
+
},
|
| 101 |
+
"75867": {
|
| 102 |
+
"content": "<|fim_suffix|>",
|
| 103 |
+
"lstrip": false,
|
| 104 |
+
"normalized": false,
|
| 105 |
+
"rstrip": false,
|
| 106 |
+
"single_word": false,
|
| 107 |
+
"special": true
|
| 108 |
+
},
|
| 109 |
+
"75868": {
|
| 110 |
+
"content": "<|fim_pad|>",
|
| 111 |
+
"lstrip": false,
|
| 112 |
+
"normalized": false,
|
| 113 |
+
"rstrip": false,
|
| 114 |
+
"single_word": false,
|
| 115 |
+
"special": true
|
| 116 |
+
},
|
| 117 |
+
"75869": {
|
| 118 |
+
"content": "<|endoftext|>",
|
| 119 |
+
"lstrip": false,
|
| 120 |
+
"normalized": false,
|
| 121 |
+
"rstrip": false,
|
| 122 |
+
"single_word": false,
|
| 123 |
+
"special": true
|
| 124 |
+
},
|
| 125 |
+
"75870": {
|
| 126 |
+
"content": "<|repo_name|>",
|
| 127 |
+
"lstrip": false,
|
| 128 |
+
"normalized": false,
|
| 129 |
+
"rstrip": false,
|
| 130 |
+
"single_word": false,
|
| 131 |
+
"special": true
|
| 132 |
+
},
|
| 133 |
+
"75871": {
|
| 134 |
+
"content": "<|file_sep|>",
|
| 135 |
+
"lstrip": false,
|
| 136 |
+
"normalized": false,
|
| 137 |
+
"rstrip": false,
|
| 138 |
+
"single_word": false,
|
| 139 |
+
"special": true
|
| 140 |
+
},
|
| 141 |
+
"75872": {
|
| 142 |
+
"content": "<think>",
|
| 143 |
+
"lstrip": false,
|
| 144 |
+
"normalized": false,
|
| 145 |
+
"rstrip": false,
|
| 146 |
+
"single_word": false,
|
| 147 |
+
"special": false
|
| 148 |
+
},
|
| 149 |
+
"75873": {
|
| 150 |
+
"content": "</think>",
|
| 151 |
+
"lstrip": false,
|
| 152 |
+
"normalized": false,
|
| 153 |
+
"rstrip": false,
|
| 154 |
+
"single_word": false,
|
| 155 |
+
"special": false
|
| 156 |
+
},
|
| 157 |
+
"75874": {
|
| 158 |
+
"content": "<tools>",
|
| 159 |
+
"lstrip": false,
|
| 160 |
+
"normalized": false,
|
| 161 |
+
"rstrip": false,
|
| 162 |
+
"single_word": false,
|
| 163 |
+
"special": false
|
| 164 |
+
},
|
| 165 |
+
"75875": {
|
| 166 |
+
"content": "</tools>",
|
| 167 |
+
"lstrip": false,
|
| 168 |
+
"normalized": false,
|
| 169 |
+
"rstrip": false,
|
| 170 |
+
"single_word": false,
|
| 171 |
+
"special": false
|
| 172 |
+
},
|
| 173 |
+
"75876": {
|
| 174 |
+
"content": "<tool_call>",
|
| 175 |
+
"lstrip": false,
|
| 176 |
+
"normalized": false,
|
| 177 |
+
"rstrip": false,
|
| 178 |
+
"single_word": false,
|
| 179 |
+
"special": false
|
| 180 |
+
},
|
| 181 |
+
"75877": {
|
| 182 |
+
"content": "</tool_call>",
|
| 183 |
+
"lstrip": false,
|
| 184 |
+
"normalized": false,
|
| 185 |
+
"rstrip": false,
|
| 186 |
+
"single_word": false,
|
| 187 |
+
"special": false
|
| 188 |
+
},
|
| 189 |
+
"75878": {
|
| 190 |
+
"content": "<tool_response>",
|
| 191 |
+
"lstrip": false,
|
| 192 |
+
"normalized": false,
|
| 193 |
+
"rstrip": false,
|
| 194 |
+
"single_word": false,
|
| 195 |
+
"special": false
|
| 196 |
+
},
|
| 197 |
+
"75879": {
|
| 198 |
+
"content": "</tool_response>",
|
| 199 |
+
"lstrip": false,
|
| 200 |
+
"normalized": false,
|
| 201 |
+
"rstrip": false,
|
| 202 |
+
"single_word": false,
|
| 203 |
+
"special": false
|
| 204 |
+
}
|
| 205 |
+
},
|
| 206 |
+
"additional_special_tokens": [
|
| 207 |
+
"<|CLS|>",
|
| 208 |
+
"<|SEP|>",
|
| 209 |
+
"<|EOD|>",
|
| 210 |
+
"<|MASK|>",
|
| 211 |
+
"<|PAD|>",
|
| 212 |
+
"<|fim_prefix|>",
|
| 213 |
+
"<|fim_middle|>",
|
| 214 |
+
"<|fim_suffix|>",
|
| 215 |
+
"<|im_start|>",
|
| 216 |
+
"<|im_end|>",
|
| 217 |
+
"<|fim_pad|>",
|
| 218 |
+
"<|endoftext|>",
|
| 219 |
+
"<|repo_name|>",
|
| 220 |
+
"<|file_sep|>",
|
| 221 |
+
"<think>",
|
| 222 |
+
"</think>"
|
| 223 |
+
],
|
| 224 |
+
"auto_map": {
|
| 225 |
+
"AutoTokenizer": [
|
| 226 |
+
"tokenization_iquestcoder.IQuestCoderTokenizer",
|
| 227 |
+
null
|
| 228 |
+
]
|
| 229 |
+
},
|
| 230 |
+
"bos_token": "<s>",
|
| 231 |
+
"chat_template": "{%- if tools %}\n {{- '<|im_start|>system\\n' }}\n {%- if messages[0].role == 'system' %}\n {{- messages[0].content + '\\n\\n' }}\n {%- else %}\n {{- 'You are LoopCoder, a helpful assistant developed by IQuest.' }}\n {%- endif %}\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>\" }}\n {%- for tool in tools %}\n {{- \"\\n\" }}\n {{- tool | tojson }}\n {%- endfor %}\n {{- \"\\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\" }}\n{%- else %}\n {%- if messages[0].role == 'system' %}\n {{- '<|im_start|>system\\n' + messages[0].content + '<|im_end|>\\n' }}\n {%- else %}\n {{- '<|im_start|>system\\nYou are LoopCoder, a helpful assistant developed by IQuest.<|im_end|>\\n' }}\n {%- endif %}\n{%- endif %}\n{%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}\n{%- for message in messages[::-1] %}\n {%- set index = (messages|length - 1) - loop.index0 %}\n {%- if ns.multi_step_tool and message.role == \"user\" and not(message.content.startswith('<tool_response>') and message.content.endswith('</tool_response>')) %}\n {%- set ns.multi_step_tool = false %}\n {%- set ns.last_query_index = index %}\n {%- endif %}\n{%- endfor %}\n{%- for message in messages %}\n {%- if (message.role == \"user\") or (message.role == \"system\" and not loop.first) %}\n {{- '<|im_start|>' + message.role + '\\n' + message.content + '<|im_end|>' + '\\n' }}\n {%- elif message.role == \"assistant\" %}\n {%- set content = message.content %}\n {{- '<|im_start|>' + message.role + '\\n' + content }}\n {%- if message.tool_calls %}\n {%- for tool_call in message.tool_calls %}\n {%- if (loop.first and content) or (not loop.first) %}\n {{- '\\n' }}\n {%- endif %}\n {%- if tool_call.function %}\n {%- set tool_call = tool_call.function %}\n {%- endif %}\n {{- '<tool_call>\\n{\"name\": \"' }}\n {{- tool_call.name }}\n {{- '\", \"arguments\": ' }}\n {%- if tool_call.arguments is string %}\n {{- tool_call.arguments }}\n {%- else %}\n {{- tool_call.arguments | tojson }}\n {%- endif %}\n {{- '}\\n</tool_call>' }}\n {%- endfor %}\n {%- endif %}\n {{- '<|im_end|>\\n' }}\n {%- elif message.role == \"tool\" %}\n {%- if loop.first or (messages[loop.index0 - 1].role != \"tool\") %}\n {{- '<|im_start|>user' }}\n {%- endif %}\n {{- '\\n<tool_response>\\n' }}\n {{- message.content }}\n {{- '\\n</tool_response>' }}\n {%- if loop.last or (messages[loop.index0 + 1].role != \"tool\") %}\n {{- '<|im_end|>\\n' }}\n {%- endif %}\n {%- endif %}\n{%- endfor %}\n{%- if add_generation_prompt %}\n {{- '<|im_start|>assistant\\n' }}\n{%- endif %}",
|
| 232 |
+
"clean_up_tokenization_spaces": false,
|
| 233 |
+
"eos_token": "<|im_end|>",
|
| 234 |
+
"model_max_length": 131072,
|
| 235 |
+
"pad_token": "<|endoftext|>",
|
| 236 |
+
"padding_side": "right",
|
| 237 |
+
"sp_model_kwargs": {},
|
| 238 |
+
"split_special_tokens": false,
|
| 239 |
+
"tokenizer_class": "IQuestCoderTokenizer",
|
| 240 |
+
"unk_token": "<unk>",
|
| 241 |
+
"use_fast": false
|
| 242 |
+
}
|