Text Generation
Transformers
Safetensors
English
talkie
bfloat16
custom_code
yarn
long-context
pre-1931
alternate-checkpoint
Instructions to use xlr8harder/talkie-1930-13b-yarn-32k-from4k-step1000-tf with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use xlr8harder/talkie-1930-13b-yarn-32k-from4k-step1000-tf with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="xlr8harder/talkie-1930-13b-yarn-32k-from4k-step1000-tf", trust_remote_code=True)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("xlr8harder/talkie-1930-13b-yarn-32k-from4k-step1000-tf", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use xlr8harder/talkie-1930-13b-yarn-32k-from4k-step1000-tf with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "xlr8harder/talkie-1930-13b-yarn-32k-from4k-step1000-tf" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "xlr8harder/talkie-1930-13b-yarn-32k-from4k-step1000-tf", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/xlr8harder/talkie-1930-13b-yarn-32k-from4k-step1000-tf
- SGLang
How to use xlr8harder/talkie-1930-13b-yarn-32k-from4k-step1000-tf with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "xlr8harder/talkie-1930-13b-yarn-32k-from4k-step1000-tf" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "xlr8harder/talkie-1930-13b-yarn-32k-from4k-step1000-tf", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "xlr8harder/talkie-1930-13b-yarn-32k-from4k-step1000-tf" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "xlr8harder/talkie-1930-13b-yarn-32k-from4k-step1000-tf", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use xlr8harder/talkie-1930-13b-yarn-32k-from4k-step1000-tf with Docker Model Runner:
docker model run hf.co/xlr8harder/talkie-1930-13b-yarn-32k-from4k-step1000-tf
Upload Talkie YaRN 32k from-4k step1000 checkpoint
Browse files- README.md +81 -0
- checkpoint_complete.json +7 -0
- config.json +44 -0
- configuration_talkie.py +100 -0
- generation_config.json +7 -0
- model-00001-of-00006.safetensors +3 -0
- model-00002-of-00006.safetensors +3 -0
- model-00003-of-00006.safetensors +3 -0
- model-00004-of-00006.safetensors +3 -0
- model-00005-of-00006.safetensors +3 -0
- model-00006-of-00006.safetensors +3 -0
- model.safetensors.index.json +450 -0
- modeling_talkie.py +638 -0
- special_tokens_map.json +3 -0
- tokenization_talkie.py +168 -0
- tokenizer_config.json +23 -0
- vocab.txt +0 -0
README.md
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language:
|
| 3 |
+
- en
|
| 4 |
+
license: apache-2.0
|
| 5 |
+
library_name: transformers
|
| 6 |
+
pipeline_tag: text-generation
|
| 7 |
+
base_model: xlr8harder/talkie-1930-13b-base-tf
|
| 8 |
+
datasets:
|
| 9 |
+
- common-pile/project_gutenberg_filtered
|
| 10 |
+
tags:
|
| 11 |
+
- transformers
|
| 12 |
+
- safetensors
|
| 13 |
+
- bfloat16
|
| 14 |
+
- custom_code
|
| 15 |
+
- text-generation
|
| 16 |
+
- talkie
|
| 17 |
+
- yarn
|
| 18 |
+
- long-context
|
| 19 |
+
- pre-1931
|
| 20 |
+
- alternate-checkpoint
|
| 21 |
+
---
|
| 22 |
+
|
| 23 |
+
# Talkie 1930 13B YaRN 32k From 4k Step1000
|
| 24 |
+
|
| 25 |
+
This is an alternate 32k-context YaRN extension of
|
| 26 |
+
[`xlr8harder/talkie-1930-13b-base-tf`](https://huggingface.co/xlr8harder/talkie-1930-13b-base-tf).
|
| 27 |
+
It uses an 8x YaRN extension from a 4,096-token starting context and continued
|
| 28 |
+
pretraining to step1000 on the same Project Gutenberg pre-1931 data recipe used
|
| 29 |
+
for the main Talkie YaRN 32k checkpoint.
|
| 30 |
+
|
| 31 |
+
The recommended checkpoint from this experiment series is
|
| 32 |
+
[`xlr8harder/talkie-1930-13b-yarn-32k-tf`](https://huggingface.co/xlr8harder/talkie-1930-13b-yarn-32k-tf).
|
| 33 |
+
That model used a 16x extension from the 2,048-token reference config and the
|
| 34 |
+
step500 checkpoint. It performed better overall at 16k and 32k, and avoided the
|
| 35 |
+
severe variable-tracking collapse seen in this 4k-start run.
|
| 36 |
+
|
| 37 |
+
## Usage
|
| 38 |
+
|
| 39 |
+
This model uses custom Talkie modeling/tokenization code, so load it with
|
| 40 |
+
`trust_remote_code=True`.
|
| 41 |
+
|
| 42 |
+
```python
|
| 43 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 44 |
+
|
| 45 |
+
model_id = "xlr8harder/talkie-1930-13b-yarn-32k-from4k-step1000-tf"
|
| 46 |
+
|
| 47 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
|
| 48 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 49 |
+
model_id,
|
| 50 |
+
torch_dtype="auto",
|
| 51 |
+
device_map="auto",
|
| 52 |
+
trust_remote_code=True,
|
| 53 |
+
)
|
| 54 |
+
```
|
| 55 |
+
|
| 56 |
+
For vLLM, set `--max-model-len 32768` and enable remote code.
|
| 57 |
+
|
| 58 |
+
## RULER Comparison
|
| 59 |
+
|
| 60 |
+
Scores are aggregate RULER accuracy percentages from our harness, using 100
|
| 61 |
+
examples per task and greedy decoding.
|
| 62 |
+
|
| 63 |
+
| Model / setup | 2k | 4k | 8k | 16k | 32k |
|
| 64 |
+
| --- | ---: | ---: | ---: | ---: | ---: |
|
| 65 |
+
| Talkie base, extrapolation only | 85.86 | 77.71 | 23.40 | n/a | n/a |
|
| 66 |
+
| Talkie YaRN 32k, 2k start, step500 | 80.78 | 79.50 | 73.15 | 70.05 | 61.83 |
|
| 67 |
+
| Talkie YaRN 32k, 4k start, step500 | 83.80 | 80.71 | 75.64 | 68.80 | 54.76 |
|
| 68 |
+
| Talkie YaRN 32k, 4k start, step1000 | 84.18 | 80.98 | 76.17 | 68.45 | 55.01 |
|
| 69 |
+
|
| 70 |
+
This checkpoint is included for comparison because it tests the later-discovered
|
| 71 |
+
4k starting context. It is better at short-context RULER tiers than the 2k-start
|
| 72 |
+
checkpoint, but worse at the longest tiers. At 32k it scored 55.01 overall, with
|
| 73 |
+
`vt` at 0.40, compared with 61.83 overall and `vt` at 26.20 for the recommended
|
| 74 |
+
2k-start step500 checkpoint.
|
| 75 |
+
|
| 76 |
+
## Training Recipe
|
| 77 |
+
|
| 78 |
+
The training data was a Project Gutenberg split filtered to English public-domain
|
| 79 |
+
books with publication years 1500-1930, totaling 265,080,702 Talkie tokens.
|
| 80 |
+
Training used 32,768-token sequences, 262,144 tokens per step, 1000 max steps,
|
| 81 |
+
cosine LR decay from `1e-5` to `1e-6`, 50 warmup steps, and weight decay `0.01`.
|
checkpoint_complete.json
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"checkpoint": "model-step-001000",
|
| 3 |
+
"checkpoint_type": "model",
|
| 4 |
+
"dtype": "bfloat16",
|
| 5 |
+
"format": "transformers-safetensors",
|
| 6 |
+
"time_unix": 1780194492.553197
|
| 7 |
+
}
|
config.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"TalkieForCausalLM"
|
| 4 |
+
],
|
| 5 |
+
"auto_map": {
|
| 6 |
+
"AutoConfig": "configuration_talkie.TalkieConfig",
|
| 7 |
+
"AutoModel": "modeling_talkie.TalkieModel",
|
| 8 |
+
"AutoModelForCausalLM": "modeling_talkie.TalkieForCausalLM"
|
| 9 |
+
},
|
| 10 |
+
"dtype": "bfloat16",
|
| 11 |
+
"eos_token_id": 65535,
|
| 12 |
+
"head_dim": 128,
|
| 13 |
+
"hidden_size": 5120,
|
| 14 |
+
"logit_scale": 1.0,
|
| 15 |
+
"max_position_embeddings": 32768,
|
| 16 |
+
"model_type": "talkie",
|
| 17 |
+
"n_embd": 5120,
|
| 18 |
+
"n_head": 40,
|
| 19 |
+
"n_layer": 40,
|
| 20 |
+
"num_attention_heads": 40,
|
| 21 |
+
"num_hidden_layers": 40,
|
| 22 |
+
"pad_token_id": 65535,
|
| 23 |
+
"rope_base": 1000000,
|
| 24 |
+
"rope_parameters": {
|
| 25 |
+
"beta_fast": 32.0,
|
| 26 |
+
"beta_slow": 1.0,
|
| 27 |
+
"factor": 8.0,
|
| 28 |
+
"original_max_position_embeddings": 4096,
|
| 29 |
+
"rope_type": "yarn"
|
| 30 |
+
},
|
| 31 |
+
"rope_scaling": {
|
| 32 |
+
"beta_fast": 32.0,
|
| 33 |
+
"beta_slow": 1.0,
|
| 34 |
+
"factor": 8.0,
|
| 35 |
+
"original_max_position_embeddings": 4096,
|
| 36 |
+
"rope_type": "yarn"
|
| 37 |
+
},
|
| 38 |
+
"style": "base",
|
| 39 |
+
"tie_word_embeddings": false,
|
| 40 |
+
"torch_dtype": "bfloat16",
|
| 41 |
+
"transformers_version": "4.57.6",
|
| 42 |
+
"use_cache": true,
|
| 43 |
+
"vocab_size": 65536
|
| 44 |
+
}
|
configuration_talkie.py
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
from collections.abc import Mapping
|
| 4 |
+
|
| 5 |
+
from transformers import PretrainedConfig
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
class TalkieConfig(PretrainedConfig):
|
| 9 |
+
model_type = "talkie"
|
| 10 |
+
|
| 11 |
+
def __init__(
|
| 12 |
+
self,
|
| 13 |
+
vocab_size: int = 65536,
|
| 14 |
+
n_layer: int = 40,
|
| 15 |
+
n_head: int = 40,
|
| 16 |
+
n_embd: int = 5120,
|
| 17 |
+
head_dim: int = 128,
|
| 18 |
+
max_position_embeddings: int = 2048,
|
| 19 |
+
rope_base: int = 1_000_000,
|
| 20 |
+
rope_scaling: dict | None = None,
|
| 21 |
+
rope_parameters: dict | None = None,
|
| 22 |
+
logit_scale: float = 1.0,
|
| 23 |
+
use_cache: bool = True,
|
| 24 |
+
tie_word_embeddings: bool = False,
|
| 25 |
+
bos_token_id: int | None = None,
|
| 26 |
+
eos_token_id: int | list[int] = 65535,
|
| 27 |
+
pad_token_id: int | None = None,
|
| 28 |
+
**kwargs,
|
| 29 |
+
):
|
| 30 |
+
if rope_scaling is None:
|
| 31 |
+
rope_scaling = rope_parameters
|
| 32 |
+
self.max_position_embeddings = max_position_embeddings
|
| 33 |
+
self.rope_scaling = self._normalize_rope_scaling(rope_scaling)
|
| 34 |
+
self.rope_parameters = self.rope_scaling
|
| 35 |
+
super().__init__(
|
| 36 |
+
bos_token_id=bos_token_id,
|
| 37 |
+
eos_token_id=eos_token_id,
|
| 38 |
+
pad_token_id=pad_token_id,
|
| 39 |
+
tie_word_embeddings=tie_word_embeddings,
|
| 40 |
+
**kwargs,
|
| 41 |
+
)
|
| 42 |
+
self.vocab_size = vocab_size
|
| 43 |
+
self.n_layer = n_layer
|
| 44 |
+
self.n_head = n_head
|
| 45 |
+
self.n_embd = n_embd
|
| 46 |
+
self.head_dim = head_dim
|
| 47 |
+
self.max_position_embeddings = max_position_embeddings
|
| 48 |
+
self.rope_base = rope_base
|
| 49 |
+
self.rope_scaling = self._normalize_rope_scaling(rope_scaling)
|
| 50 |
+
self.rope_parameters = self.rope_scaling
|
| 51 |
+
self.logit_scale = logit_scale
|
| 52 |
+
self.use_cache = use_cache
|
| 53 |
+
|
| 54 |
+
# Common Transformers aliases used by generation/cache helpers.
|
| 55 |
+
self.hidden_size = n_embd
|
| 56 |
+
self.num_hidden_layers = n_layer
|
| 57 |
+
self.num_attention_heads = n_head
|
| 58 |
+
|
| 59 |
+
@staticmethod
|
| 60 |
+
def _normalize_rope_scaling(rope_scaling: dict | None) -> dict | None:
|
| 61 |
+
if rope_scaling is None:
|
| 62 |
+
return None
|
| 63 |
+
if not isinstance(rope_scaling, Mapping):
|
| 64 |
+
raise TypeError("rope_scaling must be a dictionary")
|
| 65 |
+
|
| 66 |
+
scaling = dict(rope_scaling)
|
| 67 |
+
rope_type = scaling.get("rope_type", scaling.get("type"))
|
| 68 |
+
if rope_type is None:
|
| 69 |
+
raise ValueError("rope_scaling must include 'rope_type' or 'type'")
|
| 70 |
+
|
| 71 |
+
rope_type = str(rope_type).lower()
|
| 72 |
+
if rope_type == "ntk":
|
| 73 |
+
rope_type = "dynamic"
|
| 74 |
+
supported = {"default", "linear", "dynamic", "yarn"}
|
| 75 |
+
if rope_type not in supported:
|
| 76 |
+
raise ValueError(
|
| 77 |
+
f"unsupported rope_scaling type {rope_type!r}; expected one of {sorted(supported)}"
|
| 78 |
+
)
|
| 79 |
+
|
| 80 |
+
if rope_type == "default":
|
| 81 |
+
return None
|
| 82 |
+
|
| 83 |
+
factor = float(scaling.get("factor", 1.0))
|
| 84 |
+
if factor < 1.0:
|
| 85 |
+
raise ValueError("rope_scaling factor must be >= 1.0")
|
| 86 |
+
|
| 87 |
+
scaling["rope_type"] = rope_type
|
| 88 |
+
scaling.pop("type", None)
|
| 89 |
+
scaling["factor"] = factor
|
| 90 |
+
if "original_max_position_embeddings" in scaling:
|
| 91 |
+
scaling["original_max_position_embeddings"] = int(
|
| 92 |
+
scaling["original_max_position_embeddings"]
|
| 93 |
+
)
|
| 94 |
+
if "beta_fast" in scaling:
|
| 95 |
+
scaling["beta_fast"] = float(scaling["beta_fast"])
|
| 96 |
+
if "beta_slow" in scaling:
|
| 97 |
+
scaling["beta_slow"] = float(scaling["beta_slow"])
|
| 98 |
+
if "attention_factor" in scaling and scaling["attention_factor"] is not None:
|
| 99 |
+
scaling["attention_factor"] = float(scaling["attention_factor"])
|
| 100 |
+
return scaling
|
generation_config.json
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_from_model_config": true,
|
| 3 |
+
"eos_token_id": 65535,
|
| 4 |
+
"pad_token_id": 65535,
|
| 5 |
+
"transformers_version": "4.57.6",
|
| 6 |
+
"use_cache": false
|
| 7 |
+
}
|
model-00001-of-00006.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b772a32bce22a9c5295f75ce0e60cbbf6102957cd08fcb390c15006fd7698723
|
| 3 |
+
size 4944044254
|
model-00002-of-00006.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b60ea267b4962b3eb87f3e9fb5b1777c1502f1a9656f1cd214f33e931db02a8d
|
| 3 |
+
size 4903413312
|
model-00003-of-00006.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6c28ccb81cb4fbf1953ad70056645634f27573fcb4ae9ddc235fef8288a9a411
|
| 3 |
+
size 4903413344
|
model-00004-of-00006.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d2ad9c2f9e407da5730deb4cdf6a05ee67a3f13a30ce97c6e6cc4564d568641c
|
| 3 |
+
size 4991231302
|
model-00005-of-00006.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:fadd00e1a04c3ce8ec39150c404fb56f9334b5f984792f218ce3a37797a8c5ca
|
| 3 |
+
size 4991231584
|
model-00006-of-00006.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:df234fefc6b7589ee4eee80318c868cd53d7d547b661a4f3e03618a27d613b7e
|
| 3 |
+
size 1827146036
|
model.safetensors.index.json
ADDED
|
@@ -0,0 +1,450 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"metadata": {
|
| 3 |
+
"total_parameters": 1660027200,
|
| 4 |
+
"total_size": 26560433520
|
| 5 |
+
},
|
| 6 |
+
"weight_map": {
|
| 7 |
+
"blocks.0.attn.attn_key.weight": "model-00001-of-00006.safetensors",
|
| 8 |
+
"blocks.0.attn.attn_query.weight": "model-00001-of-00006.safetensors",
|
| 9 |
+
"blocks.0.attn.attn_resid.weight": "model-00001-of-00006.safetensors",
|
| 10 |
+
"blocks.0.attn.attn_value.weight": "model-00001-of-00006.safetensors",
|
| 11 |
+
"blocks.0.attn.head_gain.head_g": "model-00001-of-00006.safetensors",
|
| 12 |
+
"blocks.0.attn_gain.a_g": "model-00001-of-00006.safetensors",
|
| 13 |
+
"blocks.0.embed_skip.a_g": "model-00001-of-00006.safetensors",
|
| 14 |
+
"blocks.0.mlp.mlp_gate.weight": "model-00001-of-00006.safetensors",
|
| 15 |
+
"blocks.0.mlp.mlp_linear.weight": "model-00001-of-00006.safetensors",
|
| 16 |
+
"blocks.0.mlp.mlp_resid.weight": "model-00001-of-00006.safetensors",
|
| 17 |
+
"blocks.0.mlp_gain.a_g": "model-00001-of-00006.safetensors",
|
| 18 |
+
"blocks.1.attn.attn_key.weight": "model-00001-of-00006.safetensors",
|
| 19 |
+
"blocks.1.attn.attn_query.weight": "model-00001-of-00006.safetensors",
|
| 20 |
+
"blocks.1.attn.attn_resid.weight": "model-00001-of-00006.safetensors",
|
| 21 |
+
"blocks.1.attn.attn_value.weight": "model-00001-of-00006.safetensors",
|
| 22 |
+
"blocks.1.attn.head_gain.head_g": "model-00001-of-00006.safetensors",
|
| 23 |
+
"blocks.1.attn_gain.a_g": "model-00001-of-00006.safetensors",
|
| 24 |
+
"blocks.1.embed_skip.a_g": "model-00001-of-00006.safetensors",
|
| 25 |
+
"blocks.1.mlp.mlp_gate.weight": "model-00001-of-00006.safetensors",
|
| 26 |
+
"blocks.1.mlp.mlp_linear.weight": "model-00001-of-00006.safetensors",
|
| 27 |
+
"blocks.1.mlp.mlp_resid.weight": "model-00001-of-00006.safetensors",
|
| 28 |
+
"blocks.1.mlp_gain.a_g": "model-00001-of-00006.safetensors",
|
| 29 |
+
"blocks.10.attn.attn_key.weight": "model-00002-of-00006.safetensors",
|
| 30 |
+
"blocks.10.attn.attn_query.weight": "model-00002-of-00006.safetensors",
|
| 31 |
+
"blocks.10.attn.attn_resid.weight": "model-00002-of-00006.safetensors",
|
| 32 |
+
"blocks.10.attn.attn_value.weight": "model-00002-of-00006.safetensors",
|
| 33 |
+
"blocks.10.attn.head_gain.head_g": "model-00002-of-00006.safetensors",
|
| 34 |
+
"blocks.10.attn_gain.a_g": "model-00002-of-00006.safetensors",
|
| 35 |
+
"blocks.10.embed_skip.a_g": "model-00002-of-00006.safetensors",
|
| 36 |
+
"blocks.10.mlp.mlp_gate.weight": "model-00002-of-00006.safetensors",
|
| 37 |
+
"blocks.10.mlp.mlp_linear.weight": "model-00002-of-00006.safetensors",
|
| 38 |
+
"blocks.10.mlp.mlp_resid.weight": "model-00002-of-00006.safetensors",
|
| 39 |
+
"blocks.10.mlp_gain.a_g": "model-00002-of-00006.safetensors",
|
| 40 |
+
"blocks.11.attn.attn_key.weight": "model-00002-of-00006.safetensors",
|
| 41 |
+
"blocks.11.attn.attn_query.weight": "model-00002-of-00006.safetensors",
|
| 42 |
+
"blocks.11.attn.attn_resid.weight": "model-00002-of-00006.safetensors",
|
| 43 |
+
"blocks.11.attn.attn_value.weight": "model-00002-of-00006.safetensors",
|
| 44 |
+
"blocks.11.attn.head_gain.head_g": "model-00002-of-00006.safetensors",
|
| 45 |
+
"blocks.11.attn_gain.a_g": "model-00002-of-00006.safetensors",
|
| 46 |
+
"blocks.11.embed_skip.a_g": "model-00002-of-00006.safetensors",
|
| 47 |
+
"blocks.11.mlp.mlp_gate.weight": "model-00002-of-00006.safetensors",
|
| 48 |
+
"blocks.11.mlp.mlp_linear.weight": "model-00002-of-00006.safetensors",
|
| 49 |
+
"blocks.11.mlp.mlp_resid.weight": "model-00002-of-00006.safetensors",
|
| 50 |
+
"blocks.11.mlp_gain.a_g": "model-00002-of-00006.safetensors",
|
| 51 |
+
"blocks.12.attn.attn_key.weight": "model-00002-of-00006.safetensors",
|
| 52 |
+
"blocks.12.attn.attn_query.weight": "model-00002-of-00006.safetensors",
|
| 53 |
+
"blocks.12.attn.attn_resid.weight": "model-00002-of-00006.safetensors",
|
| 54 |
+
"blocks.12.attn.attn_value.weight": "model-00002-of-00006.safetensors",
|
| 55 |
+
"blocks.12.attn.head_gain.head_g": "model-00002-of-00006.safetensors",
|
| 56 |
+
"blocks.12.attn_gain.a_g": "model-00002-of-00006.safetensors",
|
| 57 |
+
"blocks.12.embed_skip.a_g": "model-00002-of-00006.safetensors",
|
| 58 |
+
"blocks.12.mlp.mlp_gate.weight": "model-00002-of-00006.safetensors",
|
| 59 |
+
"blocks.12.mlp.mlp_linear.weight": "model-00002-of-00006.safetensors",
|
| 60 |
+
"blocks.12.mlp.mlp_resid.weight": "model-00002-of-00006.safetensors",
|
| 61 |
+
"blocks.12.mlp_gain.a_g": "model-00002-of-00006.safetensors",
|
| 62 |
+
"blocks.13.attn.attn_key.weight": "model-00002-of-00006.safetensors",
|
| 63 |
+
"blocks.13.attn.attn_query.weight": "model-00002-of-00006.safetensors",
|
| 64 |
+
"blocks.13.attn.attn_resid.weight": "model-00002-of-00006.safetensors",
|
| 65 |
+
"blocks.13.attn.attn_value.weight": "model-00002-of-00006.safetensors",
|
| 66 |
+
"blocks.13.attn.head_gain.head_g": "model-00002-of-00006.safetensors",
|
| 67 |
+
"blocks.13.attn_gain.a_g": "model-00002-of-00006.safetensors",
|
| 68 |
+
"blocks.13.embed_skip.a_g": "model-00002-of-00006.safetensors",
|
| 69 |
+
"blocks.13.mlp.mlp_gate.weight": "model-00002-of-00006.safetensors",
|
| 70 |
+
"blocks.13.mlp.mlp_linear.weight": "model-00002-of-00006.safetensors",
|
| 71 |
+
"blocks.13.mlp.mlp_resid.weight": "model-00002-of-00006.safetensors",
|
| 72 |
+
"blocks.13.mlp_gain.a_g": "model-00002-of-00006.safetensors",
|
| 73 |
+
"blocks.14.attn.attn_key.weight": "model-00002-of-00006.safetensors",
|
| 74 |
+
"blocks.14.attn.attn_query.weight": "model-00002-of-00006.safetensors",
|
| 75 |
+
"blocks.14.attn.attn_resid.weight": "model-00002-of-00006.safetensors",
|
| 76 |
+
"blocks.14.attn.attn_value.weight": "model-00002-of-00006.safetensors",
|
| 77 |
+
"blocks.14.attn.head_gain.head_g": "model-00002-of-00006.safetensors",
|
| 78 |
+
"blocks.14.attn_gain.a_g": "model-00002-of-00006.safetensors",
|
| 79 |
+
"blocks.14.embed_skip.a_g": "model-00003-of-00006.safetensors",
|
| 80 |
+
"blocks.14.mlp.mlp_gate.weight": "model-00002-of-00006.safetensors",
|
| 81 |
+
"blocks.14.mlp.mlp_linear.weight": "model-00003-of-00006.safetensors",
|
| 82 |
+
"blocks.14.mlp.mlp_resid.weight": "model-00003-of-00006.safetensors",
|
| 83 |
+
"blocks.14.mlp_gain.a_g": "model-00003-of-00006.safetensors",
|
| 84 |
+
"blocks.15.attn.attn_key.weight": "model-00003-of-00006.safetensors",
|
| 85 |
+
"blocks.15.attn.attn_query.weight": "model-00003-of-00006.safetensors",
|
| 86 |
+
"blocks.15.attn.attn_resid.weight": "model-00003-of-00006.safetensors",
|
| 87 |
+
"blocks.15.attn.attn_value.weight": "model-00003-of-00006.safetensors",
|
| 88 |
+
"blocks.15.attn.head_gain.head_g": "model-00003-of-00006.safetensors",
|
| 89 |
+
"blocks.15.attn_gain.a_g": "model-00003-of-00006.safetensors",
|
| 90 |
+
"blocks.15.embed_skip.a_g": "model-00003-of-00006.safetensors",
|
| 91 |
+
"blocks.15.mlp.mlp_gate.weight": "model-00003-of-00006.safetensors",
|
| 92 |
+
"blocks.15.mlp.mlp_linear.weight": "model-00003-of-00006.safetensors",
|
| 93 |
+
"blocks.15.mlp.mlp_resid.weight": "model-00003-of-00006.safetensors",
|
| 94 |
+
"blocks.15.mlp_gain.a_g": "model-00003-of-00006.safetensors",
|
| 95 |
+
"blocks.16.attn.attn_key.weight": "model-00003-of-00006.safetensors",
|
| 96 |
+
"blocks.16.attn.attn_query.weight": "model-00003-of-00006.safetensors",
|
| 97 |
+
"blocks.16.attn.attn_resid.weight": "model-00003-of-00006.safetensors",
|
| 98 |
+
"blocks.16.attn.attn_value.weight": "model-00003-of-00006.safetensors",
|
| 99 |
+
"blocks.16.attn.head_gain.head_g": "model-00003-of-00006.safetensors",
|
| 100 |
+
"blocks.16.attn_gain.a_g": "model-00003-of-00006.safetensors",
|
| 101 |
+
"blocks.16.embed_skip.a_g": "model-00003-of-00006.safetensors",
|
| 102 |
+
"blocks.16.mlp.mlp_gate.weight": "model-00003-of-00006.safetensors",
|
| 103 |
+
"blocks.16.mlp.mlp_linear.weight": "model-00003-of-00006.safetensors",
|
| 104 |
+
"blocks.16.mlp.mlp_resid.weight": "model-00003-of-00006.safetensors",
|
| 105 |
+
"blocks.16.mlp_gain.a_g": "model-00003-of-00006.safetensors",
|
| 106 |
+
"blocks.17.attn.attn_key.weight": "model-00003-of-00006.safetensors",
|
| 107 |
+
"blocks.17.attn.attn_query.weight": "model-00003-of-00006.safetensors",
|
| 108 |
+
"blocks.17.attn.attn_resid.weight": "model-00003-of-00006.safetensors",
|
| 109 |
+
"blocks.17.attn.attn_value.weight": "model-00003-of-00006.safetensors",
|
| 110 |
+
"blocks.17.attn.head_gain.head_g": "model-00003-of-00006.safetensors",
|
| 111 |
+
"blocks.17.attn_gain.a_g": "model-00003-of-00006.safetensors",
|
| 112 |
+
"blocks.17.embed_skip.a_g": "model-00003-of-00006.safetensors",
|
| 113 |
+
"blocks.17.mlp.mlp_gate.weight": "model-00003-of-00006.safetensors",
|
| 114 |
+
"blocks.17.mlp.mlp_linear.weight": "model-00003-of-00006.safetensors",
|
| 115 |
+
"blocks.17.mlp.mlp_resid.weight": "model-00003-of-00006.safetensors",
|
| 116 |
+
"blocks.17.mlp_gain.a_g": "model-00003-of-00006.safetensors",
|
| 117 |
+
"blocks.18.attn.attn_key.weight": "model-00003-of-00006.safetensors",
|
| 118 |
+
"blocks.18.attn.attn_query.weight": "model-00003-of-00006.safetensors",
|
| 119 |
+
"blocks.18.attn.attn_resid.weight": "model-00003-of-00006.safetensors",
|
| 120 |
+
"blocks.18.attn.attn_value.weight": "model-00003-of-00006.safetensors",
|
| 121 |
+
"blocks.18.attn.head_gain.head_g": "model-00003-of-00006.safetensors",
|
| 122 |
+
"blocks.18.attn_gain.a_g": "model-00003-of-00006.safetensors",
|
| 123 |
+
"blocks.18.embed_skip.a_g": "model-00003-of-00006.safetensors",
|
| 124 |
+
"blocks.18.mlp.mlp_gate.weight": "model-00003-of-00006.safetensors",
|
| 125 |
+
"blocks.18.mlp.mlp_linear.weight": "model-00003-of-00006.safetensors",
|
| 126 |
+
"blocks.18.mlp.mlp_resid.weight": "model-00003-of-00006.safetensors",
|
| 127 |
+
"blocks.18.mlp_gain.a_g": "model-00003-of-00006.safetensors",
|
| 128 |
+
"blocks.19.attn.attn_key.weight": "model-00003-of-00006.safetensors",
|
| 129 |
+
"blocks.19.attn.attn_query.weight": "model-00003-of-00006.safetensors",
|
| 130 |
+
"blocks.19.attn.attn_resid.weight": "model-00003-of-00006.safetensors",
|
| 131 |
+
"blocks.19.attn.attn_value.weight": "model-00003-of-00006.safetensors",
|
| 132 |
+
"blocks.19.attn.head_gain.head_g": "model-00003-of-00006.safetensors",
|
| 133 |
+
"blocks.19.attn_gain.a_g": "model-00003-of-00006.safetensors",
|
| 134 |
+
"blocks.19.embed_skip.a_g": "model-00003-of-00006.safetensors",
|
| 135 |
+
"blocks.19.mlp.mlp_gate.weight": "model-00003-of-00006.safetensors",
|
| 136 |
+
"blocks.19.mlp.mlp_linear.weight": "model-00003-of-00006.safetensors",
|
| 137 |
+
"blocks.19.mlp.mlp_resid.weight": "model-00003-of-00006.safetensors",
|
| 138 |
+
"blocks.19.mlp_gain.a_g": "model-00003-of-00006.safetensors",
|
| 139 |
+
"blocks.2.attn.attn_key.weight": "model-00001-of-00006.safetensors",
|
| 140 |
+
"blocks.2.attn.attn_query.weight": "model-00001-of-00006.safetensors",
|
| 141 |
+
"blocks.2.attn.attn_resid.weight": "model-00001-of-00006.safetensors",
|
| 142 |
+
"blocks.2.attn.attn_value.weight": "model-00001-of-00006.safetensors",
|
| 143 |
+
"blocks.2.attn.head_gain.head_g": "model-00001-of-00006.safetensors",
|
| 144 |
+
"blocks.2.attn_gain.a_g": "model-00001-of-00006.safetensors",
|
| 145 |
+
"blocks.2.embed_skip.a_g": "model-00001-of-00006.safetensors",
|
| 146 |
+
"blocks.2.mlp.mlp_gate.weight": "model-00001-of-00006.safetensors",
|
| 147 |
+
"blocks.2.mlp.mlp_linear.weight": "model-00001-of-00006.safetensors",
|
| 148 |
+
"blocks.2.mlp.mlp_resid.weight": "model-00001-of-00006.safetensors",
|
| 149 |
+
"blocks.2.mlp_gain.a_g": "model-00001-of-00006.safetensors",
|
| 150 |
+
"blocks.20.attn.attn_key.weight": "model-00003-of-00006.safetensors",
|
| 151 |
+
"blocks.20.attn.attn_query.weight": "model-00003-of-00006.safetensors",
|
| 152 |
+
"blocks.20.attn.attn_resid.weight": "model-00003-of-00006.safetensors",
|
| 153 |
+
"blocks.20.attn.attn_value.weight": "model-00003-of-00006.safetensors",
|
| 154 |
+
"blocks.20.attn.head_gain.head_g": "model-00003-of-00006.safetensors",
|
| 155 |
+
"blocks.20.attn_gain.a_g": "model-00003-of-00006.safetensors",
|
| 156 |
+
"blocks.20.embed_skip.a_g": "model-00003-of-00006.safetensors",
|
| 157 |
+
"blocks.20.mlp.mlp_gate.weight": "model-00003-of-00006.safetensors",
|
| 158 |
+
"blocks.20.mlp.mlp_linear.weight": "model-00003-of-00006.safetensors",
|
| 159 |
+
"blocks.20.mlp.mlp_resid.weight": "model-00003-of-00006.safetensors",
|
| 160 |
+
"blocks.20.mlp_gain.a_g": "model-00003-of-00006.safetensors",
|
| 161 |
+
"blocks.21.attn.attn_key.weight": "model-00003-of-00006.safetensors",
|
| 162 |
+
"blocks.21.attn.attn_query.weight": "model-00003-of-00006.safetensors",
|
| 163 |
+
"blocks.21.attn.attn_resid.weight": "model-00003-of-00006.safetensors",
|
| 164 |
+
"blocks.21.attn.attn_value.weight": "model-00003-of-00006.safetensors",
|
| 165 |
+
"blocks.21.attn.head_gain.head_g": "model-00003-of-00006.safetensors",
|
| 166 |
+
"blocks.21.attn_gain.a_g": "model-00003-of-00006.safetensors",
|
| 167 |
+
"blocks.21.embed_skip.a_g": "model-00003-of-00006.safetensors",
|
| 168 |
+
"blocks.21.mlp.mlp_gate.weight": "model-00003-of-00006.safetensors",
|
| 169 |
+
"blocks.21.mlp.mlp_linear.weight": "model-00003-of-00006.safetensors",
|
| 170 |
+
"blocks.21.mlp.mlp_resid.weight": "model-00003-of-00006.safetensors",
|
| 171 |
+
"blocks.21.mlp_gain.a_g": "model-00003-of-00006.safetensors",
|
| 172 |
+
"blocks.22.attn.attn_key.weight": "model-00003-of-00006.safetensors",
|
| 173 |
+
"blocks.22.attn.attn_query.weight": "model-00003-of-00006.safetensors",
|
| 174 |
+
"blocks.22.attn.attn_resid.weight": "model-00003-of-00006.safetensors",
|
| 175 |
+
"blocks.22.attn.attn_value.weight": "model-00003-of-00006.safetensors",
|
| 176 |
+
"blocks.22.attn.head_gain.head_g": "model-00003-of-00006.safetensors",
|
| 177 |
+
"blocks.22.attn_gain.a_g": "model-00003-of-00006.safetensors",
|
| 178 |
+
"blocks.22.embed_skip.a_g": "model-00004-of-00006.safetensors",
|
| 179 |
+
"blocks.22.mlp.mlp_gate.weight": "model-00004-of-00006.safetensors",
|
| 180 |
+
"blocks.22.mlp.mlp_linear.weight": "model-00004-of-00006.safetensors",
|
| 181 |
+
"blocks.22.mlp.mlp_resid.weight": "model-00004-of-00006.safetensors",
|
| 182 |
+
"blocks.22.mlp_gain.a_g": "model-00004-of-00006.safetensors",
|
| 183 |
+
"blocks.23.attn.attn_key.weight": "model-00004-of-00006.safetensors",
|
| 184 |
+
"blocks.23.attn.attn_query.weight": "model-00004-of-00006.safetensors",
|
| 185 |
+
"blocks.23.attn.attn_resid.weight": "model-00004-of-00006.safetensors",
|
| 186 |
+
"blocks.23.attn.attn_value.weight": "model-00004-of-00006.safetensors",
|
| 187 |
+
"blocks.23.attn.head_gain.head_g": "model-00004-of-00006.safetensors",
|
| 188 |
+
"blocks.23.attn_gain.a_g": "model-00004-of-00006.safetensors",
|
| 189 |
+
"blocks.23.embed_skip.a_g": "model-00004-of-00006.safetensors",
|
| 190 |
+
"blocks.23.mlp.mlp_gate.weight": "model-00004-of-00006.safetensors",
|
| 191 |
+
"blocks.23.mlp.mlp_linear.weight": "model-00004-of-00006.safetensors",
|
| 192 |
+
"blocks.23.mlp.mlp_resid.weight": "model-00004-of-00006.safetensors",
|
| 193 |
+
"blocks.23.mlp_gain.a_g": "model-00004-of-00006.safetensors",
|
| 194 |
+
"blocks.24.attn.attn_key.weight": "model-00004-of-00006.safetensors",
|
| 195 |
+
"blocks.24.attn.attn_query.weight": "model-00004-of-00006.safetensors",
|
| 196 |
+
"blocks.24.attn.attn_resid.weight": "model-00004-of-00006.safetensors",
|
| 197 |
+
"blocks.24.attn.attn_value.weight": "model-00004-of-00006.safetensors",
|
| 198 |
+
"blocks.24.attn.head_gain.head_g": "model-00004-of-00006.safetensors",
|
| 199 |
+
"blocks.24.attn_gain.a_g": "model-00004-of-00006.safetensors",
|
| 200 |
+
"blocks.24.embed_skip.a_g": "model-00004-of-00006.safetensors",
|
| 201 |
+
"blocks.24.mlp.mlp_gate.weight": "model-00004-of-00006.safetensors",
|
| 202 |
+
"blocks.24.mlp.mlp_linear.weight": "model-00004-of-00006.safetensors",
|
| 203 |
+
"blocks.24.mlp.mlp_resid.weight": "model-00004-of-00006.safetensors",
|
| 204 |
+
"blocks.24.mlp_gain.a_g": "model-00004-of-00006.safetensors",
|
| 205 |
+
"blocks.25.attn.attn_key.weight": "model-00004-of-00006.safetensors",
|
| 206 |
+
"blocks.25.attn.attn_query.weight": "model-00004-of-00006.safetensors",
|
| 207 |
+
"blocks.25.attn.attn_resid.weight": "model-00004-of-00006.safetensors",
|
| 208 |
+
"blocks.25.attn.attn_value.weight": "model-00004-of-00006.safetensors",
|
| 209 |
+
"blocks.25.attn.head_gain.head_g": "model-00004-of-00006.safetensors",
|
| 210 |
+
"blocks.25.attn_gain.a_g": "model-00004-of-00006.safetensors",
|
| 211 |
+
"blocks.25.embed_skip.a_g": "model-00004-of-00006.safetensors",
|
| 212 |
+
"blocks.25.mlp.mlp_gate.weight": "model-00004-of-00006.safetensors",
|
| 213 |
+
"blocks.25.mlp.mlp_linear.weight": "model-00004-of-00006.safetensors",
|
| 214 |
+
"blocks.25.mlp.mlp_resid.weight": "model-00004-of-00006.safetensors",
|
| 215 |
+
"blocks.25.mlp_gain.a_g": "model-00004-of-00006.safetensors",
|
| 216 |
+
"blocks.26.attn.attn_key.weight": "model-00004-of-00006.safetensors",
|
| 217 |
+
"blocks.26.attn.attn_query.weight": "model-00004-of-00006.safetensors",
|
| 218 |
+
"blocks.26.attn.attn_resid.weight": "model-00004-of-00006.safetensors",
|
| 219 |
+
"blocks.26.attn.attn_value.weight": "model-00004-of-00006.safetensors",
|
| 220 |
+
"blocks.26.attn.head_gain.head_g": "model-00004-of-00006.safetensors",
|
| 221 |
+
"blocks.26.attn_gain.a_g": "model-00004-of-00006.safetensors",
|
| 222 |
+
"blocks.26.embed_skip.a_g": "model-00004-of-00006.safetensors",
|
| 223 |
+
"blocks.26.mlp.mlp_gate.weight": "model-00004-of-00006.safetensors",
|
| 224 |
+
"blocks.26.mlp.mlp_linear.weight": "model-00004-of-00006.safetensors",
|
| 225 |
+
"blocks.26.mlp.mlp_resid.weight": "model-00004-of-00006.safetensors",
|
| 226 |
+
"blocks.26.mlp_gain.a_g": "model-00004-of-00006.safetensors",
|
| 227 |
+
"blocks.27.attn.attn_key.weight": "model-00004-of-00006.safetensors",
|
| 228 |
+
"blocks.27.attn.attn_query.weight": "model-00004-of-00006.safetensors",
|
| 229 |
+
"blocks.27.attn.attn_resid.weight": "model-00004-of-00006.safetensors",
|
| 230 |
+
"blocks.27.attn.attn_value.weight": "model-00004-of-00006.safetensors",
|
| 231 |
+
"blocks.27.attn.head_gain.head_g": "model-00004-of-00006.safetensors",
|
| 232 |
+
"blocks.27.attn_gain.a_g": "model-00004-of-00006.safetensors",
|
| 233 |
+
"blocks.27.embed_skip.a_g": "model-00004-of-00006.safetensors",
|
| 234 |
+
"blocks.27.mlp.mlp_gate.weight": "model-00004-of-00006.safetensors",
|
| 235 |
+
"blocks.27.mlp.mlp_linear.weight": "model-00004-of-00006.safetensors",
|
| 236 |
+
"blocks.27.mlp.mlp_resid.weight": "model-00004-of-00006.safetensors",
|
| 237 |
+
"blocks.27.mlp_gain.a_g": "model-00004-of-00006.safetensors",
|
| 238 |
+
"blocks.28.attn.attn_key.weight": "model-00004-of-00006.safetensors",
|
| 239 |
+
"blocks.28.attn.attn_query.weight": "model-00004-of-00006.safetensors",
|
| 240 |
+
"blocks.28.attn.attn_resid.weight": "model-00004-of-00006.safetensors",
|
| 241 |
+
"blocks.28.attn.attn_value.weight": "model-00004-of-00006.safetensors",
|
| 242 |
+
"blocks.28.attn.head_gain.head_g": "model-00004-of-00006.safetensors",
|
| 243 |
+
"blocks.28.attn_gain.a_g": "model-00004-of-00006.safetensors",
|
| 244 |
+
"blocks.28.embed_skip.a_g": "model-00004-of-00006.safetensors",
|
| 245 |
+
"blocks.28.mlp.mlp_gate.weight": "model-00004-of-00006.safetensors",
|
| 246 |
+
"blocks.28.mlp.mlp_linear.weight": "model-00004-of-00006.safetensors",
|
| 247 |
+
"blocks.28.mlp.mlp_resid.weight": "model-00004-of-00006.safetensors",
|
| 248 |
+
"blocks.28.mlp_gain.a_g": "model-00004-of-00006.safetensors",
|
| 249 |
+
"blocks.29.attn.attn_key.weight": "model-00004-of-00006.safetensors",
|
| 250 |
+
"blocks.29.attn.attn_query.weight": "model-00004-of-00006.safetensors",
|
| 251 |
+
"blocks.29.attn.attn_resid.weight": "model-00004-of-00006.safetensors",
|
| 252 |
+
"blocks.29.attn.attn_value.weight": "model-00004-of-00006.safetensors",
|
| 253 |
+
"blocks.29.attn.head_gain.head_g": "model-00004-of-00006.safetensors",
|
| 254 |
+
"blocks.29.attn_gain.a_g": "model-00004-of-00006.safetensors",
|
| 255 |
+
"blocks.29.embed_skip.a_g": "model-00004-of-00006.safetensors",
|
| 256 |
+
"blocks.29.mlp.mlp_gate.weight": "model-00004-of-00006.safetensors",
|
| 257 |
+
"blocks.29.mlp.mlp_linear.weight": "model-00004-of-00006.safetensors",
|
| 258 |
+
"blocks.29.mlp.mlp_resid.weight": "model-00004-of-00006.safetensors",
|
| 259 |
+
"blocks.29.mlp_gain.a_g": "model-00004-of-00006.safetensors",
|
| 260 |
+
"blocks.3.attn.attn_key.weight": "model-00001-of-00006.safetensors",
|
| 261 |
+
"blocks.3.attn.attn_query.weight": "model-00001-of-00006.safetensors",
|
| 262 |
+
"blocks.3.attn.attn_resid.weight": "model-00001-of-00006.safetensors",
|
| 263 |
+
"blocks.3.attn.attn_value.weight": "model-00001-of-00006.safetensors",
|
| 264 |
+
"blocks.3.attn.head_gain.head_g": "model-00001-of-00006.safetensors",
|
| 265 |
+
"blocks.3.attn_gain.a_g": "model-00001-of-00006.safetensors",
|
| 266 |
+
"blocks.3.embed_skip.a_g": "model-00001-of-00006.safetensors",
|
| 267 |
+
"blocks.3.mlp.mlp_gate.weight": "model-00001-of-00006.safetensors",
|
| 268 |
+
"blocks.3.mlp.mlp_linear.weight": "model-00001-of-00006.safetensors",
|
| 269 |
+
"blocks.3.mlp.mlp_resid.weight": "model-00001-of-00006.safetensors",
|
| 270 |
+
"blocks.3.mlp_gain.a_g": "model-00001-of-00006.safetensors",
|
| 271 |
+
"blocks.30.attn.attn_key.weight": "model-00004-of-00006.safetensors",
|
| 272 |
+
"blocks.30.attn.attn_query.weight": "model-00004-of-00006.safetensors",
|
| 273 |
+
"blocks.30.attn.attn_resid.weight": "model-00005-of-00006.safetensors",
|
| 274 |
+
"blocks.30.attn.attn_value.weight": "model-00004-of-00006.safetensors",
|
| 275 |
+
"blocks.30.attn.head_gain.head_g": "model-00005-of-00006.safetensors",
|
| 276 |
+
"blocks.30.attn_gain.a_g": "model-00005-of-00006.safetensors",
|
| 277 |
+
"blocks.30.embed_skip.a_g": "model-00005-of-00006.safetensors",
|
| 278 |
+
"blocks.30.mlp.mlp_gate.weight": "model-00005-of-00006.safetensors",
|
| 279 |
+
"blocks.30.mlp.mlp_linear.weight": "model-00005-of-00006.safetensors",
|
| 280 |
+
"blocks.30.mlp.mlp_resid.weight": "model-00005-of-00006.safetensors",
|
| 281 |
+
"blocks.30.mlp_gain.a_g": "model-00005-of-00006.safetensors",
|
| 282 |
+
"blocks.31.attn.attn_key.weight": "model-00005-of-00006.safetensors",
|
| 283 |
+
"blocks.31.attn.attn_query.weight": "model-00005-of-00006.safetensors",
|
| 284 |
+
"blocks.31.attn.attn_resid.weight": "model-00005-of-00006.safetensors",
|
| 285 |
+
"blocks.31.attn.attn_value.weight": "model-00005-of-00006.safetensors",
|
| 286 |
+
"blocks.31.attn.head_gain.head_g": "model-00005-of-00006.safetensors",
|
| 287 |
+
"blocks.31.attn_gain.a_g": "model-00005-of-00006.safetensors",
|
| 288 |
+
"blocks.31.embed_skip.a_g": "model-00005-of-00006.safetensors",
|
| 289 |
+
"blocks.31.mlp.mlp_gate.weight": "model-00005-of-00006.safetensors",
|
| 290 |
+
"blocks.31.mlp.mlp_linear.weight": "model-00005-of-00006.safetensors",
|
| 291 |
+
"blocks.31.mlp.mlp_resid.weight": "model-00005-of-00006.safetensors",
|
| 292 |
+
"blocks.31.mlp_gain.a_g": "model-00005-of-00006.safetensors",
|
| 293 |
+
"blocks.32.attn.attn_key.weight": "model-00005-of-00006.safetensors",
|
| 294 |
+
"blocks.32.attn.attn_query.weight": "model-00005-of-00006.safetensors",
|
| 295 |
+
"blocks.32.attn.attn_resid.weight": "model-00005-of-00006.safetensors",
|
| 296 |
+
"blocks.32.attn.attn_value.weight": "model-00005-of-00006.safetensors",
|
| 297 |
+
"blocks.32.attn.head_gain.head_g": "model-00005-of-00006.safetensors",
|
| 298 |
+
"blocks.32.attn_gain.a_g": "model-00005-of-00006.safetensors",
|
| 299 |
+
"blocks.32.embed_skip.a_g": "model-00005-of-00006.safetensors",
|
| 300 |
+
"blocks.32.mlp.mlp_gate.weight": "model-00005-of-00006.safetensors",
|
| 301 |
+
"blocks.32.mlp.mlp_linear.weight": "model-00005-of-00006.safetensors",
|
| 302 |
+
"blocks.32.mlp.mlp_resid.weight": "model-00005-of-00006.safetensors",
|
| 303 |
+
"blocks.32.mlp_gain.a_g": "model-00005-of-00006.safetensors",
|
| 304 |
+
"blocks.33.attn.attn_key.weight": "model-00005-of-00006.safetensors",
|
| 305 |
+
"blocks.33.attn.attn_query.weight": "model-00005-of-00006.safetensors",
|
| 306 |
+
"blocks.33.attn.attn_resid.weight": "model-00005-of-00006.safetensors",
|
| 307 |
+
"blocks.33.attn.attn_value.weight": "model-00005-of-00006.safetensors",
|
| 308 |
+
"blocks.33.attn.head_gain.head_g": "model-00005-of-00006.safetensors",
|
| 309 |
+
"blocks.33.attn_gain.a_g": "model-00005-of-00006.safetensors",
|
| 310 |
+
"blocks.33.embed_skip.a_g": "model-00005-of-00006.safetensors",
|
| 311 |
+
"blocks.33.mlp.mlp_gate.weight": "model-00005-of-00006.safetensors",
|
| 312 |
+
"blocks.33.mlp.mlp_linear.weight": "model-00005-of-00006.safetensors",
|
| 313 |
+
"blocks.33.mlp.mlp_resid.weight": "model-00005-of-00006.safetensors",
|
| 314 |
+
"blocks.33.mlp_gain.a_g": "model-00005-of-00006.safetensors",
|
| 315 |
+
"blocks.34.attn.attn_key.weight": "model-00005-of-00006.safetensors",
|
| 316 |
+
"blocks.34.attn.attn_query.weight": "model-00005-of-00006.safetensors",
|
| 317 |
+
"blocks.34.attn.attn_resid.weight": "model-00005-of-00006.safetensors",
|
| 318 |
+
"blocks.34.attn.attn_value.weight": "model-00005-of-00006.safetensors",
|
| 319 |
+
"blocks.34.attn.head_gain.head_g": "model-00005-of-00006.safetensors",
|
| 320 |
+
"blocks.34.attn_gain.a_g": "model-00005-of-00006.safetensors",
|
| 321 |
+
"blocks.34.embed_skip.a_g": "model-00005-of-00006.safetensors",
|
| 322 |
+
"blocks.34.mlp.mlp_gate.weight": "model-00005-of-00006.safetensors",
|
| 323 |
+
"blocks.34.mlp.mlp_linear.weight": "model-00005-of-00006.safetensors",
|
| 324 |
+
"blocks.34.mlp.mlp_resid.weight": "model-00005-of-00006.safetensors",
|
| 325 |
+
"blocks.34.mlp_gain.a_g": "model-00005-of-00006.safetensors",
|
| 326 |
+
"blocks.35.attn.attn_key.weight": "model-00005-of-00006.safetensors",
|
| 327 |
+
"blocks.35.attn.attn_query.weight": "model-00005-of-00006.safetensors",
|
| 328 |
+
"blocks.35.attn.attn_resid.weight": "model-00005-of-00006.safetensors",
|
| 329 |
+
"blocks.35.attn.attn_value.weight": "model-00005-of-00006.safetensors",
|
| 330 |
+
"blocks.35.attn.head_gain.head_g": "model-00005-of-00006.safetensors",
|
| 331 |
+
"blocks.35.attn_gain.a_g": "model-00005-of-00006.safetensors",
|
| 332 |
+
"blocks.35.embed_skip.a_g": "model-00005-of-00006.safetensors",
|
| 333 |
+
"blocks.35.mlp.mlp_gate.weight": "model-00005-of-00006.safetensors",
|
| 334 |
+
"blocks.35.mlp.mlp_linear.weight": "model-00005-of-00006.safetensors",
|
| 335 |
+
"blocks.35.mlp.mlp_resid.weight": "model-00005-of-00006.safetensors",
|
| 336 |
+
"blocks.35.mlp_gain.a_g": "model-00005-of-00006.safetensors",
|
| 337 |
+
"blocks.36.attn.attn_key.weight": "model-00005-of-00006.safetensors",
|
| 338 |
+
"blocks.36.attn.attn_query.weight": "model-00005-of-00006.safetensors",
|
| 339 |
+
"blocks.36.attn.attn_resid.weight": "model-00005-of-00006.safetensors",
|
| 340 |
+
"blocks.36.attn.attn_value.weight": "model-00005-of-00006.safetensors",
|
| 341 |
+
"blocks.36.attn.head_gain.head_g": "model-00005-of-00006.safetensors",
|
| 342 |
+
"blocks.36.attn_gain.a_g": "model-00005-of-00006.safetensors",
|
| 343 |
+
"blocks.36.embed_skip.a_g": "model-00005-of-00006.safetensors",
|
| 344 |
+
"blocks.36.mlp.mlp_gate.weight": "model-00005-of-00006.safetensors",
|
| 345 |
+
"blocks.36.mlp.mlp_linear.weight": "model-00005-of-00006.safetensors",
|
| 346 |
+
"blocks.36.mlp.mlp_resid.weight": "model-00005-of-00006.safetensors",
|
| 347 |
+
"blocks.36.mlp_gain.a_g": "model-00005-of-00006.safetensors",
|
| 348 |
+
"blocks.37.attn.attn_key.weight": "model-00005-of-00006.safetensors",
|
| 349 |
+
"blocks.37.attn.attn_query.weight": "model-00005-of-00006.safetensors",
|
| 350 |
+
"blocks.37.attn.attn_resid.weight": "model-00005-of-00006.safetensors",
|
| 351 |
+
"blocks.37.attn.attn_value.weight": "model-00005-of-00006.safetensors",
|
| 352 |
+
"blocks.37.attn.head_gain.head_g": "model-00005-of-00006.safetensors",
|
| 353 |
+
"blocks.37.attn_gain.a_g": "model-00005-of-00006.safetensors",
|
| 354 |
+
"blocks.37.embed_skip.a_g": "model-00005-of-00006.safetensors",
|
| 355 |
+
"blocks.37.mlp.mlp_gate.weight": "model-00005-of-00006.safetensors",
|
| 356 |
+
"blocks.37.mlp.mlp_linear.weight": "model-00005-of-00006.safetensors",
|
| 357 |
+
"blocks.37.mlp.mlp_resid.weight": "model-00005-of-00006.safetensors",
|
| 358 |
+
"blocks.37.mlp_gain.a_g": "model-00005-of-00006.safetensors",
|
| 359 |
+
"blocks.38.attn.attn_key.weight": "model-00005-of-00006.safetensors",
|
| 360 |
+
"blocks.38.attn.attn_query.weight": "model-00005-of-00006.safetensors",
|
| 361 |
+
"blocks.38.attn.attn_resid.weight": "model-00006-of-00006.safetensors",
|
| 362 |
+
"blocks.38.attn.attn_value.weight": "model-00006-of-00006.safetensors",
|
| 363 |
+
"blocks.38.attn.head_gain.head_g": "model-00006-of-00006.safetensors",
|
| 364 |
+
"blocks.38.attn_gain.a_g": "model-00006-of-00006.safetensors",
|
| 365 |
+
"blocks.38.embed_skip.a_g": "model-00006-of-00006.safetensors",
|
| 366 |
+
"blocks.38.mlp.mlp_gate.weight": "model-00006-of-00006.safetensors",
|
| 367 |
+
"blocks.38.mlp.mlp_linear.weight": "model-00006-of-00006.safetensors",
|
| 368 |
+
"blocks.38.mlp.mlp_resid.weight": "model-00006-of-00006.safetensors",
|
| 369 |
+
"blocks.38.mlp_gain.a_g": "model-00006-of-00006.safetensors",
|
| 370 |
+
"blocks.39.attn.attn_key.weight": "model-00006-of-00006.safetensors",
|
| 371 |
+
"blocks.39.attn.attn_query.weight": "model-00006-of-00006.safetensors",
|
| 372 |
+
"blocks.39.attn.attn_resid.weight": "model-00006-of-00006.safetensors",
|
| 373 |
+
"blocks.39.attn.attn_value.weight": "model-00006-of-00006.safetensors",
|
| 374 |
+
"blocks.39.attn.head_gain.head_g": "model-00006-of-00006.safetensors",
|
| 375 |
+
"blocks.39.attn_gain.a_g": "model-00006-of-00006.safetensors",
|
| 376 |
+
"blocks.39.embed_skip.a_g": "model-00006-of-00006.safetensors",
|
| 377 |
+
"blocks.39.mlp.mlp_gate.weight": "model-00006-of-00006.safetensors",
|
| 378 |
+
"blocks.39.mlp.mlp_linear.weight": "model-00006-of-00006.safetensors",
|
| 379 |
+
"blocks.39.mlp.mlp_resid.weight": "model-00006-of-00006.safetensors",
|
| 380 |
+
"blocks.39.mlp_gain.a_g": "model-00006-of-00006.safetensors",
|
| 381 |
+
"blocks.4.attn.attn_key.weight": "model-00001-of-00006.safetensors",
|
| 382 |
+
"blocks.4.attn.attn_query.weight": "model-00001-of-00006.safetensors",
|
| 383 |
+
"blocks.4.attn.attn_resid.weight": "model-00001-of-00006.safetensors",
|
| 384 |
+
"blocks.4.attn.attn_value.weight": "model-00001-of-00006.safetensors",
|
| 385 |
+
"blocks.4.attn.head_gain.head_g": "model-00001-of-00006.safetensors",
|
| 386 |
+
"blocks.4.attn_gain.a_g": "model-00001-of-00006.safetensors",
|
| 387 |
+
"blocks.4.embed_skip.a_g": "model-00001-of-00006.safetensors",
|
| 388 |
+
"blocks.4.mlp.mlp_gate.weight": "model-00001-of-00006.safetensors",
|
| 389 |
+
"blocks.4.mlp.mlp_linear.weight": "model-00001-of-00006.safetensors",
|
| 390 |
+
"blocks.4.mlp.mlp_resid.weight": "model-00001-of-00006.safetensors",
|
| 391 |
+
"blocks.4.mlp_gain.a_g": "model-00001-of-00006.safetensors",
|
| 392 |
+
"blocks.5.attn.attn_key.weight": "model-00001-of-00006.safetensors",
|
| 393 |
+
"blocks.5.attn.attn_query.weight": "model-00001-of-00006.safetensors",
|
| 394 |
+
"blocks.5.attn.attn_resid.weight": "model-00001-of-00006.safetensors",
|
| 395 |
+
"blocks.5.attn.attn_value.weight": "model-00001-of-00006.safetensors",
|
| 396 |
+
"blocks.5.attn.head_gain.head_g": "model-00001-of-00006.safetensors",
|
| 397 |
+
"blocks.5.attn_gain.a_g": "model-00001-of-00006.safetensors",
|
| 398 |
+
"blocks.5.embed_skip.a_g": "model-00001-of-00006.safetensors",
|
| 399 |
+
"blocks.5.mlp.mlp_gate.weight": "model-00001-of-00006.safetensors",
|
| 400 |
+
"blocks.5.mlp.mlp_linear.weight": "model-00001-of-00006.safetensors",
|
| 401 |
+
"blocks.5.mlp.mlp_resid.weight": "model-00001-of-00006.safetensors",
|
| 402 |
+
"blocks.5.mlp_gain.a_g": "model-00001-of-00006.safetensors",
|
| 403 |
+
"blocks.6.attn.attn_key.weight": "model-00001-of-00006.safetensors",
|
| 404 |
+
"blocks.6.attn.attn_query.weight": "model-00001-of-00006.safetensors",
|
| 405 |
+
"blocks.6.attn.attn_resid.weight": "model-00001-of-00006.safetensors",
|
| 406 |
+
"blocks.6.attn.attn_value.weight": "model-00001-of-00006.safetensors",
|
| 407 |
+
"blocks.6.attn.head_gain.head_g": "model-00001-of-00006.safetensors",
|
| 408 |
+
"blocks.6.attn_gain.a_g": "model-00001-of-00006.safetensors",
|
| 409 |
+
"blocks.6.embed_skip.a_g": "model-00002-of-00006.safetensors",
|
| 410 |
+
"blocks.6.mlp.mlp_gate.weight": "model-00001-of-00006.safetensors",
|
| 411 |
+
"blocks.6.mlp.mlp_linear.weight": "model-00001-of-00006.safetensors",
|
| 412 |
+
"blocks.6.mlp.mlp_resid.weight": "model-00002-of-00006.safetensors",
|
| 413 |
+
"blocks.6.mlp_gain.a_g": "model-00002-of-00006.safetensors",
|
| 414 |
+
"blocks.7.attn.attn_key.weight": "model-00002-of-00006.safetensors",
|
| 415 |
+
"blocks.7.attn.attn_query.weight": "model-00002-of-00006.safetensors",
|
| 416 |
+
"blocks.7.attn.attn_resid.weight": "model-00002-of-00006.safetensors",
|
| 417 |
+
"blocks.7.attn.attn_value.weight": "model-00002-of-00006.safetensors",
|
| 418 |
+
"blocks.7.attn.head_gain.head_g": "model-00002-of-00006.safetensors",
|
| 419 |
+
"blocks.7.attn_gain.a_g": "model-00002-of-00006.safetensors",
|
| 420 |
+
"blocks.7.embed_skip.a_g": "model-00002-of-00006.safetensors",
|
| 421 |
+
"blocks.7.mlp.mlp_gate.weight": "model-00002-of-00006.safetensors",
|
| 422 |
+
"blocks.7.mlp.mlp_linear.weight": "model-00002-of-00006.safetensors",
|
| 423 |
+
"blocks.7.mlp.mlp_resid.weight": "model-00002-of-00006.safetensors",
|
| 424 |
+
"blocks.7.mlp_gain.a_g": "model-00002-of-00006.safetensors",
|
| 425 |
+
"blocks.8.attn.attn_key.weight": "model-00002-of-00006.safetensors",
|
| 426 |
+
"blocks.8.attn.attn_query.weight": "model-00002-of-00006.safetensors",
|
| 427 |
+
"blocks.8.attn.attn_resid.weight": "model-00002-of-00006.safetensors",
|
| 428 |
+
"blocks.8.attn.attn_value.weight": "model-00002-of-00006.safetensors",
|
| 429 |
+
"blocks.8.attn.head_gain.head_g": "model-00002-of-00006.safetensors",
|
| 430 |
+
"blocks.8.attn_gain.a_g": "model-00002-of-00006.safetensors",
|
| 431 |
+
"blocks.8.embed_skip.a_g": "model-00002-of-00006.safetensors",
|
| 432 |
+
"blocks.8.mlp.mlp_gate.weight": "model-00002-of-00006.safetensors",
|
| 433 |
+
"blocks.8.mlp.mlp_linear.weight": "model-00002-of-00006.safetensors",
|
| 434 |
+
"blocks.8.mlp.mlp_resid.weight": "model-00002-of-00006.safetensors",
|
| 435 |
+
"blocks.8.mlp_gain.a_g": "model-00002-of-00006.safetensors",
|
| 436 |
+
"blocks.9.attn.attn_key.weight": "model-00002-of-00006.safetensors",
|
| 437 |
+
"blocks.9.attn.attn_query.weight": "model-00002-of-00006.safetensors",
|
| 438 |
+
"blocks.9.attn.attn_resid.weight": "model-00002-of-00006.safetensors",
|
| 439 |
+
"blocks.9.attn.attn_value.weight": "model-00002-of-00006.safetensors",
|
| 440 |
+
"blocks.9.attn.head_gain.head_g": "model-00002-of-00006.safetensors",
|
| 441 |
+
"blocks.9.attn_gain.a_g": "model-00002-of-00006.safetensors",
|
| 442 |
+
"blocks.9.embed_skip.a_g": "model-00002-of-00006.safetensors",
|
| 443 |
+
"blocks.9.mlp.mlp_gate.weight": "model-00002-of-00006.safetensors",
|
| 444 |
+
"blocks.9.mlp.mlp_linear.weight": "model-00002-of-00006.safetensors",
|
| 445 |
+
"blocks.9.mlp.mlp_resid.weight": "model-00002-of-00006.safetensors",
|
| 446 |
+
"blocks.9.mlp_gain.a_g": "model-00002-of-00006.safetensors",
|
| 447 |
+
"embed.weight": "model-00001-of-00006.safetensors",
|
| 448 |
+
"lm_head.weight": "model-00006-of-00006.safetensors"
|
| 449 |
+
}
|
| 450 |
+
}
|
modeling_talkie.py
ADDED
|
@@ -0,0 +1,638 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
import math
|
| 4 |
+
|
| 5 |
+
import torch
|
| 6 |
+
import torch.nn as nn
|
| 7 |
+
import torch.nn.functional as F
|
| 8 |
+
from transformers.cache_utils import Cache, DynamicCache
|
| 9 |
+
from transformers import GenerationMixin
|
| 10 |
+
from transformers import PreTrainedModel
|
| 11 |
+
from transformers.modeling_outputs import BaseModelOutputWithPast, CausalLMOutputWithPast
|
| 12 |
+
|
| 13 |
+
try:
|
| 14 |
+
from transformers.modeling_utils import ALL_ATTENTION_FUNCTIONS
|
| 15 |
+
except ImportError: # pragma: no cover - compatibility with older Transformers.
|
| 16 |
+
ALL_ATTENTION_FUNCTIONS = None
|
| 17 |
+
|
| 18 |
+
from .configuration_talkie import TalkieConfig
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
def eager_attention_forward(
|
| 22 |
+
module: nn.Module,
|
| 23 |
+
query: torch.Tensor,
|
| 24 |
+
key: torch.Tensor,
|
| 25 |
+
value: torch.Tensor,
|
| 26 |
+
attention_mask: torch.Tensor | None,
|
| 27 |
+
dropout: float = 0.0,
|
| 28 |
+
scaling: float | None = None,
|
| 29 |
+
is_causal: bool | None = None,
|
| 30 |
+
**kwargs,
|
| 31 |
+
) -> tuple[torch.Tensor, None]:
|
| 32 |
+
del kwargs
|
| 33 |
+
is_causal = is_causal if is_causal is not None else getattr(module, "is_causal", True)
|
| 34 |
+
output = F.scaled_dot_product_attention(
|
| 35 |
+
query,
|
| 36 |
+
key,
|
| 37 |
+
value,
|
| 38 |
+
attn_mask=attention_mask,
|
| 39 |
+
dropout_p=dropout,
|
| 40 |
+
scale=scaling,
|
| 41 |
+
is_causal=is_causal and attention_mask is None,
|
| 42 |
+
)
|
| 43 |
+
return output.transpose(1, 2).contiguous(), None
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
def apply_rotary_emb(x: torch.Tensor, cos: torch.Tensor, sin: torch.Tensor) -> torch.Tensor:
|
| 47 |
+
d = x.shape[3] // 2
|
| 48 |
+
x1 = x[..., :d]
|
| 49 |
+
x2 = x[..., d:]
|
| 50 |
+
y1 = x1 * cos + x2 * sin
|
| 51 |
+
y2 = x1 * (-sin) + x2 * cos
|
| 52 |
+
return torch.cat([y1, y2], 3).type_as(x)
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
class HeadGain(nn.Module):
|
| 56 |
+
def __init__(self, n_head: int):
|
| 57 |
+
super().__init__()
|
| 58 |
+
self.head_g = nn.Parameter(torch.ones([n_head]))
|
| 59 |
+
|
| 60 |
+
def forward(self, x: torch.Tensor) -> torch.Tensor:
|
| 61 |
+
return x * self.head_g.type_as(x).view(1, 1, -1, 1)
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
class WeightGain(nn.Module):
|
| 65 |
+
def __init__(self):
|
| 66 |
+
super().__init__()
|
| 67 |
+
self.w_g = nn.Parameter(torch.ones(1))
|
| 68 |
+
|
| 69 |
+
def forward(self, w: torch.Tensor) -> torch.Tensor:
|
| 70 |
+
return w * self.w_g.type_as(w)
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
class ActGain(nn.Module):
|
| 74 |
+
def __init__(self, init_value: float):
|
| 75 |
+
super().__init__()
|
| 76 |
+
self.a_g = nn.Parameter(torch.ones(1) * init_value)
|
| 77 |
+
|
| 78 |
+
def forward(self, x: torch.Tensor) -> torch.Tensor:
|
| 79 |
+
return x * self.a_g.type_as(x)
|
| 80 |
+
|
| 81 |
+
|
| 82 |
+
class CausalSelfAttention(nn.Module):
|
| 83 |
+
is_causal = True
|
| 84 |
+
|
| 85 |
+
def __init__(self, config: TalkieConfig, layer_idx: int):
|
| 86 |
+
super().__init__()
|
| 87 |
+
self.config = config
|
| 88 |
+
self.layer_idx = layer_idx
|
| 89 |
+
self.n_head = config.n_head
|
| 90 |
+
self.head_dim = config.head_dim
|
| 91 |
+
n_state = config.n_embd
|
| 92 |
+
|
| 93 |
+
self.attn_query = nn.Linear(n_state, n_state, bias=False)
|
| 94 |
+
self.attn_key = nn.Linear(n_state, n_state, bias=False)
|
| 95 |
+
self.attn_value = nn.Linear(n_state, n_state, bias=False)
|
| 96 |
+
self.attn_resid = nn.Linear(n_state, n_state, bias=False)
|
| 97 |
+
self.head_gain = HeadGain(config.n_head)
|
| 98 |
+
|
| 99 |
+
def forward(
|
| 100 |
+
self,
|
| 101 |
+
x: torch.Tensor,
|
| 102 |
+
cos_sin: tuple[torch.Tensor, torch.Tensor],
|
| 103 |
+
attention_mask: torch.Tensor | None = None,
|
| 104 |
+
**kwargs,
|
| 105 |
+
) -> torch.Tensor:
|
| 106 |
+
bsz, seq_len, _ = x.size()
|
| 107 |
+
q = self.attn_query(x).view(bsz, seq_len, self.n_head, self.head_dim)
|
| 108 |
+
k = self.attn_key(x).view(bsz, seq_len, self.n_head, self.head_dim)
|
| 109 |
+
v = self.attn_value(x).view(bsz, seq_len, self.n_head, self.head_dim)
|
| 110 |
+
|
| 111 |
+
cos, sin = cos_sin
|
| 112 |
+
q, k = apply_rotary_emb(q, cos, sin), apply_rotary_emb(k, cos, sin)
|
| 113 |
+
q, k = F.rms_norm(q, (q.size(-1),)), F.rms_norm(k, (k.size(-1),))
|
| 114 |
+
q = self.head_gain(q)
|
| 115 |
+
|
| 116 |
+
key_states = k.transpose(1, 2)
|
| 117 |
+
value_states = v.transpose(1, 2)
|
| 118 |
+
if kwargs.get("past_key_values") is not None:
|
| 119 |
+
key_states, value_states = kwargs["past_key_values"].update(
|
| 120 |
+
key_states, value_states, self.layer_idx
|
| 121 |
+
)
|
| 122 |
+
|
| 123 |
+
if ALL_ATTENTION_FUNCTIONS is None:
|
| 124 |
+
attention_interface = eager_attention_forward
|
| 125 |
+
elif hasattr(ALL_ATTENTION_FUNCTIONS, "get_interface"):
|
| 126 |
+
attention_interface = ALL_ATTENTION_FUNCTIONS.get_interface(
|
| 127 |
+
self.config._attn_implementation, eager_attention_forward
|
| 128 |
+
)
|
| 129 |
+
else: # pragma: no cover - compatibility with older Transformers.
|
| 130 |
+
attention_interface = ALL_ATTENTION_FUNCTIONS.get(
|
| 131 |
+
self.config._attn_implementation, eager_attention_forward
|
| 132 |
+
)
|
| 133 |
+
is_causal = attention_mask is None and key_states.shape[-2] == q.shape[1]
|
| 134 |
+
y, _ = attention_interface(
|
| 135 |
+
self,
|
| 136 |
+
q.transpose(1, 2),
|
| 137 |
+
key_states,
|
| 138 |
+
value_states,
|
| 139 |
+
attention_mask,
|
| 140 |
+
is_causal=is_causal,
|
| 141 |
+
**kwargs,
|
| 142 |
+
)
|
| 143 |
+
y = y.contiguous().view_as(x)
|
| 144 |
+
return self.attn_resid(y)
|
| 145 |
+
|
| 146 |
+
|
| 147 |
+
class MLP(nn.Module):
|
| 148 |
+
def __init__(self, config: TalkieConfig):
|
| 149 |
+
super().__init__()
|
| 150 |
+
n_state = config.n_embd
|
| 151 |
+
n_mlp = int(round(((8 / 3) * n_state) / 128) * 128)
|
| 152 |
+
|
| 153 |
+
self.mlp_gate = nn.Linear(n_state, n_mlp, bias=False)
|
| 154 |
+
self.mlp_linear = nn.Linear(n_state, n_mlp, bias=False)
|
| 155 |
+
self.mlp_resid = nn.Linear(n_mlp, n_state, bias=False)
|
| 156 |
+
|
| 157 |
+
def forward(self, x: torch.Tensor) -> torch.Tensor:
|
| 158 |
+
x = F.silu(self.mlp_gate(x)) * self.mlp_linear(x)
|
| 159 |
+
return self.mlp_resid(x)
|
| 160 |
+
|
| 161 |
+
|
| 162 |
+
class Block(nn.Module):
|
| 163 |
+
def __init__(self, config: TalkieConfig, layer_idx: int):
|
| 164 |
+
super().__init__()
|
| 165 |
+
self.attn = CausalSelfAttention(config, layer_idx)
|
| 166 |
+
self.attn_gain = ActGain((2 * config.n_layer) ** -0.5)
|
| 167 |
+
self.mlp = MLP(config)
|
| 168 |
+
self.mlp_gain = ActGain((2 * config.n_layer) ** -0.5)
|
| 169 |
+
self.embed_skip = ActGain(0.0)
|
| 170 |
+
|
| 171 |
+
def forward(
|
| 172 |
+
self,
|
| 173 |
+
e_x: torch.Tensor,
|
| 174 |
+
x: torch.Tensor,
|
| 175 |
+
cos_sin: tuple[torch.Tensor, torch.Tensor],
|
| 176 |
+
attention_mask: torch.Tensor | None = None,
|
| 177 |
+
**kwargs,
|
| 178 |
+
) -> torch.Tensor:
|
| 179 |
+
x = x + self.attn_gain(
|
| 180 |
+
self.attn(F.rms_norm(x, (x.shape[-1],)), cos_sin, attention_mask, **kwargs)
|
| 181 |
+
)
|
| 182 |
+
x = x + self.mlp_gain(self.mlp(F.rms_norm(x, (x.shape[-1],))))
|
| 183 |
+
x = x + self.embed_skip(e_x)
|
| 184 |
+
return x
|
| 185 |
+
|
| 186 |
+
|
| 187 |
+
class TalkiePreTrainedModel(PreTrainedModel):
|
| 188 |
+
config_class = TalkieConfig
|
| 189 |
+
base_model_prefix = ""
|
| 190 |
+
supports_gradient_checkpointing = True
|
| 191 |
+
_supports_sdpa = True
|
| 192 |
+
_supports_attention_backend = True
|
| 193 |
+
_no_split_modules = ["Block"]
|
| 194 |
+
_tied_weights_keys = None
|
| 195 |
+
|
| 196 |
+
def _init_weights(self, module: nn.Module) -> None:
|
| 197 |
+
return
|
| 198 |
+
|
| 199 |
+
|
| 200 |
+
class TalkieModel(TalkiePreTrainedModel, GenerationMixin):
|
| 201 |
+
def __init__(self, config: TalkieConfig):
|
| 202 |
+
super().__init__(config)
|
| 203 |
+
self.embed = nn.Embedding(config.vocab_size, config.n_embd)
|
| 204 |
+
self.blocks = nn.ModuleList([Block(config, i) for i in range(config.n_layer)])
|
| 205 |
+
self.gradient_checkpointing = False
|
| 206 |
+
|
| 207 |
+
cos, sin = self._precompute_rotary_embeddings(config.max_position_embeddings)
|
| 208 |
+
self.register_buffer("cos", cos, persistent=False)
|
| 209 |
+
self.register_buffer("sin", sin, persistent=False)
|
| 210 |
+
self._rotary_initialized = cos.device.type != "meta"
|
| 211 |
+
self.post_init()
|
| 212 |
+
|
| 213 |
+
def _apply(self, fn, recurse: bool = True):
|
| 214 |
+
for name in ("cos", "sin"):
|
| 215 |
+
buffer = self._buffers.get(name)
|
| 216 |
+
if buffer is not None and getattr(buffer, "is_meta", False):
|
| 217 |
+
self._buffers[name] = torch.empty(0, dtype=buffer.dtype)
|
| 218 |
+
self._rotary_initialized = False
|
| 219 |
+
return super()._apply(fn, recurse=recurse)
|
| 220 |
+
|
| 221 |
+
def _precompute_rotary_embeddings(
|
| 222 |
+
self,
|
| 223 |
+
seq_len: int,
|
| 224 |
+
head_dim: int | None = None,
|
| 225 |
+
base: int | float | None = None,
|
| 226 |
+
) -> tuple[torch.Tensor, torch.Tensor]:
|
| 227 |
+
device = self.embed.weight.device if hasattr(self, "embed") else "cpu"
|
| 228 |
+
head_dim = head_dim if head_dim is not None else self.config.head_dim
|
| 229 |
+
base = base if base is not None else self.config.rope_base
|
| 230 |
+
inv_freq, attention_factor = self._rotary_inv_freq(seq_len, head_dim, float(base), device)
|
| 231 |
+
t = torch.arange(seq_len, dtype=torch.float32, device=device)
|
| 232 |
+
freqs = torch.outer(t, inv_freq)
|
| 233 |
+
cos, sin = freqs.cos(), freqs.sin()
|
| 234 |
+
if attention_factor != 1.0:
|
| 235 |
+
cos = cos * attention_factor
|
| 236 |
+
sin = sin * attention_factor
|
| 237 |
+
cos, sin = cos.bfloat16(), sin.bfloat16()
|
| 238 |
+
cos, sin = cos[None, :, None, :], sin[None, :, None, :]
|
| 239 |
+
return cos, sin
|
| 240 |
+
|
| 241 |
+
def _rotary_inv_freq(
|
| 242 |
+
self,
|
| 243 |
+
seq_len: int,
|
| 244 |
+
head_dim: int,
|
| 245 |
+
base: float,
|
| 246 |
+
device: torch.device | str,
|
| 247 |
+
) -> tuple[torch.Tensor, float]:
|
| 248 |
+
scaling = self.config.rope_scaling
|
| 249 |
+
rope_type = scaling.get("rope_type") if scaling else None
|
| 250 |
+
if rope_type in (None, "default"):
|
| 251 |
+
return self._default_rotary_inv_freq(head_dim, base, device), 1.0
|
| 252 |
+
if rope_type == "linear":
|
| 253 |
+
inv_freq = self._default_rotary_inv_freq(head_dim, base, device)
|
| 254 |
+
return inv_freq / float(scaling["factor"]), 1.0
|
| 255 |
+
if rope_type == "dynamic":
|
| 256 |
+
return self._dynamic_rotary_inv_freq(seq_len, head_dim, base, device, scaling), 1.0
|
| 257 |
+
if rope_type == "yarn":
|
| 258 |
+
return self._yarn_rotary_inv_freq(head_dim, base, device, scaling)
|
| 259 |
+
raise ValueError(f"unsupported rope_scaling type {rope_type!r}")
|
| 260 |
+
|
| 261 |
+
@staticmethod
|
| 262 |
+
def _default_rotary_inv_freq(
|
| 263 |
+
head_dim: int, base: float, device: torch.device | str
|
| 264 |
+
) -> torch.Tensor:
|
| 265 |
+
channel_range = torch.arange(0, head_dim, 2, dtype=torch.float32, device=device)
|
| 266 |
+
return 1.0 / (base ** (channel_range / head_dim))
|
| 267 |
+
|
| 268 |
+
def _original_max_position_embeddings(self, scaling: dict | None) -> int:
|
| 269 |
+
if scaling and "original_max_position_embeddings" in scaling:
|
| 270 |
+
return int(scaling["original_max_position_embeddings"])
|
| 271 |
+
return int(self.config.max_position_embeddings)
|
| 272 |
+
|
| 273 |
+
def _dynamic_rotary_inv_freq(
|
| 274 |
+
self,
|
| 275 |
+
seq_len: int,
|
| 276 |
+
head_dim: int,
|
| 277 |
+
base: float,
|
| 278 |
+
device: torch.device | str,
|
| 279 |
+
scaling: dict,
|
| 280 |
+
) -> torch.Tensor:
|
| 281 |
+
original_max_position_embeddings = self._original_max_position_embeddings(scaling)
|
| 282 |
+
scaled_seq_len = max(seq_len, original_max_position_embeddings)
|
| 283 |
+
factor = float(scaling["factor"])
|
| 284 |
+
base = base * (
|
| 285 |
+
(factor * scaled_seq_len / original_max_position_embeddings) - (factor - 1.0)
|
| 286 |
+
) ** (head_dim / (head_dim - 2.0))
|
| 287 |
+
return self._default_rotary_inv_freq(head_dim, base, device)
|
| 288 |
+
|
| 289 |
+
def _yarn_rotary_inv_freq(
|
| 290 |
+
self,
|
| 291 |
+
head_dim: int,
|
| 292 |
+
base: float,
|
| 293 |
+
device: torch.device | str,
|
| 294 |
+
scaling: dict,
|
| 295 |
+
) -> tuple[torch.Tensor, float]:
|
| 296 |
+
factor = float(scaling["factor"])
|
| 297 |
+
original_max_position_embeddings = self._original_max_position_embeddings(scaling)
|
| 298 |
+
beta_fast = float(scaling.get("beta_fast", 32.0))
|
| 299 |
+
beta_slow = float(scaling.get("beta_slow", 1.0))
|
| 300 |
+
attention_factor = scaling.get("attention_factor")
|
| 301 |
+
if attention_factor is None:
|
| 302 |
+
attention_factor = 1.0 if factor <= 1.0 else 0.1 * math.log(factor) + 1.0
|
| 303 |
+
|
| 304 |
+
channel_range = torch.arange(0, head_dim, 2, dtype=torch.float32, device=device)
|
| 305 |
+
pos_freqs = base ** (channel_range / head_dim)
|
| 306 |
+
inv_freq_extrapolation = 1.0 / pos_freqs
|
| 307 |
+
inv_freq_interpolation = 1.0 / (factor * pos_freqs)
|
| 308 |
+
|
| 309 |
+
low, high = self._yarn_correction_range(
|
| 310 |
+
beta_fast,
|
| 311 |
+
beta_slow,
|
| 312 |
+
head_dim,
|
| 313 |
+
base,
|
| 314 |
+
original_max_position_embeddings,
|
| 315 |
+
truncate=bool(scaling.get("truncate", True)),
|
| 316 |
+
)
|
| 317 |
+
ramp = self._yarn_linear_ramp(low, high, head_dim // 2, device)
|
| 318 |
+
extrapolation_factor = 1.0 - ramp
|
| 319 |
+
inv_freq = (
|
| 320 |
+
inv_freq_interpolation * (1.0 - extrapolation_factor)
|
| 321 |
+
+ inv_freq_extrapolation * extrapolation_factor
|
| 322 |
+
)
|
| 323 |
+
return inv_freq, float(attention_factor)
|
| 324 |
+
|
| 325 |
+
@staticmethod
|
| 326 |
+
def _yarn_correction_range(
|
| 327 |
+
low_rot: float,
|
| 328 |
+
high_rot: float,
|
| 329 |
+
head_dim: int,
|
| 330 |
+
base: float,
|
| 331 |
+
original_max_position_embeddings: int,
|
| 332 |
+
truncate: bool,
|
| 333 |
+
) -> tuple[float, float]:
|
| 334 |
+
def correction_dim(num_rotations: float) -> float:
|
| 335 |
+
return (
|
| 336 |
+
head_dim
|
| 337 |
+
* math.log(original_max_position_embeddings / (num_rotations * 2.0 * math.pi))
|
| 338 |
+
/ (2.0 * math.log(base))
|
| 339 |
+
)
|
| 340 |
+
|
| 341 |
+
low = correction_dim(low_rot)
|
| 342 |
+
high = correction_dim(high_rot)
|
| 343 |
+
if truncate:
|
| 344 |
+
low = math.floor(low)
|
| 345 |
+
high = math.ceil(high)
|
| 346 |
+
return max(low, 0.0), min(high, float(head_dim - 1))
|
| 347 |
+
|
| 348 |
+
@staticmethod
|
| 349 |
+
def _yarn_linear_ramp(
|
| 350 |
+
low: float,
|
| 351 |
+
high: float,
|
| 352 |
+
dim: int,
|
| 353 |
+
device: torch.device | str,
|
| 354 |
+
) -> torch.Tensor:
|
| 355 |
+
if low == high:
|
| 356 |
+
high += 0.001
|
| 357 |
+
ramp = (torch.arange(dim, dtype=torch.float32, device=device) - low) / (high - low)
|
| 358 |
+
return torch.clamp(ramp, 0.0, 1.0)
|
| 359 |
+
|
| 360 |
+
def _ensure_rotary_embeddings(self, seq_len: int) -> None:
|
| 361 |
+
device = self.embed.weight.device
|
| 362 |
+
needs_init = (
|
| 363 |
+
not self._rotary_initialized
|
| 364 |
+
or self.cos.device != device
|
| 365 |
+
or self.sin.device != device
|
| 366 |
+
or self.cos.shape[1] < seq_len
|
| 367 |
+
)
|
| 368 |
+
if needs_init:
|
| 369 |
+
max_seq_len = max(seq_len, self.config.max_position_embeddings)
|
| 370 |
+
cos, sin = self._precompute_rotary_embeddings(max_seq_len)
|
| 371 |
+
self.cos = cos.to(device=device)
|
| 372 |
+
self.sin = sin.to(device=device)
|
| 373 |
+
self._rotary_initialized = True
|
| 374 |
+
|
| 375 |
+
def reset_rotary_embeddings(self) -> None:
|
| 376 |
+
self._rotary_initialized = False
|
| 377 |
+
|
| 378 |
+
def get_input_embeddings(self) -> nn.Embedding:
|
| 379 |
+
return self.embed
|
| 380 |
+
|
| 381 |
+
def set_input_embeddings(self, value: nn.Embedding) -> None:
|
| 382 |
+
self.embed = value
|
| 383 |
+
|
| 384 |
+
def _position_ids(
|
| 385 |
+
self,
|
| 386 |
+
input_ids: torch.LongTensor,
|
| 387 |
+
position_ids: torch.LongTensor | None = None,
|
| 388 |
+
cache_position: torch.LongTensor | None = None,
|
| 389 |
+
past_key_values: Cache | None = None,
|
| 390 |
+
) -> torch.LongTensor:
|
| 391 |
+
batch_size, seq_len = input_ids.shape
|
| 392 |
+
if position_ids is not None:
|
| 393 |
+
if position_ids.dim() == 1:
|
| 394 |
+
position_ids = position_ids.unsqueeze(0)
|
| 395 |
+
return position_ids.to(device=input_ids.device, dtype=torch.long)
|
| 396 |
+
if cache_position is not None:
|
| 397 |
+
if cache_position.dim() == 1:
|
| 398 |
+
cache_position = cache_position.unsqueeze(0)
|
| 399 |
+
if cache_position.shape[0] == 1 and batch_size != 1:
|
| 400 |
+
cache_position = cache_position.expand(batch_size, -1)
|
| 401 |
+
return cache_position.to(device=input_ids.device, dtype=torch.long)
|
| 402 |
+
past_seen = past_key_values.get_seq_length() if past_key_values is not None else 0
|
| 403 |
+
position_ids = torch.arange(seq_len, device=input_ids.device, dtype=torch.long) + past_seen
|
| 404 |
+
return position_ids.unsqueeze(0).expand(batch_size, -1)
|
| 405 |
+
|
| 406 |
+
def _attention_mask(
|
| 407 |
+
self,
|
| 408 |
+
attention_mask: torch.Tensor | None,
|
| 409 |
+
input_ids: torch.Tensor,
|
| 410 |
+
position_ids: torch.Tensor,
|
| 411 |
+
past_key_values: Cache | None,
|
| 412 |
+
dtype: torch.dtype,
|
| 413 |
+
) -> torch.Tensor | None:
|
| 414 |
+
if attention_mask is not None and attention_mask.dim() >= 4:
|
| 415 |
+
return attention_mask
|
| 416 |
+
batch_size, query_length = input_ids.shape
|
| 417 |
+
past_seen = past_key_values.get_seq_length() if past_key_values is not None else 0
|
| 418 |
+
|
| 419 |
+
if attention_mask is not None and attention_mask.dim() != 2:
|
| 420 |
+
return attention_mask
|
| 421 |
+
if attention_mask is None and past_seen == 0:
|
| 422 |
+
return None
|
| 423 |
+
|
| 424 |
+
key_length = past_seen + query_length
|
| 425 |
+
if attention_mask is not None:
|
| 426 |
+
if attention_mask.shape[-1] == query_length and past_seen:
|
| 427 |
+
prefix = torch.ones(
|
| 428 |
+
attention_mask.shape[0],
|
| 429 |
+
past_seen,
|
| 430 |
+
dtype=attention_mask.dtype,
|
| 431 |
+
device=attention_mask.device,
|
| 432 |
+
)
|
| 433 |
+
attention_mask = torch.cat([prefix, attention_mask], dim=-1)
|
| 434 |
+
key_length = attention_mask.shape[-1]
|
| 435 |
+
|
| 436 |
+
key_positions = torch.arange(key_length, device=input_ids.device, dtype=torch.long)
|
| 437 |
+
future_mask = key_positions.view(1, 1, 1, key_length) > position_ids.view(
|
| 438 |
+
batch_size, 1, query_length, 1
|
| 439 |
+
)
|
| 440 |
+
if attention_mask is not None:
|
| 441 |
+
padding_mask = attention_mask[:, None, None, :].to(device=input_ids.device) == 0
|
| 442 |
+
mask = future_mask | padding_mask
|
| 443 |
+
else:
|
| 444 |
+
mask = future_mask
|
| 445 |
+
|
| 446 |
+
min_value = torch.finfo(dtype).min
|
| 447 |
+
causal_mask = torch.zeros(
|
| 448 |
+
batch_size, 1, query_length, key_length, dtype=dtype, device=input_ids.device
|
| 449 |
+
)
|
| 450 |
+
return causal_mask.masked_fill(mask, min_value)
|
| 451 |
+
|
| 452 |
+
def forward(
|
| 453 |
+
self,
|
| 454 |
+
input_ids: torch.LongTensor | None = None,
|
| 455 |
+
inputs_embeds: torch.FloatTensor | None = None,
|
| 456 |
+
attention_mask: torch.Tensor | None = None,
|
| 457 |
+
position_ids: torch.LongTensor | None = None,
|
| 458 |
+
past_key_values: Cache | None = None,
|
| 459 |
+
use_cache: bool | None = None,
|
| 460 |
+
return_dict: bool | None = None,
|
| 461 |
+
**kwargs,
|
| 462 |
+
) -> BaseModelOutputWithPast | tuple[torch.Tensor, ...]:
|
| 463 |
+
cache_position = kwargs.pop("cache_position", None)
|
| 464 |
+
if input_ids is None and inputs_embeds is None:
|
| 465 |
+
raise ValueError("input_ids or inputs_embeds is required")
|
| 466 |
+
if input_ids is not None and inputs_embeds is not None:
|
| 467 |
+
raise ValueError("provide only one of input_ids or inputs_embeds")
|
| 468 |
+
if input_ids is None:
|
| 469 |
+
input_ids = torch.empty(
|
| 470 |
+
inputs_embeds.shape[:2],
|
| 471 |
+
dtype=torch.long,
|
| 472 |
+
device=inputs_embeds.device,
|
| 473 |
+
)
|
| 474 |
+
use_cache = use_cache if use_cache is not None else self.config.use_cache
|
| 475 |
+
if self.gradient_checkpointing and self.training:
|
| 476 |
+
use_cache = False
|
| 477 |
+
if use_cache and past_key_values is None:
|
| 478 |
+
past_key_values = DynamicCache(config=self.config)
|
| 479 |
+
|
| 480 |
+
position_ids = self._position_ids(input_ids, position_ids, cache_position, past_key_values)
|
| 481 |
+
# Keep graph capture free of CUDA tensor -> Python scalar syncs. The
|
| 482 |
+
# configured context length is the static serving/training contract.
|
| 483 |
+
self._ensure_rotary_embeddings(int(self.config.max_position_embeddings))
|
| 484 |
+
|
| 485 |
+
cos = self.cos[0, position_ids, :, :]
|
| 486 |
+
sin = self.sin[0, position_ids, :, :]
|
| 487 |
+
cos_sin = cos, sin
|
| 488 |
+
x = inputs_embeds if inputs_embeds is not None else self.embed(input_ids)
|
| 489 |
+
x = F.rms_norm(x, (x.shape[-1],))
|
| 490 |
+
attention_mask = self._attention_mask(attention_mask, input_ids, position_ids, past_key_values, x.dtype)
|
| 491 |
+
e_x = x
|
| 492 |
+
for block in self.blocks:
|
| 493 |
+
if self.gradient_checkpointing and self.training:
|
| 494 |
+
def custom_forward(
|
| 495 |
+
e_x: torch.Tensor,
|
| 496 |
+
x: torch.Tensor,
|
| 497 |
+
cos: torch.Tensor,
|
| 498 |
+
sin: torch.Tensor,
|
| 499 |
+
attention_mask: torch.Tensor | None,
|
| 500 |
+
block: Block = block,
|
| 501 |
+
) -> torch.Tensor:
|
| 502 |
+
return block(e_x, x, (cos, sin), attention_mask=attention_mask)
|
| 503 |
+
|
| 504 |
+
x = self._gradient_checkpointing_func(
|
| 505 |
+
custom_forward,
|
| 506 |
+
e_x,
|
| 507 |
+
x,
|
| 508 |
+
cos,
|
| 509 |
+
sin,
|
| 510 |
+
attention_mask,
|
| 511 |
+
)
|
| 512 |
+
else:
|
| 513 |
+
x = block(
|
| 514 |
+
e_x,
|
| 515 |
+
x,
|
| 516 |
+
cos_sin,
|
| 517 |
+
attention_mask=attention_mask,
|
| 518 |
+
past_key_values=past_key_values if use_cache else None,
|
| 519 |
+
**kwargs,
|
| 520 |
+
)
|
| 521 |
+
x = F.rms_norm(x, (x.shape[-1],))
|
| 522 |
+
past_key_values = past_key_values if use_cache else None
|
| 523 |
+
use_return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
| 524 |
+
if use_return_dict:
|
| 525 |
+
return BaseModelOutputWithPast(last_hidden_state=x, past_key_values=past_key_values)
|
| 526 |
+
output = (x,)
|
| 527 |
+
return output + ((past_key_values,) if past_key_values is not None else ())
|
| 528 |
+
|
| 529 |
+
|
| 530 |
+
class TalkieForCausalLM(TalkieModel):
|
| 531 |
+
_tied_weights_keys = None
|
| 532 |
+
|
| 533 |
+
def __init__(self, config: TalkieConfig):
|
| 534 |
+
super().__init__(config)
|
| 535 |
+
self.lm_head = nn.Linear(config.n_embd, config.vocab_size, bias=False)
|
| 536 |
+
self.post_init()
|
| 537 |
+
|
| 538 |
+
def get_output_embeddings(self) -> nn.Linear:
|
| 539 |
+
return self.lm_head
|
| 540 |
+
|
| 541 |
+
def set_output_embeddings(self, value: nn.Linear) -> None:
|
| 542 |
+
self.lm_head = value
|
| 543 |
+
|
| 544 |
+
def _chunked_lm_loss(
|
| 545 |
+
self,
|
| 546 |
+
hidden_states: torch.Tensor,
|
| 547 |
+
labels: torch.Tensor,
|
| 548 |
+
chunk_size: int,
|
| 549 |
+
) -> torch.Tensor:
|
| 550 |
+
if chunk_size <= 0:
|
| 551 |
+
raise ValueError("chunk_size must be positive")
|
| 552 |
+
|
| 553 |
+
total_loss = hidden_states.new_zeros((), dtype=torch.float32)
|
| 554 |
+
total_tokens = hidden_states.new_zeros((), dtype=torch.float32)
|
| 555 |
+
for start in range(0, hidden_states.shape[1], chunk_size):
|
| 556 |
+
end = min(start + chunk_size, hidden_states.shape[1])
|
| 557 |
+
logits = self.lm_head(hidden_states[:, start:end, :]).float()
|
| 558 |
+
if self.config.logit_scale != 1.0:
|
| 559 |
+
logits = logits * self.config.logit_scale
|
| 560 |
+
chunk_labels = labels[:, start:end].contiguous()
|
| 561 |
+
total_loss = total_loss + F.cross_entropy(
|
| 562 |
+
logits.reshape(-1, logits.size(-1)),
|
| 563 |
+
chunk_labels.reshape(-1),
|
| 564 |
+
ignore_index=-100,
|
| 565 |
+
reduction="sum",
|
| 566 |
+
)
|
| 567 |
+
total_tokens = total_tokens + (chunk_labels != -100).sum(dtype=torch.float32)
|
| 568 |
+
return total_loss / total_tokens.clamp_min(1.0)
|
| 569 |
+
|
| 570 |
+
def forward(
|
| 571 |
+
self,
|
| 572 |
+
input_ids: torch.LongTensor | None = None,
|
| 573 |
+
attention_mask: torch.Tensor | None = None,
|
| 574 |
+
inputs_embeds: torch.FloatTensor | None = None,
|
| 575 |
+
labels: torch.LongTensor | None = None,
|
| 576 |
+
return_dict: bool | None = None,
|
| 577 |
+
past_key_values: Cache | None = None,
|
| 578 |
+
use_cache: bool | None = None,
|
| 579 |
+
position_ids: torch.LongTensor | None = None,
|
| 580 |
+
logits_to_keep: int | torch.Tensor = 0,
|
| 581 |
+
loss_chunk_size: int = 0,
|
| 582 |
+
return_logits: bool = True,
|
| 583 |
+
**kwargs,
|
| 584 |
+
) -> CausalLMOutputWithPast | tuple[torch.Tensor, ...]:
|
| 585 |
+
if input_ids is None and inputs_embeds is None:
|
| 586 |
+
raise ValueError("input_ids or inputs_embeds is required")
|
| 587 |
+
cache_position = kwargs.pop("cache_position", None)
|
| 588 |
+
outputs = super().forward(
|
| 589 |
+
input_ids,
|
| 590 |
+
inputs_embeds=inputs_embeds,
|
| 591 |
+
attention_mask=attention_mask,
|
| 592 |
+
position_ids=position_ids,
|
| 593 |
+
past_key_values=past_key_values,
|
| 594 |
+
use_cache=use_cache,
|
| 595 |
+
cache_position=cache_position,
|
| 596 |
+
return_dict=True,
|
| 597 |
+
**kwargs,
|
| 598 |
+
)
|
| 599 |
+
hidden_states = outputs.last_hidden_state
|
| 600 |
+
loss = None
|
| 601 |
+
logits = None
|
| 602 |
+
if labels is not None and loss_chunk_size > 0:
|
| 603 |
+
loss = self._chunked_lm_loss(
|
| 604 |
+
hidden_states[:, :-1, :],
|
| 605 |
+
labels[:, 1:],
|
| 606 |
+
loss_chunk_size,
|
| 607 |
+
)
|
| 608 |
+
if return_logits:
|
| 609 |
+
slice_indices = slice(-logits_to_keep, None) if isinstance(logits_to_keep, int) else logits_to_keep
|
| 610 |
+
logits = self.lm_head(hidden_states[:, slice_indices, :]).float()
|
| 611 |
+
if self.config.logit_scale != 1.0:
|
| 612 |
+
logits = logits * self.config.logit_scale
|
| 613 |
+
|
| 614 |
+
if labels is not None and loss is None:
|
| 615 |
+
if logits is None:
|
| 616 |
+
raise ValueError("return_logits must be true when loss_chunk_size is not used")
|
| 617 |
+
shift_logits = logits[..., :-1, :].contiguous()
|
| 618 |
+
shift_labels = labels[..., 1:].contiguous()
|
| 619 |
+
loss = F.cross_entropy(
|
| 620 |
+
shift_logits.view(-1, shift_logits.size(-1)),
|
| 621 |
+
shift_labels.view(-1),
|
| 622 |
+
ignore_index=-100,
|
| 623 |
+
)
|
| 624 |
+
|
| 625 |
+
use_return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
| 626 |
+
if use_return_dict:
|
| 627 |
+
return CausalLMOutputWithPast(
|
| 628 |
+
loss=loss,
|
| 629 |
+
logits=logits,
|
| 630 |
+
past_key_values=outputs.past_key_values,
|
| 631 |
+
)
|
| 632 |
+
output = (logits,)
|
| 633 |
+
if outputs.past_key_values is not None:
|
| 634 |
+
output += (outputs.past_key_values,)
|
| 635 |
+
return ((loss,) + output) if loss is not None else output
|
| 636 |
+
|
| 637 |
+
|
| 638 |
+
__all__ = ["TalkieConfig", "TalkieForCausalLM", "TalkieModel"]
|
special_tokens_map.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"eos_token": "<|endoftext|>"
|
| 3 |
+
}
|
tokenization_talkie.py
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
import os
|
| 4 |
+
import shutil
|
| 5 |
+
from pathlib import Path
|
| 6 |
+
|
| 7 |
+
import tiktoken
|
| 8 |
+
from tiktoken.load import load_tiktoken_bpe
|
| 9 |
+
from transformers import PreTrainedTokenizer
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
BASE_VOCAB_SIZE = 65536
|
| 13 |
+
IT_VOCAB_SIZE = BASE_VOCAB_SIZE + 4
|
| 14 |
+
|
| 15 |
+
_PAT_STR = "|".join(
|
| 16 |
+
[
|
| 17 |
+
r"""[^\r\n\p{L}\p{N}]?[\p{Lu}\p{Lt}\p{Lm}\p{Lo}\p{M}]*[\p{Ll}\p{Lm}\p{Lo}\p{M}]+(?i:'s|'t|'re|'ve|'m|'ll|'d)?""",
|
| 18 |
+
r"""[^\r\n\p{L}\p{N}]?[\p{Lu}\p{Lt}\p{Lm}\p{Lo}\p{M}]+[\p{Ll}\p{Lm}\p{Lo}\p{M}]*(?i:'s|'t|'re|'ve|'m|'ll|'d)?""",
|
| 19 |
+
r"""\p{N}{1,3}""",
|
| 20 |
+
r""" ?[^\s\p{L}\p{N}]+[\r\n/]*""",
|
| 21 |
+
r"""\s*[\r\n]+""",
|
| 22 |
+
r"""\s+(?!\S)""",
|
| 23 |
+
r"""\s+""",
|
| 24 |
+
]
|
| 25 |
+
)
|
| 26 |
+
|
| 27 |
+
_BASE_SPECIAL_TOKENS = {
|
| 28 |
+
"<|endoftext|>": BASE_VOCAB_SIZE - 1,
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
_IT_SPECIAL_TOKENS = {
|
| 32 |
+
"<|endoftext|>": BASE_VOCAB_SIZE - 1,
|
| 33 |
+
"<|end|>": BASE_VOCAB_SIZE,
|
| 34 |
+
"<|user|>": BASE_VOCAB_SIZE + 1,
|
| 35 |
+
"<|assistant|>": BASE_VOCAB_SIZE + 2,
|
| 36 |
+
"<|system|>": BASE_VOCAB_SIZE + 3,
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
class TalkieTokenizer(PreTrainedTokenizer):
|
| 41 |
+
vocab_files_names = {"vocab_file": "vocab.txt"}
|
| 42 |
+
model_input_names = ["input_ids", "attention_mask"]
|
| 43 |
+
|
| 44 |
+
def __init__(
|
| 45 |
+
self,
|
| 46 |
+
vocab_file: str,
|
| 47 |
+
style: str = "base",
|
| 48 |
+
model_max_length: int = 2048,
|
| 49 |
+
**kwargs,
|
| 50 |
+
):
|
| 51 |
+
self.vocab_file = str(vocab_file)
|
| 52 |
+
self.style = style
|
| 53 |
+
|
| 54 |
+
mergeable_ranks = load_tiktoken_bpe(self.vocab_file)
|
| 55 |
+
mergeable_ranks = {
|
| 56 |
+
key: value for key, value in mergeable_ranks.items() if value < BASE_VOCAB_SIZE - 1
|
| 57 |
+
}
|
| 58 |
+
if style == "it":
|
| 59 |
+
special_tokens = dict(_IT_SPECIAL_TOKENS)
|
| 60 |
+
vocab_size = IT_VOCAB_SIZE
|
| 61 |
+
name = "talkie-it"
|
| 62 |
+
elif style == "base":
|
| 63 |
+
special_tokens = dict(_BASE_SPECIAL_TOKENS)
|
| 64 |
+
vocab_size = BASE_VOCAB_SIZE
|
| 65 |
+
name = "talkie-base"
|
| 66 |
+
else:
|
| 67 |
+
raise ValueError(f"unknown Talkie tokenizer style: {style!r}")
|
| 68 |
+
|
| 69 |
+
self.encoder = tiktoken.Encoding(
|
| 70 |
+
name=name,
|
| 71 |
+
pat_str=_PAT_STR,
|
| 72 |
+
mergeable_ranks=mergeable_ranks,
|
| 73 |
+
special_tokens=special_tokens,
|
| 74 |
+
)
|
| 75 |
+
self._vocab_size = vocab_size
|
| 76 |
+
self._special_token_to_id = special_tokens
|
| 77 |
+
self._id_to_special_token = {value: key for key, value in special_tokens.items()}
|
| 78 |
+
|
| 79 |
+
if style == "it":
|
| 80 |
+
kwargs.setdefault("eos_token", "<|end|>")
|
| 81 |
+
kwargs.setdefault(
|
| 82 |
+
"additional_special_tokens",
|
| 83 |
+
["<|endoftext|>", "<|user|>", "<|assistant|>", "<|system|>"],
|
| 84 |
+
)
|
| 85 |
+
else:
|
| 86 |
+
kwargs.setdefault("eos_token", "<|endoftext|>")
|
| 87 |
+
super().__init__(model_max_length=model_max_length, **kwargs)
|
| 88 |
+
|
| 89 |
+
@property
|
| 90 |
+
def vocab_size(self) -> int:
|
| 91 |
+
return self._vocab_size
|
| 92 |
+
|
| 93 |
+
def get_vocab(self) -> dict[str, int]:
|
| 94 |
+
vocab = {str(index): index for index in range(self._vocab_size)}
|
| 95 |
+
vocab.update(self._special_token_to_id)
|
| 96 |
+
vocab.update(self.get_added_vocab())
|
| 97 |
+
return vocab
|
| 98 |
+
|
| 99 |
+
def _tokenize(self, text: str, **kwargs) -> list[str]:
|
| 100 |
+
return [str(token_id) for token_id in self.encoder.encode(text, allowed_special="all")]
|
| 101 |
+
|
| 102 |
+
def _convert_token_to_id(self, token: str) -> int:
|
| 103 |
+
if token in self._special_token_to_id:
|
| 104 |
+
return self._special_token_to_id[token]
|
| 105 |
+
try:
|
| 106 |
+
token_id = int(token)
|
| 107 |
+
except ValueError:
|
| 108 |
+
return self.eos_token_id
|
| 109 |
+
if 0 <= token_id < self._vocab_size:
|
| 110 |
+
return token_id
|
| 111 |
+
return self.eos_token_id
|
| 112 |
+
|
| 113 |
+
def _convert_id_to_token(self, index: int) -> str:
|
| 114 |
+
index = int(index)
|
| 115 |
+
return self._id_to_special_token.get(index, str(index))
|
| 116 |
+
|
| 117 |
+
def convert_tokens_to_string(self, tokens: list[str]) -> str:
|
| 118 |
+
ids = [self._convert_token_to_id(token) for token in tokens]
|
| 119 |
+
return self.encoder.decode(ids)
|
| 120 |
+
|
| 121 |
+
def _decode(
|
| 122 |
+
self,
|
| 123 |
+
token_ids,
|
| 124 |
+
skip_special_tokens: bool = False,
|
| 125 |
+
clean_up_tokenization_spaces: bool | None = None,
|
| 126 |
+
**kwargs,
|
| 127 |
+
) -> str:
|
| 128 |
+
if isinstance(token_ids, int):
|
| 129 |
+
token_ids = [token_ids]
|
| 130 |
+
ids = [int(token_id) for token_id in token_ids]
|
| 131 |
+
if skip_special_tokens:
|
| 132 |
+
specials = set(self._special_token_to_id.values())
|
| 133 |
+
ids = [token_id for token_id in ids if token_id not in specials]
|
| 134 |
+
return self.encoder.decode(ids)
|
| 135 |
+
|
| 136 |
+
def build_inputs_with_special_tokens(
|
| 137 |
+
self, token_ids_0: list[int], token_ids_1: list[int] | None = None
|
| 138 |
+
) -> list[int]:
|
| 139 |
+
if token_ids_1 is None:
|
| 140 |
+
return list(token_ids_0)
|
| 141 |
+
return list(token_ids_0) + list(token_ids_1)
|
| 142 |
+
|
| 143 |
+
def get_special_tokens_mask(
|
| 144 |
+
self,
|
| 145 |
+
token_ids_0: list[int],
|
| 146 |
+
token_ids_1: list[int] | None = None,
|
| 147 |
+
already_has_special_tokens: bool = False,
|
| 148 |
+
) -> list[int]:
|
| 149 |
+
special_ids = set(self._special_token_to_id.values())
|
| 150 |
+
if already_has_special_tokens:
|
| 151 |
+
return [1 if token_id in special_ids else 0 for token_id in token_ids_0]
|
| 152 |
+
token_ids = list(token_ids_0) if token_ids_1 is None else list(token_ids_0) + list(token_ids_1)
|
| 153 |
+
return [1 if token_id in special_ids else 0 for token_id in token_ids]
|
| 154 |
+
|
| 155 |
+
def create_token_type_ids_from_sequences(
|
| 156 |
+
self, token_ids_0: list[int], token_ids_1: list[int] | None = None
|
| 157 |
+
) -> list[int]:
|
| 158 |
+
length = len(token_ids_0) if token_ids_1 is None else len(token_ids_0) + len(token_ids_1)
|
| 159 |
+
return [0] * length
|
| 160 |
+
|
| 161 |
+
def save_vocabulary(self, save_directory: str, filename_prefix: str | None = None):
|
| 162 |
+
if not os.path.isdir(save_directory):
|
| 163 |
+
raise ValueError(f"Vocabulary path {save_directory!r} is not a directory")
|
| 164 |
+
name = "vocab.txt" if filename_prefix is None else f"{filename_prefix}-vocab.txt"
|
| 165 |
+
out = Path(save_directory) / name
|
| 166 |
+
if Path(self.vocab_file).resolve() != out.resolve():
|
| 167 |
+
shutil.copyfile(self.vocab_file, out)
|
| 168 |
+
return (str(out),)
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"added_tokens_decoder": {
|
| 3 |
+
"65535": {
|
| 4 |
+
"content": "<|endoftext|>",
|
| 5 |
+
"lstrip": false,
|
| 6 |
+
"normalized": false,
|
| 7 |
+
"rstrip": false,
|
| 8 |
+
"single_word": false,
|
| 9 |
+
"special": true
|
| 10 |
+
}
|
| 11 |
+
},
|
| 12 |
+
"auto_map": {
|
| 13 |
+
"AutoTokenizer": [
|
| 14 |
+
"tokenization_talkie.TalkieTokenizer",
|
| 15 |
+
null
|
| 16 |
+
]
|
| 17 |
+
},
|
| 18 |
+
"clean_up_tokenization_spaces": false,
|
| 19 |
+
"eos_token": "<|endoftext|>",
|
| 20 |
+
"extra_special_tokens": {},
|
| 21 |
+
"model_max_length": 9223372036854775807,
|
| 22 |
+
"tokenizer_class": "TalkieTokenizer"
|
| 23 |
+
}
|
vocab.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|