update model 39B
Browse files- config.json +26 -0
- configuration_geov.py +111 -0
- generation_config.json +6 -0
- modeling_geov.py +666 -0
- pytorch_model-00001-of-00010.bin +3 -0
- pytorch_model-00002-of-00010.bin +3 -0
- pytorch_model-00003-of-00010.bin +3 -0
- pytorch_model-00004-of-00010.bin +3 -0
- pytorch_model-00005-of-00010.bin +3 -0
- pytorch_model-00006-of-00010.bin +3 -0
- pytorch_model-00007-of-00010.bin +3 -0
- pytorch_model-00008-of-00010.bin +3 -0
- pytorch_model-00009-of-00010.bin +3 -0
- pytorch_model-00010-of-00010.bin +3 -0
- pytorch_model.bin.index.json +396 -0
- special_tokens_map.json +5 -0
- spiece.model +3 -0
- tokenization_geov.py +177 -0
- tokenizer_config.json +14 -0
config.json
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"architectures": [
|
3 |
+
"GeoVForCausalLM"
|
4 |
+
],
|
5 |
+
"auto_map": {
|
6 |
+
"AutoConfig": "configuration_geov.GeoVConfig",
|
7 |
+
"AutoModelForCausalLM": "modeling_geov.GeoVForCausalLM"
|
8 |
+
},
|
9 |
+
"bos_token_id": 0,
|
10 |
+
"eos_token_id": 2,
|
11 |
+
"hidden_size": 5120,
|
12 |
+
"intermediate_size": 20480,
|
13 |
+
"layer_norm_eps": 0.0001,
|
14 |
+
"max_position_embeddings": 2048,
|
15 |
+
"model_type": "geov",
|
16 |
+
"num_attention_heads": 40,
|
17 |
+
"num_hidden_layers": 32,
|
18 |
+
"rotary_emb_base": 10000,
|
19 |
+
"tie_word_embeddings": false,
|
20 |
+
"tokenizer_class": "GeoVTokenizer",
|
21 |
+
"torch_dtype": "bfloat16",
|
22 |
+
"transformers_version": "4.28.0.dev0",
|
23 |
+
"use_cache": true,
|
24 |
+
"use_extra_biases_ffn": false,
|
25 |
+
"vocab_size": 65536
|
26 |
+
}
|
configuration_geov.py
ADDED
@@ -0,0 +1,111 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# coding=utf-8
|
2 |
+
# Copyright 2023 Better Planet Investments and labml.ai team. ALl rights reserved.
|
3 |
+
#
|
4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
+
# you may not use this file except in compliance with the License.
|
6 |
+
# You may obtain a copy of the License at
|
7 |
+
#
|
8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9 |
+
#
|
10 |
+
# Unless required by applicable law or agreed to in writing, software
|
11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13 |
+
# See the License for the specific language governing permissions and
|
14 |
+
# limitations under the License.
|
15 |
+
""" GeoV model configuration"""
|
16 |
+
from transformers.configuration_utils import PretrainedConfig
|
17 |
+
from transformers.utils import logging
|
18 |
+
|
19 |
+
logger = logging.get_logger(__name__)
|
20 |
+
|
21 |
+
GEOV_PRETRAINED_CONFIG_ARCHIVE_MAP = {
|
22 |
+
"GeoV/GeoV-9b": "https://huggingface.co/GeoV/GeoV-9b/resolve/main/config.json",
|
23 |
+
}
|
24 |
+
|
25 |
+
|
26 |
+
class GeoVConfig(PretrainedConfig):
|
27 |
+
r"""
|
28 |
+
This is the configuration class to store the configuration of a [`GeoVModel`]. It is used to instantiate a
|
29 |
+
GeoV model according to the specified arguments, defining the model architecture. Instantiating a configuration
|
30 |
+
with the defaults will yield a similar configuration to that of the GeoV
|
31 |
+
[GeoV/GeoV-9b](https://huggingface.co/GeoV/GeoV-9b) architecture.
|
32 |
+
|
33 |
+
Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
|
34 |
+
documentation from [`PretrainedConfig`] for more information.
|
35 |
+
|
36 |
+
|
37 |
+
Args:
|
38 |
+
vocab_size (`int`, *optional*, defaults to 65536):
|
39 |
+
Vocabulary size of the GeoV model. Defines the number of different tokens that can be represented by the
|
40 |
+
`inputs_ids` passed when calling [`GeoVModel`].
|
41 |
+
hidden_size (`int`, *optional*, defaults to 5120):
|
42 |
+
Dimension of the encoder layers and the pooler layer.
|
43 |
+
num_hidden_layers (`int`, *optional*, defaults to 32):
|
44 |
+
Number of hidden layers in the Transformer encoder.
|
45 |
+
num_attention_heads (`int`, *optional*, defaults to 40):
|
46 |
+
Number of attention heads for each attention layer in the Transformer encoder.
|
47 |
+
intermediate_size (`int`, *optional*, defaults to 20480):
|
48 |
+
Dimension of the "intermediate" (i.e., feed-forward) layer in the Transformer encoder.
|
49 |
+
rotary_emb_base (`int`, *optional*, defaults to 10000)
|
50 |
+
base for computing rotary embeddings frequency
|
51 |
+
max_position_embeddings (`int`, *optional*, defaults to 2048):
|
52 |
+
The maximum sequence length that this model might ever be used with. Typically set this to something large
|
53 |
+
just in case (e.g., 512 or 1024 or 2048).
|
54 |
+
layer_norm_eps (`float`, *optional*, defaults to 1e-4):
|
55 |
+
The epsilon used by the layer normalization layers.
|
56 |
+
use_cache (`bool`, *optional*, defaults to `True`):
|
57 |
+
Whether or not the model should return the last key/values attentions (not used by all models). Only
|
58 |
+
relevant if `config.is_decoder=True`.
|
59 |
+
use_extra_biases_ffn (`bool`, *optional*, defaults to `False`):
|
60 |
+
Whether or not to have extra bias parameters in the final layer of FFN modules.
|
61 |
+
Example:
|
62 |
+
|
63 |
+
```python
|
64 |
+
>>> from transformers import GeoVConfig, GeoVModel
|
65 |
+
|
66 |
+
>>> # Initializing a GeoV configuration
|
67 |
+
>>> configuration = GeoVConfig()
|
68 |
+
|
69 |
+
>>> # Initializing a model (with random weights) from the configuration
|
70 |
+
>>> model = GeoVModel(configuration) # doctest: +SKIP
|
71 |
+
|
72 |
+
>>> # Accessing the model configuration
|
73 |
+
>>> configuration = model.config # doctest: +SKIP
|
74 |
+
```"""
|
75 |
+
model_type = "geov"
|
76 |
+
|
77 |
+
def __init__(
|
78 |
+
self,
|
79 |
+
vocab_size=65_536,
|
80 |
+
hidden_size=5_120,
|
81 |
+
num_hidden_layers=32,
|
82 |
+
num_attention_heads=40,
|
83 |
+
intermediate_size=1024 * 5 * 4,
|
84 |
+
layer_norm_eps=1e-4,
|
85 |
+
rotary_emb_base=10000,
|
86 |
+
max_position_embeddings=2048,
|
87 |
+
use_extra_biases_ffn=False,
|
88 |
+
use_cache=True,
|
89 |
+
bos_token_id=0,
|
90 |
+
eos_token_id=2,
|
91 |
+
tie_word_embeddings=False,
|
92 |
+
tokenizer_class="GeoVTokenizer",
|
93 |
+
**kwargs,
|
94 |
+
):
|
95 |
+
super().__init__(
|
96 |
+
bos_token_id=bos_token_id,
|
97 |
+
eos_token_id=eos_token_id,
|
98 |
+
tie_word_embeddings=tie_word_embeddings,
|
99 |
+
tokenizer_class=tokenizer_class,
|
100 |
+
**kwargs
|
101 |
+
)
|
102 |
+
self.vocab_size = vocab_size
|
103 |
+
self.max_position_embeddings = max_position_embeddings
|
104 |
+
self.hidden_size = hidden_size
|
105 |
+
self.num_hidden_layers = num_hidden_layers
|
106 |
+
self.num_attention_heads = num_attention_heads
|
107 |
+
self.intermediate_size = intermediate_size
|
108 |
+
self.rotary_emb_base = rotary_emb_base
|
109 |
+
self.use_cache = use_cache
|
110 |
+
self.layer_norm_eps = layer_norm_eps
|
111 |
+
self.use_extra_biases_ffn = use_extra_biases_ffn
|
generation_config.json
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_from_model_config": true,
|
3 |
+
"bos_token_id": 0,
|
4 |
+
"eos_token_id": 2,
|
5 |
+
"transformers_version": "4.28.0.dev0"
|
6 |
+
}
|
modeling_geov.py
ADDED
@@ -0,0 +1,666 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# coding=utf-8
|
2 |
+
# Copyright 2022 EleutherAI The HuggingFace Inc. team. All rights reserved.
|
3 |
+
# Modifications Copyright 2023 Better Planet Investments and labml.ai team. ALl rights reserved.
|
4 |
+
#
|
5 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
+
# you may not use this file except in compliance with the License.
|
7 |
+
# You may obtain a copy of the License at
|
8 |
+
#
|
9 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10 |
+
#
|
11 |
+
# Unless required by applicable law or agreed to in writing, software
|
12 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14 |
+
# See the License for the specific language governing permissions and
|
15 |
+
# limitations under the License.
|
16 |
+
""" PyTorch GeoV model."""
|
17 |
+
import math
|
18 |
+
from typing import Optional, Tuple, Union
|
19 |
+
|
20 |
+
import torch
|
21 |
+
import torch.utils.checkpoint
|
22 |
+
from torch import nn
|
23 |
+
from torch.nn import CrossEntropyLoss
|
24 |
+
|
25 |
+
from transformers.file_utils import (
|
26 |
+
add_code_sample_docstrings,
|
27 |
+
add_start_docstrings,
|
28 |
+
add_start_docstrings_to_model_forward,
|
29 |
+
replace_return_docstrings,
|
30 |
+
)
|
31 |
+
from transformers.modeling_outputs import BaseModelOutputWithPast, CausalLMOutputWithPast
|
32 |
+
from transformers.modeling_utils import PreTrainedModel
|
33 |
+
from transformers.utils import logging
|
34 |
+
from .configuration_geov import GeoVConfig
|
35 |
+
|
36 |
+
logger = logging.get_logger(__name__)
|
37 |
+
|
38 |
+
_CHECKPOINT_FOR_DOC = "GeoV/GeoV-9b"
|
39 |
+
_REAL_CHECKPOINT_FOR_DOC = "GeoV/GeoV-9b"
|
40 |
+
_CONFIG_FOR_DOC = "GeoVConfig"
|
41 |
+
|
42 |
+
GEOV_PRETRAINED_MODEL_ARCHIVE_LIST = [
|
43 |
+
"GeoV/GeoV-9b",
|
44 |
+
# See all GeoV models at https://huggingface.co/models?filter=geov
|
45 |
+
]
|
46 |
+
|
47 |
+
|
48 |
+
class RotaryEmbedding(torch.nn.Module):
|
49 |
+
def __init__(self, dim, base=10000):
|
50 |
+
super().__init__()
|
51 |
+
inv_freq = 1.0 / (base ** (torch.arange(0, dim, 2).float() / dim))
|
52 |
+
self.register_buffer("inv_freq", inv_freq)
|
53 |
+
|
54 |
+
self.max_seq_len_cached = -1
|
55 |
+
|
56 |
+
def forward(self, x, seq_len=None):
|
57 |
+
# x: [bs, num_attention_heads, seq_len, head_size]
|
58 |
+
# This `if` block is unlikely to be run after we build sin/cos in `__init__`. Keep the logic here just in case.
|
59 |
+
if seq_len > self.max_seq_len_cached:
|
60 |
+
self.max_seq_len_cached = seq_len
|
61 |
+
t = torch.arange(self.max_seq_len_cached, device=x.device, dtype=self.inv_freq.dtype)
|
62 |
+
freqs = torch.einsum("i,j->ij", t, self.inv_freq)
|
63 |
+
# Different from paper, but it uses a different permutation in order to obtain the same calculation
|
64 |
+
emb = torch.cat((freqs, freqs), dim=-1).to(x.device)
|
65 |
+
self.cos_cached = emb.cos()[None, None, :, :].to(x.dtype)
|
66 |
+
self.sin_cached = emb.sin()[None, None, :, :].to(x.dtype)
|
67 |
+
return self.cos_cached.to(x.device), self.sin_cached.to(x.device)
|
68 |
+
|
69 |
+
|
70 |
+
def rotate_half(x):
|
71 |
+
"""Rotates half the hidden dims of the input."""
|
72 |
+
x1 = x[..., : x.shape[-1] // 2]
|
73 |
+
x2 = x[..., x.shape[-1] // 2:]
|
74 |
+
return torch.cat((-x2, x1), dim=-1)
|
75 |
+
|
76 |
+
|
77 |
+
def apply_rotary_pos_emb(q, cos, sin, position_ids):
|
78 |
+
"""Apply positional embeddings"""
|
79 |
+
gather_indices = position_ids[:, None, :, None] # [bs, 1, seq_len, 1]
|
80 |
+
gather_indices = gather_indices.repeat(1, cos.shape[1], 1, cos.shape[3])
|
81 |
+
cos = torch.gather(cos.repeat(gather_indices.shape[0], 1, 1, 1), 2, gather_indices)
|
82 |
+
sin = torch.gather(sin.repeat(gather_indices.shape[0], 1, 1, 1), 2, gather_indices)
|
83 |
+
q_embed = (q * cos) + (rotate_half(q) * sin)
|
84 |
+
return q_embed
|
85 |
+
|
86 |
+
|
87 |
+
def apply_rotary_pos_emb_reverse(q, cos, sin, position_ids):
|
88 |
+
"""Apply positional embeddings in reverse"""
|
89 |
+
gather_indices = position_ids[:, None, :, None] # [bs, 1, seq_len, 1]
|
90 |
+
gather_indices = gather_indices.repeat(1, cos.shape[1], 1, cos.shape[3])
|
91 |
+
cos = torch.gather(cos.repeat(gather_indices.shape[0], 1, 1, 1), 2, gather_indices)
|
92 |
+
sin = torch.gather(sin.repeat(gather_indices.shape[0], 1, 1, 1), 2, gather_indices)
|
93 |
+
q_embed = (q * cos) - (rotate_half(q) * sin)
|
94 |
+
return q_embed
|
95 |
+
|
96 |
+
|
97 |
+
class GeoVAttention(nn.Module):
|
98 |
+
"""
|
99 |
+
Attention module
|
100 |
+
"""
|
101 |
+
|
102 |
+
def __init__(self, config):
|
103 |
+
super().__init__()
|
104 |
+
self.num_attention_heads = config.num_attention_heads
|
105 |
+
self.hidden_size = config.hidden_size
|
106 |
+
self.head_size = self.hidden_size // self.num_attention_heads
|
107 |
+
max_positions = config.max_position_embeddings
|
108 |
+
self.register_buffer("causal_mask", torch.tril(torch.ones((max_positions, max_positions), dtype=torch.bool)))
|
109 |
+
self.rotary_emb = RotaryEmbedding(self.head_size, base=config.rotary_emb_base)
|
110 |
+
self.qkv = nn.Linear(config.hidden_size, 3 * config.hidden_size)
|
111 |
+
self.dense = nn.Linear(config.hidden_size, config.hidden_size, bias=False)
|
112 |
+
|
113 |
+
def forward(
|
114 |
+
self,
|
115 |
+
hidden_states: torch.FloatTensor,
|
116 |
+
attention_mask: torch.FloatTensor,
|
117 |
+
position_ids: torch.LongTensor,
|
118 |
+
head_mask: Optional[torch.FloatTensor] = None,
|
119 |
+
layer_past: Optional[Tuple[torch.Tensor]] = None,
|
120 |
+
use_cache: Optional[bool] = False,
|
121 |
+
output_attentions: Optional[bool] = False,
|
122 |
+
):
|
123 |
+
has_layer_past = layer_past is not None
|
124 |
+
|
125 |
+
# Compute QKV
|
126 |
+
# Attention heads [batch, seq_len, hidden_size]
|
127 |
+
# --> [batch, seq_len, (np * 3 * head_size)]
|
128 |
+
qkv = self.qkv(hidden_states)
|
129 |
+
query, key, value = torch.tensor_split(qkv, 3, dim=-1)
|
130 |
+
|
131 |
+
# 'b l (h q) -> b h l q'
|
132 |
+
query = self._split_heads(query, self.num_attention_heads)
|
133 |
+
key = self._split_heads(key, self.num_attention_heads)
|
134 |
+
value = self._split_heads(value, self.num_attention_heads)
|
135 |
+
|
136 |
+
# Compute token offset for rotary embeddings (when decoding)
|
137 |
+
seq_len = key.shape[-2]
|
138 |
+
offset = 0
|
139 |
+
if has_layer_past:
|
140 |
+
seq_len += layer_past[0].shape[-2]
|
141 |
+
|
142 |
+
cos, sin = self.rotary_emb(query, seq_len=seq_len)
|
143 |
+
query = apply_rotary_pos_emb(query, cos, sin, position_ids)
|
144 |
+
key = apply_rotary_pos_emb(key, cos, sin, position_ids)
|
145 |
+
value = apply_rotary_pos_emb(value, cos, sin, position_ids)
|
146 |
+
|
147 |
+
# Cache QKV values
|
148 |
+
if has_layer_past:
|
149 |
+
past_key = layer_past[0]
|
150 |
+
past_value = layer_past[1]
|
151 |
+
key = torch.cat((past_key, key), dim=-2)
|
152 |
+
value = torch.cat((past_value, value), dim=-2)
|
153 |
+
present = (key, value) if use_cache else None
|
154 |
+
|
155 |
+
# Compute attention
|
156 |
+
attn_output, attn_weights = self._attn(query, key, value, attention_mask, head_mask)
|
157 |
+
|
158 |
+
attn_output = apply_rotary_pos_emb_reverse(attn_output, cos, sin, position_ids)
|
159 |
+
|
160 |
+
# Reshape outputs
|
161 |
+
attn_output = self._merge_heads(attn_output)
|
162 |
+
attn_output = self.dense(attn_output)
|
163 |
+
|
164 |
+
outputs = (attn_output, present)
|
165 |
+
if output_attentions:
|
166 |
+
outputs += (attn_weights,)
|
167 |
+
|
168 |
+
return outputs
|
169 |
+
|
170 |
+
@classmethod
|
171 |
+
def _split_heads(cls, tensor, num_attention_heads):
|
172 |
+
"""
|
173 |
+
Splits hidden dim into num_attention_heads
|
174 |
+
"""
|
175 |
+
# tensor: [bs, seq_len, hidden_size]
|
176 |
+
new_shape = tensor.shape[:-1] + (num_attention_heads, tensor.shape[-1] // num_attention_heads)
|
177 |
+
# -> [bs, seq_len, num_attention_heads, attn_head_size]
|
178 |
+
tensor = tensor.view(new_shape)
|
179 |
+
# -> [bs, num_attention_heads, seq_len, attn_head_size]
|
180 |
+
tensor = tensor.permute(0, 2, 1, 3)
|
181 |
+
return tensor
|
182 |
+
|
183 |
+
@classmethod
|
184 |
+
def _merge_heads(cls, tensor):
|
185 |
+
"""
|
186 |
+
Merges heads
|
187 |
+
"""
|
188 |
+
# tensor [bs, num_attention_heads, seq_len, attn_head_size]
|
189 |
+
tensor = tensor.permute(0, 2, 1, 3).contiguous()
|
190 |
+
# -> [bs, seq_len, num_attention_heads, attn_head_size]
|
191 |
+
tensor = tensor.view(*tensor.shape[:2], tensor.shape[2] * tensor.shape[3])
|
192 |
+
# -> [bs, seq_len, hidden_size]
|
193 |
+
return tensor
|
194 |
+
|
195 |
+
def _attn(self, query, key, value, attention_mask=None, head_mask=None):
|
196 |
+
# q, k, v: [bs, num_attention_heads, seq_len, attn_head_size]
|
197 |
+
# compute causal mask from causal mask buffer
|
198 |
+
batch_size, num_attention_heads, query_length, attn_head_size = query.shape
|
199 |
+
key_length = key.shape[-2]
|
200 |
+
|
201 |
+
causal_mask = self.causal_mask[None, None, key_length - query_length: key_length, :key_length]
|
202 |
+
|
203 |
+
attn_scores = torch.einsum("bhid,bhjd->bhij", query, key) / math.sqrt(attn_head_size)
|
204 |
+
|
205 |
+
attn_scores.masked_fill_(causal_mask == 0, torch.finfo(attn_scores.dtype).min)
|
206 |
+
|
207 |
+
if attention_mask is not None:
|
208 |
+
# Apply the attention mask
|
209 |
+
attn_scores = attn_scores + attention_mask
|
210 |
+
|
211 |
+
attn_weights = nn.functional.softmax(attn_scores, dim=-1)
|
212 |
+
|
213 |
+
# Mask heads if we want to
|
214 |
+
if head_mask is not None:
|
215 |
+
attn_weights = attn_weights * head_mask
|
216 |
+
|
217 |
+
attn_output = torch.matmul(attn_weights, value)
|
218 |
+
return attn_output, attn_weights
|
219 |
+
|
220 |
+
|
221 |
+
class GeoVMLP(nn.Module):
|
222 |
+
"""Position wise Feed-forward network"""
|
223 |
+
|
224 |
+
def __init__(self, config: "GeoVConfig"):
|
225 |
+
super().__init__()
|
226 |
+
self.dense_h_to_4h = nn.Linear(config.hidden_size, config.intermediate_size)
|
227 |
+
self.dense_2h_to_h = nn.Linear(
|
228 |
+
config.intermediate_size // 2, config.hidden_size, bias=config.use_extra_biases_ffn
|
229 |
+
)
|
230 |
+
self.act = nn.GELU()
|
231 |
+
|
232 |
+
def forward(self, hidden_states):
|
233 |
+
hidden_states = self.dense_h_to_4h(hidden_states)
|
234 |
+
# Gated GELU
|
235 |
+
gate, pass_through = torch.tensor_split(hidden_states, 2, dim=-1)
|
236 |
+
gate = self.act(gate)
|
237 |
+
hidden_states = gate * pass_through
|
238 |
+
|
239 |
+
hidden_states = self.dense_2h_to_h(hidden_states)
|
240 |
+
return hidden_states
|
241 |
+
|
242 |
+
|
243 |
+
class GeoVLayer(nn.Module):
|
244 |
+
"""GeoV transformer layer"""
|
245 |
+
|
246 |
+
def __init__(self, config: "GeoVConfig"):
|
247 |
+
super().__init__()
|
248 |
+
self.input_layernorm = nn.LayerNorm(config.hidden_size, eps=config.layer_norm_eps)
|
249 |
+
self.post_attention_layernorm = nn.LayerNorm(config.hidden_size, eps=config.layer_norm_eps)
|
250 |
+
self.attention = GeoVAttention(config)
|
251 |
+
self.mlp = GeoVMLP(config)
|
252 |
+
|
253 |
+
def forward(
|
254 |
+
self,
|
255 |
+
hidden_states: Optional[torch.FloatTensor],
|
256 |
+
attention_mask: Optional[torch.FloatTensor] = None,
|
257 |
+
position_ids: Optional[torch.LongTensor] = None,
|
258 |
+
head_mask: Optional[torch.FloatTensor] = None,
|
259 |
+
use_cache: Optional[bool] = False,
|
260 |
+
layer_past: Optional[Tuple[torch.Tensor]] = None,
|
261 |
+
output_attentions: Optional[bool] = False,
|
262 |
+
):
|
263 |
+
attention_layer_outputs = self.attention(
|
264 |
+
self.input_layernorm(hidden_states),
|
265 |
+
attention_mask=attention_mask,
|
266 |
+
position_ids=position_ids,
|
267 |
+
layer_past=layer_past,
|
268 |
+
head_mask=head_mask,
|
269 |
+
use_cache=use_cache,
|
270 |
+
output_attentions=output_attentions,
|
271 |
+
)
|
272 |
+
attn_output = attention_layer_outputs[0] # output_attn: attn_output, present, (attn_weights)
|
273 |
+
outputs = attention_layer_outputs[1:]
|
274 |
+
|
275 |
+
attn_output = attn_output + hidden_states
|
276 |
+
mlp_output = self.mlp(self.post_attention_layernorm(attn_output))
|
277 |
+
hidden_states = mlp_output + attn_output
|
278 |
+
|
279 |
+
if use_cache:
|
280 |
+
outputs = (hidden_states,) + outputs # hidden_states, present, (attn_weights)
|
281 |
+
else:
|
282 |
+
outputs = (hidden_states,) + outputs[1:] # hidden_states, (attn_weights)
|
283 |
+
|
284 |
+
return outputs
|
285 |
+
|
286 |
+
|
287 |
+
class GeoVPreTrainedModel(PreTrainedModel):
|
288 |
+
"""
|
289 |
+
An abstract class to handle weights initialization and a simple interface for downloading and loading pretrained
|
290 |
+
models.
|
291 |
+
"""
|
292 |
+
|
293 |
+
config_class = GeoVConfig
|
294 |
+
base_model_prefix = "geov"
|
295 |
+
supports_gradient_checkpointing = True
|
296 |
+
_no_split_modules = ["GeoVLayer"]
|
297 |
+
|
298 |
+
def _init_weights(self, module):
|
299 |
+
pass
|
300 |
+
|
301 |
+
def _set_gradient_checkpointing(self, module, value=False):
|
302 |
+
if isinstance(module, GeoVModel):
|
303 |
+
module.gradient_checkpointing = value
|
304 |
+
|
305 |
+
|
306 |
+
GEOV_START_DOCSTRING = r"""
|
307 |
+
This model is a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) sub-class. Use
|
308 |
+
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
|
309 |
+
behavior.
|
310 |
+
|
311 |
+
Parameters:
|
312 |
+
config ([`~GeoVConfig`]): Model configuration class with all the parameters of the model.
|
313 |
+
Initializing with a config file does not load the weights associated with the model, only the
|
314 |
+
configuration. Check out the [`~PreTrainedModel.from_pretrained`] method to load the model weights.
|
315 |
+
"""
|
316 |
+
|
317 |
+
GEOV_INPUTS_DOCSTRING = r"""
|
318 |
+
Args:
|
319 |
+
input_ids (`torch.LongTensor` of shape `(batch_size, seq_len)`):
|
320 |
+
Indices of input sequence tokens in the vocabulary.
|
321 |
+
|
322 |
+
Indices can be obtained using [`AutoTokenizer`]. See [`PreTrainedTokenizer.encode`] and
|
323 |
+
[`PreTrainedTokenizer.__call__`] for details.
|
324 |
+
|
325 |
+
[What are input IDs?](../glossary#input-ids)
|
326 |
+
attention_mask (`torch.FloatTensor` of shape `(batch_size, seq_len)`, *optional*):
|
327 |
+
Mask to avoid performing attention on padding token indices. Mask values selected in `[0, 1]`:
|
328 |
+
|
329 |
+
- 1 for tokens that are **not masked**,
|
330 |
+
- 0 for tokens that are **masked**.
|
331 |
+
|
332 |
+
[What are attention masks?](../glossary#attention-mask)
|
333 |
+
position_ids (`torch.LongTensor` of shape `({0})`, *optional*):
|
334 |
+
Indices of positions of each input sequence tokens in the position embeddings. Selected in the range `[0,
|
335 |
+
config.n_positions - 1]`.
|
336 |
+
|
337 |
+
[What are position IDs?](../glossary#position-ids)
|
338 |
+
head_mask (`torch.FloatTensor` of shape `(num_heads,)` or `(num_layers, num_heads)`, *optional*):
|
339 |
+
Mask to nullify selected heads of the self-attention modules. Mask values selected in `[0, 1]`:
|
340 |
+
|
341 |
+
- 1 indicates the head is **not masked**,
|
342 |
+
- 0 indicates the head is **masked**.
|
343 |
+
|
344 |
+
past_key_values (`Tuple[Tuple[torch.FloatTensor]]` of length `n_layers`, with each tuple having 2 tensors of shape `(batch_size, n_heads, seq_len - 1, head_size)`, *optional*):
|
345 |
+
Contains precomputed key and value hidden states of the attention blocks. Can be used to speed up decoding.
|
346 |
+
|
347 |
+
use_cache (`bool`, *optional*):
|
348 |
+
If set to `True`, `past_key_values` key value states are returned and can be used to speed up decoding (see
|
349 |
+
`past_key_values`).
|
350 |
+
inputs_embeds (`torch.FloatTensor` of shape `(batch_size, seq_len, hidden_size)`, *optional*):
|
351 |
+
Optionally, instead of passing `input_ids` you can choose to directly pass an embedded representation. This
|
352 |
+
is useful if you want more control over how to convert *input_ids* indices into associated vectors than the
|
353 |
+
model's internal embedding lookup matrix.
|
354 |
+
output_attentions (`bool`, *optional*):
|
355 |
+
Whether or not to return the attentions tensors of all attention layers. See `attentions` under returned
|
356 |
+
tensors for more detail.
|
357 |
+
output_hidden_states (`bool`, *optional*):
|
358 |
+
Whether or not to return the hidden states of all layers. See `hidden_states` under returned tensors for
|
359 |
+
more detail.
|
360 |
+
return_dict (`bool`, *optional*):
|
361 |
+
Whether or not to return a [`~file_utils.ModelOutput`] instead of a plain tuple.
|
362 |
+
"""
|
363 |
+
|
364 |
+
|
365 |
+
@add_start_docstrings(
|
366 |
+
"The bare GeoV Model transformer outputting raw hidden-states without any specific head on top.",
|
367 |
+
GEOV_START_DOCSTRING,
|
368 |
+
)
|
369 |
+
class GeoVModel(GeoVPreTrainedModel):
|
370 |
+
def __init__(self, config: "GeoVConfig"):
|
371 |
+
super().__init__(config)
|
372 |
+
self.config = config
|
373 |
+
|
374 |
+
self.embed_in = nn.Embedding(config.vocab_size, config.hidden_size)
|
375 |
+
self.layers = nn.ModuleList([GeoVLayer(config) for _ in range(config.num_hidden_layers)])
|
376 |
+
self.final_layer_norm = nn.LayerNorm(config.hidden_size, eps=config.layer_norm_eps)
|
377 |
+
|
378 |
+
self.embed_in.to(torch.bfloat16)
|
379 |
+
self.layers.to(torch.bfloat16)
|
380 |
+
|
381 |
+
self.gradient_checkpointing = False
|
382 |
+
|
383 |
+
# Initialize weights and apply final processing
|
384 |
+
self.post_init()
|
385 |
+
|
386 |
+
def get_input_embeddings(self):
|
387 |
+
return self.embed_in
|
388 |
+
|
389 |
+
def set_input_embeddings(self, value):
|
390 |
+
self.embed_in = value
|
391 |
+
|
392 |
+
@add_start_docstrings_to_model_forward(GEOV_INPUTS_DOCSTRING)
|
393 |
+
@add_code_sample_docstrings(
|
394 |
+
checkpoint=_CHECKPOINT_FOR_DOC,
|
395 |
+
real_checkpoint=_REAL_CHECKPOINT_FOR_DOC,
|
396 |
+
output_type=BaseModelOutputWithPast,
|
397 |
+
config_class=_CONFIG_FOR_DOC,
|
398 |
+
)
|
399 |
+
def forward(
|
400 |
+
self,
|
401 |
+
input_ids: Optional[torch.LongTensor] = None,
|
402 |
+
attention_mask: Optional[torch.FloatTensor] = None,
|
403 |
+
position_ids: Optional[torch.LongTensor] = None,
|
404 |
+
head_mask: Optional[torch.FloatTensor] = None,
|
405 |
+
inputs_embeds: Optional[torch.FloatTensor] = None,
|
406 |
+
past_key_values: Optional[Tuple[Tuple[torch.FloatTensor]]] = None,
|
407 |
+
use_cache: Optional[bool] = None,
|
408 |
+
output_attentions: Optional[bool] = None,
|
409 |
+
output_hidden_states: Optional[bool] = None,
|
410 |
+
return_dict: Optional[bool] = None,
|
411 |
+
) -> Union[Tuple, BaseModelOutputWithPast]:
|
412 |
+
output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
|
413 |
+
output_hidden_states = (
|
414 |
+
output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
|
415 |
+
)
|
416 |
+
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
417 |
+
use_cache = use_cache if use_cache is not None else self.config.use_cache
|
418 |
+
|
419 |
+
if input_ids is not None and inputs_embeds is not None:
|
420 |
+
raise ValueError("You cannot specify both input_ids and inputs_embeds at the same time")
|
421 |
+
elif input_ids is not None:
|
422 |
+
input_shape = input_ids.size()
|
423 |
+
elif inputs_embeds is not None:
|
424 |
+
input_shape = inputs_embeds.size()[:-1]
|
425 |
+
else:
|
426 |
+
raise ValueError("You have to specify either input_ids or inputs_embeds")
|
427 |
+
|
428 |
+
batch_size, seq_length = input_shape
|
429 |
+
|
430 |
+
if past_key_values is None:
|
431 |
+
past_length = 0
|
432 |
+
past_key_values = tuple([None] * self.config.num_hidden_layers)
|
433 |
+
else:
|
434 |
+
past_length = past_key_values[0][0].size(-2)
|
435 |
+
|
436 |
+
if position_ids is None:
|
437 |
+
device = input_ids.device if input_ids is not None else inputs_embeds.device
|
438 |
+
position_ids = torch.arange(past_length, seq_length + past_length, dtype=torch.long, device=device)
|
439 |
+
position_ids = position_ids.unsqueeze(0).view(-1, seq_length)
|
440 |
+
else:
|
441 |
+
position_ids = position_ids.view(-1, seq_length).long()
|
442 |
+
|
443 |
+
# Attention mask.
|
444 |
+
if attention_mask is not None:
|
445 |
+
assert batch_size > 0, "batch_size has to be defined and > 0"
|
446 |
+
attention_mask = attention_mask.view(batch_size, -1)
|
447 |
+
# We create a 3D attention mask from a 2D tensor mask.
|
448 |
+
# Sizes are [batch_size, 1, 1, to_seq_length]
|
449 |
+
# So we can broadcast to [batch_size, num_heads, from_seq_length, to_seq_length]
|
450 |
+
# this attention mask is more simple than the triangular masking of causal attention
|
451 |
+
# used in OpenAI GPT, we just need to prepare the broadcast dimension here.
|
452 |
+
attention_mask = attention_mask[:, None, None, :]
|
453 |
+
|
454 |
+
# Since attention_mask is 1.0 for positions we want to attend and 0.0 for
|
455 |
+
# masked positions, this operation will create a tensor which is 0.0 for
|
456 |
+
# positions we want to attend and the dtype's smallest value for masked positions.
|
457 |
+
# Since we are adding it to the raw scores before the softmax, this is
|
458 |
+
# effectively the same as removing these entirely.
|
459 |
+
attention_mask = attention_mask.to(dtype=self.dtype) # fp16 compatibility
|
460 |
+
attention_mask = (1.0 - attention_mask) * torch.finfo(self.dtype).min
|
461 |
+
|
462 |
+
# Prepare head mask if needed
|
463 |
+
# 1.0 in head_mask indicate we keep the head
|
464 |
+
# attention_probs has shape bsz x n_heads x N x N
|
465 |
+
# input head_mask has shape [num_heads] or [num_hidden_layers x num_heads]
|
466 |
+
# and head_mask is converted to shape [num_hidden_layers x batch x num_heads x seq_length x seq_length]
|
467 |
+
head_mask = self.get_head_mask(head_mask, self.config.num_hidden_layers)
|
468 |
+
|
469 |
+
if inputs_embeds is None:
|
470 |
+
inputs_embeds = self.embed_in(input_ids)
|
471 |
+
|
472 |
+
hidden_states = inputs_embeds
|
473 |
+
|
474 |
+
if self.gradient_checkpointing and self.training:
|
475 |
+
if use_cache:
|
476 |
+
logger.warning(
|
477 |
+
"`use_cache=True` is incompatible with gradient checkpointing. Setting `use_cache=False`..."
|
478 |
+
)
|
479 |
+
use_cache = False
|
480 |
+
|
481 |
+
presents = () if use_cache else None
|
482 |
+
all_attentions = () if output_attentions else None
|
483 |
+
all_hidden_states = () if output_hidden_states else None
|
484 |
+
for i, (layer, layer_past) in enumerate(zip(self.layers, past_key_values)):
|
485 |
+
if output_hidden_states:
|
486 |
+
all_hidden_states = all_hidden_states + (hidden_states,)
|
487 |
+
|
488 |
+
if self.gradient_checkpointing and self.training:
|
489 |
+
|
490 |
+
def create_custom_forward(module):
|
491 |
+
def custom_forward(*inputs):
|
492 |
+
# None for layer_past
|
493 |
+
return module(*inputs, use_cache, None, output_attentions)
|
494 |
+
|
495 |
+
return custom_forward
|
496 |
+
|
497 |
+
outputs = torch.utils.checkpoint.checkpoint(
|
498 |
+
create_custom_forward(layer),
|
499 |
+
hidden_states,
|
500 |
+
attention_mask,
|
501 |
+
position_ids,
|
502 |
+
head_mask[i],
|
503 |
+
)
|
504 |
+
else:
|
505 |
+
outputs = layer(
|
506 |
+
hidden_states,
|
507 |
+
attention_mask=attention_mask,
|
508 |
+
position_ids=position_ids,
|
509 |
+
head_mask=head_mask[i],
|
510 |
+
layer_past=layer_past,
|
511 |
+
use_cache=use_cache,
|
512 |
+
output_attentions=output_attentions,
|
513 |
+
)
|
514 |
+
hidden_states = outputs[0]
|
515 |
+
if use_cache is True:
|
516 |
+
presents = presents + (outputs[1],)
|
517 |
+
if output_attentions:
|
518 |
+
all_attentions = all_attentions + (outputs[2 if use_cache else 1],)
|
519 |
+
|
520 |
+
# Cast the hidden state to final layer norm data type (this is the modification from GPTNeoX)
|
521 |
+
hidden_states = self.final_layer_norm(hidden_states.to(self.final_layer_norm.weight.dtype))
|
522 |
+
# Add last hidden state
|
523 |
+
if output_hidden_states:
|
524 |
+
all_hidden_states = all_hidden_states + (hidden_states,)
|
525 |
+
|
526 |
+
if not return_dict:
|
527 |
+
return tuple(v for v in [hidden_states, presents, all_hidden_states, all_attentions] if v is not None)
|
528 |
+
|
529 |
+
return BaseModelOutputWithPast(
|
530 |
+
last_hidden_state=hidden_states,
|
531 |
+
past_key_values=presents,
|
532 |
+
hidden_states=all_hidden_states,
|
533 |
+
attentions=all_attentions,
|
534 |
+
)
|
535 |
+
|
536 |
+
|
537 |
+
@add_start_docstrings(
|
538 |
+
"""GeoV Model with a `language modeling` head on top for CLM fine-tuning.""", GEOV_START_DOCSTRING
|
539 |
+
)
|
540 |
+
class GeoVForCausalLM(GeoVPreTrainedModel):
|
541 |
+
_keys_to_ignore_on_load_missing = [r"causal_mask", r"inv_freq"]
|
542 |
+
|
543 |
+
def __init__(self, config: "GeoVConfig"):
|
544 |
+
super().__init__(config)
|
545 |
+
|
546 |
+
self.geov = GeoVModel(config)
|
547 |
+
self.embed_out = nn.Linear(config.hidden_size, config.vocab_size)
|
548 |
+
|
549 |
+
# Initialize weights and apply final processing
|
550 |
+
self.post_init()
|
551 |
+
|
552 |
+
def get_output_embeddings(self):
|
553 |
+
return self.embed_out
|
554 |
+
|
555 |
+
def set_output_embeddings(self, new_embeddings):
|
556 |
+
self.embed_out = new_embeddings
|
557 |
+
|
558 |
+
@add_start_docstrings_to_model_forward(GEOV_INPUTS_DOCSTRING)
|
559 |
+
@replace_return_docstrings(output_type=CausalLMOutputWithPast, config_class=_CONFIG_FOR_DOC)
|
560 |
+
def forward(
|
561 |
+
self,
|
562 |
+
input_ids: Optional[torch.LongTensor] = None,
|
563 |
+
attention_mask: Optional[torch.FloatTensor] = None,
|
564 |
+
position_ids: Optional[torch.LongTensor] = None,
|
565 |
+
inputs_embeds: Optional[torch.FloatTensor] = None,
|
566 |
+
head_mask: Optional[torch.FloatTensor] = None,
|
567 |
+
past_key_values: Optional[Tuple[Tuple[torch.FloatTensor]]] = None,
|
568 |
+
labels: Optional[torch.LongTensor] = None,
|
569 |
+
use_cache: Optional[bool] = None,
|
570 |
+
output_attentions: Optional[bool] = None,
|
571 |
+
output_hidden_states: Optional[bool] = None,
|
572 |
+
return_dict: Optional[bool] = None,
|
573 |
+
) -> Union[Tuple, CausalLMOutputWithPast]:
|
574 |
+
r"""
|
575 |
+
labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
|
576 |
+
Labels for computing the left-to-right language modeling loss (next word prediction). Indices should be in
|
577 |
+
`[-100, 0, ..., config.vocab_size]` (see `input_ids` docstring) Tokens with indices set to `-100` are
|
578 |
+
ignored (masked), the loss is only computed for the tokens with labels n `[0, ..., config.vocab_size]`.
|
579 |
+
|
580 |
+
Returns:
|
581 |
+
|
582 |
+
Example:
|
583 |
+
|
584 |
+
```python
|
585 |
+
>>> from transformers import AutoTokenizer, GeoVForCausalLM, GeoVConfig
|
586 |
+
>>> import torch
|
587 |
+
|
588 |
+
>>> tokenizer = AutoTokenizer.from_pretrained("GeoV/GeoV-9b")
|
589 |
+
>>> model = GeoVForCausalLM.from_pretrained("GeoV/GeoV-9b")
|
590 |
+
|
591 |
+
>>> inputs = tokenizer("Hello, my dog is cute", return_tensors="pt")
|
592 |
+
>>> outputs = model(**inputs)
|
593 |
+
|
594 |
+
>>> prediction_logits = outputs.logits
|
595 |
+
```"""
|
596 |
+
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
597 |
+
|
598 |
+
outputs = self.geov(
|
599 |
+
input_ids,
|
600 |
+
attention_mask=attention_mask,
|
601 |
+
position_ids=position_ids,
|
602 |
+
head_mask=head_mask,
|
603 |
+
inputs_embeds=inputs_embeds,
|
604 |
+
past_key_values=past_key_values,
|
605 |
+
use_cache=use_cache,
|
606 |
+
output_attentions=output_attentions,
|
607 |
+
output_hidden_states=output_hidden_states,
|
608 |
+
return_dict=return_dict,
|
609 |
+
)
|
610 |
+
|
611 |
+
hidden_states = outputs[0]
|
612 |
+
lm_logits = self.embed_out(hidden_states)
|
613 |
+
|
614 |
+
lm_loss = None
|
615 |
+
if labels is not None:
|
616 |
+
# we are doing next-token prediction; shift prediction scores and input ids by one
|
617 |
+
shift_logits = lm_logits[:, :-1, :].contiguous()
|
618 |
+
labels = labels[:, 1:].contiguous()
|
619 |
+
loss_fct = CrossEntropyLoss()
|
620 |
+
lm_loss = loss_fct(shift_logits.view(-1, shift_logits.size(-1)), labels.view(-1))
|
621 |
+
|
622 |
+
if not return_dict:
|
623 |
+
output = (lm_logits,) + outputs[1:]
|
624 |
+
return ((lm_loss,) + output) if lm_loss is not None else output
|
625 |
+
|
626 |
+
return CausalLMOutputWithPast(
|
627 |
+
loss=lm_loss,
|
628 |
+
logits=lm_logits,
|
629 |
+
past_key_values=outputs.past_key_values,
|
630 |
+
hidden_states=outputs.hidden_states,
|
631 |
+
attentions=outputs.attentions,
|
632 |
+
)
|
633 |
+
|
634 |
+
def prepare_inputs_for_generation(self, input_ids, past_key_values=None, attention_mask=None, **kwargs):
|
635 |
+
input_shape = input_ids.shape
|
636 |
+
|
637 |
+
# cut decoder_input_ids if past is used
|
638 |
+
if past_key_values and past_key_values[0] is not None:
|
639 |
+
input_ids = input_ids[:, -1:]
|
640 |
+
|
641 |
+
position_ids = kwargs.get("position_ids", None)
|
642 |
+
if attention_mask is not None and position_ids is None:
|
643 |
+
# create position_ids on the fly for batch generation
|
644 |
+
position_ids = attention_mask.long().cumsum(-1) - 1
|
645 |
+
position_ids.masked_fill_(attention_mask == 0, 1)
|
646 |
+
if past_key_values:
|
647 |
+
position_ids = position_ids[:, -1].unsqueeze(-1)
|
648 |
+
|
649 |
+
# if model is used as a decoder in encoder-decoder model, the decoder attention mask is created on the fly
|
650 |
+
if attention_mask is None:
|
651 |
+
attention_mask = input_ids.new_ones(input_shape)
|
652 |
+
|
653 |
+
return {
|
654 |
+
"input_ids": input_ids,
|
655 |
+
"attention_mask": attention_mask,
|
656 |
+
"position_ids": position_ids,
|
657 |
+
"past_key_values": past_key_values,
|
658 |
+
}
|
659 |
+
|
660 |
+
def _reorder_cache(self, past_key_values, beam_idx):
|
661 |
+
reordered_past = ()
|
662 |
+
for layer_past in past_key_values:
|
663 |
+
reordered_past += (
|
664 |
+
tuple(past_state.index_select(0, beam_idx) for past_state in layer_past[:2]) + layer_past[2:],
|
665 |
+
)
|
666 |
+
return reordered_past
|
pytorch_model-00001-of-00010.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:3a2ef40d7f48fae70d5632c48ec8e2e8c50dded769ed1c01bd6968dbf9b39832
|
3 |
+
size 1942271283
|
pytorch_model-00002-of-00010.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:079b090e4aa3442833bb3fce74cf5199ba74d0b77576c1f9333fb3b4413a3b68
|
3 |
+
size 1904649273
|
pytorch_model-00003-of-00010.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:1d604f1cd4262c8e4d7077cd709cc1a0f68ce4331f0a4c5fef76d532f109f0ba
|
3 |
+
size 2005300849
|
pytorch_model-00004-of-00010.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:2d9ac580e352e27a76f55ea22d92d90124419311fead33fab94fd5ad0fc3578e
|
3 |
+
size 1904639435
|
pytorch_model-00005-of-00010.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:734323cb9c051e05ecde41749894217632d5497738fc70ad1ecf3971b91183ab
|
3 |
+
size 1904649337
|
pytorch_model-00006-of-00010.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e9e16c68548bb6aea2515f6e5a9a660e6634e51c9919a0bfa16f0997197edf4a
|
3 |
+
size 2005300913
|
pytorch_model-00007-of-00010.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:4241ef22c478e078f029de33aab424d7733308f63ee0e4af7a536b3a45d68981
|
3 |
+
size 1904639435
|
pytorch_model-00008-of-00010.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:b051f84170e916484bcd7fe5fc7b4f1f557a130a6abebc3cf8c8d5e64164b9e4
|
3 |
+
size 1904649337
|
pytorch_model-00009-of-00010.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:4b5d229217bf18cac0be9651ed0787d3b9ddd7a2bbd5524b96116c39f75676c8
|
3 |
+
size 2005300913
|
pytorch_model-00010-of-00010.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:b33fa2fab91fb005e3b006083fad95b08995c31e488285019b610ed156bebb33
|
3 |
+
size 1447340142
|
pytorch_model.bin.index.json
ADDED
@@ -0,0 +1,396 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"metadata": {
|
3 |
+
"total_size": 18811170816.0
|
4 |
+
},
|
5 |
+
"weight_map": {
|
6 |
+
"embed_out.bias": "pytorch_model-00010-of-00010.bin",
|
7 |
+
"embed_out.weight": "pytorch_model-00010-of-00010.bin",
|
8 |
+
"geov.embed_in.weight": "pytorch_model-00001-of-00010.bin",
|
9 |
+
"geov.final_layer_norm.bias": "pytorch_model-00010-of-00010.bin",
|
10 |
+
"geov.final_layer_norm.weight": "pytorch_model-00010-of-00010.bin",
|
11 |
+
"geov.layers.0.attention.causal_mask": "pytorch_model-00001-of-00010.bin",
|
12 |
+
"geov.layers.0.attention.dense.weight": "pytorch_model-00001-of-00010.bin",
|
13 |
+
"geov.layers.0.attention.qkv.bias": "pytorch_model-00001-of-00010.bin",
|
14 |
+
"geov.layers.0.attention.qkv.weight": "pytorch_model-00001-of-00010.bin",
|
15 |
+
"geov.layers.0.attention.rotary_emb.inv_freq": "pytorch_model-00001-of-00010.bin",
|
16 |
+
"geov.layers.0.input_layernorm.bias": "pytorch_model-00001-of-00010.bin",
|
17 |
+
"geov.layers.0.input_layernorm.weight": "pytorch_model-00001-of-00010.bin",
|
18 |
+
"geov.layers.0.mlp.dense_2h_to_h.weight": "pytorch_model-00001-of-00010.bin",
|
19 |
+
"geov.layers.0.mlp.dense_h_to_4h.bias": "pytorch_model-00001-of-00010.bin",
|
20 |
+
"geov.layers.0.mlp.dense_h_to_4h.weight": "pytorch_model-00001-of-00010.bin",
|
21 |
+
"geov.layers.0.post_attention_layernorm.bias": "pytorch_model-00001-of-00010.bin",
|
22 |
+
"geov.layers.0.post_attention_layernorm.weight": "pytorch_model-00001-of-00010.bin",
|
23 |
+
"geov.layers.1.attention.causal_mask": "pytorch_model-00001-of-00010.bin",
|
24 |
+
"geov.layers.1.attention.dense.weight": "pytorch_model-00001-of-00010.bin",
|
25 |
+
"geov.layers.1.attention.qkv.bias": "pytorch_model-00001-of-00010.bin",
|
26 |
+
"geov.layers.1.attention.qkv.weight": "pytorch_model-00001-of-00010.bin",
|
27 |
+
"geov.layers.1.attention.rotary_emb.inv_freq": "pytorch_model-00001-of-00010.bin",
|
28 |
+
"geov.layers.1.input_layernorm.bias": "pytorch_model-00001-of-00010.bin",
|
29 |
+
"geov.layers.1.input_layernorm.weight": "pytorch_model-00001-of-00010.bin",
|
30 |
+
"geov.layers.1.mlp.dense_2h_to_h.weight": "pytorch_model-00001-of-00010.bin",
|
31 |
+
"geov.layers.1.mlp.dense_h_to_4h.bias": "pytorch_model-00001-of-00010.bin",
|
32 |
+
"geov.layers.1.mlp.dense_h_to_4h.weight": "pytorch_model-00001-of-00010.bin",
|
33 |
+
"geov.layers.1.post_attention_layernorm.bias": "pytorch_model-00001-of-00010.bin",
|
34 |
+
"geov.layers.1.post_attention_layernorm.weight": "pytorch_model-00001-of-00010.bin",
|
35 |
+
"geov.layers.10.attention.causal_mask": "pytorch_model-00004-of-00010.bin",
|
36 |
+
"geov.layers.10.attention.dense.weight": "pytorch_model-00004-of-00010.bin",
|
37 |
+
"geov.layers.10.attention.qkv.bias": "pytorch_model-00004-of-00010.bin",
|
38 |
+
"geov.layers.10.attention.qkv.weight": "pytorch_model-00004-of-00010.bin",
|
39 |
+
"geov.layers.10.attention.rotary_emb.inv_freq": "pytorch_model-00004-of-00010.bin",
|
40 |
+
"geov.layers.10.input_layernorm.bias": "pytorch_model-00004-of-00010.bin",
|
41 |
+
"geov.layers.10.input_layernorm.weight": "pytorch_model-00004-of-00010.bin",
|
42 |
+
"geov.layers.10.mlp.dense_2h_to_h.weight": "pytorch_model-00004-of-00010.bin",
|
43 |
+
"geov.layers.10.mlp.dense_h_to_4h.bias": "pytorch_model-00004-of-00010.bin",
|
44 |
+
"geov.layers.10.mlp.dense_h_to_4h.weight": "pytorch_model-00004-of-00010.bin",
|
45 |
+
"geov.layers.10.post_attention_layernorm.bias": "pytorch_model-00004-of-00010.bin",
|
46 |
+
"geov.layers.10.post_attention_layernorm.weight": "pytorch_model-00004-of-00010.bin",
|
47 |
+
"geov.layers.11.attention.causal_mask": "pytorch_model-00004-of-00010.bin",
|
48 |
+
"geov.layers.11.attention.dense.weight": "pytorch_model-00004-of-00010.bin",
|
49 |
+
"geov.layers.11.attention.qkv.bias": "pytorch_model-00004-of-00010.bin",
|
50 |
+
"geov.layers.11.attention.qkv.weight": "pytorch_model-00004-of-00010.bin",
|
51 |
+
"geov.layers.11.attention.rotary_emb.inv_freq": "pytorch_model-00004-of-00010.bin",
|
52 |
+
"geov.layers.11.input_layernorm.bias": "pytorch_model-00004-of-00010.bin",
|
53 |
+
"geov.layers.11.input_layernorm.weight": "pytorch_model-00004-of-00010.bin",
|
54 |
+
"geov.layers.11.mlp.dense_2h_to_h.weight": "pytorch_model-00004-of-00010.bin",
|
55 |
+
"geov.layers.11.mlp.dense_h_to_4h.bias": "pytorch_model-00004-of-00010.bin",
|
56 |
+
"geov.layers.11.mlp.dense_h_to_4h.weight": "pytorch_model-00004-of-00010.bin",
|
57 |
+
"geov.layers.11.post_attention_layernorm.bias": "pytorch_model-00004-of-00010.bin",
|
58 |
+
"geov.layers.11.post_attention_layernorm.weight": "pytorch_model-00004-of-00010.bin",
|
59 |
+
"geov.layers.12.attention.causal_mask": "pytorch_model-00004-of-00010.bin",
|
60 |
+
"geov.layers.12.attention.dense.weight": "pytorch_model-00004-of-00010.bin",
|
61 |
+
"geov.layers.12.attention.qkv.bias": "pytorch_model-00004-of-00010.bin",
|
62 |
+
"geov.layers.12.attention.qkv.weight": "pytorch_model-00004-of-00010.bin",
|
63 |
+
"geov.layers.12.attention.rotary_emb.inv_freq": "pytorch_model-00004-of-00010.bin",
|
64 |
+
"geov.layers.12.input_layernorm.bias": "pytorch_model-00004-of-00010.bin",
|
65 |
+
"geov.layers.12.input_layernorm.weight": "pytorch_model-00004-of-00010.bin",
|
66 |
+
"geov.layers.12.mlp.dense_2h_to_h.weight": "pytorch_model-00004-of-00010.bin",
|
67 |
+
"geov.layers.12.mlp.dense_h_to_4h.bias": "pytorch_model-00004-of-00010.bin",
|
68 |
+
"geov.layers.12.mlp.dense_h_to_4h.weight": "pytorch_model-00004-of-00010.bin",
|
69 |
+
"geov.layers.12.post_attention_layernorm.bias": "pytorch_model-00004-of-00010.bin",
|
70 |
+
"geov.layers.12.post_attention_layernorm.weight": "pytorch_model-00004-of-00010.bin",
|
71 |
+
"geov.layers.13.attention.causal_mask": "pytorch_model-00004-of-00010.bin",
|
72 |
+
"geov.layers.13.attention.dense.weight": "pytorch_model-00004-of-00010.bin",
|
73 |
+
"geov.layers.13.attention.qkv.bias": "pytorch_model-00004-of-00010.bin",
|
74 |
+
"geov.layers.13.attention.qkv.weight": "pytorch_model-00004-of-00010.bin",
|
75 |
+
"geov.layers.13.attention.rotary_emb.inv_freq": "pytorch_model-00004-of-00010.bin",
|
76 |
+
"geov.layers.13.input_layernorm.bias": "pytorch_model-00004-of-00010.bin",
|
77 |
+
"geov.layers.13.input_layernorm.weight": "pytorch_model-00004-of-00010.bin",
|
78 |
+
"geov.layers.13.mlp.dense_2h_to_h.weight": "pytorch_model-00005-of-00010.bin",
|
79 |
+
"geov.layers.13.mlp.dense_h_to_4h.bias": "pytorch_model-00005-of-00010.bin",
|
80 |
+
"geov.layers.13.mlp.dense_h_to_4h.weight": "pytorch_model-00005-of-00010.bin",
|
81 |
+
"geov.layers.13.post_attention_layernorm.bias": "pytorch_model-00004-of-00010.bin",
|
82 |
+
"geov.layers.13.post_attention_layernorm.weight": "pytorch_model-00004-of-00010.bin",
|
83 |
+
"geov.layers.14.attention.causal_mask": "pytorch_model-00005-of-00010.bin",
|
84 |
+
"geov.layers.14.attention.dense.weight": "pytorch_model-00005-of-00010.bin",
|
85 |
+
"geov.layers.14.attention.qkv.bias": "pytorch_model-00005-of-00010.bin",
|
86 |
+
"geov.layers.14.attention.qkv.weight": "pytorch_model-00005-of-00010.bin",
|
87 |
+
"geov.layers.14.attention.rotary_emb.inv_freq": "pytorch_model-00005-of-00010.bin",
|
88 |
+
"geov.layers.14.input_layernorm.bias": "pytorch_model-00005-of-00010.bin",
|
89 |
+
"geov.layers.14.input_layernorm.weight": "pytorch_model-00005-of-00010.bin",
|
90 |
+
"geov.layers.14.mlp.dense_2h_to_h.weight": "pytorch_model-00005-of-00010.bin",
|
91 |
+
"geov.layers.14.mlp.dense_h_to_4h.bias": "pytorch_model-00005-of-00010.bin",
|
92 |
+
"geov.layers.14.mlp.dense_h_to_4h.weight": "pytorch_model-00005-of-00010.bin",
|
93 |
+
"geov.layers.14.post_attention_layernorm.bias": "pytorch_model-00005-of-00010.bin",
|
94 |
+
"geov.layers.14.post_attention_layernorm.weight": "pytorch_model-00005-of-00010.bin",
|
95 |
+
"geov.layers.15.attention.causal_mask": "pytorch_model-00005-of-00010.bin",
|
96 |
+
"geov.layers.15.attention.dense.weight": "pytorch_model-00005-of-00010.bin",
|
97 |
+
"geov.layers.15.attention.qkv.bias": "pytorch_model-00005-of-00010.bin",
|
98 |
+
"geov.layers.15.attention.qkv.weight": "pytorch_model-00005-of-00010.bin",
|
99 |
+
"geov.layers.15.attention.rotary_emb.inv_freq": "pytorch_model-00005-of-00010.bin",
|
100 |
+
"geov.layers.15.input_layernorm.bias": "pytorch_model-00005-of-00010.bin",
|
101 |
+
"geov.layers.15.input_layernorm.weight": "pytorch_model-00005-of-00010.bin",
|
102 |
+
"geov.layers.15.mlp.dense_2h_to_h.weight": "pytorch_model-00005-of-00010.bin",
|
103 |
+
"geov.layers.15.mlp.dense_h_to_4h.bias": "pytorch_model-00005-of-00010.bin",
|
104 |
+
"geov.layers.15.mlp.dense_h_to_4h.weight": "pytorch_model-00005-of-00010.bin",
|
105 |
+
"geov.layers.15.post_attention_layernorm.bias": "pytorch_model-00005-of-00010.bin",
|
106 |
+
"geov.layers.15.post_attention_layernorm.weight": "pytorch_model-00005-of-00010.bin",
|
107 |
+
"geov.layers.16.attention.causal_mask": "pytorch_model-00005-of-00010.bin",
|
108 |
+
"geov.layers.16.attention.dense.weight": "pytorch_model-00005-of-00010.bin",
|
109 |
+
"geov.layers.16.attention.qkv.bias": "pytorch_model-00005-of-00010.bin",
|
110 |
+
"geov.layers.16.attention.qkv.weight": "pytorch_model-00005-of-00010.bin",
|
111 |
+
"geov.layers.16.attention.rotary_emb.inv_freq": "pytorch_model-00005-of-00010.bin",
|
112 |
+
"geov.layers.16.input_layernorm.bias": "pytorch_model-00005-of-00010.bin",
|
113 |
+
"geov.layers.16.input_layernorm.weight": "pytorch_model-00005-of-00010.bin",
|
114 |
+
"geov.layers.16.mlp.dense_2h_to_h.weight": "pytorch_model-00005-of-00010.bin",
|
115 |
+
"geov.layers.16.mlp.dense_h_to_4h.bias": "pytorch_model-00005-of-00010.bin",
|
116 |
+
"geov.layers.16.mlp.dense_h_to_4h.weight": "pytorch_model-00005-of-00010.bin",
|
117 |
+
"geov.layers.16.post_attention_layernorm.bias": "pytorch_model-00005-of-00010.bin",
|
118 |
+
"geov.layers.16.post_attention_layernorm.weight": "pytorch_model-00005-of-00010.bin",
|
119 |
+
"geov.layers.17.attention.causal_mask": "pytorch_model-00005-of-00010.bin",
|
120 |
+
"geov.layers.17.attention.dense.weight": "pytorch_model-00006-of-00010.bin",
|
121 |
+
"geov.layers.17.attention.qkv.bias": "pytorch_model-00006-of-00010.bin",
|
122 |
+
"geov.layers.17.attention.qkv.weight": "pytorch_model-00006-of-00010.bin",
|
123 |
+
"geov.layers.17.attention.rotary_emb.inv_freq": "pytorch_model-00005-of-00010.bin",
|
124 |
+
"geov.layers.17.input_layernorm.bias": "pytorch_model-00005-of-00010.bin",
|
125 |
+
"geov.layers.17.input_layernorm.weight": "pytorch_model-00005-of-00010.bin",
|
126 |
+
"geov.layers.17.mlp.dense_2h_to_h.weight": "pytorch_model-00006-of-00010.bin",
|
127 |
+
"geov.layers.17.mlp.dense_h_to_4h.bias": "pytorch_model-00006-of-00010.bin",
|
128 |
+
"geov.layers.17.mlp.dense_h_to_4h.weight": "pytorch_model-00006-of-00010.bin",
|
129 |
+
"geov.layers.17.post_attention_layernorm.bias": "pytorch_model-00005-of-00010.bin",
|
130 |
+
"geov.layers.17.post_attention_layernorm.weight": "pytorch_model-00005-of-00010.bin",
|
131 |
+
"geov.layers.18.attention.causal_mask": "pytorch_model-00006-of-00010.bin",
|
132 |
+
"geov.layers.18.attention.dense.weight": "pytorch_model-00006-of-00010.bin",
|
133 |
+
"geov.layers.18.attention.qkv.bias": "pytorch_model-00006-of-00010.bin",
|
134 |
+
"geov.layers.18.attention.qkv.weight": "pytorch_model-00006-of-00010.bin",
|
135 |
+
"geov.layers.18.attention.rotary_emb.inv_freq": "pytorch_model-00006-of-00010.bin",
|
136 |
+
"geov.layers.18.input_layernorm.bias": "pytorch_model-00006-of-00010.bin",
|
137 |
+
"geov.layers.18.input_layernorm.weight": "pytorch_model-00006-of-00010.bin",
|
138 |
+
"geov.layers.18.mlp.dense_2h_to_h.weight": "pytorch_model-00006-of-00010.bin",
|
139 |
+
"geov.layers.18.mlp.dense_h_to_4h.bias": "pytorch_model-00006-of-00010.bin",
|
140 |
+
"geov.layers.18.mlp.dense_h_to_4h.weight": "pytorch_model-00006-of-00010.bin",
|
141 |
+
"geov.layers.18.post_attention_layernorm.bias": "pytorch_model-00006-of-00010.bin",
|
142 |
+
"geov.layers.18.post_attention_layernorm.weight": "pytorch_model-00006-of-00010.bin",
|
143 |
+
"geov.layers.19.attention.causal_mask": "pytorch_model-00006-of-00010.bin",
|
144 |
+
"geov.layers.19.attention.dense.weight": "pytorch_model-00006-of-00010.bin",
|
145 |
+
"geov.layers.19.attention.qkv.bias": "pytorch_model-00006-of-00010.bin",
|
146 |
+
"geov.layers.19.attention.qkv.weight": "pytorch_model-00006-of-00010.bin",
|
147 |
+
"geov.layers.19.attention.rotary_emb.inv_freq": "pytorch_model-00006-of-00010.bin",
|
148 |
+
"geov.layers.19.input_layernorm.bias": "pytorch_model-00006-of-00010.bin",
|
149 |
+
"geov.layers.19.input_layernorm.weight": "pytorch_model-00006-of-00010.bin",
|
150 |
+
"geov.layers.19.mlp.dense_2h_to_h.weight": "pytorch_model-00006-of-00010.bin",
|
151 |
+
"geov.layers.19.mlp.dense_h_to_4h.bias": "pytorch_model-00006-of-00010.bin",
|
152 |
+
"geov.layers.19.mlp.dense_h_to_4h.weight": "pytorch_model-00006-of-00010.bin",
|
153 |
+
"geov.layers.19.post_attention_layernorm.bias": "pytorch_model-00006-of-00010.bin",
|
154 |
+
"geov.layers.19.post_attention_layernorm.weight": "pytorch_model-00006-of-00010.bin",
|
155 |
+
"geov.layers.2.attention.causal_mask": "pytorch_model-00001-of-00010.bin",
|
156 |
+
"geov.layers.2.attention.dense.weight": "pytorch_model-00001-of-00010.bin",
|
157 |
+
"geov.layers.2.attention.qkv.bias": "pytorch_model-00001-of-00010.bin",
|
158 |
+
"geov.layers.2.attention.qkv.weight": "pytorch_model-00001-of-00010.bin",
|
159 |
+
"geov.layers.2.attention.rotary_emb.inv_freq": "pytorch_model-00001-of-00010.bin",
|
160 |
+
"geov.layers.2.input_layernorm.bias": "pytorch_model-00001-of-00010.bin",
|
161 |
+
"geov.layers.2.input_layernorm.weight": "pytorch_model-00001-of-00010.bin",
|
162 |
+
"geov.layers.2.mlp.dense_2h_to_h.weight": "pytorch_model-00002-of-00010.bin",
|
163 |
+
"geov.layers.2.mlp.dense_h_to_4h.bias": "pytorch_model-00002-of-00010.bin",
|
164 |
+
"geov.layers.2.mlp.dense_h_to_4h.weight": "pytorch_model-00002-of-00010.bin",
|
165 |
+
"geov.layers.2.post_attention_layernorm.bias": "pytorch_model-00001-of-00010.bin",
|
166 |
+
"geov.layers.2.post_attention_layernorm.weight": "pytorch_model-00001-of-00010.bin",
|
167 |
+
"geov.layers.20.attention.causal_mask": "pytorch_model-00006-of-00010.bin",
|
168 |
+
"geov.layers.20.attention.dense.weight": "pytorch_model-00006-of-00010.bin",
|
169 |
+
"geov.layers.20.attention.qkv.bias": "pytorch_model-00006-of-00010.bin",
|
170 |
+
"geov.layers.20.attention.qkv.weight": "pytorch_model-00006-of-00010.bin",
|
171 |
+
"geov.layers.20.attention.rotary_emb.inv_freq": "pytorch_model-00006-of-00010.bin",
|
172 |
+
"geov.layers.20.input_layernorm.bias": "pytorch_model-00006-of-00010.bin",
|
173 |
+
"geov.layers.20.input_layernorm.weight": "pytorch_model-00006-of-00010.bin",
|
174 |
+
"geov.layers.20.mlp.dense_2h_to_h.weight": "pytorch_model-00007-of-00010.bin",
|
175 |
+
"geov.layers.20.mlp.dense_h_to_4h.bias": "pytorch_model-00006-of-00010.bin",
|
176 |
+
"geov.layers.20.mlp.dense_h_to_4h.weight": "pytorch_model-00006-of-00010.bin",
|
177 |
+
"geov.layers.20.post_attention_layernorm.bias": "pytorch_model-00006-of-00010.bin",
|
178 |
+
"geov.layers.20.post_attention_layernorm.weight": "pytorch_model-00006-of-00010.bin",
|
179 |
+
"geov.layers.21.attention.causal_mask": "pytorch_model-00007-of-00010.bin",
|
180 |
+
"geov.layers.21.attention.dense.weight": "pytorch_model-00007-of-00010.bin",
|
181 |
+
"geov.layers.21.attention.qkv.bias": "pytorch_model-00007-of-00010.bin",
|
182 |
+
"geov.layers.21.attention.qkv.weight": "pytorch_model-00007-of-00010.bin",
|
183 |
+
"geov.layers.21.attention.rotary_emb.inv_freq": "pytorch_model-00007-of-00010.bin",
|
184 |
+
"geov.layers.21.input_layernorm.bias": "pytorch_model-00007-of-00010.bin",
|
185 |
+
"geov.layers.21.input_layernorm.weight": "pytorch_model-00007-of-00010.bin",
|
186 |
+
"geov.layers.21.mlp.dense_2h_to_h.weight": "pytorch_model-00007-of-00010.bin",
|
187 |
+
"geov.layers.21.mlp.dense_h_to_4h.bias": "pytorch_model-00007-of-00010.bin",
|
188 |
+
"geov.layers.21.mlp.dense_h_to_4h.weight": "pytorch_model-00007-of-00010.bin",
|
189 |
+
"geov.layers.21.post_attention_layernorm.bias": "pytorch_model-00007-of-00010.bin",
|
190 |
+
"geov.layers.21.post_attention_layernorm.weight": "pytorch_model-00007-of-00010.bin",
|
191 |
+
"geov.layers.22.attention.causal_mask": "pytorch_model-00007-of-00010.bin",
|
192 |
+
"geov.layers.22.attention.dense.weight": "pytorch_model-00007-of-00010.bin",
|
193 |
+
"geov.layers.22.attention.qkv.bias": "pytorch_model-00007-of-00010.bin",
|
194 |
+
"geov.layers.22.attention.qkv.weight": "pytorch_model-00007-of-00010.bin",
|
195 |
+
"geov.layers.22.attention.rotary_emb.inv_freq": "pytorch_model-00007-of-00010.bin",
|
196 |
+
"geov.layers.22.input_layernorm.bias": "pytorch_model-00007-of-00010.bin",
|
197 |
+
"geov.layers.22.input_layernorm.weight": "pytorch_model-00007-of-00010.bin",
|
198 |
+
"geov.layers.22.mlp.dense_2h_to_h.weight": "pytorch_model-00007-of-00010.bin",
|
199 |
+
"geov.layers.22.mlp.dense_h_to_4h.bias": "pytorch_model-00007-of-00010.bin",
|
200 |
+
"geov.layers.22.mlp.dense_h_to_4h.weight": "pytorch_model-00007-of-00010.bin",
|
201 |
+
"geov.layers.22.post_attention_layernorm.bias": "pytorch_model-00007-of-00010.bin",
|
202 |
+
"geov.layers.22.post_attention_layernorm.weight": "pytorch_model-00007-of-00010.bin",
|
203 |
+
"geov.layers.23.attention.causal_mask": "pytorch_model-00007-of-00010.bin",
|
204 |
+
"geov.layers.23.attention.dense.weight": "pytorch_model-00007-of-00010.bin",
|
205 |
+
"geov.layers.23.attention.qkv.bias": "pytorch_model-00007-of-00010.bin",
|
206 |
+
"geov.layers.23.attention.qkv.weight": "pytorch_model-00007-of-00010.bin",
|
207 |
+
"geov.layers.23.attention.rotary_emb.inv_freq": "pytorch_model-00007-of-00010.bin",
|
208 |
+
"geov.layers.23.input_layernorm.bias": "pytorch_model-00007-of-00010.bin",
|
209 |
+
"geov.layers.23.input_layernorm.weight": "pytorch_model-00007-of-00010.bin",
|
210 |
+
"geov.layers.23.mlp.dense_2h_to_h.weight": "pytorch_model-00007-of-00010.bin",
|
211 |
+
"geov.layers.23.mlp.dense_h_to_4h.bias": "pytorch_model-00007-of-00010.bin",
|
212 |
+
"geov.layers.23.mlp.dense_h_to_4h.weight": "pytorch_model-00007-of-00010.bin",
|
213 |
+
"geov.layers.23.post_attention_layernorm.bias": "pytorch_model-00007-of-00010.bin",
|
214 |
+
"geov.layers.23.post_attention_layernorm.weight": "pytorch_model-00007-of-00010.bin",
|
215 |
+
"geov.layers.24.attention.causal_mask": "pytorch_model-00007-of-00010.bin",
|
216 |
+
"geov.layers.24.attention.dense.weight": "pytorch_model-00007-of-00010.bin",
|
217 |
+
"geov.layers.24.attention.qkv.bias": "pytorch_model-00007-of-00010.bin",
|
218 |
+
"geov.layers.24.attention.qkv.weight": "pytorch_model-00007-of-00010.bin",
|
219 |
+
"geov.layers.24.attention.rotary_emb.inv_freq": "pytorch_model-00007-of-00010.bin",
|
220 |
+
"geov.layers.24.input_layernorm.bias": "pytorch_model-00007-of-00010.bin",
|
221 |
+
"geov.layers.24.input_layernorm.weight": "pytorch_model-00007-of-00010.bin",
|
222 |
+
"geov.layers.24.mlp.dense_2h_to_h.weight": "pytorch_model-00008-of-00010.bin",
|
223 |
+
"geov.layers.24.mlp.dense_h_to_4h.bias": "pytorch_model-00008-of-00010.bin",
|
224 |
+
"geov.layers.24.mlp.dense_h_to_4h.weight": "pytorch_model-00008-of-00010.bin",
|
225 |
+
"geov.layers.24.post_attention_layernorm.bias": "pytorch_model-00007-of-00010.bin",
|
226 |
+
"geov.layers.24.post_attention_layernorm.weight": "pytorch_model-00007-of-00010.bin",
|
227 |
+
"geov.layers.25.attention.causal_mask": "pytorch_model-00008-of-00010.bin",
|
228 |
+
"geov.layers.25.attention.dense.weight": "pytorch_model-00008-of-00010.bin",
|
229 |
+
"geov.layers.25.attention.qkv.bias": "pytorch_model-00008-of-00010.bin",
|
230 |
+
"geov.layers.25.attention.qkv.weight": "pytorch_model-00008-of-00010.bin",
|
231 |
+
"geov.layers.25.attention.rotary_emb.inv_freq": "pytorch_model-00008-of-00010.bin",
|
232 |
+
"geov.layers.25.input_layernorm.bias": "pytorch_model-00008-of-00010.bin",
|
233 |
+
"geov.layers.25.input_layernorm.weight": "pytorch_model-00008-of-00010.bin",
|
234 |
+
"geov.layers.25.mlp.dense_2h_to_h.weight": "pytorch_model-00008-of-00010.bin",
|
235 |
+
"geov.layers.25.mlp.dense_h_to_4h.bias": "pytorch_model-00008-of-00010.bin",
|
236 |
+
"geov.layers.25.mlp.dense_h_to_4h.weight": "pytorch_model-00008-of-00010.bin",
|
237 |
+
"geov.layers.25.post_attention_layernorm.bias": "pytorch_model-00008-of-00010.bin",
|
238 |
+
"geov.layers.25.post_attention_layernorm.weight": "pytorch_model-00008-of-00010.bin",
|
239 |
+
"geov.layers.26.attention.causal_mask": "pytorch_model-00008-of-00010.bin",
|
240 |
+
"geov.layers.26.attention.dense.weight": "pytorch_model-00008-of-00010.bin",
|
241 |
+
"geov.layers.26.attention.qkv.bias": "pytorch_model-00008-of-00010.bin",
|
242 |
+
"geov.layers.26.attention.qkv.weight": "pytorch_model-00008-of-00010.bin",
|
243 |
+
"geov.layers.26.attention.rotary_emb.inv_freq": "pytorch_model-00008-of-00010.bin",
|
244 |
+
"geov.layers.26.input_layernorm.bias": "pytorch_model-00008-of-00010.bin",
|
245 |
+
"geov.layers.26.input_layernorm.weight": "pytorch_model-00008-of-00010.bin",
|
246 |
+
"geov.layers.26.mlp.dense_2h_to_h.weight": "pytorch_model-00008-of-00010.bin",
|
247 |
+
"geov.layers.26.mlp.dense_h_to_4h.bias": "pytorch_model-00008-of-00010.bin",
|
248 |
+
"geov.layers.26.mlp.dense_h_to_4h.weight": "pytorch_model-00008-of-00010.bin",
|
249 |
+
"geov.layers.26.post_attention_layernorm.bias": "pytorch_model-00008-of-00010.bin",
|
250 |
+
"geov.layers.26.post_attention_layernorm.weight": "pytorch_model-00008-of-00010.bin",
|
251 |
+
"geov.layers.27.attention.causal_mask": "pytorch_model-00008-of-00010.bin",
|
252 |
+
"geov.layers.27.attention.dense.weight": "pytorch_model-00008-of-00010.bin",
|
253 |
+
"geov.layers.27.attention.qkv.bias": "pytorch_model-00008-of-00010.bin",
|
254 |
+
"geov.layers.27.attention.qkv.weight": "pytorch_model-00008-of-00010.bin",
|
255 |
+
"geov.layers.27.attention.rotary_emb.inv_freq": "pytorch_model-00008-of-00010.bin",
|
256 |
+
"geov.layers.27.input_layernorm.bias": "pytorch_model-00008-of-00010.bin",
|
257 |
+
"geov.layers.27.input_layernorm.weight": "pytorch_model-00008-of-00010.bin",
|
258 |
+
"geov.layers.27.mlp.dense_2h_to_h.weight": "pytorch_model-00008-of-00010.bin",
|
259 |
+
"geov.layers.27.mlp.dense_h_to_4h.bias": "pytorch_model-00008-of-00010.bin",
|
260 |
+
"geov.layers.27.mlp.dense_h_to_4h.weight": "pytorch_model-00008-of-00010.bin",
|
261 |
+
"geov.layers.27.post_attention_layernorm.bias": "pytorch_model-00008-of-00010.bin",
|
262 |
+
"geov.layers.27.post_attention_layernorm.weight": "pytorch_model-00008-of-00010.bin",
|
263 |
+
"geov.layers.28.attention.causal_mask": "pytorch_model-00008-of-00010.bin",
|
264 |
+
"geov.layers.28.attention.dense.weight": "pytorch_model-00009-of-00010.bin",
|
265 |
+
"geov.layers.28.attention.qkv.bias": "pytorch_model-00009-of-00010.bin",
|
266 |
+
"geov.layers.28.attention.qkv.weight": "pytorch_model-00009-of-00010.bin",
|
267 |
+
"geov.layers.28.attention.rotary_emb.inv_freq": "pytorch_model-00008-of-00010.bin",
|
268 |
+
"geov.layers.28.input_layernorm.bias": "pytorch_model-00008-of-00010.bin",
|
269 |
+
"geov.layers.28.input_layernorm.weight": "pytorch_model-00008-of-00010.bin",
|
270 |
+
"geov.layers.28.mlp.dense_2h_to_h.weight": "pytorch_model-00009-of-00010.bin",
|
271 |
+
"geov.layers.28.mlp.dense_h_to_4h.bias": "pytorch_model-00009-of-00010.bin",
|
272 |
+
"geov.layers.28.mlp.dense_h_to_4h.weight": "pytorch_model-00009-of-00010.bin",
|
273 |
+
"geov.layers.28.post_attention_layernorm.bias": "pytorch_model-00008-of-00010.bin",
|
274 |
+
"geov.layers.28.post_attention_layernorm.weight": "pytorch_model-00008-of-00010.bin",
|
275 |
+
"geov.layers.29.attention.causal_mask": "pytorch_model-00009-of-00010.bin",
|
276 |
+
"geov.layers.29.attention.dense.weight": "pytorch_model-00009-of-00010.bin",
|
277 |
+
"geov.layers.29.attention.qkv.bias": "pytorch_model-00009-of-00010.bin",
|
278 |
+
"geov.layers.29.attention.qkv.weight": "pytorch_model-00009-of-00010.bin",
|
279 |
+
"geov.layers.29.attention.rotary_emb.inv_freq": "pytorch_model-00009-of-00010.bin",
|
280 |
+
"geov.layers.29.input_layernorm.bias": "pytorch_model-00009-of-00010.bin",
|
281 |
+
"geov.layers.29.input_layernorm.weight": "pytorch_model-00009-of-00010.bin",
|
282 |
+
"geov.layers.29.mlp.dense_2h_to_h.weight": "pytorch_model-00009-of-00010.bin",
|
283 |
+
"geov.layers.29.mlp.dense_h_to_4h.bias": "pytorch_model-00009-of-00010.bin",
|
284 |
+
"geov.layers.29.mlp.dense_h_to_4h.weight": "pytorch_model-00009-of-00010.bin",
|
285 |
+
"geov.layers.29.post_attention_layernorm.bias": "pytorch_model-00009-of-00010.bin",
|
286 |
+
"geov.layers.29.post_attention_layernorm.weight": "pytorch_model-00009-of-00010.bin",
|
287 |
+
"geov.layers.3.attention.causal_mask": "pytorch_model-00002-of-00010.bin",
|
288 |
+
"geov.layers.3.attention.dense.weight": "pytorch_model-00002-of-00010.bin",
|
289 |
+
"geov.layers.3.attention.qkv.bias": "pytorch_model-00002-of-00010.bin",
|
290 |
+
"geov.layers.3.attention.qkv.weight": "pytorch_model-00002-of-00010.bin",
|
291 |
+
"geov.layers.3.attention.rotary_emb.inv_freq": "pytorch_model-00002-of-00010.bin",
|
292 |
+
"geov.layers.3.input_layernorm.bias": "pytorch_model-00002-of-00010.bin",
|
293 |
+
"geov.layers.3.input_layernorm.weight": "pytorch_model-00002-of-00010.bin",
|
294 |
+
"geov.layers.3.mlp.dense_2h_to_h.weight": "pytorch_model-00002-of-00010.bin",
|
295 |
+
"geov.layers.3.mlp.dense_h_to_4h.bias": "pytorch_model-00002-of-00010.bin",
|
296 |
+
"geov.layers.3.mlp.dense_h_to_4h.weight": "pytorch_model-00002-of-00010.bin",
|
297 |
+
"geov.layers.3.post_attention_layernorm.bias": "pytorch_model-00002-of-00010.bin",
|
298 |
+
"geov.layers.3.post_attention_layernorm.weight": "pytorch_model-00002-of-00010.bin",
|
299 |
+
"geov.layers.30.attention.causal_mask": "pytorch_model-00009-of-00010.bin",
|
300 |
+
"geov.layers.30.attention.dense.weight": "pytorch_model-00009-of-00010.bin",
|
301 |
+
"geov.layers.30.attention.qkv.bias": "pytorch_model-00009-of-00010.bin",
|
302 |
+
"geov.layers.30.attention.qkv.weight": "pytorch_model-00009-of-00010.bin",
|
303 |
+
"geov.layers.30.attention.rotary_emb.inv_freq": "pytorch_model-00009-of-00010.bin",
|
304 |
+
"geov.layers.30.input_layernorm.bias": "pytorch_model-00009-of-00010.bin",
|
305 |
+
"geov.layers.30.input_layernorm.weight": "pytorch_model-00009-of-00010.bin",
|
306 |
+
"geov.layers.30.mlp.dense_2h_to_h.weight": "pytorch_model-00009-of-00010.bin",
|
307 |
+
"geov.layers.30.mlp.dense_h_to_4h.bias": "pytorch_model-00009-of-00010.bin",
|
308 |
+
"geov.layers.30.mlp.dense_h_to_4h.weight": "pytorch_model-00009-of-00010.bin",
|
309 |
+
"geov.layers.30.post_attention_layernorm.bias": "pytorch_model-00009-of-00010.bin",
|
310 |
+
"geov.layers.30.post_attention_layernorm.weight": "pytorch_model-00009-of-00010.bin",
|
311 |
+
"geov.layers.31.attention.causal_mask": "pytorch_model-00009-of-00010.bin",
|
312 |
+
"geov.layers.31.attention.dense.weight": "pytorch_model-00009-of-00010.bin",
|
313 |
+
"geov.layers.31.attention.qkv.bias": "pytorch_model-00009-of-00010.bin",
|
314 |
+
"geov.layers.31.attention.qkv.weight": "pytorch_model-00009-of-00010.bin",
|
315 |
+
"geov.layers.31.attention.rotary_emb.inv_freq": "pytorch_model-00009-of-00010.bin",
|
316 |
+
"geov.layers.31.input_layernorm.bias": "pytorch_model-00009-of-00010.bin",
|
317 |
+
"geov.layers.31.input_layernorm.weight": "pytorch_model-00009-of-00010.bin",
|
318 |
+
"geov.layers.31.mlp.dense_2h_to_h.weight": "pytorch_model-00010-of-00010.bin",
|
319 |
+
"geov.layers.31.mlp.dense_h_to_4h.bias": "pytorch_model-00009-of-00010.bin",
|
320 |
+
"geov.layers.31.mlp.dense_h_to_4h.weight": "pytorch_model-00009-of-00010.bin",
|
321 |
+
"geov.layers.31.post_attention_layernorm.bias": "pytorch_model-00009-of-00010.bin",
|
322 |
+
"geov.layers.31.post_attention_layernorm.weight": "pytorch_model-00009-of-00010.bin",
|
323 |
+
"geov.layers.4.attention.causal_mask": "pytorch_model-00002-of-00010.bin",
|
324 |
+
"geov.layers.4.attention.dense.weight": "pytorch_model-00002-of-00010.bin",
|
325 |
+
"geov.layers.4.attention.qkv.bias": "pytorch_model-00002-of-00010.bin",
|
326 |
+
"geov.layers.4.attention.qkv.weight": "pytorch_model-00002-of-00010.bin",
|
327 |
+
"geov.layers.4.attention.rotary_emb.inv_freq": "pytorch_model-00002-of-00010.bin",
|
328 |
+
"geov.layers.4.input_layernorm.bias": "pytorch_model-00002-of-00010.bin",
|
329 |
+
"geov.layers.4.input_layernorm.weight": "pytorch_model-00002-of-00010.bin",
|
330 |
+
"geov.layers.4.mlp.dense_2h_to_h.weight": "pytorch_model-00002-of-00010.bin",
|
331 |
+
"geov.layers.4.mlp.dense_h_to_4h.bias": "pytorch_model-00002-of-00010.bin",
|
332 |
+
"geov.layers.4.mlp.dense_h_to_4h.weight": "pytorch_model-00002-of-00010.bin",
|
333 |
+
"geov.layers.4.post_attention_layernorm.bias": "pytorch_model-00002-of-00010.bin",
|
334 |
+
"geov.layers.4.post_attention_layernorm.weight": "pytorch_model-00002-of-00010.bin",
|
335 |
+
"geov.layers.5.attention.causal_mask": "pytorch_model-00002-of-00010.bin",
|
336 |
+
"geov.layers.5.attention.dense.weight": "pytorch_model-00002-of-00010.bin",
|
337 |
+
"geov.layers.5.attention.qkv.bias": "pytorch_model-00002-of-00010.bin",
|
338 |
+
"geov.layers.5.attention.qkv.weight": "pytorch_model-00002-of-00010.bin",
|
339 |
+
"geov.layers.5.attention.rotary_emb.inv_freq": "pytorch_model-00002-of-00010.bin",
|
340 |
+
"geov.layers.5.input_layernorm.bias": "pytorch_model-00002-of-00010.bin",
|
341 |
+
"geov.layers.5.input_layernorm.weight": "pytorch_model-00002-of-00010.bin",
|
342 |
+
"geov.layers.5.mlp.dense_2h_to_h.weight": "pytorch_model-00002-of-00010.bin",
|
343 |
+
"geov.layers.5.mlp.dense_h_to_4h.bias": "pytorch_model-00002-of-00010.bin",
|
344 |
+
"geov.layers.5.mlp.dense_h_to_4h.weight": "pytorch_model-00002-of-00010.bin",
|
345 |
+
"geov.layers.5.post_attention_layernorm.bias": "pytorch_model-00002-of-00010.bin",
|
346 |
+
"geov.layers.5.post_attention_layernorm.weight": "pytorch_model-00002-of-00010.bin",
|
347 |
+
"geov.layers.6.attention.causal_mask": "pytorch_model-00002-of-00010.bin",
|
348 |
+
"geov.layers.6.attention.dense.weight": "pytorch_model-00003-of-00010.bin",
|
349 |
+
"geov.layers.6.attention.qkv.bias": "pytorch_model-00003-of-00010.bin",
|
350 |
+
"geov.layers.6.attention.qkv.weight": "pytorch_model-00003-of-00010.bin",
|
351 |
+
"geov.layers.6.attention.rotary_emb.inv_freq": "pytorch_model-00002-of-00010.bin",
|
352 |
+
"geov.layers.6.input_layernorm.bias": "pytorch_model-00002-of-00010.bin",
|
353 |
+
"geov.layers.6.input_layernorm.weight": "pytorch_model-00002-of-00010.bin",
|
354 |
+
"geov.layers.6.mlp.dense_2h_to_h.weight": "pytorch_model-00003-of-00010.bin",
|
355 |
+
"geov.layers.6.mlp.dense_h_to_4h.bias": "pytorch_model-00003-of-00010.bin",
|
356 |
+
"geov.layers.6.mlp.dense_h_to_4h.weight": "pytorch_model-00003-of-00010.bin",
|
357 |
+
"geov.layers.6.post_attention_layernorm.bias": "pytorch_model-00002-of-00010.bin",
|
358 |
+
"geov.layers.6.post_attention_layernorm.weight": "pytorch_model-00002-of-00010.bin",
|
359 |
+
"geov.layers.7.attention.causal_mask": "pytorch_model-00003-of-00010.bin",
|
360 |
+
"geov.layers.7.attention.dense.weight": "pytorch_model-00003-of-00010.bin",
|
361 |
+
"geov.layers.7.attention.qkv.bias": "pytorch_model-00003-of-00010.bin",
|
362 |
+
"geov.layers.7.attention.qkv.weight": "pytorch_model-00003-of-00010.bin",
|
363 |
+
"geov.layers.7.attention.rotary_emb.inv_freq": "pytorch_model-00003-of-00010.bin",
|
364 |
+
"geov.layers.7.input_layernorm.bias": "pytorch_model-00003-of-00010.bin",
|
365 |
+
"geov.layers.7.input_layernorm.weight": "pytorch_model-00003-of-00010.bin",
|
366 |
+
"geov.layers.7.mlp.dense_2h_to_h.weight": "pytorch_model-00003-of-00010.bin",
|
367 |
+
"geov.layers.7.mlp.dense_h_to_4h.bias": "pytorch_model-00003-of-00010.bin",
|
368 |
+
"geov.layers.7.mlp.dense_h_to_4h.weight": "pytorch_model-00003-of-00010.bin",
|
369 |
+
"geov.layers.7.post_attention_layernorm.bias": "pytorch_model-00003-of-00010.bin",
|
370 |
+
"geov.layers.7.post_attention_layernorm.weight": "pytorch_model-00003-of-00010.bin",
|
371 |
+
"geov.layers.8.attention.causal_mask": "pytorch_model-00003-of-00010.bin",
|
372 |
+
"geov.layers.8.attention.dense.weight": "pytorch_model-00003-of-00010.bin",
|
373 |
+
"geov.layers.8.attention.qkv.bias": "pytorch_model-00003-of-00010.bin",
|
374 |
+
"geov.layers.8.attention.qkv.weight": "pytorch_model-00003-of-00010.bin",
|
375 |
+
"geov.layers.8.attention.rotary_emb.inv_freq": "pytorch_model-00003-of-00010.bin",
|
376 |
+
"geov.layers.8.input_layernorm.bias": "pytorch_model-00003-of-00010.bin",
|
377 |
+
"geov.layers.8.input_layernorm.weight": "pytorch_model-00003-of-00010.bin",
|
378 |
+
"geov.layers.8.mlp.dense_2h_to_h.weight": "pytorch_model-00003-of-00010.bin",
|
379 |
+
"geov.layers.8.mlp.dense_h_to_4h.bias": "pytorch_model-00003-of-00010.bin",
|
380 |
+
"geov.layers.8.mlp.dense_h_to_4h.weight": "pytorch_model-00003-of-00010.bin",
|
381 |
+
"geov.layers.8.post_attention_layernorm.bias": "pytorch_model-00003-of-00010.bin",
|
382 |
+
"geov.layers.8.post_attention_layernorm.weight": "pytorch_model-00003-of-00010.bin",
|
383 |
+
"geov.layers.9.attention.causal_mask": "pytorch_model-00003-of-00010.bin",
|
384 |
+
"geov.layers.9.attention.dense.weight": "pytorch_model-00003-of-00010.bin",
|
385 |
+
"geov.layers.9.attention.qkv.bias": "pytorch_model-00003-of-00010.bin",
|
386 |
+
"geov.layers.9.attention.qkv.weight": "pytorch_model-00003-of-00010.bin",
|
387 |
+
"geov.layers.9.attention.rotary_emb.inv_freq": "pytorch_model-00003-of-00010.bin",
|
388 |
+
"geov.layers.9.input_layernorm.bias": "pytorch_model-00003-of-00010.bin",
|
389 |
+
"geov.layers.9.input_layernorm.weight": "pytorch_model-00003-of-00010.bin",
|
390 |
+
"geov.layers.9.mlp.dense_2h_to_h.weight": "pytorch_model-00004-of-00010.bin",
|
391 |
+
"geov.layers.9.mlp.dense_h_to_4h.bias": "pytorch_model-00003-of-00010.bin",
|
392 |
+
"geov.layers.9.mlp.dense_h_to_4h.weight": "pytorch_model-00003-of-00010.bin",
|
393 |
+
"geov.layers.9.post_attention_layernorm.bias": "pytorch_model-00003-of-00010.bin",
|
394 |
+
"geov.layers.9.post_attention_layernorm.weight": "pytorch_model-00003-of-00010.bin"
|
395 |
+
}
|
396 |
+
}
|
special_tokens_map.json
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"bos_token": "<s>",
|
3 |
+
"eos_token": "</s>",
|
4 |
+
"unk_token": "<unk>"
|
5 |
+
}
|
spiece.model
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:42005475648603fbcb46bf8d08f4ade44c8546c6b37f8048bb5333b7b725ab85
|
3 |
+
size 1269630
|
tokenization_geov.py
ADDED
@@ -0,0 +1,177 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# coding=utf-8
|
2 |
+
# Copyright 2023 Better Planet Investments and labml.ai team. ALl rights reserved.
|
3 |
+
#
|
4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
+
# you may not use this file except in compliance with the License.
|
6 |
+
# You may obtain a copy of the License at
|
7 |
+
#
|
8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9 |
+
#
|
10 |
+
# Unless required by applicable law or agreed to in writing, software
|
11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13 |
+
# See the License for the specific language governing permissions and
|
14 |
+
# limitations under the License.
|
15 |
+
"""Tokenization classes for GeoV."""
|
16 |
+
from pathlib import Path
|
17 |
+
from typing import List, Optional, Tuple
|
18 |
+
|
19 |
+
import sentencepiece as spm
|
20 |
+
|
21 |
+
from transformers.tokenization_utils import PreTrainedTokenizer
|
22 |
+
from transformers.utils import SPIECE_UNDERLINE, logging
|
23 |
+
|
24 |
+
logger = logging.get_logger(__name__)
|
25 |
+
|
26 |
+
VOCAB_FILES_NAMES = {"vocab_file": "spiece.model"}
|
27 |
+
|
28 |
+
PRETRAINED_VOCAB_FILES_MAP = {
|
29 |
+
"vocab_file": {
|
30 |
+
"GeoV/GeoV-9b": "https://huggingface.co/GeoV/GeoV-9b/resolve/main/spiece.model",
|
31 |
+
}
|
32 |
+
}
|
33 |
+
|
34 |
+
PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES = {
|
35 |
+
"GeoV-9b": 2048,
|
36 |
+
}
|
37 |
+
|
38 |
+
|
39 |
+
class GeoVTokenizer(PreTrainedTokenizer):
|
40 |
+
"""
|
41 |
+
Construct an GeoV tokenizer. Based on [SentencePiece](https://github.com/google/sentencepiece).
|
42 |
+
|
43 |
+
This tokenizer inherits from [`PreTrainedTokenizer`] which contains most of the main methods. Users should refer to
|
44 |
+
this superclass for more information regarding those methods.
|
45 |
+
|
46 |
+
Args:
|
47 |
+
vocab_file (`str`):
|
48 |
+
[SentencePiece](https://github.com/google/sentencepiece) file (generally has a .spm extension) that
|
49 |
+
contains the vocabulary necessary to instantiate a tokenizer.
|
50 |
+
bos_token (`str`, *optional*, defaults to `"<s>"`):
|
51 |
+
The beginning of sequence token that was used during pretraining.
|
52 |
+
|
53 |
+
eos_token (`str`, *optional*, defaults to `"</s>"`):
|
54 |
+
The end of sequence token.
|
55 |
+
|
56 |
+
unk_token (`str`, *optional*, defaults to `"<unk>"`):
|
57 |
+
The unknown token. A token that is not in the vocabulary cannot be converted to an ID and is set to be this
|
58 |
+
token instead.
|
59 |
+
|
60 |
+
new_line_token_id (`int`, *optional*, defaults to `65_499`):
|
61 |
+
The token id of new line character.
|
62 |
+
|
63 |
+
Attributes:
|
64 |
+
sp_model (`SentencePieceProcessor`):
|
65 |
+
The *SentencePiece* processor that is used for every conversion (string, tokens and IDs).
|
66 |
+
"""
|
67 |
+
|
68 |
+
vocab_files_names = VOCAB_FILES_NAMES
|
69 |
+
pretrained_vocab_files_map = PRETRAINED_VOCAB_FILES_MAP
|
70 |
+
max_model_input_sizes = PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
|
71 |
+
model_input_names = ["input_ids", "attention_mask"]
|
72 |
+
|
73 |
+
def __init__(
|
74 |
+
self,
|
75 |
+
vocab_file,
|
76 |
+
bos_token="<s>",
|
77 |
+
eos_token="</s>",
|
78 |
+
unk_token="<unk>",
|
79 |
+
new_line_token_id=65_499,
|
80 |
+
**kwargs,
|
81 |
+
) -> None:
|
82 |
+
super().__init__(
|
83 |
+
bos_token=bos_token,
|
84 |
+
eos_token=eos_token,
|
85 |
+
unk_token=unk_token,
|
86 |
+
new_line_token_id=new_line_token_id,
|
87 |
+
**kwargs,
|
88 |
+
)
|
89 |
+
self.vocab_file = vocab_file
|
90 |
+
self.new_line_token_id = new_line_token_id
|
91 |
+
|
92 |
+
self.sp_model = spm.SentencePieceProcessor()
|
93 |
+
self.sp_model.Load(vocab_file)
|
94 |
+
|
95 |
+
@property
|
96 |
+
def vocab_size(self):
|
97 |
+
return len(self.sp_model)
|
98 |
+
|
99 |
+
def get_vocab(self):
|
100 |
+
vocab = {self.convert_ids_to_tokens(i): i for i in range(self.vocab_size)}
|
101 |
+
vocab.update(self.added_tokens_encoder)
|
102 |
+
return vocab
|
103 |
+
|
104 |
+
def __getstate__(self):
|
105 |
+
state = self.__dict__.copy()
|
106 |
+
state["sp_model"] = None
|
107 |
+
return state
|
108 |
+
|
109 |
+
def __setstate__(self, d):
|
110 |
+
self.__dict__ = d
|
111 |
+
|
112 |
+
self.sp_model = spm.SentencePieceProcessor()
|
113 |
+
self.sp_model.Load(self.vocab_file)
|
114 |
+
|
115 |
+
def _tokenize(self, text: str) -> List[str]:
|
116 |
+
"""Tokenize a string."""
|
117 |
+
ret = []
|
118 |
+
split_text = text.splitlines()
|
119 |
+
for l in split_text:
|
120 |
+
rl = self.sp_model.encode(l, out_type=str)
|
121 |
+
ret.extend(rl)
|
122 |
+
ret.append("\n")
|
123 |
+
ret = ret[:-1]
|
124 |
+
return ret
|
125 |
+
|
126 |
+
def _convert_token_to_id(self, token):
|
127 |
+
"""Converts a token (str) in an id using the vocab."""
|
128 |
+
if token == "\n":
|
129 |
+
return self.new_line_token_id
|
130 |
+
return self.sp_model.PieceToId(token)
|
131 |
+
|
132 |
+
def _convert_id_to_token(self, index):
|
133 |
+
"""Converts an index (integer) in a token (str) using the vocab."""
|
134 |
+
if index == self.new_line_token_id:
|
135 |
+
return "\n"
|
136 |
+
return self.sp_model.IdToPiece(index)
|
137 |
+
|
138 |
+
def convert_tokens_to_string(self, tokens):
|
139 |
+
"""Converts a sequence of tokens (strings for sub-words) in a single string."""
|
140 |
+
out_string = "".join(tokens).replace(SPIECE_UNDERLINE, " ").strip()
|
141 |
+
return out_string
|
142 |
+
|
143 |
+
def _decode(
|
144 |
+
self,
|
145 |
+
token_ids: List[int],
|
146 |
+
skip_special_tokens: bool = False,
|
147 |
+
clean_up_tokenization_spaces: bool = True,
|
148 |
+
spaces_between_special_tokens: bool = True,
|
149 |
+
**kwargs,
|
150 |
+
) -> str:
|
151 |
+
filtered_tokens = self.convert_ids_to_tokens(token_ids, skip_special_tokens=skip_special_tokens)
|
152 |
+
|
153 |
+
if skip_special_tokens:
|
154 |
+
filtered_tokens = [t for t in filtered_tokens if t not in self.all_special_ids]
|
155 |
+
|
156 |
+
text = self.convert_tokens_to_string(filtered_tokens)
|
157 |
+
|
158 |
+
if clean_up_tokenization_spaces:
|
159 |
+
clean_text = self.clean_up_tokenization(text)
|
160 |
+
return clean_text
|
161 |
+
else:
|
162 |
+
return text
|
163 |
+
|
164 |
+
def save_vocabulary(self, save_directory: str, filename_prefix: Optional[str] = None) -> Tuple[str]:
|
165 |
+
save_directory = Path(save_directory)
|
166 |
+
if not save_directory.is_dir():
|
167 |
+
raise ValueError(f"Vocabulary path ({save_directory}) should be a directory")
|
168 |
+
vocab_fn = VOCAB_FILES_NAMES["vocab_file"]
|
169 |
+
filename_prefix = f"{filename_prefix}-" if filename_prefix else ""
|
170 |
+
|
171 |
+
vocab_file = save_directory / f"{filename_prefix}{vocab_fn}"
|
172 |
+
|
173 |
+
with open(str(vocab_file), "wb") as fi:
|
174 |
+
content_spiece_model = self.sp_model.serialized_model_proto()
|
175 |
+
fi.write(content_spiece_model)
|
176 |
+
|
177 |
+
return (str(vocab_file),)
|
tokenizer_config.json
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"auto_map": {
|
3 |
+
"AutoTokenizer": [
|
4 |
+
"tokenization_geov.GeoVTokenizer",
|
5 |
+
null
|
6 |
+
]
|
7 |
+
},
|
8 |
+
"bos_token": "<s>",
|
9 |
+
"eos_token": "</s>",
|
10 |
+
"model_max_length": 1000000000000000019884624838656,
|
11 |
+
"new_line_token_id": 65500,
|
12 |
+
"tokenizer_class": "GeoVTokenizer",
|
13 |
+
"unk_token": "<unk>"
|
14 |
+
}
|