A straightforward method for training your LLM, from downloading data to generating text.
fix: broken computational graph
Tianyi (Alex) Qiu77cc348ce233
diff --git a/PITFALLS.md b/PITFALLS.mdindex efe394f..37d8362 100644--- a/PITFALLS.md+++ b/PITFALLS.md@@ -1,6 +1,7 @@- No bias in Q/K/V- `attn = torch.tril(attn, diagonal=0) + torch.triu(torch.ones_like(attn) * (-torch.inf), diagonal=1)`- `k = torch.transpose(k, -1, -2)`-- `x += self.attn(self.ln_attn(x)); x += self.mlp(self.ln_mlp(x))`+- `x = x + self.attn(self.ln_attn(x)); x = x + self.mlp(self.ln_mlp(x))`- `x = self.lm_head(self.ln_lmhead(x))`-- Send model & all tensors to device\ No newline at end of file+- Send model & all tensors to device+- Use `x = x + ...` not `x += ...` !\ No newline at end of filediff --git a/src/models/transformer_block.py b/src/models/transformer_block.pyindex dfc345f..4cb76ed 100644--- a/src/models/transformer_block.py+++ b/src/models/transformer_block.py@@ -18,6 +18,6 @@ class TransformerBlock(nn.Module):self.ln_mlp = nn.LayerNorm(emb_dim)def forward(self, x: torch.Tensor):- x += self.attn(self.ln_attn(x))- x += self.mlp(self.ln_mlp(x))+ x = x + self.attn(self.ln_attn(x))+ x = x + self.mlp(self.ln_mlp(x))return x\ No newline at end of file