Upload folder using huggingface_hub
Browse files- __init__.py +26 -0
- config.json +34 -0
- configuration_iquestloopcoder.py +132 -0
- generation_config.json +6 -0
- model-00001-of-00016.safetensors +3 -0
- model-00002-of-00016.safetensors +3 -0
- model-00003-of-00016.safetensors +3 -0
- model-00004-of-00016.safetensors +3 -0
- model-00005-of-00016.safetensors +3 -0
- model-00006-of-00016.safetensors +3 -0
- model-00007-of-00016.safetensors +3 -0
- model-00008-of-00016.safetensors +3 -0
- model-00009-of-00016.safetensors +3 -0
- model-00010-of-00016.safetensors +3 -0
- model-00011-of-00016.safetensors +3 -0
- model-00012-of-00016.safetensors +3 -0
- model-00013-of-00016.safetensors +3 -0
- model-00014-of-00016.safetensors +3 -0
- model-00015-of-00016.safetensors +3 -0
- model-00016-of-00016.safetensors +3 -0
- model.safetensors.index.json +890 -0
- modeling_iquestloopcoder.py +1411 -0
- tokenization_iquestcoder.py +552 -0
- tokenizer.model +3 -0
- tokenizer_config.json +242 -0
__init__.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""IQuestLoopCoder model package."""
|
| 2 |
+
|
| 3 |
+
from .configuration_iquestloopcoder import IQuestLoopCoderConfig
|
| 4 |
+
from .modeling_iquestloopcoder import (
|
| 5 |
+
IQuestLoopCoderPreTrainedModel,
|
| 6 |
+
IQuestLoopCoderModel,
|
| 7 |
+
IQuestLoopCoderForCausalLM,
|
| 8 |
+
IQuestLoopCoderCache,
|
| 9 |
+
)
|
| 10 |
+
from .tokenization_iquestcoder import IQuestCoderTokenizer
|
| 11 |
+
|
| 12 |
+
try:
|
| 13 |
+
from .tokenization_iquestcoder import IQuestCoderTokenizerFast
|
| 14 |
+
except ImportError:
|
| 15 |
+
IQuestCoderTokenizerFast = None
|
| 16 |
+
|
| 17 |
+
__all__ = [
|
| 18 |
+
"IQuestLoopCoderConfig",
|
| 19 |
+
"IQuestLoopCoderPreTrainedModel",
|
| 20 |
+
"IQuestLoopCoderModel",
|
| 21 |
+
"IQuestLoopCoderForCausalLM",
|
| 22 |
+
"IQuestLoopCoderCache",
|
| 23 |
+
"IQuestCoderTokenizer",
|
| 24 |
+
"IQuestCoderTokenizerFast",
|
| 25 |
+
]
|
| 26 |
+
|
config.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_name_or_path": "iquestloopcoder",
|
| 3 |
+
"architectures": [
|
| 4 |
+
"IQuestLoopCoderForCausalLM"
|
| 5 |
+
],
|
| 6 |
+
"model_type": "iquestloopcoder",
|
| 7 |
+
"vocab_size": 76800,
|
| 8 |
+
"hidden_size": 5120,
|
| 9 |
+
"intermediate_size": 27648,
|
| 10 |
+
"num_hidden_layers": 80,
|
| 11 |
+
"eos_token_id": [2, 75864, 75869],
|
| 12 |
+
"num_attention_heads": 40,
|
| 13 |
+
"num_key_value_heads": 8,
|
| 14 |
+
"head_dim": 128,
|
| 15 |
+
"hidden_act": "silu",
|
| 16 |
+
"max_position_embeddings": 131072,
|
| 17 |
+
"initializer_range": 0.02,
|
| 18 |
+
"rms_norm_eps": 1e-05,
|
| 19 |
+
"use_cache": true,
|
| 20 |
+
"tie_word_embeddings": false,
|
| 21 |
+
"rope_theta": 500000,
|
| 22 |
+
"attention_bias": false,
|
| 23 |
+
"attention_dropout": 0.0,
|
| 24 |
+
"mlp_bias": false,
|
| 25 |
+
"loop_num": 2,
|
| 26 |
+
"loop_window_size": 64,
|
| 27 |
+
"torch_dtype": "bfloat16",
|
| 28 |
+
"transformers_version": "4.40.0",
|
| 29 |
+
"auto_map": {
|
| 30 |
+
"AutoConfig": "configuration_iquestloopcoder.IQuestLoopCoderConfig",
|
| 31 |
+
"AutoModel": "modeling_iquestloopcoder.IQuestLoopCoderModel",
|
| 32 |
+
"AutoModelForCausalLM": "modeling_iquestloopcoder.IQuestLoopCoderForCausalLM"
|
| 33 |
+
}
|
| 34 |
+
}
|
configuration_iquestloopcoder.py
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2024 IQuestLoopCoder Authors
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
"""IQuestLoopCoder model configuration"""
|
| 6 |
+
|
| 7 |
+
from transformers.configuration_utils import PretrainedConfig
|
| 8 |
+
from transformers.utils import logging
|
| 9 |
+
|
| 10 |
+
logger = logging.get_logger(__name__)
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
class IQuestLoopCoderConfig(PretrainedConfig):
|
| 14 |
+
r"""
|
| 15 |
+
Configuration class for IQuestLoopCoder model.
|
| 16 |
+
|
| 17 |
+
IQuestLoopCoder extends the standard LLaMA architecture with a loop mechanism:
|
| 18 |
+
- Loop 1: Standard attention, stores K1, V1
|
| 19 |
+
- Loop 2+: Mixed attention with gated combination of global (K1,V1) and local (K2,V2) KV
|
| 20 |
+
|
| 21 |
+
The gate is computed as: gate = sigmoid(W @ Q + bias)
|
| 22 |
+
Mixed output = gate * Attention(Q, K1, V1) + (1 - gate) * SlidingWindowAttention(Q, K2, V2)
|
| 23 |
+
|
| 24 |
+
Args:
|
| 25 |
+
vocab_size (`int`, *optional*, defaults to 76800):
|
| 26 |
+
Vocabulary size of the model.
|
| 27 |
+
hidden_size (`int`, *optional*, defaults to 5120):
|
| 28 |
+
Dimension of the hidden representations.
|
| 29 |
+
intermediate_size (`int`, *optional*, defaults to 27648):
|
| 30 |
+
Dimension of the MLP representations (FFN hidden size).
|
| 31 |
+
num_hidden_layers (`int`, *optional*, defaults to 80):
|
| 32 |
+
Number of hidden layers in the Transformer decoder.
|
| 33 |
+
num_attention_heads (`int`, *optional*, defaults to 40):
|
| 34 |
+
Number of attention heads for each attention layer.
|
| 35 |
+
num_key_value_heads (`int`, *optional*, defaults to 8):
|
| 36 |
+
Number of key-value heads (for GQA). If None, defaults to num_attention_heads.
|
| 37 |
+
head_dim (`int`, *optional*, defaults to 128):
|
| 38 |
+
Dimension of each attention head (hidden_size // num_attention_heads).
|
| 39 |
+
hidden_act (`str` or `function`, *optional*, defaults to `"silu"`):
|
| 40 |
+
Activation function in the MLP.
|
| 41 |
+
max_position_embeddings (`int`, *optional*, defaults to 8192):
|
| 42 |
+
Maximum sequence length.
|
| 43 |
+
initializer_range (`float`, *optional*, defaults to 0.02):
|
| 44 |
+
Standard deviation for weight initialization.
|
| 45 |
+
rms_norm_eps (`float`, *optional*, defaults to 1e-5):
|
| 46 |
+
Epsilon for RMS normalization layers.
|
| 47 |
+
use_cache (`bool`, *optional*, defaults to `True`):
|
| 48 |
+
Whether to use past key/values for generation.
|
| 49 |
+
tie_word_embeddings (`bool`, *optional*, defaults to `False`):
|
| 50 |
+
Whether to tie input and output embeddings.
|
| 51 |
+
rope_theta (`float`, *optional*, defaults to 500000.0):
|
| 52 |
+
Base value for rotary position embeddings.
|
| 53 |
+
attention_bias (`bool`, *optional*, defaults to `False`):
|
| 54 |
+
Whether to use bias in attention layers.
|
| 55 |
+
attention_dropout (`float`, *optional*, defaults to 0.0):
|
| 56 |
+
Dropout ratio for attention weights.
|
| 57 |
+
mlp_bias (`bool`, *optional*, defaults to `False`):
|
| 58 |
+
Whether to use bias in MLP layers.
|
| 59 |
+
|
| 60 |
+
# Loop-specific parameters
|
| 61 |
+
loop_num (`int`, *optional*, defaults to 2):
|
| 62 |
+
Number of loops through the decoder.
|
| 63 |
+
loop_window_size (`int`, *optional*, defaults to 64):
|
| 64 |
+
Window size for sliding window attention in Loop 2+.
|
| 65 |
+
"""
|
| 66 |
+
|
| 67 |
+
model_type = "iquestloopcoder"
|
| 68 |
+
keys_to_ignore_at_inference = ["past_key_values"]
|
| 69 |
+
|
| 70 |
+
def __init__(
|
| 71 |
+
self,
|
| 72 |
+
vocab_size=76800,
|
| 73 |
+
hidden_size=5120,
|
| 74 |
+
intermediate_size=27648,
|
| 75 |
+
num_hidden_layers=80,
|
| 76 |
+
num_attention_heads=40,
|
| 77 |
+
num_key_value_heads=8,
|
| 78 |
+
head_dim=128,
|
| 79 |
+
hidden_act="silu",
|
| 80 |
+
max_position_embeddings=8192,
|
| 81 |
+
initializer_range=0.02,
|
| 82 |
+
rms_norm_eps=1e-5,
|
| 83 |
+
use_cache=True,
|
| 84 |
+
pad_token_id=None,
|
| 85 |
+
bos_token_id=1,
|
| 86 |
+
eos_token_id=2,
|
| 87 |
+
tie_word_embeddings=False,
|
| 88 |
+
rope_theta=500000.0,
|
| 89 |
+
rope_scaling=None,
|
| 90 |
+
attention_bias=False,
|
| 91 |
+
attention_dropout=0.0,
|
| 92 |
+
mlp_bias=False,
|
| 93 |
+
# Loop-specific parameters
|
| 94 |
+
loop_num=2,
|
| 95 |
+
loop_window_size=64,
|
| 96 |
+
**kwargs,
|
| 97 |
+
):
|
| 98 |
+
self.vocab_size = vocab_size
|
| 99 |
+
self.max_position_embeddings = max_position_embeddings
|
| 100 |
+
self.hidden_size = hidden_size
|
| 101 |
+
self.intermediate_size = intermediate_size
|
| 102 |
+
self.num_hidden_layers = num_hidden_layers
|
| 103 |
+
self.num_attention_heads = num_attention_heads
|
| 104 |
+
self.head_dim = head_dim
|
| 105 |
+
|
| 106 |
+
# GQA support
|
| 107 |
+
if num_key_value_heads is None:
|
| 108 |
+
num_key_value_heads = num_attention_heads
|
| 109 |
+
self.num_key_value_heads = num_key_value_heads
|
| 110 |
+
|
| 111 |
+
self.hidden_act = hidden_act
|
| 112 |
+
self.initializer_range = initializer_range
|
| 113 |
+
self.rms_norm_eps = rms_norm_eps
|
| 114 |
+
self.use_cache = use_cache
|
| 115 |
+
self.rope_theta = rope_theta
|
| 116 |
+
self.rope_scaling = rope_scaling
|
| 117 |
+
self.attention_bias = attention_bias
|
| 118 |
+
self.attention_dropout = attention_dropout
|
| 119 |
+
self.mlp_bias = mlp_bias
|
| 120 |
+
|
| 121 |
+
# Loop-specific
|
| 122 |
+
self.loop_num = loop_num
|
| 123 |
+
self.loop_window_size = loop_window_size
|
| 124 |
+
|
| 125 |
+
super().__init__(
|
| 126 |
+
pad_token_id=pad_token_id,
|
| 127 |
+
bos_token_id=bos_token_id,
|
| 128 |
+
eos_token_id=eos_token_id,
|
| 129 |
+
tie_word_embeddings=tie_word_embeddings,
|
| 130 |
+
**kwargs,
|
| 131 |
+
)
|
| 132 |
+
|
generation_config.json
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_from_model_config": true,
|
| 3 |
+
"bos_token_id": 1,
|
| 4 |
+
"eos_token_id": [2, 75864, 75869],
|
| 5 |
+
"transformers_version": "4.55.4"
|
| 6 |
+
}
|
model-00001-of-00016.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a9433151153a8a83cc7aa4c15338e61fb73022b9377099596858181ba5efc7ce
|
| 3 |
+
size 5359151696
|
model-00002-of-00016.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:00cf8bdb3506d972f5d528a9b070cbf66662109cfbea43fddcd15595cbe282de
|
| 3 |
+
size 5274455744
|
model-00003-of-00016.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0d75d4294504e0eed0095f0528adb9ed74617305fa87d5f915a68d6edf5cfcb5
|
| 3 |
+
size 5159101664
|
model-00004-of-00016.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d86956a47df06e404ac8c00a2996eb180b67bb03ca4aa464c971a3f643a726d0
|
| 3 |
+
size 5284951976
|
model-00005-of-00016.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5e667fa53b09c758774232aa81d232aad08179c3aa46892647538e21c0e332cc
|
| 3 |
+
size 5159101664
|
model-00006-of-00016.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5fd7b5d45765e95e62c94508bc757d8d63e4eb29d646ac29ca672170c64f88a9
|
| 3 |
+
size 5159101680
|
model-00007-of-00016.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b6b756b0bdff8aa89599d49b43f6765b53c3b6e2a5b811255e100d538e8f093d
|
| 3 |
+
size 5284951968
|
model-00008-of-00016.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:78794dd0071ae57746030f5dd1ba2d8cba2546d44992ebb065454183525067b5
|
| 3 |
+
size 5159101680
|
model-00009-of-00016.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b80829c307ef680e282aae5153a7c78494664e6268e96fbffaaf1d714925e33f
|
| 3 |
+
size 5159101664
|
model-00010-of-00016.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ccd839c88a7efca21e2cb18f7ea2764d1ba5deaff22259e0f315d6bc6b20a426
|
| 3 |
+
size 5284951976
|
model-00011-of-00016.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7a3bca95b8e7cc54c8ff72182046031b5c3ea500ac6453fb99d00a84f0b3ed32
|
| 3 |
+
size 5159101664
|
model-00012-of-00016.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5eea564372bb8b8fe83908d608c11af4bd22e54a76b9a386737cdeb54c77dce7
|
| 3 |
+
size 5159101680
|
model-00013-of-00016.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ffb8e154ba4f93956ace20501496bae0c9b9283ac2ddb9c41054a68750f0dfc6
|
| 3 |
+
size 5284951968
|
model-00014-of-00016.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ee0dc913f924a572e61548035c151c772341c6a5dcc7d210a033f5d2f87ce71c
|
| 3 |
+
size 5159101680
|
model-00015-of-00016.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:aab0983411682f912be4c40bc32d9c1d58b098a12424b15e0afe8d871898a72f
|
| 3 |
+
size 5159101672
|
model-00016-of-00016.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"metadata": {
|
| 3 |
+
"total_size": 79589392640
|
| 4 |
+
},
|
| 5 |
+
"weight_map": {
|
| 6 |
+
"lm_head.weight": "model-00001-of-00016.safetensors",
|
| 7 |
+
"model.embed_tokens.weight": "model-00001-of-00016.safetensors",
|
| 8 |
+
"model.gate_projections.0.bias": "model-00001-of-00016.safetensors",
|
| 9 |
+
"model.gate_projections.0.weight": "model-00001-of-00016.safetensors",
|
| 10 |
+
"model.gate_projections.1.bias": "model-00001-of-00016.safetensors",
|
| 11 |
+
"model.gate_projections.1.weight": "model-00001-of-00016.safetensors",
|
| 12 |
+
"model.gate_projections.10.bias": "model-00001-of-00016.safetensors",
|
| 13 |
+
"model.gate_projections.10.weight": "model-00001-of-00016.safetensors",
|
| 14 |
+
"model.gate_projections.11.bias": "model-00001-of-00016.safetensors",
|
| 15 |
+
"model.gate_projections.11.weight": "model-00001-of-00016.safetensors",
|
| 16 |
+
"model.gate_projections.12.bias": "model-00001-of-00016.safetensors",
|
| 17 |
+
"model.gate_projections.12.weight": "model-00001-of-00016.safetensors",
|
| 18 |
+
"model.gate_projections.13.bias": "model-00001-of-00016.safetensors",
|
| 19 |
+
"model.gate_projections.13.weight": "model-00001-of-00016.safetensors",
|
| 20 |
+
"model.gate_projections.14.bias": "model-00001-of-00016.safetensors",
|
| 21 |
+
"model.gate_projections.14.weight": "model-00001-of-00016.safetensors",
|
| 22 |
+
"model.gate_projections.15.bias": "model-00001-of-00016.safetensors",
|
| 23 |
+
"model.gate_projections.15.weight": "model-00001-of-00016.safetensors",
|
| 24 |
+
"model.gate_projections.16.bias": "model-00001-of-00016.safetensors",
|
| 25 |
+
"model.gate_projections.16.weight": "model-00001-of-00016.safetensors",
|
| 26 |
+
"model.gate_projections.17.bias": "model-00001-of-00016.safetensors",
|
| 27 |
+
"model.gate_projections.17.weight": "model-00001-of-00016.safetensors",
|
| 28 |
+
"model.gate_projections.18.bias": "model-00001-of-00016.safetensors",
|
| 29 |
+
"model.gate_projections.18.weight": "model-00001-of-00016.safetensors",
|
| 30 |
+
"model.gate_projections.19.bias": "model-00001-of-00016.safetensors",
|
| 31 |
+
"model.gate_projections.19.weight": "model-00001-of-00016.safetensors",
|
| 32 |
+
"model.gate_projections.2.bias": "model-00001-of-00016.safetensors",
|
| 33 |
+
"model.gate_projections.2.weight": "model-00001-of-00016.safetensors",
|
| 34 |
+
"model.gate_projections.20.bias": "model-00001-of-00016.safetensors",
|
| 35 |
+
"model.gate_projections.20.weight": "model-00001-of-00016.safetensors",
|
| 36 |
+
"model.gate_projections.21.bias": "model-00001-of-00016.safetensors",
|
| 37 |
+
"model.gate_projections.21.weight": "model-00001-of-00016.safetensors",
|
| 38 |
+
"model.gate_projections.22.bias": "model-00001-of-00016.safetensors",
|
| 39 |
+
"model.gate_projections.22.weight": "model-00001-of-00016.safetensors",
|
| 40 |
+
"model.gate_projections.23.bias": "model-00001-of-00016.safetensors",
|
| 41 |
+
"model.gate_projections.23.weight": "model-00001-of-00016.safetensors",
|
| 42 |
+
"model.gate_projections.24.bias": "model-00001-of-00016.safetensors",
|
| 43 |
+
"model.gate_projections.24.weight": "model-00001-of-00016.safetensors",
|
| 44 |
+
"model.gate_projections.25.bias": "model-00001-of-00016.safetensors",
|
| 45 |
+
"model.gate_projections.25.weight": "model-00001-of-00016.safetensors",
|
| 46 |
+
"model.gate_projections.26.bias": "model-00001-of-00016.safetensors",
|
| 47 |
+
"model.gate_projections.26.weight": "model-00001-of-00016.safetensors",
|
| 48 |
+
"model.gate_projections.27.bias": "model-00001-of-00016.safetensors",
|
| 49 |
+
"model.gate_projections.27.weight": "model-00001-of-00016.safetensors",
|
| 50 |
+
"model.gate_projections.28.bias": "model-00001-of-00016.safetensors",
|
| 51 |
+
"model.gate_projections.28.weight": "model-00001-of-00016.safetensors",
|
| 52 |
+
"model.gate_projections.29.bias": "model-00001-of-00016.safetensors",
|
| 53 |
+
"model.gate_projections.29.weight": "model-00001-of-00016.safetensors",
|
| 54 |
+
"model.gate_projections.3.bias": "model-00001-of-00016.safetensors",
|
| 55 |
+
"model.gate_projections.3.weight": "model-00001-of-00016.safetensors",
|
| 56 |
+
"model.gate_projections.30.bias": "model-00001-of-00016.safetensors",
|
| 57 |
+
"model.gate_projections.30.weight": "model-00001-of-00016.safetensors",
|
| 58 |
+
"model.gate_projections.31.bias": "model-00001-of-00016.safetensors",
|
| 59 |
+
"model.gate_projections.31.weight": "model-00001-of-00016.safetensors",
|
| 60 |
+
"model.gate_projections.32.bias": "model-00001-of-00016.safetensors",
|
| 61 |
+
"model.gate_projections.32.weight": "model-00001-of-00016.safetensors",
|
| 62 |
+
"model.gate_projections.33.bias": "model-00001-of-00016.safetensors",
|
| 63 |
+
"model.gate_projections.33.weight": "model-00001-of-00016.safetensors",
|
| 64 |
+
"model.gate_projections.34.bias": "model-00001-of-00016.safetensors",
|
| 65 |
+
"model.gate_projections.34.weight": "model-00001-of-00016.safetensors",
|
| 66 |
+
"model.gate_projections.35.bias": "model-00001-of-00016.safetensors",
|
| 67 |
+
"model.gate_projections.35.weight": "model-00001-of-00016.safetensors",
|
| 68 |
+
"model.gate_projections.36.bias": "model-00001-of-00016.safetensors",
|
| 69 |
+
"model.gate_projections.36.weight": "model-00001-of-00016.safetensors",
|
| 70 |
+
"model.gate_projections.37.bias": "model-00001-of-00016.safetensors",
|
| 71 |
+
"model.gate_projections.37.weight": "model-00001-of-00016.safetensors",
|
| 72 |
+
"model.gate_projections.38.bias": "model-00001-of-00016.safetensors",
|
| 73 |
+
"model.gate_projections.38.weight": "model-00001-of-00016.safetensors",
|
| 74 |
+
"model.gate_projections.39.bias": "model-00001-of-00016.safetensors",
|
| 75 |
+
"model.gate_projections.39.weight": "model-00001-of-00016.safetensors",
|
| 76 |
+
"model.gate_projections.4.bias": "model-00001-of-00016.safetensors",
|
| 77 |
+
"model.gate_projections.4.weight": "model-00001-of-00016.safetensors",
|
| 78 |
+
"model.gate_projections.40.bias": "model-00001-of-00016.safetensors",
|
| 79 |
+
"model.gate_projections.40.weight": "model-00001-of-00016.safetensors",
|
| 80 |
+
"model.gate_projections.41.bias": "model-00001-of-00016.safetensors",
|
| 81 |
+
"model.gate_projections.41.weight": "model-00001-of-00016.safetensors",
|
| 82 |
+
"model.gate_projections.42.bias": "model-00001-of-00016.safetensors",
|
| 83 |
+
"model.gate_projections.42.weight": "model-00001-of-00016.safetensors",
|
| 84 |
+
"model.gate_projections.43.bias": "model-00001-of-00016.safetensors",
|
| 85 |
+
"model.gate_projections.43.weight": "model-00001-of-00016.safetensors",
|
| 86 |
+
"model.gate_projections.44.bias": "model-00001-of-00016.safetensors",
|
| 87 |
+
"model.gate_projections.44.weight": "model-00001-of-00016.safetensors",
|
| 88 |
+
"model.gate_projections.45.bias": "model-00001-of-00016.safetensors",
|
| 89 |
+
"model.gate_projections.45.weight": "model-00001-of-00016.safetensors",
|
| 90 |
+
"model.gate_projections.46.bias": "model-00001-of-00016.safetensors",
|
| 91 |
+
"model.gate_projections.46.weight": "model-00001-of-00016.safetensors",
|
| 92 |
+
"model.gate_projections.47.bias": "model-00001-of-00016.safetensors",
|
| 93 |
+
"model.gate_projections.47.weight": "model-00001-of-00016.safetensors",
|
| 94 |
+
"model.gate_projections.48.bias": "model-00001-of-00016.safetensors",
|
| 95 |
+
"model.gate_projections.48.weight": "model-00001-of-00016.safetensors",
|
| 96 |
+
"model.gate_projections.49.bias": "model-00001-of-00016.safetensors",
|
| 97 |
+
"model.gate_projections.49.weight": "model-00001-of-00016.safetensors",
|
| 98 |
+
"model.gate_projections.5.bias": "model-00001-of-00016.safetensors",
|
| 99 |
+
"model.gate_projections.5.weight": "model-00001-of-00016.safetensors",
|
| 100 |
+
"model.gate_projections.50.bias": "model-00001-of-00016.safetensors",
|
| 101 |
+
"model.gate_projections.50.weight": "model-00001-of-00016.safetensors",
|
| 102 |
+
"model.gate_projections.51.bias": "model-00001-of-00016.safetensors",
|
| 103 |
+
"model.gate_projections.51.weight": "model-00001-of-00016.safetensors",
|
| 104 |
+
"model.gate_projections.52.bias": "model-00001-of-00016.safetensors",
|
| 105 |
+
"model.gate_projections.52.weight": "model-00001-of-00016.safetensors",
|
| 106 |
+
"model.gate_projections.53.bias": "model-00001-of-00016.safetensors",
|
| 107 |
+
"model.gate_projections.53.weight": "model-00001-of-00016.safetensors",
|
| 108 |
+
"model.gate_projections.54.bias": "model-00001-of-00016.safetensors",
|
| 109 |
+
"model.gate_projections.54.weight": "model-00001-of-00016.safetensors",
|
| 110 |
+
"model.gate_projections.55.bias": "model-00001-of-00016.safetensors",
|
| 111 |
+
"model.gate_projections.55.weight": "model-00001-of-00016.safetensors",
|
| 112 |
+
"model.gate_projections.56.bias": "model-00001-of-00016.safetensors",
|
| 113 |
+
"model.gate_projections.56.weight": "model-00001-of-00016.safetensors",
|
| 114 |
+
"model.gate_projections.57.bias": "model-00001-of-00016.safetensors",
|
| 115 |
+
"model.gate_projections.57.weight": "model-00001-of-00016.safetensors",
|
| 116 |
+
"model.gate_projections.58.bias": "model-00001-of-00016.safetensors",
|
| 117 |
+
"model.gate_projections.58.weight": "model-00001-of-00016.safetensors",
|
| 118 |
+
"model.gate_projections.59.bias": "model-00001-of-00016.safetensors",
|
| 119 |
+
"model.gate_projections.59.weight": "model-00001-of-00016.safetensors",
|
| 120 |
+
"model.gate_projections.6.bias": "model-00001-of-00016.safetensors",
|
| 121 |
+
"model.gate_projections.6.weight": "model-00001-of-00016.safetensors",
|
| 122 |
+
"model.gate_projections.60.bias": "model-00001-of-00016.safetensors",
|
| 123 |
+
"model.gate_projections.60.weight": "model-00001-of-00016.safetensors",
|
| 124 |
+
"model.gate_projections.61.bias": "model-00001-of-00016.safetensors",
|
| 125 |
+
"model.gate_projections.61.weight": "model-00001-of-00016.safetensors",
|
| 126 |
+
"model.gate_projections.62.bias": "model-00001-of-00016.safetensors",
|
| 127 |
+
"model.gate_projections.62.weight": "model-00001-of-00016.safetensors",
|
| 128 |
+
"model.gate_projections.63.bias": "model-00001-of-00016.safetensors",
|
| 129 |
+
"model.gate_projections.63.weight": "model-00001-of-00016.safetensors",
|
| 130 |
+
"model.gate_projections.64.bias": "model-00001-of-00016.safetensors",
|
| 131 |
+
"model.gate_projections.64.weight": "model-00001-of-00016.safetensors",
|
| 132 |
+
"model.gate_projections.65.bias": "model-00001-of-00016.safetensors",
|
| 133 |
+
"model.gate_projections.65.weight": "model-00001-of-00016.safetensors",
|
| 134 |
+
"model.gate_projections.66.bias": "model-00001-of-00016.safetensors",
|
| 135 |
+
"model.gate_projections.66.weight": "model-00001-of-00016.safetensors",
|
| 136 |
+
"model.gate_projections.67.bias": "model-00001-of-00016.safetensors",
|
| 137 |
+
"model.gate_projections.67.weight": "model-00001-of-00016.safetensors",
|
| 138 |
+
"model.gate_projections.68.bias": "model-00001-of-00016.safetensors",
|
| 139 |
+
"model.gate_projections.68.weight": "model-00001-of-00016.safetensors",
|
| 140 |
+
"model.gate_projections.69.bias": "model-00001-of-00016.safetensors",
|
| 141 |
+
"model.gate_projections.69.weight": "model-00001-of-00016.safetensors",
|
| 142 |
+
"model.gate_projections.7.bias": "model-00001-of-00016.safetensors",
|
| 143 |
+
"model.gate_projections.7.weight": "model-00001-of-00016.safetensors",
|
| 144 |
+
"model.gate_projections.70.bias": "model-00001-of-00016.safetensors",
|
| 145 |
+
"model.gate_projections.70.weight": "model-00001-of-00016.safetensors",
|
| 146 |
+
"model.gate_projections.71.bias": "model-00001-of-00016.safetensors",
|
| 147 |
+
"model.gate_projections.71.weight": "model-00001-of-00016.safetensors",
|
| 148 |
+
"model.gate_projections.72.bias": "model-00001-of-00016.safetensors",
|
| 149 |
+
"model.gate_projections.72.weight": "model-00001-of-00016.safetensors",
|
| 150 |
+
"model.gate_projections.73.bias": "model-00001-of-00016.safetensors",
|
| 151 |
+
"model.gate_projections.73.weight": "model-00001-of-00016.safetensors",
|
| 152 |
+
"model.gate_projections.74.bias": "model-00001-of-00016.safetensors",
|
| 153 |
+
"model.gate_projections.74.weight": "model-00001-of-00016.safetensors",
|
| 154 |
+
"model.gate_projections.75.bias": "model-00001-of-00016.safetensors",
|
| 155 |
+
"model.gate_projections.75.weight": "model-00001-of-00016.safetensors",
|
| 156 |
+
"model.gate_projections.76.bias": "model-00001-of-00016.safetensors",
|
| 157 |
+
"model.gate_projections.76.weight": "model-00001-of-00016.safetensors",
|
| 158 |
+
"model.gate_projections.77.bias": "model-00001-of-00016.safetensors",
|
| 159 |
+
"model.gate_projections.77.weight": "model-00001-of-00016.safetensors",
|
| 160 |
+
"model.gate_projections.78.bias": "model-00001-of-00016.safetensors",
|
| 161 |
+
"model.gate_projections.78.weight": "model-00001-of-00016.safetensors",
|
| 162 |
+
"model.gate_projections.79.bias": "model-00001-of-00016.safetensors",
|
| 163 |
+
"model.gate_projections.79.weight": "model-00001-of-00016.safetensors",
|
| 164 |
+
"model.gate_projections.8.bias": "model-00001-of-00016.safetensors",
|
| 165 |
+
"model.gate_projections.8.weight": "model-00001-of-00016.safetensors",
|
| 166 |
+
"model.gate_projections.9.bias": "model-00001-of-00016.safetensors",
|
| 167 |
+
"model.gate_projections.9.weight": "model-00001-of-00016.safetensors",
|
| 168 |
+
"model.layers.0.input_layernorm.weight": "model-00001-of-00016.safetensors",
|
| 169 |
+
"model.layers.0.mlp.down_proj.weight": "model-00001-of-00016.safetensors",
|
| 170 |
+
"model.layers.0.mlp.gate_proj.weight": "model-00001-of-00016.safetensors",
|
| 171 |
+
"model.layers.0.mlp.up_proj.weight": "model-00001-of-00016.safetensors",
|
| 172 |
+
"model.layers.0.post_attention_layernorm.weight": "model-00001-of-00016.safetensors",
|
| 173 |
+
"model.layers.0.self_attn.k_proj.weight": "model-00001-of-00016.safetensors",
|
| 174 |
+
"model.layers.0.self_attn.o_proj.weight": "model-00001-of-00016.safetensors",
|
| 175 |
+
"model.layers.0.self_attn.q_proj.weight": "model-00001-of-00016.safetensors",
|
| 176 |
+
"model.layers.0.self_attn.v_proj.weight": "model-00001-of-00016.safetensors",
|
| 177 |
+
"model.layers.1.input_layernorm.weight": "model-00001-of-00016.safetensors",
|
| 178 |
+
"model.layers.1.mlp.down_proj.weight": "model-00001-of-00016.safetensors",
|
| 179 |
+
"model.layers.1.mlp.gate_proj.weight": "model-00001-of-00016.safetensors",
|
| 180 |
+
"model.layers.1.mlp.up_proj.weight": "model-00001-of-00016.safetensors",
|
| 181 |
+
"model.layers.1.post_attention_layernorm.weight": "model-00001-of-00016.safetensors",
|
| 182 |
+
"model.layers.1.self_attn.k_proj.weight": "model-00001-of-00016.safetensors",
|
| 183 |
+
"model.layers.1.self_attn.o_proj.weight": "model-00001-of-00016.safetensors",
|
| 184 |
+
"model.layers.1.self_attn.q_proj.weight": "model-00001-of-00016.safetensors",
|
| 185 |
+
"model.layers.1.self_attn.v_proj.weight": "model-00001-of-00016.safetensors",
|
| 186 |
+
"model.layers.10.input_layernorm.weight": "model-00001-of-00016.safetensors",
|
| 187 |
+
"model.layers.10.mlp.down_proj.weight": "model-00001-of-00016.safetensors",
|
| 188 |
+
"model.layers.10.mlp.gate_proj.weight": "model-00001-of-00016.safetensors",
|
| 189 |
+
"model.layers.10.mlp.up_proj.weight": "model-00001-of-00016.safetensors",
|
| 190 |
+
"model.layers.10.post_attention_layernorm.weight": "model-00001-of-00016.safetensors",
|
| 191 |
+
"model.layers.10.self_attn.k_proj.weight": "model-00001-of-00016.safetensors",
|
| 192 |
+
"model.layers.10.self_attn.o_proj.weight": "model-00001-of-00016.safetensors",
|
| 193 |
+
"model.layers.10.self_attn.q_proj.weight": "model-00001-of-00016.safetensors",
|
| 194 |
+
"model.layers.10.self_attn.v_proj.weight": "model-00001-of-00016.safetensors",
|
| 195 |
+
"model.layers.11.input_layernorm.weight": "model-00001-of-00016.safetensors",
|
| 196 |
+
"model.layers.11.mlp.down_proj.weight": "model-00001-of-00016.safetensors",
|
| 197 |
+
"model.layers.11.mlp.gate_proj.weight": "model-00001-of-00016.safetensors",
|
| 198 |
+
"model.layers.11.mlp.up_proj.weight": "model-00001-of-00016.safetensors",
|
| 199 |
+
"model.layers.11.post_attention_layernorm.weight": "model-00001-of-00016.safetensors",
|
| 200 |
+
"model.layers.11.self_attn.k_proj.weight": "model-00001-of-00016.safetensors",
|
| 201 |
+
"model.layers.11.self_attn.o_proj.weight": "model-00002-of-00016.safetensors",
|
| 202 |
+
"model.layers.11.self_attn.q_proj.weight": "model-00002-of-00016.safetensors",
|
| 203 |
+
"model.layers.11.self_attn.v_proj.weight": "model-00002-of-00016.safetensors",
|
| 204 |
+
"model.layers.12.input_layernorm.weight": "model-00002-of-00016.safetensors",
|
| 205 |
+
"model.layers.12.mlp.down_proj.weight": "model-00002-of-00016.safetensors",
|
| 206 |
+
"model.layers.12.mlp.gate_proj.weight": "model-00002-of-00016.safetensors",
|
| 207 |
+
"model.layers.12.mlp.up_proj.weight": "model-00002-of-00016.safetensors",
|
| 208 |
+
"model.layers.12.post_attention_layernorm.weight": "model-00002-of-00016.safetensors",
|
| 209 |
+
"model.layers.12.self_attn.k_proj.weight": "model-00002-of-00016.safetensors",
|
| 210 |
+
"model.layers.12.self_attn.o_proj.weight": "model-00002-of-00016.safetensors",
|
| 211 |
+
"model.layers.12.self_attn.q_proj.weight": "model-00002-of-00016.safetensors",
|
| 212 |
+
"model.layers.12.self_attn.v_proj.weight": "model-00002-of-00016.safetensors",
|
| 213 |
+
"model.layers.13.input_layernorm.weight": "model-00002-of-00016.safetensors",
|
| 214 |
+
"model.layers.13.mlp.down_proj.weight": "model-00002-of-00016.safetensors",
|
| 215 |
+
"model.layers.13.mlp.gate_proj.weight": "model-00002-of-00016.safetensors",
|
| 216 |
+
"model.layers.13.mlp.up_proj.weight": "model-00002-of-00016.safetensors",
|
| 217 |
+
"model.layers.13.post_attention_layernorm.weight": "model-00002-of-00016.safetensors",
|
| 218 |
+
"model.layers.13.self_attn.k_proj.weight": "model-00002-of-00016.safetensors",
|
| 219 |
+
"model.layers.13.self_attn.o_proj.weight": "model-00002-of-00016.safetensors",
|
| 220 |
+
"model.layers.13.self_attn.q_proj.weight": "model-00002-of-00016.safetensors",
|
| 221 |
+
"model.layers.13.self_attn.v_proj.weight": "model-00002-of-00016.safetensors",
|
| 222 |
+
"model.layers.14.input_layernorm.weight": "model-00002-of-00016.safetensors",
|
| 223 |
+
"model.layers.14.mlp.down_proj.weight": "model-00002-of-00016.safetensors",
|
| 224 |
+
"model.layers.14.mlp.gate_proj.weight": "model-00002-of-00016.safetensors",
|
| 225 |
+
"model.layers.14.mlp.up_proj.weight": "model-00002-of-00016.safetensors",
|
| 226 |
+
"model.layers.14.post_attention_layernorm.weight": "model-00002-of-00016.safetensors",
|
| 227 |
+
"model.layers.14.self_attn.k_proj.weight": "model-00002-of-00016.safetensors",
|
| 228 |
+
"model.layers.14.self_attn.o_proj.weight": "model-00002-of-00016.safetensors",
|
| 229 |
+
"model.layers.14.self_attn.q_proj.weight": "model-00002-of-00016.safetensors",
|
| 230 |
+
"model.layers.14.self_attn.v_proj.weight": "model-00002-of-00016.safetensors",
|
| 231 |
+
"model.layers.15.input_layernorm.weight": "model-00002-of-00016.safetensors",
|
| 232 |
+
"model.layers.15.mlp.down_proj.weight": "model-00002-of-00016.safetensors",
|
| 233 |
+
"model.layers.15.mlp.gate_proj.weight": "model-00002-of-00016.safetensors",
|
| 234 |
+
"model.layers.15.mlp.up_proj.weight": "model-00002-of-00016.safetensors",
|
| 235 |
+
"model.layers.15.post_attention_layernorm.weight": "model-00002-of-00016.safetensors",
|
| 236 |
+
"model.layers.15.self_attn.k_proj.weight": "model-00002-of-00016.safetensors",
|
| 237 |
+
"model.layers.15.self_attn.o_proj.weight": "model-00002-of-00016.safetensors",
|
| 238 |
+
"model.layers.15.self_attn.q_proj.weight": "model-00002-of-00016.safetensors",
|
| 239 |
+
"model.layers.15.self_attn.v_proj.weight": "model-00002-of-00016.safetensors",
|
| 240 |
+
"model.layers.16.input_layernorm.weight": "model-00002-of-00016.safetensors",
|
| 241 |
+
"model.layers.16.mlp.down_proj.weight": "model-00002-of-00016.safetensors",
|
| 242 |
+
"model.layers.16.mlp.gate_proj.weight": "model-00002-of-00016.safetensors",
|
| 243 |
+
"model.layers.16.mlp.up_proj.weight": "model-00002-of-00016.safetensors",
|
| 244 |
+
"model.layers.16.post_attention_layernorm.weight": "model-00002-of-00016.safetensors",
|
| 245 |
+
"model.layers.16.self_attn.k_proj.weight": "model-00002-of-00016.safetensors",
|
| 246 |
+
"model.layers.16.self_attn.o_proj.weight": "model-00002-of-00016.safetensors",
|
| 247 |
+
"model.layers.16.self_attn.q_proj.weight": "model-00002-of-00016.safetensors",
|
| 248 |
+
"model.layers.16.self_attn.v_proj.weight": "model-00002-of-00016.safetensors",
|
| 249 |
+
"model.layers.17.input_layernorm.weight": "model-00002-of-00016.safetensors",
|
| 250 |
+
"model.layers.17.mlp.down_proj.weight": "model-00002-of-00016.safetensors",
|
| 251 |
+
"model.layers.17.mlp.gate_proj.weight": "model-00003-of-00016.safetensors",
|
| 252 |
+
"model.layers.17.mlp.up_proj.weight": "model-00003-of-00016.safetensors",
|
| 253 |
+
"model.layers.17.post_attention_layernorm.weight": "model-00003-of-00016.safetensors",
|
| 254 |
+
"model.layers.17.self_attn.k_proj.weight": "model-00003-of-00016.safetensors",
|
| 255 |
+
"model.layers.17.self_attn.o_proj.weight": "model-00003-of-00016.safetensors",
|
| 256 |
+
"model.layers.17.self_attn.q_proj.weight": "model-00003-of-00016.safetensors",
|
| 257 |
+
"model.layers.17.self_attn.v_proj.weight": "model-00003-of-00016.safetensors",
|
| 258 |
+
"model.layers.18.input_layernorm.weight": "model-00003-of-00016.safetensors",
|
| 259 |
+
"model.layers.18.mlp.down_proj.weight": "model-00003-of-00016.safetensors",
|
| 260 |
+
"model.layers.18.mlp.gate_proj.weight": "model-00003-of-00016.safetensors",
|
| 261 |
+
"model.layers.18.mlp.up_proj.weight": "model-00003-of-00016.safetensors",
|
| 262 |
+
"model.layers.18.post_attention_layernorm.weight": "model-00003-of-00016.safetensors",
|
| 263 |
+
"model.layers.18.self_attn.k_proj.weight": "model-00003-of-00016.safetensors",
|
| 264 |
+
"model.layers.18.self_attn.o_proj.weight": "model-00003-of-00016.safetensors",
|
| 265 |
+
"model.layers.18.self_attn.q_proj.weight": "model-00003-of-00016.safetensors",
|
| 266 |
+
"model.layers.18.self_attn.v_proj.weight": "model-00003-of-00016.safetensors",
|
| 267 |
+
"model.layers.19.input_layernorm.weight": "model-00003-of-00016.safetensors",
|
| 268 |
+
"model.layers.19.mlp.down_proj.weight": "model-00003-of-00016.safetensors",
|
| 269 |
+
"model.layers.19.mlp.gate_proj.weight": "model-00003-of-00016.safetensors",
|
| 270 |
+
"model.layers.19.mlp.up_proj.weight": "model-00003-of-00016.safetensors",
|
| 271 |
+
"model.layers.19.post_attention_layernorm.weight": "model-00003-of-00016.safetensors",
|
| 272 |
+
"model.layers.19.self_attn.k_proj.weight": "model-00003-of-00016.safetensors",
|
| 273 |
+
"model.layers.19.self_attn.o_proj.weight": "model-00003-of-00016.safetensors",
|
| 274 |
+
"model.layers.19.self_attn.q_proj.weight": "model-00003-of-00016.safetensors",
|
| 275 |
+
"model.layers.19.self_attn.v_proj.weight": "model-00003-of-00016.safetensors",
|
| 276 |
+
"model.layers.2.input_layernorm.weight": "model-00003-of-00016.safetensors",
|
| 277 |
+
"model.layers.2.mlp.down_proj.weight": "model-00003-of-00016.safetensors",
|
| 278 |
+
"model.layers.2.mlp.gate_proj.weight": "model-00003-of-00016.safetensors",
|
| 279 |
+
"model.layers.2.mlp.up_proj.weight": "model-00003-of-00016.safetensors",
|
| 280 |
+
"model.layers.2.post_attention_layernorm.weight": "model-00003-of-00016.safetensors",
|
| 281 |
+
"model.layers.2.self_attn.k_proj.weight": "model-00003-of-00016.safetensors",
|
| 282 |
+
"model.layers.2.self_attn.o_proj.weight": "model-00003-of-00016.safetensors",
|
| 283 |
+
"model.layers.2.self_attn.q_proj.weight": "model-00003-of-00016.safetensors",
|
| 284 |
+
"model.layers.2.self_attn.v_proj.weight": "model-00003-of-00016.safetensors",
|
| 285 |
+
"model.layers.20.input_layernorm.weight": "model-00003-of-00016.safetensors",
|
| 286 |
+
"model.layers.20.mlp.down_proj.weight": "model-00003-of-00016.safetensors",
|
| 287 |
+
"model.layers.20.mlp.gate_proj.weight": "model-00003-of-00016.safetensors",
|
| 288 |
+
"model.layers.20.mlp.up_proj.weight": "model-00003-of-00016.safetensors",
|
| 289 |
+
"model.layers.20.post_attention_layernorm.weight": "model-00003-of-00016.safetensors",
|
| 290 |
+
"model.layers.20.self_attn.k_proj.weight": "model-00003-of-00016.safetensors",
|
| 291 |
+
"model.layers.20.self_attn.o_proj.weight": "model-00003-of-00016.safetensors",
|
| 292 |
+
"model.layers.20.self_attn.q_proj.weight": "model-00003-of-00016.safetensors",
|
| 293 |
+
"model.layers.20.self_attn.v_proj.weight": "model-00003-of-00016.safetensors",
|
| 294 |
+
"model.layers.21.input_layernorm.weight": "model-00003-of-00016.safetensors",
|
| 295 |
+
"model.layers.21.mlp.down_proj.weight": "model-00003-of-00016.safetensors",
|
| 296 |
+
"model.layers.21.mlp.gate_proj.weight": "model-00003-of-00016.safetensors",
|
| 297 |
+
"model.layers.21.mlp.up_proj.weight": "model-00004-of-00016.safetensors",
|
| 298 |
+
"model.layers.21.post_attention_layernorm.weight": "model-00004-of-00016.safetensors",
|
| 299 |
+
"model.layers.21.self_attn.k_proj.weight": "model-00004-of-00016.safetensors",
|
| 300 |
+
"model.layers.21.self_attn.o_proj.weight": "model-00004-of-00016.safetensors",
|
| 301 |
+
"model.layers.21.self_attn.q_proj.weight": "model-00004-of-00016.safetensors",
|
| 302 |
+
"model.layers.21.self_attn.v_proj.weight": "model-00004-of-00016.safetensors",
|
| 303 |
+
"model.layers.22.input_layernorm.weight": "model-00004-of-00016.safetensors",
|
| 304 |
+
"model.layers.22.mlp.down_proj.weight": "model-00004-of-00016.safetensors",
|
| 305 |
+
"model.layers.22.mlp.gate_proj.weight": "model-00004-of-00016.safetensors",
|
| 306 |
+
"model.layers.22.mlp.up_proj.weight": "model-00004-of-00016.safetensors",
|
| 307 |
+
"model.layers.22.post_attention_layernorm.weight": "model-00004-of-00016.safetensors",
|
| 308 |
+
"model.layers.22.self_attn.k_proj.weight": "model-00004-of-00016.safetensors",
|
| 309 |
+
"model.layers.22.self_attn.o_proj.weight": "model-00004-of-00016.safetensors",
|
| 310 |
+
"model.layers.22.self_attn.q_proj.weight": "model-00004-of-00016.safetensors",
|
| 311 |
+
"model.layers.22.self_attn.v_proj.weight": "model-00004-of-00016.safetensors",
|
| 312 |
+
"model.layers.23.input_layernorm.weight": "model-00004-of-00016.safetensors",
|
| 313 |
+
"model.layers.23.mlp.down_proj.weight": "model-00004-of-00016.safetensors",
|
| 314 |
+
"model.layers.23.mlp.gate_proj.weight": "model-00004-of-00016.safetensors",
|
| 315 |
+
"model.layers.23.mlp.up_proj.weight": "model-00004-of-00016.safetensors",
|
| 316 |
+
"model.layers.23.post_attention_layernorm.weight": "model-00004-of-00016.safetensors",
|
| 317 |
+
"model.layers.23.self_attn.k_proj.weight": "model-00004-of-00016.safetensors",
|
| 318 |
+
"model.layers.23.self_attn.o_proj.weight": "model-00004-of-00016.safetensors",
|
| 319 |
+
"model.layers.23.self_attn.q_proj.weight": "model-00004-of-00016.safetensors",
|
| 320 |
+
"model.layers.23.self_attn.v_proj.weight": "model-00004-of-00016.safetensors",
|
| 321 |
+
"model.layers.24.input_layernorm.weight": "model-00004-of-00016.safetensors",
|
| 322 |
+
"model.layers.24.mlp.down_proj.weight": "model-00004-of-00016.safetensors",
|
| 323 |
+
"model.layers.24.mlp.gate_proj.weight": "model-00004-of-00016.safetensors",
|
| 324 |
+
"model.layers.24.mlp.up_proj.weight": "model-00004-of-00016.safetensors",
|
| 325 |
+
"model.layers.24.post_attention_layernorm.weight": "model-00004-of-00016.safetensors",
|
| 326 |
+
"model.layers.24.self_attn.k_proj.weight": "model-00004-of-00016.safetensors",
|
| 327 |
+
"model.layers.24.self_attn.o_proj.weight": "model-00004-of-00016.safetensors",
|
| 328 |
+
"model.layers.24.self_attn.q_proj.weight": "model-00004-of-00016.safetensors",
|
| 329 |
+
"model.layers.24.self_attn.v_proj.weight": "model-00004-of-00016.safetensors",
|
| 330 |
+
"model.layers.25.input_layernorm.weight": "model-00004-of-00016.safetensors",
|
| 331 |
+
"model.layers.25.mlp.down_proj.weight": "model-00004-of-00016.safetensors",
|
| 332 |
+
"model.layers.25.mlp.gate_proj.weight": "model-00004-of-00016.safetensors",
|
| 333 |
+
"model.layers.25.mlp.up_proj.weight": "model-00004-of-00016.safetensors",
|
| 334 |
+
"model.layers.25.post_attention_layernorm.weight": "model-00004-of-00016.safetensors",
|
| 335 |
+
"model.layers.25.self_attn.k_proj.weight": "model-00004-of-00016.safetensors",
|
| 336 |
+
"model.layers.25.self_attn.o_proj.weight": "model-00004-of-00016.safetensors",
|
| 337 |
+
"model.layers.25.self_attn.q_proj.weight": "model-00004-of-00016.safetensors",
|
| 338 |
+
"model.layers.25.self_attn.v_proj.weight": "model-00004-of-00016.safetensors",
|
| 339 |
+
"model.layers.26.input_layernorm.weight": "model-00004-of-00016.safetensors",
|
| 340 |
+
"model.layers.26.mlp.down_proj.weight": "model-00004-of-00016.safetensors",
|
| 341 |
+
"model.layers.26.mlp.gate_proj.weight": "model-00004-of-00016.safetensors",
|
| 342 |
+
"model.layers.26.mlp.up_proj.weight": "model-00004-of-00016.safetensors",
|
| 343 |
+
"model.layers.26.post_attention_layernorm.weight": "model-00004-of-00016.safetensors",
|
| 344 |
+
"model.layers.26.self_attn.k_proj.weight": "model-00004-of-00016.safetensors",
|
| 345 |
+
"model.layers.26.self_attn.o_proj.weight": "model-00004-of-00016.safetensors",
|
| 346 |
+
"model.layers.26.self_attn.q_proj.weight": "model-00004-of-00016.safetensors",
|
| 347 |
+
"model.layers.26.self_attn.v_proj.weight": "model-00004-of-00016.safetensors",
|
| 348 |
+
"model.layers.27.input_layernorm.weight": "model-00004-of-00016.safetensors",
|
| 349 |
+
"model.layers.27.mlp.down_proj.weight": "model-00005-of-00016.safetensors",
|
| 350 |
+
"model.layers.27.mlp.gate_proj.weight": "model-00005-of-00016.safetensors",
|
| 351 |
+
"model.layers.27.mlp.up_proj.weight": "model-00005-of-00016.safetensors",
|
| 352 |
+
"model.layers.27.post_attention_layernorm.weight": "model-00005-of-00016.safetensors",
|
| 353 |
+
"model.layers.27.self_attn.k_proj.weight": "model-00005-of-00016.safetensors",
|
| 354 |
+
"model.layers.27.self_attn.o_proj.weight": "model-00005-of-00016.safetensors",
|
| 355 |
+
"model.layers.27.self_attn.q_proj.weight": "model-00005-of-00016.safetensors",
|
| 356 |
+
"model.layers.27.self_attn.v_proj.weight": "model-00005-of-00016.safetensors",
|
| 357 |
+
"model.layers.28.input_layernorm.weight": "model-00005-of-00016.safetensors",
|
| 358 |
+
"model.layers.28.mlp.down_proj.weight": "model-00005-of-00016.safetensors",
|
| 359 |
+
"model.layers.28.mlp.gate_proj.weight": "model-00005-of-00016.safetensors",
|
| 360 |
+
"model.layers.28.mlp.up_proj.weight": "model-00005-of-00016.safetensors",
|
| 361 |
+
"model.layers.28.post_attention_layernorm.weight": "model-00005-of-00016.safetensors",
|
| 362 |
+
"model.layers.28.self_attn.k_proj.weight": "model-00005-of-00016.safetensors",
|
| 363 |
+
"model.layers.28.self_attn.o_proj.weight": "model-00005-of-00016.safetensors",
|
| 364 |
+
"model.layers.28.self_attn.q_proj.weight": "model-00005-of-00016.safetensors",
|
| 365 |
+
"model.layers.28.self_attn.v_proj.weight": "model-00005-of-00016.safetensors",
|
| 366 |
+
"model.layers.29.input_layernorm.weight": "model-00005-of-00016.safetensors",
|
| 367 |
+
"model.layers.29.mlp.down_proj.weight": "model-00005-of-00016.safetensors",
|
| 368 |
+
"model.layers.29.mlp.gate_proj.weight": "model-00005-of-00016.safetensors",
|
| 369 |
+
"model.layers.29.mlp.up_proj.weight": "model-00005-of-00016.safetensors",
|
| 370 |
+
"model.layers.29.post_attention_layernorm.weight": "model-00005-of-00016.safetensors",
|
| 371 |
+
"model.layers.29.self_attn.k_proj.weight": "model-00005-of-00016.safetensors",
|
| 372 |
+
"model.layers.29.self_attn.o_proj.weight": "model-00005-of-00016.safetensors",
|
| 373 |
+
"model.layers.29.self_attn.q_proj.weight": "model-00005-of-00016.safetensors",
|
| 374 |
+
"model.layers.29.self_attn.v_proj.weight": "model-00005-of-00016.safetensors",
|
| 375 |
+
"model.layers.3.input_layernorm.weight": "model-00005-of-00016.safetensors",
|
| 376 |
+
"model.layers.3.mlp.down_proj.weight": "model-00005-of-00016.safetensors",
|
| 377 |
+
"model.layers.3.mlp.gate_proj.weight": "model-00005-of-00016.safetensors",
|
| 378 |
+
"model.layers.3.mlp.up_proj.weight": "model-00005-of-00016.safetensors",
|
| 379 |
+
"model.layers.3.post_attention_layernorm.weight": "model-00005-of-00016.safetensors",
|
| 380 |
+
"model.layers.3.self_attn.k_proj.weight": "model-00005-of-00016.safetensors",
|
| 381 |
+
"model.layers.3.self_attn.o_proj.weight": "model-00005-of-00016.safetensors",
|
| 382 |
+
"model.layers.3.self_attn.q_proj.weight": "model-00005-of-00016.safetensors",
|
| 383 |
+
"model.layers.3.self_attn.v_proj.weight": "model-00005-of-00016.safetensors",
|
| 384 |
+
"model.layers.30.input_layernorm.weight": "model-00005-of-00016.safetensors",
|
| 385 |
+
"model.layers.30.mlp.down_proj.weight": "model-00005-of-00016.safetensors",
|
| 386 |
+
"model.layers.30.mlp.gate_proj.weight": "model-00005-of-00016.safetensors",
|
| 387 |
+
"model.layers.30.mlp.up_proj.weight": "model-00005-of-00016.safetensors",
|
| 388 |
+
"model.layers.30.post_attention_layernorm.weight": "model-00005-of-00016.safetensors",
|
| 389 |
+
"model.layers.30.self_attn.k_proj.weight": "model-00005-of-00016.safetensors",
|
| 390 |
+
"model.layers.30.self_attn.o_proj.weight": "model-00005-of-00016.safetensors",
|
| 391 |
+
"model.layers.30.self_attn.q_proj.weight": "model-00005-of-00016.safetensors",
|
| 392 |
+
"model.layers.30.self_attn.v_proj.weight": "model-00005-of-00016.safetensors",
|
| 393 |
+
"model.layers.31.input_layernorm.weight": "model-00005-of-00016.safetensors",
|
| 394 |
+
"model.layers.31.mlp.down_proj.weight": "model-00005-of-00016.safetensors",
|
| 395 |
+
"model.layers.31.mlp.gate_proj.weight": "model-00006-of-00016.safetensors",
|
| 396 |
+
"model.layers.31.mlp.up_proj.weight": "model-00006-of-00016.safetensors",
|
| 397 |
+
"model.layers.31.post_attention_layernorm.weight": "model-00006-of-00016.safetensors",
|
| 398 |
+
"model.layers.31.self_attn.k_proj.weight": "model-00006-of-00016.safetensors",
|
| 399 |
+
"model.layers.31.self_attn.o_proj.weight": "model-00006-of-00016.safetensors",
|
| 400 |
+
"model.layers.31.self_attn.q_proj.weight": "model-00006-of-00016.safetensors",
|
| 401 |
+
"model.layers.31.self_attn.v_proj.weight": "model-00006-of-00016.safetensors",
|
| 402 |
+
"model.layers.32.input_layernorm.weight": "model-00006-of-00016.safetensors",
|
| 403 |
+
"model.layers.32.mlp.down_proj.weight": "model-00006-of-00016.safetensors",
|
| 404 |
+
"model.layers.32.mlp.gate_proj.weight": "model-00006-of-00016.safetensors",
|
| 405 |
+
"model.layers.32.mlp.up_proj.weight": "model-00006-of-00016.safetensors",
|
| 406 |
+
"model.layers.32.post_attention_layernorm.weight": "model-00006-of-00016.safetensors",
|
| 407 |
+
"model.layers.32.self_attn.k_proj.weight": "model-00006-of-00016.safetensors",
|
| 408 |
+
"model.layers.32.self_attn.o_proj.weight": "model-00006-of-00016.safetensors",
|
| 409 |
+
"model.layers.32.self_attn.q_proj.weight": "model-00006-of-00016.safetensors",
|
| 410 |
+
"model.layers.32.self_attn.v_proj.weight": "model-00006-of-00016.safetensors",
|
| 411 |
+
"model.layers.33.input_layernorm.weight": "model-00006-of-00016.safetensors",
|
| 412 |
+
"model.layers.33.mlp.down_proj.weight": "model-00006-of-00016.safetensors",
|
| 413 |
+
"model.layers.33.mlp.gate_proj.weight": "model-00006-of-00016.safetensors",
|
| 414 |
+
"model.layers.33.mlp.up_proj.weight": "model-00006-of-00016.safetensors",
|
| 415 |
+
"model.layers.33.post_attention_layernorm.weight": "model-00006-of-00016.safetensors",
|
| 416 |
+
"model.layers.33.self_attn.k_proj.weight": "model-00006-of-00016.safetensors",
|
| 417 |
+
"model.layers.33.self_attn.o_proj.weight": "model-00006-of-00016.safetensors",
|
| 418 |
+
"model.layers.33.self_attn.q_proj.weight": "model-00006-of-00016.safetensors",
|
| 419 |
+
"model.layers.33.self_attn.v_proj.weight": "model-00006-of-00016.safetensors",
|
| 420 |
+
"model.layers.34.input_layernorm.weight": "model-00006-of-00016.safetensors",
|
| 421 |
+
"model.layers.34.mlp.down_proj.weight": "model-00006-of-00016.safetensors",
|
| 422 |
+
"model.layers.34.mlp.gate_proj.weight": "model-00006-of-00016.safetensors",
|
| 423 |
+
"model.layers.34.mlp.up_proj.weight": "model-00006-of-00016.safetensors",
|
| 424 |
+
"model.layers.34.post_attention_layernorm.weight": "model-00006-of-00016.safetensors",
|
| 425 |
+
"model.layers.34.self_attn.k_proj.weight": "model-00006-of-00016.safetensors",
|
| 426 |
+
"model.layers.34.self_attn.o_proj.weight": "model-00006-of-00016.safetensors",
|
| 427 |
+
"model.layers.34.self_attn.q_proj.weight": "model-00006-of-00016.safetensors",
|
| 428 |
+
"model.layers.34.self_attn.v_proj.weight": "model-00006-of-00016.safetensors",
|
| 429 |
+
"model.layers.35.input_layernorm.weight": "model-00006-of-00016.safetensors",
|
| 430 |
+
"model.layers.35.mlp.down_proj.weight": "model-00006-of-00016.safetensors",
|
| 431 |
+
"model.layers.35.mlp.gate_proj.weight": "model-00006-of-00016.safetensors",
|
| 432 |
+
"model.layers.35.mlp.up_proj.weight": "model-00006-of-00016.safetensors",
|
| 433 |
+
"model.layers.35.post_attention_layernorm.weight": "model-00006-of-00016.safetensors",
|
| 434 |
+
"model.layers.35.self_attn.k_proj.weight": "model-00006-of-00016.safetensors",
|
| 435 |
+
"model.layers.35.self_attn.o_proj.weight": "model-00006-of-00016.safetensors",
|
| 436 |
+
"model.layers.35.self_attn.q_proj.weight": "model-00006-of-00016.safetensors",
|
| 437 |
+
"model.layers.35.self_attn.v_proj.weight": "model-00006-of-00016.safetensors",
|
| 438 |
+
"model.layers.36.input_layernorm.weight": "model-00006-of-00016.safetensors",
|
| 439 |
+
"model.layers.36.mlp.down_proj.weight": "model-00006-of-00016.safetensors",
|
| 440 |
+
"model.layers.36.mlp.gate_proj.weight": "model-00006-of-00016.safetensors",
|
| 441 |
+
"model.layers.36.mlp.up_proj.weight": "model-00007-of-00016.safetensors",
|
| 442 |
+
"model.layers.36.post_attention_layernorm.weight": "model-00007-of-00016.safetensors",
|
| 443 |
+
"model.layers.36.self_attn.k_proj.weight": "model-00007-of-00016.safetensors",
|
| 444 |
+
"model.layers.36.self_attn.o_proj.weight": "model-00007-of-00016.safetensors",
|
| 445 |
+
"model.layers.36.self_attn.q_proj.weight": "model-00007-of-00016.safetensors",
|
| 446 |
+
"model.layers.36.self_attn.v_proj.weight": "model-00007-of-00016.safetensors",
|
| 447 |
+
"model.layers.37.input_layernorm.weight": "model-00007-of-00016.safetensors",
|
| 448 |
+
"model.layers.37.mlp.down_proj.weight": "model-00007-of-00016.safetensors",
|
| 449 |
+
"model.layers.37.mlp.gate_proj.weight": "model-00007-of-00016.safetensors",
|
| 450 |
+
"model.layers.37.mlp.up_proj.weight": "model-00007-of-00016.safetensors",
|
| 451 |
+
"model.layers.37.post_attention_layernorm.weight": "model-00007-of-00016.safetensors",
|
| 452 |
+
"model.layers.37.self_attn.k_proj.weight": "model-00007-of-00016.safetensors",
|
| 453 |
+
"model.layers.37.self_attn.o_proj.weight": "model-00007-of-00016.safetensors",
|
| 454 |
+
"model.layers.37.self_attn.q_proj.weight": "model-00007-of-00016.safetensors",
|
| 455 |
+
"model.layers.37.self_attn.v_proj.weight": "model-00007-of-00016.safetensors",
|
| 456 |
+
"model.layers.38.input_layernorm.weight": "model-00007-of-00016.safetensors",
|
| 457 |
+
"model.layers.38.mlp.down_proj.weight": "model-00007-of-00016.safetensors",
|
| 458 |
+
"model.layers.38.mlp.gate_proj.weight": "model-00007-of-00016.safetensors",
|
| 459 |
+
"model.layers.38.mlp.up_proj.weight": "model-00007-of-00016.safetensors",
|
| 460 |
+
"model.layers.38.post_attention_layernorm.weight": "model-00007-of-00016.safetensors",
|
| 461 |
+
"model.layers.38.self_attn.k_proj.weight": "model-00007-of-00016.safetensors",
|
| 462 |
+
"model.layers.38.self_attn.o_proj.weight": "model-00007-of-00016.safetensors",
|
| 463 |
+
"model.layers.38.self_attn.q_proj.weight": "model-00007-of-00016.safetensors",
|
| 464 |
+
"model.layers.38.self_attn.v_proj.weight": "model-00007-of-00016.safetensors",
|
| 465 |
+
"model.layers.39.input_layernorm.weight": "model-00007-of-00016.safetensors",
|
| 466 |
+
"model.layers.39.mlp.down_proj.weight": "model-00007-of-00016.safetensors",
|
| 467 |
+
"model.layers.39.mlp.gate_proj.weight": "model-00007-of-00016.safetensors",
|
| 468 |
+
"model.layers.39.mlp.up_proj.weight": "model-00007-of-00016.safetensors",
|
| 469 |
+
"model.layers.39.post_attention_layernorm.weight": "model-00007-of-00016.safetensors",
|
| 470 |
+
"model.layers.39.self_attn.k_proj.weight": "model-00007-of-00016.safetensors",
|
| 471 |
+
"model.layers.39.self_attn.o_proj.weight": "model-00007-of-00016.safetensors",
|
| 472 |
+
"model.layers.39.self_attn.q_proj.weight": "model-00007-of-00016.safetensors",
|
| 473 |
+
"model.layers.39.self_attn.v_proj.weight": "model-00007-of-00016.safetensors",
|
| 474 |
+
"model.layers.4.input_layernorm.weight": "model-00007-of-00016.safetensors",
|
| 475 |
+
"model.layers.4.mlp.down_proj.weight": "model-00007-of-00016.safetensors",
|
| 476 |
+
"model.layers.4.mlp.gate_proj.weight": "model-00007-of-00016.safetensors",
|
| 477 |
+
"model.layers.4.mlp.up_proj.weight": "model-00007-of-00016.safetensors",
|
| 478 |
+
"model.layers.4.post_attention_layernorm.weight": "model-00007-of-00016.safetensors",
|
| 479 |
+
"model.layers.4.self_attn.k_proj.weight": "model-00007-of-00016.safetensors",
|
| 480 |
+
"model.layers.4.self_attn.o_proj.weight": "model-00007-of-00016.safetensors",
|
| 481 |
+
"model.layers.4.self_attn.q_proj.weight": "model-00007-of-00016.safetensors",
|
| 482 |
+
"model.layers.4.self_attn.v_proj.weight": "model-00007-of-00016.safetensors",
|
| 483 |
+
"model.layers.40.input_layernorm.weight": "model-00007-of-00016.safetensors",
|
| 484 |
+
"model.layers.40.mlp.down_proj.weight": "model-00007-of-00016.safetensors",
|
| 485 |
+
"model.layers.40.mlp.gate_proj.weight": "model-00007-of-00016.safetensors",
|
| 486 |
+
"model.layers.40.mlp.up_proj.weight": "model-00007-of-00016.safetensors",
|
| 487 |
+
"model.layers.40.post_attention_layernorm.weight": "model-00007-of-00016.safetensors",
|
| 488 |
+
"model.layers.40.self_attn.k_proj.weight": "model-00007-of-00016.safetensors",
|
| 489 |
+
"model.layers.40.self_attn.o_proj.weight": "model-00007-of-00016.safetensors",
|
| 490 |
+
"model.layers.40.self_attn.q_proj.weight": "model-00007-of-00016.safetensors",
|
| 491 |
+
"model.layers.40.self_attn.v_proj.weight": "model-00007-of-00016.safetensors",
|
| 492 |
+
"model.layers.41.input_layernorm.weight": "model-00007-of-00016.safetensors",
|
| 493 |
+
"model.layers.41.mlp.down_proj.weight": "model-00008-of-00016.safetensors",
|
| 494 |
+
"model.layers.41.mlp.gate_proj.weight": "model-00008-of-00016.safetensors",
|
| 495 |
+
"model.layers.41.mlp.up_proj.weight": "model-00008-of-00016.safetensors",
|
| 496 |
+
"model.layers.41.post_attention_layernorm.weight": "model-00008-of-00016.safetensors",
|
| 497 |
+
"model.layers.41.self_attn.k_proj.weight": "model-00008-of-00016.safetensors",
|
| 498 |
+
"model.layers.41.self_attn.o_proj.weight": "model-00008-of-00016.safetensors",
|
| 499 |
+
"model.layers.41.self_attn.q_proj.weight": "model-00008-of-00016.safetensors",
|
| 500 |
+
"model.layers.41.self_attn.v_proj.weight": "model-00008-of-00016.safetensors",
|
| 501 |
+
"model.layers.42.input_layernorm.weight": "model-00008-of-00016.safetensors",
|
| 502 |
+
"model.layers.42.mlp.down_proj.weight": "model-00008-of-00016.safetensors",
|
| 503 |
+
"model.layers.42.mlp.gate_proj.weight": "model-00008-of-00016.safetensors",
|
| 504 |
+
"model.layers.42.mlp.up_proj.weight": "model-00008-of-00016.safetensors",
|
| 505 |
+
"model.layers.42.post_attention_layernorm.weight": "model-00008-of-00016.safetensors",
|
| 506 |
+
"model.layers.42.self_attn.k_proj.weight": "model-00008-of-00016.safetensors",
|
| 507 |
+
"model.layers.42.self_attn.o_proj.weight": "model-00008-of-00016.safetensors",
|
| 508 |
+
"model.layers.42.self_attn.q_proj.weight": "model-00008-of-00016.safetensors",
|
| 509 |
+
"model.layers.42.self_attn.v_proj.weight": "model-00008-of-00016.safetensors",
|
| 510 |
+
"model.layers.43.input_layernorm.weight": "model-00008-of-00016.safetensors",
|
| 511 |
+
"model.layers.43.mlp.down_proj.weight": "model-00008-of-00016.safetensors",
|
| 512 |
+
"model.layers.43.mlp.gate_proj.weight": "model-00008-of-00016.safetensors",
|
| 513 |
+
"model.layers.43.mlp.up_proj.weight": "model-00008-of-00016.safetensors",
|
| 514 |
+
"model.layers.43.post_attention_layernorm.weight": "model-00008-of-00016.safetensors",
|
| 515 |
+
"model.layers.43.self_attn.k_proj.weight": "model-00008-of-00016.safetensors",
|
| 516 |
+
"model.layers.43.self_attn.o_proj.weight": "model-00008-of-00016.safetensors",
|
| 517 |
+
"model.layers.43.self_attn.q_proj.weight": "model-00008-of-00016.safetensors",
|
| 518 |
+
"model.layers.43.self_attn.v_proj.weight": "model-00008-of-00016.safetensors",
|
| 519 |
+
"model.layers.44.input_layernorm.weight": "model-00008-of-00016.safetensors",
|
| 520 |
+
"model.layers.44.mlp.down_proj.weight": "model-00008-of-00016.safetensors",
|
| 521 |
+
"model.layers.44.mlp.gate_proj.weight": "model-00008-of-00016.safetensors",
|
| 522 |
+
"model.layers.44.mlp.up_proj.weight": "model-00008-of-00016.safetensors",
|
| 523 |
+
"model.layers.44.post_attention_layernorm.weight": "model-00008-of-00016.safetensors",
|
| 524 |
+
"model.layers.44.self_attn.k_proj.weight": "model-00008-of-00016.safetensors",
|
| 525 |
+
"model.layers.44.self_attn.o_proj.weight": "model-00008-of-00016.safetensors",
|
| 526 |
+
"model.layers.44.self_attn.q_proj.weight": "model-00008-of-00016.safetensors",
|
| 527 |
+
"model.layers.44.self_attn.v_proj.weight": "model-00008-of-00016.safetensors",
|
| 528 |
+
"model.layers.45.input_layernorm.weight": "model-00008-of-00016.safetensors",
|
| 529 |
+
"model.layers.45.mlp.down_proj.weight": "model-00008-of-00016.safetensors",
|
| 530 |
+
"model.layers.45.mlp.gate_proj.weight": "model-00008-of-00016.safetensors",
|
| 531 |
+
"model.layers.45.mlp.up_proj.weight": "model-00008-of-00016.safetensors",
|
| 532 |
+
"model.layers.45.post_attention_layernorm.weight": "model-00008-of-00016.safetensors",
|
| 533 |
+
"model.layers.45.self_attn.k_proj.weight": "model-00008-of-00016.safetensors",
|
| 534 |
+
"model.layers.45.self_attn.o_proj.weight": "model-00008-of-00016.safetensors",
|
| 535 |
+
"model.layers.45.self_attn.q_proj.weight": "model-00008-of-00016.safetensors",
|
| 536 |
+
"model.layers.45.self_attn.v_proj.weight": "model-00008-of-00016.safetensors",
|
| 537 |
+
"model.layers.46.input_layernorm.weight": "model-00008-of-00016.safetensors",
|
| 538 |
+
"model.layers.46.mlp.down_proj.weight": "model-00008-of-00016.safetensors",
|
| 539 |
+
"model.layers.46.mlp.gate_proj.weight": "model-00009-of-00016.safetensors",
|
| 540 |
+
"model.layers.46.mlp.up_proj.weight": "model-00009-of-00016.safetensors",
|
| 541 |
+
"model.layers.46.post_attention_layernorm.weight": "model-00009-of-00016.safetensors",
|
| 542 |
+
"model.layers.46.self_attn.k_proj.weight": "model-00009-of-00016.safetensors",
|
| 543 |
+
"model.layers.46.self_attn.o_proj.weight": "model-00009-of-00016.safetensors",
|
| 544 |
+
"model.layers.46.self_attn.q_proj.weight": "model-00009-of-00016.safetensors",
|
| 545 |
+
"model.layers.46.self_attn.v_proj.weight": "model-00009-of-00016.safetensors",
|
| 546 |
+
"model.layers.47.input_layernorm.weight": "model-00009-of-00016.safetensors",
|
| 547 |
+
"model.layers.47.mlp.down_proj.weight": "model-00009-of-00016.safetensors",
|
| 548 |
+
"model.layers.47.mlp.gate_proj.weight": "model-00009-of-00016.safetensors",
|
| 549 |
+
"model.layers.47.mlp.up_proj.weight": "model-00009-of-00016.safetensors",
|
| 550 |
+
"model.layers.47.post_attention_layernorm.weight": "model-00009-of-00016.safetensors",
|
| 551 |
+
"model.layers.47.self_attn.k_proj.weight": "model-00009-of-00016.safetensors",
|
| 552 |
+
"model.layers.47.self_attn.o_proj.weight": "model-00009-of-00016.safetensors",
|
| 553 |
+
"model.layers.47.self_attn.q_proj.weight": "model-00009-of-00016.safetensors",
|
| 554 |
+
"model.layers.47.self_attn.v_proj.weight": "model-00009-of-00016.safetensors",
|
| 555 |
+
"model.layers.48.input_layernorm.weight": "model-00009-of-00016.safetensors",
|
| 556 |
+
"model.layers.48.mlp.down_proj.weight": "model-00009-of-00016.safetensors",
|
| 557 |
+
"model.layers.48.mlp.gate_proj.weight": "model-00009-of-00016.safetensors",
|
| 558 |
+
"model.layers.48.mlp.up_proj.weight": "model-00009-of-00016.safetensors",
|
| 559 |
+
"model.layers.48.post_attention_layernorm.weight": "model-00009-of-00016.safetensors",
|
| 560 |
+
"model.layers.48.self_attn.k_proj.weight": "model-00009-of-00016.safetensors",
|
| 561 |
+
"model.layers.48.self_attn.o_proj.weight": "model-00009-of-00016.safetensors",
|
| 562 |
+
"model.layers.48.self_attn.q_proj.weight": "model-00009-of-00016.safetensors",
|
| 563 |
+
"model.layers.48.self_attn.v_proj.weight": "model-00009-of-00016.safetensors",
|
| 564 |
+
"model.layers.49.input_layernorm.weight": "model-00009-of-00016.safetensors",
|
| 565 |
+
"model.layers.49.mlp.down_proj.weight": "model-00009-of-00016.safetensors",
|
| 566 |
+
"model.layers.49.mlp.gate_proj.weight": "model-00009-of-00016.safetensors",
|
| 567 |
+
"model.layers.49.mlp.up_proj.weight": "model-00009-of-00016.safetensors",
|
| 568 |
+
"model.layers.49.post_attention_layernorm.weight": "model-00009-of-00016.safetensors",
|
| 569 |
+
"model.layers.49.self_attn.k_proj.weight": "model-00009-of-00016.safetensors",
|
| 570 |
+
"model.layers.49.self_attn.o_proj.weight": "model-00009-of-00016.safetensors",
|
| 571 |
+
"model.layers.49.self_attn.q_proj.weight": "model-00009-of-00016.safetensors",
|
| 572 |
+
"model.layers.49.self_attn.v_proj.weight": "model-00009-of-00016.safetensors",
|
| 573 |
+
"model.layers.5.input_layernorm.weight": "model-00009-of-00016.safetensors",
|
| 574 |
+
"model.layers.5.mlp.down_proj.weight": "model-00009-of-00016.safetensors",
|
| 575 |
+
"model.layers.5.mlp.gate_proj.weight": "model-00009-of-00016.safetensors",
|
| 576 |
+
"model.layers.5.mlp.up_proj.weight": "model-00009-of-00016.safetensors",
|
| 577 |
+
"model.layers.5.post_attention_layernorm.weight": "model-00009-of-00016.safetensors",
|
| 578 |
+
"model.layers.5.self_attn.k_proj.weight": "model-00009-of-00016.safetensors",
|
| 579 |
+
"model.layers.5.self_attn.o_proj.weight": "model-00009-of-00016.safetensors",
|
| 580 |
+
"model.layers.5.self_attn.q_proj.weight": "model-00009-of-00016.safetensors",
|
| 581 |
+
"model.layers.5.self_attn.v_proj.weight": "model-00009-of-00016.safetensors",
|
| 582 |
+
"model.layers.50.input_layernorm.weight": "model-00009-of-00016.safetensors",
|
| 583 |
+
"model.layers.50.mlp.down_proj.weight": "model-00009-of-00016.safetensors",
|
| 584 |
+
"model.layers.50.mlp.gate_proj.weight": "model-00009-of-00016.safetensors",
|
| 585 |
+
"model.layers.50.mlp.up_proj.weight": "model-00010-of-00016.safetensors",
|
| 586 |
+
"model.layers.50.post_attention_layernorm.weight": "model-00010-of-00016.safetensors",
|
| 587 |
+
"model.layers.50.self_attn.k_proj.weight": "model-00010-of-00016.safetensors",
|
| 588 |
+
"model.layers.50.self_attn.o_proj.weight": "model-00010-of-00016.safetensors",
|
| 589 |
+
"model.layers.50.self_attn.q_proj.weight": "model-00010-of-00016.safetensors",
|
| 590 |
+
"model.layers.50.self_attn.v_proj.weight": "model-00010-of-00016.safetensors",
|
| 591 |
+
"model.layers.51.input_layernorm.weight": "model-00010-of-00016.safetensors",
|
| 592 |
+
"model.layers.51.mlp.down_proj.weight": "model-00010-of-00016.safetensors",
|
| 593 |
+
"model.layers.51.mlp.gate_proj.weight": "model-00010-of-00016.safetensors",
|
| 594 |
+
"model.layers.51.mlp.up_proj.weight": "model-00010-of-00016.safetensors",
|
| 595 |
+
"model.layers.51.post_attention_layernorm.weight": "model-00010-of-00016.safetensors",
|
| 596 |
+
"model.layers.51.self_attn.k_proj.weight": "model-00010-of-00016.safetensors",
|
| 597 |
+
"model.layers.51.self_attn.o_proj.weight": "model-00010-of-00016.safetensors",
|
| 598 |
+
"model.layers.51.self_attn.q_proj.weight": "model-00010-of-00016.safetensors",
|
| 599 |
+
"model.layers.51.self_attn.v_proj.weight": "model-00010-of-00016.safetensors",
|
| 600 |
+
"model.layers.52.input_layernorm.weight": "model-00010-of-00016.safetensors",
|
| 601 |
+
"model.layers.52.mlp.down_proj.weight": "model-00010-of-00016.safetensors",
|
| 602 |
+
"model.layers.52.mlp.gate_proj.weight": "model-00010-of-00016.safetensors",
|
| 603 |
+
"model.layers.52.mlp.up_proj.weight": "model-00010-of-00016.safetensors",
|
| 604 |
+
"model.layers.52.post_attention_layernorm.weight": "model-00010-of-00016.safetensors",
|
| 605 |
+
"model.layers.52.self_attn.k_proj.weight": "model-00010-of-00016.safetensors",
|
| 606 |
+
"model.layers.52.self_attn.o_proj.weight": "model-00010-of-00016.safetensors",
|
| 607 |
+
"model.layers.52.self_attn.q_proj.weight": "model-00010-of-00016.safetensors",
|
| 608 |
+
"model.layers.52.self_attn.v_proj.weight": "model-00010-of-00016.safetensors",
|
| 609 |
+
"model.layers.53.input_layernorm.weight": "model-00010-of-00016.safetensors",
|
| 610 |
+
"model.layers.53.mlp.down_proj.weight": "model-00010-of-00016.safetensors",
|
| 611 |
+
"model.layers.53.mlp.gate_proj.weight": "model-00010-of-00016.safetensors",
|
| 612 |
+
"model.layers.53.mlp.up_proj.weight": "model-00010-of-00016.safetensors",
|
| 613 |
+
"model.layers.53.post_attention_layernorm.weight": "model-00010-of-00016.safetensors",
|
| 614 |
+
"model.layers.53.self_attn.k_proj.weight": "model-00010-of-00016.safetensors",
|
| 615 |
+
"model.layers.53.self_attn.o_proj.weight": "model-00010-of-00016.safetensors",
|
| 616 |
+
"model.layers.53.self_attn.q_proj.weight": "model-00010-of-00016.safetensors",
|
| 617 |
+
"model.layers.53.self_attn.v_proj.weight": "model-00010-of-00016.safetensors",
|
| 618 |
+
"model.layers.54.input_layernorm.weight": "model-00010-of-00016.safetensors",
|
| 619 |
+
"model.layers.54.mlp.down_proj.weight": "model-00010-of-00016.safetensors",
|
| 620 |
+
"model.layers.54.mlp.gate_proj.weight": "model-00010-of-00016.safetensors",
|
| 621 |
+
"model.layers.54.mlp.up_proj.weight": "model-00010-of-00016.safetensors",
|
| 622 |
+
"model.layers.54.post_attention_layernorm.weight": "model-00010-of-00016.safetensors",
|
| 623 |
+
"model.layers.54.self_attn.k_proj.weight": "model-00010-of-00016.safetensors",
|
| 624 |
+
"model.layers.54.self_attn.o_proj.weight": "model-00010-of-00016.safetensors",
|
| 625 |
+
"model.layers.54.self_attn.q_proj.weight": "model-00010-of-00016.safetensors",
|
| 626 |
+
"model.layers.54.self_attn.v_proj.weight": "model-00010-of-00016.safetensors",
|
| 627 |
+
"model.layers.55.input_layernorm.weight": "model-00010-of-00016.safetensors",
|
| 628 |
+
"model.layers.55.mlp.down_proj.weight": "model-00010-of-00016.safetensors",
|
| 629 |
+
"model.layers.55.mlp.gate_proj.weight": "model-00010-of-00016.safetensors",
|
| 630 |
+
"model.layers.55.mlp.up_proj.weight": "model-00010-of-00016.safetensors",
|
| 631 |
+
"model.layers.55.post_attention_layernorm.weight": "model-00010-of-00016.safetensors",
|
| 632 |
+
"model.layers.55.self_attn.k_proj.weight": "model-00010-of-00016.safetensors",
|
| 633 |
+
"model.layers.55.self_attn.o_proj.weight": "model-00010-of-00016.safetensors",
|
| 634 |
+
"model.layers.55.self_attn.q_proj.weight": "model-00010-of-00016.safetensors",
|
| 635 |
+
"model.layers.55.self_attn.v_proj.weight": "model-00010-of-00016.safetensors",
|
| 636 |
+
"model.layers.56.input_layernorm.weight": "model-00010-of-00016.safetensors",
|
| 637 |
+
"model.layers.56.mlp.down_proj.weight": "model-00011-of-00016.safetensors",
|
| 638 |
+
"model.layers.56.mlp.gate_proj.weight": "model-00011-of-00016.safetensors",
|
| 639 |
+
"model.layers.56.mlp.up_proj.weight": "model-00011-of-00016.safetensors",
|
| 640 |
+
"model.layers.56.post_attention_layernorm.weight": "model-00011-of-00016.safetensors",
|
| 641 |
+
"model.layers.56.self_attn.k_proj.weight": "model-00011-of-00016.safetensors",
|
| 642 |
+
"model.layers.56.self_attn.o_proj.weight": "model-00011-of-00016.safetensors",
|
| 643 |
+
"model.layers.56.self_attn.q_proj.weight": "model-00011-of-00016.safetensors",
|
| 644 |
+
"model.layers.56.self_attn.v_proj.weight": "model-00011-of-00016.safetensors",
|
| 645 |
+
"model.layers.57.input_layernorm.weight": "model-00011-of-00016.safetensors",
|
| 646 |
+
"model.layers.57.mlp.down_proj.weight": "model-00011-of-00016.safetensors",
|
| 647 |
+
"model.layers.57.mlp.gate_proj.weight": "model-00011-of-00016.safetensors",
|
| 648 |
+
"model.layers.57.mlp.up_proj.weight": "model-00011-of-00016.safetensors",
|
| 649 |
+
"model.layers.57.post_attention_layernorm.weight": "model-00011-of-00016.safetensors",
|
| 650 |
+
"model.layers.57.self_attn.k_proj.weight": "model-00011-of-00016.safetensors",
|
| 651 |
+
"model.layers.57.self_attn.o_proj.weight": "model-00011-of-00016.safetensors",
|
| 652 |
+
"model.layers.57.self_attn.q_proj.weight": "model-00011-of-00016.safetensors",
|
| 653 |
+
"model.layers.57.self_attn.v_proj.weight": "model-00011-of-00016.safetensors",
|
| 654 |
+
"model.layers.58.input_layernorm.weight": "model-00011-of-00016.safetensors",
|
| 655 |
+
"model.layers.58.mlp.down_proj.weight": "model-00011-of-00016.safetensors",
|
| 656 |
+
"model.layers.58.mlp.gate_proj.weight": "model-00011-of-00016.safetensors",
|
| 657 |
+
"model.layers.58.mlp.up_proj.weight": "model-00011-of-00016.safetensors",
|
| 658 |
+
"model.layers.58.post_attention_layernorm.weight": "model-00011-of-00016.safetensors",
|
| 659 |
+
"model.layers.58.self_attn.k_proj.weight": "model-00011-of-00016.safetensors",
|
| 660 |
+
"model.layers.58.self_attn.o_proj.weight": "model-00011-of-00016.safetensors",
|
| 661 |
+
"model.layers.58.self_attn.q_proj.weight": "model-00011-of-00016.safetensors",
|
| 662 |
+
"model.layers.58.self_attn.v_proj.weight": "model-00011-of-00016.safetensors",
|
| 663 |
+
"model.layers.59.input_layernorm.weight": "model-00011-of-00016.safetensors",
|
| 664 |
+
"model.layers.59.mlp.down_proj.weight": "model-00011-of-00016.safetensors",
|
| 665 |
+
"model.layers.59.mlp.gate_proj.weight": "model-00011-of-00016.safetensors",
|
| 666 |
+
"model.layers.59.mlp.up_proj.weight": "model-00011-of-00016.safetensors",
|
| 667 |
+
"model.layers.59.post_attention_layernorm.weight": "model-00011-of-00016.safetensors",
|
| 668 |
+
"model.layers.59.self_attn.k_proj.weight": "model-00011-of-00016.safetensors",
|
| 669 |
+
"model.layers.59.self_attn.o_proj.weight": "model-00011-of-00016.safetensors",
|
| 670 |
+
"model.layers.59.self_attn.q_proj.weight": "model-00011-of-00016.safetensors",
|
| 671 |
+
"model.layers.59.self_attn.v_proj.weight": "model-00011-of-00016.safetensors",
|
| 672 |
+
"model.layers.6.input_layernorm.weight": "model-00011-of-00016.safetensors",
|
| 673 |
+
"model.layers.6.mlp.down_proj.weight": "model-00011-of-00016.safetensors",
|
| 674 |
+
"model.layers.6.mlp.gate_proj.weight": "model-00011-of-00016.safetensors",
|
| 675 |
+
"model.layers.6.mlp.up_proj.weight": "model-00011-of-00016.safetensors",
|
| 676 |
+
"model.layers.6.post_attention_layernorm.weight": "model-00011-of-00016.safetensors",
|
| 677 |
+
"model.layers.6.self_attn.k_proj.weight": "model-00011-of-00016.safetensors",
|
| 678 |
+
"model.layers.6.self_attn.o_proj.weight": "model-00011-of-00016.safetensors",
|
| 679 |
+
"model.layers.6.self_attn.q_proj.weight": "model-00011-of-00016.safetensors",
|
| 680 |
+
"model.layers.6.self_attn.v_proj.weight": "model-00011-of-00016.safetensors",
|
| 681 |
+
"model.layers.60.input_layernorm.weight": "model-00011-of-00016.safetensors",
|
| 682 |
+
"model.layers.60.mlp.down_proj.weight": "model-00011-of-00016.safetensors",
|
| 683 |
+
"model.layers.60.mlp.gate_proj.weight": "model-00012-of-00016.safetensors",
|
| 684 |
+
"model.layers.60.mlp.up_proj.weight": "model-00012-of-00016.safetensors",
|
| 685 |
+
"model.layers.60.post_attention_layernorm.weight": "model-00012-of-00016.safetensors",
|
| 686 |
+
"model.layers.60.self_attn.k_proj.weight": "model-00012-of-00016.safetensors",
|
| 687 |
+
"model.layers.60.self_attn.o_proj.weight": "model-00012-of-00016.safetensors",
|
| 688 |
+
"model.layers.60.self_attn.q_proj.weight": "model-00012-of-00016.safetensors",
|
| 689 |
+
"model.layers.60.self_attn.v_proj.weight": "model-00012-of-00016.safetensors",
|
| 690 |
+
"model.layers.61.input_layernorm.weight": "model-00012-of-00016.safetensors",
|
| 691 |
+
"model.layers.61.mlp.down_proj.weight": "model-00012-of-00016.safetensors",
|
| 692 |
+
"model.layers.61.mlp.gate_proj.weight": "model-00012-of-00016.safetensors",
|
| 693 |
+
"model.layers.61.mlp.up_proj.weight": "model-00012-of-00016.safetensors",
|
| 694 |
+
"model.layers.61.post_attention_layernorm.weight": "model-00012-of-00016.safetensors",
|
| 695 |
+
"model.layers.61.self_attn.k_proj.weight": "model-00012-of-00016.safetensors",
|
| 696 |
+
"model.layers.61.self_attn.o_proj.weight": "model-00012-of-00016.safetensors",
|
| 697 |
+
"model.layers.61.self_attn.q_proj.weight": "model-00012-of-00016.safetensors",
|
| 698 |
+
"model.layers.61.self_attn.v_proj.weight": "model-00012-of-00016.safetensors",
|
| 699 |
+
"model.layers.62.input_layernorm.weight": "model-00012-of-00016.safetensors",
|
| 700 |
+
"model.layers.62.mlp.down_proj.weight": "model-00012-of-00016.safetensors",
|
| 701 |
+
"model.layers.62.mlp.gate_proj.weight": "model-00012-of-00016.safetensors",
|
| 702 |
+
"model.layers.62.mlp.up_proj.weight": "model-00012-of-00016.safetensors",
|
| 703 |
+
"model.layers.62.post_attention_layernorm.weight": "model-00012-of-00016.safetensors",
|
| 704 |
+
"model.layers.62.self_attn.k_proj.weight": "model-00012-of-00016.safetensors",
|
| 705 |
+
"model.layers.62.self_attn.o_proj.weight": "model-00012-of-00016.safetensors",
|
| 706 |
+
"model.layers.62.self_attn.q_proj.weight": "model-00012-of-00016.safetensors",
|
| 707 |
+
"model.layers.62.self_attn.v_proj.weight": "model-00012-of-00016.safetensors",
|
| 708 |
+
"model.layers.63.input_layernorm.weight": "model-00012-of-00016.safetensors",
|
| 709 |
+
"model.layers.63.mlp.down_proj.weight": "model-00012-of-00016.safetensors",
|
| 710 |
+
"model.layers.63.mlp.gate_proj.weight": "model-00012-of-00016.safetensors",
|
| 711 |
+
"model.layers.63.mlp.up_proj.weight": "model-00012-of-00016.safetensors",
|
| 712 |
+
"model.layers.63.post_attention_layernorm.weight": "model-00012-of-00016.safetensors",
|
| 713 |
+
"model.layers.63.self_attn.k_proj.weight": "model-00012-of-00016.safetensors",
|
| 714 |
+
"model.layers.63.self_attn.o_proj.weight": "model-00012-of-00016.safetensors",
|
| 715 |
+
"model.layers.63.self_attn.q_proj.weight": "model-00012-of-00016.safetensors",
|
| 716 |
+
"model.layers.63.self_attn.v_proj.weight": "model-00012-of-00016.safetensors",
|
| 717 |
+
"model.layers.64.input_layernorm.weight": "model-00012-of-00016.safetensors",
|
| 718 |
+
"model.layers.64.mlp.down_proj.weight": "model-00012-of-00016.safetensors",
|
| 719 |
+
"model.layers.64.mlp.gate_proj.weight": "model-00012-of-00016.safetensors",
|
| 720 |
+
"model.layers.64.mlp.up_proj.weight": "model-00012-of-00016.safetensors",
|
| 721 |
+
"model.layers.64.post_attention_layernorm.weight": "model-00012-of-00016.safetensors",
|
| 722 |
+
"model.layers.64.self_attn.k_proj.weight": "model-00012-of-00016.safetensors",
|
| 723 |
+
"model.layers.64.self_attn.o_proj.weight": "model-00012-of-00016.safetensors",
|
| 724 |
+
"model.layers.64.self_attn.q_proj.weight": "model-00012-of-00016.safetensors",
|
| 725 |
+
"model.layers.64.self_attn.v_proj.weight": "model-00012-of-00016.safetensors",
|
| 726 |
+
"model.layers.65.input_layernorm.weight": "model-00012-of-00016.safetensors",
|
| 727 |
+
"model.layers.65.mlp.down_proj.weight": "model-00012-of-00016.safetensors",
|
| 728 |
+
"model.layers.65.mlp.gate_proj.weight": "model-00012-of-00016.safetensors",
|
| 729 |
+
"model.layers.65.mlp.up_proj.weight": "model-00013-of-00016.safetensors",
|
| 730 |
+
"model.layers.65.post_attention_layernorm.weight": "model-00013-of-00016.safetensors",
|
| 731 |
+
"model.layers.65.self_attn.k_proj.weight": "model-00013-of-00016.safetensors",
|
| 732 |
+
"model.layers.65.self_attn.o_proj.weight": "model-00013-of-00016.safetensors",
|
| 733 |
+
"model.layers.65.self_attn.q_proj.weight": "model-00013-of-00016.safetensors",
|
| 734 |
+
"model.layers.65.self_attn.v_proj.weight": "model-00013-of-00016.safetensors",
|
| 735 |
+
"model.layers.66.input_layernorm.weight": "model-00013-of-00016.safetensors",
|
| 736 |
+
"model.layers.66.mlp.down_proj.weight": "model-00013-of-00016.safetensors",
|
| 737 |
+
"model.layers.66.mlp.gate_proj.weight": "model-00013-of-00016.safetensors",
|
| 738 |
+
"model.layers.66.mlp.up_proj.weight": "model-00013-of-00016.safetensors",
|
| 739 |
+
"model.layers.66.post_attention_layernorm.weight": "model-00013-of-00016.safetensors",
|
| 740 |
+
"model.layers.66.self_attn.k_proj.weight": "model-00013-of-00016.safetensors",
|
| 741 |
+
"model.layers.66.self_attn.o_proj.weight": "model-00013-of-00016.safetensors",
|
| 742 |
+
"model.layers.66.self_attn.q_proj.weight": "model-00013-of-00016.safetensors",
|
| 743 |
+
"model.layers.66.self_attn.v_proj.weight": "model-00013-of-00016.safetensors",
|
| 744 |
+
"model.layers.67.input_layernorm.weight": "model-00013-of-00016.safetensors",
|
| 745 |
+
"model.layers.67.mlp.down_proj.weight": "model-00013-of-00016.safetensors",
|
| 746 |
+
"model.layers.67.mlp.gate_proj.weight": "model-00013-of-00016.safetensors",
|
| 747 |
+
"model.layers.67.mlp.up_proj.weight": "model-00013-of-00016.safetensors",
|
| 748 |
+
"model.layers.67.post_attention_layernorm.weight": "model-00013-of-00016.safetensors",
|
| 749 |
+
"model.layers.67.self_attn.k_proj.weight": "model-00013-of-00016.safetensors",
|
| 750 |
+
"model.layers.67.self_attn.o_proj.weight": "model-00013-of-00016.safetensors",
|
| 751 |
+
"model.layers.67.self_attn.q_proj.weight": "model-00013-of-00016.safetensors",
|
| 752 |
+
"model.layers.67.self_attn.v_proj.weight": "model-00013-of-00016.safetensors",
|
| 753 |
+
"model.layers.68.input_layernorm.weight": "model-00013-of-00016.safetensors",
|
| 754 |
+
"model.layers.68.mlp.down_proj.weight": "model-00013-of-00016.safetensors",
|
| 755 |
+
"model.layers.68.mlp.gate_proj.weight": "model-00013-of-00016.safetensors",
|
| 756 |
+
"model.layers.68.mlp.up_proj.weight": "model-00013-of-00016.safetensors",
|
| 757 |
+
"model.layers.68.post_attention_layernorm.weight": "model-00013-of-00016.safetensors",
|
| 758 |
+
"model.layers.68.self_attn.k_proj.weight": "model-00013-of-00016.safetensors",
|
| 759 |
+
"model.layers.68.self_attn.o_proj.weight": "model-00013-of-00016.safetensors",
|
| 760 |
+
"model.layers.68.self_attn.q_proj.weight": "model-00013-of-00016.safetensors",
|
| 761 |
+
"model.layers.68.self_attn.v_proj.weight": "model-00013-of-00016.safetensors",
|
| 762 |
+
"model.layers.69.input_layernorm.weight": "model-00013-of-00016.safetensors",
|
| 763 |
+
"model.layers.69.mlp.down_proj.weight": "model-00013-of-00016.safetensors",
|
| 764 |
+
"model.layers.69.mlp.gate_proj.weight": "model-00013-of-00016.safetensors",
|
| 765 |
+
"model.layers.69.mlp.up_proj.weight": "model-00013-of-00016.safetensors",
|
| 766 |
+
"model.layers.69.post_attention_layernorm.weight": "model-00013-of-00016.safetensors",
|
| 767 |
+
"model.layers.69.self_attn.k_proj.weight": "model-00013-of-00016.safetensors",
|
| 768 |
+
"model.layers.69.self_attn.o_proj.weight": "model-00013-of-00016.safetensors",
|
| 769 |
+
"model.layers.69.self_attn.q_proj.weight": "model-00013-of-00016.safetensors",
|
| 770 |
+
"model.layers.69.self_attn.v_proj.weight": "model-00013-of-00016.safetensors",
|
| 771 |
+
"model.layers.7.input_layernorm.weight": "model-00013-of-00016.safetensors",
|
| 772 |
+
"model.layers.7.mlp.down_proj.weight": "model-00013-of-00016.safetensors",
|
| 773 |
+
"model.layers.7.mlp.gate_proj.weight": "model-00013-of-00016.safetensors",
|
| 774 |
+
"model.layers.7.mlp.up_proj.weight": "model-00013-of-00016.safetensors",
|
| 775 |
+
"model.layers.7.post_attention_layernorm.weight": "model-00013-of-00016.safetensors",
|
| 776 |
+
"model.layers.7.self_attn.k_proj.weight": "model-00013-of-00016.safetensors",
|
| 777 |
+
"model.layers.7.self_attn.o_proj.weight": "model-00013-of-00016.safetensors",
|
| 778 |
+
"model.layers.7.self_attn.q_proj.weight": "model-00013-of-00016.safetensors",
|
| 779 |
+
"model.layers.7.self_attn.v_proj.weight": "model-00013-of-00016.safetensors",
|
| 780 |
+
"model.layers.70.input_layernorm.weight": "model-00013-of-00016.safetensors",
|
| 781 |
+
"model.layers.70.mlp.down_proj.weight": "model-00014-of-00016.safetensors",
|
| 782 |
+
"model.layers.70.mlp.gate_proj.weight": "model-00014-of-00016.safetensors",
|
| 783 |
+
"model.layers.70.mlp.up_proj.weight": "model-00014-of-00016.safetensors",
|
| 784 |
+
"model.layers.70.post_attention_layernorm.weight": "model-00014-of-00016.safetensors",
|
| 785 |
+
"model.layers.70.self_attn.k_proj.weight": "model-00014-of-00016.safetensors",
|
| 786 |
+
"model.layers.70.self_attn.o_proj.weight": "model-00014-of-00016.safetensors",
|
| 787 |
+
"model.layers.70.self_attn.q_proj.weight": "model-00014-of-00016.safetensors",
|
| 788 |
+
"model.layers.70.self_attn.v_proj.weight": "model-00014-of-00016.safetensors",
|
| 789 |
+
"model.layers.71.input_layernorm.weight": "model-00014-of-00016.safetensors",
|
| 790 |
+
"model.layers.71.mlp.down_proj.weight": "model-00014-of-00016.safetensors",
|
| 791 |
+
"model.layers.71.mlp.gate_proj.weight": "model-00014-of-00016.safetensors",
|
| 792 |
+
"model.layers.71.mlp.up_proj.weight": "model-00014-of-00016.safetensors",
|
| 793 |
+
"model.layers.71.post_attention_layernorm.weight": "model-00014-of-00016.safetensors",
|
| 794 |
+
"model.layers.71.self_attn.k_proj.weight": "model-00014-of-00016.safetensors",
|
| 795 |
+
"model.layers.71.self_attn.o_proj.weight": "model-00014-of-00016.safetensors",
|
| 796 |
+
"model.layers.71.self_attn.q_proj.weight": "model-00014-of-00016.safetensors",
|
| 797 |
+
"model.layers.71.self_attn.v_proj.weight": "model-00014-of-00016.safetensors",
|
| 798 |
+
"model.layers.72.input_layernorm.weight": "model-00014-of-00016.safetensors",
|
| 799 |
+
"model.layers.72.mlp.down_proj.weight": "model-00014-of-00016.safetensors",
|
| 800 |
+
"model.layers.72.mlp.gate_proj.weight": "model-00014-of-00016.safetensors",
|
| 801 |
+
"model.layers.72.mlp.up_proj.weight": "model-00014-of-00016.safetensors",
|
| 802 |
+
"model.layers.72.post_attention_layernorm.weight": "model-00014-of-00016.safetensors",
|
| 803 |
+
"model.layers.72.self_attn.k_proj.weight": "model-00014-of-00016.safetensors",
|
| 804 |
+
"model.layers.72.self_attn.o_proj.weight": "model-00014-of-00016.safetensors",
|
| 805 |
+
"model.layers.72.self_attn.q_proj.weight": "model-00014-of-00016.safetensors",
|
| 806 |
+
"model.layers.72.self_attn.v_proj.weight": "model-00014-of-00016.safetensors",
|
| 807 |
+
"model.layers.73.input_layernorm.weight": "model-00014-of-00016.safetensors",
|
| 808 |
+
"model.layers.73.mlp.down_proj.weight": "model-00014-of-00016.safetensors",
|
| 809 |
+
"model.layers.73.mlp.gate_proj.weight": "model-00014-of-00016.safetensors",
|
| 810 |
+
"model.layers.73.mlp.up_proj.weight": "model-00014-of-00016.safetensors",
|
| 811 |
+
"model.layers.73.post_attention_layernorm.weight": "model-00014-of-00016.safetensors",
|
| 812 |
+
"model.layers.73.self_attn.k_proj.weight": "model-00014-of-00016.safetensors",
|
| 813 |
+
"model.layers.73.self_attn.o_proj.weight": "model-00014-of-00016.safetensors",
|
| 814 |
+
"model.layers.73.self_attn.q_proj.weight": "model-00014-of-00016.safetensors",
|
| 815 |
+
"model.layers.73.self_attn.v_proj.weight": "model-00014-of-00016.safetensors",
|
| 816 |
+
"model.layers.74.input_layernorm.weight": "model-00014-of-00016.safetensors",
|
| 817 |
+
"model.layers.74.mlp.down_proj.weight": "model-00014-of-00016.safetensors",
|
| 818 |
+
"model.layers.74.mlp.gate_proj.weight": "model-00014-of-00016.safetensors",
|
| 819 |
+
"model.layers.74.mlp.up_proj.weight": "model-00014-of-00016.safetensors",
|
| 820 |
+
"model.layers.74.post_attention_layernorm.weight": "model-00014-of-00016.safetensors",
|
| 821 |
+
"model.layers.74.self_attn.k_proj.weight": "model-00014-of-00016.safetensors",
|
| 822 |
+
"model.layers.74.self_attn.o_proj.weight": "model-00014-of-00016.safetensors",
|
| 823 |
+
"model.layers.74.self_attn.q_proj.weight": "model-00014-of-00016.safetensors",
|
| 824 |
+
"model.layers.74.self_attn.v_proj.weight": "model-00014-of-00016.safetensors",
|
| 825 |
+
"model.layers.75.input_layernorm.weight": "model-00014-of-00016.safetensors",
|
| 826 |
+
"model.layers.75.mlp.down_proj.weight": "model-00014-of-00016.safetensors",
|
| 827 |
+
"model.layers.75.mlp.gate_proj.weight": "model-00015-of-00016.safetensors",
|
| 828 |
+
"model.layers.75.mlp.up_proj.weight": "model-00015-of-00016.safetensors",
|
| 829 |
+
"model.layers.75.post_attention_layernorm.weight": "model-00015-of-00016.safetensors",
|
| 830 |
+
"model.layers.75.self_attn.k_proj.weight": "model-00015-of-00016.safetensors",
|
| 831 |
+
"model.layers.75.self_attn.o_proj.weight": "model-00015-of-00016.safetensors",
|
| 832 |
+
"model.layers.75.self_attn.q_proj.weight": "model-00015-of-00016.safetensors",
|
| 833 |
+
"model.layers.75.self_attn.v_proj.weight": "model-00015-of-00016.safetensors",
|
| 834 |
+
"model.layers.76.input_layernorm.weight": "model-00015-of-00016.safetensors",
|
| 835 |
+
"model.layers.76.mlp.down_proj.weight": "model-00015-of-00016.safetensors",
|
| 836 |
+
"model.layers.76.mlp.gate_proj.weight": "model-00015-of-00016.safetensors",
|
| 837 |
+
"model.layers.76.mlp.up_proj.weight": "model-00015-of-00016.safetensors",
|
| 838 |
+
"model.layers.76.post_attention_layernorm.weight": "model-00015-of-00016.safetensors",
|
| 839 |
+
"model.layers.76.self_attn.k_proj.weight": "model-00015-of-00016.safetensors",
|
| 840 |
+
"model.layers.76.self_attn.o_proj.weight": "model-00015-of-00016.safetensors",
|
| 841 |
+
"model.layers.76.self_attn.q_proj.weight": "model-00015-of-00016.safetensors",
|
| 842 |
+
"model.layers.76.self_attn.v_proj.weight": "model-00015-of-00016.safetensors",
|
| 843 |
+
"model.layers.77.input_layernorm.weight": "model-00015-of-00016.safetensors",
|
| 844 |
+
"model.layers.77.mlp.down_proj.weight": "model-00015-of-00016.safetensors",
|
| 845 |
+
"model.layers.77.mlp.gate_proj.weight": "model-00015-of-00016.safetensors",
|
| 846 |
+
"model.layers.77.mlp.up_proj.weight": "model-00015-of-00016.safetensors",
|
| 847 |
+
"model.layers.77.post_attention_layernorm.weight": "model-00015-of-00016.safetensors",
|
| 848 |
+
"model.layers.77.self_attn.k_proj.weight": "model-00015-of-00016.safetensors",
|
| 849 |
+
"model.layers.77.self_attn.o_proj.weight": "model-00015-of-00016.safetensors",
|
| 850 |
+
"model.layers.77.self_attn.q_proj.weight": "model-00015-of-00016.safetensors",
|
| 851 |
+
"model.layers.77.self_attn.v_proj.weight": "model-00015-of-00016.safetensors",
|
| 852 |
+
"model.layers.78.input_layernorm.weight": "model-00015-of-00016.safetensors",
|
| 853 |
+
"model.layers.78.mlp.down_proj.weight": "model-00015-of-00016.safetensors",
|
| 854 |
+
"model.layers.78.mlp.gate_proj.weight": "model-00015-of-00016.safetensors",
|
| 855 |
+
"model.layers.78.mlp.up_proj.weight": "model-00015-of-00016.safetensors",
|
| 856 |
+
"model.layers.78.post_attention_layernorm.weight": "model-00015-of-00016.safetensors",
|
| 857 |
+
"model.layers.78.self_attn.k_proj.weight": "model-00015-of-00016.safetensors",
|
| 858 |
+
"model.layers.78.self_attn.o_proj.weight": "model-00015-of-00016.safetensors",
|
| 859 |
+
"model.layers.78.self_attn.q_proj.weight": "model-00015-of-00016.safetensors",
|
| 860 |
+
"model.layers.78.self_attn.v_proj.weight": "model-00015-of-00016.safetensors",
|
| 861 |
+
"model.layers.79.input_layernorm.weight": "model-00015-of-00016.safetensors",
|
| 862 |
+
"model.layers.79.mlp.down_proj.weight": "model-00015-of-00016.safetensors",
|
| 863 |
+
"model.layers.79.mlp.gate_proj.weight": "model-00015-of-00016.safetensors",
|
| 864 |
+
"model.layers.79.mlp.up_proj.weight": "model-00015-of-00016.safetensors",
|
| 865 |
+
"model.layers.79.post_attention_layernorm.weight": "model-00015-of-00016.safetensors",
|
| 866 |
+
"model.layers.79.self_attn.k_proj.weight": "model-00015-of-00016.safetensors",
|
| 867 |
+
"model.layers.79.self_attn.o_proj.weight": "model-00015-of-00016.safetensors",
|
| 868 |
+
"model.layers.79.self_attn.q_proj.weight": "model-00015-of-00016.safetensors",
|
| 869 |
+
"model.layers.79.self_attn.v_proj.weight": "model-00015-of-00016.safetensors",
|
| 870 |
+
"model.layers.8.input_layernorm.weight": "model-00015-of-00016.safetensors",
|
| 871 |
+
"model.layers.8.mlp.down_proj.weight": "model-00015-of-00016.safetensors",
|
| 872 |
+
"model.layers.8.mlp.gate_proj.weight": "model-00015-of-00016.safetensors",
|
| 873 |
+
"model.layers.8.mlp.up_proj.weight": "model-00016-of-00016.safetensors",
|
| 874 |
+
"model.layers.8.post_attention_layernorm.weight": "model-00016-of-00016.safetensors",
|
| 875 |
+
"model.layers.8.self_attn.k_proj.weight": "model-00016-of-00016.safetensors",
|
| 876 |
+
"model.layers.8.self_attn.o_proj.weight": "model-00016-of-00016.safetensors",
|
| 877 |
+
"model.layers.8.self_attn.q_proj.weight": "model-00016-of-00016.safetensors",
|
| 878 |
+
"model.layers.8.self_attn.v_proj.weight": "model-00016-of-00016.safetensors",
|
| 879 |
+
"model.layers.9.input_layernorm.weight": "model-00016-of-00016.safetensors",
|
| 880 |
+
"model.layers.9.mlp.down_proj.weight": "model-00016-of-00016.safetensors",
|
| 881 |
+
"model.layers.9.mlp.gate_proj.weight": "model-00016-of-00016.safetensors",
|
| 882 |
+
"model.layers.9.mlp.up_proj.weight": "model-00016-of-00016.safetensors",
|
| 883 |
+
"model.layers.9.post_attention_layernorm.weight": "model-00016-of-00016.safetensors",
|
| 884 |
+
"model.layers.9.self_attn.k_proj.weight": "model-00016-of-00016.safetensors",
|
| 885 |
+
"model.layers.9.self_attn.o_proj.weight": "model-00016-of-00016.safetensors",
|
| 886 |
+
"model.layers.9.self_attn.q_proj.weight": "model-00016-of-00016.safetensors",
|
| 887 |
+
"model.layers.9.self_attn.v_proj.weight": "model-00016-of-00016.safetensors",
|
| 888 |
+
"model.norm.weight": "model-00016-of-00016.safetensors"
|
| 889 |
+
}
|
| 890 |
+
}
|
modeling_iquestloopcoder.py
ADDED
|
@@ -0,0 +1,1411 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2024 IQuestLoopCoder Authors
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
"""
|
| 6 |
+
IQuestLoopCoder Model Implementation for HuggingFace.
|
| 7 |
+
|
| 8 |
+
Loop model passes hidden states through the decoder multiple times:
|
| 9 |
+
- Loop 1: Standard attention, stores K1, V1 for each layer
|
| 10 |
+
- Loop 2+: Mixed attention with gated combination of:
|
| 11 |
+
- A: Full attention with Loop1's KV (global context)
|
| 12 |
+
- B: Sliding window attention with Loop2's KV (local, high-precision context)
|
| 13 |
+
- Gate g = sigmoid(linear(Q)), per-head
|
| 14 |
+
- Output = g * A + (1 - g) * B
|
| 15 |
+
"""
|
| 16 |
+
|
| 17 |
+
import math
|
| 18 |
+
from typing import Any, List, Optional, Tuple, Union
|
| 19 |
+
|
| 20 |
+
import torch
|
| 21 |
+
import torch.nn.functional as F
|
| 22 |
+
import torch.utils.checkpoint
|
| 23 |
+
from torch import nn
|
| 24 |
+
|
| 25 |
+
from transformers.activations import ACT2FN
|
| 26 |
+
from transformers.cache_utils import Cache, DynamicCache, StaticCache
|
| 27 |
+
from transformers.modeling_attn_mask_utils import AttentionMaskConverter
|
| 28 |
+
from transformers.modeling_outputs import (
|
| 29 |
+
BaseModelOutputWithPast,
|
| 30 |
+
CausalLMOutputWithPast,
|
| 31 |
+
)
|
| 32 |
+
from transformers.modeling_utils import PreTrainedModel
|
| 33 |
+
from transformers.generation.utils import GenerationMixin
|
| 34 |
+
from transformers.utils import (
|
| 35 |
+
add_start_docstrings,
|
| 36 |
+
add_start_docstrings_to_model_forward,
|
| 37 |
+
logging,
|
| 38 |
+
replace_return_docstrings,
|
| 39 |
+
)
|
| 40 |
+
|
| 41 |
+
from .configuration_iquestloopcoder import IQuestLoopCoderConfig
|
| 42 |
+
|
| 43 |
+
logger = logging.get_logger(__name__)
|
| 44 |
+
|
| 45 |
+
_CONFIG_FOR_DOC = "IQuestLoopCoderConfig"
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
class IQuestLoopCoderCache(Cache):
|
| 49 |
+
"""Cache implementation for IQuestLoopCoder that manages shared and local KV caches.
|
| 50 |
+
|
| 51 |
+
- shared_key_cache/shared_value_cache: Stores KV from Loop 1 (global context)
|
| 52 |
+
- local_key_cache/local_value_cache: Stores KV from Loop 2+ (local window, only window_size tokens)
|
| 53 |
+
"""
|
| 54 |
+
|
| 55 |
+
def __init__(self, window_size: int, num_layers: int):
|
| 56 |
+
# We intentionally don't call super().__init__ because the parent assumes static cache sizes.
|
| 57 |
+
self.window_size = window_size
|
| 58 |
+
self.num_layers = num_layers
|
| 59 |
+
|
| 60 |
+
# Shared cache: stores Loop 1 KV (global context)
|
| 61 |
+
self.shared_key_cache: List[Optional[torch.Tensor]] = [None] * num_layers
|
| 62 |
+
self.shared_value_cache: List[Optional[torch.Tensor]] = [None] * num_layers
|
| 63 |
+
|
| 64 |
+
# Local cache: stores Loop 2+ KV (sliding window, only window_size tokens)
|
| 65 |
+
self.local_key_cache: List[Optional[torch.Tensor]] = [None] * num_layers
|
| 66 |
+
self.local_value_cache: List[Optional[torch.Tensor]] = [None] * num_layers
|
| 67 |
+
|
| 68 |
+
self.layers: List[Any] = [] # attribute expected by HF Cache utilities
|
| 69 |
+
self._seen_tokens = 0
|
| 70 |
+
|
| 71 |
+
def update_shared(
|
| 72 |
+
self,
|
| 73 |
+
key_states: torch.Tensor,
|
| 74 |
+
value_states: torch.Tensor,
|
| 75 |
+
layer_idx: int,
|
| 76 |
+
cache_kwargs: Optional[dict] = None,
|
| 77 |
+
) -> Tuple[torch.Tensor, torch.Tensor]:
|
| 78 |
+
"""Update shared cache (Loop 1 KV)."""
|
| 79 |
+
if layer_idx < 0 or layer_idx >= self.num_layers:
|
| 80 |
+
raise ValueError(f"layer_idx must be in [0, {self.num_layers}), got {layer_idx}")
|
| 81 |
+
|
| 82 |
+
cached_key = self.shared_key_cache[layer_idx]
|
| 83 |
+
cached_value = self.shared_value_cache[layer_idx]
|
| 84 |
+
|
| 85 |
+
if cached_key is None:
|
| 86 |
+
self.shared_key_cache[layer_idx] = key_states
|
| 87 |
+
self.shared_value_cache[layer_idx] = value_states
|
| 88 |
+
else:
|
| 89 |
+
if (
|
| 90 |
+
key_states.shape[0] != cached_key.shape[0]
|
| 91 |
+
or key_states.shape[1] != cached_key.shape[1]
|
| 92 |
+
or key_states.shape[3] != cached_key.shape[3]
|
| 93 |
+
):
|
| 94 |
+
raise ValueError(
|
| 95 |
+
"Cached and incoming key/value tensors must match on batch, head, and head_dim dimensions."
|
| 96 |
+
)
|
| 97 |
+
assert cached_value is not None
|
| 98 |
+
self.shared_key_cache[layer_idx] = torch.cat([cached_key, key_states], dim=2)
|
| 99 |
+
self.shared_value_cache[layer_idx] = torch.cat([cached_value, value_states], dim=2)
|
| 100 |
+
|
| 101 |
+
result_key = self.shared_key_cache[layer_idx]
|
| 102 |
+
result_value = self.shared_value_cache[layer_idx]
|
| 103 |
+
assert result_key is not None and result_value is not None
|
| 104 |
+
|
| 105 |
+
# Track sequence length
|
| 106 |
+
self._seen_tokens = result_key.shape[2]
|
| 107 |
+
return result_key, result_value
|
| 108 |
+
|
| 109 |
+
def update_local(
|
| 110 |
+
self,
|
| 111 |
+
key_states: torch.Tensor,
|
| 112 |
+
value_states: torch.Tensor,
|
| 113 |
+
layer_idx: int,
|
| 114 |
+
cache_kwargs: Optional[dict] = None,
|
| 115 |
+
) -> Tuple[torch.Tensor, torch.Tensor]:
|
| 116 |
+
"""Update local cache (Loop 2+ KV) with sliding window management.
|
| 117 |
+
|
| 118 |
+
If the cache is full (window_size tokens), remove the oldest token and add the new one.
|
| 119 |
+
"""
|
| 120 |
+
if layer_idx < 0 or layer_idx >= self.num_layers:
|
| 121 |
+
raise ValueError(f"layer_idx must be in [0, {self.num_layers}), got {layer_idx}")
|
| 122 |
+
|
| 123 |
+
cached_key = self.local_key_cache[layer_idx]
|
| 124 |
+
cached_value = self.local_value_cache[layer_idx]
|
| 125 |
+
|
| 126 |
+
if cached_key is None:
|
| 127 |
+
# First token in local cache
|
| 128 |
+
self.local_key_cache[layer_idx] = key_states
|
| 129 |
+
self.local_value_cache[layer_idx] = value_states
|
| 130 |
+
else:
|
| 131 |
+
if (
|
| 132 |
+
key_states.shape[0] != cached_key.shape[0]
|
| 133 |
+
or key_states.shape[1] != cached_key.shape[1]
|
| 134 |
+
or key_states.shape[3] != cached_key.shape[3]
|
| 135 |
+
):
|
| 136 |
+
raise ValueError(
|
| 137 |
+
"Cached and incoming key/value tensors must match on batch, head, and head_dim dimensions."
|
| 138 |
+
)
|
| 139 |
+
assert cached_value is not None
|
| 140 |
+
|
| 141 |
+
# Check if we need to remove the oldest token
|
| 142 |
+
current_len = cached_key.shape[2]
|
| 143 |
+
if current_len >= self.window_size:
|
| 144 |
+
# Remove the first token (oldest) and add the new one
|
| 145 |
+
self.local_key_cache[layer_idx] = torch.cat([cached_key[:, :, 1:, :], key_states], dim=2)
|
| 146 |
+
self.local_value_cache[layer_idx] = torch.cat([cached_value[:, :, 1:, :], value_states], dim=2)
|
| 147 |
+
else:
|
| 148 |
+
# Just append
|
| 149 |
+
self.local_key_cache[layer_idx] = torch.cat([cached_key, key_states], dim=2)
|
| 150 |
+
self.local_value_cache[layer_idx] = torch.cat([cached_value, value_states], dim=2)
|
| 151 |
+
|
| 152 |
+
result_key = self.local_key_cache[layer_idx]
|
| 153 |
+
result_value = self.local_value_cache[layer_idx]
|
| 154 |
+
assert result_key is not None and result_value is not None
|
| 155 |
+
|
| 156 |
+
return result_key, result_value
|
| 157 |
+
|
| 158 |
+
def get_shared(self, layer_idx: int) -> Tuple[Optional[torch.Tensor], Optional[torch.Tensor]]:
|
| 159 |
+
"""Get shared cache for a layer."""
|
| 160 |
+
if layer_idx < 0 or layer_idx >= self.num_layers:
|
| 161 |
+
return None, None
|
| 162 |
+
return self.shared_key_cache[layer_idx], self.shared_value_cache[layer_idx]
|
| 163 |
+
|
| 164 |
+
def get_local(self, layer_idx: int) -> Tuple[Optional[torch.Tensor], Optional[torch.Tensor]]:
|
| 165 |
+
"""Get local cache for a layer."""
|
| 166 |
+
if layer_idx < 0 or layer_idx >= self.num_layers:
|
| 167 |
+
return None, None
|
| 168 |
+
return self.local_key_cache[layer_idx], self.local_value_cache[layer_idx]
|
| 169 |
+
|
| 170 |
+
def update(
|
| 171 |
+
self,
|
| 172 |
+
key_states: torch.Tensor,
|
| 173 |
+
value_states: torch.Tensor,
|
| 174 |
+
layer_idx: int,
|
| 175 |
+
cache_kwargs: Optional[dict] = None,
|
| 176 |
+
) -> Tuple[torch.Tensor, torch.Tensor]:
|
| 177 |
+
"""Default update method (for compatibility, updates shared cache)."""
|
| 178 |
+
return self.update_shared(key_states, value_states, layer_idx, cache_kwargs)
|
| 179 |
+
|
| 180 |
+
def get_seq_length(self, layer_idx: Optional[int] = 0) -> int:
|
| 181 |
+
"""Get sequence length from shared cache."""
|
| 182 |
+
if layer_idx is None:
|
| 183 |
+
layer_idx = 0
|
| 184 |
+
if layer_idx < 0 or layer_idx >= len(self.shared_key_cache):
|
| 185 |
+
return 0
|
| 186 |
+
cached = self.shared_key_cache[layer_idx]
|
| 187 |
+
if cached is None:
|
| 188 |
+
return 0
|
| 189 |
+
return cached.shape[2]
|
| 190 |
+
|
| 191 |
+
def get_max_length(self) -> Optional[int]:
|
| 192 |
+
return None
|
| 193 |
+
|
| 194 |
+
def get_usable_length(
|
| 195 |
+
self, new_seq_length: int, layer_idx: Optional[int] = 0
|
| 196 |
+
) -> int:
|
| 197 |
+
return self.get_seq_length(layer_idx)
|
| 198 |
+
|
| 199 |
+
def reorder_cache(self, beam_idx: torch.LongTensor) -> None:
|
| 200 |
+
"""Reorder cache for beam search."""
|
| 201 |
+
for layer_idx in range(self.num_layers):
|
| 202 |
+
if self.shared_key_cache[layer_idx] is not None:
|
| 203 |
+
device = self.shared_key_cache[layer_idx].device
|
| 204 |
+
self.shared_key_cache[layer_idx] = self.shared_key_cache[layer_idx].index_select(0, beam_idx.to(device))
|
| 205 |
+
self.shared_value_cache[layer_idx] = self.shared_value_cache[layer_idx].index_select(0, beam_idx.to(device))
|
| 206 |
+
|
| 207 |
+
if self.local_key_cache[layer_idx] is not None:
|
| 208 |
+
device = self.local_key_cache[layer_idx].device
|
| 209 |
+
self.local_key_cache[layer_idx] = self.local_key_cache[layer_idx].index_select(0, beam_idx.to(device))
|
| 210 |
+
self.local_value_cache[layer_idx] = self.local_value_cache[layer_idx].index_select(0, beam_idx.to(device))
|
| 211 |
+
|
| 212 |
+
@property
|
| 213 |
+
def is_compileable(self) -> bool:
|
| 214 |
+
return False
|
| 215 |
+
|
| 216 |
+
def clear(self) -> None:
|
| 217 |
+
"""Clear all caches."""
|
| 218 |
+
logger.debug("Clearing IQuestLoopCoderCache")
|
| 219 |
+
self.shared_key_cache = [None] * self.num_layers
|
| 220 |
+
self.shared_value_cache = [None] * self.num_layers
|
| 221 |
+
self.local_key_cache = [None] * self.num_layers
|
| 222 |
+
self.local_value_cache = [None] * self.num_layers
|
| 223 |
+
self._seen_tokens = 0
|
| 224 |
+
|
| 225 |
+
|
| 226 |
+
class IQuestLoopCoderRMSNorm(nn.Module):
|
| 227 |
+
"""RMS Normalization layer."""
|
| 228 |
+
|
| 229 |
+
def __init__(self, hidden_size, eps=1e-6):
|
| 230 |
+
super().__init__()
|
| 231 |
+
self.weight = nn.Parameter(torch.ones(hidden_size))
|
| 232 |
+
self.variance_epsilon = eps
|
| 233 |
+
|
| 234 |
+
def forward(self, hidden_states):
|
| 235 |
+
input_dtype = hidden_states.dtype
|
| 236 |
+
hidden_states = hidden_states.to(torch.float32)
|
| 237 |
+
variance = hidden_states.pow(2).mean(-1, keepdim=True)
|
| 238 |
+
hidden_states = hidden_states * torch.rsqrt(variance + self.variance_epsilon)
|
| 239 |
+
return self.weight * hidden_states.to(input_dtype)
|
| 240 |
+
|
| 241 |
+
|
| 242 |
+
class IQuestLoopCoderRotaryEmbedding(nn.Module):
|
| 243 |
+
"""Rotary Position Embedding (RoPE)."""
|
| 244 |
+
|
| 245 |
+
def __init__(self, dim, max_position_embeddings=8192, base=500000.0, device=None, scaling_factor=1.0):
|
| 246 |
+
super().__init__()
|
| 247 |
+
self.scaling_factor = scaling_factor
|
| 248 |
+
self.dim = dim
|
| 249 |
+
self.max_position_embeddings = max_position_embeddings
|
| 250 |
+
self.base = base
|
| 251 |
+
inv_freq = 1.0 / (self.base ** (torch.arange(0, self.dim, 2, dtype=torch.int64).float().to(device) / self.dim))
|
| 252 |
+
self.register_buffer("inv_freq", inv_freq, persistent=False)
|
| 253 |
+
self.max_seq_len_cached = max_position_embeddings
|
| 254 |
+
|
| 255 |
+
@torch.no_grad()
|
| 256 |
+
def forward(self, x, position_ids):
|
| 257 |
+
# x: [batch_size, num_heads, seq_len, head_dim]
|
| 258 |
+
inv_freq_expanded = self.inv_freq[None, :, None].float().expand(position_ids.shape[0], -1, 1)
|
| 259 |
+
position_ids_expanded = position_ids[:, None, :].float()
|
| 260 |
+
|
| 261 |
+
device_type = x.device.type
|
| 262 |
+
with torch.autocast(device_type=device_type, enabled=False):
|
| 263 |
+
freqs = (inv_freq_expanded.float() @ position_ids_expanded.float()).transpose(1, 2)
|
| 264 |
+
emb = torch.cat((freqs, freqs), dim=-1)
|
| 265 |
+
cos = emb.cos()
|
| 266 |
+
sin = emb.sin()
|
| 267 |
+
return cos.to(dtype=x.dtype), sin.to(dtype=x.dtype)
|
| 268 |
+
|
| 269 |
+
|
| 270 |
+
def rotate_half(x):
|
| 271 |
+
"""Rotates half the hidden dims of the input."""
|
| 272 |
+
x1 = x[..., : x.shape[-1] // 2]
|
| 273 |
+
x2 = x[..., x.shape[-1] // 2 :]
|
| 274 |
+
return torch.cat((-x2, x1), dim=-1)
|
| 275 |
+
|
| 276 |
+
|
| 277 |
+
def apply_rotary_pos_emb(q, k, cos, sin, position_ids=None, unsqueeze_dim=1):
|
| 278 |
+
"""Applies Rotary Position Embedding to the query and key tensors."""
|
| 279 |
+
cos = cos.unsqueeze(unsqueeze_dim)
|
| 280 |
+
sin = sin.unsqueeze(unsqueeze_dim)
|
| 281 |
+
q_embed = (q * cos) + (rotate_half(q) * sin)
|
| 282 |
+
k_embed = (k * cos) + (rotate_half(k) * sin)
|
| 283 |
+
return q_embed, k_embed
|
| 284 |
+
|
| 285 |
+
|
| 286 |
+
def repeat_kv(hidden_states: torch.Tensor, n_rep: int) -> torch.Tensor:
|
| 287 |
+
"""Expand KV heads to match query heads for GQA."""
|
| 288 |
+
batch, num_key_value_heads, slen, head_dim = hidden_states.shape
|
| 289 |
+
if n_rep == 1:
|
| 290 |
+
return hidden_states
|
| 291 |
+
hidden_states = hidden_states[:, :, None, :, :].expand(batch, num_key_value_heads, n_rep, slen, head_dim)
|
| 292 |
+
return hidden_states.reshape(batch, num_key_value_heads * n_rep, slen, head_dim)
|
| 293 |
+
|
| 294 |
+
|
| 295 |
+
class IQuestLoopCoderMLP(nn.Module):
|
| 296 |
+
"""MLP with SwiGLU activation."""
|
| 297 |
+
|
| 298 |
+
def __init__(self, config):
|
| 299 |
+
super().__init__()
|
| 300 |
+
self.config = config
|
| 301 |
+
self.hidden_size = config.hidden_size
|
| 302 |
+
self.intermediate_size = config.intermediate_size
|
| 303 |
+
self.gate_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=config.mlp_bias)
|
| 304 |
+
self.up_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=config.mlp_bias)
|
| 305 |
+
self.down_proj = nn.Linear(self.intermediate_size, self.hidden_size, bias=config.mlp_bias)
|
| 306 |
+
self.act_fn = ACT2FN[config.hidden_act]
|
| 307 |
+
|
| 308 |
+
def forward(self, x):
|
| 309 |
+
return self.down_proj(self.act_fn(self.gate_proj(x)) * self.up_proj(x))
|
| 310 |
+
|
| 311 |
+
|
| 312 |
+
class LoopGateProjection(nn.Module):
|
| 313 |
+
"""Gate projection for mixed attention in Loop 2+.
|
| 314 |
+
|
| 315 |
+
Computes: g = sigmoid(linear(Q)) for each head independently.
|
| 316 |
+
This gate determines how much to use Loop1's KV (global) vs current loop's KV (local).
|
| 317 |
+
"""
|
| 318 |
+
|
| 319 |
+
def __init__(self, num_heads: int, head_dim: int):
|
| 320 |
+
super().__init__()
|
| 321 |
+
self.num_heads = num_heads
|
| 322 |
+
self.head_dim = head_dim
|
| 323 |
+
# Each head has its own gate: Linear(head_dim -> 1) per head
|
| 324 |
+
# Implemented as [num_heads, head_dim] weight + [num_heads] bias
|
| 325 |
+
self.weight = nn.Parameter(torch.zeros(num_heads, head_dim))
|
| 326 |
+
self.bias = nn.Parameter(torch.zeros(num_heads))
|
| 327 |
+
|
| 328 |
+
def forward(self, query: torch.Tensor) -> torch.Tensor:
|
| 329 |
+
"""Compute gate values from query tensor.
|
| 330 |
+
|
| 331 |
+
Args:
|
| 332 |
+
query: [batch, num_heads, seq_len, head_dim]
|
| 333 |
+
|
| 334 |
+
Returns:
|
| 335 |
+
gate: [batch, num_heads, seq_len, 1]
|
| 336 |
+
"""
|
| 337 |
+
# query: [batch, num_heads, seq_len, head_dim]
|
| 338 |
+
# weight: [num_heads, head_dim]
|
| 339 |
+
# For each head h: gate_h = query[:, h, :, :] @ weight[h, :].T + bias[h]
|
| 340 |
+
# Using einsum: gate = einsum('bhsd,hd->bhs', query, weight) + bias
|
| 341 |
+
gate_logits = torch.einsum('bhsd,hd->bhs', query, self.weight) # [batch, num_heads, seq_len]
|
| 342 |
+
gate_logits = gate_logits + self.bias[None, :, None] # broadcast bias
|
| 343 |
+
gate = torch.sigmoid(gate_logits)
|
| 344 |
+
return gate.unsqueeze(-1) # [batch, num_heads, seq_len, 1]
|
| 345 |
+
|
| 346 |
+
|
| 347 |
+
class IQuestLoopCoderAttention(nn.Module):
|
| 348 |
+
"""Multi-head attention with GQA support."""
|
| 349 |
+
|
| 350 |
+
def __init__(self, config: IQuestLoopCoderConfig, layer_idx: Optional[int] = None):
|
| 351 |
+
super().__init__()
|
| 352 |
+
self.config = config
|
| 353 |
+
self.layer_idx = layer_idx
|
| 354 |
+
|
| 355 |
+
self.hidden_size = config.hidden_size
|
| 356 |
+
self.num_heads = config.num_attention_heads
|
| 357 |
+
self.head_dim = config.head_dim
|
| 358 |
+
self.num_key_value_heads = config.num_key_value_heads
|
| 359 |
+
self.num_key_value_groups = self.num_heads // self.num_key_value_heads
|
| 360 |
+
self.max_position_embeddings = config.max_position_embeddings
|
| 361 |
+
self.rope_theta = config.rope_theta
|
| 362 |
+
self.attention_dropout = config.attention_dropout
|
| 363 |
+
|
| 364 |
+
self.q_proj = nn.Linear(self.hidden_size, self.num_heads * self.head_dim, bias=config.attention_bias)
|
| 365 |
+
self.k_proj = nn.Linear(self.hidden_size, self.num_key_value_heads * self.head_dim, bias=config.attention_bias)
|
| 366 |
+
self.v_proj = nn.Linear(self.hidden_size, self.num_key_value_heads * self.head_dim, bias=config.attention_bias)
|
| 367 |
+
self.o_proj = nn.Linear(self.num_heads * self.head_dim, self.hidden_size, bias=config.attention_bias)
|
| 368 |
+
|
| 369 |
+
self.rotary_emb = IQuestLoopCoderRotaryEmbedding(
|
| 370 |
+
self.head_dim,
|
| 371 |
+
max_position_embeddings=self.max_position_embeddings,
|
| 372 |
+
base=self.rope_theta,
|
| 373 |
+
)
|
| 374 |
+
|
| 375 |
+
def forward(
|
| 376 |
+
self,
|
| 377 |
+
hidden_states: torch.Tensor,
|
| 378 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 379 |
+
position_ids: Optional[torch.LongTensor] = None,
|
| 380 |
+
past_key_value: Optional[Cache] = None,
|
| 381 |
+
output_attentions: bool = False,
|
| 382 |
+
use_cache: bool = False,
|
| 383 |
+
cache_position: Optional[torch.LongTensor] = None,
|
| 384 |
+
**kwargs,
|
| 385 |
+
) -> Tuple[torch.Tensor, Optional[torch.Tensor], Optional[Tuple[torch.Tensor]]]:
|
| 386 |
+
bsz, q_len, _ = hidden_states.size()
|
| 387 |
+
|
| 388 |
+
query_states = self.q_proj(hidden_states)
|
| 389 |
+
key_states = self.k_proj(hidden_states)
|
| 390 |
+
value_states = self.v_proj(hidden_states)
|
| 391 |
+
|
| 392 |
+
query_states = query_states.view(bsz, q_len, self.num_heads, self.head_dim).transpose(1, 2)
|
| 393 |
+
key_states = key_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
|
| 394 |
+
value_states = value_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
|
| 395 |
+
|
| 396 |
+
cos, sin = self.rotary_emb(value_states, position_ids)
|
| 397 |
+
query_states, key_states = apply_rotary_pos_emb(query_states, key_states, cos, sin)
|
| 398 |
+
|
| 399 |
+
if past_key_value is not None:
|
| 400 |
+
cache_kwargs = {"sin": sin, "cos": cos, "cache_position": cache_position}
|
| 401 |
+
key_states, value_states = past_key_value.update(key_states, value_states, self.layer_idx, cache_kwargs)
|
| 402 |
+
|
| 403 |
+
# Repeat KV for GQA
|
| 404 |
+
key_states = repeat_kv(key_states, self.num_key_value_groups)
|
| 405 |
+
value_states = repeat_kv(value_states, self.num_key_value_groups)
|
| 406 |
+
|
| 407 |
+
attn_weights = torch.matmul(query_states, key_states.transpose(2, 3)) / math.sqrt(self.head_dim)
|
| 408 |
+
|
| 409 |
+
if attention_mask is not None:
|
| 410 |
+
causal_mask = attention_mask[:, :, :, : key_states.shape[-2]]
|
| 411 |
+
attn_weights = attn_weights + causal_mask
|
| 412 |
+
|
| 413 |
+
attn_weights = nn.functional.softmax(attn_weights, dim=-1, dtype=torch.float32).to(query_states.dtype)
|
| 414 |
+
attn_weights = nn.functional.dropout(attn_weights, p=self.attention_dropout, training=self.training)
|
| 415 |
+
attn_output = torch.matmul(attn_weights, value_states)
|
| 416 |
+
|
| 417 |
+
attn_output = attn_output.transpose(1, 2).contiguous()
|
| 418 |
+
attn_output = attn_output.reshape(bsz, q_len, -1)
|
| 419 |
+
attn_output = self.o_proj(attn_output)
|
| 420 |
+
|
| 421 |
+
return attn_output, attn_weights if output_attentions else None, past_key_value
|
| 422 |
+
|
| 423 |
+
def forward_with_external_kv(
|
| 424 |
+
self,
|
| 425 |
+
hidden_states: torch.Tensor,
|
| 426 |
+
external_key: torch.Tensor,
|
| 427 |
+
external_value: torch.Tensor,
|
| 428 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 429 |
+
position_ids: Optional[torch.LongTensor] = None,
|
| 430 |
+
sliding_window: Optional[int] = None,
|
| 431 |
+
) -> torch.Tensor:
|
| 432 |
+
"""Forward pass using external K, V (for Loop 2+ mixed attention).
|
| 433 |
+
|
| 434 |
+
Args:
|
| 435 |
+
hidden_states: Input for computing Q
|
| 436 |
+
external_key: Pre-computed K (already with RoPE applied)
|
| 437 |
+
external_value: Pre-computed V
|
| 438 |
+
attention_mask: Causal attention mask
|
| 439 |
+
position_ids: Position IDs
|
| 440 |
+
sliding_window: If set, apply sliding window attention
|
| 441 |
+
|
| 442 |
+
Returns:
|
| 443 |
+
Attention output [batch, seq_len, num_heads, head_dim]
|
| 444 |
+
"""
|
| 445 |
+
bsz, q_len, _ = hidden_states.size()
|
| 446 |
+
|
| 447 |
+
# Compute Q from current hidden states
|
| 448 |
+
query_states = self.q_proj(hidden_states)
|
| 449 |
+
query_states = query_states.view(bsz, q_len, self.num_heads, self.head_dim).transpose(1, 2)
|
| 450 |
+
|
| 451 |
+
# Apply RoPE to Q
|
| 452 |
+
cos, sin = self.rotary_emb(query_states, position_ids)
|
| 453 |
+
query_states = (query_states * cos.unsqueeze(1)) + (rotate_half(query_states) * sin.unsqueeze(1))
|
| 454 |
+
|
| 455 |
+
# Use external K, V (already have RoPE for K)
|
| 456 |
+
key_states = external_key
|
| 457 |
+
value_states = external_value
|
| 458 |
+
|
| 459 |
+
# Repeat KV for GQA
|
| 460 |
+
key_states = repeat_kv(key_states, self.num_key_value_groups)
|
| 461 |
+
value_states = repeat_kv(value_states, self.num_key_value_groups)
|
| 462 |
+
|
| 463 |
+
# Compute attention
|
| 464 |
+
attn_weights = torch.matmul(query_states, key_states.transpose(2, 3)) / math.sqrt(self.head_dim)
|
| 465 |
+
|
| 466 |
+
# Apply attention mask (causal)
|
| 467 |
+
if attention_mask is not None:
|
| 468 |
+
causal_mask = attention_mask[:, :, :, : key_states.shape[-2]]
|
| 469 |
+
attn_weights = attn_weights + causal_mask
|
| 470 |
+
|
| 471 |
+
# Apply sliding window mask if needed
|
| 472 |
+
if sliding_window is not None and q_len > sliding_window:
|
| 473 |
+
# Create sliding window mask
|
| 474 |
+
# For each position i, can only attend to [i-window+1, i]
|
| 475 |
+
seq_len = key_states.shape[2]
|
| 476 |
+
row_idx = torch.arange(q_len, device=query_states.device).unsqueeze(1)
|
| 477 |
+
col_idx = torch.arange(seq_len, device=query_states.device).unsqueeze(0)
|
| 478 |
+
window_mask = (col_idx > row_idx) | (col_idx < row_idx - sliding_window + 1)
|
| 479 |
+
window_mask = window_mask.unsqueeze(0).unsqueeze(0) # [1, 1, q_len, seq_len]
|
| 480 |
+
attn_weights = attn_weights.masked_fill(window_mask, float('-inf'))
|
| 481 |
+
|
| 482 |
+
attn_weights = nn.functional.softmax(attn_weights, dim=-1, dtype=torch.float32).to(query_states.dtype)
|
| 483 |
+
attn_output = torch.matmul(attn_weights, value_states)
|
| 484 |
+
|
| 485 |
+
# Don't apply o_proj here - return raw attention output
|
| 486 |
+
attn_output = attn_output.transpose(1, 2).contiguous()
|
| 487 |
+
return attn_output # [batch, seq_len, num_heads, head_dim]
|
| 488 |
+
|
| 489 |
+
def get_qkv(
|
| 490 |
+
self,
|
| 491 |
+
hidden_states: torch.Tensor,
|
| 492 |
+
position_ids: Optional[torch.LongTensor] = None,
|
| 493 |
+
) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor]:
|
| 494 |
+
"""Get Q, K, V tensors with RoPE applied.
|
| 495 |
+
|
| 496 |
+
Returns:
|
| 497 |
+
query: [batch, num_heads, seq_len, head_dim]
|
| 498 |
+
key: [batch, num_kv_heads, seq_len, head_dim]
|
| 499 |
+
value: [batch, num_kv_heads, seq_len, head_dim]
|
| 500 |
+
"""
|
| 501 |
+
bsz, q_len, _ = hidden_states.size()
|
| 502 |
+
|
| 503 |
+
query_states = self.q_proj(hidden_states)
|
| 504 |
+
key_states = self.k_proj(hidden_states)
|
| 505 |
+
value_states = self.v_proj(hidden_states)
|
| 506 |
+
|
| 507 |
+
query_states = query_states.view(bsz, q_len, self.num_heads, self.head_dim).transpose(1, 2)
|
| 508 |
+
key_states = key_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
|
| 509 |
+
value_states = value_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
|
| 510 |
+
|
| 511 |
+
cos, sin = self.rotary_emb(value_states, position_ids)
|
| 512 |
+
query_states, key_states = apply_rotary_pos_emb(query_states, key_states, cos, sin)
|
| 513 |
+
|
| 514 |
+
return query_states, key_states, value_states
|
| 515 |
+
|
| 516 |
+
def forward_decode_loop1(
|
| 517 |
+
self,
|
| 518 |
+
hidden_states: torch.Tensor,
|
| 519 |
+
past_shared_key: Optional[torch.Tensor],
|
| 520 |
+
past_shared_value: Optional[torch.Tensor],
|
| 521 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 522 |
+
position_ids: Optional[torch.LongTensor] = None,
|
| 523 |
+
cache_position: Optional[torch.LongTensor] = None,
|
| 524 |
+
) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor]:
|
| 525 |
+
"""Forward pass for Loop 1 in decode stage.
|
| 526 |
+
|
| 527 |
+
Args:
|
| 528 |
+
hidden_states: Current hidden states [batch, 1, hidden_size]
|
| 529 |
+
past_shared_key: Past shared keys from cache [batch, num_kv_heads, past_len, head_dim]
|
| 530 |
+
past_shared_value: Past shared values from cache [batch, num_kv_heads, past_len, head_dim]
|
| 531 |
+
attention_mask: Causal attention mask
|
| 532 |
+
position_ids: Position IDs
|
| 533 |
+
cache_position: Cache position
|
| 534 |
+
|
| 535 |
+
Returns:
|
| 536 |
+
output: Attention output [batch, 1, hidden_size]
|
| 537 |
+
k1: Current key [batch, num_kv_heads, 1, head_dim] (only current token)
|
| 538 |
+
v1: Current value [batch, num_kv_heads, 1, head_dim] (only current token)
|
| 539 |
+
"""
|
| 540 |
+
bsz, q_len, _ = hidden_states.size()
|
| 541 |
+
|
| 542 |
+
query_states = self.q_proj(hidden_states)
|
| 543 |
+
key_states = self.k_proj(hidden_states)
|
| 544 |
+
value_states = self.v_proj(hidden_states)
|
| 545 |
+
|
| 546 |
+
query_states = query_states.view(bsz, q_len, self.num_heads, self.head_dim).transpose(1, 2)
|
| 547 |
+
key_states = key_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
|
| 548 |
+
value_states = value_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
|
| 549 |
+
|
| 550 |
+
cos, sin = self.rotary_emb(value_states, position_ids)
|
| 551 |
+
query_states, key_states = apply_rotary_pos_emb(query_states, key_states, cos, sin)
|
| 552 |
+
|
| 553 |
+
# Store current token's k1, v1 for return (before concatenation)
|
| 554 |
+
k1_current = key_states # [batch, num_kv_heads, 1, head_dim]
|
| 555 |
+
v1_current = value_states # [batch, num_kv_heads, 1, head_dim]
|
| 556 |
+
|
| 557 |
+
# Concatenate with past shared KV cache for attention computation
|
| 558 |
+
if past_shared_key is not None and past_shared_value is not None:
|
| 559 |
+
key_states = torch.cat([past_shared_key, key_states], dim=2)
|
| 560 |
+
value_states = torch.cat([past_shared_value, value_states], dim=2)
|
| 561 |
+
|
| 562 |
+
# Repeat KV for GQA
|
| 563 |
+
key_states = repeat_kv(key_states, self.num_key_value_groups)
|
| 564 |
+
value_states = repeat_kv(value_states, self.num_key_value_groups)
|
| 565 |
+
|
| 566 |
+
attn_weights = torch.matmul(query_states, key_states.transpose(2, 3)) / math.sqrt(self.head_dim)
|
| 567 |
+
|
| 568 |
+
if attention_mask is not None:
|
| 569 |
+
causal_mask = attention_mask[:, :, :, : key_states.shape[-2]]
|
| 570 |
+
attn_weights = attn_weights + causal_mask
|
| 571 |
+
|
| 572 |
+
attn_weights = nn.functional.softmax(attn_weights, dim=-1, dtype=torch.float32).to(query_states.dtype)
|
| 573 |
+
attn_weights = nn.functional.dropout(attn_weights, p=self.attention_dropout, training=self.training)
|
| 574 |
+
attn_output = torch.matmul(attn_weights, value_states)
|
| 575 |
+
|
| 576 |
+
attn_output = attn_output.transpose(1, 2).contiguous()
|
| 577 |
+
attn_output = attn_output.reshape(bsz, q_len, -1)
|
| 578 |
+
attn_output = self.o_proj(attn_output)
|
| 579 |
+
|
| 580 |
+
return attn_output, k1_current, v1_current
|
| 581 |
+
|
| 582 |
+
def forward_decode_loop2(
|
| 583 |
+
self,
|
| 584 |
+
hidden_states: torch.Tensor,
|
| 585 |
+
k1: torch.Tensor,
|
| 586 |
+
v1: torch.Tensor,
|
| 587 |
+
past_shared_key: Optional[torch.Tensor],
|
| 588 |
+
past_shared_value: Optional[torch.Tensor],
|
| 589 |
+
past_local_key: Optional[torch.Tensor],
|
| 590 |
+
past_local_value: Optional[torch.Tensor],
|
| 591 |
+
gate_proj: LoopGateProjection,
|
| 592 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 593 |
+
position_ids: Optional[torch.LongTensor] = None,
|
| 594 |
+
loop_window_size: int = 64,
|
| 595 |
+
) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor]:
|
| 596 |
+
"""Forward pass for Loop 2 in decode stage with mixed attention.
|
| 597 |
+
|
| 598 |
+
Args:
|
| 599 |
+
hidden_states: Current hidden states [batch, 1, hidden_size]
|
| 600 |
+
k1: Key from Loop 1 (current token) [batch, num_kv_heads, 1, head_dim]
|
| 601 |
+
v1: Value from Loop 1 (current token) [batch, num_kv_heads, 1, head_dim]
|
| 602 |
+
past_shared_key: Past shared keys from cache [batch, num_kv_heads, past_len, head_dim]
|
| 603 |
+
past_shared_value: Past shared values from cache [batch, num_kv_heads, past_len, head_dim]
|
| 604 |
+
past_local_key: Past local keys from cache [batch, num_kv_heads, window_len, head_dim]
|
| 605 |
+
past_local_value: Past local values from cache [batch, num_kv_heads, window_len, head_dim]
|
| 606 |
+
gate_proj: Gate projection module
|
| 607 |
+
attention_mask: Causal attention mask
|
| 608 |
+
position_ids: Position IDs
|
| 609 |
+
loop_window_size: Window size for sliding window attention
|
| 610 |
+
|
| 611 |
+
Returns:
|
| 612 |
+
output: Attention output [batch, 1, hidden_size]
|
| 613 |
+
k2: Current key [batch, num_kv_heads, 1, head_dim]
|
| 614 |
+
v2: Current value [batch, num_kv_heads, 1, head_dim]
|
| 615 |
+
"""
|
| 616 |
+
bsz, q_len, _ = hidden_states.size()
|
| 617 |
+
|
| 618 |
+
# Get Q2, K2, V2 for current loop
|
| 619 |
+
q2, k2, v2 = self.get_qkv(hidden_states, position_ids)
|
| 620 |
+
|
| 621 |
+
# Compute gate: g = sigmoid(linear(Q2))
|
| 622 |
+
gate = gate_proj(q2) # [batch, num_heads, 1, 1]
|
| 623 |
+
|
| 624 |
+
# For attention A: concatenate past shared KV with current k1, v1 (full global context)
|
| 625 |
+
if past_shared_key is not None and past_shared_value is not None:
|
| 626 |
+
k1_full = torch.cat([past_shared_key, k1], dim=2)
|
| 627 |
+
v1_full = torch.cat([past_shared_value, v1], dim=2)
|
| 628 |
+
else:
|
| 629 |
+
k1_full = k1
|
| 630 |
+
v1_full = v1
|
| 631 |
+
|
| 632 |
+
# For attention B: concatenate past local KV with current k2, v2 (sliding window)
|
| 633 |
+
if past_local_key is not None and past_local_value is not None:
|
| 634 |
+
k2_full = torch.cat([past_local_key, k2], dim=2)
|
| 635 |
+
v2_full = torch.cat([past_local_value, v2], dim=2)
|
| 636 |
+
else:
|
| 637 |
+
k2_full = k2
|
| 638 |
+
v2_full = v2
|
| 639 |
+
|
| 640 |
+
# Repeat KV for GQA
|
| 641 |
+
k1_expanded = repeat_kv(k1_full, self.num_key_value_groups)
|
| 642 |
+
v1_expanded = repeat_kv(v1_full, self.num_key_value_groups)
|
| 643 |
+
k2_expanded = repeat_kv(k2_full, self.num_key_value_groups)
|
| 644 |
+
v2_expanded = repeat_kv(v2_full, self.num_key_value_groups)
|
| 645 |
+
|
| 646 |
+
# Attention A: Q2 @ K1_full, V1_full (global, full sequence)
|
| 647 |
+
head_dim = q2.shape[-1]
|
| 648 |
+
attn_weights_A = torch.matmul(q2, k1_expanded.transpose(2, 3)) / math.sqrt(head_dim)
|
| 649 |
+
if attention_mask is not None:
|
| 650 |
+
causal_mask = attention_mask[:, :, :, : k1_expanded.shape[-2]]
|
| 651 |
+
attn_weights_A = attn_weights_A + causal_mask
|
| 652 |
+
attn_weights_A = nn.functional.softmax(attn_weights_A, dim=-1, dtype=torch.float32).to(q2.dtype)
|
| 653 |
+
attn_A = torch.matmul(attn_weights_A, v1_expanded)
|
| 654 |
+
|
| 655 |
+
# Attention B: Q2 @ K2_full, V2_full (local sliding window)
|
| 656 |
+
attn_weights_B = torch.matmul(q2, k2_expanded.transpose(2, 3)) / math.sqrt(head_dim)
|
| 657 |
+
if attention_mask is not None:
|
| 658 |
+
causal_mask = attention_mask[:, :, :, : k2_expanded.shape[-2]]
|
| 659 |
+
attn_weights_B = attn_weights_B + causal_mask
|
| 660 |
+
|
| 661 |
+
# Apply sliding window mask
|
| 662 |
+
q_len_attn = q2.shape[2]
|
| 663 |
+
k_len_attn = k2_expanded.shape[2]
|
| 664 |
+
if q_len_attn <= loop_window_size:
|
| 665 |
+
# If sequence fits in window, use standard attention
|
| 666 |
+
attn_weights_B = nn.functional.softmax(attn_weights_B, dim=-1, dtype=torch.float32).to(q2.dtype)
|
| 667 |
+
else:
|
| 668 |
+
# Apply sliding window mask
|
| 669 |
+
row_idx = torch.arange(q_len_attn, device=q2.device).unsqueeze(1)
|
| 670 |
+
col_idx = torch.arange(k_len_attn, device=q2.device).unsqueeze(0)
|
| 671 |
+
window_mask = (col_idx > row_idx) | (col_idx < row_idx - loop_window_size + 1)
|
| 672 |
+
window_mask = window_mask.unsqueeze(0).unsqueeze(0)
|
| 673 |
+
attn_weights_B = attn_weights_B.masked_fill(window_mask, float('-inf'))
|
| 674 |
+
attn_weights_B = nn.functional.softmax(attn_weights_B, dim=-1, dtype=torch.float32).to(q2.dtype)
|
| 675 |
+
attn_B = torch.matmul(attn_weights_B, v2_expanded)
|
| 676 |
+
|
| 677 |
+
# Mixed attention: gate * A + (1 - gate) * B
|
| 678 |
+
mixed_attn = gate * attn_A + (1 - gate) * attn_B
|
| 679 |
+
|
| 680 |
+
# Reshape and apply output projection
|
| 681 |
+
bsz, num_heads, seq_len, head_dim = mixed_attn.shape
|
| 682 |
+
mixed_attn = mixed_attn.transpose(1, 2).contiguous().reshape(bsz, seq_len, -1)
|
| 683 |
+
attn_output = self.o_proj(mixed_attn)
|
| 684 |
+
|
| 685 |
+
return attn_output, k2, v2
|
| 686 |
+
|
| 687 |
+
|
| 688 |
+
class IQuestLoopCoderDecoderLayer(nn.Module):
|
| 689 |
+
"""Transformer decoder layer."""
|
| 690 |
+
|
| 691 |
+
def __init__(self, config: IQuestLoopCoderConfig, layer_idx: int):
|
| 692 |
+
super().__init__()
|
| 693 |
+
self.hidden_size = config.hidden_size
|
| 694 |
+
self.self_attn = IQuestLoopCoderAttention(config=config, layer_idx=layer_idx)
|
| 695 |
+
self.mlp = IQuestLoopCoderMLP(config)
|
| 696 |
+
self.input_layernorm = IQuestLoopCoderRMSNorm(config.hidden_size, eps=config.rms_norm_eps)
|
| 697 |
+
self.post_attention_layernorm = IQuestLoopCoderRMSNorm(config.hidden_size, eps=config.rms_norm_eps)
|
| 698 |
+
|
| 699 |
+
def forward(
|
| 700 |
+
self,
|
| 701 |
+
hidden_states: torch.Tensor,
|
| 702 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 703 |
+
position_ids: Optional[torch.LongTensor] = None,
|
| 704 |
+
past_key_value: Optional[Cache] = None,
|
| 705 |
+
output_attentions: Optional[bool] = False,
|
| 706 |
+
use_cache: Optional[bool] = False,
|
| 707 |
+
cache_position: Optional[torch.LongTensor] = None,
|
| 708 |
+
**kwargs,
|
| 709 |
+
) -> Tuple[torch.FloatTensor, Optional[Tuple[torch.FloatTensor, torch.FloatTensor]]]:
|
| 710 |
+
residual = hidden_states
|
| 711 |
+
hidden_states = self.input_layernorm(hidden_states)
|
| 712 |
+
|
| 713 |
+
hidden_states, self_attn_weights, present_key_value = self.self_attn(
|
| 714 |
+
hidden_states=hidden_states,
|
| 715 |
+
attention_mask=attention_mask,
|
| 716 |
+
position_ids=position_ids,
|
| 717 |
+
past_key_value=past_key_value,
|
| 718 |
+
output_attentions=output_attentions,
|
| 719 |
+
use_cache=use_cache,
|
| 720 |
+
cache_position=cache_position,
|
| 721 |
+
**kwargs,
|
| 722 |
+
)
|
| 723 |
+
hidden_states = residual + hidden_states
|
| 724 |
+
|
| 725 |
+
residual = hidden_states
|
| 726 |
+
hidden_states = self.post_attention_layernorm(hidden_states)
|
| 727 |
+
hidden_states = self.mlp(hidden_states)
|
| 728 |
+
hidden_states = residual + hidden_states
|
| 729 |
+
|
| 730 |
+
outputs = (hidden_states,)
|
| 731 |
+
if output_attentions:
|
| 732 |
+
outputs += (self_attn_weights,)
|
| 733 |
+
if use_cache:
|
| 734 |
+
outputs += (present_key_value,)
|
| 735 |
+
return outputs
|
| 736 |
+
|
| 737 |
+
def forward_loop2_mixed(
|
| 738 |
+
self,
|
| 739 |
+
hidden_states: torch.Tensor,
|
| 740 |
+
k1: torch.Tensor,
|
| 741 |
+
v1: torch.Tensor,
|
| 742 |
+
gate_proj: LoopGateProjection,
|
| 743 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 744 |
+
position_ids: Optional[torch.LongTensor] = None,
|
| 745 |
+
loop_window_size: int = 64,
|
| 746 |
+
) -> Tuple[torch.Tensor, float]:
|
| 747 |
+
"""Forward pass for Loop 2+ with mixed attention.
|
| 748 |
+
|
| 749 |
+
Args:
|
| 750 |
+
hidden_states: Current hidden states
|
| 751 |
+
k1: Key from Loop 1 [batch, num_kv_heads, seq_len, head_dim]
|
| 752 |
+
v1: Value from Loop 1 [batch, num_kv_heads, seq_len, head_dim]
|
| 753 |
+
gate_proj: Gate projection module for this layer
|
| 754 |
+
attention_mask: Causal attention mask
|
| 755 |
+
position_ids: Position IDs
|
| 756 |
+
loop_window_size: Window size for sliding window attention
|
| 757 |
+
|
| 758 |
+
Returns:
|
| 759 |
+
output hidden states, gate mean value
|
| 760 |
+
"""
|
| 761 |
+
residual = hidden_states
|
| 762 |
+
hidden_states_normed = self.input_layernorm(hidden_states)
|
| 763 |
+
|
| 764 |
+
# Get Q2, K2, V2 for current loop
|
| 765 |
+
q2, k2, v2 = self.self_attn.get_qkv(hidden_states_normed, position_ids)
|
| 766 |
+
|
| 767 |
+
# Compute gate: g = sigmoid(linear(Q2))
|
| 768 |
+
# q2: [batch, num_heads, seq_len, head_dim]
|
| 769 |
+
gate = gate_proj(q2) # [batch, num_heads, seq_len, 1]
|
| 770 |
+
gate_mean = gate.detach().mean().item()
|
| 771 |
+
|
| 772 |
+
# Repeat K1, V1 for GQA
|
| 773 |
+
k1_expanded = repeat_kv(k1, self.self_attn.num_key_value_groups)
|
| 774 |
+
v1_expanded = repeat_kv(v1, self.self_attn.num_key_value_groups)
|
| 775 |
+
k2_expanded = repeat_kv(k2, self.self_attn.num_key_value_groups)
|
| 776 |
+
v2_expanded = repeat_kv(v2, self.self_attn.num_key_value_groups)
|
| 777 |
+
|
| 778 |
+
# Attention A: Q2 @ K1, V1 (global, full sequence)
|
| 779 |
+
attn_A = self._compute_attention(q2, k1_expanded, v1_expanded, attention_mask)
|
| 780 |
+
|
| 781 |
+
# Attention B: Q2 @ K2, V2 (local sliding window)
|
| 782 |
+
attn_B = self._compute_attention_with_window(q2, k2_expanded, v2_expanded, attention_mask, loop_window_size)
|
| 783 |
+
|
| 784 |
+
# Mixed attention: gate * A + (1 - gate) * B
|
| 785 |
+
# attn_A, attn_B: [batch, num_heads, seq_len, head_dim]
|
| 786 |
+
mixed_attn = gate * attn_A + (1 - gate) * attn_B
|
| 787 |
+
|
| 788 |
+
# Reshape and apply output projection
|
| 789 |
+
bsz, num_heads, seq_len, head_dim = mixed_attn.shape
|
| 790 |
+
mixed_attn = mixed_attn.transpose(1, 2).contiguous().reshape(bsz, seq_len, -1)
|
| 791 |
+
hidden_states = self.self_attn.o_proj(mixed_attn)
|
| 792 |
+
|
| 793 |
+
hidden_states = residual + hidden_states
|
| 794 |
+
|
| 795 |
+
# MLP
|
| 796 |
+
residual = hidden_states
|
| 797 |
+
hidden_states = self.post_attention_layernorm(hidden_states)
|
| 798 |
+
hidden_states = self.mlp(hidden_states)
|
| 799 |
+
hidden_states = residual + hidden_states
|
| 800 |
+
|
| 801 |
+
return hidden_states, gate_mean
|
| 802 |
+
|
| 803 |
+
def _compute_attention(
|
| 804 |
+
self,
|
| 805 |
+
query: torch.Tensor,
|
| 806 |
+
key: torch.Tensor,
|
| 807 |
+
value: torch.Tensor,
|
| 808 |
+
attention_mask: Optional[torch.Tensor],
|
| 809 |
+
) -> torch.Tensor:
|
| 810 |
+
"""Standard attention computation."""
|
| 811 |
+
head_dim = query.shape[-1]
|
| 812 |
+
attn_weights = torch.matmul(query, key.transpose(2, 3)) / math.sqrt(head_dim)
|
| 813 |
+
|
| 814 |
+
if attention_mask is not None:
|
| 815 |
+
causal_mask = attention_mask[:, :, :, : key.shape[-2]]
|
| 816 |
+
attn_weights = attn_weights + causal_mask
|
| 817 |
+
|
| 818 |
+
attn_weights = nn.functional.softmax(attn_weights, dim=-1, dtype=torch.float32).to(query.dtype)
|
| 819 |
+
attn_output = torch.matmul(attn_weights, value)
|
| 820 |
+
return attn_output
|
| 821 |
+
|
| 822 |
+
def _compute_attention_with_window(
|
| 823 |
+
self,
|
| 824 |
+
query: torch.Tensor,
|
| 825 |
+
key: torch.Tensor,
|
| 826 |
+
value: torch.Tensor,
|
| 827 |
+
attention_mask: Optional[torch.Tensor],
|
| 828 |
+
window_size: int,
|
| 829 |
+
) -> torch.Tensor:
|
| 830 |
+
"""Attention with sliding window."""
|
| 831 |
+
q_len = query.shape[2]
|
| 832 |
+
k_len = key.shape[2]
|
| 833 |
+
head_dim = query.shape[-1]
|
| 834 |
+
|
| 835 |
+
# If sequence fits in window, use standard attention
|
| 836 |
+
if q_len <= window_size:
|
| 837 |
+
return self._compute_attention(query, key, value, attention_mask)
|
| 838 |
+
|
| 839 |
+
attn_weights = torch.matmul(query, key.transpose(2, 3)) / math.sqrt(head_dim)
|
| 840 |
+
|
| 841 |
+
# Apply causal mask
|
| 842 |
+
if attention_mask is not None:
|
| 843 |
+
causal_mask = attention_mask[:, :, :, : key.shape[-2]]
|
| 844 |
+
attn_weights = attn_weights + causal_mask
|
| 845 |
+
|
| 846 |
+
# Apply sliding window mask
|
| 847 |
+
row_idx = torch.arange(q_len, device=query.device).unsqueeze(1)
|
| 848 |
+
col_idx = torch.arange(k_len, device=query.device).unsqueeze(0)
|
| 849 |
+
# Can only attend to positions in [i - window_size + 1, i]
|
| 850 |
+
window_mask = (col_idx > row_idx) | (col_idx < row_idx - window_size + 1)
|
| 851 |
+
window_mask = window_mask.unsqueeze(0).unsqueeze(0)
|
| 852 |
+
attn_weights = attn_weights.masked_fill(window_mask, float('-inf'))
|
| 853 |
+
|
| 854 |
+
attn_weights = nn.functional.softmax(attn_weights, dim=-1, dtype=torch.float32).to(query.dtype)
|
| 855 |
+
attn_output = torch.matmul(attn_weights, value)
|
| 856 |
+
return attn_output
|
| 857 |
+
|
| 858 |
+
|
| 859 |
+
class IQuestLoopCoderPreTrainedModel(PreTrainedModel):
|
| 860 |
+
"""Base class for IQuestLoopCoder models."""
|
| 861 |
+
config_class = IQuestLoopCoderConfig
|
| 862 |
+
base_model_prefix = "model"
|
| 863 |
+
supports_gradient_checkpointing = True
|
| 864 |
+
_no_split_modules = ["IQuestLoopCoderDecoderLayer"]
|
| 865 |
+
_skip_keys_device_placement = ["past_key_values"]
|
| 866 |
+
_supports_cache_class = True
|
| 867 |
+
_supports_static_cache = True
|
| 868 |
+
|
| 869 |
+
def _init_weights(self, module):
|
| 870 |
+
std = self.config.initializer_range
|
| 871 |
+
if isinstance(module, nn.Linear):
|
| 872 |
+
module.weight.data.normal_(mean=0.0, std=std)
|
| 873 |
+
if module.bias is not None:
|
| 874 |
+
module.bias.data.zero_()
|
| 875 |
+
elif isinstance(module, nn.Embedding):
|
| 876 |
+
module.weight.data.normal_(mean=0.0, std=std)
|
| 877 |
+
if module.padding_idx is not None:
|
| 878 |
+
module.weight.data[module.padding_idx].zero_()
|
| 879 |
+
|
| 880 |
+
|
| 881 |
+
class IQuestLoopCoderModel(IQuestLoopCoderPreTrainedModel):
|
| 882 |
+
"""IQuestLoopCoder Transformer decoder model."""
|
| 883 |
+
|
| 884 |
+
def __init__(self, config: IQuestLoopCoderConfig):
|
| 885 |
+
super().__init__(config)
|
| 886 |
+
self.padding_idx = config.pad_token_id
|
| 887 |
+
self.vocab_size = config.vocab_size
|
| 888 |
+
|
| 889 |
+
self.embed_tokens = nn.Embedding(config.vocab_size, config.hidden_size, self.padding_idx)
|
| 890 |
+
self.layers = nn.ModuleList([
|
| 891 |
+
IQuestLoopCoderDecoderLayer(config, layer_idx) for layer_idx in range(config.num_hidden_layers)
|
| 892 |
+
])
|
| 893 |
+
self.norm = IQuestLoopCoderRMSNorm(config.hidden_size, eps=config.rms_norm_eps)
|
| 894 |
+
|
| 895 |
+
# Gate projections for Loop 2+ (one per layer)
|
| 896 |
+
self.gate_projections = nn.ModuleList([
|
| 897 |
+
LoopGateProjection(config.num_attention_heads, config.head_dim)
|
| 898 |
+
for _ in range(config.num_hidden_layers)
|
| 899 |
+
])
|
| 900 |
+
|
| 901 |
+
# Loop configuration
|
| 902 |
+
self.loop_num = config.loop_num
|
| 903 |
+
self.loop_window_size = config.loop_window_size
|
| 904 |
+
|
| 905 |
+
self.gradient_checkpointing = False
|
| 906 |
+
self.post_init()
|
| 907 |
+
|
| 908 |
+
def get_input_embeddings(self):
|
| 909 |
+
return self.embed_tokens
|
| 910 |
+
|
| 911 |
+
def set_input_embeddings(self, value):
|
| 912 |
+
self.embed_tokens = value
|
| 913 |
+
|
| 914 |
+
def forward(
|
| 915 |
+
self,
|
| 916 |
+
input_ids: torch.LongTensor = None,
|
| 917 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 918 |
+
position_ids: Optional[torch.LongTensor] = None,
|
| 919 |
+
past_key_values: Optional[Cache] = None,
|
| 920 |
+
inputs_embeds: Optional[torch.FloatTensor] = None,
|
| 921 |
+
use_cache: Optional[bool] = None,
|
| 922 |
+
output_attentions: Optional[bool] = None,
|
| 923 |
+
output_hidden_states: Optional[bool] = None,
|
| 924 |
+
return_dict: Optional[bool] = None,
|
| 925 |
+
cache_position: Optional[torch.LongTensor] = None,
|
| 926 |
+
) -> Union[Tuple, BaseModelOutputWithPast]:
|
| 927 |
+
output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
|
| 928 |
+
output_hidden_states = output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
|
| 929 |
+
use_cache = use_cache if use_cache is not None else self.config.use_cache
|
| 930 |
+
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
| 931 |
+
|
| 932 |
+
if inputs_embeds is None:
|
| 933 |
+
inputs_embeds = self.embed_tokens(input_ids)
|
| 934 |
+
|
| 935 |
+
seq_length = inputs_embeds.shape[1]
|
| 936 |
+
|
| 937 |
+
# Determine which forward path to use:
|
| 938 |
+
# 1. If past_key_values exists and seq_length == 1: autoregressive generation step
|
| 939 |
+
# -> Use standard attention with KV cache (no loop needed for single token)
|
| 940 |
+
# 2. Otherwise (prefill or training): use loop mechanism
|
| 941 |
+
|
| 942 |
+
is_generation_step = past_key_values is not None and seq_length == 1
|
| 943 |
+
# import pdb; pdb.set_trace()
|
| 944 |
+
|
| 945 |
+
if is_generation_step:
|
| 946 |
+
# Autoregressive generation: single token, use KV cache
|
| 947 |
+
return self._forward_with_cache(
|
| 948 |
+
inputs_embeds=inputs_embeds,
|
| 949 |
+
attention_mask=attention_mask,
|
| 950 |
+
position_ids=position_ids,
|
| 951 |
+
past_key_values=past_key_values,
|
| 952 |
+
use_cache=use_cache,
|
| 953 |
+
output_attentions=output_attentions,
|
| 954 |
+
output_hidden_states=output_hidden_states,
|
| 955 |
+
return_dict=return_dict,
|
| 956 |
+
cache_position=cache_position,
|
| 957 |
+
)
|
| 958 |
+
|
| 959 |
+
# Prefill or training: use loop mechanism
|
| 960 |
+
return self._forward_loop(
|
| 961 |
+
inputs_embeds=inputs_embeds,
|
| 962 |
+
attention_mask=attention_mask,
|
| 963 |
+
position_ids=position_ids,
|
| 964 |
+
output_attentions=output_attentions,
|
| 965 |
+
output_hidden_states=output_hidden_states,
|
| 966 |
+
return_dict=return_dict,
|
| 967 |
+
use_cache=use_cache,
|
| 968 |
+
cache_position=cache_position,
|
| 969 |
+
)
|
| 970 |
+
|
| 971 |
+
def _forward_loop(
|
| 972 |
+
self,
|
| 973 |
+
inputs_embeds: torch.Tensor,
|
| 974 |
+
attention_mask: Optional[torch.Tensor],
|
| 975 |
+
position_ids: Optional[torch.LongTensor],
|
| 976 |
+
output_attentions: bool,
|
| 977 |
+
output_hidden_states: bool,
|
| 978 |
+
return_dict: bool,
|
| 979 |
+
use_cache: bool = False,
|
| 980 |
+
cache_position: Optional[torch.LongTensor] = None,
|
| 981 |
+
) -> Union[Tuple, BaseModelOutputWithPast]:
|
| 982 |
+
"""Forward with loop mechanism (for training and prefill).
|
| 983 |
+
|
| 984 |
+
This implements the Loop mechanism:
|
| 985 |
+
- Loop 1: Standard attention, stores K1, V1 for each layer
|
| 986 |
+
- Loop 2+: Mixed attention with gated combination of global (K1,V1) and local (K2,V2)
|
| 987 |
+
"""
|
| 988 |
+
batch_size, seq_length, _ = inputs_embeds.shape
|
| 989 |
+
|
| 990 |
+
if position_ids is None:
|
| 991 |
+
device = inputs_embeds.device
|
| 992 |
+
position_ids = torch.arange(seq_length, dtype=torch.long, device=device).unsqueeze(0)
|
| 993 |
+
|
| 994 |
+
if cache_position is None:
|
| 995 |
+
cache_position = torch.arange(seq_length, device=inputs_embeds.device)
|
| 996 |
+
|
| 997 |
+
# Create causal mask
|
| 998 |
+
causal_mask = self._update_causal_mask(attention_mask, inputs_embeds, cache_position, None, output_attentions)
|
| 999 |
+
|
| 1000 |
+
hidden_states = inputs_embeds
|
| 1001 |
+
all_hidden_states = () if output_hidden_states else None
|
| 1002 |
+
all_self_attns = () if output_attentions else None
|
| 1003 |
+
|
| 1004 |
+
# For KV cache during prefill - use IQuestLoopCoderCache
|
| 1005 |
+
# In prefill, past_key_values should be None, so we create a new cache
|
| 1006 |
+
if use_cache:
|
| 1007 |
+
next_decoder_cache = IQuestLoopCoderCache(self.loop_window_size, len(self.layers))
|
| 1008 |
+
else:
|
| 1009 |
+
next_decoder_cache = None
|
| 1010 |
+
|
| 1011 |
+
# ============ Loop 1: Standard forward, store K1, V1 in shared cache ============
|
| 1012 |
+
for layer_idx, decoder_layer in enumerate(self.layers):
|
| 1013 |
+
if output_hidden_states:
|
| 1014 |
+
all_hidden_states += (hidden_states,)
|
| 1015 |
+
|
| 1016 |
+
# Get K1, V1 before standard forward (from original hidden_states, after layernorm)
|
| 1017 |
+
hidden_states_normed = decoder_layer.input_layernorm(hidden_states)
|
| 1018 |
+
q1, k1, v1 = decoder_layer.self_attn.get_qkv(hidden_states_normed, position_ids)
|
| 1019 |
+
|
| 1020 |
+
# Store K1, V1 in shared cache
|
| 1021 |
+
if use_cache:
|
| 1022 |
+
next_decoder_cache.update_shared(k1, v1, layer_idx)
|
| 1023 |
+
|
| 1024 |
+
# Standard forward
|
| 1025 |
+
layer_outputs = decoder_layer(
|
| 1026 |
+
hidden_states,
|
| 1027 |
+
attention_mask=causal_mask,
|
| 1028 |
+
position_ids=position_ids,
|
| 1029 |
+
past_key_value=None,
|
| 1030 |
+
output_attentions=output_attentions,
|
| 1031 |
+
use_cache=False,
|
| 1032 |
+
)
|
| 1033 |
+
hidden_states = layer_outputs[0]
|
| 1034 |
+
|
| 1035 |
+
if output_attentions:
|
| 1036 |
+
all_self_attns += (layer_outputs[1],)
|
| 1037 |
+
|
| 1038 |
+
# ============ Loop 2 to loop_num: Mixed attention, store in local cache ============
|
| 1039 |
+
for loop_idx in range(2, self.loop_num + 1):
|
| 1040 |
+
for layer_idx, decoder_layer in enumerate(self.layers):
|
| 1041 |
+
# Get K1, V1 from shared cache
|
| 1042 |
+
k1, v1 = next_decoder_cache.get_shared(layer_idx) if use_cache else (None, None)
|
| 1043 |
+
if k1 is None or v1 is None:
|
| 1044 |
+
# Fallback: compute K1, V1 if not in cache (shouldn't happen in prefill)
|
| 1045 |
+
hidden_states_normed = decoder_layer.input_layernorm(hidden_states)
|
| 1046 |
+
_, k1, v1 = decoder_layer.self_attn.get_qkv(hidden_states_normed, position_ids)
|
| 1047 |
+
|
| 1048 |
+
gate_proj = self.gate_projections[layer_idx]
|
| 1049 |
+
|
| 1050 |
+
hidden_states, gate_mean = decoder_layer.forward_loop2_mixed(
|
| 1051 |
+
hidden_states,
|
| 1052 |
+
k1=k1,
|
| 1053 |
+
v1=v1,
|
| 1054 |
+
gate_proj=gate_proj,
|
| 1055 |
+
attention_mask=causal_mask,
|
| 1056 |
+
position_ids=position_ids,
|
| 1057 |
+
loop_window_size=self.loop_window_size,
|
| 1058 |
+
)
|
| 1059 |
+
|
| 1060 |
+
# Store Loop 2+ KV in local cache (only for loop_idx == 2)
|
| 1061 |
+
if use_cache and loop_idx == 2:
|
| 1062 |
+
hidden_states_normed = decoder_layer.input_layernorm(hidden_states)
|
| 1063 |
+
_, k2, v2 = decoder_layer.self_attn.get_qkv(hidden_states_normed, position_ids)
|
| 1064 |
+
next_decoder_cache.update_local(k2, v2, layer_idx)
|
| 1065 |
+
|
| 1066 |
+
hidden_states = self.norm(hidden_states)
|
| 1067 |
+
|
| 1068 |
+
if output_hidden_states:
|
| 1069 |
+
all_hidden_states += (hidden_states,)
|
| 1070 |
+
|
| 1071 |
+
if not return_dict:
|
| 1072 |
+
return tuple(v for v in [hidden_states, next_decoder_cache, all_hidden_states, all_self_attns] if v is not None)
|
| 1073 |
+
|
| 1074 |
+
return BaseModelOutputWithPast(
|
| 1075 |
+
last_hidden_state=hidden_states,
|
| 1076 |
+
past_key_values=next_decoder_cache,
|
| 1077 |
+
hidden_states=all_hidden_states,
|
| 1078 |
+
attentions=all_self_attns,
|
| 1079 |
+
)
|
| 1080 |
+
|
| 1081 |
+
def _forward_with_cache(
|
| 1082 |
+
self,
|
| 1083 |
+
inputs_embeds: torch.Tensor,
|
| 1084 |
+
attention_mask: Optional[torch.Tensor],
|
| 1085 |
+
position_ids: Optional[torch.LongTensor],
|
| 1086 |
+
past_key_values: Optional[Cache],
|
| 1087 |
+
use_cache: bool,
|
| 1088 |
+
output_attentions: bool,
|
| 1089 |
+
output_hidden_states: bool,
|
| 1090 |
+
return_dict: bool,
|
| 1091 |
+
cache_position: Optional[torch.LongTensor],
|
| 1092 |
+
) -> Union[Tuple, BaseModelOutputWithPast]:
|
| 1093 |
+
"""Forward with KV cache using loop mechanism (for inference generation).
|
| 1094 |
+
|
| 1095 |
+
Loop 1: Standard attention, uses shared KV cache (previous tokens + current token)
|
| 1096 |
+
Loop 2+: Mixed attention, uses local KV cache (sliding window)
|
| 1097 |
+
"""
|
| 1098 |
+
batch_size, seq_length, _ = inputs_embeds.shape
|
| 1099 |
+
|
| 1100 |
+
if cache_position is None:
|
| 1101 |
+
past_seen_tokens = past_key_values.get_seq_length() if past_key_values is not None else 0
|
| 1102 |
+
cache_position = torch.arange(past_seen_tokens, past_seen_tokens + seq_length, device=inputs_embeds.device)
|
| 1103 |
+
|
| 1104 |
+
if position_ids is None:
|
| 1105 |
+
position_ids = cache_position.unsqueeze(0)
|
| 1106 |
+
|
| 1107 |
+
causal_mask = self._update_causal_mask(attention_mask, inputs_embeds, cache_position, past_key_values, output_attentions)
|
| 1108 |
+
|
| 1109 |
+
# Ensure we're using IQuestLoopCoderCache
|
| 1110 |
+
if use_cache:
|
| 1111 |
+
if not isinstance(past_key_values, IQuestLoopCoderCache):
|
| 1112 |
+
# Convert to IQuestLoopCoderCache if needed
|
| 1113 |
+
next_decoder_cache = IQuestLoopCoderCache(self.loop_window_size, len(self.layers))
|
| 1114 |
+
# Copy existing cache if possible
|
| 1115 |
+
if past_key_values is not None:
|
| 1116 |
+
for layer_idx in range(len(self.layers)):
|
| 1117 |
+
try:
|
| 1118 |
+
past_k = past_key_values.key_cache[layer_idx] if hasattr(past_key_values, 'key_cache') else None
|
| 1119 |
+
past_v = past_key_values.value_cache[layer_idx] if hasattr(past_key_values, 'value_cache') else None
|
| 1120 |
+
if past_k is not None and past_v is not None:
|
| 1121 |
+
next_decoder_cache.update_shared(past_k, past_v, layer_idx)
|
| 1122 |
+
except:
|
| 1123 |
+
pass
|
| 1124 |
+
else:
|
| 1125 |
+
next_decoder_cache = past_key_values
|
| 1126 |
+
else:
|
| 1127 |
+
next_decoder_cache = None
|
| 1128 |
+
|
| 1129 |
+
hidden_states = inputs_embeds
|
| 1130 |
+
all_hidden_states = () if output_hidden_states else None
|
| 1131 |
+
all_self_attns = () if output_attentions else None
|
| 1132 |
+
|
| 1133 |
+
# ============ Loop 1: Standard attention, store in shared cache ============
|
| 1134 |
+
for layer_idx, decoder_layer in enumerate(self.layers):
|
| 1135 |
+
if output_hidden_states:
|
| 1136 |
+
all_hidden_states += (hidden_states,)
|
| 1137 |
+
|
| 1138 |
+
# Get past shared KV cache
|
| 1139 |
+
past_shared_key, past_shared_value = None, None
|
| 1140 |
+
if next_decoder_cache is not None:
|
| 1141 |
+
past_shared_key, past_shared_value = next_decoder_cache.get_shared(layer_idx)
|
| 1142 |
+
|
| 1143 |
+
# Forward Loop 1
|
| 1144 |
+
attn_output, k1, v1 = decoder_layer.self_attn.forward_decode_loop1(
|
| 1145 |
+
hidden_states=decoder_layer.input_layernorm(hidden_states),
|
| 1146 |
+
past_shared_key=past_shared_key,
|
| 1147 |
+
past_shared_value=past_shared_value,
|
| 1148 |
+
attention_mask=causal_mask,
|
| 1149 |
+
position_ids=position_ids,
|
| 1150 |
+
cache_position=cache_position,
|
| 1151 |
+
)
|
| 1152 |
+
|
| 1153 |
+
# Update shared cache with current token's Loop 1 KV
|
| 1154 |
+
if use_cache:
|
| 1155 |
+
next_decoder_cache.update_shared(k1, v1, layer_idx)
|
| 1156 |
+
|
| 1157 |
+
hidden_states = hidden_states + attn_output
|
| 1158 |
+
|
| 1159 |
+
# MLP
|
| 1160 |
+
residual = hidden_states
|
| 1161 |
+
hidden_states = decoder_layer.post_attention_layernorm(hidden_states)
|
| 1162 |
+
hidden_states = decoder_layer.mlp(hidden_states)
|
| 1163 |
+
hidden_states = residual + hidden_states
|
| 1164 |
+
|
| 1165 |
+
if output_attentions:
|
| 1166 |
+
all_self_attns += (None,) # We don't return attention weights in decode loop
|
| 1167 |
+
|
| 1168 |
+
# ============ Loop 2 to loop_num: Mixed attention, store in local cache ============
|
| 1169 |
+
# Store k1, v1 from Loop 1 for use in Loop 2+
|
| 1170 |
+
loop1_kv = []
|
| 1171 |
+
for layer_idx in range(len(self.layers)):
|
| 1172 |
+
if next_decoder_cache is not None:
|
| 1173 |
+
k1_full, v1_full = next_decoder_cache.get_shared(layer_idx)
|
| 1174 |
+
if k1_full is not None and v1_full is not None:
|
| 1175 |
+
# Get only the last token (current token)
|
| 1176 |
+
loop1_kv.append((k1_full[:, :, -1:, :], v1_full[:, :, -1:, :], k1_full, v1_full))
|
| 1177 |
+
else:
|
| 1178 |
+
loop1_kv.append((None, None, None, None))
|
| 1179 |
+
else:
|
| 1180 |
+
loop1_kv.append((None, None, None, None))
|
| 1181 |
+
|
| 1182 |
+
for loop_idx in range(2, self.loop_num + 1):
|
| 1183 |
+
for layer_idx, decoder_layer in enumerate(self.layers):
|
| 1184 |
+
# Get k1, v1 (current token's Loop 1 KV) and full shared cache
|
| 1185 |
+
k1_current, v1_current, k1_full, v1_full = loop1_kv[layer_idx]
|
| 1186 |
+
if k1_current is None or v1_current is None:
|
| 1187 |
+
continue
|
| 1188 |
+
|
| 1189 |
+
# Get past local KV cache
|
| 1190 |
+
past_local_key, past_local_value = None, None
|
| 1191 |
+
if next_decoder_cache is not None:
|
| 1192 |
+
past_local_key, past_local_value = next_decoder_cache.get_local(layer_idx)
|
| 1193 |
+
|
| 1194 |
+
gate_proj = self.gate_projections[layer_idx]
|
| 1195 |
+
|
| 1196 |
+
# Forward Loop 2+
|
| 1197 |
+
attn_output, k2, v2 = decoder_layer.self_attn.forward_decode_loop2(
|
| 1198 |
+
hidden_states=decoder_layer.input_layernorm(hidden_states),
|
| 1199 |
+
k1=k1_current,
|
| 1200 |
+
v1=v1_current,
|
| 1201 |
+
past_shared_key=k1_full[:, :, :-1, :] if k1_full is not None and k1_full.shape[2] > 1 else None,
|
| 1202 |
+
past_shared_value=v1_full[:, :, :-1, :] if v1_full is not None and v1_full.shape[2] > 1 else None,
|
| 1203 |
+
past_local_key=past_local_key,
|
| 1204 |
+
past_local_value=past_local_value,
|
| 1205 |
+
gate_proj=gate_proj,
|
| 1206 |
+
attention_mask=causal_mask,
|
| 1207 |
+
position_ids=position_ids,
|
| 1208 |
+
loop_window_size=self.loop_window_size,
|
| 1209 |
+
)
|
| 1210 |
+
|
| 1211 |
+
# Update local cache with current token's Loop 2+ KV
|
| 1212 |
+
if use_cache and loop_idx == 2:
|
| 1213 |
+
next_decoder_cache.update_local(k2, v2, layer_idx)
|
| 1214 |
+
|
| 1215 |
+
hidden_states = hidden_states + attn_output
|
| 1216 |
+
|
| 1217 |
+
# MLP
|
| 1218 |
+
residual = hidden_states
|
| 1219 |
+
hidden_states = decoder_layer.post_attention_layernorm(hidden_states)
|
| 1220 |
+
hidden_states = decoder_layer.mlp(hidden_states)
|
| 1221 |
+
hidden_states = residual + hidden_states
|
| 1222 |
+
|
| 1223 |
+
hidden_states = self.norm(hidden_states)
|
| 1224 |
+
|
| 1225 |
+
if output_hidden_states:
|
| 1226 |
+
all_hidden_states += (hidden_states,)
|
| 1227 |
+
|
| 1228 |
+
next_cache = next_decoder_cache if use_cache else None
|
| 1229 |
+
|
| 1230 |
+
if not return_dict:
|
| 1231 |
+
return tuple(v for v in [hidden_states, next_cache, all_hidden_states, all_self_attns] if v is not None)
|
| 1232 |
+
|
| 1233 |
+
return BaseModelOutputWithPast(
|
| 1234 |
+
last_hidden_state=hidden_states,
|
| 1235 |
+
past_key_values=next_cache,
|
| 1236 |
+
hidden_states=all_hidden_states,
|
| 1237 |
+
attentions=all_self_attns,
|
| 1238 |
+
)
|
| 1239 |
+
|
| 1240 |
+
def _update_causal_mask(
|
| 1241 |
+
self,
|
| 1242 |
+
attention_mask: torch.Tensor,
|
| 1243 |
+
input_tensor: torch.Tensor,
|
| 1244 |
+
cache_position: torch.Tensor,
|
| 1245 |
+
past_key_values: Cache,
|
| 1246 |
+
output_attentions: bool,
|
| 1247 |
+
):
|
| 1248 |
+
"""Create causal attention mask."""
|
| 1249 |
+
dtype, device = input_tensor.dtype, input_tensor.device
|
| 1250 |
+
min_dtype = torch.finfo(dtype).min
|
| 1251 |
+
sequence_length = input_tensor.shape[1]
|
| 1252 |
+
|
| 1253 |
+
# Determine target length for attention
|
| 1254 |
+
if past_key_values is not None:
|
| 1255 |
+
# For DynamicCache: use get_seq_length() to get cached length
|
| 1256 |
+
# target_length = cached_length + current_sequence_length
|
| 1257 |
+
past_length = past_key_values.get_seq_length()
|
| 1258 |
+
target_length = past_length + sequence_length
|
| 1259 |
+
elif attention_mask is not None:
|
| 1260 |
+
target_length = attention_mask.shape[-1]
|
| 1261 |
+
else:
|
| 1262 |
+
target_length = sequence_length
|
| 1263 |
+
|
| 1264 |
+
# Create causal mask
|
| 1265 |
+
causal_mask = torch.full((sequence_length, target_length), fill_value=min_dtype, dtype=dtype, device=device)
|
| 1266 |
+
if sequence_length != 1:
|
| 1267 |
+
# For prefill: standard causal mask
|
| 1268 |
+
causal_mask = torch.triu(causal_mask, diagonal=1)
|
| 1269 |
+
|
| 1270 |
+
# Adjust for cache position (for generation steps after prefill)
|
| 1271 |
+
causal_mask *= torch.arange(target_length, device=device) > cache_position.reshape(-1, 1)
|
| 1272 |
+
causal_mask = causal_mask[None, None, :, :].expand(input_tensor.shape[0], 1, -1, -1)
|
| 1273 |
+
|
| 1274 |
+
if attention_mask is not None:
|
| 1275 |
+
causal_mask = causal_mask.clone()
|
| 1276 |
+
mask_length = attention_mask.shape[-1]
|
| 1277 |
+
if mask_length <= target_length:
|
| 1278 |
+
padding_mask = causal_mask[:, :, :, :mask_length] + attention_mask[:, None, None, :]
|
| 1279 |
+
padding_mask = padding_mask == 0
|
| 1280 |
+
causal_mask[:, :, :, :mask_length] = causal_mask[:, :, :, :mask_length].masked_fill(padding_mask, min_dtype)
|
| 1281 |
+
|
| 1282 |
+
return causal_mask
|
| 1283 |
+
|
| 1284 |
+
|
| 1285 |
+
class IQuestLoopCoderForCausalLM(IQuestLoopCoderPreTrainedModel, GenerationMixin):
|
| 1286 |
+
"""IQuestLoopCoder model with a causal language modeling head."""
|
| 1287 |
+
_tied_weights_keys = ["lm_head.weight"]
|
| 1288 |
+
|
| 1289 |
+
def __init__(self, config):
|
| 1290 |
+
super().__init__(config)
|
| 1291 |
+
self.model = IQuestLoopCoderModel(config)
|
| 1292 |
+
self.vocab_size = config.vocab_size
|
| 1293 |
+
self.lm_head = nn.Linear(config.hidden_size, config.vocab_size, bias=False)
|
| 1294 |
+
self.post_init()
|
| 1295 |
+
|
| 1296 |
+
def get_input_embeddings(self):
|
| 1297 |
+
return self.model.embed_tokens
|
| 1298 |
+
|
| 1299 |
+
def set_input_embeddings(self, value):
|
| 1300 |
+
self.model.embed_tokens = value
|
| 1301 |
+
|
| 1302 |
+
def get_output_embeddings(self):
|
| 1303 |
+
return self.lm_head
|
| 1304 |
+
|
| 1305 |
+
def set_output_embeddings(self, new_embeddings):
|
| 1306 |
+
self.lm_head = new_embeddings
|
| 1307 |
+
|
| 1308 |
+
def set_decoder(self, decoder):
|
| 1309 |
+
self.model = decoder
|
| 1310 |
+
|
| 1311 |
+
def get_decoder(self):
|
| 1312 |
+
return self.model
|
| 1313 |
+
|
| 1314 |
+
def forward(
|
| 1315 |
+
self,
|
| 1316 |
+
input_ids: torch.LongTensor = None,
|
| 1317 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 1318 |
+
position_ids: Optional[torch.LongTensor] = None,
|
| 1319 |
+
past_key_values: Optional[Cache] = None,
|
| 1320 |
+
inputs_embeds: Optional[torch.FloatTensor] = None,
|
| 1321 |
+
labels: Optional[torch.LongTensor] = None,
|
| 1322 |
+
use_cache: Optional[bool] = None,
|
| 1323 |
+
output_attentions: Optional[bool] = None,
|
| 1324 |
+
output_hidden_states: Optional[bool] = None,
|
| 1325 |
+
return_dict: Optional[bool] = None,
|
| 1326 |
+
cache_position: Optional[torch.LongTensor] = None,
|
| 1327 |
+
) -> Union[Tuple, CausalLMOutputWithPast]:
|
| 1328 |
+
output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
|
| 1329 |
+
output_hidden_states = output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
|
| 1330 |
+
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
| 1331 |
+
|
| 1332 |
+
outputs = self.model(
|
| 1333 |
+
input_ids=input_ids,
|
| 1334 |
+
attention_mask=attention_mask,
|
| 1335 |
+
position_ids=position_ids,
|
| 1336 |
+
past_key_values=past_key_values,
|
| 1337 |
+
inputs_embeds=inputs_embeds,
|
| 1338 |
+
use_cache=use_cache,
|
| 1339 |
+
output_attentions=output_attentions,
|
| 1340 |
+
output_hidden_states=output_hidden_states,
|
| 1341 |
+
return_dict=return_dict,
|
| 1342 |
+
cache_position=cache_position,
|
| 1343 |
+
)
|
| 1344 |
+
|
| 1345 |
+
hidden_states = outputs[0]
|
| 1346 |
+
logits = self.lm_head(hidden_states)
|
| 1347 |
+
logits = logits.float()
|
| 1348 |
+
|
| 1349 |
+
loss = None
|
| 1350 |
+
if labels is not None:
|
| 1351 |
+
shift_logits = logits[..., :-1, :].contiguous()
|
| 1352 |
+
shift_labels = labels[..., 1:].contiguous()
|
| 1353 |
+
loss_fct = nn.CrossEntropyLoss()
|
| 1354 |
+
shift_logits = shift_logits.view(-1, self.config.vocab_size)
|
| 1355 |
+
shift_labels = shift_labels.view(-1)
|
| 1356 |
+
shift_labels = shift_labels.to(shift_logits.device)
|
| 1357 |
+
loss = loss_fct(shift_logits, shift_labels)
|
| 1358 |
+
|
| 1359 |
+
if not return_dict:
|
| 1360 |
+
output = (logits,) + outputs[1:]
|
| 1361 |
+
return (loss,) + output if loss is not None else output
|
| 1362 |
+
|
| 1363 |
+
return CausalLMOutputWithPast(
|
| 1364 |
+
loss=loss,
|
| 1365 |
+
logits=logits,
|
| 1366 |
+
past_key_values=outputs.past_key_values,
|
| 1367 |
+
hidden_states=outputs.hidden_states,
|
| 1368 |
+
attentions=outputs.attentions,
|
| 1369 |
+
)
|
| 1370 |
+
|
| 1371 |
+
def prepare_inputs_for_generation(
|
| 1372 |
+
self,
|
| 1373 |
+
input_ids,
|
| 1374 |
+
past_key_values=None,
|
| 1375 |
+
attention_mask=None,
|
| 1376 |
+
inputs_embeds=None,
|
| 1377 |
+
cache_position=None,
|
| 1378 |
+
use_cache=True,
|
| 1379 |
+
**kwargs,
|
| 1380 |
+
):
|
| 1381 |
+
past_length = 0
|
| 1382 |
+
if past_key_values is not None:
|
| 1383 |
+
past_length = past_key_values.get_seq_length()
|
| 1384 |
+
if attention_mask is not None and attention_mask.shape[1] > input_ids.shape[1]:
|
| 1385 |
+
input_ids = input_ids[:, -(attention_mask.shape[1] - past_length) :]
|
| 1386 |
+
elif past_length < input_ids.shape[1]:
|
| 1387 |
+
input_ids = input_ids[:, past_length:]
|
| 1388 |
+
|
| 1389 |
+
if cache_position is None:
|
| 1390 |
+
cache_position = torch.arange(past_length, past_length + input_ids.shape[1], device=input_ids.device)
|
| 1391 |
+
elif use_cache:
|
| 1392 |
+
cache_position = cache_position[-input_ids.shape[1]:]
|
| 1393 |
+
|
| 1394 |
+
position_ids = cache_position.unsqueeze(0)
|
| 1395 |
+
|
| 1396 |
+
if inputs_embeds is not None and past_key_values is None:
|
| 1397 |
+
model_inputs = {"inputs_embeds": inputs_embeds}
|
| 1398 |
+
else:
|
| 1399 |
+
model_inputs = {"input_ids": input_ids.contiguous()}
|
| 1400 |
+
|
| 1401 |
+
model_inputs.update(
|
| 1402 |
+
{
|
| 1403 |
+
"position_ids": position_ids,
|
| 1404 |
+
"cache_position": cache_position,
|
| 1405 |
+
"past_key_values": past_key_values,
|
| 1406 |
+
"use_cache": use_cache,
|
| 1407 |
+
"attention_mask": attention_mask,
|
| 1408 |
+
}
|
| 1409 |
+
)
|
| 1410 |
+
return model_inputs
|
| 1411 |
+
|
tokenization_iquestcoder.py
ADDED
|
@@ -0,0 +1,552 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Tokenization classes for IQuestCoder."""
|
| 2 |
+
|
| 3 |
+
import os
|
| 4 |
+
from shutil import copyfile
|
| 5 |
+
from typing import Any, Dict, List, Optional, Tuple, Union
|
| 6 |
+
|
| 7 |
+
import sentencepiece as spm
|
| 8 |
+
|
| 9 |
+
from transformers.tokenization_utils import AddedToken, PreTrainedTokenizer
|
| 10 |
+
from transformers.utils import logging
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
logger = logging.get_logger(__name__)
|
| 14 |
+
|
| 15 |
+
VOCAB_FILES_NAMES = {"vocab_file": "tokenizer.model"}
|
| 16 |
+
|
| 17 |
+
PRETRAINED_VOCAB_FILES_MAP = {
|
| 18 |
+
"vocab_file": {},
|
| 19 |
+
"tokenizer_file": {},
|
| 20 |
+
}
|
| 21 |
+
PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES = {}
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
class IQuestCoderTokenizer(PreTrainedTokenizer):
|
| 26 |
+
|
| 27 |
+
vocab_files_names = VOCAB_FILES_NAMES
|
| 28 |
+
pretrained_vocab_files_map = PRETRAINED_VOCAB_FILES_MAP
|
| 29 |
+
max_model_input_sizes = PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
|
| 30 |
+
model_input_names = ["input_ids", "attention_mask"]
|
| 31 |
+
|
| 32 |
+
def __init__(
|
| 33 |
+
self,
|
| 34 |
+
vocab_file,
|
| 35 |
+
unk_token="<unk>",
|
| 36 |
+
bos_token="<s>",
|
| 37 |
+
eos_token="</s>",
|
| 38 |
+
pad_token=None,
|
| 39 |
+
sp_model_kwargs: Optional[Dict[str, Any]] = None,
|
| 40 |
+
add_bos_token=True,
|
| 41 |
+
add_eos_token=False,
|
| 42 |
+
clean_up_tokenization_spaces=False,
|
| 43 |
+
add_prefix_space=False,
|
| 44 |
+
legacy=None,
|
| 45 |
+
use_default_system_prompt=False,
|
| 46 |
+
chat_template=None,
|
| 47 |
+
**kwargs,
|
| 48 |
+
):
|
| 49 |
+
self.sp_model_kwargs = {} if sp_model_kwargs is None else sp_model_kwargs
|
| 50 |
+
bos_token = AddedToken(bos_token, lstrip=False, rstrip=False) if isinstance(bos_token, str) else bos_token
|
| 51 |
+
eos_token = AddedToken(eos_token, lstrip=False, rstrip=False) if isinstance(eos_token, str) else eos_token
|
| 52 |
+
unk_token = AddedToken(unk_token, lstrip=False, rstrip=False) if isinstance(unk_token, str) else unk_token
|
| 53 |
+
pad_token = AddedToken(pad_token, lstrip=False, rstrip=False) if isinstance(pad_token, str) else pad_token
|
| 54 |
+
|
| 55 |
+
# Legacy behavior handling
|
| 56 |
+
if legacy is None:
|
| 57 |
+
logger.warning_once(
|
| 58 |
+
f"You are using the default legacy behaviour of the {self.__class__.__name__}. This is"
|
| 59 |
+
" expected, and simply means that the `legacy` (previous) behavior will be used so nothing changes for you."
|
| 60 |
+
" If you want to use the new behaviour, set `legacy=False`. This should only be set if you understand what it"
|
| 61 |
+
" means, and thoroughly read the reason why this was added as explained in"
|
| 62 |
+
" https://github.com/huggingface/transformers/pull/24565"
|
| 63 |
+
)
|
| 64 |
+
legacy = True
|
| 65 |
+
|
| 66 |
+
self.legacy = legacy
|
| 67 |
+
self.vocab_file = vocab_file
|
| 68 |
+
self.add_bos_token = add_bos_token
|
| 69 |
+
self.add_eos_token = add_eos_token
|
| 70 |
+
self.add_prefix_space = add_prefix_space
|
| 71 |
+
self.use_default_system_prompt = use_default_system_prompt
|
| 72 |
+
self.sp_model = spm.SentencePieceProcessor(**self.sp_model_kwargs)
|
| 73 |
+
self.sp_model.Load(vocab_file)
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
super().__init__(
|
| 78 |
+
bos_token=bos_token,
|
| 79 |
+
eos_token=eos_token,
|
| 80 |
+
unk_token=unk_token,
|
| 81 |
+
pad_token=pad_token,
|
| 82 |
+
add_bos_token=add_bos_token,
|
| 83 |
+
add_eos_token=add_eos_token,
|
| 84 |
+
sp_model_kwargs=self.sp_model_kwargs,
|
| 85 |
+
clean_up_tokenization_spaces=clean_up_tokenization_spaces,
|
| 86 |
+
add_prefix_space=add_prefix_space,
|
| 87 |
+
legacy=legacy,
|
| 88 |
+
use_default_system_prompt=use_default_system_prompt,
|
| 89 |
+
chat_template=chat_template,
|
| 90 |
+
**kwargs,
|
| 91 |
+
)
|
| 92 |
+
|
| 93 |
+
def __getstate__(self):
|
| 94 |
+
state = self.__dict__.copy()
|
| 95 |
+
state["sp_model"] = None
|
| 96 |
+
return state
|
| 97 |
+
|
| 98 |
+
def __setstate__(self, d):
|
| 99 |
+
self.__dict__ = d
|
| 100 |
+
self.sp_model = spm.SentencePieceProcessor(**self.sp_model_kwargs)
|
| 101 |
+
self.sp_model.Load(self.vocab_file)
|
| 102 |
+
|
| 103 |
+
@property
|
| 104 |
+
def vocab_size(self) -> int:
|
| 105 |
+
"""Returns the vocabulary size."""
|
| 106 |
+
return self.sp_model.get_piece_size()
|
| 107 |
+
|
| 108 |
+
def get_vocab(self) -> Dict[str, int]:
|
| 109 |
+
"""Returns the vocabulary as a dictionary of token to index."""
|
| 110 |
+
vocab = {self.convert_ids_to_tokens(i): i for i in range(self.vocab_size)}
|
| 111 |
+
vocab.update(self.added_tokens_encoder)
|
| 112 |
+
return vocab
|
| 113 |
+
|
| 114 |
+
def _tokenize(self, text: str) -> List[str]:
|
| 115 |
+
"""
|
| 116 |
+
Tokenize a string.
|
| 117 |
+
|
| 118 |
+
Args:
|
| 119 |
+
text (`str`): The text to tokenize.
|
| 120 |
+
|
| 121 |
+
Returns:
|
| 122 |
+
`List[str]`: The list of tokens.
|
| 123 |
+
"""
|
| 124 |
+
if self.add_prefix_space:
|
| 125 |
+
text = " " + text
|
| 126 |
+
|
| 127 |
+
if self.legacy:
|
| 128 |
+
return self.sp_model.encode(text, out_type=str)
|
| 129 |
+
|
| 130 |
+
# Non-legacy behavior: handle special tokens properly
|
| 131 |
+
return self.sp_model.encode(text, out_type=str)
|
| 132 |
+
|
| 133 |
+
def _convert_token_to_id(self, token: str) -> int:
|
| 134 |
+
"""Converts a token (str) to an id using the vocab."""
|
| 135 |
+
return self.sp_model.piece_to_id(token)
|
| 136 |
+
|
| 137 |
+
def _convert_id_to_token(self, index: int) -> str:
|
| 138 |
+
"""Converts an index (integer) to a token (str) using the vocab."""
|
| 139 |
+
token = self.sp_model.IdToPiece(index)
|
| 140 |
+
return token
|
| 141 |
+
|
| 142 |
+
def convert_tokens_to_string(self, tokens: List[str]) -> str:
|
| 143 |
+
"""
|
| 144 |
+
Converts a sequence of tokens (strings) to a single string.
|
| 145 |
+
|
| 146 |
+
This method handles special tokens separately to ensure they are not
|
| 147 |
+
decoded using the SentencePiece model.
|
| 148 |
+
|
| 149 |
+
Args:
|
| 150 |
+
tokens (`List[str]`): The list of tokens to convert.
|
| 151 |
+
|
| 152 |
+
Returns:
|
| 153 |
+
`str`: The decoded string.
|
| 154 |
+
"""
|
| 155 |
+
current_sub_tokens = []
|
| 156 |
+
out_string = ""
|
| 157 |
+
prev_is_special = False
|
| 158 |
+
for i, token in enumerate(tokens):
|
| 159 |
+
# make sure that special tokens are not decoded using sentencepiece model
|
| 160 |
+
if token in self.all_special_tokens:
|
| 161 |
+
if not prev_is_special and i != 0:
|
| 162 |
+
out_string += " "
|
| 163 |
+
out_string += self.sp_model.decode(current_sub_tokens) + token
|
| 164 |
+
prev_is_special = True
|
| 165 |
+
current_sub_tokens = []
|
| 166 |
+
else:
|
| 167 |
+
current_sub_tokens.append(token)
|
| 168 |
+
prev_is_special = False
|
| 169 |
+
out_string += self.sp_model.decode(current_sub_tokens)
|
| 170 |
+
return out_string
|
| 171 |
+
|
| 172 |
+
def save_vocabulary(self, save_directory: str, filename_prefix: Optional[str] = None) -> Tuple[str]:
|
| 173 |
+
"""
|
| 174 |
+
Save the vocabulary and special tokens file to a directory.
|
| 175 |
+
|
| 176 |
+
Args:
|
| 177 |
+
save_directory (`str`):
|
| 178 |
+
The directory in which to save the vocabulary.
|
| 179 |
+
filename_prefix (`str`, *optional*):
|
| 180 |
+
An optional prefix to add to the named of the saved files.
|
| 181 |
+
|
| 182 |
+
Returns:
|
| 183 |
+
`Tuple(str)`: Paths to the files saved.
|
| 184 |
+
"""
|
| 185 |
+
if not os.path.isdir(save_directory):
|
| 186 |
+
logger.error(f"Vocabulary path ({save_directory}) should be a directory")
|
| 187 |
+
return
|
| 188 |
+
out_vocab_file = os.path.join(
|
| 189 |
+
save_directory, (filename_prefix + "-" if filename_prefix else "") + VOCAB_FILES_NAMES["vocab_file"]
|
| 190 |
+
)
|
| 191 |
+
|
| 192 |
+
if os.path.abspath(self.vocab_file) != os.path.abspath(out_vocab_file) and os.path.isfile(self.vocab_file):
|
| 193 |
+
copyfile(self.vocab_file, out_vocab_file)
|
| 194 |
+
elif not os.path.isfile(self.vocab_file):
|
| 195 |
+
with open(out_vocab_file, "wb") as fi:
|
| 196 |
+
content_spiece_model = self.sp_model.serialized_model_proto()
|
| 197 |
+
fi.write(content_spiece_model)
|
| 198 |
+
|
| 199 |
+
return (out_vocab_file,)
|
| 200 |
+
|
| 201 |
+
def build_inputs_with_special_tokens(
|
| 202 |
+
self,
|
| 203 |
+
token_ids_0: List[int],
|
| 204 |
+
token_ids_1: Optional[List[int]] = None
|
| 205 |
+
) -> List[int]:
|
| 206 |
+
"""
|
| 207 |
+
Build model inputs from a sequence or a pair of sequences for sequence classification tasks by concatenating
|
| 208 |
+
and adding special tokens.
|
| 209 |
+
|
| 210 |
+
An IQuestCoder sequence has the following format:
|
| 211 |
+
|
| 212 |
+
- single sequence: `<s> X </s>` (if add_eos_token is True) or `<s> X` (default)
|
| 213 |
+
- pair of sequences: `<s> A </s> <s> B </s>` (if add_eos_token is True) or `<s> A <s> B` (default)
|
| 214 |
+
|
| 215 |
+
Args:
|
| 216 |
+
token_ids_0 (`List[int]`):
|
| 217 |
+
List of IDs to which the special tokens will be added.
|
| 218 |
+
token_ids_1 (`List[int]`, *optional*):
|
| 219 |
+
Optional second list of IDs for sequence pairs.
|
| 220 |
+
|
| 221 |
+
Returns:
|
| 222 |
+
`List[int]`: List of input IDs with the appropriate special tokens.
|
| 223 |
+
"""
|
| 224 |
+
bos_token_id = [self.bos_token_id] if self.add_bos_token else []
|
| 225 |
+
eos_token_id = [self.eos_token_id] if self.add_eos_token else []
|
| 226 |
+
|
| 227 |
+
output = bos_token_id + token_ids_0 + eos_token_id
|
| 228 |
+
|
| 229 |
+
if token_ids_1 is not None:
|
| 230 |
+
output = output + bos_token_id + token_ids_1 + eos_token_id
|
| 231 |
+
|
| 232 |
+
return output
|
| 233 |
+
|
| 234 |
+
def get_special_tokens_mask(
|
| 235 |
+
self,
|
| 236 |
+
token_ids_0: List[int],
|
| 237 |
+
token_ids_1: Optional[List[int]] = None,
|
| 238 |
+
already_has_special_tokens: bool = False
|
| 239 |
+
) -> List[int]:
|
| 240 |
+
"""
|
| 241 |
+
Retrieve sequence ids from a token list that has no special tokens added. This method is called when adding
|
| 242 |
+
special tokens using the tokenizer `prepare_for_model` method.
|
| 243 |
+
|
| 244 |
+
Args:
|
| 245 |
+
token_ids_0 (`List[int]`):
|
| 246 |
+
List of IDs.
|
| 247 |
+
token_ids_1 (`List[int]`, *optional*):
|
| 248 |
+
Optional second list of IDs for sequence pairs.
|
| 249 |
+
already_has_special_tokens (`bool`, *optional*, defaults to `False`):
|
| 250 |
+
Whether or not the token list is already formatted with special tokens for the model.
|
| 251 |
+
|
| 252 |
+
Returns:
|
| 253 |
+
`List[int]`: A list of integers in the range [0, 1]: 1 for a special token, 0 for a sequence token.
|
| 254 |
+
"""
|
| 255 |
+
if already_has_special_tokens:
|
| 256 |
+
return super().get_special_tokens_mask(
|
| 257 |
+
token_ids_0=token_ids_0, token_ids_1=token_ids_1, already_has_special_tokens=True
|
| 258 |
+
)
|
| 259 |
+
|
| 260 |
+
bos_token_id = [1] if self.add_bos_token else []
|
| 261 |
+
eos_token_id = [1] if self.add_eos_token else []
|
| 262 |
+
|
| 263 |
+
if token_ids_1 is None:
|
| 264 |
+
return bos_token_id + ([0] * len(token_ids_0)) + eos_token_id
|
| 265 |
+
return (
|
| 266 |
+
bos_token_id
|
| 267 |
+
+ ([0] * len(token_ids_0))
|
| 268 |
+
+ eos_token_id
|
| 269 |
+
+ bos_token_id
|
| 270 |
+
+ ([0] * len(token_ids_1))
|
| 271 |
+
+ eos_token_id
|
| 272 |
+
)
|
| 273 |
+
|
| 274 |
+
def create_token_type_ids_from_sequences(
|
| 275 |
+
self,
|
| 276 |
+
token_ids_0: List[int],
|
| 277 |
+
token_ids_1: Optional[List[int]] = None
|
| 278 |
+
) -> List[int]:
|
| 279 |
+
"""
|
| 280 |
+
Create a mask from the two sequences passed to be used in a sequence-pair classification task.
|
| 281 |
+
|
| 282 |
+
An IQuestCoder sequence pair mask has the following format:
|
| 283 |
+
|
| 284 |
+
```
|
| 285 |
+
0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1
|
| 286 |
+
| first sequence | second sequence |
|
| 287 |
+
```
|
| 288 |
+
|
| 289 |
+
If `token_ids_1` is `None`, this method only returns the first portion of the mask (0s).
|
| 290 |
+
|
| 291 |
+
Args:
|
| 292 |
+
token_ids_0 (`List[int]`):
|
| 293 |
+
List of IDs.
|
| 294 |
+
token_ids_1 (`List[int]`, *optional*):
|
| 295 |
+
Optional second list of IDs for sequence pairs.
|
| 296 |
+
|
| 297 |
+
Returns:
|
| 298 |
+
`List[int]`: List of token type IDs according to the given sequence(s).
|
| 299 |
+
"""
|
| 300 |
+
bos_token_id = [self.bos_token_id] if self.add_bos_token else []
|
| 301 |
+
eos_token_id = [self.eos_token_id] if self.add_eos_token else []
|
| 302 |
+
|
| 303 |
+
output = [0] * len(bos_token_id + token_ids_0 + eos_token_id)
|
| 304 |
+
|
| 305 |
+
if token_ids_1 is not None:
|
| 306 |
+
output += [1] * len(bos_token_id + token_ids_1 + eos_token_id)
|
| 307 |
+
|
| 308 |
+
return output
|
| 309 |
+
|
| 310 |
+
@property
|
| 311 |
+
def default_chat_template(self) -> str:
|
| 312 |
+
"""
|
| 313 |
+
Returns the default chat template for IQuestCoder.
|
| 314 |
+
|
| 315 |
+
This template formats conversations with system, user, and assistant roles.
|
| 316 |
+
"""
|
| 317 |
+
return DEFAULT_CHAT_TEMPLATE
|
| 318 |
+
|
| 319 |
+
def apply_chat_template(
|
| 320 |
+
self,
|
| 321 |
+
conversation: Union[List[Dict[str, str]], "Conversation"],
|
| 322 |
+
chat_template: Optional[str] = None,
|
| 323 |
+
add_generation_prompt: bool = False,
|
| 324 |
+
tokenize: bool = True,
|
| 325 |
+
padding: bool = False,
|
| 326 |
+
truncation: bool = False,
|
| 327 |
+
max_length: Optional[int] = None,
|
| 328 |
+
return_tensors: Optional[str] = None,
|
| 329 |
+
return_dict: bool = False,
|
| 330 |
+
**tokenizer_kwargs,
|
| 331 |
+
):
|
| 332 |
+
"""
|
| 333 |
+
Apply a chat template to format a conversation.
|
| 334 |
+
|
| 335 |
+
Args:
|
| 336 |
+
conversation (`List[Dict[str, str]]` or `Conversation`):
|
| 337 |
+
A list of dicts with "role" and "content" keys, representing the conversation history.
|
| 338 |
+
chat_template (`str`, *optional*):
|
| 339 |
+
A Jinja template to use for formatting. If not provided, the tokenizer's default will be used.
|
| 340 |
+
add_generation_prompt (`bool`, *optional*, defaults to `False`):
|
| 341 |
+
Whether to add a generation prompt at the end for the assistant to continue.
|
| 342 |
+
tokenize (`bool`, *optional*, defaults to `True`):
|
| 343 |
+
Whether to tokenize the output. If `False`, returns a string.
|
| 344 |
+
padding (`bool`, *optional*, defaults to `False`):
|
| 345 |
+
Whether to pad sequences.
|
| 346 |
+
truncation (`bool`, *optional*, defaults to `False`):
|
| 347 |
+
Whether to truncate sequences.
|
| 348 |
+
max_length (`int`, *optional*):
|
| 349 |
+
Maximum length of the output.
|
| 350 |
+
return_tensors (`str`, *optional*):
|
| 351 |
+
The type of tensors to return ("pt", "tf", "np", or None).
|
| 352 |
+
return_dict (`bool`, *optional*, defaults to `False`):
|
| 353 |
+
Whether to return a dictionary with additional information.
|
| 354 |
+
**tokenizer_kwargs:
|
| 355 |
+
Additional keyword arguments passed to the tokenizer.
|
| 356 |
+
|
| 357 |
+
Returns:
|
| 358 |
+
`Union[str, List[int], BatchEncoding]`: The formatted (and optionally tokenized) conversation.
|
| 359 |
+
|
| 360 |
+
Example:
|
| 361 |
+
```python
|
| 362 |
+
>>> tokenizer = IQuestCoderTokenizer.from_pretrained("path/to/model")
|
| 363 |
+
>>> conversation = [
|
| 364 |
+
... {"role": "system", "content": "You are a helpful assistant."},
|
| 365 |
+
... {"role": "user", "content": "Hello!"},
|
| 366 |
+
... {"role": "assistant", "content": "Hi there! How can I help you today?"},
|
| 367 |
+
... {"role": "user", "content": "What's the weather like?"},
|
| 368 |
+
... ]
|
| 369 |
+
>>> tokenizer.apply_chat_template(conversation, add_generation_prompt=True, tokenize=False)
|
| 370 |
+
'<|system|>\\nYou are a helpful assistant.\\n</|system|><|user|>\\nHello!\\n</|user|>...'
|
| 371 |
+
```
|
| 372 |
+
"""
|
| 373 |
+
# Use parent class implementation with our template
|
| 374 |
+
return super().apply_chat_template(
|
| 375 |
+
conversation,
|
| 376 |
+
chat_template=chat_template,
|
| 377 |
+
add_generation_prompt=add_generation_prompt,
|
| 378 |
+
tokenize=tokenize,
|
| 379 |
+
padding=padding,
|
| 380 |
+
truncation=truncation,
|
| 381 |
+
max_length=max_length,
|
| 382 |
+
return_tensors=return_tensors,
|
| 383 |
+
return_dict=return_dict,
|
| 384 |
+
**tokenizer_kwargs,
|
| 385 |
+
)
|
| 386 |
+
|
| 387 |
+
|
| 388 |
+
# Try to import and create Fast tokenizer version
|
| 389 |
+
try:
|
| 390 |
+
from transformers import PreTrainedTokenizerFast
|
| 391 |
+
from tokenizers import Tokenizer, decoders, models, normalizers, pre_tokenizers, processors
|
| 392 |
+
|
| 393 |
+
class IQuestCoderTokenizerFast(PreTrainedTokenizerFast):
|
| 394 |
+
"""
|
| 395 |
+
Construct a "fast" IQuestCoder tokenizer (backed by HuggingFace's *tokenizers* library).
|
| 396 |
+
|
| 397 |
+
This is a fast implementation of [`IQuestCoderTokenizer`] using the 🤗 Tokenizers library.
|
| 398 |
+
|
| 399 |
+
Args:
|
| 400 |
+
vocab_file (`str`, *optional*):
|
| 401 |
+
Path to the vocabulary file (SentencePiece model).
|
| 402 |
+
tokenizer_file (`str`, *optional*):
|
| 403 |
+
Path to a tokenizer JSON file.
|
| 404 |
+
unk_token (`str`, *optional*, defaults to `"<unk>"`):
|
| 405 |
+
The unknown token.
|
| 406 |
+
bos_token (`str`, *optional*, defaults to `"<s>"`):
|
| 407 |
+
The beginning of sequence token.
|
| 408 |
+
eos_token (`str`, *optional*, defaults to `"</s>"`):
|
| 409 |
+
The end of sequence token.
|
| 410 |
+
pad_token (`str`, *optional*):
|
| 411 |
+
The token used for padding.
|
| 412 |
+
add_bos_token (`bool`, *optional*, defaults to `True`):
|
| 413 |
+
Whether to add a BOS token at the start of sequences.
|
| 414 |
+
add_eos_token (`bool`, *optional*, defaults to `False`):
|
| 415 |
+
Whether to add an EOS token at the end of sequences.
|
| 416 |
+
add_prefix_space (`bool`, *optional*, defaults to `False`):
|
| 417 |
+
Whether to add an initial space to the input.
|
| 418 |
+
use_default_system_prompt (`bool`, *optional*, defaults to `False`):
|
| 419 |
+
Whether to use the default system prompt.
|
| 420 |
+
chat_template (`str`, *optional*):
|
| 421 |
+
A Jinja template for formatting conversations.
|
| 422 |
+
|
| 423 |
+
Example:
|
| 424 |
+
```python
|
| 425 |
+
>>> from tokenization_iquestcoder import IQuestCoderTokenizerFast
|
| 426 |
+
|
| 427 |
+
>>> tokenizer = IQuestCoderTokenizerFast.from_pretrained("path/to/model")
|
| 428 |
+
>>> tokenizer.encode("Hello, world!")
|
| 429 |
+
[1, 15043, 29892, 3186, 29991]
|
| 430 |
+
```
|
| 431 |
+
"""
|
| 432 |
+
|
| 433 |
+
vocab_files_names = VOCAB_FILES_NAMES
|
| 434 |
+
pretrained_vocab_files_map = PRETRAINED_VOCAB_FILES_MAP
|
| 435 |
+
max_model_input_sizes = PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
|
| 436 |
+
model_input_names = ["input_ids", "attention_mask"]
|
| 437 |
+
slow_tokenizer_class = IQuestCoderTokenizer
|
| 438 |
+
|
| 439 |
+
def __init__(
|
| 440 |
+
self,
|
| 441 |
+
vocab_file=None,
|
| 442 |
+
tokenizer_file=None,
|
| 443 |
+
unk_token="<unk>",
|
| 444 |
+
bos_token="<s>",
|
| 445 |
+
eos_token="</s>",
|
| 446 |
+
pad_token=None,
|
| 447 |
+
add_bos_token=True,
|
| 448 |
+
add_eos_token=False,
|
| 449 |
+
add_prefix_space=False,
|
| 450 |
+
use_default_system_prompt=False,
|
| 451 |
+
chat_template=None,
|
| 452 |
+
**kwargs,
|
| 453 |
+
):
|
| 454 |
+
self.add_bos_token = add_bos_token
|
| 455 |
+
self.add_eos_token = add_eos_token
|
| 456 |
+
self.add_prefix_space = add_prefix_space
|
| 457 |
+
self.use_default_system_prompt = use_default_system_prompt
|
| 458 |
+
|
| 459 |
+
if chat_template is None:
|
| 460 |
+
chat_template = DEFAULT_CHAT_TEMPLATE
|
| 461 |
+
|
| 462 |
+
super().__init__(
|
| 463 |
+
vocab_file=vocab_file,
|
| 464 |
+
tokenizer_file=tokenizer_file,
|
| 465 |
+
unk_token=unk_token,
|
| 466 |
+
bos_token=bos_token,
|
| 467 |
+
eos_token=eos_token,
|
| 468 |
+
pad_token=pad_token,
|
| 469 |
+
add_bos_token=add_bos_token,
|
| 470 |
+
add_eos_token=add_eos_token,
|
| 471 |
+
add_prefix_space=add_prefix_space,
|
| 472 |
+
use_default_system_prompt=use_default_system_prompt,
|
| 473 |
+
chat_template=chat_template,
|
| 474 |
+
**kwargs,
|
| 475 |
+
)
|
| 476 |
+
|
| 477 |
+
@property
|
| 478 |
+
def can_save_slow_tokenizer(self) -> bool:
|
| 479 |
+
return os.path.isfile(self.vocab_file) if self.vocab_file else False
|
| 480 |
+
|
| 481 |
+
@property
|
| 482 |
+
def default_chat_template(self) -> str:
|
| 483 |
+
"""Returns the default chat template."""
|
| 484 |
+
return DEFAULT_CHAT_TEMPLATE
|
| 485 |
+
|
| 486 |
+
def build_inputs_with_special_tokens(
|
| 487 |
+
self,
|
| 488 |
+
token_ids_0: List[int],
|
| 489 |
+
token_ids_1: Optional[List[int]] = None
|
| 490 |
+
) -> List[int]:
|
| 491 |
+
"""Build model inputs with special tokens."""
|
| 492 |
+
bos_token_id = [self.bos_token_id] if self.add_bos_token else []
|
| 493 |
+
eos_token_id = [self.eos_token_id] if self.add_eos_token else []
|
| 494 |
+
|
| 495 |
+
output = bos_token_id + token_ids_0 + eos_token_id
|
| 496 |
+
|
| 497 |
+
if token_ids_1 is not None:
|
| 498 |
+
output = output + bos_token_id + token_ids_1 + eos_token_id
|
| 499 |
+
|
| 500 |
+
return output
|
| 501 |
+
|
| 502 |
+
def get_special_tokens_mask(
|
| 503 |
+
self,
|
| 504 |
+
token_ids_0: List[int],
|
| 505 |
+
token_ids_1: Optional[List[int]] = None,
|
| 506 |
+
already_has_special_tokens: bool = False
|
| 507 |
+
) -> List[int]:
|
| 508 |
+
"""Retrieve special tokens mask."""
|
| 509 |
+
if already_has_special_tokens:
|
| 510 |
+
return super().get_special_tokens_mask(
|
| 511 |
+
token_ids_0=token_ids_0, token_ids_1=token_ids_1, already_has_special_tokens=True
|
| 512 |
+
)
|
| 513 |
+
|
| 514 |
+
bos_token_id = [1] if self.add_bos_token else []
|
| 515 |
+
eos_token_id = [1] if self.add_eos_token else []
|
| 516 |
+
|
| 517 |
+
if token_ids_1 is None:
|
| 518 |
+
return bos_token_id + ([0] * len(token_ids_0)) + eos_token_id
|
| 519 |
+
return (
|
| 520 |
+
bos_token_id
|
| 521 |
+
+ ([0] * len(token_ids_0))
|
| 522 |
+
+ eos_token_id
|
| 523 |
+
+ bos_token_id
|
| 524 |
+
+ ([0] * len(token_ids_1))
|
| 525 |
+
+ eos_token_id
|
| 526 |
+
)
|
| 527 |
+
|
| 528 |
+
def create_token_type_ids_from_sequences(
|
| 529 |
+
self,
|
| 530 |
+
token_ids_0: List[int],
|
| 531 |
+
token_ids_1: Optional[List[int]] = None
|
| 532 |
+
) -> List[int]:
|
| 533 |
+
"""Create token type IDs from sequences."""
|
| 534 |
+
bos_token_id = [self.bos_token_id] if self.add_bos_token else []
|
| 535 |
+
eos_token_id = [self.eos_token_id] if self.add_eos_token else []
|
| 536 |
+
|
| 537 |
+
output = [0] * len(bos_token_id + token_ids_0 + eos_token_id)
|
| 538 |
+
|
| 539 |
+
if token_ids_1 is not None:
|
| 540 |
+
output += [1] * len(bos_token_id + token_ids_1 + eos_token_id)
|
| 541 |
+
|
| 542 |
+
return output
|
| 543 |
+
|
| 544 |
+
except ImportError:
|
| 545 |
+
# tokenizers library not available, Fast tokenizer not supported
|
| 546 |
+
IQuestCoderTokenizerFast = None
|
| 547 |
+
logger.info(
|
| 548 |
+
"The `tokenizers` library is not installed. "
|
| 549 |
+
"IQuestCoderTokenizerFast will not be available. "
|
| 550 |
+
"Install it with `pip install tokenizers`."
|
| 551 |
+
)
|
| 552 |
+
|
tokenizer.model
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7d3be68e090a927f31e0e378d7599b15c206dd47e4a73933775a746cc9c1cd91
|
| 3 |
+
size 1345108
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,242 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_bos_token": false,
|
| 3 |
+
"add_eos_token": false,
|
| 4 |
+
"added_tokens_decoder": {
|
| 5 |
+
"0": {
|
| 6 |
+
"content": "<unk>",
|
| 7 |
+
"lstrip": false,
|
| 8 |
+
"normalized": true,
|
| 9 |
+
"rstrip": false,
|
| 10 |
+
"single_word": true,
|
| 11 |
+
"special": true
|
| 12 |
+
},
|
| 13 |
+
"1": {
|
| 14 |
+
"content": "<s>",
|
| 15 |
+
"lstrip": false,
|
| 16 |
+
"normalized": true,
|
| 17 |
+
"rstrip": false,
|
| 18 |
+
"single_word": false,
|
| 19 |
+
"special": true
|
| 20 |
+
},
|
| 21 |
+
"2": {
|
| 22 |
+
"content": "</s>",
|
| 23 |
+
"lstrip": false,
|
| 24 |
+
"normalized": true,
|
| 25 |
+
"rstrip": false,
|
| 26 |
+
"single_word": true,
|
| 27 |
+
"special": true
|
| 28 |
+
},
|
| 29 |
+
"75858": {
|
| 30 |
+
"content": "<CLS>",
|
| 31 |
+
"lstrip": false,
|
| 32 |
+
"normalized": false,
|
| 33 |
+
"rstrip": false,
|
| 34 |
+
"single_word": false,
|
| 35 |
+
"special": true
|
| 36 |
+
},
|
| 37 |
+
"75859": {
|
| 38 |
+
"content": "<SEP>",
|
| 39 |
+
"lstrip": false,
|
| 40 |
+
"normalized": false,
|
| 41 |
+
"rstrip": false,
|
| 42 |
+
"single_word": false,
|
| 43 |
+
"special": true
|
| 44 |
+
},
|
| 45 |
+
"75860": {
|
| 46 |
+
"content": "<EOD>",
|
| 47 |
+
"lstrip": false,
|
| 48 |
+
"normalized": false,
|
| 49 |
+
"rstrip": false,
|
| 50 |
+
"single_word": false,
|
| 51 |
+
"special": true
|
| 52 |
+
},
|
| 53 |
+
"75861": {
|
| 54 |
+
"content": "<MASK>",
|
| 55 |
+
"lstrip": false,
|
| 56 |
+
"normalized": false,
|
| 57 |
+
"rstrip": false,
|
| 58 |
+
"single_word": false,
|
| 59 |
+
"special": true
|
| 60 |
+
},
|
| 61 |
+
"75862": {
|
| 62 |
+
"content": "<PAD>",
|
| 63 |
+
"lstrip": false,
|
| 64 |
+
"normalized": false,
|
| 65 |
+
"rstrip": false,
|
| 66 |
+
"single_word": false,
|
| 67 |
+
"special": true
|
| 68 |
+
},
|
| 69 |
+
"75863": {
|
| 70 |
+
"content": "<|im_start|>",
|
| 71 |
+
"lstrip": false,
|
| 72 |
+
"normalized": false,
|
| 73 |
+
"rstrip": false,
|
| 74 |
+
"single_word": false,
|
| 75 |
+
"special": true
|
| 76 |
+
},
|
| 77 |
+
"75864": {
|
| 78 |
+
"content": "<|im_end|>",
|
| 79 |
+
"lstrip": false,
|
| 80 |
+
"normalized": false,
|
| 81 |
+
"rstrip": false,
|
| 82 |
+
"single_word": false,
|
| 83 |
+
"special": true
|
| 84 |
+
},
|
| 85 |
+
"75865": {
|
| 86 |
+
"content": "<|fim_prefix|>",
|
| 87 |
+
"lstrip": false,
|
| 88 |
+
"normalized": false,
|
| 89 |
+
"rstrip": false,
|
| 90 |
+
"single_word": false,
|
| 91 |
+
"special": true
|
| 92 |
+
},
|
| 93 |
+
"75866": {
|
| 94 |
+
"content": "<|fim_middle|>",
|
| 95 |
+
"lstrip": false,
|
| 96 |
+
"normalized": false,
|
| 97 |
+
"rstrip": false,
|
| 98 |
+
"single_word": false,
|
| 99 |
+
"special": true
|
| 100 |
+
},
|
| 101 |
+
"75867": {
|
| 102 |
+
"content": "<|fim_suffix|>",
|
| 103 |
+
"lstrip": false,
|
| 104 |
+
"normalized": false,
|
| 105 |
+
"rstrip": false,
|
| 106 |
+
"single_word": false,
|
| 107 |
+
"special": true
|
| 108 |
+
},
|
| 109 |
+
"75868": {
|
| 110 |
+
"content": "<|fim_pad|>",
|
| 111 |
+
"lstrip": false,
|
| 112 |
+
"normalized": false,
|
| 113 |
+
"rstrip": false,
|
| 114 |
+
"single_word": false,
|
| 115 |
+
"special": true
|
| 116 |
+
},
|
| 117 |
+
"75869": {
|
| 118 |
+
"content": "<|endoftext|>",
|
| 119 |
+
"lstrip": false,
|
| 120 |
+
"normalized": false,
|
| 121 |
+
"rstrip": false,
|
| 122 |
+
"single_word": false,
|
| 123 |
+
"special": true
|
| 124 |
+
},
|
| 125 |
+
"75870": {
|
| 126 |
+
"content": "<|repo_name|>",
|
| 127 |
+
"lstrip": false,
|
| 128 |
+
"normalized": false,
|
| 129 |
+
"rstrip": false,
|
| 130 |
+
"single_word": false,
|
| 131 |
+
"special": true
|
| 132 |
+
},
|
| 133 |
+
"75871": {
|
| 134 |
+
"content": "<|file_sep|>",
|
| 135 |
+
"lstrip": false,
|
| 136 |
+
"normalized": false,
|
| 137 |
+
"rstrip": false,
|
| 138 |
+
"single_word": false,
|
| 139 |
+
"special": true
|
| 140 |
+
},
|
| 141 |
+
"75872": {
|
| 142 |
+
"content": "<think>",
|
| 143 |
+
"lstrip": false,
|
| 144 |
+
"normalized": false,
|
| 145 |
+
"rstrip": false,
|
| 146 |
+
"single_word": false,
|
| 147 |
+
"special": false
|
| 148 |
+
},
|
| 149 |
+
"75873": {
|
| 150 |
+
"content": "</think>",
|
| 151 |
+
"lstrip": false,
|
| 152 |
+
"normalized": false,
|
| 153 |
+
"rstrip": false,
|
| 154 |
+
"single_word": false,
|
| 155 |
+
"special": false
|
| 156 |
+
},
|
| 157 |
+
"75874": {
|
| 158 |
+
"content": "<tools>",
|
| 159 |
+
"lstrip": false,
|
| 160 |
+
"normalized": false,
|
| 161 |
+
"rstrip": false,
|
| 162 |
+
"single_word": false,
|
| 163 |
+
"special": false
|
| 164 |
+
},
|
| 165 |
+
"75875": {
|
| 166 |
+
"content": "</tools>",
|
| 167 |
+
"lstrip": false,
|
| 168 |
+
"normalized": false,
|
| 169 |
+
"rstrip": false,
|
| 170 |
+
"single_word": false,
|
| 171 |
+
"special": false
|
| 172 |
+
},
|
| 173 |
+
"75876": {
|
| 174 |
+
"content": "<tool_call>",
|
| 175 |
+
"lstrip": false,
|
| 176 |
+
"normalized": false,
|
| 177 |
+
"rstrip": false,
|
| 178 |
+
"single_word": false,
|
| 179 |
+
"special": false
|
| 180 |
+
},
|
| 181 |
+
"75877": {
|
| 182 |
+
"content": "</tool_call>",
|
| 183 |
+
"lstrip": false,
|
| 184 |
+
"normalized": false,
|
| 185 |
+
"rstrip": false,
|
| 186 |
+
"single_word": false,
|
| 187 |
+
"special": false
|
| 188 |
+
},
|
| 189 |
+
"75878": {
|
| 190 |
+
"content": "<tool_response>",
|
| 191 |
+
"lstrip": false,
|
| 192 |
+
"normalized": false,
|
| 193 |
+
"rstrip": false,
|
| 194 |
+
"single_word": false,
|
| 195 |
+
"special": false
|
| 196 |
+
},
|
| 197 |
+
"75879": {
|
| 198 |
+
"content": "</tool_response>",
|
| 199 |
+
"lstrip": false,
|
| 200 |
+
"normalized": false,
|
| 201 |
+
"rstrip": false,
|
| 202 |
+
"single_word": false,
|
| 203 |
+
"special": false
|
| 204 |
+
}
|
| 205 |
+
},
|
| 206 |
+
"additional_special_tokens": [
|
| 207 |
+
"<|CLS|>",
|
| 208 |
+
"<|SEP|>",
|
| 209 |
+
"<|EOD|>",
|
| 210 |
+
"<|MASK|>",
|
| 211 |
+
"<|PAD|>",
|
| 212 |
+
"<|fim_prefix|>",
|
| 213 |
+
"<|fim_middle|>",
|
| 214 |
+
"<|fim_suffix|>",
|
| 215 |
+
"<|im_start|>",
|
| 216 |
+
"<|im_end|>",
|
| 217 |
+
"<|fim_pad|>",
|
| 218 |
+
"<|endoftext|>",
|
| 219 |
+
"<|repo_name|>",
|
| 220 |
+
"<|file_sep|>",
|
| 221 |
+
"<think>",
|
| 222 |
+
"</think>"
|
| 223 |
+
],
|
| 224 |
+
"auto_map": {
|
| 225 |
+
"AutoTokenizer": [
|
| 226 |
+
"tokenization_iquestcoder.IQuestCoderTokenizer",
|
| 227 |
+
null
|
| 228 |
+
]
|
| 229 |
+
},
|
| 230 |
+
"bos_token": "<s>",
|
| 231 |
+
"chat_template": "{%- if tools %}\n {{- '<|im_start|>system\\n' }}\n {%- if messages[0].role == 'system' %}\n {{- messages[0].content + '\\n\\n' }}\n {%- else %}\n {{- 'You are LoopCoder, a helpful assistant developed by IQuest.' }}\n {%- endif %}\n {{- \"# Tools\\n\\nYou may call one or more functions to assist with the user query.\\n\\nYou are provided with function signatures within <tools></tools> XML tags:\\n<tools>\" }}\n {%- for tool in tools %}\n {{- \"\\n\" }}\n {{- tool | tojson }}\n {%- endfor %}\n {{- \"\\n</tools>\\n\\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\\n<tool_call>\\n{\\\"name\\\": <function-name>, \\\"arguments\\\": <args-json-object>}\\n</tool_call><|im_end|>\\n\" }}\n{%- else %}\n {%- if messages[0].role == 'system' %}\n {{- '<|im_start|>system\\n' + messages[0].content + '<|im_end|>\\n' }}\n {%- else %}\n {{- '<|im_start|>system\\nYou are LoopCoder, a helpful assistant developed by IQuest.<|im_end|>\\n' }}\n {%- endif %}\n{%- endif %}\n{%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}\n{%- for message in messages[::-1] %}\n {%- set index = (messages|length - 1) - loop.index0 %}\n {%- if ns.multi_step_tool and message.role == \"user\" and not(message.content.startswith('<tool_response>') and message.content.endswith('</tool_response>')) %}\n {%- set ns.multi_step_tool = false %}\n {%- set ns.last_query_index = index %}\n {%- endif %}\n{%- endfor %}\n{%- for message in messages %}\n {%- if (message.role == \"user\") or (message.role == \"system\" and not loop.first) %}\n {{- '<|im_start|>' + message.role + '\\n' + message.content + '<|im_end|>' + '\\n' }}\n {%- elif message.role == \"assistant\" %}\n {%- set content = message.content %}\n {{- '<|im_start|>' + message.role + '\\n' + content }}\n {%- if message.tool_calls %}\n {%- for tool_call in message.tool_calls %}\n {%- if (loop.first and content) or (not loop.first) %}\n {{- '\\n' }}\n {%- endif %}\n {%- if tool_call.function %}\n {%- set tool_call = tool_call.function %}\n {%- endif %}\n {{- '<tool_call>\\n{\"name\": \"' }}\n {{- tool_call.name }}\n {{- '\", \"arguments\": ' }}\n {%- if tool_call.arguments is string %}\n {{- tool_call.arguments }}\n {%- else %}\n {{- tool_call.arguments | tojson }}\n {%- endif %}\n {{- '}\\n</tool_call>' }}\n {%- endfor %}\n {%- endif %}\n {{- '<|im_end|>\\n' }}\n {%- elif message.role == \"tool\" %}\n {%- if loop.first or (messages[loop.index0 - 1].role != \"tool\") %}\n {{- '<|im_start|>user' }}\n {%- endif %}\n {{- '\\n<tool_response>\\n' }}\n {{- message.content }}\n {{- '\\n</tool_response>' }}\n {%- if loop.last or (messages[loop.index0 + 1].role != \"tool\") %}\n {{- '<|im_end|>\\n' }}\n {%- endif %}\n {%- endif %}\n{%- endfor %}\n{%- if add_generation_prompt %}\n {{- '<|im_start|>assistant\\n' }}\n{%- endif %}",
|
| 232 |
+
"clean_up_tokenization_spaces": false,
|
| 233 |
+
"eos_token": "<|im_end|>",
|
| 234 |
+
"model_max_length": 131072,
|
| 235 |
+
"pad_token": "<|endoftext|>",
|
| 236 |
+
"padding_side": "right",
|
| 237 |
+
"sp_model_kwargs": {},
|
| 238 |
+
"split_special_tokens": false,
|
| 239 |
+
"tokenizer_class": "IQuestCoderTokenizer",
|
| 240 |
+
"unk_token": "<unk>",
|
| 241 |
+
"use_fast": false
|
| 242 |
+
}
|