Proposal
I propose to do a simple refractoring of the class HookedTransformer to support type hints for the model attribute in the ActivationCache class.
Motivation
I am frastrated by the lack of type hinting for self.model in the ActivationCache class. I think the current state is that we want to avoid circular imports, but I think we can do better.
Pitch
Create a class, say HookedTransformerMixin, that holds all methods without accessing to the definition of ActivationCache. Currently only the function run_with_cache access the ActivationCache class.
In transformer_lens/ActivationCache.py, we could import HookedTransformerMixin to provide type hint. In transformer_lens/HookedTransformer.py, HookedTransformer could inherit HookedTransformerMixin and import from ActivationCache.
Checklist
Proposal
I propose to do a simple refractoring of the class
HookedTransformerto support type hints for themodelattribute in theActivationCacheclass.Motivation
I am frastrated by the lack of type hinting for
self.modelin theActivationCacheclass. I think the current state is that we want to avoid circular imports, but I think we can do better.Pitch
Create a class, say
HookedTransformerMixin, that holds all methods without accessing to the definition ofActivationCache. Currently only the functionrun_with_cacheaccess theActivationCacheclass.In
transformer_lens/ActivationCache.py, we could importHookedTransformerMixinto provide type hint. Intransformer_lens/HookedTransformer.py,HookedTransformercould inheritHookedTransformerMixinand import fromActivationCache.Checklist