train slm: 17.78M params
Browse files
README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
#
|
| 2 |
|
| 3 |
Tiny transformer LM trained from scratch on a toy corpus in Colab.
|
| 4 |
|
|
|
|
| 1 |
+
# SLM (small human model)
|
| 2 |
|
| 3 |
Tiny transformer LM trained from scratch on a toy corpus in Colab.
|
| 4 |
|
model.py
CHANGED
|
@@ -22,7 +22,8 @@ class DenseTransformerBlock(nn.Module):
|
|
| 22 |
self.register_buffer("mask", torch.triu(torch.full((block_size, block_size), float("-inf")), diagonal=1))
|
| 23 |
|
| 24 |
def forward(self, x):
|
| 25 |
-
|
|
|
|
| 26 |
x = x + a
|
| 27 |
x = x + self.mlp(self.ln2(x))
|
| 28 |
return x
|
|
|
|
| 22 |
self.register_buffer("mask", torch.triu(torch.full((block_size, block_size), float("-inf")), diagonal=1))
|
| 23 |
|
| 24 |
def forward(self, x):
|
| 25 |
+
t = x.shape[1]
|
| 26 |
+
a, _ = self.attn(self.ln1(x), self.ln1(x), self.ln1(x), attn_mask=self.mask[:t, :t])
|
| 27 |
x = x + a
|
| 28 |
x = x + self.mlp(self.ln2(x))
|
| 29 |
return x
|