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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
library_name: transformers
|
| 3 |
+
tags: []
|
| 4 |
+
---
|
| 5 |
+
|
| 6 |
+
# Model Card for Model ID
|
| 7 |
+
|
| 8 |
+
<!-- Provide a quick summary of what the model is/does. -->
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
## Model Details
|
| 13 |
+
|
| 14 |
+
### Model Description
|
| 15 |
+
|
| 16 |
+
<!-- Provide a longer summary of what this model is. -->
|
| 17 |
+
|
| 18 |
+
This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
|
| 19 |
+
|
| 20 |
+
- **Developed by:** [More Information Needed]
|
| 21 |
+
- **Funded by [optional]:** [More Information Needed]
|
| 22 |
+
- **Shared by [optional]:** [More Information Needed]
|
| 23 |
+
- **Model type:** [More Information Needed]
|
| 24 |
+
- **Language(s) (NLP):** [More Information Needed]
|
| 25 |
+
- **License:** [More Information Needed]
|
| 26 |
+
- **Finetuned from model [optional]:** [More Information Needed]
|
| 27 |
+
|
| 28 |
+
### Model Sources [optional]
|
| 29 |
+
|
| 30 |
+
<!-- Provide the basic links for the model. -->
|
| 31 |
+
|
| 32 |
+
- **Repository:** [More Information Needed]
|
| 33 |
+
- **Paper [optional]:** [More Information Needed]
|
| 34 |
+
- **Demo [optional]:** [More Information Needed]
|
| 35 |
+
|
| 36 |
+
## Uses
|
| 37 |
+
|
| 38 |
+
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
| 39 |
+
|
| 40 |
+
### Direct Use
|
| 41 |
+
|
| 42 |
+
<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
|
| 43 |
+
|
| 44 |
+
[More Information Needed]
|
| 45 |
+
|
| 46 |
+
### Downstream Use [optional]
|
| 47 |
+
|
| 48 |
+
<!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
|
| 49 |
+
|
| 50 |
+
[More Information Needed]
|
| 51 |
+
|
| 52 |
+
### Out-of-Scope Use
|
| 53 |
+
|
| 54 |
+
<!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
|
| 55 |
+
|
| 56 |
+
[More Information Needed]
|
| 57 |
+
|
| 58 |
+
## Bias, Risks, and Limitations
|
| 59 |
+
|
| 60 |
+
<!-- This section is meant to convey both technical and sociotechnical limitations. -->
|
| 61 |
+
|
| 62 |
+
[More Information Needed]
|
| 63 |
+
|
| 64 |
+
### Recommendations
|
| 65 |
+
|
| 66 |
+
<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
|
| 67 |
+
|
| 68 |
+
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
|
| 69 |
+
|
| 70 |
+
## How to Get Started with the Model
|
| 71 |
+
|
| 72 |
+
Use the code below to get started with the model.
|
| 73 |
+
|
| 74 |
+
[More Information Needed]
|
| 75 |
+
|
| 76 |
+
## Training Details
|
| 77 |
+
|
| 78 |
+
### Training Data
|
| 79 |
+
|
| 80 |
+
<!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
|
| 81 |
+
|
| 82 |
+
[More Information Needed]
|
| 83 |
+
|
| 84 |
+
### Training Procedure
|
| 85 |
+
|
| 86 |
+
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
|
| 87 |
+
|
| 88 |
+
#### Preprocessing [optional]
|
| 89 |
+
|
| 90 |
+
[More Information Needed]
|
| 91 |
+
|
| 92 |
+
|
| 93 |
+
#### Training Hyperparameters
|
| 94 |
+
|
| 95 |
+
- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
|
| 96 |
+
|
| 97 |
+
#### Speeds, Sizes, Times [optional]
|
| 98 |
+
|
| 99 |
+
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
| 100 |
+
|
| 101 |
+
[More Information Needed]
|
| 102 |
+
|
| 103 |
+
## Evaluation
|
| 104 |
+
|
| 105 |
+
<!-- This section describes the evaluation protocols and provides the results. -->
|
| 106 |
+
|
| 107 |
+
### Testing Data, Factors & Metrics
|
| 108 |
+
|
| 109 |
+
#### Testing Data
|
| 110 |
+
|
| 111 |
+
<!-- This should link to a Dataset Card if possible. -->
|
| 112 |
+
|
| 113 |
+
[More Information Needed]
|
| 114 |
+
|
| 115 |
+
#### Factors
|
| 116 |
+
|
| 117 |
+
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
| 118 |
+
|
| 119 |
+
[More Information Needed]
|
| 120 |
+
|
| 121 |
+
#### Metrics
|
| 122 |
+
|
| 123 |
+
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
| 124 |
+
|
| 125 |
+
[More Information Needed]
|
| 126 |
+
|
| 127 |
+
### Results
|
| 128 |
+
|
| 129 |
+
[More Information Needed]
|
| 130 |
+
|
| 131 |
+
#### Summary
|
| 132 |
+
|
| 133 |
+
|
| 134 |
+
|
| 135 |
+
## Model Examination [optional]
|
| 136 |
+
|
| 137 |
+
<!-- Relevant interpretability work for the model goes here -->
|
| 138 |
+
|
| 139 |
+
[More Information Needed]
|
| 140 |
+
|
| 141 |
+
## Environmental Impact
|
| 142 |
+
|
| 143 |
+
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
| 144 |
+
|
| 145 |
+
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
|
| 146 |
+
|
| 147 |
+
- **Hardware Type:** [More Information Needed]
|
| 148 |
+
- **Hours used:** [More Information Needed]
|
| 149 |
+
- **Cloud Provider:** [More Information Needed]
|
| 150 |
+
- **Compute Region:** [More Information Needed]
|
| 151 |
+
- **Carbon Emitted:** [More Information Needed]
|
| 152 |
+
|
| 153 |
+
## Technical Specifications [optional]
|
| 154 |
+
|
| 155 |
+
### Model Architecture and Objective
|
| 156 |
+
|
| 157 |
+
[More Information Needed]
|
| 158 |
+
|
| 159 |
+
### Compute Infrastructure
|
| 160 |
+
|
| 161 |
+
[More Information Needed]
|
| 162 |
+
|
| 163 |
+
#### Hardware
|
| 164 |
+
|
| 165 |
+
[More Information Needed]
|
| 166 |
+
|
| 167 |
+
#### Software
|
| 168 |
+
|
| 169 |
+
[More Information Needed]
|
| 170 |
+
|
| 171 |
+
## Citation [optional]
|
| 172 |
+
|
| 173 |
+
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
| 174 |
+
|
| 175 |
+
**BibTeX:**
|
| 176 |
+
|
| 177 |
+
[More Information Needed]
|
| 178 |
+
|
| 179 |
+
**APA:**
|
| 180 |
+
|
| 181 |
+
[More Information Needed]
|
| 182 |
+
|
| 183 |
+
## Glossary [optional]
|
| 184 |
+
|
| 185 |
+
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
| 186 |
+
|
| 187 |
+
[More Information Needed]
|
| 188 |
+
|
| 189 |
+
## More Information [optional]
|
| 190 |
+
|
| 191 |
+
[More Information Needed]
|
| 192 |
+
|
| 193 |
+
## Model Card Authors [optional]
|
| 194 |
+
|
| 195 |
+
[More Information Needed]
|
| 196 |
+
|
| 197 |
+
## Model Card Contact
|
| 198 |
+
|
| 199 |
+
[More Information Needed]
|
config.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"activation_function": "gelu_new",
|
| 3 |
+
"architectures": [
|
| 4 |
+
"GPT2MIMOLMHeadModel"
|
| 5 |
+
],
|
| 6 |
+
"attn_pdrop": 0.1,
|
| 7 |
+
"auto_map": {
|
| 8 |
+
"AutoConfig": "configuration_gpt2mimo.GPT2MIMOConfig",
|
| 9 |
+
"AutoModel": "modeling_gpt2mimo.GPT2MIMOModel",
|
| 10 |
+
"AutoModelForCausalLM": "modeling_gpt2mimo.GPT2MIMOLMHeadModel"
|
| 11 |
+
},
|
| 12 |
+
"bos_token_id": 50256,
|
| 13 |
+
"embd_pdrop": 0.1,
|
| 14 |
+
"eos_token_id": 50256,
|
| 15 |
+
"initializer_range": 0.02,
|
| 16 |
+
"layer_norm_epsilon": 1e-05,
|
| 17 |
+
"model_type": "gpt2mimo",
|
| 18 |
+
"n_embd": 768,
|
| 19 |
+
"n_head": 12,
|
| 20 |
+
"n_inner": null,
|
| 21 |
+
"n_layer": 12,
|
| 22 |
+
"n_positions": 1024,
|
| 23 |
+
"reorder_and_upcast_attn": false,
|
| 24 |
+
"resid_pdrop": 0.1,
|
| 25 |
+
"scale_attn_by_inverse_layer_idx": false,
|
| 26 |
+
"scale_attn_weights": true,
|
| 27 |
+
"summary_activation": null,
|
| 28 |
+
"summary_first_dropout": 0.1,
|
| 29 |
+
"summary_proj_to_labels": true,
|
| 30 |
+
"summary_type": "cls_index",
|
| 31 |
+
"summary_use_proj": true,
|
| 32 |
+
"torch_dtype": "float32",
|
| 33 |
+
"transformers_version": "4.41.1",
|
| 34 |
+
"use_cache": true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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# coding=utf-8
|
| 2 |
+
# Copyright 2018 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 |
+
"""OpenAI GPT-2 configuration"""
|
| 17 |
+
|
| 18 |
+
from collections import OrderedDict
|
| 19 |
+
from typing import Any, List, Mapping, Optional
|
| 20 |
+
|
| 21 |
+
from transformers import PreTrainedTokenizer
|
| 22 |
+
from transformers.utils import TensorType, is_torch_available, logging
|
| 23 |
+
from transformers.configuration_utils import PretrainedConfig
|
| 24 |
+
from transformers.onnx import OnnxConfigWithPast, PatchingSpec
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
logger = logging.get_logger(__name__)
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
class GPT2MIMOConfig(PretrainedConfig):
|
| 31 |
+
"""
|
| 32 |
+
This is the configuration class to store the configuration of a [`GPT2Model`] or a [`TFGPT2Model`]. It is used to
|
| 33 |
+
instantiate a GPT-2 model according to the specified arguments, defining the model architecture. Instantiating a
|
| 34 |
+
configuration with the defaults will yield a similar configuration to that of the GPT-2
|
| 35 |
+
[openai-community/gpt2](https://huggingface.co/openai-community/gpt2) architecture.
|
| 36 |
+
|
| 37 |
+
Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
|
| 38 |
+
documentation from [`PretrainedConfig`] for more information.
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
Args:
|
| 42 |
+
vocab_size (`int`, *optional*, defaults to 50257):
|
| 43 |
+
Vocabulary size of the GPT-2 model. Defines the number of different tokens that can be represented by the
|
| 44 |
+
`inputs_ids` passed when calling [`GPT2Model`] or [`TFGPT2Model`].
|
| 45 |
+
n_positions (`int`, *optional*, defaults to 1024):
|
| 46 |
+
The maximum sequence length that this model might ever be used with. Typically set this to something large
|
| 47 |
+
just in case (e.g., 512 or 1024 or 2048).
|
| 48 |
+
n_embd (`int`, *optional*, defaults to 768):
|
| 49 |
+
Dimensionality of the embeddings and hidden states.
|
| 50 |
+
n_layer (`int`, *optional*, defaults to 12):
|
| 51 |
+
Number of hidden layers in the Transformer encoder.
|
| 52 |
+
n_head (`int`, *optional*, defaults to 12):
|
| 53 |
+
Number of attention heads for each attention layer in the Transformer encoder.
|
| 54 |
+
n_inner (`int`, *optional*):
|
| 55 |
+
Dimensionality of the inner feed-forward layers. `None` will set it to 4 times n_embd
|
| 56 |
+
activation_function (`str`, *optional*, defaults to `"gelu_new"`):
|
| 57 |
+
Activation function, to be selected in the list `["relu", "silu", "gelu", "tanh", "gelu_new"]`.
|
| 58 |
+
resid_pdrop (`float`, *optional*, defaults to 0.1):
|
| 59 |
+
The dropout probability for all fully connected layers in the embeddings, encoder, and pooler.
|
| 60 |
+
embd_pdrop (`float`, *optional*, defaults to 0.1):
|
| 61 |
+
The dropout ratio for the embeddings.
|
| 62 |
+
attn_pdrop (`float`, *optional*, defaults to 0.1):
|
| 63 |
+
The dropout ratio for the attention.
|
| 64 |
+
layer_norm_epsilon (`float`, *optional*, defaults to 1e-05):
|
| 65 |
+
The epsilon to use in the layer normalization layers.
|
| 66 |
+
initializer_range (`float`, *optional*, defaults to 0.02):
|
| 67 |
+
The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
|
| 68 |
+
summary_type (`string`, *optional*, defaults to `"cls_index"`):
|
| 69 |
+
Argument used when doing sequence summary, used in the models [`GPT2DoubleHeadsModel`] and
|
| 70 |
+
[`TFGPT2DoubleHeadsModel`].
|
| 71 |
+
|
| 72 |
+
Has to be one of the following options:
|
| 73 |
+
|
| 74 |
+
- `"last"`: Take the last token hidden state (like XLNet).
|
| 75 |
+
- `"first"`: Take the first token hidden state (like BERT).
|
| 76 |
+
- `"mean"`: Take the mean of all tokens hidden states.
|
| 77 |
+
- `"cls_index"`: Supply a Tensor of classification token position (like GPT/GPT-2).
|
| 78 |
+
- `"attn"`: Not implemented now, use multi-head attention.
|
| 79 |
+
summary_use_proj (`bool`, *optional*, defaults to `True`):
|
| 80 |
+
Argument used when doing sequence summary, used in the models [`GPT2DoubleHeadsModel`] and
|
| 81 |
+
[`TFGPT2DoubleHeadsModel`].
|
| 82 |
+
|
| 83 |
+
Whether or not to add a projection after the vector extraction.
|
| 84 |
+
summary_activation (`str`, *optional*):
|
| 85 |
+
Argument used when doing sequence summary. Used in for the multiple choice head in
|
| 86 |
+
[`GPT2DoubleHeadsModel`].
|
| 87 |
+
|
| 88 |
+
Pass `"tanh"` for a tanh activation to the output, any other value will result in no activation.
|
| 89 |
+
summary_proj_to_labels (`bool`, *optional*, defaults to `True`):
|
| 90 |
+
Argument used when doing sequence summary, used in the models [`GPT2DoubleHeadsModel`] and
|
| 91 |
+
[`TFGPT2DoubleHeadsModel`].
|
| 92 |
+
|
| 93 |
+
Whether the projection outputs should have `config.num_labels` or `config.hidden_size` classes.
|
| 94 |
+
summary_first_dropout (`float`, *optional*, defaults to 0.1):
|
| 95 |
+
Argument used when doing sequence summary, used in the models [`GPT2DoubleHeadsModel`] and
|
| 96 |
+
[`TFGPT2DoubleHeadsModel`].
|
| 97 |
+
|
| 98 |
+
The dropout ratio to be used after the projection and activation.
|
| 99 |
+
scale_attn_weights (`bool`, *optional*, defaults to `True`):
|
| 100 |
+
Scale attention weights by dividing by sqrt(hidden_size)..
|
| 101 |
+
use_cache (`bool`, *optional*, defaults to `True`):
|
| 102 |
+
Whether or not the model should return the last key/values attentions (not used by all models).
|
| 103 |
+
bos_token_id (`int`, *optional*, defaults to 50256):
|
| 104 |
+
Id of the beginning of sentence token in the vocabulary.
|
| 105 |
+
eos_token_id (`int`, *optional*, defaults to 50256):
|
| 106 |
+
Id of the end of sentence token in the vocabulary.
|
| 107 |
+
scale_attn_by_inverse_layer_idx (`bool`, *optional*, defaults to `False`):
|
| 108 |
+
Whether to additionally scale attention weights by `1 / layer_idx + 1`.
|
| 109 |
+
reorder_and_upcast_attn (`bool`, *optional*, defaults to `False`):
|
| 110 |
+
Whether to scale keys (K) prior to computing attention (dot-product) and upcast attention
|
| 111 |
+
dot-product/softmax to float() when training with mixed precision.
|
| 112 |
+
|
| 113 |
+
Example:
|
| 114 |
+
|
| 115 |
+
```python
|
| 116 |
+
>>> from transformers import GPT2Config, GPT2Model
|
| 117 |
+
|
| 118 |
+
>>> # Initializing a GPT2 configuration
|
| 119 |
+
>>> configuration = GPT2Config()
|
| 120 |
+
|
| 121 |
+
>>> # Initializing a model (with random weights) from the configuration
|
| 122 |
+
>>> model = GPT2Model(configuration)
|
| 123 |
+
|
| 124 |
+
>>> # Accessing the model configuration
|
| 125 |
+
>>> configuration = model.config
|
| 126 |
+
```"""
|
| 127 |
+
|
| 128 |
+
model_type = "gpt2mimo"
|
| 129 |
+
keys_to_ignore_at_inference = ["past_key_values"]
|
| 130 |
+
attribute_map = {
|
| 131 |
+
"hidden_size": "n_embd",
|
| 132 |
+
"max_position_embeddings": "n_positions",
|
| 133 |
+
"num_attention_heads": "n_head",
|
| 134 |
+
"num_hidden_layers": "n_layer",
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
def __init__(
|
| 138 |
+
self,
|
| 139 |
+
vocab_size=50257,
|
| 140 |
+
n_positions=1024,
|
| 141 |
+
n_embd=768,
|
| 142 |
+
n_layer=12,
|
| 143 |
+
n_head=12,
|
| 144 |
+
n_inner=None,
|
| 145 |
+
activation_function="gelu_new",
|
| 146 |
+
resid_pdrop=0.1,
|
| 147 |
+
embd_pdrop=0.1,
|
| 148 |
+
attn_pdrop=0.1,
|
| 149 |
+
layer_norm_epsilon=1e-5,
|
| 150 |
+
initializer_range=0.02,
|
| 151 |
+
summary_type="cls_index",
|
| 152 |
+
summary_use_proj=True,
|
| 153 |
+
summary_activation=None,
|
| 154 |
+
summary_proj_to_labels=True,
|
| 155 |
+
summary_first_dropout=0.1,
|
| 156 |
+
scale_attn_weights=True,
|
| 157 |
+
use_cache=True,
|
| 158 |
+
bos_token_id=50256,
|
| 159 |
+
eos_token_id=50256,
|
| 160 |
+
scale_attn_by_inverse_layer_idx=False,
|
| 161 |
+
reorder_and_upcast_attn=False,
|
| 162 |
+
**kwargs,
|
| 163 |
+
):
|
| 164 |
+
self.vocab_size = vocab_size
|
| 165 |
+
self.n_positions = n_positions
|
| 166 |
+
self.n_embd = n_embd
|
| 167 |
+
self.n_layer = n_layer
|
| 168 |
+
self.n_head = n_head
|
| 169 |
+
self.n_inner = n_inner
|
| 170 |
+
self.activation_function = activation_function
|
| 171 |
+
self.resid_pdrop = resid_pdrop
|
| 172 |
+
self.embd_pdrop = embd_pdrop
|
| 173 |
+
self.attn_pdrop = attn_pdrop
|
| 174 |
+
self.layer_norm_epsilon = layer_norm_epsilon
|
| 175 |
+
self.initializer_range = initializer_range
|
| 176 |
+
self.summary_type = summary_type
|
| 177 |
+
self.summary_use_proj = summary_use_proj
|
| 178 |
+
self.summary_activation = summary_activation
|
| 179 |
+
self.summary_first_dropout = summary_first_dropout
|
| 180 |
+
self.summary_proj_to_labels = summary_proj_to_labels
|
| 181 |
+
self.scale_attn_weights = scale_attn_weights
|
| 182 |
+
self.use_cache = use_cache
|
| 183 |
+
self.scale_attn_by_inverse_layer_idx = scale_attn_by_inverse_layer_idx
|
| 184 |
+
self.reorder_and_upcast_attn = reorder_and_upcast_attn
|
| 185 |
+
|
| 186 |
+
self.bos_token_id = bos_token_id
|
| 187 |
+
self.eos_token_id = eos_token_id
|
| 188 |
+
|
| 189 |
+
super().__init__(bos_token_id=bos_token_id, eos_token_id=eos_token_id, **kwargs)
|