Building a G-Code Generation Benchmark With Machining Experts

Building a G-Code Generation Benchmark With Machining Experts

G-code generation is one of the clearest tests of whether a model understands physical consequence. Every line of output either produces a valid toolpath or it does not. There is no partial credit on the machine. Building a G-code generation benchmark with machining experts is not a documentation exercise. It is a precision measurement instrument, and every design decision either sharpens or corrupts the signal. This post describes how to build one: task structure, verifier design, difficulty calibration, and the failure modes that invalidate most first attempts.

Answer Capsule

A G-code generation benchmark requires expert-authored tasks with deterministic verifiers (simulator or post-processor), empirical difficulty calibration against at least two frontier models, and explicit rubrics for geometric correctness, feed-and-speed validity, and safety constraint satisfaction. Tasks sourced from public CNC forums or documentation are contaminated by default and should not be used.

Why G-Code Is a Distinct Evaluation Domain

G-code occupies a narrow band in the landscape of programming languages. It is procedural, positional, and machine-specific. A model that generates syntactically valid G-code can still produce output that gouges a workpiece, violates spindle limits, or leaves a cutter buried in stock. These are not edge cases. They are the primary failure mode of models that have learned surface syntax without internalising the physical constraints that govern toolpath planning.

Standard code benchmarks measure functional correctness against unit tests. G-code benchmarks must measure geometric correctness, process validity, and safety constraint satisfaction simultaneously. No existing general-purpose coding benchmark captures this. The gap is structural, not a matter of adding more CNC-flavored prompts to HumanEval or similar suites.

Frontier models trained on web-derived data have seen G-code. They can produce plausible-looking output. The question a benchmark must answer is whether that output is machinable, not merely parseable. That distinction requires a verifier that understands the physical semantics of the code, and it requires tasks authored by people who have run the programs.

How to Structure G-Code Benchmark Tasks

Each task must specify four things unambiguously: the geometry to be produced, the stock material and dimensions, the machine and controller context, and the acceptance criteria. Underspecifying any one of these produces tasks that are ambiguous to the model and unverifiable by the evaluator.

Task Components

  • Geometry specification: A dimensional drawing, a coordinate table, or an explicit feature description (for example, a 12mm diameter through-hole at X50 Y30 in 6061 aluminium, 20mm stock thickness). Ambiguous geometry produces ambiguous outputs that cannot be scored reliably.

  • Machine and controller context: Controller variant matters. G41/G42 cutter compensation behaves differently across Fanuc, Haas, and Siemens 840D. Tasks must declare the target controller. Tasks that omit this are not evaluating G-code generation; they are evaluating guessing.

  • Material and tooling constraints: Feed rate and spindle speed validity depend on material, tool diameter, and depth of cut. A rubric that ignores these cannot distinguish a safe program from one that will break tooling.

  • Acceptance criteria: State what correct looks like before authoring begins. Geometric tolerance (for example, within 0.01mm of nominal), required canned cycles, mandatory safety blocks (tool length offset call, spindle start before feed move), and forbidden constructs (rapid moves into stock).

Expert task authors are not prompt writers. They are practitioners who have written and debugged G-code programs on real machines. Their value is in knowing which constraints are non-negotiable and which are stylistic, and in writing tasks where those constraints are testable. For more on how expert authoring throughput and quality interact, see expert task authoring throughput benchmarks.

Verifier Design: The Non-Negotiable Core

A G-code task without a reliable verifier is not a benchmark task. It is an opinion survey. Verifier design is where most first-attempt benchmarks fail, and where expert involvement is most critical.

Three Verifier Tiers

Tier

Method

What it catches

What it misses

Syntactic

G-code parser or post-processor lint

Malformed blocks, unknown addresses, modal conflicts

Geometric errors, unsafe feeds, wrong toolpaths

Geometric

Toolpath simulator (for example, open-source NC simulation libraries or commercial verifiers)

Gouge detection, missed features, dimensional error

Machine-specific modal state, controller quirks

Process

Expert review against rubric

Feed-and-speed validity, canned cycle appropriateness, setup efficiency

Slow; does not scale without structured rubrics

A production benchmark uses all three tiers in sequence. Syntactic failures are caught first and cheapest. Geometric failures require simulation. Process validity requires expert review, but a well-designed rubric reduces expert time per task from hours to minutes.

The verifier must be versioned and documented alongside the tasks. A verifier bug that silently accepts incorrect output invalidates every score produced while the bug was active. This is not hypothetical. Verifier drift is a real operational risk in any benchmark that runs over multiple model evaluation cycles.

Difficulty Calibration Against Frontier Models

Difficulty is not a property of a task in isolation. It is a relationship between a task and a model population at a point in time. A task that no frontier model can solve today may be trivial in eighteen months. Building a G-code generation benchmark with machining experts requires empirical difficulty calibration, not intuitive grading.

The standard method is pass@k estimation. For a given task, sample k independent model outputs and score each against the verifier. Pass@k estimates the probability that at least one of k samples is correct. Tasks where pass@1 exceeds 0.8 across all evaluated models are too easy for a discrimination benchmark. Tasks where pass@k is zero across all models at k=10 may be too hard to generate useful gradient signal for post-training.

The target difficulty band for a useful G-code benchmark is pass@1 between 0.1 and 0.6 across the model population, with meaningful variance between models. Tasks in this band discriminate. Tasks outside it do not. For the statistical reasoning behind difficulty calibration thresholds, see IRT for calibrating AI benchmark item difficulty.

Difficulty also has a structure. A well-designed benchmark covers a range of machining operations: simple facing and drilling at the easy end, multi-setup contour milling with cutter compensation and subroutine calls at the hard end. Flat difficulty distributions produce flat score distributions and low discriminative power across model generations. See benchmark discriminative power across model generations for how difficulty structure affects benchmark utility over time.

Worked Example: A Facing Operation Task

Illustrative example (numbers are plausible but constructed for demonstration):

Task prompt: Write a Fanuc-compatible G-code program to face a 100mm x 80mm x 5mm rectangular aluminium blank to a finished depth of 4mm. Use a 25mm face mill. Spindle speed: 3000 RPM. Feed rate: 500 mm/min. Include tool length offset call (H01), coolant on (M08), and a safe rapid retract to Z10 before program end.

Acceptance criteria:

  1. Syntactic: parses without error on a Fanuc-dialect parser.

  2. Geometric: simulated toolpath covers the full 100mm x 80mm surface with no uncovered region greater than 0.5mm, and does not exceed Z0 (stock surface) on any cutting move before the first depth pass.

  3. Process: H01 called before first feed move; M08 present; final block includes M09, M05, G91 G28 Z0 or equivalent retract, M30.

Illustrative pass@1 scores across four frontier models (hypothetical): Model A: 0.62, Model B: 0.48, Model C: 0.71, Model D: 0.39. This task discriminates between models and sits within the useful difficulty band. A harder variant adds a pocket with island, requiring G41 compensation and a helical entry move. Illustrative pass@1 across the same models: 0.11, 0.08, 0.19, 0.04. The harder variant is useful for post-training signal but too hard for a general discrimination benchmark.

Common Failure Modes in G-Code Benchmark Design

1. Tasks sourced from public CNC forums or documentation

Detection: Run n-gram overlap checks against common CNC training corpora. High overlap means the task is likely memorised, not reasoned. Fix: Author tasks from original specifications, using novel part geometries and non-standard feature combinations. See detecting benchmark contamination with n-gram and embedding methods.

2. Verifier that only checks syntax

Detection: A model that outputs syntactically valid but geometrically wrong code scores 1.0 on the verifier. Compare verifier scores against expert review scores on a sample of 20 tasks. If correlation is below 0.7, the verifier is insufficient. Fix: Add geometric simulation as a mandatory second tier.

3. Underspecified machine context

Detection: Two expert reviewers score the same model output differently because they assumed different controllers. Fix: Every task specifies controller dialect. Reviewers are calibrated on gold tasks before live scoring.

4. Difficulty assigned by expert intuition, not measurement

Detection: Pass@1 distribution is bimodal: most tasks cluster near 0.0 or near 1.0, with few in the 0.1 to 0.6 band. Fix: Run a pilot evaluation against two frontier models before finalising the task set. Retire or revise tasks outside the target band. Web-derived tasks decay faster and cluster at the easy end. See web-derived eval tasks and benchmark half-life.

5. No rubric for partial credit on process validity

Detection: Expert reviewers spend more than 15 minutes per task because they are re-deciding the same questions each time. Fix: Build a structured rubric before authoring begins. Define which process errors are fatal (rapid into stock), which are major (missing coolant call), and which are minor (suboptimal step-over). Score each dimension independently.

6. Benchmark treated as static after release

Detection: Pass@1 across all tasks exceeds 0.75 for the leading model within twelve months of release. Fix: Design a refresh protocol from the start. Track difficulty drift. Add harder tasks on a defined schedule. A benchmark that saturates stops measuring. See benchmark saturation timelines for empirical saturation rates across benchmark categories.

Where This Approach Breaks Down

Geometric simulation verifiers are accurate for standard milling and turning operations. They are less reliable for multi-axis simultaneous cutting, live tooling on turn-mill centres, and macro-driven programs with variable logic. Tasks in these categories require expert review for every evaluated output, which limits throughput significantly.

Pass@k calibration assumes model outputs are independent samples. In practice, models with strong positional biases may produce correlated outputs, which inflates apparent difficulty. This is a known limitation of pass@k as a difficulty estimator and should be noted in benchmark documentation.

Expert agreement on process validity is higher for well-constrained operations (facing, drilling, simple pocketing) and lower for complex multi-setup programs where multiple valid approaches exist. Tasks with low inter-expert agreement should be flagged, revised, or retired. They introduce noise, not signal.

FAQ

What makes a G-code benchmark task contamination-resistant?

Tasks authored from original part specifications, with novel geometry combinations not present in public CNC repositories, resist contamination. Contamination checks using n-gram overlap and embedding similarity against known training corpora are a necessary second step. Tasks derived from manufacturer documentation or forum posts should be treated as contaminated by default.

How many tasks does a useful G-code benchmark require?

Statistical power depends on the discrimination question. To detect a 5-percentage-point difference in pass@1 between two models at 80% power, standard power analysis suggests roughly 200 to 400 tasks, depending on the baseline pass rate and variance. Fewer tasks can support qualitative failure-mode analysis but not reliable model ranking.

Can LLM-as-judge replace expert review for G-code scoring?

For syntactic and basic structural checks, LLM-as-judge is a reasonable first pass. For geometric correctness and process validity, it is not sufficient. A model evaluating G-code output cannot simulate the toolpath or verify feed-and-speed physics. Expert review backed by a simulator is required for the dimensions that matter most.

How quickly do G-code benchmark tasks saturate?

Tasks sourced from public documentation saturate faster than expert-authored tasks because models have likely seen them in training. Empirically, benchmarks built from web-derived content in technical domains have shown meaningful score inflation within one to two model generations. Expert-authored tasks with novel geometry combinations have longer useful lifespans, but difficulty should be re-measured at each major model release.

What is the right difficulty target for a G-code eval used in post-training?

For post-training signal (SFT or RLVR), tasks where pass@1 is near zero provide no learning gradient. Tasks where pass@1 is near 1.0 provide no signal either. The productive range is pass@1 between 0.1 and 0.5, where the model occasionally succeeds and the verifier can reward correct outputs. Tasks in this band are also useful for process reward model training.

What This Means in Practice

Building a G-code generation benchmark with machining experts is an engineering problem, not a data collection problem. The decisions that determine benchmark quality are made before any task is written: verifier architecture, machine context specification, difficulty calibration protocol, and rubric design. Expert machinists and CNC instructors provide the domain knowledge that makes tasks verifiable and non-trivial. Empirical difficulty calibration ensures the benchmark measures what it claims to measure. A benchmark built this way produces signal that is durable, interpretable, and useful for both evaluation and post-training. One built without these foundations produces scores that look precise and mean very little.

If you are building evals or RL environments in CNC, CAM, or adjacent manufacturing domains, get in touch with Chiron Data Labs.

Have questions or want personalised guidance? Contact us and we'll be happy to help.

