peal.adaptors.projection_adaptor

Adaptor that repairs a classifier by projecting concept directions out of its head.

The ProjectionAdaptor is a training-free repair: it loads a trained predictor, takes the component directions of a sparse dictionary (SAE, MSAE, SVD, …) fitted on the penultimate features, and registers a forward pre-hook on the final nn.Linear layer that removes the subspace spanned by the selected components from its input. Accuracy and group statistics on the chosen data partition are printed before and after the projection so that the effect of removing a (spurious) concept can be read off directly.

Functions

projection_wrap_model

Modifies a torch.nn.Linear layer to project out specific components from the input before the standard forward pass.

Classes

ProjectionAdaptor

Training-free repair: project dictionary components out of the classifier head.

ProjectionAdaptorConfig

Config of ProjectionAdaptor.