rhscope.probes.base¶
Abstract base class for reward-hacking probes.
All concrete probes (DoMProbe, LogisticProbe, …) subclass Probe and
set a class-level probe_type discriminator. Subclasses implement five
.. method:: fit(hack_activations, clean_activations) -> None
- rhscope.probes.base.score(activations) torch.Tensor¶
- rhscope.probes.base.state_dict() dict[str, torch.Tensor]¶
- rhscope.probes.base._construct(metadata) 'Probe'¶
With those in place, save and load are handled by this base class via
the SafeTensors + JSON format from rhscope.io.
- class rhscope.probes.base.Probe(metadata)[source]¶
Bases:
ABCAbstract base class for reward-hacking probes.
Subclasses must set
probe_typeat the class level and implement the five abstract methods. Serialization is provided by this base.Example subclass skeleton:
class MyProbe(Probe): probe_type = "my_probe" def fit(self, hack, clean): ... def score(self, x): ... def state_dict(self): ... def _load_state_dict(self, state): ... @classmethod def _construct(cls, metadata): return cls(metadata=metadata)
- Parameters:
metadata (ProbeMetadata)
- property metadata: ProbeMetadata¶
Read-only reference to the probe’s metadata.
- abstractmethod fit(hack_activations, clean_activations)[source]¶
Fit the probe on hack-labeled and clean-labeled activations.
- classmethod load(stem)[source]¶
Load a probe artifact from a local stem, dispatching to the correct subclass.
- Parameters:
- Returns:
A fully populated probe instance of the class registered against
metadata.probe_type.- Raises:
KeyError – If the saved
probe_typeis not registered. This usually means the relevant concrete probe module was not imported before theloadcall.- Return type:
- classmethod from_pretrained(path_or_hub_id, *, revision=None, cache_dir=None)[source]¶
Load a probe from a local stem or a Hugging Face Hub repo.
Equivalent to
load()whenpath_or_hub_idrefers to a local stem, and to a Hub download followed byload()otherwise. Pair withHackMonitorfor the full monitoring surface (threshold, base-model safety checks).- Parameters:
- Returns:
A fully populated probe instance.
- Return type: