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:
2026-10-16 16:51:25 +02:00
parent b627c34967
commit aecaac01eb
7 changed files with 102 additions and 40 deletions
+35 -5
View File
@@ -1,9 +1,10 @@
#!/usr/bin/env python3
"""Run the floop draft on a question.
.venv/bin/python run_app.py "Per què el cel és blau?" # log only
.venv/bin/python run_app.py --verbose "Per què el cel és blau?" # + thinking on screen
FLOOP_LM=ollama-cloud .venv/bin/python run_app.py "..."
uv run run_app.py "Per què el cel és blau?" # log only
uv run run_app.py --verbose "Per què el cel és blau?" # + thinking on screen
uv run run_app.py --baseline "Per què el cel és blau?" # raw LLM, one call (A/B comparison)
FLOOP_LM=ollama-cloud uv run run_app.py "..."
Always: runs/<ts>-<slug>/run.log written with flush -> `tail -f` it from another
terminal. With --verbose, the "thinking" stream (the future floop-as-LLM thinking
@@ -12,6 +13,7 @@ output — a subset of the log) also prints to the screen, flushed.
from __future__ import annotations
import sys
import time
from pathlib import Path
import yaml
@@ -24,10 +26,27 @@ from floop.state import Budget # noqa: E402
from floop.stream import RunStreams # noqa: E402
def run_baseline(question: str, streams: RunStreams) -> str:
"""The A/B control: the raw LM answers in ONE call — no decomposition, no
experts, no evidence. Same LM, same budget unit (1 call) as the loop's init."""
from floop.llm import active_lm
streams.call("BASELINE", f"single raw LM call: {question[:80]}",
think=f"raw LM: {question[:90]}")
t0 = time.time()
raw = active_lm()(messages=[{"role": "user", "content": question}])
first = raw[0] if isinstance(raw, list) else raw.outputs[0]
answer = first["text"] if isinstance(first, dict) and "text" in first else first.get("content") or str(first)
dt = round(time.time() - t0, 1)
streams.output("BASELINE", answer)
streams.log(f"baseline time={dt}s")
return answer
def main() -> None:
args = sys.argv[1:]
verbose = "--verbose" in args
args = [a for a in args if a != "--verbose"]
baseline = "--baseline" in args
args = [a for a in args if a not in ("--verbose", "--baseline")]
if not args:
print(__doc__)
sys.exit(1)
@@ -42,7 +61,18 @@ def main() -> None:
lm_info = configure_lm()
streams = RunStreams(question, verbose=verbose, runs_dir=code_dir / "runs")
streams.log(f"lm={lm_info['provider']}/{lm_info['model']} verbose={verbose}")
streams.log(f"lm={lm_info['provider']}/{lm_info['model']} verbose={verbose} baseline={baseline}")
if baseline:
answer = run_baseline(question, streams)
streams.close()
print(f"goal: {question}")
print(f"lm: {lm_info['provider']} / {lm_info['model']} | mode=baseline (raw LLM, 1 call)")
print("\nraw LM answer:")
print(answer)
print(f"\nrun log: {streams.run_dir / 'run.log'}")
return
try:
report: RunReport = FloopRun(question, budget, streams=streams).run()
finally: