feat: baseline experts + --baseline A/B mode (raw LLM)
Per Emili 2026-10-16: the draft experts are baseline experts - the LLM answers each subquestion directly from its own knowledge (no verification yet; engines replace the baseline path per expert later). ExpertSignature no longer forbids weights-based answers; source_quote now means verbatim from GIVEN evidence, empty when answering from weights. Evidence rows record source: model_weights | given_evidence. --baseline mode: the same LM answers the whole question in ONE raw call - the A/B control against the loop's many small directed calls. Also: pyproject fixed (name floop, hatchling backend, package floop/) - uv_build expected src/ layout; runner docs now uv-first; uv.lock regenerated.
This commit is contained in:
@@ -34,18 +34,18 @@ class RouteSignature(dspy.Signature):
|
||||
|
||||
|
||||
class ExpertSignature(dspy.Signature):
|
||||
"""You are an expert ATTENDANT whose draft answer is checked by a machine.
|
||||
You translate the question into a typed answer payload — you do not compute
|
||||
values and you never invent facts. Use the evidence you are given, plus
|
||||
facts literally stated in the parent question; if the answer is not
|
||||
derivable from them, say so."""
|
||||
"""You are an expert attendant answering a small, focused subquestion.
|
||||
Use the evidence rows when they answer it; otherwise answer from your own
|
||||
knowledge. This is a BASELINE draft: no engine verifies you yet, so state
|
||||
your honest confidence. Say UNKNOWN only if you genuinely do not know."""
|
||||
question: str = dspy.InputField()
|
||||
parent_question: str = dspy.InputField(
|
||||
desc="the original user question this subquestion serves; facts literally stated there are permitted sources")
|
||||
expert_kind: str = dspy.InputField(desc="knowledge logic analytic numeric")
|
||||
evidence: str = dspy.InputField(desc="evidence rows this question references")
|
||||
evidence: str = dspy.InputField(desc="evidence rows this question references; may be empty")
|
||||
value: str = dspy.OutputField(desc="the answer value in its declared type, or 'UNKNOWN'")
|
||||
source_quote: str = dspy.OutputField(desc="VERBATIM supporting text (from evidence or the parent question); empty if none")
|
||||
source_quote: str = dspy.OutputField(
|
||||
desc="VERBATIM text from the given evidence if the answer comes from it; EMPTY when answering from your own knowledge")
|
||||
confidence: str = dspy.OutputField(desc="high medium low")
|
||||
|
||||
|
||||
@@ -63,8 +63,9 @@ class MissingSignature(dspy.Signature):
|
||||
|
||||
class AnswerSignature(dspy.Signature):
|
||||
"""You are the ANSWER step of a reasoning machine. Write the final natural
|
||||
language answer to the goal using ONLY the evidence rows. Working only from
|
||||
those rows, cite them; every number or fact carries its row id."""
|
||||
language answer to the goal using ONLY the evidence rows, citing them; every
|
||||
number or fact carries its row id. State the answer plainly — the system
|
||||
marks verification status separately, do not hedge about it."""
|
||||
goal: str = dspy.InputField()
|
||||
evidence: str = dspy.InputField()
|
||||
unverified: str = dspy.InputField(desc="'true' if the prover could not verify derivability")
|
||||
|
||||
@@ -52,7 +52,9 @@ class LLMExpertEngine:
|
||||
payload: dict = {"value": draft["value"]}
|
||||
if draft["source_quote"]:
|
||||
payload["quote"] = draft["source_quote"]
|
||||
prov = {"expert": self.kind, "note": "draft v0.1 — no real engine, no check layer"}
|
||||
prov = {"expert": self.kind,
|
||||
"source": "model_weights" if not draft["source_quote"] else "given_evidence",
|
||||
"note": "baseline v0.1 — LLM answers directly; engines come later"}
|
||||
if parent_question:
|
||||
prov["parent_question"] = parent_question
|
||||
return EvidenceRow(
|
||||
|
||||
+13
-1
@@ -37,5 +37,17 @@ def configure_lm() -> dict:
|
||||
"api_key": os.environ.get(p.get("api_key_env", ""), "empty"),
|
||||
}
|
||||
lm = dspy.LM(**kwargs)
|
||||
global _ACTIVE
|
||||
_ACTIVE = lm
|
||||
dspy.configure(lm=lm)
|
||||
return {"provider": provider, "model": p["model"], "base_url": p["base_url"]}
|
||||
return {"provider": provider, "model": p["model"], "base_url": p["base_url"]}
|
||||
|
||||
|
||||
_ACTIVE: "dspy.LM | None" = None
|
||||
|
||||
|
||||
def active_lm() -> "dspy.LM":
|
||||
"""The configured dspy.LM, configuring it lazily if needed (baseline mode uses it raw)."""
|
||||
if _ACTIVE is None:
|
||||
configure_lm()
|
||||
return _ACTIVE
|
||||
Reference in New Issue
Block a user