Easy-Transformer
Easy-Transformer copied to clipboard
Refactor components
Description
Everything that was previously in transformer_lens/components
has been refactored so that every class has a separate file. I also simplified and improved a couple things here and there in some of the classes. e.g. changed some of the setup in some of the init functions to use ternary statements instead of large if/else block & removing modification of global variables in the loop for the Attention component to instead have a local variable from a wrapper that manages the state of the variable.
There are a lot of various improvements that can be made here that would enable the creation of unit tests. I am refraining from doing too much of it at the moment, so that the changes can more easily be tracked individually from the base of these separate new files as opposed to making a bunch of changes at the same time as splitting up one giant file.
No changes are needed for this in other parts of the code base, so people should be able to continue using these components as is. The only thing that I changed as far as naming is the variable previously mentioned in the Attention component. However, I don't really think that it is ever referenced outside of the Attention component itself. If it does seem like it is going to be an issue, then I can change the name back to the original.
I do still have to go through the document headers and update the copy and pasting I did, but thought I would get this up for review.
Fixes # (issue)
Type of change
Please delete options that are not relevant.
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [x] This change requires a documentation update
Screenshots
Please attach before and after screenshots of the change if applicable.
Checklist:
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [x] New and existing unit tests pass locally with my changes
- [x] I have not rewritten tests relating to key interfaces which would affect backward compatibility
The file headings have all been updated now, and it should be ready to merge once the bug is fixed that is currently affecting the whole repo.
All set!
Note: Will return to after Mistral PR is merged