tdhook.latent.activation_patching#
Classes#
Module Contents#
- class tdhook.latent.activation_patching.ActivationPatching(modules_to_patch, patch_key='patched', clean_intermediate_keys=True, patch_fn=None, cache_callback=None)[source]#
Bases:
tdhook.contexts.HookingContextFactoryCausal mediation analysis [17] and latent editing [18, 19].
- Parameters:
modules_to_patch (List[str])
patch_key (tdhook._types.UnraveledKey)
clean_intermediate_keys (bool)
patch_fn (Optional[Callable])
cache_callback (Optional[Callable])
- _prepare_module(module, in_keys, out_keys, extra_relative_path)[source]#
- Parameters:
module (tensordict.nn.TensorDictModuleBase)
in_keys (List[tdhook._types.UnraveledKey])
out_keys (List[tdhook._types.UnraveledKey])
extra_relative_path (str)
- Return type:
tensordict.nn.TensorDictModuleBase
- _hook_module(module)[source]#
- Parameters:
module (tdhook.modules.HookedModule)
- Return type: