Delete configuration_rwkv5.py
Browse files- configuration_rwkv5.py +0 -118
configuration_rwkv5.py
DELETED
@@ -1,118 +0,0 @@
|
|
1 |
-
# coding=utf-8
|
2 |
-
# Copyright 2023 The OpenAI Team Authors and HuggingFace Inc. team.
|
3 |
-
# Copyright (c) 2018, NVIDIA CORPORATION. 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 |
-
""" RWKV configuration"""
|
17 |
-
|
18 |
-
from transformers.configuration_utils import PretrainedConfig
|
19 |
-
from transformers.utils import logging
|
20 |
-
|
21 |
-
|
22 |
-
logger = logging.get_logger(__name__)
|
23 |
-
|
24 |
-
RWKV5_PRETRAINED_CONFIG_ARCHIVE_MAP = {}
|
25 |
-
|
26 |
-
|
27 |
-
class Rwkv5Config(PretrainedConfig):
|
28 |
-
"""
|
29 |
-
This is the configuration class to store the configuration of a [`Rwkv5Model`]. It is used to instantiate a RWKV5
|
30 |
-
model according to the specified arguments, defining the model architecture. Instantiating a configuration with the
|
31 |
-
defaults will yield a similar configuration to that of the RWVK-4
|
32 |
-
[RWKV/rwkv-5-world-1b5](https://huggingface.co/RWKV/rwkv-5-world-1b5) architecture.
|
33 |
-
|
34 |
-
Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
|
35 |
-
documentation from [`PretrainedConfig`] for more information.
|
36 |
-
|
37 |
-
|
38 |
-
Args:
|
39 |
-
vocab_size (`int`, *optional*, defaults to 65536):
|
40 |
-
Vocabulary size of the RWKV5 model. Defines the number of different tokens that can be represented by the
|
41 |
-
`inputs_ids` passed when calling [`Rwkv5Model`].
|
42 |
-
hidden_size (`int`, *optional*, defaults to 768):
|
43 |
-
Dimensionality of the embeddings and hidden states.
|
44 |
-
num_hidden_layers (`int`, *optional*, defaults to 24):
|
45 |
-
Number of hidden layers in the model.
|
46 |
-
attention_hidden_size (`int`, *optional*):
|
47 |
-
Dimensionality of the attention hidden states. Will default to `hidden_size` if unset.
|
48 |
-
num_attention_heads (`int`, *optional*, defaults to 64):
|
49 |
-
The attention heads to use in rwkv5 self_attention module.
|
50 |
-
head_size (`int`, *optional*, defaults to 64): head_size of rwkv5 self_attention module.
|
51 |
-
intermediate_size (`int`, *optional*):
|
52 |
-
Dimensionality of the inner feed-forward layers. Will default to 4 times `hidden_size` if unset.
|
53 |
-
layer_norm_epsilon (`float`, *optional*, defaults to 1e-05):
|
54 |
-
The epsilon to use in the layer normalization layers.
|
55 |
-
bos_token_id (`int`, *optional*, defaults to 0):
|
56 |
-
The id of the beginning of sentence token in the vocabulary. Defaults to 0.
|
57 |
-
eos_token_id (`int`, *optional*, defaults to 0):
|
58 |
-
The id of the end of sentence token in the vocabulary. Defaults to 0.
|
59 |
-
rescale_every (`int`, *optional*, defaults to 6):
|
60 |
-
At inference, the hidden states (and weights of the correponding output layers) are divided by 2 every
|
61 |
-
`rescale_every` layer. If set to 0 or a negative number, no rescale is done.
|
62 |
-
tie_word_embeddings (`bool`, *optional*, defaults to `False`):
|
63 |
-
Whether or not to tie the word embeddings with the input token embeddings.
|
64 |
-
use_cache (`bool`, *optional*, defaults to `True`):
|
65 |
-
Whether or not the model should return the last state.
|
66 |
-
|
67 |
-
|
68 |
-
Example:
|
69 |
-
|
70 |
-
```python
|
71 |
-
>>> from transformers import Rwkv5Config, Rwkv5Model
|
72 |
-
|
73 |
-
>>> # Initializing a Rwkv5 configuration
|
74 |
-
>>> configuration = Rwkv5Config()
|
75 |
-
|
76 |
-
>>> # Initializing a model (with random weights) from the configuration
|
77 |
-
>>> model = Rwkv5Model(configuration)
|
78 |
-
|
79 |
-
>>> # Accessing the model configuration
|
80 |
-
>>> configuration = model.config
|
81 |
-
```"""
|
82 |
-
|
83 |
-
model_type = "rwkv5"
|
84 |
-
|
85 |
-
def __init__(
|
86 |
-
self,
|
87 |
-
vocab_size=65536,
|
88 |
-
hidden_size=768,
|
89 |
-
num_hidden_layers=24,
|
90 |
-
attention_hidden_size=None,
|
91 |
-
head_size=64,
|
92 |
-
head_size_divisor=8,
|
93 |
-
intermediate_size=None,
|
94 |
-
layer_norm_epsilon=1e-5,
|
95 |
-
bos_token_id=0,
|
96 |
-
eos_token_id=0,
|
97 |
-
rescale_every=6,
|
98 |
-
tie_word_embeddings=False,
|
99 |
-
use_cache=True,
|
100 |
-
**kwargs,
|
101 |
-
):
|
102 |
-
self.vocab_size = vocab_size
|
103 |
-
self.hidden_size = hidden_size
|
104 |
-
self.num_hidden_layers = num_hidden_layers
|
105 |
-
self.attention_hidden_size = attention_hidden_size if attention_hidden_size is not None else hidden_size
|
106 |
-
self.head_size = head_size
|
107 |
-
self.head_size_divisor = head_size_divisor
|
108 |
-
self.intermediate_size = None
|
109 |
-
self.layer_norm_epsilon = layer_norm_epsilon
|
110 |
-
self.rescale_every = rescale_every
|
111 |
-
self.use_cache = use_cache
|
112 |
-
|
113 |
-
self.bos_token_id = bos_token_id
|
114 |
-
self.eos_token_id = eos_token_id
|
115 |
-
|
116 |
-
super().__init__(
|
117 |
-
tie_word_embeddings=tie_word_embeddings, bos_token_id=bos_token_id, eos_token_id=eos_token_id, **kwargs
|
118 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|