Tutorials#
These notebooks are the maintained guides to TDHook. Start with one method or follow a complete workflow that combines methods with a model or domain.
Core interfaces#
Capture and intervene imperatively with an explicit managed lifecycle.
Compose methods and TensorDict operations through named inputs and outputs, and keep activation caches on caller-owned disk storage.
Advanced execution#
Preserve local shared artifacts and keep hook execution rank-local under DistributedDataParallel.
Learn the methods#
Attribute predictions to inputs with an accumulated gradient path.
Modify model behavior through intermediate activation directions.
Test which concepts are linearly available in learned representations.
Capture interactions between paired layer representations.
Estimate intrinsic dimension with TwoNN, local PCA, and related methods.
Compare learned representations with CKA and information imbalance.
Complete workflows#
Probe action representations in a TorchRL PPO agent.
Attribute chess value predictions with saliency methods.
Visualize concept attribution on natural images.
Estimate and plot dimensions for chess activations.
Reproduce published behavior and linear-probe results, then validate intervention parity.
Reproduce bounded Gemma-2-2B WeightLens candidates and CircuitLens contributors, then cluster circuit signatures.
Compare TDHook causal tracing and temporary rank-one edits with the official ROME implementation on a preregistered CounterFact slice.