jbloomAus / SAELens

Training Sparse Autoencoders on Language Models
https://jbloomaus.github.io/SAELens/
MIT License
193 stars 67 forks source link

Quality of Life Refactor of SAE Lens adding SAE Analysis with HookedSAETransformer and some other breaking changes. #162

Closed jbloomAus closed 1 month ago

jbloomAus commented 1 month ago

Description

In this PR, we support HookedSAETransformer (coming over from TransformerLens) and refactor a bunch of stuff internally. I'm sorry this PR is so large and for the number of breaking changes. I'm hoping that the future need for refactors is much smaller. We expect the changes to be fairly superficial / easy to adapt to except for those working on forks. Feel free to reach out for assistance / clarification if you are trying to update a fork. Finally, we think it's likely there are no major regressions or introduced bugs, but the test coverage now looks lower as we're showing over the entire repo and not just the training subpackage.

New Features:

Breaking changes:

Features we removed:

Renaming:

Notes:

Type of change

Please delete options that are not relevant.

Checklist:

You have tested formatting, typing and unit tests (acceptance tests not currently in use)

Performance Check.

If you have implemented a training change, please indicate precisely how performance changes with respect to the following metrics:

Please links to wandb dashboards with a control and test group.

codecov[bot] commented 1 month ago

Codecov Report

Attention: Patch coverage is 59.28500% with 410 lines in your changes are missing coverage. Please review.

Project coverage is 52.34%. Comparing base (eb9489a) to head (3faeae8).

Files Patch % Lines
sae_lens/training/sae.py 0.00% 172 Missing :warning:
sae_lens/sae_training_runner.py 30.76% 63 Missing :warning:
sae_lens/training/sae_trainer.py 68.13% 46 Missing and 12 partials :warning:
sae_lens/sae.py 86.74% 12 Missing and 12 partials :warning:
sae_lens/training/training_sae.py 88.05% 19 Missing :warning:
sae_lens/config.py 64.86% 13 Missing :warning:
sae_lens/analysis/hooked_sae_transformer.py 86.41% 6 Missing and 5 partials :warning:
sae_lens/analysis/neuronpedia_runner.py 0.00% 11 Missing :warning:
sae_lens/toolkit/pretrained_sae_loaders.py 57.69% 10 Missing and 1 partial :warning:
sae_lens/evals.py 66.66% 4 Missing and 3 partials :warning:
... and 6 more
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #162 +/- ## =========================================== - Coverage 67.13% 52.34% -14.80% =========================================== Files 19 26 +7 Lines 1710 2755 +1045 Branches 267 462 +195 =========================================== + Hits 1148 1442 +294 - Misses 504 1240 +736 - Partials 58 73 +15 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

jbloomAus commented 1 month ago

I'm leaving this here for a few hours while I dm some people for feedback. This will likely be merged shortly.