drop dead LLM pass-2 interface, refresh stale docs, add public-release plan

estimate_physics was abstract on LLMProvider and implemented by every
provider, but pass 2 has been estimator-only for a while -- nothing called
it. Removed it along with PHYSICS_ESTIMATION_PROMPT, format_metrics_for_prompt
and parse_metric_json. STATUS.md and the original IMPLEMENTATION_PLAN.md
described a project that no longer exists; replaced with a phased plan for
making the repo and a hosted demo safe and presentable.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-09-25 15:20:56 -05:00
parent b2ccd94fd5
commit 2e38a6cf73
13 changed files with 98 additions and 899 deletions

View File

@@ -4,7 +4,7 @@ from __future__ import annotations
from abc import ABC, abstractmethod
from physcom.models.domain import Domain, MetricBound
from physcom.models.domain import Domain
class LLMRateLimitError(Exception):
@@ -20,19 +20,7 @@ class LLMRateLimitError(Exception):
class LLMProvider(ABC):
"""Abstract LLM interface for physics estimation and plausibility review."""
@abstractmethod
def estimate_physics(
self, combination_description: str, metrics: list[MetricBound]
) -> dict[str, float]:
"""Given a natural-language description of a combination,
estimate raw metric values. `metrics` carries each metric's unit and
expected norm_min/norm_max so the estimate lands in the right
magnitude — a bare metric name gives no hint that "cost_efficiency"
means dollars per meter in the 1e-5 range, not a 0-1 score.
Returns {metric_name: estimated_value}."""
...
"""Abstract LLM interface for plausibility review."""
@abstractmethod
def review_plausibility(

View File

@@ -2,11 +2,8 @@
from __future__ import annotations
import json
import re
from physcom.models.domain import MetricBound
def parse_verdict(text: str) -> bool:
"""Extract VERDICT: PLAUSIBLE/IMPLAUSIBLE from response; default to True."""
@@ -22,16 +19,3 @@ def parse_rating(text: str) -> str | None:
m = re.search(r"RATING:\s*(LOW|MEDIUM|HIGH)", text, re.IGNORECASE)
return m.group(1).upper() if m else None
def parse_metric_json(text: str, metrics: list[MetricBound]) -> dict[str, float]:
"""Strip markdown fences and parse JSON; fall back to each metric's own
norm_min/norm_max midpoint on error — a flat constant like 0.5 is
guaranteed wrong-magnitude for at least some metrics regardless of unit.
"""
names = {mb.metric_name for mb in metrics}
text = re.sub(r"```(?:json)?\s*", "", text).strip().rstrip("`").strip()
try:
data = json.loads(text)
return {k: float(v) for k, v in data.items() if k in names}
except (json.JSONDecodeError, ValueError, TypeError):
return {mb.metric_name: (mb.norm_min + mb.norm_max) / 2 for mb in metrics}

View File

@@ -8,18 +8,6 @@ if TYPE_CHECKING:
from physcom.models.domain import MetricBound
def format_metrics_for_prompt(metrics: list["MetricBound"]) -> str:
"""Render each metric with its unit and expected range, so the model
anchors on the right order of magnitude instead of a generic decimal."""
lines = []
for mb in metrics:
unit = mb.unit or "dimensionless"
lines.append(
f"- {mb.metric_name} ({unit}): typical range {mb.norm_min:g} to {mb.norm_max:g}"
)
return "\n".join(lines)
def format_scores_for_prompt(
raw_metrics: dict[str, float],
normalized_scores: dict[str, float],
@@ -73,24 +61,14 @@ match that magnitude, don't guess a generically "reasonable-looking" decimal.
{{"some_metric": <number>, "another_metric": <number>}} — no explanatory text.
"""
# ponytail: pass 4 used to see only pass 2's normalized scores, not the raw
# physical numbers or any reasoning behind them. Fixed the raw-value half of
# that gap: format_scores_for_prompt() now shows both, since a correct raw
# estimate can look damning once log-normalized against a scale built for a
# different kind of vehicle (a cyclist's real ~5 W/kg reads as "0.159" next
# to a car's 2000 W/kg ceiling) -- gemma2:27b did exactly this on a real
# bicycle combo, citing "extremely low power density (0.159)" as grounds for
# IMPLAUSIBLE while never reasoning from the actual (correct) 5 W/kg. The
# reasoning-text half of the gap is still open: estimate_physics() doesn't
# return a per-metric rationale, so pass 4 still can't see WHY pass 2 landed
# on a number, only what the number is. Upgrade path if the raw value alone
# isn't enough in practice: have estimate_physics() also return a short
# per-metric reason, persist it alongside raw_value (new nullable column),
# and feed it into this prompt. Deferred because it needs a schema/interface
# change across LLMProvider + both providers + pipeline + scorer +
# repository, and more generated tokens per combo.
#
# If we plan to LLM-review every p2 pass then maybe p2 and p4 should be combined.
# ponytail: pass 4 sees raw values + normalized scores (format_scores_for_prompt),
# since a correct raw estimate can look damning once log-normalized against a
# scale built for a different kind of vehicle (a cyclist's real ~5 W/kg reads
# as "0.159" next to a car's 2000 W/kg ceiling) -- gemma2:27b did exactly this
# on a real bicycle combo, citing "extremely low power density (0.159)" as
# grounds for IMPLAUSIBLE. It still can't see WHY pass 2 landed on a number.
# Upgrade path if raw values aren't enough: show the deterministic
# estimator's chosen mass allocation / free-variable values in this prompt.
#
# Calibration history: the original wording asked the model to weigh "novelty"
# and "genuinely interesting innovation or nonsense" as part of the verdict,

View File

@@ -6,14 +6,12 @@ import re
import math
from physcom.llm.base import LLMProvider, LLMRateLimitError
from physcom.llm.parsing import parse_metric_json, parse_verdict
from physcom.llm.parsing import parse_verdict
from physcom.llm.prompts import (
PHYSICS_ESTIMATION_PROMPT,
PLAUSIBILITY_REVIEW_PROMPT,
format_metrics_for_prompt,
format_scores_for_prompt,
)
from physcom.models.domain import Domain, MetricBound
from physcom.models.domain import Domain
class GeminiLLMProvider(LLMProvider):
@@ -29,23 +27,6 @@ class GeminiLLMProvider(LLMProvider):
self._client = genai.Client(api_key=api_key)
self._model = model
def estimate_physics(
self, combination_description: str, metrics: list[MetricBound]
) -> dict[str, float]:
prompt = PHYSICS_ESTIMATION_PROMPT.format(
description=combination_description,
metrics=format_metrics_for_prompt(metrics),
)
try:
response = self._client.models.generate_content(
model=self._model, contents=prompt
)
except Exception as exc:
if "429" in str(exc) or "RESOURCE_EXHAUSTED" in str(exc):
raise LLMRateLimitError(str(exc), self._parse_retry_after(exc)) from exc
raise
return parse_metric_json(response.text, metrics)
def review_plausibility(
self,
combination_description: str,

View File

@@ -3,23 +3,12 @@
from __future__ import annotations
from physcom.llm.base import LLMProvider
from physcom.models.domain import Domain, MetricBound
from physcom.models.domain import Domain
class MockLLMProvider(LLMProvider):
"""Returns deterministic stub responses for testing."""
def __init__(self, default_estimates: dict[str, float] | None = None) -> None:
self._defaults = default_estimates or {}
def estimate_physics(
self, combination_description: str, metrics: list[MetricBound]
) -> dict[str, float]:
result = {}
for mb in metrics:
result[mb.metric_name] = self._defaults.get(mb.metric_name, 0.5)
return result
def review_plausibility(
self,
combination_description: str,

View File

@@ -7,14 +7,12 @@ import urllib.error
import urllib.request
from physcom.llm.base import LLMProvider
from physcom.llm.parsing import parse_metric_json, parse_verdict
from physcom.llm.parsing import parse_verdict
from physcom.llm.prompts import (
PHYSICS_ESTIMATION_PROMPT,
PLAUSIBILITY_REVIEW_PROMPT,
format_metrics_for_prompt,
format_scores_for_prompt,
)
from physcom.models.domain import Domain, MetricBound
from physcom.models.domain import Domain
class OllamaLLMProvider(LLMProvider):
@@ -24,16 +22,6 @@ class OllamaLLMProvider(LLMProvider):
self._model = model
self._host = host.rstrip("/")
def estimate_physics(
self, combination_description: str, metrics: list[MetricBound]
) -> dict[str, float]:
prompt = PHYSICS_ESTIMATION_PROMPT.format(
description=combination_description,
metrics=format_metrics_for_prompt(metrics),
)
text = self._generate(prompt, json_mode=True)
return parse_metric_json(text, metrics)
def review_plausibility(
self,
combination_description: str,
@@ -48,13 +36,11 @@ class OllamaLLMProvider(LLMProvider):
domain_name=domain.name,
domain_description=domain.description,
)
text = self._generate(prompt, json_mode=False).strip()
text = self._generate(prompt).strip()
return (text, parse_verdict(text))
def _generate(self, prompt: str, json_mode: bool) -> str:
def _generate(self, prompt: str) -> str:
payload = {"model": self._model, "prompt": prompt, "stream": False}
if json_mode:
payload["format"] = "json"
req = urllib.request.Request(
f"{self._host}/api/generate",
data=json.dumps(payload).encode("utf-8"),