Spaces:
Running
Running
unknown
Claude Opus 5.5
Smart Humanize faster: setting groups of a pass rewritten at once (GPU), rescue rewrites requested at the start of each call, vocabulary step alongside Parrot; job time in the log
82a89bf Download devtools/bench_smart.py from Rasheed/Test_AI_writing: direct link, hf CLI and curl.
- Browser
- Download file 2.02 kB
-
https://huggingface.co/spaces/Rasheed/Test_AI_writing/resolve/main/devtools/bench_smart.py
- Command line
-
hf download hf://spaces/Rasheed/Test_AI_writing/devtools/bench_smart.py
-
curl -L -o bench_smart.py https://huggingface.co/spaces/Rasheed/Test_AI_writing/resolve/main/devtools/bench_smart.py
2.02 kB
| """Smart engine on a small fixed document (two AI-written paragraphs) with the app's default settings: | |
| time per job and the AI score before -> after. For comparing engine settings (SMART_*, HUM_* variables apply as on | |
| the Space); absolute times on a CPU-only PC are much longer than on the GPU, the comparison is what counts. | |
| python devtools/bench_smart.py [--passes 4] [--tag name]""" | |
| import argparse | |
| import os | |
| import sys | |
| import tempfile | |
| 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 | |
| def main(): | |
| ap = argparse.ArgumentParser() | |
| ap.add_argument("--passes", type=int, default=4) | |
| ap.add_argument("--tag", default="run") | |
| a = ap.parse_args() | |
| import groqai as G | |
| import smart as S | |
| d = Document() | |
| d.add_heading("Results", level=1) | |
| from samples_domains import DOMAINS # plain AI-written prose: little that must stay fixed | |
| for k in ("management", "economics"): | |
| d.add_paragraph(DOMAINS[k]) | |
| path = Path(tempfile.mkdtemp()) / f"bench_smart_{a.tag}.docx" | |
| d.save(path) | |
| class Rep: | |
| frac, desc = 0.0, "" | |
| def __call__(self, frac, desc=""): | |
| self.frac, self.desc = frac, desc | |
| S._score_doc(Document(str(path))) # load the detector before the clock starts | |
| t0 = time.time() | |
| res = S.smart_docx(str(path), 0, a.passes, 0.9, "Fast (recommended)", 0.80, 0.50, Rep()) | |
| took = time.time() - t0 | |
| acct = G.ACCT.get() | |
| print(f"[bench_smart] {a.tag}: {took:.0f}s | AI {res['before']['pct']}% -> {res['after']['pct']}% | " | |
| f"Groq ${G.spent(acct) if acct else 0:.4f}") | |
| for line in res["log"]: | |
| print(" ", line) | |
| if __name__ == "__main__": | |
| main() | |