train slm: 17.78M params
Browse files1234# PunyPunkTiny transformer LM trained from scratch on a toy corpus in Colab.1234# SLM (small human model)Tiny transformer LM trained from scratch on a toy corpus in Colab.
21 unmodified lines2223242526272821 unmodified linesself.register_buffer("mask", torch.triu(torch.full((block_size, block_size), float("-inf")), diagonal=1))def forward(self, x):a, _ = self.attn(self.ln1(x), self.ln1(x), self.ln1(x), attn_mask=self.mask)x = x + ax = x + self.mlp(self.ln2(x))return x21 unmodified lines222324252627282921 unmodified linesself.register_buffer("mask", torch.triu(torch.full((block_size, block_size), float("-inf")), diagonal=1))def forward(self, x):t = x.shape[1]a, _ = self.attn(self.ln1(x), self.ln1(x), self.ln1(x), attn_mask=self.mask[:t, :t])x = x + ax = x + self.mlp(self.ln2(x))return x
README.md+1-1
model.py+2-1