### Installation: uv sync and .env setup Source: https://github.com/benchcad/benchcad-main/blob/main/README.md Sets up the Python 3.11 environment with uv and copies the .env.example file to .env for LLM API keys. The benchmark data is public; only API keys are needed. ```bash uv sync ``` ```bash cp .env.example .env # then paste OPENAI / ANTHROPIC / GEMINI / XAI / OPENROUTER keys ``` -------------------------------- ### YAML config example Source: https://github.com/benchcad/benchcad-main/blob/main/CodeEdit/README.md Shows the structure of a YAML config file with data_dir, out_dir, models, and modes fields. Paths are relative to CodeEdit/. ```yaml data_dir: test_data out_dir: results_test models: [gpt-4o, claude-opus-4-7, ...] modes: [instruction] ``` -------------------------------- ### Quick start: run BenchCAD benchmark Source: https://github.com/benchcad/benchcad-main/blob/main/README.md Runs the benchmark with various options. The first command is a quick smoke test (5 records per task). The second runs the full benchmark. The third runs one task with a reproducible random sample. The fourth runs several models with composite scoring for Vision2Code. ```bash uv run python benchcad.py --model gpt-4o ``` ```bash uv run python benchcad.py --task all --num all --model gpt-4o ``` ```bash uv run python benchcad.py --task vision2code --num 100 --model claude-opus-4-7 --seed 42 ``` ```bash uv run python benchcad.py --num all --model gpt-4o gemini-3-pro-preview --score composite ``` -------------------------------- ### Run benchcad-qa evaluation with uv Source: https://github.com/benchcad/benchcad-main/blob/main/environments/benchcad-qa/README.md Command to run the benchcad-qa environment with 20 examples. Use `-n` to specify the number of questions; omit for the full set. ```bash uv run vf-eval benchcad-qa -n 20 ``` -------------------------------- ### Create venv and install environment Source: https://github.com/benchcad/benchcad-main/blob/main/environments/benchcad-vision2code/README.md Creates a Python 3.12 virtual environment and installs the benchcad-vision2code environment. Requires Python 3.11 or 3.12 because the CAD stack is pinned to numpy 1.26.4, which has no 3.13 wheel. ```bash uv venv --python 3.12 && source .venv/bin/activate prime env install benchcad/benchcad-vision2code ``` -------------------------------- ### Set up development environment with uv sync and .env Source: https://github.com/benchcad/benchcad-main/blob/main/CONTRIBUTING.md Initializes the Python 3.11 environment and copies the .env.example file to .env. LLM API keys are required in .env; benchmark data is public and does not need keys. ```bash uv sync # Python 3.11 cp .env.example .env # LLM API keys only — benchmark data is public ``` -------------------------------- ### Quick eval and load environment Source: https://github.com/benchcad/benchcad-main/blob/main/environments/benchcad-vision2code/README.md Shows how to run a quick evaluation on a few parts using vf-eval, and how to load the environment in code with verifiers. The load_environment function accepts num_examples to cap the number of parts. ```bash # install + quick eval on a few parts uv run vf-eval benchcad-vision2code -n 5 ``` ```python # in code import verifiers as vf env = vf.load_environment("benchcad-vision2code", num_examples=100) ``` -------------------------------- ### Quick smoke run Source: https://github.com/benchcad/benchcad-main/blob/main/CodeEdit/README.md Run the default config (configs/test.yaml) and plot results from results.jsonl. ```bash cd CodeEdit # Run with default config (configs/test.yaml): uv run python main.py # Plot from whatever's in /results.jsonl: uv run python main.py --plot ``` -------------------------------- ### Download full-bench data Source: https://github.com/benchcad/benchcad-main/blob/main/CodeEdit/README.md One-time command to download the full benchmark data into data/ (~339 MB, 748 records). ```bash cd CodeEdit uv run python tools/download_edit_bench.py # → data/ (~339 MB, 748 records) ``` -------------------------------- ### Build sandbox image and run agentic config Source: https://github.com/benchcad/benchcad-main/blob/main/Vision2Code/README.md Build the Docker sandbox image for your architecture (once) and run the agentic config. The sandbox has no network; run_python returns stdout, stderr, and images. submit ends the episode; an episode that never calls submit scores 0. ```bash # once, from the repo root: build the sandbox image for your architecture docker build -f docker/sandbox.arm64.Dockerfile -t benchcad-sandbox:arm64 . # Apple silicon docker build -f docker/sandbox.Dockerfile -t benchcad-sandbox:amd64 . # x86-64 # from Vision2Code/ uv run python main.py --config configs/agentic.yaml ``` -------------------------------- ### Download full-bench data Source: https://github.com/benchcad/benchcad-main/blob/main/QA/README.md One-time download of full-bench data. The code bench downloads to data/, the image bench to data_qa_img/. Use --limit and --out to create a tiny smoke fixture. ```bash cd QA # code bench (text-only): uv run python tools/download_qa_bench.py # → data/ # image bench (composite_png + 12 QA per stem): uv run python tools/download_qa_img.py # → data_qa_img/ uv run python tools/download_qa_img.py --limit 2 \ --out test_data_img # tiny smoke fixture ``` -------------------------------- ### Folder structure Source: https://github.com/benchcad/benchcad-main/blob/main/CodeEdit/README.md Shows the project directory layout with main.py, configs, tools, pipeline, scoring, models, test_data, and data. ```text CodeEdit/ ├── main.py CLI: --config, --plot, --records, --limit ├── configs/ YAML configs (test.yaml, prod.yaml, ...) ├── tools/ │ └── download_edit_bench.py pulls HF parquet → data/ (matches test_data shape) ├── pipeline/ │ ├── modes.py (system, user_text, image_paths) per mode │ ├── runner.py per-record loop + overwrite store │ ├── store.py results.jsonl helpers │ ├── plot.py results.jsonl → bar plot (husl palette) │ └── prompts/ reference prompt templates ├── scoring/ │ ├── exec_cq.py extract code → run subprocess → STEP file │ ├── iou.py voxel IoU + norm_iou │ └── views.py STEP → 4-view composite PNG (Tiffany blue) ├── models/ provider adapters (openai / anthropic / gemini / openrouter) ├── test_data/ 4 records committed for smoke runs └── data/ full bench, populated by tools/download_edit_bench.py (gitignored) ``` -------------------------------- ### Quick smoke run Source: https://github.com/benchcad/benchcad-main/blob/main/QA/README.md Quick smoke run with the default config, then plot results from results.jsonl. ```bash cd QA # Run with default config (configs/test.yaml): uv run python main.py # Plot from whatever's in /results.jsonl: uv run python main.py --plot ``` -------------------------------- ### Download full-bench data Source: https://github.com/benchcad/benchcad-main/blob/main/Vision2Code/README.md One-time download of the full benchmark data into the data/ directory. Run from the Vision2Code directory. ```bash cd Vision2Code uv run python tools/download_codegen_bench.py # → data/ ``` -------------------------------- ### Vision2Code folder structure Source: https://github.com/benchcad/benchcad-main/blob/main/Vision2Code/README.md Directory layout of the Vision2Code project. main.py is the CLI entry point with flags --config, --plot, --records, --limit. tools/download_codegen_bench.py pulls HF parquet into data/. pipeline/ contains runner, agentic, prompt, store, and plot modules. scoring/ includes exec_cq.py, iou.py, and views.py. models/ holds provider adapters. test_data/ has 4 committed records for smoke runs; data/ is gitignored and populated by the download tool. ```text Vision2Code/ ├── main.py CLI: --config, --plot, --records, --limit ├── configs/ YAML configs (test.yaml, prod.yaml, ...) ├── tools/ │ └── download_codegen_bench.py pulls HF parquet → data/ ├── pipeline/ │ ├── runner.py per-record loop + overwrite store │ ├── agentic.py sandbox episode loop (configs/agentic.yaml) │ ├── prompt.py (system, user_text, image_paths) builder │ ├── store.py results.jsonl helpers │ └── plot.py results.jsonl → bar plot (husl palette) ├── scoring/ │ ├── exec_cq.py extract code → run subprocess → STEP file │ ├── iou.py voxel IoU (64³ grid) │ └── views.py STEP → 4-view composite PNG (Tiffany blue) ├── models/ provider adapters (openai / anthropic / gemini / openrouter) ├── test_data/ 4 records committed for smoke runs └── data/ full bench, populated by tools/download_codegen_bench.py (gitignored) ``` -------------------------------- ### Custom run with config Source: https://github.com/benchcad/benchcad-main/blob/main/CodeEdit/README.md Run with a specific config file and optionally plot results. ```bash cd CodeEdit uv run python main.py --config configs/prod.yaml uv run python main.py --config configs/myrun.yaml --plot ``` -------------------------------- ### Output directory structure Source: https://github.com/benchcad/benchcad-main/blob/main/CodeEdit/README.md Shows the output directory layout with results.jsonl, plot.png, and outputs/ subdirectories. ```text / ├── results.jsonl (mode, model, record_id) → norm_iou + paths ├── plot.png written by --plot only └── outputs///.{py,step,png} ``` -------------------------------- ### YAML config for QA run Source: https://github.com/benchcad/benchcad-main/blob/main/QA/README.md Defines the run configuration: input mode, data and output directories, and model list. Paths are relative to QA/. Copy to configs/myrun.yaml and pass --config. ```yaml mode: code # code | img | both (default: code) data_dir: test_data out_dir: results_test models: [gpt-4o, claude-opus-4-7, ...] ``` -------------------------------- ### Custom run with --config Source: https://github.com/benchcad/benchcad-main/blob/main/QA/README.md Run with a custom config and optionally plot. Debug overrides: --records r1 r2 and --limit N. ```bash cd QA uv run python main.py --config configs/prod.yaml uv run python main.py --config configs/myrun.yaml --plot ``` -------------------------------- ### Run linting and tests locally Source: https://github.com/benchcad/benchcad-main/blob/main/CONTRIBUTING.md Run these checks before submitting a PR. Every behavior change must ship a test that fails before and passes after. ```bash uv run ruff check . uv run pytest -q ``` -------------------------------- ### QA folder structure Source: https://github.com/benchcad/benchcad-main/blob/main/QA/README.md Folder structure of the QA directory, listing key files and their roles. ```text QA/ ├── main.py CLI: --config, --plot, --records, --limit ├── configs/ YAML configs (test.yaml, prod.yaml, ...) ├── tools/ │ ├── download_qa_bench.py code bench: HF code-qa-bench → data/ │ └── download_qa_img.py image bench: HF QA/qa_2400.parquet → data_qa_img/ ├── pipeline/ │ ├── runner.py per-record loop + overwrite store │ ├── prompt.py (system, user_text, image_paths) builder │ ├── store.py results.jsonl helpers │ └── plot.py results.jsonl → bar plot (husl palette) ├── scoring/ │ └── qa_score.py JSON parser + ratio accuracy ├── models/ provider adapters (openai / anthropic / gemini / openrouter) ├── test_data/ 4 records committed for code-mode smoke runs ├── test_data_img/ tiny img-mode smoke fixture (populate via download_qa_img.py --limit) ├── data/ full code bench (gitignored) └── data_qa_img/ full image bench (gitignored) ``` -------------------------------- ### Output directory structure Source: https://github.com/benchcad/benchcad-main/blob/main/Vision2Code/README.md Output per config's out_dir, relative to Vision2Code/. results.jsonl is overwrite-keyed by (model, record_id); re-running a tuple replaces the old row. ```text / ├── results.jsonl (model, record_id) → iou + paths ├── plot.png written by --plot only └── outputs//.{py,step,png} ``` -------------------------------- ### Output directory structure Source: https://github.com/benchcad/benchcad-main/blob/main/QA/README.md Output directory structure. results.jsonl is overwrite-keyed by (model, record_id); re-running a tuple replaces the old row. ```text / ├── results.jsonl (model, record_id) → qa_score + per_qa breakdown ├── plot.png written by --plot only └── outputs//.{txt,json} ``` -------------------------------- ### CadQuery Edit Prompt Template Source: https://github.com/benchcad/benchcad-main/blob/main/CodeEdit/pipeline/prompts/ablation.txt System prompt instructing the AI to edit a CadQuery program. It requires outputting only the full edited Python code in a single fenced block, with no prose. The prompt includes placeholders for the instruction, original and target geometry images, and the original code. ```markdown System: You are a CAD engineer. Edit the given CadQuery program so the resulting STEP file matches the requested change. Output ONLY the full edited Python code in a single ```python fenced block — no prose. User: Instruction: {instruction} Original geometry (image 1) and the target geometry (image 2): [image 1: orig.png] [image 2: gt.png] Original code: ```python {orig_code} ``` ``` -------------------------------- ### CadQuery Python code block placeholder Source: https://github.com/benchcad/benchcad-main/blob/main/CodeEdit/pipeline/prompts/instruction_only.txt This is the placeholder for the original CadQuery code that the user provides. The system prompt instructs the AI to edit this code to match the requested change and output the full edited Python code in a single fenced block. ```python {orig_code} ``` -------------------------------- ### Set response timeout on OpenAI client Source: https://github.com/benchcad/benchcad-main/blob/main/environments/benchcad-vision2code/README.md Configures a generous response timeout on the OpenAI client to avoid cutting off slow reasoning models. This timeout is separate from the execution timeout and is set on the client, not the environment. ```python from openai import AsyncOpenAI import verifiers as vf client = AsyncOpenAI(timeout=3600) # 1 h — so slow reasoning isn't cut off env = vf.load_environment("benchcad-vision2code", num_examples=100) # ...evaluate the env with `client`. The other generation knobs — max_tokens, # reasoning_effort — are sampling args (`vf-eval -S '{...}'`), also client-side. ``` -------------------------------- ### BenchCAD contribution directory layout Source: https://github.com/benchcad/benchcad-main/blob/main/CONTRIBUTING.md Required file structure for a new part family contribution. Includes family.json, generator.py, qa/.json, and edits/.json. The generator.py must define build(difficulty, seed) returning CadQuery code as a string. ```text contributions// ├── family.json # {"family","standard","base_plane","description","source","contributor"} ├── generator.py # defines build(difficulty, seed) -> str (a CadQuery program) ├── qa/.json # ≥2 files, 12 questions each: [{"question","answer","type","level"}] └── edits/.json # cover all 3 prototype difficulties, ~2-3 each: # {"prototype_difficulty":"easy|medium|hard", # "category":"T1..T5", "edit_type":"dim|add_hole|rotate|...", # "instruction":"...", "orig_code":"...", "gt_code":"..."} ``` -------------------------------- ### Local re-grading command with tools/regrade.py Source: https://github.com/benchcad/benchcad-main/blob/main/CONTRIBUTING.md Run this command to sanity-check predictions locally. --task must be one of codeqa, codegen, or codeedit. codegen/codeedit re-execute CadQuery and score by voxel IoU; codeqa scores by symmetric ratio accuracy. No judge model is involved. ```bash uv run python tools/regrade.py --task codeqa \ --gt path/to/gt_records.jsonl --pred submission.jsonl --model "" ``` -------------------------------- ### Submission JSONL format for model results Source: https://github.com/benchcad/benchcad-main/blob/main/CONTRIBUTING.md Each line in submission.jsonl must be one object with record_id and prediction fields. The prediction is the raw model output text; do not send a score. ```jsonl {"record_id": "...", "prediction": ""} ``` -------------------------------- ### Composite score formula (--score composite) Source: https://github.com/benchcad/benchcad-main/blob/main/Vision2Code/README.md Fused BenchCAD total score combining IoU, essential operations, feature F1, Chamfer, and Hausdorff terms. IoU is the raw voxel IoU (same as --score iou). Essential-op term is dropped for families without a spec, rescaling the remaining 0.80 to [0,1]. Weights and essential-op spec are sourced from the vendored BenchCAD generation repo. ```python score = 0.60·IoU + 0.20·essential-op + 0.10·Feature-F1 + 0.05·Chamfer-score + 0.05·Hausdorff-score ``` -------------------------------- ### Voxel IoU scoring formula Source: https://github.com/benchcad/benchcad-main/blob/main/Vision2Code/README.md Computes voxel IoU between model and ground-truth STEP on a 64³ grid. Both STEPs are tessellated, normalized (bbox center to [0.5,0.5,0.5], longest axis to [0,1]), and voxelized at pitch 1/64. IoU is 0 when code doesn't exec or geometry is degenerate; 1 when voxelized solids match. ```python iou = voxel-IoU(model_step, gt_step) # 64³ grid, normalized ``` -------------------------------- ### norm_iou scoring formula Source: https://github.com/benchcad/benchcad-main/blob/main/CodeEdit/README.md Formula for normalized IoU, showing how model_iou, baseline_iou, and norm_iou are computed. ```text model_iou = voxel-IoU(model_step, gt_step) # 64³ grid, normalized baseline_iou = record["iou"] # = IoU(orig_step, gt_step) norm_iou = clip( (model_iou - baseline_iou) / (1 - baseline_iou), 0, 1 ) ``` -------------------------------- ### Set execution timeout Source: https://github.com/benchcad/benchcad-main/blob/main/environments/benchcad-vision2code/README.md Sets the execution timeout for scoring, which bounds the CadQuery-to-STEP subprocess runs used to score a rollout. Default is 300 seconds; raise it for slow-tessellating families on slower hardware. ```python env = vf.load_environment("benchcad-vision2code", exec_timeout=600) ```