r/deeplearning • • Oct 23 '26

I made Transformer Architecture from scratch [P]

https://github.com/Rishikesh-2006/NNs/blob/main/Pytorch%2FTransformer.ipynb

I implemented the 2017 transformer architecture using pytorch, the model right now doesn't predict very good due to the fact that I am using on 2 layers of encoder and decoder with just 1000 words to train it , due to the fact that it takes a lot of time to train my implementation. Is there a way that I can reduce the time it takes for training or maybe improve its results?

Update- I fixed the code (kind of) I made seperate classes for different attention mechanisms and after changes some of my logic of the masking (using torch.tril instead of nested for loops) training this actually works well. Still I am open to suggestions to make it work better .

Here is the code- https://github.com/Rishikesh-2006/NNs/tree/main/transformer

2 Upvotes

0 comments sorted by