G-code generation is one of the clearest tests of whether a model understands physical consequence. Every line of output either produces a valid toolpath or it does not. There is no partial credit on the machine. Building a G-code generation benchmark with machining experts is not a documentation exercise. It is a precision measurement instrument, and every design decision either sharpens or corrupts the signal. This post describes how to build one: task structure, verifier design, difficulty calibration, and the failure modes that invalidate most first attempts.

Answer Capsule

A G-code generation benchmark requires expert-authored tasks with deterministic verifiers (simulator or post-processor), empirical difficulty calibration against at least two frontier models, and explicit rubrics for geometric correctness, feed-and-speed validity, and safety constraint satisfaction. Tasks sourced from public CNC forums or documentation are contaminated by default and should not be used.

Why G-Code Is a Distinct Evaluation Domain

G-code occupies a narrow band in the landscape of programming languages. It is procedural, positional, and machine-specific. A model that generates syntactically valid G-code can still produce output that gouges a workpiece, violates spindle limits, or leaves a cutter buried in stock. These are not edge cases. They are the primary failure mode of models that have learned surface syntax without internalising the physical constraints that govern toolpath planning.

Standard code benchmarks measure functional correctness against unit tests. G-code benchmarks must measure geometric correctness, process validity, and safety constraint satisfaction simultaneously. No existing general-purpose coding benchmark captures this. The gap is structural, not a matter of adding more CNC-flavored prompts to HumanEval or similar suites.

Frontier models trained on web-derived data have seen G-code. They can produce plausible-looking output. The question a benchmark must answer is whether that output is machinable, not merely parseable. That distinction requires a verifier that understands the physical semantics of the code, and it requires tasks authored by people who have run the programs.

How to Structure G-Code Benchmark Tasks

Each task must specify four things unambiguously: the geometry to be produced, the stock material and dimensions, the machine and controller context, and the acceptance criteria. Underspecifying any one of these produces tasks that are ambiguous to the model and unverifiable by the evaluator.

Task Components

  • Geometry specification: A dimensional drawing, a coordinate table, or an explicit feature description (for example, a 12mm diameter through-hole at X50 Y30 in 6061 aluminium, 20mm stock thickness). Ambiguous geometry produces ambiguous outputs that cannot be scored reliably.

  • Machine and controller context: Controller variant matters. G41/G42 cutter compensation behaves differently across Fanuc, Haas, and Siemens 840D. Tasks must declare the target controller. Tasks that omit this are not evaluating G-code generation; they are evaluating guessing.

  • Material and tooling constraints: Feed rate and spindle speed validity depend on material, tool diameter, and depth of cut. A rubric that ignores these cannot distinguish a safe program from one that will break tooling.

  • Acceptance criteria: State what correct looks like before authoring begins. Geometric tolerance (for example, within 0.01mm of nominal), required canned cycles, mandatory safety blocks (tool length offset call, spindle start before feed move), and forbidden constructs (rapid moves into stock).

Expert task authors are not prompt writers. They are practitioners who have written and debugged G-code programs on real machines. Their value is in knowing which constraints are non-negotiable and which are stylistic, and in writing tasks where those constraints are testable. For more on how expert authoring throughput and quality interact, see expert task authoring throughput benchmarks.

Verifier Design: The Non-Negotiable Core

A G-code task without a reliable verifier is not a benchmark task. It is an opinion survey. Verifier design is where most first-attempt benchmarks fail, and where expert involvement is most critical.

Three Verifier Tiers

Tier

Method

What it catches

What it misses

Syntactic

G-code parser or post-processor lint

Malformed blocks, unknown addresses, modal conflicts

Geometric errors, unsafe feeds, wrong toolpaths

Geometric

Toolpath simulator (for example, open-source NC simulation libraries or commercial verifiers)

Gouge detection, missed features, dimensional error

Machine-specific modal state, controller quirks

Process

Expert review against rubric

Feed-and-speed validity, canned cycle appropriateness, setup efficiency

Slow; does not scale without structured rubrics

