Datasets:
Download scripts/run_bench.py from iulio/plc-llm-bench: direct link, hf CLI and curl.
- Browser
- Download file 3.97 kB
-
https://huggingface.co/datasets/iulio/plc-llm-bench/resolve/main/scripts/run_bench.py
- Command line
-
hf download hf://datasets/iulio/plc-llm-bench/scripts/run_bench.py
-
curl -L -o run_bench.py https://huggingface.co/datasets/iulio/plc-llm-bench/resolve/main/scripts/run_bench.py
3.97 kB
| """CLI entrypoint for running the industrial PLC LLM benchmark or rescoring checkpoints.""" | |
| from __future__ import annotations | |
| import argparse | |
| import pathlib | |
| import sys | |
| _ROOT = pathlib.Path(__file__).resolve().parents[1] | |
| if str(_ROOT) not in sys.path: | |
| sys.path.insert(0, str(_ROOT)) | |
| from plc_bench.report import generate_reports | |
| from plc_bench.runner import rescore_checkpoint, run_benchmark, run_openai_endpoint | |
| def main() -> None: | |
| parser = argparse.ArgumentParser(description="Benchmark open-weight LLMs on Siemens SCL / IEC 61131-3 ST") | |
| parser.add_argument("--checkpoint", type=pathlib.Path, default=pathlib.Path("results/checkpoint.jsonl")) | |
| parser.add_argument("--out-dir", type=pathlib.Path, default=pathlib.Path("results")) | |
| parser.add_argument("--llama-server", default="llama-server") | |
| parser.add_argument("--cache-dir", type=pathlib.Path, default=pathlib.Path("gguf_cache")) | |
| parser.add_argument("--tier", type=int, choices=[1, 2], default=None) | |
| parser.add_argument("--models", nargs="*", default=None) | |
| parser.add_argument("--smoke", action="store_true", help="Run 3 custom SCL tasks only for quick smoke testing") | |
| parser.add_argument("--autoplc-dir", type=pathlib.Path, default=None) | |
| parser.add_argument("--agents4plc-dir", type=pathlib.Path, default=None) | |
| parser.add_argument("--port", type=int, default=8089) | |
| parser.add_argument("--keep-gguf", action="store_true") | |
| parser.add_argument("--api-url", default=None, help="OpenAI-compatible base URL (Ollama, vLLM, LM Studio)") | |
| parser.add_argument("--api-model", default=None, help="Model identifier expected by --api-url") | |
| parser.add_argument("--api-key", default="EMPTY", help="Optional Bearer API key for --api-url") | |
| parser.add_argument("--api-tier", type=int, choices=[1, 2], default=1, help="Tier tag when using --api-url") | |
| parser.add_argument("--api-reasoning", action="store_true", help="Add concise-reasoning hint for thinking models") | |
| parser.add_argument("--custom-only", action="store_true", help="Evaluate only the verified 30 custom SCL tasks") | |
| parser.add_argument("--rescore-only", action="store_true", help="Re-evaluate an existing checkpoint JSONL offline") | |
| parser.add_argument("--rescore-out", type=pathlib.Path, default=None, help="Optional output path for rescored JSONL") | |
| args = parser.parse_args() | |
| report_ckpt = args.checkpoint | |
| if args.rescore_only: | |
| rescored = rescore_checkpoint(args.checkpoint, out_path=args.rescore_out) | |
| report_ckpt = args.rescore_out or args.checkpoint | |
| print(f"Rescored {len(rescored)} checkpoint records -> {report_ckpt}") | |
| elif args.api_url: | |
| if not args.api_model: | |
| parser.error("--api-model is required when --api-url is specified.") | |
| run_openai_endpoint( | |
| checkpoint_path=args.checkpoint, | |
| api_url=args.api_url, | |
| model_name=args.api_model, | |
| api_key=args.api_key, | |
| tier=args.api_tier, | |
| custom_only=args.custom_only or not (args.autoplc_dir or args.agents4plc_dir), | |
| smoke=args.smoke, | |
| autoplc_dir=args.autoplc_dir, | |
| agents4plc_dir=args.agents4plc_dir, | |
| is_reasoning=args.api_reasoning, | |
| ) | |
| else: | |
| run_benchmark( | |
| checkpoint_path=args.checkpoint, | |
| llama_server_bin=args.llama_server, | |
| model_cache_dir=args.cache_dir, | |
| tier=args.tier, | |
| model_names=args.models, | |
| smoke=args.smoke, | |
| autoplc_dir=None if args.custom_only else args.autoplc_dir, | |
| agents4plc_dir=None if args.custom_only else args.agents4plc_dir, | |
| port=args.port, | |
| delete_gguf_after_model=not args.keep_gguf, | |
| ) | |
| md_path, json_path, png_path = generate_reports(report_ckpt, args.out_dir) | |
| print(f"\nReport generated:\n {md_path}\n {json_path}\n {png_path}") | |
| if __name__ == "__main__": | |
| main() | |