rhscope.metadata

Metadata model for probe artifacts.

A probe is always stored as two files:

<stem>.safetensors - the learned parameters <stem>.json - a serialized ProbeMetadata

This module defines the metadata schema. It is intentionally strict: schema drift between versions is caught at load time rather than at scoring time.

rhscope.metadata.CANONICAL_CATEGORIES: tuple[str, ...] = ('general', 'code_shortcut', 'format_gaming', 'verbosity', 'sycophancy', 'hallucinated_justification', 'benchmark_overfitting')

Canonical category names aligned with RH-Detect.

The category field accepts any string for extensibility, but shipping probes should prefer one of these names so benchmark results are directly comparable.

class rhscope.metadata.ProbeMetadata(*, base_model, layer, pooling='last_token', probe_type, category, hidden_dim, val_auroc=None, train_examples=None, training_data_hash=None, rhscope_version='unknown', created_at=<factory>, notes='', extra=<factory>)[source]

Bases: BaseModel

Metadata describing a single probe artifact.

Variables:
  • base_model (str) – Hugging Face model ID the probe was trained against (e.g. "Qwen/Qwen3-1.5B"). Required at score time; a probe trained on model A will not score model B correctly.

  • layer (int) – Zero-indexed transformer layer whose residual-stream (or equivalent hidden-state) activations the probe consumes.

  • pooling (Literal['last_token', 'mean', 'max']) – How activations are pooled across the response tokens before scoring.

  • probe_type (str) – Discriminator used by the probe registry to dispatch deserialization ("dom", "logistic", …).

  • category (str) – Hacking behavior the probe targets. Prefer values from CANONICAL_CATEGORIES for cross-probe comparisons.

  • hidden_dim (int) – Size of the activation vector the probe operates on.

  • val_auroc (float | None) – Validation AUROC at training time, if known.

  • train_examples (int | None) – Number of training examples used (hack + clean combined).

  • training_data_hash (str | None) – SHA-256 of the training JSONL for reproducibility.

  • rhscope_version (str) – Version of this library that produced the artifact.

  • created_at (datetime.datetime) – UTC timestamp of training.

  • notes (str) – Free-form human-readable notes. Not used for dispatch.

  • extra (dict[str, Any]) – Arbitrary extra fields. Preserved across save/load round-trips.

Parameters:
  • base_model (str)

  • layer (int)

  • pooling (Literal['last_token', 'mean', 'max'])

  • probe_type (str)

  • category (str)

  • hidden_dim (int)

  • val_auroc (float | None)

  • train_examples (int | None)

  • training_data_hash (str | None)

  • rhscope_version (str)

  • created_at (datetime)

  • notes (str)

  • extra (dict[str, Any])

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

model_config = {'extra': 'forbid', 'frozen': False, 'validate_assignment': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

base_model: str
layer: int
pooling: PoolingStrategy
probe_type: str
category: str
hidden_dim: int
val_auroc: float | None
train_examples: int | None
training_data_hash: str | None
rhscope_version: str
created_at: datetime
notes: str
extra: dict[str, Any]
is_canonical_category()[source]

Return True iff category is one of CANONICAL_CATEGORIES.

Return type:

bool