tdhook.latent.activation_caching#

Classes#

ActivationCaching

Maximally activating samples [15] and attention visualisation [16].

Module Contents#

class tdhook.latent.activation_caching.ActivationCaching(key_pattern, relative=True, cache=None, callback=None, directions=None, use_nested_keys=False, clear_cache=True)[source]#

Bases: tdhook.contexts.HookingContextFactory

Maximally activating samples [15] and attention visualisation [16].

Parameters:
  • key_pattern (str)

  • relative (bool)

  • cache (Optional[tensordict.TensorDict])

  • callback (Optional[Callable])

  • directions (Optional[List[tdhook.hooks.HookDirection]])

  • use_nested_keys (bool)

  • clear_cache (bool)

_hooking_context_class[source]#
_key_pattern[source]#
_relative = True[source]#
_hook_manager[source]#
_callback = None[source]#
_directions = ['fwd'][source]#
_use_nested_keys[source]#
property key_pattern: str[source]#
Return type:

str

_hook_module(module)[source]#
Parameters:

module (tdhook.modules.HookedModule)

Return type:

tdhook.hooks.MultiHookHandle