Upload modeling_opt.py
Browse files- modeling_opt.py +6 -5
modeling_opt.py
CHANGED
|
@@ -167,8 +167,6 @@ class OPTAttention(nn.Module):
|
|
| 167 |
def __init__(
|
| 168 |
self,
|
| 169 |
config: OPTConfig,
|
| 170 |
-
embed_dim: int,
|
| 171 |
-
num_heads: int,
|
| 172 |
dropout: float = 0.0,
|
| 173 |
is_decoder: bool = False,
|
| 174 |
bias: bool = True,
|
|
@@ -188,10 +186,13 @@ class OPTAttention(nn.Module):
|
|
| 188 |
attn_softmax='vanilla',
|
| 189 |
):
|
| 190 |
super().__init__()
|
| 191 |
-
self.embed_dim =
|
| 192 |
-
self.num_heads =
|
| 193 |
-
self.dropout =
|
|
|
|
| 194 |
self.head_dim = embed_dim // num_heads
|
|
|
|
|
|
|
| 195 |
|
| 196 |
if (self.head_dim * num_heads) != self.embed_dim:
|
| 197 |
raise ValueError(
|
|
|
|
| 167 |
def __init__(
|
| 168 |
self,
|
| 169 |
config: OPTConfig,
|
|
|
|
|
|
|
| 170 |
dropout: float = 0.0,
|
| 171 |
is_decoder: bool = False,
|
| 172 |
bias: bool = True,
|
|
|
|
| 186 |
attn_softmax='vanilla',
|
| 187 |
):
|
| 188 |
super().__init__()
|
| 189 |
+
self.embed_dim = config.hidden_size
|
| 190 |
+
self.num_heads = config.num_attention_heads
|
| 191 |
+
self.dropout = config.attention_dropout
|
| 192 |
+
self.enable_bias = config.enable_bias
|
| 193 |
self.head_dim = embed_dim // num_heads
|
| 194 |
+
self.is_causal = True
|
| 195 |
+
|
| 196 |
|
| 197 |
if (self.head_dim * num_heads) != self.embed_dim:
|
| 198 |
raise ValueError(
|