Skip to content

Steps — Train

Train step: computes directions from recorded activations.

Output of SteeringVector step.

Attributes:

  • direction_per_layer: {Node: tensor [d_model]} normalized direction,
  • keyed by component address.
  • separation_scores: {Node: float} how well the direction separates
  • classes.
  • best_layer: :class:Node with the highest separation score.
def __init__(self, direction_per_layer: dict[Node, Tensor], separation_scores: dict[Node, float], best_layer: Node) -> None:

Find a steering direction via contrastive mean difference.

Reads from results:

  • results['record']: ActivationStore (must have .positive and .negative)

Writes to results:

  • results['steering']: SteeringResult

Args:

  • method: Estimation method. Currently only "contrastive_mean_diff"
  • is supported.
  • normalize: If True, normalize each per-layer direction to unit norm.

Raises:

  • ValueError: If method is not a supported value.
def __init__(self, method: str = 'contrastive_mean_diff', normalize: bool = True):