Upload folder using huggingface_hub
Browse files- .gitignore +1 -0
- config.json +49 -0
- configuration_mamba2.py +185 -0
- generation_config.json +7 -0
- modeling_mamba2.py +1201 -0
- pytorch_model-00001-of-00006.bin +3 -0
- pytorch_model-00002-of-00006.bin +3 -0
- pytorch_model-00003-of-00006.bin +3 -0
- pytorch_model-00004-of-00006.bin +3 -0
- pytorch_model-00005-of-00006.bin +3 -0
- pytorch_model-00006-of-00006.bin +3 -0
- pytorch_model.bin.index.json +586 -0
- special_tokens_map.json +23 -0
- tokenizer.json +0 -0
- tokenizer.model +3 -0
- tokenizer_config.json +0 -0
.gitignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
fabric*
|
config.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_name_or_path": "mistralai/mamba-codestral-7B-v0.1",
|
| 3 |
+
"architectures": [
|
| 4 |
+
"Mamba2ForCausalLM"
|
| 5 |
+
],
|
| 6 |
+
"auto_map": {
|
| 7 |
+
"AutoConfig": "configuration_mamba2.Mamba2Config",
|
| 8 |
+
"AutoModel": "modeling_mamba2.Mamba2ForCausalLM",
|
| 9 |
+
"AutoModelForCausalLM": "modeling_mamba2.Mamba2ForCausalLM"
|
| 10 |
+
},
|
| 11 |
+
"bos_token_id": 0,
|
| 12 |
+
"chunk_size": 256,
|
| 13 |
+
"conv_kernel": 4,
|
| 14 |
+
"eos_token_id": 0,
|
| 15 |
+
"expand": 2,
|
| 16 |
+
"head_dim": 64,
|
| 17 |
+
"hidden_act": "silu",
|
| 18 |
+
"hidden_size": 4096,
|
| 19 |
+
"initializer_range": 0.1,
|
| 20 |
+
"intermediate_size": 8192,
|
| 21 |
+
"layer_norm_epsilon": 1e-05,
|
| 22 |
+
"model_type": "mamba2",
|
| 23 |
+
"n_groups": 8,
|
| 24 |
+
"norm_before_gate": true,
|
| 25 |
+
"num_heads": 128,
|
| 26 |
+
"num_hidden_layers": 64,
|
| 27 |
+
"pad_token_id": 0,
|
| 28 |
+
"rescale_prenorm_residual": false,
|
| 29 |
+
"residual_in_fp32": true,
|
| 30 |
+
"rms_norm": true,
|
| 31 |
+
"state_size": 128,
|
| 32 |
+
"tie_word_embeddings": false,
|
| 33 |
+
"time_step_floor": 0.0001,
|
| 34 |
+
"time_step_init_scheme": "random",
|
| 35 |
+
"time_step_limit": [
|
| 36 |
+
0.0,
|
| 37 |
+
Infinity
|
| 38 |
+
],
|
| 39 |
+
"time_step_max": 0.1,
|
| 40 |
+
"time_step_min": 0.001,
|
| 41 |
+
"time_step_rank": 256,
|
| 42 |
+
"time_step_scale": 1.0,
|
| 43 |
+
"torch_dtype": "float32",
|
| 44 |
+
"transformers_version": "4.43.3",
|
| 45 |
+
"use_bias": false,
|
| 46 |
+
"use_cache": true,
|
| 47 |
+
"use_conv_bias": true,
|
| 48 |
+
"vocab_size": 32768
|
| 49 |
+
}
|
configuration_mamba2.py
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# coding=utf-8
|
| 2 |
+
# Copyright 2024 The HuggingFace Inc. team.
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
"""MAMBA2 configuration"""
|
| 16 |
+
|
| 17 |
+
import math
|
| 18 |
+
|
| 19 |
+
from transformers.configuration_utils import PretrainedConfig
|
| 20 |
+
from transformers.utils import logging
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
logger = logging.get_logger(__name__)
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
class Mamba2Config(PretrainedConfig):
|
| 27 |
+
"""
|
| 28 |
+
This is the configuration class to store the configuration of a [`Mamba2Model`]. It is used to instantiate a MAMBA2
|
| 29 |
+
model according to the specified arguments, defining the model architecture. Instantiating a configuration with the
|
| 30 |
+
defaults will yield a similar configuration to that of the MAMBA2
|
| 31 |
+
[state-spaces/mamba2-2.8b](https://huggingface.co/state-spaces/mamba2-2.8b) architecture.
|
| 32 |
+
|
| 33 |
+
Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
|
| 34 |
+
documentation from [`PretrainedConfig`] for more information.
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
Args:
|
| 38 |
+
num_heads (`int`, *optional*, defaults to 128):
|
| 39 |
+
Number of heads for the evolution matrices of mamba 2.
|
| 40 |
+
head_dim (`int`, *optional*, defaults to 64):
|
| 41 |
+
Dimension of each head.
|
| 42 |
+
vocab_size (`int`, *optional*, defaults to 32768):
|
| 43 |
+
Vocabulary size of the MAMBA2 model. Defines the number of different tokens that can be represented by the
|
| 44 |
+
`inputs_ids` passed when calling [`Mamba2Model`].
|
| 45 |
+
hidden_size (`int`, *optional*, defaults to 4096):
|
| 46 |
+
Dimensionality of the embeddings and hidden states.
|
| 47 |
+
state_size (`int`, *optional*, defaults to 128): shape of the state space latents.
|
| 48 |
+
num_hidden_layers (`int`, *optional*, defaults to 64):
|
| 49 |
+
Number of hidden layers in the model.
|
| 50 |
+
layer_norm_epsilon (`float`, *optional*, defaults to 1e-05):
|
| 51 |
+
The epsilon to use in the layer normalization layers.
|
| 52 |
+
pad_token_id (`int`, *optional*, defaults to 1):
|
| 53 |
+
Padding token id.
|
| 54 |
+
bos_token_id (`int`, *optional*, defaults to 0):
|
| 55 |
+
The id of the beginning of sentence token in the vocabulary.
|
| 56 |
+
eos_token_id (`int`, *optional*, defaults to 2):
|
| 57 |
+
The id of the end of sentence token in the vocabulary.
|
| 58 |
+
expand (`int`, *optional*, defaults to 2): Expanding factor used to determine the intermediate size.
|
| 59 |
+
conv_kernel (`int`, *optional*, defaults to 4): Size of the convolution kernel.
|
| 60 |
+
n_groups (`int`, *optional*, defaults to 8):
|
| 61 |
+
Number of groups for the evolution matrices of mamba 2.
|
| 62 |
+
use_bias (`bool`, *optional*, defaults to `False`):
|
| 63 |
+
Whether or not to use bias in ["in_proj", "out_proj"] of the mixer block
|
| 64 |
+
use_conv_bias (`bool`, *optional*, defaults to `True`):
|
| 65 |
+
Whether or not to use bias in the convolution layer of the mixer block.
|
| 66 |
+
hidden_act (`str`, *optional*, defaults to `"silu"`):
|
| 67 |
+
The non-linear activation function (function or string) in the decoder.
|
| 68 |
+
initializer_range (`float`, *optional*, defaults to 0.1):
|
| 69 |
+
The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
|
| 70 |
+
residual_in_fp32 (`bool`, *optional*, defaults to `True`):
|
| 71 |
+
Whether or not residuals should be in `float32`. If set to `False` residuals will keep the same `dtype` as the rest of the model
|
| 72 |
+
time_step_rank (`Union[int,str]`, *optional*, defaults to `"auto"`):
|
| 73 |
+
Rank of the discretization projection matrix. `"auto"` means that it will default to `math.ceil(self.hidden_size / 16)`
|
| 74 |
+
time_step_min (`float`, *optional*, defaults to 0.001):
|
| 75 |
+
Minimum `time_step` used to bound `dt_proj.bias`.
|
| 76 |
+
time_step_max (`float`, *optional*, defaults to 0.1):
|
| 77 |
+
Maximum `time_step` used to bound `dt_proj.bias`.
|
| 78 |
+
time_step_floor (`float`, *optional*, defaults to 0.0001):
|
| 79 |
+
Minimum clamping value of the `dt_proj.bias` layer initialization.
|
| 80 |
+
time_step_limit (`tuple`, *optional*, defaults to `(0.0, inf)`):
|
| 81 |
+
Accepted range of time step values.
|
| 82 |
+
rescale_prenorm_residual (`bool`, *optional*, defaults to `False`):
|
| 83 |
+
Whether or not to rescale `out_proj` weights when initializing.
|
| 84 |
+
use_cache (`bool`, *optional*, defaults to `True`):
|
| 85 |
+
Whether or not the cache should be used.
|
| 86 |
+
rms_norm (`bool`, *optional*, defaults to `True`):
|
| 87 |
+
Whether to use RMS norm or not.
|
| 88 |
+
chunk_size (`int`, *optional*, defaults to 256):
|
| 89 |
+
Size of the chunks that will comprise the sequence.
|
| 90 |
+
tie_word_embeddings (`bool`, *optional*, defaults to `False`):
|
| 91 |
+
Whether to tie word embeddings or not.
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
Example:
|
| 95 |
+
|
| 96 |
+
```python
|
| 97 |
+
>>> from transformers import Mamba2Config, Mamba2Model
|
| 98 |
+
|
| 99 |
+
>>> # Initializing a Mamba2 configuration
|
| 100 |
+
>>> configuration = Mamba2Config()
|
| 101 |
+
|
| 102 |
+
>>> # Initializing a model (with random weights) from the configuration
|
| 103 |
+
>>> model = Mamba2Model(configuration)
|
| 104 |
+
|
| 105 |
+
>>> # Accessing the model configuration
|
| 106 |
+
>>> configuration = model.config
|
| 107 |
+
```"""
|
| 108 |
+
|
| 109 |
+
model_type = "mamba2"
|
| 110 |
+
|
| 111 |
+
def __init__(
|
| 112 |
+
self,
|
| 113 |
+
num_classes=1,
|
| 114 |
+
num_heads=128,
|
| 115 |
+
head_dim=64,
|
| 116 |
+
vocab_size=32768,
|
| 117 |
+
hidden_size=4096,
|
| 118 |
+
state_size=128,
|
| 119 |
+
num_hidden_layers=64,
|
| 120 |
+
layer_norm_epsilon=1e-5,
|
| 121 |
+
pad_token_id=1,
|
| 122 |
+
bos_token_id=0,
|
| 123 |
+
eos_token_id=2,
|
| 124 |
+
expand=2,
|
| 125 |
+
conv_kernel=4,
|
| 126 |
+
n_groups=8,
|
| 127 |
+
use_bias=False,
|
| 128 |
+
use_conv_bias=True,
|
| 129 |
+
hidden_act="silu",
|
| 130 |
+
initializer_range=0.1,
|
| 131 |
+
residual_in_fp32=True,
|
| 132 |
+
time_step_rank="auto",
|
| 133 |
+
time_step_min=0.001,
|
| 134 |
+
time_step_max=0.1,
|
| 135 |
+
time_step_floor=1e-4,
|
| 136 |
+
time_step_limit=(0.0, float("inf")),
|
| 137 |
+
rescale_prenorm_residual=False,
|
| 138 |
+
use_cache=True,
|
| 139 |
+
rms_norm=True,
|
| 140 |
+
chunk_size=256,
|
| 141 |
+
tie_word_embeddings=False,
|
| 142 |
+
**kwargs,
|
| 143 |
+
):
|
| 144 |
+
self.num_classes = num_classes
|
| 145 |
+
self.vocab_size = vocab_size
|
| 146 |
+
self.hidden_size = hidden_size
|
| 147 |
+
self.state_size = state_size
|
| 148 |
+
self.num_hidden_layers = num_hidden_layers
|
| 149 |
+
self.layer_norm_epsilon = layer_norm_epsilon
|
| 150 |
+
self.conv_kernel = conv_kernel
|
| 151 |
+
self.expand = expand
|
| 152 |
+
|
| 153 |
+
self.bos_token_id = bos_token_id
|
| 154 |
+
self.eos_token_id = eos_token_id
|
| 155 |
+
self.pad_token_id = pad_token_id
|
| 156 |
+
self.use_bias = use_bias
|
| 157 |
+
self.use_conv_bias = use_conv_bias
|
| 158 |
+
self.hidden_act = hidden_act
|
| 159 |
+
self.initializer_range = initializer_range
|
| 160 |
+
self.time_step_rank = math.ceil(self.hidden_size / 16) if time_step_rank == "auto" else time_step_rank
|
| 161 |
+
self.time_step_min = time_step_min
|
| 162 |
+
self.time_step_max = time_step_max
|
| 163 |
+
self.time_step_floor = time_step_floor
|
| 164 |
+
self.rescale_prenorm_residual = rescale_prenorm_residual
|
| 165 |
+
self.residual_in_fp32 = residual_in_fp32
|
| 166 |
+
self.use_cache = use_cache
|
| 167 |
+
self.n_groups = n_groups
|
| 168 |
+
self.num_heads = num_heads
|
| 169 |
+
self.head_dim = head_dim
|
| 170 |
+
self.rms_norm = rms_norm
|
| 171 |
+
self.state_size = state_size
|
| 172 |
+
self.chunk_size = chunk_size
|
| 173 |
+
self.time_step_limit = time_step_limit
|
| 174 |
+
self.tie_word_embeddings = tie_word_embeddings
|
| 175 |
+
|
| 176 |
+
super().__init__(
|
| 177 |
+
bos_token_id=bos_token_id,
|
| 178 |
+
eos_token_id=eos_token_id,
|
| 179 |
+
pad_token_id=pad_token_id,
|
| 180 |
+
tie_word_embeddings=tie_word_embeddings,
|
| 181 |
+
**kwargs,
|
| 182 |
+
)
|
| 183 |
+
|
| 184 |
+
|
| 185 |
+
__all__ = ["Mamba2Config"]
|
generation_config.json
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_from_model_config": true,
|
| 3 |
+
"bos_token_id": 0,
|
| 4 |
+
"eos_token_id": 2,
|
| 5 |
+
"pad_token_id": 1,
|
| 6 |
+
"transformers_version": "4.43.3"
|
| 7 |
+
}
|
modeling_mamba2.py
ADDED
|
@@ -0,0 +1,1201 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# coding=utf-8
|
| 2 |
+
# Copyright 2024 state-spaces/mamba2 org and HuggingFace Inc. team.
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
"""PyTorch MAMBA2 model."""
|
| 16 |
+
|
| 17 |
+
import math
|
| 18 |
+
from dataclasses import dataclass
|
| 19 |
+
from typing import Optional, Tuple, Union
|
| 20 |
+
|
| 21 |
+
import torch
|
| 22 |
+
import torch.utils.checkpoint
|
| 23 |
+
from torch import nn
|
| 24 |
+
from torch.nn import CrossEntropyLoss
|
| 25 |
+
|
| 26 |
+
from transformers.activations import ACT2FN
|
| 27 |
+
from transformers.generation import GenerationMixin
|
| 28 |
+
from transformers.modeling_utils import PreTrainedModel
|
| 29 |
+
from transformers.utils import (
|
| 30 |
+
ModelOutput,
|
| 31 |
+
add_code_sample_docstrings,
|
| 32 |
+
add_start_docstrings,
|
| 33 |
+
add_start_docstrings_to_model_forward,
|
| 34 |
+
logging,
|
| 35 |
+
)
|
| 36 |
+
from transformers.utils.import_utils import is_causal_conv1d_available, is_torch_available, _is_package_available, version
|
| 37 |
+
from .configuration_mamba2 import Mamba2Config
|
| 38 |
+
|
| 39 |
+
def is_mamba_2_ssm_available():
|
| 40 |
+
if is_torch_available():
|
| 41 |
+
import torch
|
| 42 |
+
|
| 43 |
+
if not torch.cuda.is_available():
|
| 44 |
+
return False
|
| 45 |
+
else:
|
| 46 |
+
if _is_package_available("mamba_ssm"):
|
| 47 |
+
import mamba_ssm
|
| 48 |
+
|
| 49 |
+
if version.parse(mamba_ssm.__version__) >= version.parse("2.0.4"):
|
| 50 |
+
return True
|
| 51 |
+
return False
|
| 52 |
+
|
| 53 |
+
logger = logging.get_logger(__name__)
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
if is_mamba_2_ssm_available():
|
| 57 |
+
from mamba_ssm.ops.triton.selective_state_update import selective_state_update
|
| 58 |
+
from mamba_ssm.ops.triton.ssd_combined import mamba_chunk_scan_combined, mamba_split_conv1d_scan_combined
|
| 59 |
+
else:
|
| 60 |
+
mamba_chunk_scan_combined, mamba_split_conv1d_scan_combined, selective_state_update = None, None, None
|
| 61 |
+
|
| 62 |
+
if is_causal_conv1d_available():
|
| 63 |
+
from causal_conv1d import causal_conv1d_fn, causal_conv1d_update
|
| 64 |
+
else:
|
| 65 |
+
causal_conv1d_update, causal_conv1d_fn = None, None
|
| 66 |
+
|
| 67 |
+
is_fast_path_available = all(
|
| 68 |
+
(
|
| 69 |
+
selective_state_update,
|
| 70 |
+
mamba_chunk_scan_combined,
|
| 71 |
+
mamba_split_conv1d_scan_combined,
|
| 72 |
+
causal_conv1d_fn,
|
| 73 |
+
causal_conv1d_update,
|
| 74 |
+
)
|
| 75 |
+
)
|
| 76 |
+
|
| 77 |
+
_CHECKPOINT_FOR_DOC = "mistralai/mamba-codestral-7B-v0.1"
|
| 78 |
+
_CONFIG_FOR_DOC = "Mamba2Config"
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
# Helper methods for segment sum computation
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
def pad_tensor_by_size(input_tensor: torch.Tensor, pad_size: int):
|
| 85 |
+
"""
|
| 86 |
+
Padding x tensor with `pad_size` on the seq_len dim (dim=1)
|
| 87 |
+
|
| 88 |
+
Assumes that we only have tensors of either size 4 or 3
|
| 89 |
+
"""
|
| 90 |
+
pad_shape = (0, 0, 0, 0, 0, pad_size, 0, 0) if len(input_tensor.shape) == 4 else (0, 0, 0, pad_size, 0, 0)
|
| 91 |
+
|
| 92 |
+
return torch.nn.functional.pad(input_tensor, pad_shape, mode="constant", value=0)
|
| 93 |
+
|
| 94 |
+
|
| 95 |
+
def reshape_into_chunks(input_tensor, pad_size, chunk_size):
|
| 96 |
+
"""
|
| 97 |
+
Padding input_tensor with `pad_size` on the seq_len dim (dim=1) and
|
| 98 |
+
simultaneously splitting it into chunk sequences.
|
| 99 |
+
|
| 100 |
+
Assumes that we only have tensors of either size 4 or 3
|
| 101 |
+
"""
|
| 102 |
+
# [bsz, seq_len, ...] -> [bsz, seq_len multiple of chunk_size, ...]
|
| 103 |
+
input_tensor = pad_tensor_by_size(input_tensor, pad_size)
|
| 104 |
+
|
| 105 |
+
if len(input_tensor.shape) == 3:
|
| 106 |
+
# [bsz, seq_len multiple of chunk_size, num_heads] -> [bsz, -1, chunk_size, num_heads]
|
| 107 |
+
return input_tensor.reshape(input_tensor.shape[0], -1, chunk_size, input_tensor.shape[2])
|
| 108 |
+
else:
|
| 109 |
+
# [bsz, seq_len multiple of chunk_size, num_heads, head_dim or state_size] -> [bsz, -1, chunk_size, num_heads, head_dim or state_size]
|
| 110 |
+
return input_tensor.reshape(
|
| 111 |
+
input_tensor.shape[0], -1, chunk_size, input_tensor.shape[2], input_tensor.shape[3]
|
| 112 |
+
)
|
| 113 |
+
|
| 114 |
+
|
| 115 |
+
def segment_sum(input_tensor):
|
| 116 |
+
"""
|
| 117 |
+
More stable segment sum calculation. Uses cumulative sums and masking instead of direct subtractions.
|
| 118 |
+
"""
|
| 119 |
+
chunk_size = input_tensor.size(-1)
|
| 120 |
+
# 1. expand input tensor to have an additional dimension and repeat along that dimension
|
| 121 |
+
# [..., chunk_size] -> [..., chunk_size, chunk_size]
|
| 122 |
+
input_tensor = input_tensor[..., None].expand(*input_tensor.size(), chunk_size)
|
| 123 |
+
# 2. create a lower triangular mask with the diagonal set to 0 to 0 out elements above diag
|
| 124 |
+
mask = torch.tril(torch.ones(chunk_size, chunk_size, device=input_tensor.device, dtype=torch.bool), diagonal=-1)
|
| 125 |
+
input_tensor = input_tensor.masked_fill(~mask, 0)
|
| 126 |
+
# 3. compute actual cumsum
|
| 127 |
+
tensor_segsum = torch.cumsum(input_tensor, dim=-2)
|
| 128 |
+
|
| 129 |
+
# 4. apply mask to keep only the lower triangular part of the cumulative sum result (incl diagonal this time)
|
| 130 |
+
mask = torch.tril(torch.ones(chunk_size, chunk_size, device=input_tensor.device, dtype=torch.bool), diagonal=0)
|
| 131 |
+
tensor_segsum = tensor_segsum.masked_fill(~mask, -torch.inf)
|
| 132 |
+
return tensor_segsum
|
| 133 |
+
|
| 134 |
+
|
| 135 |
+
def apply_mask_to_padding_states(hidden_states, attention_mask):
|
| 136 |
+
"""
|
| 137 |
+
Tunes out the hidden states for padding tokens, see https://github.com/state-spaces/mamba/issues/66
|
| 138 |
+
"""
|
| 139 |
+
if attention_mask is not None and attention_mask.shape[1] > 1 and attention_mask.shape[0] > 1:
|
| 140 |
+
dtype = hidden_states.dtype
|
| 141 |
+
hidden_states = (hidden_states * attention_mask[:, :, None]).to(dtype)
|
| 142 |
+
|
| 143 |
+
return hidden_states
|
| 144 |
+
|
| 145 |
+
|
| 146 |
+
class Mamba2Cache:
|
| 147 |
+
"""
|
| 148 |
+
Arguments:
|
| 149 |
+
config: Mamba2Config
|
| 150 |
+
batch_size: int
|
| 151 |
+
dtype: torch.dtype
|
| 152 |
+
device: torch.device
|
| 153 |
+
|
| 154 |
+
Attributes:
|
| 155 |
+
dtype: (`torch.dtype`):
|
| 156 |
+
The default `dtype` used to initializing the cache.
|
| 157 |
+
conv_kernel_size: (`int`):
|
| 158 |
+
Model's convolution kernel size taken from config.
|
| 159 |
+
n_groups: (`int`):
|
| 160 |
+
Model's number of groups taken from the config - similar to tensor parallel in Transformer.
|
| 161 |
+
state_size: (`int`):
|
| 162 |
+
Model's SSM state size taken from config.
|
| 163 |
+
num_heads: (`int`):
|
| 164 |
+
The number of heads used in the linear attention / SSM.
|
| 165 |
+
head_dim: (`int`):
|
| 166 |
+
The respective dimension of the heads used in the linear attention / SSM.
|
| 167 |
+
intermediate_size: (`int`):
|
| 168 |
+
Model's intermediate_size based on (expand * hidden_dim) from config.
|
| 169 |
+
conv_states: (`torch.Tensor`):
|
| 170 |
+
A tensor of shape `[num_layers, batch_size, conv_kernel_size, intermediate_size + 2 * n_groups * state_size]` that holds convolutional states.
|
| 171 |
+
ssm_states: (`torch.Tensor`):
|
| 172 |
+
A tensor of shape `[num_layers, batch_size, num_heads, head_dim, state_size]` that holds ssm states.
|
| 173 |
+
"""
|
| 174 |
+
|
| 175 |
+
def __init__(
|
| 176 |
+
self, config: Mamba2Config, batch_size: int, dtype: torch.dtype = torch.float16, device: Optional[str] = None
|
| 177 |
+
):
|
| 178 |
+
self.dtype = dtype
|
| 179 |
+
self.conv_kernel_size = config.conv_kernel
|
| 180 |
+
self.n_groups = config.n_groups
|
| 181 |
+
self.state_size = config.state_size
|
| 182 |
+
self.num_heads = config.num_heads
|
| 183 |
+
self.head_dim = config.head_dim
|
| 184 |
+
self.intermediate_size = int(config.expand * config.hidden_size)
|
| 185 |
+
|
| 186 |
+
self.conv_states = torch.zeros(
|
| 187 |
+
config.num_hidden_layers,
|
| 188 |
+
batch_size,
|
| 189 |
+
self.intermediate_size + 2 * self.n_groups * self.state_size,
|
| 190 |
+
self.conv_kernel_size,
|
| 191 |
+
device=device,
|
| 192 |
+
dtype=dtype,
|
| 193 |
+
)
|
| 194 |
+
self.ssm_states = torch.zeros(
|
| 195 |
+
config.num_hidden_layers,
|
| 196 |
+
batch_size,
|
| 197 |
+
self.num_heads,
|
| 198 |
+
self.head_dim,
|
| 199 |
+
self.state_size,
|
| 200 |
+
device=device,
|
| 201 |
+
dtype=dtype,
|
| 202 |
+
)
|
| 203 |
+
|
| 204 |
+
def update_conv_state(
|
| 205 |
+
self, layer_idx: int, new_conv_state: torch.Tensor, cache_init: bool = False
|
| 206 |
+
) -> torch.Tensor:
|
| 207 |
+
if cache_init:
|
| 208 |
+
self.conv_states[layer_idx] = new_conv_state.to(self.conv_states.device)
|
| 209 |
+
else:
|
| 210 |
+
self.conv_states[layer_idx] = self.conv_states[layer_idx].roll(shifts=-1, dims=-1)
|
| 211 |
+
self.conv_states[layer_idx][:, :, -1] = new_conv_state[:, 0, :].to(self.conv_states.device)
|
| 212 |
+
return self.conv_states[layer_idx]
|
| 213 |
+
|
| 214 |
+
def update_ssm_state(self, layer_idx: int, new_ssm_state: torch.Tensor):
|
| 215 |
+
self.ssm_states[layer_idx] = new_ssm_state.to(self.ssm_states.device)
|
| 216 |
+
return self.ssm_states[layer_idx]
|
| 217 |
+
|
| 218 |
+
def reset(self):
|
| 219 |
+
self.conv_states.zero_()
|
| 220 |
+
self.ssm_states.zero_()
|
| 221 |
+
|
| 222 |
+
|
| 223 |
+
class MambaRMSNormGated(torch.nn.Module):
|
| 224 |
+
def __init__(self, hidden_size, eps=1e-6):
|
| 225 |
+
super().__init__()
|
| 226 |
+
self.weight = nn.Parameter(torch.ones(hidden_size))
|
| 227 |
+
self.variance_epsilon = eps
|
| 228 |
+
|
| 229 |
+
def forward(self, hidden_states, gate=None):
|
| 230 |
+
input_dtype = hidden_states.dtype
|
| 231 |
+
hidden_states = hidden_states.to(torch.float32)
|
| 232 |
+
|
| 233 |
+
if gate is not None:
|
| 234 |
+
hidden_states = hidden_states * nn.functional.silu(gate.to(torch.float32))
|
| 235 |
+
variance = hidden_states.pow(2).mean(-1, keepdim=True)
|
| 236 |
+
hidden_states = hidden_states * torch.rsqrt(variance + self.variance_epsilon)
|
| 237 |
+
|
| 238 |
+
return self.weight * hidden_states.to(input_dtype)
|
| 239 |
+
|
| 240 |
+
|
| 241 |
+
class Mamba2Mixer(nn.Module):
|
| 242 |
+
"""
|
| 243 |
+
Compute ∆, A, B, C, and D the state space parameters and compute the `contextualized_states`.
|
| 244 |
+
A, D are input independent (see Mamba paper [1] Section 3.5.2 "Interpretation of A" for why A isn't selective)
|
| 245 |
+
∆, B, C are input-dependent (this is a key difference between Mamba and the linear time invariant S4,
|
| 246 |
+
and is why Mamba is called **selective** state spaces)
|
| 247 |
+
"""
|
| 248 |
+
|
| 249 |
+
def __init__(self, config: Mamba2Config, layer_idx: int):
|
| 250 |
+
super().__init__()
|
| 251 |
+
self.num_heads = config.num_heads
|
| 252 |
+
self.hidden_size = config.hidden_size
|
| 253 |
+
self.ssm_state_size = config.state_size
|
| 254 |
+
self.conv_kernel_size = config.conv_kernel
|
| 255 |
+
self.intermediate_size = int(config.expand * self.hidden_size)
|
| 256 |
+
self.time_step_rank = int(config.time_step_rank)
|
| 257 |
+
self.layer_idx = layer_idx
|
| 258 |
+
self.use_conv_bias = config.use_conv_bias
|
| 259 |
+
self.activation = config.hidden_act
|
| 260 |
+
self.act = ACT2FN[config.hidden_act]
|
| 261 |
+
|
| 262 |
+
self.layer_norm_epsilon = config.layer_norm_epsilon
|
| 263 |
+
self.rms_norm = config.rms_norm
|
| 264 |
+
|
| 265 |
+
self.n_groups = config.n_groups
|
| 266 |
+
self.head_dim = config.head_dim
|
| 267 |
+
self.chunk_size = config.chunk_size
|
| 268 |
+
|
| 269 |
+
self.time_step_limit = config.time_step_limit
|
| 270 |
+
self.time_step_min = config.time_step_min
|
| 271 |
+
self.time_step_max = config.time_step_max
|
| 272 |
+
|
| 273 |
+
self.conv_dim = self.intermediate_size + 2 * self.n_groups * self.ssm_state_size
|
| 274 |
+
self.conv1d = nn.Conv1d(
|
| 275 |
+
in_channels=self.conv_dim,
|
| 276 |
+
out_channels=self.conv_dim,
|
| 277 |
+
bias=config.use_conv_bias,
|
| 278 |
+
kernel_size=config.conv_kernel,
|
| 279 |
+
groups=self.conv_dim,
|
| 280 |
+
padding=config.conv_kernel - 1,
|
| 281 |
+
)
|
| 282 |
+
|
| 283 |
+
# projection of the input hidden states
|
| 284 |
+
projection_size = self.intermediate_size + self.conv_dim + self.num_heads
|
| 285 |
+
self.in_proj = nn.Linear(
|
| 286 |
+
self.hidden_size,
|
| 287 |
+
projection_size,
|
| 288 |
+
bias=config.use_bias,
|
| 289 |
+
)
|
| 290 |
+
# selective projection used to make dt, B and C input dependant
|
| 291 |
+
|
| 292 |
+
# time step projection (discretization)
|
| 293 |
+
# instantiate once and copy inv_dt in init_weights of PretrainedModel
|
| 294 |
+
self.dt_bias = nn.Parameter(torch.ones(self.num_heads))
|
| 295 |
+
|
| 296 |
+
# S4D real initialization. These are not discretized!
|
| 297 |
+
# The core is to load them, compute the discrete states, then write the updated state. Keeps the memory bounded
|
| 298 |
+
A = torch.arange(1, self.num_heads + 1)
|
| 299 |
+
self.A_log = nn.Parameter(torch.log(A))
|
| 300 |
+
self.A_log._no_weight_decay = True
|
| 301 |
+
self.norm = MambaRMSNormGated(self.intermediate_size, eps=self.layer_norm_epsilon)
|
| 302 |
+
self.D = nn.Parameter(torch.ones(self.num_heads))
|
| 303 |
+
self.D._no_weight_decay = True
|
| 304 |
+
|
| 305 |
+
self.out_proj = nn.Linear(self.intermediate_size, self.hidden_size, bias=config.use_bias)
|
| 306 |
+
self.use_bias = config.use_bias
|
| 307 |
+
|
| 308 |
+
if not is_fast_path_available:
|
| 309 |
+
logger.warning_once(
|
| 310 |
+
"The fast path is not available because on of `(selective_state_update, causal_conv1d_fn, causal_conv1d_update)`"
|
| 311 |
+
" is None. Falling back to the naive implementation. To install follow https://github.com/state-spaces/mamba/#installation and"
|
| 312 |
+
" https://github.com/Dao-AILab/causal-conv1d"
|
| 313 |
+
)
|
| 314 |
+
|
| 315 |
+
def cuda_kernels_forward(
|
| 316 |
+
self,
|
| 317 |
+
hidden_states: torch.Tensor,
|
| 318 |
+
cache_params: Optional[Mamba2Cache] = None,
|
| 319 |
+
cache_position: Optional[torch.LongTensor] = None,
|
| 320 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 321 |
+
):
|
| 322 |
+
# 1. Gated MLP's linear projection
|
| 323 |
+
hidden_states = apply_mask_to_padding_states(hidden_states, attention_mask)
|
| 324 |
+
projected_states = self.in_proj(hidden_states)
|
| 325 |
+
|
| 326 |
+
# Set up dimensions for reshapes later
|
| 327 |
+
batch_size, seq_len, _ = hidden_states.shape
|
| 328 |
+
groups_time_state_size = self.n_groups * self.ssm_state_size
|
| 329 |
+
d_mlp = (
|
| 330 |
+
projected_states.shape[-1]
|
| 331 |
+
- 2 * self.intermediate_size
|
| 332 |
+
- 2 * self.n_groups * self.ssm_state_size
|
| 333 |
+
- self.num_heads
|
| 334 |
+
) // 2
|
| 335 |
+
|
| 336 |
+
# Single step calculations via cache
|
| 337 |
+
if cache_params is not None and cache_position is not None and cache_position[0] > 0:
|
| 338 |
+
_, _, gate, hidden_states_B_C, dt = projected_states.squeeze(1).split(
|
| 339 |
+
[d_mlp, d_mlp, self.intermediate_size, self.conv_dim, self.num_heads], dim=-1
|
| 340 |
+
)
|
| 341 |
+
|
| 342 |
+
# 2. Convolution sequence transformation
|
| 343 |
+
hidden_states_B_C = causal_conv1d_update(
|
| 344 |
+
hidden_states_B_C,
|
| 345 |
+
cache_params.conv_states[self.layer_idx],
|
| 346 |
+
self.conv1d.weight.squeeze(1),
|
| 347 |
+
self.conv1d.bias,
|
| 348 |
+
self.activation,
|
| 349 |
+
)
|
| 350 |
+
|
| 351 |
+
hidden_states, B, C = torch.split(
|
| 352 |
+
hidden_states_B_C,
|
| 353 |
+
[self.intermediate_size, groups_time_state_size, groups_time_state_size],
|
| 354 |
+
dim=-1,
|
| 355 |
+
)
|
| 356 |
+
|
| 357 |
+
# 3. SSM transformation
|
| 358 |
+
A = -torch.exp(self.A_log.float()) # (nheads,)
|
| 359 |
+
A = A[:, None, ...][:, :, None].expand(-1, self.head_dim, self.ssm_state_size).to(dtype=torch.float32)
|
| 360 |
+
dt = dt[:, :, None].expand(-1, -1, self.head_dim)
|
| 361 |
+
dt_bias = self.dt_bias[:, None, ...].expand(-1, self.head_dim)
|
| 362 |
+
D = self.D[:, None, ...].expand(-1, self.head_dim)
|
| 363 |
+
B = B.view(batch_size, self.n_groups, B.shape[1] // self.n_groups)
|
| 364 |
+
C = C.view(batch_size, self.n_groups, C.shape[1] // self.n_groups)
|
| 365 |
+
hidden_states_reshaped = hidden_states.view(batch_size, self.num_heads, self.head_dim)
|
| 366 |
+
hidden_states = selective_state_update(
|
| 367 |
+
cache_params.ssm_states[self.layer_idx],
|
| 368 |
+
hidden_states_reshaped,
|
| 369 |
+
dt,
|
| 370 |
+
A,
|
| 371 |
+
B,
|
| 372 |
+
C,
|
| 373 |
+
D,
|
| 374 |
+
z=None,
|
| 375 |
+
dt_bias=dt_bias,
|
| 376 |
+
dt_softplus=True,
|
| 377 |
+
)
|
| 378 |
+
hidden_states = hidden_states.view(batch_size, self.num_heads * self.head_dim)
|
| 379 |
+
hidden_states = self.norm(hidden_states, gate)
|
| 380 |
+
|
| 381 |
+
# 4. Final linear projection
|
| 382 |
+
out = self.out_proj(hidden_states)[:, None, ...]
|
| 383 |
+
|
| 384 |
+
# Fused calculations or step by step if no initialized cache is found
|
| 385 |
+
else:
|
| 386 |
+
A = -torch.exp(self.A_log.float()) # (num_heads) or (intermediate_size, state_size)
|
| 387 |
+
dt_limit_kwargs = {} if self.time_step_limit == (0.0, float("inf")) else {"dt_limit": self.time_step_limit}
|
| 388 |
+
|
| 389 |
+
# 2-4. Fused kernel for conv1d, SSM, and the final projection
|
| 390 |
+
if self.training and cache_params is None:
|
| 391 |
+
out = mamba_split_conv1d_scan_combined(
|
| 392 |
+
projected_states,
|
| 393 |
+
self.conv1d.weight.squeeze(1),
|
| 394 |
+
self.conv1d.bias,
|
| 395 |
+
self.dt_bias,
|
| 396 |
+
A,
|
| 397 |
+
D=self.D,
|
| 398 |
+
chunk_size=self.chunk_size,
|
| 399 |
+
seq_idx=None, # was seq_idx
|
| 400 |
+
activation=self.activation,
|
| 401 |
+
rmsnorm_weight=self.norm.weight,
|
| 402 |
+
rmsnorm_eps=self.norm.variance_epsilon,
|
| 403 |
+
outproj_weight=self.out_proj.weight,
|
| 404 |
+
outproj_bias=self.out_proj.bias,
|
| 405 |
+
headdim=self.head_dim,
|
| 406 |
+
ngroups=self.n_groups,
|
| 407 |
+
norm_before_gate=False,
|
| 408 |
+
return_final_states=False,
|
| 409 |
+
**dt_limit_kwargs,
|
| 410 |
+
)
|
| 411 |
+
|
| 412 |
+
else:
|
| 413 |
+
_, _, gate, hidden_states_B_C, dt = projected_states.split(
|
| 414 |
+
[d_mlp, d_mlp, self.intermediate_size, self.conv_dim, self.num_heads], dim=-1
|
| 415 |
+
)
|
| 416 |
+
|
| 417 |
+
# 2. Convolution sequence transformation
|
| 418 |
+
# Init cache
|
| 419 |
+
if cache_params is not None:
|
| 420 |
+
hidden_states_B_C_transposed = hidden_states_B_C.transpose(1, 2)
|
| 421 |
+
conv_states = nn.functional.pad(
|
| 422 |
+
hidden_states_B_C_transposed,
|
| 423 |
+
(cache_params.conv_kernel_size - hidden_states_B_C_transposed.shape[-1], 0),
|
| 424 |
+
)
|
| 425 |
+
cache_params.update_conv_state(
|
| 426 |
+
layer_idx=self.layer_idx, new_conv_state=conv_states, cache_init=True
|
| 427 |
+
)
|
| 428 |
+
|
| 429 |
+
if self.activation not in ["silu", "swish"]:
|
| 430 |
+
hidden_states_B_C = self.act(
|
| 431 |
+
self.conv1d(hidden_states_B_C.transpose(1, 2))[..., :seq_len].transpose(1, 2)
|
| 432 |
+
)
|
| 433 |
+
else:
|
| 434 |
+
hidden_states_B_C = causal_conv1d_fn(
|
| 435 |
+
x=hidden_states_B_C.transpose(1, 2),
|
| 436 |
+
weight=self.conv1d.weight.squeeze(1),
|
| 437 |
+
bias=self.conv1d.bias,
|
| 438 |
+
activation=self.activation,
|
| 439 |
+
).transpose(1, 2)
|
| 440 |
+
|
| 441 |
+
hidden_states_B_C = apply_mask_to_padding_states(hidden_states_B_C, attention_mask)
|
| 442 |
+
hidden_states, B, C = torch.split(
|
| 443 |
+
hidden_states_B_C,
|
| 444 |
+
[self.intermediate_size, groups_time_state_size, groups_time_state_size],
|
| 445 |
+
dim=-1,
|
| 446 |
+
)
|
| 447 |
+
|
| 448 |
+
# 3. SSM transformation
|
| 449 |
+
scan_output, ssm_state = mamba_chunk_scan_combined(
|
| 450 |
+
hidden_states.view(batch_size, seq_len, -1, self.head_dim),
|
| 451 |
+
dt,
|
| 452 |
+
A,
|
| 453 |
+
B.view(batch_size, seq_len, self.n_groups, -1),
|
| 454 |
+
C.view(batch_size, seq_len, self.n_groups, -1),
|
| 455 |
+
chunk_size=self.chunk_size,
|
| 456 |
+
D=self.D,
|
| 457 |
+
z=None,
|
| 458 |
+
seq_idx=None,
|
| 459 |
+
return_final_states=True,
|
| 460 |
+
dt_bias=self.dt_bias,
|
| 461 |
+
dt_softplus=True,
|
| 462 |
+
**dt_limit_kwargs,
|
| 463 |
+
)
|
| 464 |
+
|
| 465 |
+
# Init cache
|
| 466 |
+
if ssm_state is not None and cache_params is not None:
|
| 467 |
+
cache_params.update_ssm_state(layer_idx=self.layer_idx, new_ssm_state=ssm_state)
|
| 468 |
+
|
| 469 |
+
scan_output = scan_output.view(batch_size, seq_len, -1)
|
| 470 |
+
# Multiply "gate" branch and apply extra normalization layer
|
| 471 |
+
scan_output = self.norm(scan_output, gate)
|
| 472 |
+
|
| 473 |
+
# 4. Final linear projection
|
| 474 |
+
out = self.out_proj(scan_output)
|
| 475 |
+
return out
|
| 476 |
+
|
| 477 |
+
# fmt: off
|
| 478 |
+
def torch_forward(self, input_states, cache_params: Optional[Mamba2Cache]=None, cache_position:Optional[torch.LongTensor]=None, attention_mask: Optional[torch.Tensor]=None):
|
| 479 |
+
batch_size, seq_len, _ = input_states.shape
|
| 480 |
+
dtype = input_states.dtype
|
| 481 |
+
|
| 482 |
+
# 1. Gated MLP's linear projection
|
| 483 |
+
input_states = apply_mask_to_padding_states(input_states, attention_mask)
|
| 484 |
+
projected_states = self.in_proj(input_states)
|
| 485 |
+
d_mlp = (projected_states.shape[-1] - 2 * self.intermediate_size - 2 * self.n_groups * self.ssm_state_size-self.num_heads) // 2
|
| 486 |
+
_, _, gate, hidden_states_B_C, dt = projected_states.split(
|
| 487 |
+
[d_mlp, d_mlp, self.intermediate_size, self.conv_dim, self.num_heads], dim=-1
|
| 488 |
+
)
|
| 489 |
+
|
| 490 |
+
# 2. Convolution sequence transformation
|
| 491 |
+
if cache_params is not None and cache_position is not None and cache_position[0] > 0:
|
| 492 |
+
cache_params.update_conv_state(layer_idx=self.layer_idx, new_conv_state=hidden_states_B_C, cache_init=False)
|
| 493 |
+
|
| 494 |
+
# We need to guarantee that anything regarding the cache is on the same device
|
| 495 |
+
conv_states = cache_params.conv_states[self.layer_idx].to(device=self.conv1d.weight.device)
|
| 496 |
+
|
| 497 |
+
hidden_states_B_C = torch.sum(
|
| 498 |
+
conv_states * self.conv1d.weight.squeeze(1), dim=-1
|
| 499 |
+
)
|
| 500 |
+
if self.use_conv_bias:
|
| 501 |
+
hidden_states_B_C = hidden_states_B_C + self.conv1d.bias
|
| 502 |
+
hidden_states_B_C = self.act(hidden_states_B_C)
|
| 503 |
+
else:
|
| 504 |
+
# Init cache
|
| 505 |
+
if cache_params is not None:
|
| 506 |
+
hidden_states_B_C_transposed = hidden_states_B_C.transpose(1, 2)
|
| 507 |
+
conv_states = nn.functional.pad(
|
| 508 |
+
hidden_states_B_C_transposed, (cache_params.conv_kernel_size - hidden_states_B_C_transposed.shape[-1], 0)
|
| 509 |
+
)
|
| 510 |
+
cache_params.update_conv_state(layer_idx=self.layer_idx, new_conv_state=conv_states, cache_init=True)
|
| 511 |
+
|
| 512 |
+
hidden_states_B_C = self.act(self.conv1d(hidden_states_B_C.transpose(1, 2))[..., :seq_len].transpose(1, 2))
|
| 513 |
+
|
| 514 |
+
hidden_states_B_C = apply_mask_to_padding_states(hidden_states_B_C, attention_mask)
|
| 515 |
+
hidden_states, B, C = torch.split(
|
| 516 |
+
hidden_states_B_C,
|
| 517 |
+
[self.intermediate_size, self.n_groups * self.ssm_state_size, self.n_groups * self.ssm_state_size],
|
| 518 |
+
dim=-1
|
| 519 |
+
)
|
| 520 |
+
|
| 521 |
+
# 3. SSM transformation
|
| 522 |
+
A = -torch.exp(self.A_log.float()) # [num_heads]
|
| 523 |
+
if cache_params is not None and cache_position is not None and cache_position[0] > 0:
|
| 524 |
+
# We need to guarantee that anything regarding the cache is on the same device
|
| 525 |
+
cache_device = cache_params.ssm_states.device
|
| 526 |
+
|
| 527 |
+
# Note: there is no need to pad parameter matrices here, as there is just one new token
|
| 528 |
+
# for batched generation
|
| 529 |
+
dt = dt[:, 0, :][:, None, ...]
|
| 530 |
+
dt = dt.transpose(1, 2).expand(batch_size, dt.shape[-1], self.head_dim)
|
| 531 |
+
# [num_heads] -> [num_heads, head_dim]
|
| 532 |
+
dt_bias = self.dt_bias[..., None].expand(self.dt_bias.shape[0], self.head_dim)
|
| 533 |
+
|
| 534 |
+
dt = torch.nn.functional.softplus(dt + dt_bias.to(dt.dtype))
|
| 535 |
+
dt = torch.clamp(dt, self.time_step_limit[0], self.time_step_limit[1])
|
| 536 |
+
A = A[..., None, None].expand(self.num_heads, self.head_dim, self.ssm_state_size).to(dtype=torch.float32)
|
| 537 |
+
# [bsz, num_heads, head_dim, state_size]
|
| 538 |
+
dA = (torch.exp(dt[..., None] * A)).to(device=cache_device)
|
| 539 |
+
|
| 540 |
+
# Discretize B
|
| 541 |
+
# [bsz, n_groups * state_size] -> [bsz, n_groups, 1, state_size] ->
|
| 542 |
+
# -> [bsz, n_groups, group to head repetition factor, state_size] -> [bsz, num_heads, state_size]
|
| 543 |
+
B = B.reshape(batch_size, self.n_groups, -1)[..., None, :]
|
| 544 |
+
B = B.expand(batch_size, self.n_groups, self.num_heads // self.n_groups, B.shape[-1]).contiguous()
|
| 545 |
+
B = B.reshape(batch_size, -1, B.shape[-1])
|
| 546 |
+
# [bsz, num_heads, head_dim, state_size]
|
| 547 |
+
dB = dt[..., None] * B[..., None, :]
|
| 548 |
+
|
| 549 |
+
# Discretize x into dB
|
| 550 |
+
# [bsz, intermediate_size] -> [bsz, num_heads, head_dim]
|
| 551 |
+
hidden_states = hidden_states.reshape(batch_size, -1, self.head_dim)
|
| 552 |
+
dBx = (dB * hidden_states[..., None]).to(device=cache_device)
|
| 553 |
+
|
| 554 |
+
# State calculation
|
| 555 |
+
cache_params.update_ssm_state(
|
| 556 |
+
layer_idx=self.layer_idx,
|
| 557 |
+
new_ssm_state=cache_params.ssm_states[self.layer_idx] * dA + dBx
|
| 558 |
+
)
|
| 559 |
+
|
| 560 |
+
# Subsequent output
|
| 561 |
+
# [bsz, n_groups * state_size] -> [bsz, num_heads, state_size]
|
| 562 |
+
C = C.reshape(batch_size, self.n_groups, -1)[..., None, :]
|
| 563 |
+
C = C.expand(batch_size, self.n_groups, self.num_heads // self.n_groups, C.shape[-1]).contiguous()
|
| 564 |
+
C = C.reshape(batch_size, -1, C.shape[-1])
|
| 565 |
+
# [bsz, num_heads, head_dim]
|
| 566 |
+
|
| 567 |
+
ssm_states = cache_params.ssm_states[self.layer_idx].to(device=C.device, dtype=C.dtype) # Shape: [b, h, d, n]
|
| 568 |
+
# Reshape ssm_states to merge the first two dimensions
|
| 569 |
+
ssm_states_reshaped = ssm_states.view(batch_size * self.num_heads, self.head_dim, self.ssm_state_size) # Shape: [b*h, d, n]
|
| 570 |
+
C_reshaped = C.view(batch_size * self.num_heads, self.ssm_state_size, 1) # Shape: [b*h, n, 1]
|
| 571 |
+
y = torch.bmm(ssm_states_reshaped, C_reshaped)
|
| 572 |
+
y = y.view(batch_size, self.num_heads, self.head_dim)
|
| 573 |
+
|
| 574 |
+
# D skip connection
|
| 575 |
+
# [num_heads] -> [num_heads, head_dim]
|
| 576 |
+
D = self.D[..., None].expand(self.D.shape[0], self.head_dim)
|
| 577 |
+
y = (y + hidden_states * D).to(y.dtype)
|
| 578 |
+
|
| 579 |
+
# [bsz, num_heads, head_dim] -> [bsz, 1, intermediate_size]
|
| 580 |
+
y = y.reshape(batch_size, -1)[:, None, ...]
|
| 581 |
+
else:
|
| 582 |
+
# begin ssd naive implementation without einsums
|
| 583 |
+
dt = nn.functional.softplus(dt + self.dt_bias)
|
| 584 |
+
dt = torch.clamp(dt, self.time_step_limit[0], self.time_step_limit[1])
|
| 585 |
+
hidden_states = hidden_states.reshape(batch_size, seq_len, -1, self.head_dim).float()
|
| 586 |
+
B = B.reshape(batch_size, seq_len, -1, self.ssm_state_size).float()
|
| 587 |
+
C = C.reshape(batch_size, seq_len, -1, self.ssm_state_size).float()
|
| 588 |
+
B = B.repeat(1, 1, self.num_heads // self.n_groups, 1)
|
| 589 |
+
C = C.repeat(1, 1, self.num_heads // self.n_groups, 1)
|
| 590 |
+
pad_size = (self.chunk_size - seq_len % self.chunk_size) % self.chunk_size
|
| 591 |
+
|
| 592 |
+
D_residual = self.D[..., None] * pad_tensor_by_size(hidden_states, pad_size)
|
| 593 |
+
|
| 594 |
+
# Discretize x and A
|
| 595 |
+
hidden_states = hidden_states * dt[..., None]
|
| 596 |
+
A = A.to(hidden_states.dtype) * dt
|
| 597 |
+
|
| 598 |
+
# Rearrange into blocks/chunks
|
| 599 |
+
hidden_states, A, B, C = [reshape_into_chunks(t, pad_size, self.chunk_size) for t in (hidden_states, A, B, C)]
|
| 600 |
+
|
| 601 |
+
# [bsz, -1, chunk_size, num_heads] -> [bsz, num_heads, -1, chunk_size]
|
| 602 |
+
A = A.permute(0, 3, 1, 2)
|
| 603 |
+
A_cumsum = torch.cumsum(A, dim=-1)
|
| 604 |
+
|
| 605 |
+
# 1. Compute the output for each intra-chunk (diagonal blocks)
|
| 606 |
+
# This is the analog of a causal mask
|
| 607 |
+
L = torch.exp(segment_sum(A))
|
| 608 |
+
|
| 609 |
+
# Contraction of C and B to get G (attention-weights like)
|
| 610 |
+
G_intermediate = C[:, :, :, None, :, :] * B[:, :, None, :, :, :] # shape: (b, c, l, s, h, n)
|
| 611 |
+
G = G_intermediate.sum(dim=-1) # shape: (b, c, l, s, h)
|
| 612 |
+
|
| 613 |
+
# Compute M, equivalent to applying attention mask to weights
|
| 614 |
+
M_intermediate = G[..., None] * L.permute(0, 2, 3, 4, 1)[..., None]
|
| 615 |
+
M = M_intermediate.sum(dim=-1)
|
| 616 |
+
|
| 617 |
+
# Compute Y_diag (apply to values)
|
| 618 |
+
Y_diag = (M[..., None] * hidden_states[:, :, None]).sum(dim=3)
|
| 619 |
+
|
| 620 |
+
# 2. Compute the state for each intra-chunk
|
| 621 |
+
# (right term of low-rank factorization of off-diagonal blocks; B terms)
|
| 622 |
+
decay_states = torch.exp((A_cumsum[:, :, :, -1:] - A_cumsum))
|
| 623 |
+
B_decay = B * decay_states.permute(0, -2, -1, 1)[..., None]
|
| 624 |
+
states = (B_decay[..., None, :] * hidden_states[..., None]).sum(dim=2)
|
| 625 |
+
|
| 626 |
+
# 3. Compute the inter-chunk SSM recurrence; produces correct SSM states at chunk boundaries
|
| 627 |
+
# (middle term of factorization of off-diag blocks; A terms)
|
| 628 |
+
if cache_params is not None and cache_position is not None and cache_position[0] > 0:
|
| 629 |
+
previous_states = cache_params.ssm_states[self.layer_idx][:, None, ...].to(device=states.device)
|
| 630 |
+
else:
|
| 631 |
+
previous_states = torch.zeros_like(states[:, :1])
|
| 632 |
+
states = torch.cat([previous_states, states], dim=1)
|
| 633 |
+
decay_chunk = torch.exp(segment_sum(nn.functional.pad(A_cumsum[:, :, :, -1], (1, 0))))
|
| 634 |
+
decay_chunk = decay_chunk.transpose(1, 3)
|
| 635 |
+
new_states = (decay_chunk[..., None, None] * states[:, :, None, ...]).sum(dim=1)
|
| 636 |
+
states, ssm_state = new_states[:, :-1], new_states[:, -1]
|
| 637 |
+
|
| 638 |
+
# 4. Compute state -> output conversion per chunk
|
| 639 |
+
# (left term of low-rank factorization of off-diagonal blocks; C terms)
|
| 640 |
+
state_decay_out = torch.exp(A_cumsum)
|
| 641 |
+
C_times_states = (C[..., None, :] * states[:, :, None, ...])
|
| 642 |
+
state_decay_out_permuted = state_decay_out.permute(0, 2, 3, 1)
|
| 643 |
+
Y_off = (C_times_states.sum(-1) * state_decay_out_permuted[..., None])
|
| 644 |
+
|
| 645 |
+
# Add output of intra-chunk and inter-chunk terms (diagonal and off-diagonal blocks)
|
| 646 |
+
y = Y_diag + Y_off
|
| 647 |
+
# [bsz, -1, self.chunk_size, num_heads, head_dim] -> [bsz, (padded) seq_len, num_heads, head_dim]
|
| 648 |
+
y = y.reshape(batch_size, -1, self.num_heads, self.head_dim)
|
| 649 |
+
|
| 650 |
+
y = y + D_residual
|
| 651 |
+
# Cutting off padded chunks
|
| 652 |
+
if pad_size > 0:
|
| 653 |
+
y = y[:, :seq_len, :, :]
|
| 654 |
+
y = y.reshape(batch_size, seq_len, -1)
|
| 655 |
+
|
| 656 |
+
# Init cache
|
| 657 |
+
if ssm_state is not None and cache_params is not None:
|
| 658 |
+
cache_params.update_ssm_state(layer_idx=self.layer_idx, new_ssm_state=ssm_state)
|
| 659 |
+
|
| 660 |
+
scan_output = self.norm(y, gate)
|
| 661 |
+
|
| 662 |
+
# end ssd naive
|
| 663 |
+
|
| 664 |
+
# 4. Final linear projection
|
| 665 |
+
contextualized_states = self.out_proj(scan_output.to(dtype)) # [batch, seq_len, hidden_size]
|
| 666 |
+
return contextualized_states
|
| 667 |
+
# fmt: on
|
| 668 |
+
|
| 669 |
+
def forward(
|
| 670 |
+
self,
|
| 671 |
+
hidden_states,
|
| 672 |
+
cache_params: Optional[Mamba2Cache] = None,
|
| 673 |
+
cache_position: Optional[torch.LongTensor] = None,
|
| 674 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 675 |
+
):
|
| 676 |
+
if is_fast_path_available and "cuda" in self.in_proj.weight.device.type:
|
| 677 |
+
return self.cuda_kernels_forward(hidden_states, cache_params, cache_position, attention_mask)
|
| 678 |
+
dtype = hidden_states.dtype
|
| 679 |
+
if attention_mask is not None and attention_mask.shape[1] > 1 and attention_mask.shape[0] > 1:
|
| 680 |
+
# tune out hidden states for pad tokens, see https://github.com/state-spaces/mamba/issues/66
|
| 681 |
+
hidden_states = (hidden_states * attention_mask[:, :, None]).to(dtype)
|
| 682 |
+
|
| 683 |
+
return self.torch_forward(hidden_states, cache_params, cache_position, attention_mask)
|
| 684 |
+
|
| 685 |
+
|
| 686 |
+
class Mamba2RMSNorm(nn.Module):
|
| 687 |
+
def __init__(self, hidden_size, eps=1e-6):
|
| 688 |
+
"""
|
| 689 |
+
Mamba2RMSNorm is equivalent to T5LayerNorm and LlamaRMSNorm
|
| 690 |
+
"""
|
| 691 |
+
super().__init__()
|
| 692 |
+
self.weight = nn.Parameter(torch.ones(hidden_size))
|
| 693 |
+
self.variance_epsilon = eps
|
| 694 |
+
|
| 695 |
+
def forward(self, hidden_states):
|
| 696 |
+
input_dtype = hidden_states.dtype
|
| 697 |
+
hidden_states = hidden_states.to(torch.float32)
|
| 698 |
+
variance = hidden_states.pow(2).mean(-1, keepdim=True)
|
| 699 |
+
hidden_states = hidden_states * torch.rsqrt(variance + self.variance_epsilon)
|
| 700 |
+
return self.weight * hidden_states.to(input_dtype)
|
| 701 |
+
|
| 702 |
+
|
| 703 |
+
class Mamba2Block(nn.Module):
|
| 704 |
+
def __init__(self, config, layer_idx):
|
| 705 |
+
super().__init__()
|
| 706 |
+
self.config = config
|
| 707 |
+
self.layer_idx = layer_idx
|
| 708 |
+
self.residual_in_fp32 = config.residual_in_fp32
|
| 709 |
+
self.norm = Mamba2RMSNorm(config.hidden_size, eps=config.layer_norm_epsilon)
|
| 710 |
+
self.mixer = Mamba2Mixer(config, layer_idx=layer_idx)
|
| 711 |
+
|
| 712 |
+
def forward(
|
| 713 |
+
self,
|
| 714 |
+
hidden_states,
|
| 715 |
+
cache_params: Optional[Mamba2Cache] = None,
|
| 716 |
+
cache_position: Optional[torch.LongTensor] = None,
|
| 717 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 718 |
+
):
|
| 719 |
+
residual = hidden_states
|
| 720 |
+
hidden_states = self.norm(hidden_states.to(dtype=self.norm.weight.dtype))
|
| 721 |
+
if self.residual_in_fp32:
|
| 722 |
+
residual = residual.to(torch.float32)
|
| 723 |
+
|
| 724 |
+
hidden_states = self.mixer(
|
| 725 |
+
hidden_states, cache_params=cache_params, cache_position=cache_position, attention_mask=attention_mask
|
| 726 |
+
)
|
| 727 |
+
hidden_states = residual + hidden_states
|
| 728 |
+
return hidden_states
|
| 729 |
+
|
| 730 |
+
|
| 731 |
+
class Mamba2PreTrainedModel(PreTrainedModel):
|
| 732 |
+
"""
|
| 733 |
+
An abstract class to handle weights initialization and a simple interface for downloading and loading pretrained
|
| 734 |
+
models.
|
| 735 |
+
"""
|
| 736 |
+
|
| 737 |
+
config_class = Mamba2Config
|
| 738 |
+
base_model_prefix = "backbone"
|
| 739 |
+
_no_split_modules = ["Mamba2Block"]
|
| 740 |
+
supports_gradient_checkpointing = True
|
| 741 |
+
_is_stateful = True
|
| 742 |
+
|
| 743 |
+
def _init_weights(self, module):
|
| 744 |
+
"""Initialize the weights."""
|
| 745 |
+
if isinstance(module, Mamba2Mixer):
|
| 746 |
+
module.A_log._no_weight_decay = True
|
| 747 |
+
module.D._no_weight_decay = True
|
| 748 |
+
|
| 749 |
+
dt = torch.exp(
|
| 750 |
+
torch.rand(self.config.num_heads)
|
| 751 |
+
* (math.log(self.config.time_step_max) - math.log(self.config.time_step_min))
|
| 752 |
+
+ math.log(self.config.time_step_min)
|
| 753 |
+
).clamp(min=self.config.time_step_floor)
|
| 754 |
+
|
| 755 |
+
# # Inverse of softplus: https://github.com/pytorch/pytorch/issues/72759
|
| 756 |
+
inv_dt = dt + torch.log(-torch.expm1(-dt))
|
| 757 |
+
with torch.no_grad():
|
| 758 |
+
module.dt_bias.copy_(inv_dt)
|
| 759 |
+
module.dt_bias._no_reinit = True
|
| 760 |
+
|
| 761 |
+
if isinstance(module, nn.Linear):
|
| 762 |
+
if module.bias is not None:
|
| 763 |
+
if not getattr(module.bias, "_no_reinit", False):
|
| 764 |
+
nn.init.zeros_(module.bias)
|
| 765 |
+
elif isinstance(module, nn.Embedding):
|
| 766 |
+
nn.init.normal_(module.weight, std=self.config.initializer_range)
|
| 767 |
+
|
| 768 |
+
if self.config.rescale_prenorm_residual:
|
| 769 |
+
# Reinitialize selected weights subject to the OpenAI GPT-2 Paper Scheme:
|
| 770 |
+
# > A modified initialization which accounts for the accumulation on the residual path with model depth. Scale
|
| 771 |
+
# > the weights of residual layers at initialization by a factor of 1/√N where N is the # of residual layers.
|
| 772 |
+
# > -- GPT-2 :: https://openai.com/blog/better-language-models/
|
| 773 |
+
#
|
| 774 |
+
# Reference (Megatron-LM): https://github.com/NVIDIA/Megatron-LM/blob/main/megatron/model/gpt_model.py
|
| 775 |
+
for name, p in module.named_parameters():
|
| 776 |
+
if name in ["out_proj.weight"]:
|
| 777 |
+
# Special Scaled Initialization --> There are 2 Layer Norms per Transformer Block
|
| 778 |
+
# Following Pytorch init, except scale by 1/sqrt(2 * n_layer)
|
| 779 |
+
# We need to reinit p since this code could be called multiple times
|
| 780 |
+
# Having just p *= scale would repeatedly scale it down
|
| 781 |
+
nn.init.kaiming_uniform_(p, a=math.sqrt(5))
|
| 782 |
+
with torch.no_grad():
|
| 783 |
+
p /= math.sqrt(self.config.num_hidden_layers)
|
| 784 |
+
|
| 785 |
+
|
| 786 |
+
@dataclass
|
| 787 |
+
# Copied from transformers.models.mamba.modeling_mamba.MambaOutput with MAMBA->MAMBA2,Mamba->Mamba2
|
| 788 |
+
class Mamba2Output(ModelOutput):
|
| 789 |
+
"""
|
| 790 |
+
Class for the MAMBA2 model outputs.
|
| 791 |
+
|
| 792 |
+
Args:
|
| 793 |
+
last_hidden_state (`torch.FloatTensor` of shape `(batch_size, sequence_length, hidden_size)`):
|
| 794 |
+
Sequence of hidden-states at the output of the last layer of the model.
|
| 795 |
+
cache_params (`Mamba2Cache`):
|
| 796 |
+
The state of the model at the last time step. Can be used in a forward method with the next `input_ids` to
|
| 797 |
+
avoid providing the old `input_ids`.
|
| 798 |
+
|
| 799 |
+
Includes both the State space model state matrices after the selective scan, and the Convolutional states
|
| 800 |
+
hidden_states (`tuple(torch.FloatTensor)`, *optional*, returned when `output_hidden_states=True` is passed or when `config.output_hidden_states=True`):
|
| 801 |
+
Tuple of `torch.FloatTensor` (one for the output of the embeddings, if the model has an embedding layer, +
|
| 802 |
+
one for the output of each layer) of shape `(batch_size, sequence_length, hidden_size)`.
|
| 803 |
+
|
| 804 |
+
Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.
|
| 805 |
+
"""
|
| 806 |
+
|
| 807 |
+
last_hidden_state: Optional[torch.FloatTensor] = None
|
| 808 |
+
cache_params: Optional[Mamba2Cache] = None
|
| 809 |
+
hidden_states: Optional[Tuple[torch.FloatTensor]] = None
|
| 810 |
+
|
| 811 |
+
|
| 812 |
+
@dataclass
|
| 813 |
+
# Copied from transformers.models.mamba.modeling_mamba.MambaCausalLMOutput with Mamba->Mamba2
|
| 814 |
+
class Mamba2CausalLMOutput(ModelOutput):
|
| 815 |
+
"""
|
| 816 |
+
Base class for causal language model (or autoregressive) outputs.
|
| 817 |
+
|
| 818 |
+
Args:
|
| 819 |
+
loss (`torch.FloatTensor` of shape `(1,)`, *optional*, returned when `labels` is provided):
|
| 820 |
+
Language modeling loss (for next-token prediction).
|
| 821 |
+
logits (`torch.FloatTensor` of shape `(batch_size, sequence_length, config.vocab_size)`):
|
| 822 |
+
Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax).
|
| 823 |
+
cache_params (`Mamba2Cache`):
|
| 824 |
+
The state of the model at the last time step. Can be used in a forward method with the next `input_ids` to
|
| 825 |
+
avoid providing the old `input_ids`.
|
| 826 |
+
|
| 827 |
+
Includes both the State space model state matrices after the selective scan, and the Convolutional states
|
| 828 |
+
hidden_states (`tuple(torch.FloatTensor)`, *optional*, returned when `output_hidden_states=True` is passed or when `config.output_hidden_states=True`):
|
| 829 |
+
Tuple of `torch.FloatTensor` (one for the output of the embeddings, if the model has an embedding layer, +
|
| 830 |
+
one for the output of each layer) of shape `(batch_size, sequence_length, hidden_size)`.
|
| 831 |
+
|
| 832 |
+
Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.
|
| 833 |
+
"""
|
| 834 |
+
|
| 835 |
+
loss: Optional[torch.FloatTensor] = None
|
| 836 |
+
logits: Optional[torch.FloatTensor] = None
|
| 837 |
+
cache_params: Optional[Mamba2Cache] = None
|
| 838 |
+
hidden_states: Optional[Tuple[torch.FloatTensor]] = None
|
| 839 |
+
|
| 840 |
+
|
| 841 |
+
MAMBA2_START_DOCSTRING = r"""
|
| 842 |
+
|
| 843 |
+
This model inherits from [`PreTrainedModel`]. Check the superclass documentation for the generic methods the
|
| 844 |
+
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
|
| 845 |
+
etc.)
|
| 846 |
+
|
| 847 |
+
This model is also a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) subclass.
|
| 848 |
+
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
|
| 849 |
+
and behavior.
|
| 850 |
+
|
| 851 |
+
Parameters:
|
| 852 |
+
config ([`Mamba2Config`]): Model configuration class with all the parameters of the model.
|
| 853 |
+
Initializing with a config file does not load the weights associated with the model, only the
|
| 854 |
+
configuration. Check out the [`~PreTrainedModel.from_pretrained`] method to load the model weights.
|
| 855 |
+
"""
|
| 856 |
+
|
| 857 |
+
MAMBA2_INPUTS_DOCSTRING = r"""
|
| 858 |
+
Args:
|
| 859 |
+
input_ids (`torch.LongTensor` of shape `(batch_size, input_ids_length)`):
|
| 860 |
+
Indices of input sequence tokens in the vocabulary.
|
| 861 |
+
|
| 862 |
+
If `cache_params.seqlen_offset>0`, only `input_ids` that do not have their past calculated should be passed as
|
| 863 |
+
`input_ids`.
|
| 864 |
+
|
| 865 |
+
Indices can be obtained using [`AutoTokenizer`]. See [`PreTrainedTokenizer.encode`] and
|
| 866 |
+
[`PreTrainedTokenizer.__call__`] for details.
|
| 867 |
+
|
| 868 |
+
[What are input IDs?](../glossary#input-ids)
|
| 869 |
+
inputs_embeds (`torch.FloatTensor` of shape `(batch_size, sequence_length, hidden_size)`, *optional*):
|
| 870 |
+
Optionally, instead of passing `input_ids` you can choose to directly pass an embedded representation. This
|
| 871 |
+
is useful if you want more control over how to convert `input_ids` indices into associated vectors than the
|
| 872 |
+
model's internal embedding lookup matrix.
|
| 873 |
+
cache_params (`Mamba2Cache`, *optional*):
|
| 874 |
+
If passed along, the model uses the previous state in all the blocks (which will give the output for the
|
| 875 |
+
`input_ids` provided as if the model add `state_input_ids + input_ids` as context).
|
| 876 |
+
use_cache (`bool`, *optional*):
|
| 877 |
+
If set to `True`, the `cache_params` is returned and can be used to quickly generate the next logits.
|
| 878 |
+
output_hidden_states (`bool`, *optional*):
|
| 879 |
+
Whether or not to return the hidden states of all layers. See `hidden_states` under returned tensors for
|
| 880 |
+
more detail.
|
| 881 |
+
return_dict (`bool`, *optional*):
|
| 882 |
+
Whether or not to return a [`~utils.ModelOutput`] instead of a plain tuple.
|
| 883 |
+
cache_position (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
|
| 884 |
+
The position of the current input in the cache. This is used to ensure that the cache is correctly updated.
|
| 885 |
+
If `cache_params` is passed, `cache_position` should also be passed.
|
| 886 |
+
attention_mask (`torch.FloatTensor` of shape `(batch_size, sequence_length)`, *optional*):
|
| 887 |
+
Mask to avoid performing attention on padding token indices. Mask values selected in `[0, 1]`:
|
| 888 |
+
|
| 889 |
+
- 1 for tokens that are **not masked**,
|
| 890 |
+
- 0 for tokens that are **masked**.
|
| 891 |
+
|
| 892 |
+
[What are attention masks?](../glossary#attention-mask)
|
| 893 |
+
"""
|
| 894 |
+
|
| 895 |
+
|
| 896 |
+
@add_start_docstrings(
|
| 897 |
+
"The bare MAMBA2 Model transformer outputting raw hidden-states without any specific head on top.",
|
| 898 |
+
MAMBA2_START_DOCSTRING,
|
| 899 |
+
)
|
| 900 |
+
class Mamba2Model(Mamba2PreTrainedModel):
|
| 901 |
+
def __init__(self, config):
|
| 902 |
+
super().__init__(config)
|
| 903 |
+
|
| 904 |
+
self.embeddings = nn.Embedding(config.vocab_size, config.hidden_size)
|
| 905 |
+
self.layers = nn.ModuleList([Mamba2Block(config, layer_idx=idx) for idx in range(config.num_hidden_layers)])
|
| 906 |
+
|
| 907 |
+
self.gradient_checkpointing = False
|
| 908 |
+
self.norm_f = Mamba2RMSNorm(config.hidden_size, eps=config.layer_norm_epsilon)
|
| 909 |
+
# Initialize weights and apply final processing
|
| 910 |
+
self._register_load_state_dict_pre_hook(self.load_hook)
|
| 911 |
+
self.post_init()
|
| 912 |
+
|
| 913 |
+
def load_hook(self, state_dict, prefix, *args):
|
| 914 |
+
for k in state_dict:
|
| 915 |
+
if "embedding." in k:
|
| 916 |
+
state_dict[k.replace("embedding.", "embeddings.")] = state_dict.pop(k)
|
| 917 |
+
break
|
| 918 |
+
|
| 919 |
+
def get_input_embeddings(self):
|
| 920 |
+
return self.embeddings
|
| 921 |
+
|
| 922 |
+
def set_input_embeddings(self, new_embeddings):
|
| 923 |
+
self.embeddings = new_embeddings
|
| 924 |
+
|
| 925 |
+
@add_start_docstrings_to_model_forward(MAMBA2_INPUTS_DOCSTRING)
|
| 926 |
+
@add_code_sample_docstrings(
|
| 927 |
+
checkpoint=_CHECKPOINT_FOR_DOC,
|
| 928 |
+
output_type=Mamba2Output,
|
| 929 |
+
config_class=_CONFIG_FOR_DOC,
|
| 930 |
+
)
|
| 931 |
+
def forward(
|
| 932 |
+
self,
|
| 933 |
+
input_ids: Optional[torch.LongTensor] = None,
|
| 934 |
+
inputs_embeds: Optional[torch.LongTensor] = None,
|
| 935 |
+
cache_params: Optional[Mamba2Cache] = None,
|
| 936 |
+
use_cache: Optional[bool] = None,
|
| 937 |
+
output_hidden_states: Optional[bool] = None,
|
| 938 |
+
return_dict: Optional[bool] = None,
|
| 939 |
+
cache_position: Optional[torch.LongTensor] = None,
|
| 940 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 941 |
+
**kwargs,
|
| 942 |
+
) -> Union[Tuple, Mamba2Output]:
|
| 943 |
+
output_hidden_states = (
|
| 944 |
+
output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
|
| 945 |
+
)
|
| 946 |
+
use_cache = use_cache if use_cache is not None else (self.config.use_cache if not self.training else False)
|
| 947 |
+
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
| 948 |
+
|
| 949 |
+
if (input_ids is None) ^ (inputs_embeds is not None): # ^ is python for xor
|
| 950 |
+
raise ValueError("You must specify exactly one of input_ids or inputs_embeds")
|
| 951 |
+
|
| 952 |
+
if inputs_embeds is None:
|
| 953 |
+
inputs_embeds = self.embeddings(input_ids)
|
| 954 |
+
|
| 955 |
+
if self.gradient_checkpointing and self.training and use_cache:
|
| 956 |
+
use_cache = False
|
| 957 |
+
|
| 958 |
+
if use_cache:
|
| 959 |
+
if cache_params is None:
|
| 960 |
+
cache_params = Mamba2Cache(
|
| 961 |
+
self.config, inputs_embeds.size(0), device=inputs_embeds.device, dtype=inputs_embeds.dtype
|
| 962 |
+
)
|
| 963 |
+
cache_position = torch.arange(0, self.config.conv_kernel, device=inputs_embeds.device)
|
| 964 |
+
elif cache_position is None:
|
| 965 |
+
# cases when we do manual forward instead of using `model.generate` which will initiate
|
| 966 |
+
# `cache_position` and makes sure it is not None, throw error here instead of doing some
|
| 967 |
+
# hack to conjecture the current cache position
|
| 968 |
+
raise ValueError(
|
| 969 |
+
"You have to specify the `cache_position` manually when `use_cache=True` and `cache_params` is passed, "
|
| 970 |
+
"you don't have to pass a `cache_params` if you are in prefilling stage because in that case it will "
|
| 971 |
+
"be initialized for you automatically"
|
| 972 |
+
)
|
| 973 |
+
else:
|
| 974 |
+
cache_params = None
|
| 975 |
+
|
| 976 |
+
hidden_states = inputs_embeds
|
| 977 |
+
all_hidden_states = () if output_hidden_states else None
|
| 978 |
+
for mixer_block in self.layers:
|
| 979 |
+
if self.gradient_checkpointing and self.training:
|
| 980 |
+
hidden_states = self._gradient_checkpointing_func(
|
| 981 |
+
mixer_block.__call__, hidden_states, cache_params, cache_position, attention_mask
|
| 982 |
+
)
|
| 983 |
+
else:
|
| 984 |
+
hidden_states = mixer_block(
|
| 985 |
+
hidden_states,
|
| 986 |
+
cache_params=cache_params,
|
| 987 |
+
cache_position=cache_position,
|
| 988 |
+
attention_mask=attention_mask,
|
| 989 |
+
)
|
| 990 |
+
|
| 991 |
+
if output_hidden_states:
|
| 992 |
+
all_hidden_states = all_hidden_states + (hidden_states,)
|
| 993 |
+
|
| 994 |
+
hidden_states = self.norm_f(hidden_states)
|
| 995 |
+
|
| 996 |
+
if output_hidden_states:
|
| 997 |
+
all_hidden_states = all_hidden_states + (hidden_states,)
|
| 998 |
+
|
| 999 |
+
if not return_dict:
|
| 1000 |
+
return tuple(v for v in [hidden_states, cache_params, all_hidden_states] if v is not None)
|
| 1001 |
+
|
| 1002 |
+
return Mamba2Output(
|
| 1003 |
+
last_hidden_state=hidden_states,
|
| 1004 |
+
cache_params=cache_params if use_cache else None,
|
| 1005 |
+
hidden_states=all_hidden_states,
|
| 1006 |
+
)
|
| 1007 |
+
|
| 1008 |
+
class Mamba2ForClassification(Mamba2PreTrainedModel):
|
| 1009 |
+
_tied_weights_keys = []
|
| 1010 |
+
|
| 1011 |
+
def __init__(self, config):
|
| 1012 |
+
super().__init__(config)
|
| 1013 |
+
self.backbone = Mamba2Model(config)
|
| 1014 |
+
self.cls_head = nn.Linear(config.hidden_size, config.num_classes, bias=False)
|
| 1015 |
+
# Initialize weights and apply final processing
|
| 1016 |
+
self.post_init()
|
| 1017 |
+
|
| 1018 |
+
def forward(
|
| 1019 |
+
self,
|
| 1020 |
+
input_ids: Optional[torch.LongTensor] = None,
|
| 1021 |
+
inputs_embeds: Optional[torch.FloatTensor] = None,
|
| 1022 |
+
cache_params: Optional[Mamba2Cache] = None,
|
| 1023 |
+
labels: Optional[torch.LongTensor] = None,
|
| 1024 |
+
output_hidden_states: Optional[bool] = None,
|
| 1025 |
+
return_dict: Optional[bool] = None,
|
| 1026 |
+
use_cache: Optional[bool] = None,
|
| 1027 |
+
cache_position: Optional[torch.Tensor] = None,
|
| 1028 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 1029 |
+
**kwargs, # for now we need this for generation
|
| 1030 |
+
):
|
| 1031 |
+
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
| 1032 |
+
|
| 1033 |
+
mamba2_outputs = self.backbone(
|
| 1034 |
+
input_ids,
|
| 1035 |
+
cache_params=cache_params,
|
| 1036 |
+
inputs_embeds=inputs_embeds,
|
| 1037 |
+
output_hidden_states=output_hidden_states,
|
| 1038 |
+
return_dict=return_dict,
|
| 1039 |
+
use_cache=use_cache,
|
| 1040 |
+
cache_position=cache_position,
|
| 1041 |
+
attention_mask=attention_mask,
|
| 1042 |
+
)
|
| 1043 |
+
hidden_states = mamba2_outputs[0]
|
| 1044 |
+
|
| 1045 |
+
logits = self.cls_head(hidden_states.to(self.cls_head.weight.dtype)).float()
|
| 1046 |
+
|
| 1047 |
+
loss = None
|
| 1048 |
+
if labels is not None:
|
| 1049 |
+
labels = labels.to(logits.device)
|
| 1050 |
+
loss_fct = CrossEntropyLoss()
|
| 1051 |
+
loss = loss_fct(logits.view(-1, logits.size(-1)), labels.view(-1))
|
| 1052 |
+
|
| 1053 |
+
if not return_dict:
|
| 1054 |
+
output = (logits,) + mamba2_outputs[1:]
|
| 1055 |
+
return ((loss,) + output) if loss is not None else output
|
| 1056 |
+
|
| 1057 |
+
return loss
|
| 1058 |
+
|
| 1059 |
+
|
| 1060 |
+
@add_start_docstrings(
|
| 1061 |
+
"""
|
| 1062 |
+
The MAMBA2 Model transformer with a language modeling head on top (linear layer with weights not tied to the input
|
| 1063 |
+
embeddings).
|
| 1064 |
+
""",
|
| 1065 |
+
MAMBA2_START_DOCSTRING,
|
| 1066 |
+
)
|
| 1067 |
+
class Mamba2ForCausalLM(Mamba2PreTrainedModel, GenerationMixin):
|
| 1068 |
+
_tied_weights_keys = []
|
| 1069 |
+
|
| 1070 |
+
def __init__(self, config):
|
| 1071 |
+
super().__init__(config)
|
| 1072 |
+
self.backbone = Mamba2Model(config)
|
| 1073 |
+
self.lm_head = nn.Linear(config.hidden_size, config.vocab_size, bias=False)
|
| 1074 |
+
# Initialize weights and apply final processing
|
| 1075 |
+
self.post_init()
|
| 1076 |
+
|
| 1077 |
+
def get_output_embeddings(self):
|
| 1078 |
+
return self.lm_head
|
| 1079 |
+
|
| 1080 |
+
def set_output_embeddings(self, new_embeddings):
|
| 1081 |
+
self.lm_head = new_embeddings
|
| 1082 |
+
|
| 1083 |
+
def get_input_embeddings(self):
|
| 1084 |
+
return self.backbone.get_input_embeddings()
|
| 1085 |
+
|
| 1086 |
+
def set_input_embeddings(self, new_embeddings):
|
| 1087 |
+
return self.backbone.set_input_embeddings(new_embeddings)
|
| 1088 |
+
|
| 1089 |
+
def prepare_inputs_for_generation(
|
| 1090 |
+
self,
|
| 1091 |
+
input_ids,
|
| 1092 |
+
inputs_embeds=None,
|
| 1093 |
+
use_cache=None,
|
| 1094 |
+
cache_params: Optional[Mamba2Cache] = None,
|
| 1095 |
+
cache_position: Optional[torch.LongTensor] = None,
|
| 1096 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 1097 |
+
**kwargs,
|
| 1098 |
+
):
|
| 1099 |
+
# Overwitten -- uses `cache_params` as opposed to `past_key_values`
|
| 1100 |
+
|
| 1101 |
+
if use_cache:
|
| 1102 |
+
# `cache_position` should have been initialized in `generate`
|
| 1103 |
+
if cache_position is None:
|
| 1104 |
+
raise ValueError(
|
| 1105 |
+
"`cache_position` should not be None as it should have been initialized in "
|
| 1106 |
+
"`model.generate`, you are responsible for passing in a valid `cache_position` if "
|
| 1107 |
+
"you are calling `prepare_inputs_for_generation` directly with `use_cache=True`"
|
| 1108 |
+
)
|
| 1109 |
+
if cache_position[0] > 0:
|
| 1110 |
+
input_ids = input_ids[:, -1][..., None]
|
| 1111 |
+
|
| 1112 |
+
if attention_mask is not None:
|
| 1113 |
+
attention_mask = None
|
| 1114 |
+
else:
|
| 1115 |
+
# we initialize the `cache_position` to full size of `conv_states` at prefill stage
|
| 1116 |
+
# considering padding will be applied when input length is shorter, and truncation
|
| 1117 |
+
# will be applied when it is longer, so it will be equivalent to always have it match
|
| 1118 |
+
# the length of `cache_params.conv_states`, which is `config.conv_kernel`
|
| 1119 |
+
cache_position = torch.arange(0, self.config.conv_kernel, device=input_ids.device)
|
| 1120 |
+
|
| 1121 |
+
if inputs_embeds is not None and cache_params is None:
|
| 1122 |
+
model_inputs = {"inputs_embeds": inputs_embeds}
|
| 1123 |
+
else:
|
| 1124 |
+
model_inputs = {"input_ids": input_ids}
|
| 1125 |
+
|
| 1126 |
+
model_inputs.update(
|
| 1127 |
+
{
|
| 1128 |
+
"attention_mask": attention_mask,
|
| 1129 |
+
"cache_params": cache_params,
|
| 1130 |
+
"use_cache": use_cache,
|
| 1131 |
+
"cache_position": cache_position,
|
| 1132 |
+
}
|
| 1133 |
+
)
|
| 1134 |
+
return model_inputs
|
| 1135 |
+
|
| 1136 |
+
@add_start_docstrings_to_model_forward(MAMBA2_INPUTS_DOCSTRING)
|
| 1137 |
+
@add_code_sample_docstrings(
|
| 1138 |
+
checkpoint=_CHECKPOINT_FOR_DOC,
|
| 1139 |
+
output_type=Mamba2CausalLMOutput,
|
| 1140 |
+
config_class=_CONFIG_FOR_DOC,
|
| 1141 |
+
)
|
| 1142 |
+
def forward(
|
| 1143 |
+
self,
|
| 1144 |
+
input_ids: Optional[torch.LongTensor] = None,
|
| 1145 |
+
inputs_embeds: Optional[torch.FloatTensor] = None,
|
| 1146 |
+
cache_params: Optional[Mamba2Cache] = None,
|
| 1147 |
+
labels: Optional[torch.LongTensor] = None,
|
| 1148 |
+
output_hidden_states: Optional[bool] = None,
|
| 1149 |
+
return_dict: Optional[bool] = None,
|
| 1150 |
+
use_cache: Optional[bool] = None,
|
| 1151 |
+
cache_position: Optional[torch.Tensor] = None,
|
| 1152 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 1153 |
+
**kwargs, # for now we need this for generation
|
| 1154 |
+
) -> Union[Tuple, Mamba2CausalLMOutput]:
|
| 1155 |
+
r"""
|
| 1156 |
+
labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
|
| 1157 |
+
Labels for language modeling. Note that the labels **are shifted** inside the model, i.e. you can set
|
| 1158 |
+
`labels = input_ids` Indices are selected in `[-100, 0, ..., config.vocab_size]` All labels set to `-100`
|
| 1159 |
+
are ignored (masked), the loss is only computed for labels in `[0, ..., config.vocab_size]`
|
| 1160 |
+
"""
|
| 1161 |
+
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
| 1162 |
+
|
| 1163 |
+
mamba2_outputs = self.backbone(
|
| 1164 |
+
input_ids,
|
| 1165 |
+
cache_params=cache_params,
|
| 1166 |
+
inputs_embeds=inputs_embeds,
|
| 1167 |
+
output_hidden_states=output_hidden_states,
|
| 1168 |
+
return_dict=return_dict,
|
| 1169 |
+
use_cache=use_cache,
|
| 1170 |
+
cache_position=cache_position,
|
| 1171 |
+
attention_mask=attention_mask,
|
| 1172 |
+
)
|
| 1173 |
+
hidden_states = mamba2_outputs[0]
|
| 1174 |
+
|
| 1175 |
+
logits = self.lm_head(hidden_states.to(self.lm_head.weight.dtype)).float()
|
| 1176 |
+
|
| 1177 |
+
loss = None
|
| 1178 |
+
if labels is not None:
|
| 1179 |
+
# move labels to correct device to enable model parallelism
|
| 1180 |
+
labels = labels.to(logits.device)
|
| 1181 |
+
# Shift so that tokens < n predict n
|
| 1182 |
+
shift_logits = logits[..., :-1, :].contiguous()
|
| 1183 |
+
shift_labels = labels[..., 1:].contiguous()
|
| 1184 |
+
# Flatten the tokens
|
| 1185 |
+
loss_fct = CrossEntropyLoss()
|
| 1186 |
+
loss = loss_fct(shift_logits.view(-1, shift_logits.size(-1)), shift_labels.view(-1))
|
| 1187 |
+
|
| 1188 |
+
if not return_dict:
|
| 1189 |
+
output = (logits,) + mamba2_outputs[1:]
|
| 1190 |
+
return ((loss,) + output) if loss is not None else output
|
| 1191 |
+
|
| 1192 |
+
return Mamba2CausalLMOutput(
|
| 1193 |
+
loss=loss,
|
| 1194 |
+
logits=logits,
|
| 1195 |
+
cache_params=mamba2_outputs.cache_params,
|
| 1196 |
+
hidden_states=mamba2_outputs.hidden_states,
|
| 1197 |
+
)
|
| 1198 |
+
|
| 1199 |
+
|
| 1200 |
+
__all__ = ["Mamba2ForCausalLM", "Mamba2Model", "Mamba2PreTrainedModel", "Mamba2Block", "Mamba2ForClassification"]
|
| 1201 |
+
|
pytorch_model-00001-of-00006.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:bbe1db915da074857b84fbd1eea6a990eb195770844ae24f7af62725aa4866fb
|
| 3 |
+
size 4922730652
|
pytorch_model-00002-of-00006.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:28c2779e626d7b0db5a28d894ac74b39772ae425cbaa4d605b18875edda4b5d4
|
| 3 |
+
size 4824198060
|
pytorch_model-00003-of-00006.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:bf334ea52672c642c0a30831338615465c126aaa479bc9d62737a333fb9609ac
|
| 3 |
+
size 4824198060
|
pytorch_model-00004-of-00006.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:cbf0d7de995170b8d96b11f5403848ec2c5407b95db678ab1df4d4b1e30cbb69
|
| 3 |
+
size 4824198060
|
pytorch_model-00005-of-00006.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0c78c040a09c773b3705a151503b3d13ab28858ff53d10f122d9e6a2de176416
|
| 3 |
+
size 4824198060
|
pytorch_model-00006-of-00006.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:29704e0815948fbb803fc0c28d9cf7d55e91c8eef5bad54e1752234a6a659f40
|
| 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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"metadata": {
|
| 3 |
+
"total_size": 29141614592
|
| 4 |
+
},
|
| 5 |
+
"weight_map": {
|
| 6 |
+
"backbone.embeddings.weight": "pytorch_model-00001-of-00006.bin",
|
| 7 |
+
"backbone.layers.0.mixer.A_log": "pytorch_model-00001-of-00006.bin",
|
| 8 |
+
"backbone.layers.0.mixer.D": "pytorch_model-00001-of-00006.bin",
|
| 9 |
+
"backbone.layers.0.mixer.conv1d.bias": "pytorch_model-00001-of-00006.bin",
|
| 10 |
+
"backbone.layers.0.mixer.conv1d.weight": "pytorch_model-00001-of-00006.bin",
|
| 11 |
+
"backbone.layers.0.mixer.dt_bias": "pytorch_model-00001-of-00006.bin",
|
| 12 |
+
"backbone.layers.0.mixer.in_proj.weight": "pytorch_model-00001-of-00006.bin",
|
| 13 |
+
"backbone.layers.0.mixer.norm.weight": "pytorch_model-00001-of-00006.bin",
|
| 14 |
+
"backbone.layers.0.mixer.out_proj.weight": "pytorch_model-00001-of-00006.bin",
|
| 15 |
+
"backbone.layers.0.norm.weight": "pytorch_model-00001-of-00006.bin",
|
| 16 |
+
"backbone.layers.1.mixer.A_log": "pytorch_model-00001-of-00006.bin",
|
| 17 |
+
"backbone.layers.1.mixer.D": "pytorch_model-00001-of-00006.bin",
|
| 18 |
+
"backbone.layers.1.mixer.conv1d.bias": "pytorch_model-00001-of-00006.bin",
|
| 19 |
+
"backbone.layers.1.mixer.conv1d.weight": "pytorch_model-00001-of-00006.bin",
|
| 20 |
+
"backbone.layers.1.mixer.dt_bias": "pytorch_model-00001-of-00006.bin",
|
| 21 |
+
"backbone.layers.1.mixer.in_proj.weight": "pytorch_model-00001-of-00006.bin",
|
| 22 |
+
"backbone.layers.1.mixer.norm.weight": "pytorch_model-00001-of-00006.bin",
|
| 23 |
+
"backbone.layers.1.mixer.out_proj.weight": "pytorch_model-00001-of-00006.bin",
|
| 24 |
+
"backbone.layers.1.norm.weight": "pytorch_model-00001-of-00006.bin",
|
| 25 |
+
"backbone.layers.10.mixer.A_log": "pytorch_model-00001-of-00006.bin",
|
| 26 |
+
"backbone.layers.10.mixer.D": "pytorch_model-00001-of-00006.bin",
|
| 27 |
+
"backbone.layers.10.mixer.conv1d.bias": "pytorch_model-00001-of-00006.bin",
|
| 28 |
+
"backbone.layers.10.mixer.conv1d.weight": "pytorch_model-00001-of-00006.bin",
|
| 29 |
+
"backbone.layers.10.mixer.dt_bias": "pytorch_model-00001-of-00006.bin",
|
| 30 |
+
"backbone.layers.10.mixer.in_proj.weight": "pytorch_model-00002-of-00006.bin",
|
| 31 |
+
"backbone.layers.10.mixer.norm.weight": "pytorch_model-00002-of-00006.bin",
|
| 32 |
+
"backbone.layers.10.mixer.out_proj.weight": "pytorch_model-00002-of-00006.bin",
|
| 33 |
+
"backbone.layers.10.norm.weight": "pytorch_model-00001-of-00006.bin",
|
| 34 |
+
"backbone.layers.11.mixer.A_log": "pytorch_model-00002-of-00006.bin",
|
| 35 |
+
"backbone.layers.11.mixer.D": "pytorch_model-00002-of-00006.bin",
|
| 36 |
+
"backbone.layers.11.mixer.conv1d.bias": "pytorch_model-00002-of-00006.bin",
|
| 37 |
+
"backbone.layers.11.mixer.conv1d.weight": "pytorch_model-00002-of-00006.bin",
|
| 38 |
+
"backbone.layers.11.mixer.dt_bias": "pytorch_model-00002-of-00006.bin",
|
| 39 |
+
"backbone.layers.11.mixer.in_proj.weight": "pytorch_model-00002-of-00006.bin",
|
| 40 |
+
"backbone.layers.11.mixer.norm.weight": "pytorch_model-00002-of-00006.bin",
|
| 41 |
+
"backbone.layers.11.mixer.out_proj.weight": "pytorch_model-00002-of-00006.bin",
|
| 42 |
+
"backbone.layers.11.norm.weight": "pytorch_model-00002-of-00006.bin",
|
| 43 |
+
"backbone.layers.12.mixer.A_log": "pytorch_model-00002-of-00006.bin",
|
| 44 |
+
"backbone.layers.12.mixer.D": "pytorch_model-00002-of-00006.bin",
|
| 45 |
+
"backbone.layers.12.mixer.conv1d.bias": "pytorch_model-00002-of-00006.bin",
|
| 46 |
+
"backbone.layers.12.mixer.conv1d.weight": "pytorch_model-00002-of-00006.bin",
|
| 47 |
+
"backbone.layers.12.mixer.dt_bias": "pytorch_model-00002-of-00006.bin",
|
| 48 |
+
"backbone.layers.12.mixer.in_proj.weight": "pytorch_model-00002-of-00006.bin",
|
| 49 |
+
"backbone.layers.12.mixer.norm.weight": "pytorch_model-00002-of-00006.bin",
|
| 50 |
+
"backbone.layers.12.mixer.out_proj.weight": "pytorch_model-00002-of-00006.bin",
|
| 51 |
+
"backbone.layers.12.norm.weight": "pytorch_model-00002-of-00006.bin",
|
| 52 |
+
"backbone.layers.13.mixer.A_log": "pytorch_model-00002-of-00006.bin",
|
| 53 |
+
"backbone.layers.13.mixer.D": "pytorch_model-00002-of-00006.bin",
|
| 54 |
+
"backbone.layers.13.mixer.conv1d.bias": "pytorch_model-00002-of-00006.bin",
|
| 55 |
+
"backbone.layers.13.mixer.conv1d.weight": "pytorch_model-00002-of-00006.bin",
|
| 56 |
+
"backbone.layers.13.mixer.dt_bias": "pytorch_model-00002-of-00006.bin",
|
| 57 |
+
"backbone.layers.13.mixer.in_proj.weight": "pytorch_model-00002-of-00006.bin",
|
| 58 |
+
"backbone.layers.13.mixer.norm.weight": "pytorch_model-00002-of-00006.bin",
|
| 59 |
+
"backbone.layers.13.mixer.out_proj.weight": "pytorch_model-00002-of-00006.bin",
|
| 60 |
+
"backbone.layers.13.norm.weight": "pytorch_model-00002-of-00006.bin",
|
| 61 |
+
"backbone.layers.14.mixer.A_log": "pytorch_model-00002-of-00006.bin",
|
| 62 |
+
"backbone.layers.14.mixer.D": "pytorch_model-00002-of-00006.bin",
|
| 63 |
+
"backbone.layers.14.mixer.conv1d.bias": "pytorch_model-00002-of-00006.bin",
|
| 64 |
+
"backbone.layers.14.mixer.conv1d.weight": "pytorch_model-00002-of-00006.bin",
|
| 65 |
+
"backbone.layers.14.mixer.dt_bias": "pytorch_model-00002-of-00006.bin",
|
| 66 |
+
"backbone.layers.14.mixer.in_proj.weight": "pytorch_model-00002-of-00006.bin",
|
| 67 |
+
"backbone.layers.14.mixer.norm.weight": "pytorch_model-00002-of-00006.bin",
|
| 68 |
+
"backbone.layers.14.mixer.out_proj.weight": "pytorch_model-00002-of-00006.bin",
|
| 69 |
+
"backbone.layers.14.norm.weight": "pytorch_model-00002-of-00006.bin",
|
| 70 |
+
"backbone.layers.15.mixer.A_log": "pytorch_model-00002-of-00006.bin",
|
| 71 |
+
"backbone.layers.15.mixer.D": "pytorch_model-00002-of-00006.bin",
|
| 72 |
+
"backbone.layers.15.mixer.conv1d.bias": "pytorch_model-00002-of-00006.bin",
|
| 73 |
+
"backbone.layers.15.mixer.conv1d.weight": "pytorch_model-00002-of-00006.bin",
|
| 74 |
+
"backbone.layers.15.mixer.dt_bias": "pytorch_model-00002-of-00006.bin",
|
| 75 |
+
"backbone.layers.15.mixer.in_proj.weight": "pytorch_model-00002-of-00006.bin",
|
| 76 |
+
"backbone.layers.15.mixer.norm.weight": "pytorch_model-00002-of-00006.bin",
|
| 77 |
+
"backbone.layers.15.mixer.out_proj.weight": "pytorch_model-00002-of-00006.bin",
|
| 78 |
+
"backbone.layers.15.norm.weight": "pytorch_model-00002-of-00006.bin",
|
| 79 |
+
"backbone.layers.16.mixer.A_log": "pytorch_model-00002-of-00006.bin",
|
| 80 |
+
"backbone.layers.16.mixer.D": "pytorch_model-00002-of-00006.bin",
|
| 81 |
+
"backbone.layers.16.mixer.conv1d.bias": "pytorch_model-00002-of-00006.bin",
|
| 82 |
+
"backbone.layers.16.mixer.conv1d.weight": "pytorch_model-00002-of-00006.bin",
|
| 83 |
+
"backbone.layers.16.mixer.dt_bias": "pytorch_model-00002-of-00006.bin",
|
| 84 |
+
"backbone.layers.16.mixer.in_proj.weight": "pytorch_model-00002-of-00006.bin",
|
| 85 |
+
"backbone.layers.16.mixer.norm.weight": "pytorch_model-00002-of-00006.bin",
|
| 86 |
+
"backbone.layers.16.mixer.out_proj.weight": "pytorch_model-00002-of-00006.bin",
|
| 87 |
+
"backbone.layers.16.norm.weight": "pytorch_model-00002-of-00006.bin",
|
| 88 |
+
"backbone.layers.17.mixer.A_log": "pytorch_model-00002-of-00006.bin",
|
| 89 |
+
"backbone.layers.17.mixer.D": "pytorch_model-00002-of-00006.bin",
|
| 90 |
+
"backbone.layers.17.mixer.conv1d.bias": "pytorch_model-00002-of-00006.bin",
|
| 91 |
+
"backbone.layers.17.mixer.conv1d.weight": "pytorch_model-00002-of-00006.bin",
|
| 92 |
+
"backbone.layers.17.mixer.dt_bias": "pytorch_model-00002-of-00006.bin",
|
| 93 |
+
"backbone.layers.17.mixer.in_proj.weight": "pytorch_model-00002-of-00006.bin",
|
| 94 |
+
"backbone.layers.17.mixer.norm.weight": "pytorch_model-00002-of-00006.bin",
|
| 95 |
+
"backbone.layers.17.mixer.out_proj.weight": "pytorch_model-00002-of-00006.bin",
|
| 96 |
+
"backbone.layers.17.norm.weight": "pytorch_model-00002-of-00006.bin",
|
| 97 |
+
"backbone.layers.18.mixer.A_log": "pytorch_model-00002-of-00006.bin",
|
| 98 |
+
"backbone.layers.18.mixer.D": "pytorch_model-00002-of-00006.bin",
|
| 99 |
+
"backbone.layers.18.mixer.conv1d.bias": "pytorch_model-00002-of-00006.bin",
|
| 100 |
+
"backbone.layers.18.mixer.conv1d.weight": "pytorch_model-00002-of-00006.bin",
|
| 101 |
+
"backbone.layers.18.mixer.dt_bias": "pytorch_model-00002-of-00006.bin",
|
| 102 |
+
"backbone.layers.18.mixer.in_proj.weight": "pytorch_model-00002-of-00006.bin",
|
| 103 |
+
"backbone.layers.18.mixer.norm.weight": "pytorch_model-00002-of-00006.bin",
|
| 104 |
+
"backbone.layers.18.mixer.out_proj.weight": "pytorch_model-00002-of-00006.bin",
|
| 105 |
+
"backbone.layers.18.norm.weight": "pytorch_model-00002-of-00006.bin",
|
| 106 |
+
"backbone.layers.19.mixer.A_log": "pytorch_model-00002-of-00006.bin",
|
| 107 |
+
"backbone.layers.19.mixer.D": "pytorch_model-00002-of-00006.bin",
|
| 108 |
+
"backbone.layers.19.mixer.conv1d.bias": "pytorch_model-00002-of-00006.bin",
|
| 109 |
+
"backbone.layers.19.mixer.conv1d.weight": "pytorch_model-00002-of-00006.bin",
|
| 110 |
+
"backbone.layers.19.mixer.dt_bias": "pytorch_model-00002-of-00006.bin",
|
| 111 |
+
"backbone.layers.19.mixer.in_proj.weight": "pytorch_model-00002-of-00006.bin",
|
| 112 |
+
"backbone.layers.19.mixer.norm.weight": "pytorch_model-00002-of-00006.bin",
|
| 113 |
+
"backbone.layers.19.mixer.out_proj.weight": "pytorch_model-00002-of-00006.bin",
|
| 114 |
+
"backbone.layers.19.norm.weight": "pytorch_model-00002-of-00006.bin",
|
| 115 |
+
"backbone.layers.2.mixer.A_log": "pytorch_model-00001-of-00006.bin",
|
| 116 |
+
"backbone.layers.2.mixer.D": "pytorch_model-00001-of-00006.bin",
|
| 117 |
+
"backbone.layers.2.mixer.conv1d.bias": "pytorch_model-00001-of-00006.bin",
|
| 118 |
+
"backbone.layers.2.mixer.conv1d.weight": "pytorch_model-00001-of-00006.bin",
|
| 119 |
+
"backbone.layers.2.mixer.dt_bias": "pytorch_model-00001-of-00006.bin",
|
| 120 |
+
"backbone.layers.2.mixer.in_proj.weight": "pytorch_model-00001-of-00006.bin",
|
| 121 |
+
"backbone.layers.2.mixer.norm.weight": "pytorch_model-00001-of-00006.bin",
|
| 122 |
+
"backbone.layers.2.mixer.out_proj.weight": "pytorch_model-00001-of-00006.bin",
|
| 123 |
+
"backbone.layers.2.norm.weight": "pytorch_model-00001-of-00006.bin",
|
| 124 |
+
"backbone.layers.20.mixer.A_log": "pytorch_model-00002-of-00006.bin",
|
| 125 |
+
"backbone.layers.20.mixer.D": "pytorch_model-00002-of-00006.bin",
|
| 126 |
+
"backbone.layers.20.mixer.conv1d.bias": "pytorch_model-00002-of-00006.bin",
|
| 127 |
+
"backbone.layers.20.mixer.conv1d.weight": "pytorch_model-00002-of-00006.bin",
|
| 128 |
+
"backbone.layers.20.mixer.dt_bias": "pytorch_model-00002-of-00006.bin",
|
| 129 |
+
"backbone.layers.20.mixer.in_proj.weight": "pytorch_model-00002-of-00006.bin",
|
| 130 |
+
"backbone.layers.20.mixer.norm.weight": "pytorch_model-00002-of-00006.bin",
|
| 131 |
+
"backbone.layers.20.mixer.out_proj.weight": "pytorch_model-00002-of-00006.bin",
|
| 132 |
+
"backbone.layers.20.norm.weight": "pytorch_model-00002-of-00006.bin",
|
| 133 |
+
"backbone.layers.21.mixer.A_log": "pytorch_model-00002-of-00006.bin",
|
| 134 |
+
"backbone.layers.21.mixer.D": "pytorch_model-00002-of-00006.bin",
|
| 135 |
+
"backbone.layers.21.mixer.conv1d.bias": "pytorch_model-00002-of-00006.bin",
|
| 136 |
+
"backbone.layers.21.mixer.conv1d.weight": "pytorch_model-00002-of-00006.bin",
|
| 137 |
+
"backbone.layers.21.mixer.dt_bias": "pytorch_model-00002-of-00006.bin",
|
| 138 |
+
"backbone.layers.21.mixer.in_proj.weight": "pytorch_model-00003-of-00006.bin",
|
| 139 |
+
"backbone.layers.21.mixer.norm.weight": "pytorch_model-00003-of-00006.bin",
|
| 140 |
+
"backbone.layers.21.mixer.out_proj.weight": "pytorch_model-00003-of-00006.bin",
|
| 141 |
+
"backbone.layers.21.norm.weight": "pytorch_model-00002-of-00006.bin",
|
| 142 |
+
"backbone.layers.22.mixer.A_log": "pytorch_model-00003-of-00006.bin",
|
| 143 |
+
"backbone.layers.22.mixer.D": "pytorch_model-00003-of-00006.bin",
|
| 144 |
+
"backbone.layers.22.mixer.conv1d.bias": "pytorch_model-00003-of-00006.bin",
|
| 145 |
+
"backbone.layers.22.mixer.conv1d.weight": "pytorch_model-00003-of-00006.bin",
|
| 146 |
+
"backbone.layers.22.mixer.dt_bias": "pytorch_model-00003-of-00006.bin",
|
| 147 |
+
"backbone.layers.22.mixer.in_proj.weight": "pytorch_model-00003-of-00006.bin",
|
| 148 |
+
"backbone.layers.22.mixer.norm.weight": "pytorch_model-00003-of-00006.bin",
|
| 149 |
+
"backbone.layers.22.mixer.out_proj.weight": "pytorch_model-00003-of-00006.bin",
|
| 150 |
+
"backbone.layers.22.norm.weight": "pytorch_model-00003-of-00006.bin",
|
| 151 |
+
"backbone.layers.23.mixer.A_log": "pytorch_model-00003-of-00006.bin",
|
| 152 |
+
"backbone.layers.23.mixer.D": "pytorch_model-00003-of-00006.bin",
|
| 153 |
+
"backbone.layers.23.mixer.conv1d.bias": "pytorch_model-00003-of-00006.bin",
|
| 154 |
+
"backbone.layers.23.mixer.conv1d.weight": "pytorch_model-00003-of-00006.bin",
|
| 155 |
+
"backbone.layers.23.mixer.dt_bias": "pytorch_model-00003-of-00006.bin",
|
| 156 |
+
"backbone.layers.23.mixer.in_proj.weight": "pytorch_model-00003-of-00006.bin",
|
| 157 |
+
"backbone.layers.23.mixer.norm.weight": "pytorch_model-00003-of-00006.bin",
|
| 158 |
+
"backbone.layers.23.mixer.out_proj.weight": "pytorch_model-00003-of-00006.bin",
|
| 159 |
+
"backbone.layers.23.norm.weight": "pytorch_model-00003-of-00006.bin",
|
| 160 |
+
"backbone.layers.24.mixer.A_log": "pytorch_model-00003-of-00006.bin",
|
| 161 |
+
"backbone.layers.24.mixer.D": "pytorch_model-00003-of-00006.bin",
|
| 162 |
+
"backbone.layers.24.mixer.conv1d.bias": "pytorch_model-00003-of-00006.bin",
|
| 163 |
+
"backbone.layers.24.mixer.conv1d.weight": "pytorch_model-00003-of-00006.bin",
|
| 164 |
+
"backbone.layers.24.mixer.dt_bias": "pytorch_model-00003-of-00006.bin",
|
| 165 |
+
"backbone.layers.24.mixer.in_proj.weight": "pytorch_model-00003-of-00006.bin",
|
| 166 |
+
"backbone.layers.24.mixer.norm.weight": "pytorch_model-00003-of-00006.bin",
|
| 167 |
+
"backbone.layers.24.mixer.out_proj.weight": "pytorch_model-00003-of-00006.bin",
|
| 168 |
+
"backbone.layers.24.norm.weight": "pytorch_model-00003-of-00006.bin",
|
| 169 |
+
"backbone.layers.25.mixer.A_log": "pytorch_model-00003-of-00006.bin",
|
| 170 |
+
"backbone.layers.25.mixer.D": "pytorch_model-00003-of-00006.bin",
|
| 171 |
+
"backbone.layers.25.mixer.conv1d.bias": "pytorch_model-00003-of-00006.bin",
|
| 172 |
+
"backbone.layers.25.mixer.conv1d.weight": "pytorch_model-00003-of-00006.bin",
|
| 173 |
+
"backbone.layers.25.mixer.dt_bias": "pytorch_model-00003-of-00006.bin",
|
| 174 |
+
"backbone.layers.25.mixer.in_proj.weight": "pytorch_model-00003-of-00006.bin",
|
| 175 |
+
"backbone.layers.25.mixer.norm.weight": "pytorch_model-00003-of-00006.bin",
|
| 176 |
+
"backbone.layers.25.mixer.out_proj.weight": "pytorch_model-00003-of-00006.bin",
|
| 177 |
+
"backbone.layers.25.norm.weight": "pytorch_model-00003-of-00006.bin",
|
| 178 |
+
"backbone.layers.26.mixer.A_log": "pytorch_model-00003-of-00006.bin",
|
| 179 |
+
"backbone.layers.26.mixer.D": "pytorch_model-00003-of-00006.bin",
|
| 180 |
+
"backbone.layers.26.mixer.conv1d.bias": "pytorch_model-00003-of-00006.bin",
|
| 181 |
+
"backbone.layers.26.mixer.conv1d.weight": "pytorch_model-00003-of-00006.bin",
|
| 182 |
+
"backbone.layers.26.mixer.dt_bias": "pytorch_model-00003-of-00006.bin",
|
| 183 |
+
"backbone.layers.26.mixer.in_proj.weight": "pytorch_model-00003-of-00006.bin",
|
| 184 |
+
"backbone.layers.26.mixer.norm.weight": "pytorch_model-00003-of-00006.bin",
|
| 185 |
+
"backbone.layers.26.mixer.out_proj.weight": "pytorch_model-00003-of-00006.bin",
|
| 186 |
+
"backbone.layers.26.norm.weight": "pytorch_model-00003-of-00006.bin",
|
| 187 |
+
"backbone.layers.27.mixer.A_log": "pytorch_model-00003-of-00006.bin",
|
| 188 |
+
"backbone.layers.27.mixer.D": "pytorch_model-00003-of-00006.bin",
|
| 189 |
+
"backbone.layers.27.mixer.conv1d.bias": "pytorch_model-00003-of-00006.bin",
|
| 190 |
+
"backbone.layers.27.mixer.conv1d.weight": "pytorch_model-00003-of-00006.bin",
|
| 191 |
+
"backbone.layers.27.mixer.dt_bias": "pytorch_model-00003-of-00006.bin",
|
| 192 |
+
"backbone.layers.27.mixer.in_proj.weight": "pytorch_model-00003-of-00006.bin",
|
| 193 |
+
"backbone.layers.27.mixer.norm.weight": "pytorch_model-00003-of-00006.bin",
|
| 194 |
+
"backbone.layers.27.mixer.out_proj.weight": "pytorch_model-00003-of-00006.bin",
|
| 195 |
+
"backbone.layers.27.norm.weight": "pytorch_model-00003-of-00006.bin",
|
| 196 |
+
"backbone.layers.28.mixer.A_log": "pytorch_model-00003-of-00006.bin",
|
| 197 |
+
"backbone.layers.28.mixer.D": "pytorch_model-00003-of-00006.bin",
|
| 198 |
+
"backbone.layers.28.mixer.conv1d.bias": "pytorch_model-00003-of-00006.bin",
|
| 199 |
+
"backbone.layers.28.mixer.conv1d.weight": "pytorch_model-00003-of-00006.bin",
|
| 200 |
+
"backbone.layers.28.mixer.dt_bias": "pytorch_model-00003-of-00006.bin",
|
| 201 |
+
"backbone.layers.28.mixer.in_proj.weight": "pytorch_model-00003-of-00006.bin",
|
| 202 |
+
"backbone.layers.28.mixer.norm.weight": "pytorch_model-00003-of-00006.bin",
|
| 203 |
+
"backbone.layers.28.mixer.out_proj.weight": "pytorch_model-00003-of-00006.bin",
|
| 204 |
+
"backbone.layers.28.norm.weight": "pytorch_model-00003-of-00006.bin",
|
| 205 |
+
"backbone.layers.29.mixer.A_log": "pytorch_model-00003-of-00006.bin",
|
| 206 |
+
"backbone.layers.29.mixer.D": "pytorch_model-00003-of-00006.bin",
|
| 207 |
+
"backbone.layers.29.mixer.conv1d.bias": "pytorch_model-00003-of-00006.bin",
|
| 208 |
+
"backbone.layers.29.mixer.conv1d.weight": "pytorch_model-00003-of-00006.bin",
|
| 209 |
+
"backbone.layers.29.mixer.dt_bias": "pytorch_model-00003-of-00006.bin",
|
| 210 |
+
"backbone.layers.29.mixer.in_proj.weight": "pytorch_model-00003-of-00006.bin",
|
| 211 |
+
"backbone.layers.29.mixer.norm.weight": "pytorch_model-00003-of-00006.bin",
|
| 212 |
+
"backbone.layers.29.mixer.out_proj.weight": "pytorch_model-00003-of-00006.bin",
|
| 213 |
+
"backbone.layers.29.norm.weight": "pytorch_model-00003-of-00006.bin",
|
| 214 |
+
"backbone.layers.3.mixer.A_log": "pytorch_model-00001-of-00006.bin",
|
| 215 |
+
"backbone.layers.3.mixer.D": "pytorch_model-00001-of-00006.bin",
|
| 216 |
+
"backbone.layers.3.mixer.conv1d.bias": "pytorch_model-00001-of-00006.bin",
|
| 217 |
+
"backbone.layers.3.mixer.conv1d.weight": "pytorch_model-00001-of-00006.bin",
|
| 218 |
+
"backbone.layers.3.mixer.dt_bias": "pytorch_model-00001-of-00006.bin",
|
| 219 |
+
"backbone.layers.3.mixer.in_proj.weight": "pytorch_model-00001-of-00006.bin",
|
| 220 |
+
"backbone.layers.3.mixer.norm.weight": "pytorch_model-00001-of-00006.bin",
|
| 221 |
+
"backbone.layers.3.mixer.out_proj.weight": "pytorch_model-00001-of-00006.bin",
|
| 222 |
+
"backbone.layers.3.norm.weight": "pytorch_model-00001-of-00006.bin",
|
| 223 |
+
"backbone.layers.30.mixer.A_log": "pytorch_model-00003-of-00006.bin",
|
| 224 |
+
"backbone.layers.30.mixer.D": "pytorch_model-00003-of-00006.bin",
|
| 225 |
+
"backbone.layers.30.mixer.conv1d.bias": "pytorch_model-00003-of-00006.bin",
|
| 226 |
+
"backbone.layers.30.mixer.conv1d.weight": "pytorch_model-00003-of-00006.bin",
|
| 227 |
+
"backbone.layers.30.mixer.dt_bias": "pytorch_model-00003-of-00006.bin",
|
| 228 |
+
"backbone.layers.30.mixer.in_proj.weight": "pytorch_model-00003-of-00006.bin",
|
| 229 |
+
"backbone.layers.30.mixer.norm.weight": "pytorch_model-00003-of-00006.bin",
|
| 230 |
+
"backbone.layers.30.mixer.out_proj.weight": "pytorch_model-00003-of-00006.bin",
|
| 231 |
+
"backbone.layers.30.norm.weight": "pytorch_model-00003-of-00006.bin",
|
| 232 |
+
"backbone.layers.31.mixer.A_log": "pytorch_model-00003-of-00006.bin",
|
| 233 |
+
"backbone.layers.31.mixer.D": "pytorch_model-00003-of-00006.bin",
|
| 234 |
+
"backbone.layers.31.mixer.conv1d.bias": "pytorch_model-00003-of-00006.bin",
|
| 235 |
+
"backbone.layers.31.mixer.conv1d.weight": "pytorch_model-00003-of-00006.bin",
|
| 236 |
+
"backbone.layers.31.mixer.dt_bias": "pytorch_model-00003-of-00006.bin",
|
| 237 |
+
"backbone.layers.31.mixer.in_proj.weight": "pytorch_model-00003-of-00006.bin",
|
| 238 |
+
"backbone.layers.31.mixer.norm.weight": "pytorch_model-00003-of-00006.bin",
|
| 239 |
+
"backbone.layers.31.mixer.out_proj.weight": "pytorch_model-00003-of-00006.bin",
|
| 240 |
+
"backbone.layers.31.norm.weight": "pytorch_model-00003-of-00006.bin",
|
| 241 |
+
"backbone.layers.32.mixer.A_log": "pytorch_model-00003-of-00006.bin",
|
| 242 |
+
"backbone.layers.32.mixer.D": "pytorch_model-00003-of-00006.bin",
|
| 243 |
+
"backbone.layers.32.mixer.conv1d.bias": "pytorch_model-00003-of-00006.bin",
|
| 244 |
+
"backbone.layers.32.mixer.conv1d.weight": "pytorch_model-00003-of-00006.bin",
|
| 245 |
+
"backbone.layers.32.mixer.dt_bias": "pytorch_model-00003-of-00006.bin",
|
| 246 |
+
"backbone.layers.32.mixer.in_proj.weight": "pytorch_model-00004-of-00006.bin",
|
| 247 |
+
"backbone.layers.32.mixer.norm.weight": "pytorch_model-00004-of-00006.bin",
|
| 248 |
+
"backbone.layers.32.mixer.out_proj.weight": "pytorch_model-00004-of-00006.bin",
|
| 249 |
+
"backbone.layers.32.norm.weight": "pytorch_model-00003-of-00006.bin",
|
| 250 |
+
"backbone.layers.33.mixer.A_log": "pytorch_model-00004-of-00006.bin",
|
| 251 |
+
"backbone.layers.33.mixer.D": "pytorch_model-00004-of-00006.bin",
|
| 252 |
+
"backbone.layers.33.mixer.conv1d.bias": "pytorch_model-00004-of-00006.bin",
|
| 253 |
+
"backbone.layers.33.mixer.conv1d.weight": "pytorch_model-00004-of-00006.bin",
|
| 254 |
+
"backbone.layers.33.mixer.dt_bias": "pytorch_model-00004-of-00006.bin",
|
| 255 |
+
"backbone.layers.33.mixer.in_proj.weight": "pytorch_model-00004-of-00006.bin",
|
| 256 |
+
"backbone.layers.33.mixer.norm.weight": "pytorch_model-00004-of-00006.bin",
|
| 257 |
+
"backbone.layers.33.mixer.out_proj.weight": "pytorch_model-00004-of-00006.bin",
|
| 258 |
+
"backbone.layers.33.norm.weight": "pytorch_model-00004-of-00006.bin",
|
| 259 |
+
"backbone.layers.34.mixer.A_log": "pytorch_model-00004-of-00006.bin",
|
| 260 |
+
"backbone.layers.34.mixer.D": "pytorch_model-00004-of-00006.bin",
|
| 261 |
+
"backbone.layers.34.mixer.conv1d.bias": "pytorch_model-00004-of-00006.bin",
|
| 262 |
+
"backbone.layers.34.mixer.conv1d.weight": "pytorch_model-00004-of-00006.bin",
|
| 263 |
+
"backbone.layers.34.mixer.dt_bias": "pytorch_model-00004-of-00006.bin",
|
| 264 |
+
"backbone.layers.34.mixer.in_proj.weight": "pytorch_model-00004-of-00006.bin",
|
| 265 |
+
"backbone.layers.34.mixer.norm.weight": "pytorch_model-00004-of-00006.bin",
|
| 266 |
+
"backbone.layers.34.mixer.out_proj.weight": "pytorch_model-00004-of-00006.bin",
|
| 267 |
+
"backbone.layers.34.norm.weight": "pytorch_model-00004-of-00006.bin",
|
| 268 |
+
"backbone.layers.35.mixer.A_log": "pytorch_model-00004-of-00006.bin",
|
| 269 |
+
"backbone.layers.35.mixer.D": "pytorch_model-00004-of-00006.bin",
|
| 270 |
+
"backbone.layers.35.mixer.conv1d.bias": "pytorch_model-00004-of-00006.bin",
|
| 271 |
+
"backbone.layers.35.mixer.conv1d.weight": "pytorch_model-00004-of-00006.bin",
|
| 272 |
+
"backbone.layers.35.mixer.dt_bias": "pytorch_model-00004-of-00006.bin",
|
| 273 |
+
"backbone.layers.35.mixer.in_proj.weight": "pytorch_model-00004-of-00006.bin",
|
| 274 |
+
"backbone.layers.35.mixer.norm.weight": "pytorch_model-00004-of-00006.bin",
|
| 275 |
+
"backbone.layers.35.mixer.out_proj.weight": "pytorch_model-00004-of-00006.bin",
|
| 276 |
+
"backbone.layers.35.norm.weight": "pytorch_model-00004-of-00006.bin",
|
| 277 |
+
"backbone.layers.36.mixer.A_log": "pytorch_model-00004-of-00006.bin",
|
| 278 |
+
"backbone.layers.36.mixer.D": "pytorch_model-00004-of-00006.bin",
|
| 279 |
+
"backbone.layers.36.mixer.conv1d.bias": "pytorch_model-00004-of-00006.bin",
|
| 280 |
+
"backbone.layers.36.mixer.conv1d.weight": "pytorch_model-00004-of-00006.bin",
|
| 281 |
+
"backbone.layers.36.mixer.dt_bias": "pytorch_model-00004-of-00006.bin",
|
| 282 |
+
"backbone.layers.36.mixer.in_proj.weight": "pytorch_model-00004-of-00006.bin",
|
| 283 |
+
"backbone.layers.36.mixer.norm.weight": "pytorch_model-00004-of-00006.bin",
|
| 284 |
+
"backbone.layers.36.mixer.out_proj.weight": "pytorch_model-00004-of-00006.bin",
|
| 285 |
+
"backbone.layers.36.norm.weight": "pytorch_model-00004-of-00006.bin",
|
| 286 |
+
"backbone.layers.37.mixer.A_log": "pytorch_model-00004-of-00006.bin",
|
| 287 |
+
"backbone.layers.37.mixer.D": "pytorch_model-00004-of-00006.bin",
|
| 288 |
+
"backbone.layers.37.mixer.conv1d.bias": "pytorch_model-00004-of-00006.bin",
|
| 289 |
+
"backbone.layers.37.mixer.conv1d.weight": "pytorch_model-00004-of-00006.bin",
|
| 290 |
+
"backbone.layers.37.mixer.dt_bias": "pytorch_model-00004-of-00006.bin",
|
| 291 |
+
"backbone.layers.37.mixer.in_proj.weight": "pytorch_model-00004-of-00006.bin",
|
| 292 |
+
"backbone.layers.37.mixer.norm.weight": "pytorch_model-00004-of-00006.bin",
|
| 293 |
+
"backbone.layers.37.mixer.out_proj.weight": "pytorch_model-00004-of-00006.bin",
|
| 294 |
+
"backbone.layers.37.norm.weight": "pytorch_model-00004-of-00006.bin",
|
| 295 |
+
"backbone.layers.38.mixer.A_log": "pytorch_model-00004-of-00006.bin",
|
| 296 |
+
"backbone.layers.38.mixer.D": "pytorch_model-00004-of-00006.bin",
|
| 297 |
+
"backbone.layers.38.mixer.conv1d.bias": "pytorch_model-00004-of-00006.bin",
|
| 298 |
+
"backbone.layers.38.mixer.conv1d.weight": "pytorch_model-00004-of-00006.bin",
|
| 299 |
+
"backbone.layers.38.mixer.dt_bias": "pytorch_model-00004-of-00006.bin",
|
| 300 |
+
"backbone.layers.38.mixer.in_proj.weight": "pytorch_model-00004-of-00006.bin",
|
| 301 |
+
"backbone.layers.38.mixer.norm.weight": "pytorch_model-00004-of-00006.bin",
|
| 302 |
+
"backbone.layers.38.mixer.out_proj.weight": "pytorch_model-00004-of-00006.bin",
|
| 303 |
+
"backbone.layers.38.norm.weight": "pytorch_model-00004-of-00006.bin",
|
| 304 |
+
"backbone.layers.39.mixer.A_log": "pytorch_model-00004-of-00006.bin",
|
| 305 |
+
"backbone.layers.39.mixer.D": "pytorch_model-00004-of-00006.bin",
|
| 306 |
+
"backbone.layers.39.mixer.conv1d.bias": "pytorch_model-00004-of-00006.bin",
|
| 307 |
+
"backbone.layers.39.mixer.conv1d.weight": "pytorch_model-00004-of-00006.bin",
|
| 308 |
+
"backbone.layers.39.mixer.dt_bias": "pytorch_model-00004-of-00006.bin",
|
| 309 |
+
"backbone.layers.39.mixer.in_proj.weight": "pytorch_model-00004-of-00006.bin",
|
| 310 |
+
"backbone.layers.39.mixer.norm.weight": "pytorch_model-00004-of-00006.bin",
|
| 311 |
+
"backbone.layers.39.mixer.out_proj.weight": "pytorch_model-00004-of-00006.bin",
|
| 312 |
+
"backbone.layers.39.norm.weight": "pytorch_model-00004-of-00006.bin",
|
| 313 |
+
"backbone.layers.4.mixer.A_log": "pytorch_model-00001-of-00006.bin",
|
| 314 |
+
"backbone.layers.4.mixer.D": "pytorch_model-00001-of-00006.bin",
|
| 315 |
+
"backbone.layers.4.mixer.conv1d.bias": "pytorch_model-00001-of-00006.bin",
|
| 316 |
+
"backbone.layers.4.mixer.conv1d.weight": "pytorch_model-00001-of-00006.bin",
|
| 317 |
+
"backbone.layers.4.mixer.dt_bias": "pytorch_model-00001-of-00006.bin",
|
| 318 |
+
"backbone.layers.4.mixer.in_proj.weight": "pytorch_model-00001-of-00006.bin",
|
| 319 |
+
"backbone.layers.4.mixer.norm.weight": "pytorch_model-00001-of-00006.bin",
|
| 320 |
+
"backbone.layers.4.mixer.out_proj.weight": "pytorch_model-00001-of-00006.bin",
|
| 321 |
+
"backbone.layers.4.norm.weight": "pytorch_model-00001-of-00006.bin",
|
| 322 |
+
"backbone.layers.40.mixer.A_log": "pytorch_model-00004-of-00006.bin",
|
| 323 |
+
"backbone.layers.40.mixer.D": "pytorch_model-00004-of-00006.bin",
|
| 324 |
+
"backbone.layers.40.mixer.conv1d.bias": "pytorch_model-00004-of-00006.bin",
|
| 325 |
+
"backbone.layers.40.mixer.conv1d.weight": "pytorch_model-00004-of-00006.bin",
|
| 326 |
+
"backbone.layers.40.mixer.dt_bias": "pytorch_model-00004-of-00006.bin",
|
| 327 |
+
"backbone.layers.40.mixer.in_proj.weight": "pytorch_model-00004-of-00006.bin",
|
| 328 |
+
"backbone.layers.40.mixer.norm.weight": "pytorch_model-00004-of-00006.bin",
|
| 329 |
+
"backbone.layers.40.mixer.out_proj.weight": "pytorch_model-00004-of-00006.bin",
|
| 330 |
+
"backbone.layers.40.norm.weight": "pytorch_model-00004-of-00006.bin",
|
| 331 |
+
"backbone.layers.41.mixer.A_log": "pytorch_model-00004-of-00006.bin",
|
| 332 |
+
"backbone.layers.41.mixer.D": "pytorch_model-00004-of-00006.bin",
|
| 333 |
+
"backbone.layers.41.mixer.conv1d.bias": "pytorch_model-00004-of-00006.bin",
|
| 334 |
+
"backbone.layers.41.mixer.conv1d.weight": "pytorch_model-00004-of-00006.bin",
|
| 335 |
+
"backbone.layers.41.mixer.dt_bias": "pytorch_model-00004-of-00006.bin",
|
| 336 |
+
"backbone.layers.41.mixer.in_proj.weight": "pytorch_model-00004-of-00006.bin",
|
| 337 |
+
"backbone.layers.41.mixer.norm.weight": "pytorch_model-00004-of-00006.bin",
|
| 338 |
+
"backbone.layers.41.mixer.out_proj.weight": "pytorch_model-00004-of-00006.bin",
|
| 339 |
+
"backbone.layers.41.norm.weight": "pytorch_model-00004-of-00006.bin",
|
| 340 |
+
"backbone.layers.42.mixer.A_log": "pytorch_model-00004-of-00006.bin",
|
| 341 |
+
"backbone.layers.42.mixer.D": "pytorch_model-00004-of-00006.bin",
|
| 342 |
+
"backbone.layers.42.mixer.conv1d.bias": "pytorch_model-00004-of-00006.bin",
|
| 343 |
+
"backbone.layers.42.mixer.conv1d.weight": "pytorch_model-00004-of-00006.bin",
|
| 344 |
+
"backbone.layers.42.mixer.dt_bias": "pytorch_model-00004-of-00006.bin",
|
| 345 |
+
"backbone.layers.42.mixer.in_proj.weight": "pytorch_model-00004-of-00006.bin",
|
| 346 |
+
"backbone.layers.42.mixer.norm.weight": "pytorch_model-00004-of-00006.bin",
|
| 347 |
+
"backbone.layers.42.mixer.out_proj.weight": "pytorch_model-00004-of-00006.bin",
|
| 348 |
+
"backbone.layers.42.norm.weight": "pytorch_model-00004-of-00006.bin",
|
| 349 |
+
"backbone.layers.43.mixer.A_log": "pytorch_model-00004-of-00006.bin",
|
| 350 |
+
"backbone.layers.43.mixer.D": "pytorch_model-00004-of-00006.bin",
|
| 351 |
+
"backbone.layers.43.mixer.conv1d.bias": "pytorch_model-00004-of-00006.bin",
|
| 352 |
+
"backbone.layers.43.mixer.conv1d.weight": "pytorch_model-00004-of-00006.bin",
|
| 353 |
+
"backbone.layers.43.mixer.dt_bias": "pytorch_model-00004-of-00006.bin",
|
| 354 |
+
"backbone.layers.43.mixer.in_proj.weight": "pytorch_model-00005-of-00006.bin",
|
| 355 |
+
"backbone.layers.43.mixer.norm.weight": "pytorch_model-00005-of-00006.bin",
|
| 356 |
+
"backbone.layers.43.mixer.out_proj.weight": "pytorch_model-00005-of-00006.bin",
|
| 357 |
+
"backbone.layers.43.norm.weight": "pytorch_model-00004-of-00006.bin",
|
| 358 |
+
"backbone.layers.44.mixer.A_log": "pytorch_model-00005-of-00006.bin",
|
| 359 |
+
"backbone.layers.44.mixer.D": "pytorch_model-00005-of-00006.bin",
|
| 360 |
+
"backbone.layers.44.mixer.conv1d.bias": "pytorch_model-00005-of-00006.bin",
|
| 361 |
+
"backbone.layers.44.mixer.conv1d.weight": "pytorch_model-00005-of-00006.bin",
|
| 362 |
+
"backbone.layers.44.mixer.dt_bias": "pytorch_model-00005-of-00006.bin",
|
| 363 |
+
"backbone.layers.44.mixer.in_proj.weight": "pytorch_model-00005-of-00006.bin",
|
| 364 |
+
"backbone.layers.44.mixer.norm.weight": "pytorch_model-00005-of-00006.bin",
|
| 365 |
+
"backbone.layers.44.mixer.out_proj.weight": "pytorch_model-00005-of-00006.bin",
|
| 366 |
+
"backbone.layers.44.norm.weight": "pytorch_model-00005-of-00006.bin",
|
| 367 |
+
"backbone.layers.45.mixer.A_log": "pytorch_model-00005-of-00006.bin",
|
| 368 |
+
"backbone.layers.45.mixer.D": "pytorch_model-00005-of-00006.bin",
|
| 369 |
+
"backbone.layers.45.mixer.conv1d.bias": "pytorch_model-00005-of-00006.bin",
|
| 370 |
+
"backbone.layers.45.mixer.conv1d.weight": "pytorch_model-00005-of-00006.bin",
|
| 371 |
+
"backbone.layers.45.mixer.dt_bias": "pytorch_model-00005-of-00006.bin",
|
| 372 |
+
"backbone.layers.45.mixer.in_proj.weight": "pytorch_model-00005-of-00006.bin",
|
| 373 |
+
"backbone.layers.45.mixer.norm.weight": "pytorch_model-00005-of-00006.bin",
|
| 374 |
+
"backbone.layers.45.mixer.out_proj.weight": "pytorch_model-00005-of-00006.bin",
|
| 375 |
+
"backbone.layers.45.norm.weight": "pytorch_model-00005-of-00006.bin",
|
| 376 |
+
"backbone.layers.46.mixer.A_log": "pytorch_model-00005-of-00006.bin",
|
| 377 |
+
"backbone.layers.46.mixer.D": "pytorch_model-00005-of-00006.bin",
|
| 378 |
+
"backbone.layers.46.mixer.conv1d.bias": "pytorch_model-00005-of-00006.bin",
|
| 379 |
+
"backbone.layers.46.mixer.conv1d.weight": "pytorch_model-00005-of-00006.bin",
|
| 380 |
+
"backbone.layers.46.mixer.dt_bias": "pytorch_model-00005-of-00006.bin",
|
| 381 |
+
"backbone.layers.46.mixer.in_proj.weight": "pytorch_model-00005-of-00006.bin",
|
| 382 |
+
"backbone.layers.46.mixer.norm.weight": "pytorch_model-00005-of-00006.bin",
|
| 383 |
+
"backbone.layers.46.mixer.out_proj.weight": "pytorch_model-00005-of-00006.bin",
|
| 384 |
+
"backbone.layers.46.norm.weight": "pytorch_model-00005-of-00006.bin",
|
| 385 |
+
"backbone.layers.47.mixer.A_log": "pytorch_model-00005-of-00006.bin",
|
| 386 |
+
"backbone.layers.47.mixer.D": "pytorch_model-00005-of-00006.bin",
|
| 387 |
+
"backbone.layers.47.mixer.conv1d.bias": "pytorch_model-00005-of-00006.bin",
|
| 388 |
+
"backbone.layers.47.mixer.conv1d.weight": "pytorch_model-00005-of-00006.bin",
|
| 389 |
+
"backbone.layers.47.mixer.dt_bias": "pytorch_model-00005-of-00006.bin",
|
| 390 |
+
"backbone.layers.47.mixer.in_proj.weight": "pytorch_model-00005-of-00006.bin",
|
| 391 |
+
"backbone.layers.47.mixer.norm.weight": "pytorch_model-00005-of-00006.bin",
|
| 392 |
+
"backbone.layers.47.mixer.out_proj.weight": "pytorch_model-00005-of-00006.bin",
|
| 393 |
+
"backbone.layers.47.norm.weight": "pytorch_model-00005-of-00006.bin",
|
| 394 |
+
"backbone.layers.48.mixer.A_log": "pytorch_model-00005-of-00006.bin",
|
| 395 |
+
"backbone.layers.48.mixer.D": "pytorch_model-00005-of-00006.bin",
|
| 396 |
+
"backbone.layers.48.mixer.conv1d.bias": "pytorch_model-00005-of-00006.bin",
|
| 397 |
+
"backbone.layers.48.mixer.conv1d.weight": "pytorch_model-00005-of-00006.bin",
|
| 398 |
+
"backbone.layers.48.mixer.dt_bias": "pytorch_model-00005-of-00006.bin",
|
| 399 |
+
"backbone.layers.48.mixer.in_proj.weight": "pytorch_model-00005-of-00006.bin",
|
| 400 |
+
"backbone.layers.48.mixer.norm.weight": "pytorch_model-00005-of-00006.bin",
|
| 401 |
+
"backbone.layers.48.mixer.out_proj.weight": "pytorch_model-00005-of-00006.bin",
|
| 402 |
+
"backbone.layers.48.norm.weight": "pytorch_model-00005-of-00006.bin",
|
| 403 |
+
"backbone.layers.49.mixer.A_log": "pytorch_model-00005-of-00006.bin",
|
| 404 |
+
"backbone.layers.49.mixer.D": "pytorch_model-00005-of-00006.bin",
|
| 405 |
+
"backbone.layers.49.mixer.conv1d.bias": "pytorch_model-00005-of-00006.bin",
|
| 406 |
+
"backbone.layers.49.mixer.conv1d.weight": "pytorch_model-00005-of-00006.bin",
|
| 407 |
+
"backbone.layers.49.mixer.dt_bias": "pytorch_model-00005-of-00006.bin",
|
| 408 |
+
"backbone.layers.49.mixer.in_proj.weight": "pytorch_model-00005-of-00006.bin",
|
| 409 |
+
"backbone.layers.49.mixer.norm.weight": "pytorch_model-00005-of-00006.bin",
|
| 410 |
+
"backbone.layers.49.mixer.out_proj.weight": "pytorch_model-00005-of-00006.bin",
|
| 411 |
+
"backbone.layers.49.norm.weight": "pytorch_model-00005-of-00006.bin",
|
| 412 |
+
"backbone.layers.5.mixer.A_log": "pytorch_model-00001-of-00006.bin",
|
| 413 |
+
"backbone.layers.5.mixer.D": "pytorch_model-00001-of-00006.bin",
|
| 414 |
+
"backbone.layers.5.mixer.conv1d.bias": "pytorch_model-00001-of-00006.bin",
|
| 415 |
+
"backbone.layers.5.mixer.conv1d.weight": "pytorch_model-00001-of-00006.bin",
|
| 416 |
+
"backbone.layers.5.mixer.dt_bias": "pytorch_model-00001-of-00006.bin",
|
| 417 |
+
"backbone.layers.5.mixer.in_proj.weight": "pytorch_model-00001-of-00006.bin",
|
| 418 |
+
"backbone.layers.5.mixer.norm.weight": "pytorch_model-00001-of-00006.bin",
|
| 419 |
+
"backbone.layers.5.mixer.out_proj.weight": "pytorch_model-00001-of-00006.bin",
|
| 420 |
+
"backbone.layers.5.norm.weight": "pytorch_model-00001-of-00006.bin",
|
| 421 |
+
"backbone.layers.50.mixer.A_log": "pytorch_model-00005-of-00006.bin",
|
| 422 |
+
"backbone.layers.50.mixer.D": "pytorch_model-00005-of-00006.bin",
|
| 423 |
+
"backbone.layers.50.mixer.conv1d.bias": "pytorch_model-00005-of-00006.bin",
|
| 424 |
+
"backbone.layers.50.mixer.conv1d.weight": "pytorch_model-00005-of-00006.bin",
|
| 425 |
+
"backbone.layers.50.mixer.dt_bias": "pytorch_model-00005-of-00006.bin",
|
| 426 |
+
"backbone.layers.50.mixer.in_proj.weight": "pytorch_model-00005-of-00006.bin",
|
| 427 |
+
"backbone.layers.50.mixer.norm.weight": "pytorch_model-00005-of-00006.bin",
|
| 428 |
+
"backbone.layers.50.mixer.out_proj.weight": "pytorch_model-00005-of-00006.bin",
|
| 429 |
+
"backbone.layers.50.norm.weight": "pytorch_model-00005-of-00006.bin",
|
| 430 |
+
"backbone.layers.51.mixer.A_log": "pytorch_model-00005-of-00006.bin",
|
| 431 |
+
"backbone.layers.51.mixer.D": "pytorch_model-00005-of-00006.bin",
|
| 432 |
+
"backbone.layers.51.mixer.conv1d.bias": "pytorch_model-00005-of-00006.bin",
|
| 433 |
+
"backbone.layers.51.mixer.conv1d.weight": "pytorch_model-00005-of-00006.bin",
|
| 434 |
+
"backbone.layers.51.mixer.dt_bias": "pytorch_model-00005-of-00006.bin",
|
| 435 |
+
"backbone.layers.51.mixer.in_proj.weight": "pytorch_model-00005-of-00006.bin",
|
| 436 |
+
"backbone.layers.51.mixer.norm.weight": "pytorch_model-00005-of-00006.bin",
|
| 437 |
+
"backbone.layers.51.mixer.out_proj.weight": "pytorch_model-00005-of-00006.bin",
|
| 438 |
+
"backbone.layers.51.norm.weight": "pytorch_model-00005-of-00006.bin",
|
| 439 |
+
"backbone.layers.52.mixer.A_log": "pytorch_model-00005-of-00006.bin",
|
| 440 |
+
"backbone.layers.52.mixer.D": "pytorch_model-00005-of-00006.bin",
|
| 441 |
+
"backbone.layers.52.mixer.conv1d.bias": "pytorch_model-00005-of-00006.bin",
|
| 442 |
+
"backbone.layers.52.mixer.conv1d.weight": "pytorch_model-00005-of-00006.bin",
|
| 443 |
+
"backbone.layers.52.mixer.dt_bias": "pytorch_model-00005-of-00006.bin",
|
| 444 |
+
"backbone.layers.52.mixer.in_proj.weight": "pytorch_model-00005-of-00006.bin",
|
| 445 |
+
"backbone.layers.52.mixer.norm.weight": "pytorch_model-00005-of-00006.bin",
|
| 446 |
+
"backbone.layers.52.mixer.out_proj.weight": "pytorch_model-00005-of-00006.bin",
|
| 447 |
+
"backbone.layers.52.norm.weight": "pytorch_model-00005-of-00006.bin",
|
| 448 |
+
"backbone.layers.53.mixer.A_log": "pytorch_model-00005-of-00006.bin",
|
| 449 |
+
"backbone.layers.53.mixer.D": "pytorch_model-00005-of-00006.bin",
|
| 450 |
+
"backbone.layers.53.mixer.conv1d.bias": "pytorch_model-00005-of-00006.bin",
|
| 451 |
+
"backbone.layers.53.mixer.conv1d.weight": "pytorch_model-00005-of-00006.bin",
|
| 452 |
+
"backbone.layers.53.mixer.dt_bias": "pytorch_model-00005-of-00006.bin",
|
| 453 |
+
"backbone.layers.53.mixer.in_proj.weight": "pytorch_model-00005-of-00006.bin",
|
| 454 |
+
"backbone.layers.53.mixer.norm.weight": "pytorch_model-00005-of-00006.bin",
|
| 455 |
+
"backbone.layers.53.mixer.out_proj.weight": "pytorch_model-00005-of-00006.bin",
|
| 456 |
+
"backbone.layers.53.norm.weight": "pytorch_model-00005-of-00006.bin",
|
| 457 |
+
"backbone.layers.54.mixer.A_log": "pytorch_model-00005-of-00006.bin",
|
| 458 |
+
"backbone.layers.54.mixer.D": "pytorch_model-00005-of-00006.bin",
|
| 459 |
+
"backbone.layers.54.mixer.conv1d.bias": "pytorch_model-00005-of-00006.bin",
|
| 460 |
+
"backbone.layers.54.mixer.conv1d.weight": "pytorch_model-00005-of-00006.bin",
|
| 461 |
+
"backbone.layers.54.mixer.dt_bias": "pytorch_model-00005-of-00006.bin",
|
| 462 |
+
"backbone.layers.54.mixer.in_proj.weight": "pytorch_model-00006-of-00006.bin",
|
| 463 |
+
"backbone.layers.54.mixer.norm.weight": "pytorch_model-00006-of-00006.bin",
|
| 464 |
+
"backbone.layers.54.mixer.out_proj.weight": "pytorch_model-00006-of-00006.bin",
|
| 465 |
+
"backbone.layers.54.norm.weight": "pytorch_model-00005-of-00006.bin",
|
| 466 |
+
"backbone.layers.55.mixer.A_log": "pytorch_model-00006-of-00006.bin",
|
| 467 |
+
"backbone.layers.55.mixer.D": "pytorch_model-00006-of-00006.bin",
|
| 468 |
+
"backbone.layers.55.mixer.conv1d.bias": "pytorch_model-00006-of-00006.bin",
|
| 469 |
+
"backbone.layers.55.mixer.conv1d.weight": "pytorch_model-00006-of-00006.bin",
|
| 470 |
+
"backbone.layers.55.mixer.dt_bias": "pytorch_model-00006-of-00006.bin",
|
| 471 |
+
"backbone.layers.55.mixer.in_proj.weight": "pytorch_model-00006-of-00006.bin",
|
| 472 |
+
"backbone.layers.55.mixer.norm.weight": "pytorch_model-00006-of-00006.bin",
|
| 473 |
+
"backbone.layers.55.mixer.out_proj.weight": "pytorch_model-00006-of-00006.bin",
|
| 474 |
+
"backbone.layers.55.norm.weight": "pytorch_model-00006-of-00006.bin",
|
| 475 |
+
"backbone.layers.56.mixer.A_log": "pytorch_model-00006-of-00006.bin",
|
| 476 |
+
"backbone.layers.56.mixer.D": "pytorch_model-00006-of-00006.bin",
|
| 477 |
+
"backbone.layers.56.mixer.conv1d.bias": "pytorch_model-00006-of-00006.bin",
|
| 478 |
+
"backbone.layers.56.mixer.conv1d.weight": "pytorch_model-00006-of-00006.bin",
|
| 479 |
+
"backbone.layers.56.mixer.dt_bias": "pytorch_model-00006-of-00006.bin",
|
| 480 |
+
"backbone.layers.56.mixer.in_proj.weight": "pytorch_model-00006-of-00006.bin",
|
| 481 |
+
"backbone.layers.56.mixer.norm.weight": "pytorch_model-00006-of-00006.bin",
|
| 482 |
+
"backbone.layers.56.mixer.out_proj.weight": "pytorch_model-00006-of-00006.bin",
|
| 483 |
+
"backbone.layers.56.norm.weight": "pytorch_model-00006-of-00006.bin",
|
| 484 |
+
"backbone.layers.57.mixer.A_log": "pytorch_model-00006-of-00006.bin",
|
| 485 |
+
"backbone.layers.57.mixer.D": "pytorch_model-00006-of-00006.bin",
|
| 486 |
+
"backbone.layers.57.mixer.conv1d.bias": "pytorch_model-00006-of-00006.bin",
|
| 487 |
+
"backbone.layers.57.mixer.conv1d.weight": "pytorch_model-00006-of-00006.bin",
|
| 488 |
+
"backbone.layers.57.mixer.dt_bias": "pytorch_model-00006-of-00006.bin",
|
| 489 |
+
"backbone.layers.57.mixer.in_proj.weight": "pytorch_model-00006-of-00006.bin",
|
| 490 |
+
"backbone.layers.57.mixer.norm.weight": "pytorch_model-00006-of-00006.bin",
|
| 491 |
+
"backbone.layers.57.mixer.out_proj.weight": "pytorch_model-00006-of-00006.bin",
|
| 492 |
+
"backbone.layers.57.norm.weight": "pytorch_model-00006-of-00006.bin",
|
| 493 |
+
"backbone.layers.58.mixer.A_log": "pytorch_model-00006-of-00006.bin",
|
| 494 |
+
"backbone.layers.58.mixer.D": "pytorch_model-00006-of-00006.bin",
|
| 495 |
+
"backbone.layers.58.mixer.conv1d.bias": "pytorch_model-00006-of-00006.bin",
|
| 496 |
+
"backbone.layers.58.mixer.conv1d.weight": "pytorch_model-00006-of-00006.bin",
|
| 497 |
+
"backbone.layers.58.mixer.dt_bias": "pytorch_model-00006-of-00006.bin",
|
| 498 |
+
"backbone.layers.58.mixer.in_proj.weight": "pytorch_model-00006-of-00006.bin",
|
| 499 |
+
"backbone.layers.58.mixer.norm.weight": "pytorch_model-00006-of-00006.bin",
|
| 500 |
+
"backbone.layers.58.mixer.out_proj.weight": "pytorch_model-00006-of-00006.bin",
|
| 501 |
+
"backbone.layers.58.norm.weight": "pytorch_model-00006-of-00006.bin",
|
| 502 |
+
"backbone.layers.59.mixer.A_log": "pytorch_model-00006-of-00006.bin",
|
| 503 |
+
"backbone.layers.59.mixer.D": "pytorch_model-00006-of-00006.bin",
|
| 504 |
+
"backbone.layers.59.mixer.conv1d.bias": "pytorch_model-00006-of-00006.bin",
|
| 505 |
+
"backbone.layers.59.mixer.conv1d.weight": "pytorch_model-00006-of-00006.bin",
|
| 506 |
+
"backbone.layers.59.mixer.dt_bias": "pytorch_model-00006-of-00006.bin",
|
| 507 |
+
"backbone.layers.59.mixer.in_proj.weight": "pytorch_model-00006-of-00006.bin",
|
| 508 |
+
"backbone.layers.59.mixer.norm.weight": "pytorch_model-00006-of-00006.bin",
|
| 509 |
+
"backbone.layers.59.mixer.out_proj.weight": "pytorch_model-00006-of-00006.bin",
|
| 510 |
+
"backbone.layers.59.norm.weight": "pytorch_model-00006-of-00006.bin",
|
| 511 |
+
"backbone.layers.6.mixer.A_log": "pytorch_model-00001-of-00006.bin",
|
| 512 |
+
"backbone.layers.6.mixer.D": "pytorch_model-00001-of-00006.bin",
|
| 513 |
+
"backbone.layers.6.mixer.conv1d.bias": "pytorch_model-00001-of-00006.bin",
|
| 514 |
+
"backbone.layers.6.mixer.conv1d.weight": "pytorch_model-00001-of-00006.bin",
|
| 515 |
+
"backbone.layers.6.mixer.dt_bias": "pytorch_model-00001-of-00006.bin",
|
| 516 |
+
"backbone.layers.6.mixer.in_proj.weight": "pytorch_model-00001-of-00006.bin",
|
| 517 |
+
"backbone.layers.6.mixer.norm.weight": "pytorch_model-00001-of-00006.bin",
|
| 518 |
+
"backbone.layers.6.mixer.out_proj.weight": "pytorch_model-00001-of-00006.bin",
|
| 519 |
+
"backbone.layers.6.norm.weight": "pytorch_model-00001-of-00006.bin",
|
| 520 |
+
"backbone.layers.60.mixer.A_log": "pytorch_model-00006-of-00006.bin",
|
| 521 |
+
"backbone.layers.60.mixer.D": "pytorch_model-00006-of-00006.bin",
|
| 522 |
+
"backbone.layers.60.mixer.conv1d.bias": "pytorch_model-00006-of-00006.bin",
|
| 523 |
+
"backbone.layers.60.mixer.conv1d.weight": "pytorch_model-00006-of-00006.bin",
|
| 524 |
+
"backbone.layers.60.mixer.dt_bias": "pytorch_model-00006-of-00006.bin",
|
| 525 |
+
"backbone.layers.60.mixer.in_proj.weight": "pytorch_model-00006-of-00006.bin",
|
| 526 |
+
"backbone.layers.60.mixer.norm.weight": "pytorch_model-00006-of-00006.bin",
|
| 527 |
+
"backbone.layers.60.mixer.out_proj.weight": "pytorch_model-00006-of-00006.bin",
|
| 528 |
+
"backbone.layers.60.norm.weight": "pytorch_model-00006-of-00006.bin",
|
| 529 |
+
"backbone.layers.61.mixer.A_log": "pytorch_model-00006-of-00006.bin",
|
| 530 |
+
"backbone.layers.61.mixer.D": "pytorch_model-00006-of-00006.bin",
|
| 531 |
+
"backbone.layers.61.mixer.conv1d.bias": "pytorch_model-00006-of-00006.bin",
|
| 532 |
+
"backbone.layers.61.mixer.conv1d.weight": "pytorch_model-00006-of-00006.bin",
|
| 533 |
+
"backbone.layers.61.mixer.dt_bias": "pytorch_model-00006-of-00006.bin",
|
| 534 |
+
"backbone.layers.61.mixer.in_proj.weight": "pytorch_model-00006-of-00006.bin",
|
| 535 |
+
"backbone.layers.61.mixer.norm.weight": "pytorch_model-00006-of-00006.bin",
|
| 536 |
+
"backbone.layers.61.mixer.out_proj.weight": "pytorch_model-00006-of-00006.bin",
|
| 537 |
+
"backbone.layers.61.norm.weight": "pytorch_model-00006-of-00006.bin",
|
| 538 |
+
"backbone.layers.62.mixer.A_log": "pytorch_model-00006-of-00006.bin",
|
| 539 |
+
"backbone.layers.62.mixer.D": "pytorch_model-00006-of-00006.bin",
|
| 540 |
+
"backbone.layers.62.mixer.conv1d.bias": "pytorch_model-00006-of-00006.bin",
|
| 541 |
+
"backbone.layers.62.mixer.conv1d.weight": "pytorch_model-00006-of-00006.bin",
|
| 542 |
+
"backbone.layers.62.mixer.dt_bias": "pytorch_model-00006-of-00006.bin",
|
| 543 |
+
"backbone.layers.62.mixer.in_proj.weight": "pytorch_model-00006-of-00006.bin",
|
| 544 |
+
"backbone.layers.62.mixer.norm.weight": "pytorch_model-00006-of-00006.bin",
|
| 545 |
+
"backbone.layers.62.mixer.out_proj.weight": "pytorch_model-00006-of-00006.bin",
|
| 546 |
+
"backbone.layers.62.norm.weight": "pytorch_model-00006-of-00006.bin",
|
| 547 |
+
"backbone.layers.63.mixer.A_log": "pytorch_model-00006-of-00006.bin",
|
| 548 |
+
"backbone.layers.63.mixer.D": "pytorch_model-00006-of-00006.bin",
|
| 549 |
+
"backbone.layers.63.mixer.conv1d.bias": "pytorch_model-00006-of-00006.bin",
|
| 550 |
+
"backbone.layers.63.mixer.conv1d.weight": "pytorch_model-00006-of-00006.bin",
|
| 551 |
+
"backbone.layers.63.mixer.dt_bias": "pytorch_model-00006-of-00006.bin",
|
| 552 |
+
"backbone.layers.63.mixer.in_proj.weight": "pytorch_model-00006-of-00006.bin",
|
| 553 |
+
"backbone.layers.63.mixer.norm.weight": "pytorch_model-00006-of-00006.bin",
|
| 554 |
+
"backbone.layers.63.mixer.out_proj.weight": "pytorch_model-00006-of-00006.bin",
|
| 555 |
+
"backbone.layers.63.norm.weight": "pytorch_model-00006-of-00006.bin",
|
| 556 |
+
"backbone.layers.7.mixer.A_log": "pytorch_model-00001-of-00006.bin",
|
| 557 |
+
"backbone.layers.7.mixer.D": "pytorch_model-00001-of-00006.bin",
|
| 558 |
+
"backbone.layers.7.mixer.conv1d.bias": "pytorch_model-00001-of-00006.bin",
|
| 559 |
+
"backbone.layers.7.mixer.conv1d.weight": "pytorch_model-00001-of-00006.bin",
|
| 560 |
+
"backbone.layers.7.mixer.dt_bias": "pytorch_model-00001-of-00006.bin",
|
| 561 |
+
"backbone.layers.7.mixer.in_proj.weight": "pytorch_model-00001-of-00006.bin",
|
| 562 |
+
"backbone.layers.7.mixer.norm.weight": "pytorch_model-00001-of-00006.bin",
|
| 563 |
+
"backbone.layers.7.mixer.out_proj.weight": "pytorch_model-00001-of-00006.bin",
|
| 564 |
+
"backbone.layers.7.norm.weight": "pytorch_model-00001-of-00006.bin",
|
| 565 |
+
"backbone.layers.8.mixer.A_log": "pytorch_model-00001-of-00006.bin",
|
| 566 |
+
"backbone.layers.8.mixer.D": "pytorch_model-00001-of-00006.bin",
|
| 567 |
+
"backbone.layers.8.mixer.conv1d.bias": "pytorch_model-00001-of-00006.bin",
|
| 568 |
+
"backbone.layers.8.mixer.conv1d.weight": "pytorch_model-00001-of-00006.bin",
|
| 569 |
+
"backbone.layers.8.mixer.dt_bias": "pytorch_model-00001-of-00006.bin",
|
| 570 |
+
"backbone.layers.8.mixer.in_proj.weight": "pytorch_model-00001-of-00006.bin",
|
| 571 |
+
"backbone.layers.8.mixer.norm.weight": "pytorch_model-00001-of-00006.bin",
|
| 572 |
+
"backbone.layers.8.mixer.out_proj.weight": "pytorch_model-00001-of-00006.bin",
|
| 573 |
+
"backbone.layers.8.norm.weight": "pytorch_model-00001-of-00006.bin",
|
| 574 |
+
"backbone.layers.9.mixer.A_log": "pytorch_model-00001-of-00006.bin",
|
| 575 |
+
"backbone.layers.9.mixer.D": "pytorch_model-00001-of-00006.bin",
|
| 576 |
+
"backbone.layers.9.mixer.conv1d.bias": "pytorch_model-00001-of-00006.bin",
|
| 577 |
+
"backbone.layers.9.mixer.conv1d.weight": "pytorch_model-00001-of-00006.bin",
|
| 578 |
+
"backbone.layers.9.mixer.dt_bias": "pytorch_model-00001-of-00006.bin",
|
| 579 |
+
"backbone.layers.9.mixer.in_proj.weight": "pytorch_model-00001-of-00006.bin",
|
| 580 |
+
"backbone.layers.9.mixer.norm.weight": "pytorch_model-00001-of-00006.bin",
|
| 581 |
+
"backbone.layers.9.mixer.out_proj.weight": "pytorch_model-00001-of-00006.bin",
|
| 582 |
+
"backbone.layers.9.norm.weight": "pytorch_model-00001-of-00006.bin",
|
| 583 |
+
"backbone.norm_f.weight": "pytorch_model-00006-of-00006.bin",
|
| 584 |
+
"lm_head.weight": "pytorch_model-00006-of-00006.bin"
|
| 585 |
+
}
|
| 586 |
+
}
|
special_tokens_map.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"bos_token": {
|
| 3 |
+
"content": "<s>",
|
| 4 |
+
"lstrip": false,
|
| 5 |
+
"normalized": false,
|
| 6 |
+
"rstrip": false,
|
| 7 |
+
"single_word": false
|
| 8 |
+
},
|
| 9 |
+
"eos_token": {
|
| 10 |
+
"content": "</s>",
|
| 11 |
+
"lstrip": false,
|
| 12 |
+
"normalized": false,
|
| 13 |
+
"rstrip": false,
|
| 14 |
+
"single_word": false
|
| 15 |
+
},
|
| 16 |
+
"unk_token": {
|
| 17 |
+
"content": "<unk>",
|
| 18 |
+
"lstrip": false,
|
| 19 |
+
"normalized": false,
|
| 20 |
+
"rstrip": false,
|
| 21 |
+
"single_word": false
|
| 22 |
+
}
|
| 23 |
+
}
|
tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tokenizer.model
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:59f95e28944c062244741268596badc900df86c7f5ded05088d2da22a7379e06
|
| 3 |
+
size 587583
|
tokenizer_config.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|