mirror of
https://github.com/elder-plinius/OBLITERATUS.git
synced 2026-07-14 07:57:21 +02:00
04b8ec60cb
New core modules: - auto_obliterate.py: Automated multi-iteration obliteration pipeline - watchtower.py: HF Hub model discovery and tracking - ui_watchtower.py: Gradio tabs for Watchtower (ready for app.py wiring) - hard_negative.py: Residue mining from refusal audits - model_profile.py: Parameter profiling from safetensors/config - bestiary_sync.py: Sync models from PlinyOS BESTIARY registry - models_client.py: Lightweight HF model list client Framework enhancements: - abliterate.py: ASPA source-tethering, step gradient blending, hard-negative residue support - cli.py: self-improve command, model profiling, hard-negative flags - prompts.py: Expanded 842-prompt refusal eval corpus across 10 categories - __init__.py: New exports (Watchtower, AutoObliterator) Reference implementations (14 scripts): - ASPA sweep, gradient search, coherence eval, MMLU benchmarks - Pareto controller, refusal sniper, stock comparisons Documentation: - README: Research framing, responsible use section, comprehensive disclaimer - docs/beyond_sota_roadmap.md, docs/recursive_self_improvement.md Tests: 4 new test files (354 lines) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
85 lines
3.1 KiB
Python
85 lines
3.1 KiB
Python
"""
|
|
bestiary_sync.py — augment OBLITERATUS presets with fresh open-weight models
|
|
from the PlinyOS BESTIARY registry.
|
|
|
|
OBLITERATUS ships a curated `_PRESETS_LIST` with precise compute tiers + dtypes.
|
|
That list is authoritative but goes stale the moment a new open-weight model
|
|
drops. BESTIARY tracks releases across OpenRouter + HuggingFace; this adapter
|
|
pulls its open-weight channel and surfaces any model not already curated as an
|
|
auto-discovered preset (compute tier inferred from the param count in the id).
|
|
|
|
Non-destructive by design: curated presets always win on hf_id collision, and
|
|
if the catalog isn't reachable (BESTIARY not running / BESTIARY_CATALOG unset)
|
|
this returns [] so presets behave exactly as before.
|
|
|
|
Wiring: set BESTIARY_CATALOG to the served catalog url or a catalog.json path,
|
|
e.g. `export BESTIARY_CATALOG=http://127.0.0.1:8892/catalog.json`.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import re
|
|
|
|
# Param-count → compute tier, mirroring presets.py's tiers.
|
|
_PARAM_RE = re.compile(r"(\d+(?:\.\d+)?)\s*b\b", re.IGNORECASE)
|
|
|
|
|
|
def _infer_tier_params(hf_id: str, rec: dict) -> tuple[str, str]:
|
|
"""Best-effort (tier, params) from the model id, e.g. 'Qwen/Qwen3-32B' → (large, 32B).
|
|
MoE 'A<x>B' active-param hints are ignored in favor of total size."""
|
|
name = (hf_id or "") + " " + (rec.get("name") or "")
|
|
sizes = [float(x) for x in _PARAM_RE.findall(name)]
|
|
# Drop tiny active-param hints (e.g. A3B) by preferring the largest match.
|
|
b = max(sizes) if sizes else None
|
|
if b is None:
|
|
return "large", "unknown" # unknown size → assume heavy, don't auto-pick on weak HW
|
|
params = f"{b:g}B"
|
|
if b < 2:
|
|
return "tiny", params
|
|
if b < 8:
|
|
return "small", params
|
|
if b < 16:
|
|
return "medium", params
|
|
if b < 70:
|
|
return "large", params
|
|
return "frontier", params
|
|
|
|
|
|
_GATED_ORGS = {"meta-llama", "google", "mistralai"}
|
|
|
|
|
|
def extra_presets(ModelPreset, existing_hf_ids):
|
|
"""Return a list of ModelPreset objects for open-weight models in the BESTIARY
|
|
catalog that aren't already curated. Empty list on any failure (safe no-op)."""
|
|
try:
|
|
try:
|
|
from .models_client import models # vendored alongside this module
|
|
except ImportError:
|
|
from models_client import models # flat-layout fallback
|
|
catalog = models(open_weight=True)
|
|
except Exception:
|
|
return []
|
|
|
|
out = []
|
|
seen = set(existing_hf_ids)
|
|
for m in catalog:
|
|
hf = m.get("hf_id")
|
|
if not hf or hf in seen:
|
|
continue
|
|
seen.add(hf)
|
|
tier, params = _infer_tier_params(hf, m)
|
|
caps = ", ".join(m.get("capabilities", [])) or "open-weight"
|
|
rel = m.get("released") or "?"
|
|
org = hf.split("/")[0] if "/" in hf else ""
|
|
out.append(ModelPreset(
|
|
name=m.get("name") or hf.split("/")[-1],
|
|
hf_id=hf,
|
|
description=f"[BESTIARY · {rel}] {caps}.",
|
|
tier=tier,
|
|
params=params,
|
|
recommended_dtype="bfloat16",
|
|
recommended_quantization=("4bit" if tier in ("large", "frontier") else None),
|
|
gated=(org in _GATED_ORGS),
|
|
))
|
|
return out
|