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#

Interactive Hook Sessions

Capture and intervene imperatively with an explicit managed lifecycle.

Interactive Hook Sessions (Offline)
Declared Workflows

Compose methods and TensorDict operations through named inputs and outputs, and keep activation caches on caller-owned disk storage.

Declared Workflows (Offline)

Advanced execution#

Process Handoff and DDP

Preserve local shared artifacts and keep hook execution rank-local under DistributedDataParallel.

Process Handoff and DistributedDataParallel (Offline)

Learn the methods#

Integrated Gradients

Attribute predictions to inputs with an accumulated gradient path.

Integrated Gradients
Steering Vectors

Modify model behavior through intermediate activation directions.

Steering Vectors
Linear Probing

Test which concepts are linearly available in learned representations.

Linear Probing
Bilinear Probing

Capture interactions between paired layer representations.

Bilinear Probing
Dimension Estimation

Estimate intrinsic dimension with TwoNN, local PCA, and related methods.

Dimension Estimation
Representation Similarity

Compare learned representations with CKA and information imbalance.

Representation Similarity

Complete workflows#

TorchRL PPO Action Probing

Probe action representations in a TorchRL PPO agent.

TorchRL PPO Action Probing
Chess Value Saliency

Attribute chess value predictions with saliency methods.

Chess Value Saliency
Concept Attribution

Visualize concept attribution on natural images.

Concept Attribution (LRP + RelMax)
Chess Dimension Estimation

Estimate and plot dimensions for chess activations.

Chess Dimension Estimation
Othello Research Reproduction

Reproduce published behavior and linear-probe results, then validate intervention parity.

Othello-GPT: Probing and Activation Intervention
Circuit Insights: WeightLens and CircuitLens

Reproduce bounded Gemma-2-2B WeightLens candidates and CircuitLens contributors, then cluster circuit signatures.

Circuit Insights: WeightLens and CircuitLens
ROME Causal Tracing and Editing

Compare TDHook causal tracing and temporary rank-one edits with the official ROME implementation on a preregistered CounterFact slice.

ROME: Causal Tracing and Rank-One Editing