rhscope.probes.mlp¶
Shallow MLP probe for cases where the hacking concept is not linearly separable.
Linear probes (DoMProbe and
LogisticProbe) are the right default
because they are cheap, easy to analyse, and work surprisingly well for
the kinds of concepts rhscope targets. But a small two-layer MLP is a
strictly stronger baseline worth having on hand - reviewers consistently
ask for it, and on some hacking patterns that depend on non-linear
feature combinations it outperforms the linear baselines by a meaningful
margin. When it does not beat the linear probe, that is itself a
useful observation.
The probe is a single hidden layer with tanh nonlinearity followed
by a linear head. Trained with Adam + early stopping on an internal
validation split carved from the fit input. Weight tensors are
persisted via state_dict() and round-trip through the same
SafeTensors loader as the linear probes.
- class rhscope.probes.mlp.MLPProbe(metadata, *, hidden_size=None, l2=None, lr=0.001, max_epochs=200, patience=15)[source]¶
Bases:
ProbeBinary classifier with one hidden
tanhlayer.- Variables:
probe_type (ClassVar[str]) – Discriminator used by the
Proberegistry.hidden_size – Width of the hidden layer. Recorded in
metadata.extrafor round-trip.l2 – L2 penalty applied to the weight matrices (not biases).
lr – Adam learning rate.
max_epochs – Hard cap on training epochs; early stopping usually stops sooner.
patience – Epochs to wait for validation AUROC improvement before stopping.
- Parameters:
Width of the hidden layer.
- fit(hack_activations, clean_activations)[source]¶
Fit the MLP probe with Adam and internal early stopping.
- Parameters:
- Raises:
ValueError – If inputs are empty or mis-shaped.
- Return type:
None