r/MachineLearning • u/Jumbledsaturn52 • Oct 23 '26
Project I made Transformer Architecture from scratch [P]
https://github.com/Rishikesh-2006/NNs/blob/main/Pytorch%2FTransformer.ipynbI 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 sentences to train it , due to the fact that it takes a lot of time to train my implementation. Looking at the code 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 for suggestions for making it better
Here is the code- https://github.com/Rishikesh-2006/NNs/tree/main/transformer
2
u/[deleted] Oct 24 '26
You might find interesting implementation details here:
https://github.com/joeynmt/joeynmt
0
u/AutoModerator Oct 23 '26
Your post was automatically removed for being a link post on the weekday, please read rule 5. The moderators will not respond to questions regarding this removal unless you suggest which rule you most likely broke. If you have a beginner related question, visit /r/MLQuestions or /r/LearnMachineLearning.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
2
u/[deleted] Oct 25 '26
[removed] — view removed comment