Test_AI_writing / devtools /bench_fast.py
unknown
Claude Opus 5.5
Fast engine: stronger first round, rounds 2+ judged in context, never builds on a worse round, stock AI phrases always rewritten
0cb108c
Raw History Blame Contribute Delete
1.75 kB
"""Fast engine on a small fixed document (default: 4 AI-written subject paragraphs, ~460 words), all rounds allowed,
scored by the live detector ensemble. For comparing engine settings; speed on CPU is not meaningful.
python devtools/bench_fast.py [--paras 4] [--tag name] (FAST_* variables apply as on the Space)
Writes devtools/logs/bench_fast_<tag>.docx and prints the score after each round."""
import argparse
import os
import shutil
import sys
import time
from pathlib import Path
ROOT = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(ROOT))
sys.path.insert(0, str(Path(__file__).resolve().parent))
import env # noqa: E402
env.load()
os.environ.setdefault("LT_MODE", "off")
os.environ.setdefault("SKIP_MODEL_LOAD", "1")
sys.stdout.reconfigure(encoding="utf-8")
from docx import Document # noqa: E402
PICK = ["civil engineering", "medicine", "management", "law", "computer science", "economics"]
def main():
ap = argparse.ArgumentParser()
ap.add_argument("--paras", type=int, default=4)
ap.add_argument("--tag", default="run")
a = ap.parse_args()
from samples_domains import DOMAINS
import fast as F
d = Document()
d.add_heading("Benchmark", 1)
for k in PICK[:a.paras]:
d.add_heading(k.title(), 2)
d.add_paragraph(DOMAINS[k])
src = ROOT / "devtools" / "logs" / "bench_fast_src.docx"
d.save(str(src))
t = time.time()
r = F.humanize_docx(str(src), budget=100000)
print(f"RESULT {a.tag}: {r['before']['pct']}% -> {r['after']['pct']}% | " + " | ".join(r["log"])
+ f" | {time.time() - t:.0f}s", flush=True)
shutil.copy(r["path"], ROOT / "devtools" / "logs" / f"bench_fast_{a.tag}.docx")
if __name__ == "__main__":
main()