rhscope.model_card¶
Hugging Face model-card rendering for probe artifacts.
A model card is a Markdown file with a YAML front-matter header. The Hub
renders it on the repo landing page and uses the structured fields (tags,
base_model, license) for search and filtering.
The card produced here is intentionally deterministic and template-free -
no Jinja dependency, no optional sections that silently drift between runs.
Every probe uploaded through push_probe_to_hub should be accompanied by
a card produced by render_model_card().
- class rhscope.model_card.ModelCardExtras(bench_result=None, per_category_benchmarks=<factory>, trials=<factory>, datasets=<factory>, license='apache-2.0', language='en', tags=<factory>, notes='')[source]¶
Bases:
objectOptional extra sections surfaced in a model card.
- Variables:
bench_result (rhscope.bench.result.BenchResult | None) – Benchmark result to render as a metrics table.
per_category_benchmarks (dict[str, rhscope.bench.result.BenchResult]) – Mapping category ->
BenchResultfor the auxiliary leaderboard table.trials (list[dict[str, Any]]) – Per-layer AUROCs from the probe-training sweep.
datasets (list[str]) – Hugging Face dataset IDs the probe was trained on; forwarded to the YAML
datasetsfield.license (str) – SPDX identifier for the model card. Defaults to
apache-2.0.language (str) –
languagefield in the front matter.tags (list[str]) – Extra tags to append to the default
rhscope/reward-hacking-detection/ category tags.notes (str) – Free-form markdown appended after the standard sections.
- Parameters:
- bench_result: BenchResult | None = None¶
- per_category_benchmarks: dict[str, BenchResult]¶
- rhscope.model_card.render_model_card(metadata, *, repo_id=None, extras=None)[source]¶
Return the Markdown body of a Hugging Face model card.
- Parameters:
metadata (ProbeMetadata) – The probe’s
ProbeMetadata.repo_id (str | None) – Target Hugging Face repo ID; rendered into the usage example. If omitted, the example uses a placeholder.
extras (ModelCardExtras | None) – Optional
ModelCardExtrascarrying evaluation results, training trials, additional tags, and free-form notes.
- Returns:
The full card content as a single string, including YAML front matter.
- Return type:
- rhscope.model_card.save_model_card(metadata, path, *, repo_id=None, extras=None)[source]¶
Render a model card and write it to
path.- Parameters:
metadata (ProbeMetadata) – Probe metadata.
path (Any) – Output path (str or Path). Parent directories are created if missing.
repo_id (str | None) – Forwarded to
render_model_card().extras (ModelCardExtras | None) – Forwarded to
render_model_card().
- Return type:
None