A production benchmark uses all three tiers in sequence. Syntactic failures are caught first and cheapest. Geometric failures require simulation. Process validity requires expert review, but a well-designed rubric reduces expert time per task from hours to minutes.

The verifier must be versioned and documented alongside the tasks. A verifier bug that silently accepts incorrect output invalidates every score produced while the bug was active. This is not hypothetical. Verifier drift is a real operational risk in any benchmark that runs over multiple model evaluation cycles.

Difficulty Calibration Against Frontier Models

Difficulty is not a property of a task in isolation. It is a relationship between a task and a model population at a point in time. A task that no frontier model can solve today may be trivial in eighteen months. Building a G-code generation benchmark with machining experts requires empirical difficulty calibration, not intuitive grading.

The standard method is pass@k estimation. For a given task, sample k independent model outputs and score each against the verifier. Pass@k estimates the probability that at least one of k samples is correct. Tasks where pass@1 exceeds 0.8 across all evaluated models are too easy for a discrimination benchmark. Tasks where pass@k is zero across all models at k=10 may be too hard to generate useful gradient signal for post-training.

The target difficulty band for a useful G-code benchmark is pass@1 between 0.1 and 0.6 across the model population, with meaningful variance between models. Tasks in this band discriminate. Tasks outside it do not. For the statistical reasoning behind difficulty calibration thresholds, see IRT for calibrating AI benchmark item difficulty.

Difficulty also has a structure. A well-designed benchmark covers a range of machining operations: simple facing and drilling at the easy end, multi-setup contour milling with cutter compensation and subroutine calls at the hard end. Flat difficulty distributions produce flat score distributions and low discriminative power across model generations. See benchmark discriminative power across model generations for how difficulty structure affects benchmark utility over time.

Worked Example: A Facing Operation Task

Illustrative example (numbers are plausible but constructed for demonstration):

Task prompt: Write a Fanuc-compatible G-code program to face a 100mm x 80mm x 5mm rectangular aluminium blank to a finished depth of 4mm. Use a 25mm face mill. Spindle speed: 3000 RPM. Feed rate: 500 mm/min. Include tool length offset call (H01), coolant on (M08), and a safe rapid retract to Z10 before program end.

Acceptance criteria:

  1. Syntactic: parses without error on a Fanuc-dialect parser.

  2. Geometric: simulated toolpath covers the full 100mm x 80mm surface with no uncovered region greater than 0.5mm, and does not exceed Z0 (stock surface) on any cutting move before the first depth pass.

  3. Process: H01 called before first feed move; M08 present; final block includes M09, M05, G91 G28 Z0 or equivalent retract, M30.

Illustrative pass@1 scores across four frontier models (hypothetical): Model A: 0.62, Model B: 0.48, Model C: 0.71, Model D: 0.39. This task discriminates between models and sits within the useful difficulty band. A harder variant adds a pocket with island, requiring G41 compensation and a helical entry move. Illustrative pass@1 across the same models: 0.11, 0.08, 0.19, 0.04. The harder variant is useful for post-training signal but too hard for a general discrimination benchmark.

Common Failure Modes in G-Code Benchmark Design

1. Tasks sourced from public CNC forums or documentation

Detection: Run n-gram overlap checks against common CNC training corpora. High overlap means the task is likely memorised, not reasoned. Fix: Author tasks from original specifications, using novel part geometries and non-standard feature combinations. See detecting benchmark contamination with n-gram and embedding methods.

2. Verifier that only checks syntax

Detection: A model that outputs syntactically valid but geometrically wrong code scores 1.0 on the verifier. Compare verifier scores against expert review scores on a sample of 20 tasks. If correlation is below 0.7, the verifier is insufficient. Fix: Add geometric simulation as a mandatory second tier.

3. Underspecified machine context

Detection: Two expert reviewers score the same model output differently because they assumed different controllers. Fix: Every task specifies controller dialect. Reviewers are calibrated on gold tasks before live scoring.

4. Difficulty assigned by expert intuition, not measurement

Detection: Pass@1 distribution is bimodal: most tasks cluster near 0.0 or near 1.0, with few in the 0.1 to 0.6 band. Fix: Run a pilot evaluation against two frontier models before finalising the task set. Retire or revise tasks outside the target band. Web-derived tasks decay faster and cluster at the easy end. See web-derived eval tasks and benchmark half-life.

