Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:2akouwu Reverify model loop run

From Leeroopedia
Knowledge Sources
Domains Benchmarking, LLM_Agents
Last Updated 2026-10-24 12:00 GMT

Overview

Concrete tool for the closed-loop benchmark that runs the full propose-verify-revise loop with a real or mock model, measuring grounded rate, rounds to ground, and hallucinations caught, provided by the Reverify library.

Description

The run function in model_loop.py runs the ReconstructionAgent on real binaries with either a real LLM (via openai_proposer, requires OPENAI_API_KEY) or the offline demo_proposer (--mock). It measures per-binary: grounded, rounds_used, information, round1 refuted/claims, and aggregate claims/verified/refuted/trivial/echoed/known. Totals: grounded_rate, mean_rounds, round1_hallucination_rate, restatements_rejected.

Usage

Use this function when you need to:

  • Benchmark the full closed loop with a real model.
  • Measure how many rounds it takes to reach grounding.
  • Track hallucinations caught (round1 refutations) and restatements rejected.
  • Run the model-in-loop benchmark in CI or offline (--mock).

Code Reference

Source Location

  • Repository: Reverify
  • File: benchmarks/model_loop.py
  • Lines: run at L46-109; main at L139-166; markdown at L112-136

Signature

def run(
    dirs: List[str],
    per_dir: int = 5,
    rounds: int = 3,
    mock: bool = False,
    model: Optional[str] = None,
) -> Dict[str, Any]:
    """Run the closed loop on real binaries; return result dict."""

def main(argv: List[str]) -> int:
    """CLI entry: run benchmark, print/markdown/json."""

Import

from benchmarks.model_loop import run

I/O Contract

Inputs

Name Type Required Description
dirs List[str] No Corpus directories
per_dir int No Files per dir (default 5)
rounds int No Max rounds (default 3)
mock bool No Use offline demo_proposer (default False)
model str No Model name (default from OPENAI_MODEL env)

Outputs

Name Type Description
return Dict Per-binary rows (file, sha256, format, arch, grounded, rounds, information, round1_refuted/claims, aggregate), totals (grounded_rate, mean_rounds, round1_hallucination_rate, restatements_rejected)

Usage Examples

CLI Usage

# Offline mock (no API key needed)
python benchmarks/model_loop.py --mock --markdown

# With a real model
OPENAI_API_KEY=sk-... python benchmarks/model_loop.py --model gpt-4o --rounds 4 --json results.json

Related Pages

Implements Principle

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment