Skip to content

Steps — Probe

Probe step: trains linear classifiers on recorded activations.

Output of the Probe step.

Attributes:

  • accuracy_per_layer: {Node: float} mean CV accuracy.
  • cv_scores: {Node: ndarray} per-fold accuracy scores.
  • best_layer: :class:Node with highest mean accuracy.
  • classifiers: {Node: fitted sklearn classifier} (only if refit=True).
  • label_names: Human-readable label names (passed through from dataset).
def __init__(self, accuracy_per_layer: dict[Node, float], cv_scores: dict[Node, ndarray], best_layer: Node, classifiers: dict[Node, Any] = dict(), label_names: list[str] | None = None) -> None:

Train a linear probe per layer via cross-validation.

Reads from results:

  • results['record']: LabeledActivationStore
  • results['dataset']: LabeledDataset (optional, for label_names)

Writes to results:

  • results['probe']: ProbeResult

Args:

  • classifier: sklearn classifier instance (default: LogisticRegression).
  • Will be cloned per layer.
  • cv: Number of cross-validation folds.
  • refit: If True, fit a final classifier on all data per layer and store
  • in ProbeResult.classifiers.
def __init__(self, classifier: Any | None = None, cv: int = 5, refit: bool = False):