5. No rubric for partial credit on process validity

Detection: Expert reviewers spend more than 15 minutes per task because they are re-deciding the same questions each time. Fix: Build a structured rubric before authoring begins. Define which process errors are fatal (rapid into stock), which are major (missing coolant call), and which are minor (suboptimal step-over). Score each dimension independently.

6. Benchmark treated as static after release

Detection: Pass@1 across all tasks exceeds 0.75 for the leading model within twelve months of release. Fix: Design a refresh protocol from the start. Track difficulty drift. Add harder tasks on a defined schedule. A benchmark that saturates stops measuring. See benchmark saturation timelines for empirical saturation rates across benchmark categories.

Where This Approach Breaks Down

Geometric simulation verifiers are accurate for standard milling and turning operations. They are less reliable for multi-axis simultaneous cutting, live tooling on turn-mill centres, and macro-driven programs with variable logic. Tasks in these categories require expert review for every evaluated output, which limits throughput significantly.

Pass@k calibration assumes model outputs are independent samples. In practice, models with strong positional biases may produce correlated outputs, which inflates apparent difficulty. This is a known limitation of pass@k as a difficulty estimator and should be noted in benchmark documentation.

Expert agreement on process validity is higher for well-constrained operations (facing, drilling, simple pocketing) and lower for complex multi-setup programs where multiple valid approaches exist. Tasks with low inter-expert agreement should be flagged, revised, or retired. They introduce noise, not signal.

FAQ

What makes a G-code benchmark task contamination-resistant?

Tasks authored from original part specifications, with novel geometry combinations not present in public CNC repositories, resist contamination. Contamination checks using n-gram overlap and embedding similarity against known training corpora are a necessary second step. Tasks derived from manufacturer documentation or forum posts should be treated as contaminated by default.

How many tasks does a useful G-code benchmark require?

Statistical power depends on the discrimination question. To detect a 5-percentage-point difference in pass@1 between two models at 80% power, standard power analysis suggests roughly 200 to 400 tasks, depending on the baseline pass rate and variance. Fewer tasks can support qualitative failure-mode analysis but not reliable model ranking.

Can LLM-as-judge replace expert review for G-code scoring?

For syntactic and basic structural checks, LLM-as-judge is a reasonable first pass. For geometric correctness and process validity, it is not sufficient. A model evaluating G-code output cannot simulate the toolpath or verify feed-and-speed physics. Expert review backed by a simulator is required for the dimensions that matter most.

How quickly do G-code benchmark tasks saturate?

Tasks sourced from public documentation saturate faster than expert-authored tasks because models have likely seen them in training. Empirically, benchmarks built from web-derived content in technical domains have shown meaningful score inflation within one to two model generations. Expert-authored tasks with novel geometry combinations have longer useful lifespans, but difficulty should be re-measured at each major model release.

What is the right difficulty target for a G-code eval used in post-training?

For post-training signal (SFT or RLVR), tasks where pass@1 is near zero provide no learning gradient. Tasks where pass@1 is near 1.0 provide no signal either. The productive range is pass@1 between 0.1 and 0.5, where the model occasionally succeeds and the verifier can reward correct outputs. Tasks in this band are also useful for process reward model training.

What This Means in Practice

Building a G-code generation benchmark with machining experts is an engineering problem, not a data collection problem. The decisions that determine benchmark quality are made before any task is written: verifier architecture, machine context specification, difficulty calibration protocol, and rubric design. Expert machinists and CNC instructors provide the domain knowledge that makes tasks verifiable and non-trivial. Empirical difficulty calibration ensures the benchmark measures what it claims to measure. A benchmark built this way produces signal that is durable, interpretable, and useful for both evaluation and post-training. One built without these foundations produces scores that look precise and mean very little.

If you are building evals or RL environments in CNC, CAM, or adjacent manufacturing domains, get in touch with Chiron Data Labs.

Have questions or want personalised guidance? Contact us and we'll be happy to help.

© 2026 CHIRON, SAN FRANCISCO, CA