Authoring Original G-Code Tasks: A Guide for CNC Instructors
Authoring Original G-Code Tasks: A Guide for CNC Instructors
Frontier AI models can recite G-code syntax. They can explain what G41 does. What they cannot reliably do is produce a correct, collision-free toolpath for a real part under real constraints, then defend every line of it. That gap is where CNC instructors have irreplaceable value. Authoring original G-code tasks for AI training and evaluation is not a side project. It is a rigorous discipline, and this guide covers exactly how to do it. If you are a CNC or CAM instructor considering authoring original G-code tasks, this is the operational playbook.
Answer Capsule
Authoring original G-code tasks for AI training requires a CNC or CAM practitioner to design a machining scenario with unambiguous setup conditions, write a verifiable correct solution, define a programmatic or expert rubric that checks dimensional accuracy and process validity, and confirm that at least one frontier model fails the task before releasing it. Tasks sourced from textbooks or public forums are contaminated by default.
Why G-Code Tasks Are Unusually Hard to Author Well
G-code tasks fail as training signal for one of three reasons: the problem statement is ambiguous, the correct answer is not verifiable, or the task already exists in a form the model has seen. Each failure mode corrupts the downstream reward signal in a different way.
Ambiguous problem statements allow multiple valid toolpaths, which means a model can produce a wrong answer that a non-expert verifier marks correct. Unverifiable answers force evaluation to rely on human judgment alone, which does not scale and introduces inter-rater variance. Contaminated tasks, drawn from CNC textbooks, forum threads, or manufacturer documentation, inflate model performance scores without reflecting genuine capability.
The machining domain adds a further complication: correctness is multi-dimensional. A toolpath can be geometrically correct, dimensionally correct, and still cause a crash because feed rate, spindle speed, and tool compensation were not considered together. A task that checks only dimensional output misses the process reasoning that separates a competent machinist from a dangerous one.
For a deeper treatment of why original authorship is the contamination control mechanism, see the analysis of the contamination gap between original and scraped tasks.
The Anatomy of a Verifiable G-Code Task
A verifiable G-code task has five components. Every component must be present before the task is usable as an eval or training signal.
Setup specification. Machine type, controller dialect (Fanuc, Haas, Siemens, Mazak), work coordinate system origin, stock dimensions, and tool library. If any of these are underspecified, the task has multiple valid answers by definition.
Part geometry description. A dimensioned description or drawing reference. For text-only tasks, this means explicit coordinates, tolerances, and surface finish requirements. For multimodal tasks, an engineering drawing with GD&T callouts.
Process constraints. Required operations (roughing, finishing, drilling, threading), fixturing assumptions, and any explicit prohibitions (no climb milling, specific tool change position).
Gold solution. The correct G-code program, authored by the expert, with line-by-line annotations explaining each decision. The gold solution is not shown to the model; it anchors the verifier.
Verifier or rubric. A programmatic check, a simulation run, or an expert rubric that maps model output to the gold solution on specific criteria. A task without a verifier is not a task; it is a prompt.
The practical guide to programmatic verifiers for domain tasks covers how to design the verification layer for tasks like these.
Authoring Original G-Code Tasks: A Step-by-Step Protocol
The following protocol is for CNC instructors authoring tasks intended for AI evaluation or post-training. Each step produces a deliverable. Steps are sequential; do not skip forward.
Select a scenario from practice, not from curriculum. Draw the scenario from a real job you have set up or a common student error you have diagnosed. Do not adapt an example from a textbook or a manufacturer's programming guide. The scenario must not be findable verbatim on the public web.
Write the setup specification first. Before describing the part, lock the machine configuration. Controller dialect, tool offsets, and coordinate system origin must be explicit. Ambiguity here propagates into every subsequent step.
Describe the part geometry with tolerances. Use dimensional language, not narrative. "A rectangular pocket 80mm x 40mm x 15mm deep, centered at X50 Y30 from the WCS origin, with a corner radius of 5mm and a wall tolerance of +0.0 / -0.05mm" is a task. "Machine a pocket" is not.
Author the gold solution yourself, without AI assistance. Write the G-code program as you would for a real job. Annotate each block. The annotation is part of the deliverable; it becomes the rubric basis and the process supervision signal.
Design the verifier before testing the model. Decide what the verifier will check: coordinate sequence, modal state at each operation boundary, feed and speed values within acceptable range, absence of known crash conditions. A checklist verifier is sufficient for many tasks; a simulator-based verifier is required for complex multi-operation programs.
Run the task against at least two frontier models. If both models solve it correctly, the task is too easy or already contaminated. A good task produces at least one failure, and the failure should be instructive, meaning it reveals a specific gap in the model's process reasoning, not just a syntax error.
Document the failure mode. Record what the model got wrong and why. This failure-mode annotation is as valuable as the gold solution for post-training teams.
For the broader framework on converting domain knowledge into a verifiable task specification, the expert task authoring playbook covers the full pipeline from domain to deliverable.
Illustrative Example: A Facing and Shoulder Task
Illustrative example. Numbers are plausible but constructed to demonstrate the protocol, not drawn from a real production record.
Setup: Haas VF-2, Fanuc-compatible dialect, G54 work offset, stock is 100mm x 80mm x 30mm aluminum 6061, tool T01 is a 50mm face mill at H01/D01, T02 is a 12mm end mill at H02/D02.
Task: Write a G-code program to face the top surface of the stock to a depth of 0.5mm, then machine a 20mm wide x 10mm deep shoulder along the full 100mm length of the left edge (X-side), leaving a 0.02mm finish allowance on the shoulder wall. Use G41 cutter compensation on the shoulder pass. Tool change at X0 Y0 Z100. Program must include a safe Z retract before any rapid move.
What frontier models typically produce: The facing pass is usually correct. The shoulder pass frequently fails in one of three ways: G41 is invoked without a D offset word, the compensation is applied before the approach move rather than during it, or the finish allowance is ignored entirely and the shoulder is cut to nominal. The safe retract before rapids is omitted in roughly half of outputs tested informally by CNC instructors authoring tasks in this class.
Verifier checks for this task:
G41 present with correct D word before shoulder contour
G40 cancellation after contour, before tool change
Z retract to a value greater than stock height before every G00 XY move
Shoulder depth programmed to 9.98mm (10mm minus 0.02mm allowance), not 10mm
Feed rate on shoulder finishing pass within a defined acceptable range for the material and tool diameter
Each check maps to a rubric criterion. A model output that passes all five is a correct solution. A model output that fails criterion three is a crash risk. The distinction matters for how the training signal is weighted.
Common Failure Modes in G-Code Task Authoring
These are the failure modes that degrade task quality before the model ever sees the prompt.
1. Underspecified setup. Detection: another expert reads the task and asks a clarifying question about the machine or tool configuration. Fix: add every parameter that a setup sheet would include. If it would be on the job traveler, it belongs in the task.
2. Gold solution not machine-verified. Detection: the gold solution has never been run in a simulator or on a machine. Fix: run the gold solution through a G-code simulator (several free options exist) before finalizing the task. A gold solution with a crash is worse than no gold solution.
3. Verifier checks syntax, not process. Detection: the verifier passes any program that uses the correct G-codes in any order. Fix: add modal-state checks and sequence checks. The order of operations in machining is not arbitrary; a verifier that ignores sequence is not checking process reasoning.
4. Task is too easy because it is single-operation. Detection: both frontier models tested produce correct output. Fix: add a second operation that depends on the result of the first, or add a tolerance constraint that requires the model to adjust nominal values. For guidance on pushing tasks to the difficulty threshold where frontier models fail, see the approach described in adversarial task authoring to beat frontier models.
5. Failure mode not documented. Detection: the task record has a gold solution and a verifier but no record of what models got wrong. Fix: run the task, record the failure, annotate it with the specific line or decision where the model diverged from correct process reasoning. This annotation is the highest-value output of the authoring process for post-training teams.
6. Controller dialect mismatch. Detection: the task specifies Fanuc but the gold solution uses Siemens Cycle syntax. Fix: lock the dialect in the setup specification and verify the gold solution uses only commands valid for that dialect. Mixed-dialect tasks produce ambiguous model outputs that cannot be reliably scored.
Where This Approach Breaks Down
Programmatic verifiers cover a large fraction of G-code correctness criteria, but not all of them. Surface finish, chatter risk, and tool wear are not checkable from G-code alone; they require simulation or physical verification. Tasks that require judgment about these factors need expert rubrics, not just programmatic checks, and expert rubrics introduce inter-rater variance that must be managed through calibration.
Difficulty calibration also drifts. A task that two frontier models fail today may be solved reliably by the next model generation. Authoring original G-code tasks is not a one-time contribution; the difficulty of any given task relative to current models must be re-evaluated periodically. The model-in-the-loop authoring workflow describes how to use model failures to guide task revision without contaminating the task set.
Finally, throughput is a real constraint. A CNC instructor authoring tasks at the quality level described here will produce fewer tasks per hour than a generalist labeler producing simpler annotation work. Understanding the realistic output rate matters for planning. The expert task authoring throughput benchmarks provide reference points for scoping expert programs.
Frequently Asked Questions
Can I adapt tasks from a CNC programming textbook?
No. Textbook examples are in the training data of every frontier model. Adapting them, even with modified dimensions, produces tasks with high contamination risk. The gold solution may already be derivable from patterns the model has memorized. Original tasks must be constructed from scenarios not present in publicly available instructional material.
How many frontier models should I test a task against before finalizing it?
Test against at least two models from different families. A task that one model fails but another solves correctly is still a valid task; the difficulty is model-specific, which is expected. A task that both models solve correctly should be revised to increase complexity before release. Difficulty is always measured per model and per date, not as an absolute property of the task.
What makes a G-code verifier reliable enough for training signal?
A reliable verifier checks modal state, operation sequence, and dimensional output, not just the presence of correct G-codes. It should be deterministic: the same model output must always produce the same score. If the verifier requires human judgment to resolve ambiguous cases, document those cases explicitly and treat them as rubric items rather than programmatic checks.
Do I need to know Python or write code to author tasks?
Not necessarily. A CNC instructor can author the scenario, the gold solution, and the rubric criteria in plain language. A software engineer or data engineer can implement the programmatic verifier from those criteria. The critical contribution of the domain expert is the gold solution and the failure-mode annotation, not the code that checks it.
What is the difference between an eval task and a training task in this context?
Eval tasks must never appear in training data; contamination in either direction degrades the signal. Training tasks, particularly for supervised fine-tuning or process reward modeling, can include the gold solution and the step-by-step reasoning. Eval tasks should be held out and re-verified for contamination before each evaluation run. Author the two sets separately and track provenance from the start.
What This Means in Practice
CNC and CAM instructors hold knowledge that no web scrape can recover: the judgment behind every feed rate, the process reasoning behind every tool path decision, the failure modes that only appear on a real machine. That knowledge, translated into original, verifiable G-code tasks, is the training signal that moves AI from syntax recall to genuine machining competence. The protocol above is how that translation happens without losing the signal in ambiguity, contamination, or unverifiable rubrics.
The engineers who built the last century will teach the next one.
If you are building evals or RL environments in CNC, CAM, or manufacturing domains, get in touch with Chiron Data Labs.
Have questions or want personalised guidance? Contact us and we'll be happy to help.
Frontier AI models can recite G-code syntax. They can explain what G41 does. What they cannot reliably do is produce a correct, collision-free toolpath for a real part under real constraints, then defend every line of it. That gap is where CNC instructors have irreplaceable value. Authoring original G-code tasks for AI training and evaluation is not a side project. It is a rigorous discipline, and this guide covers exactly how to do it. If you are a CNC or CAM instructor considering authoring original G-code tasks, this is the operational playbook.
Answer Capsule
Authoring original G-code tasks for AI training requires a CNC or CAM practitioner to design a machining scenario with unambiguous setup conditions, write a verifiable correct solution, define a programmatic or expert rubric that checks dimensional accuracy and process validity, and confirm that at least one frontier model fails the task before releasing it. Tasks sourced from textbooks or public forums are contaminated by default.
Why G-Code Tasks Are Unusually Hard to Author Well
G-code tasks fail as training signal for one of three reasons: the problem statement is ambiguous, the correct answer is not verifiable, or the task already exists in a form the model has seen. Each failure mode corrupts the downstream reward signal in a different way.
Ambiguous problem statements allow multiple valid toolpaths, which means a model can produce a wrong answer that a non-expert verifier marks correct. Unverifiable answers force evaluation to rely on human judgment alone, which does not scale and introduces inter-rater variance. Contaminated tasks, drawn from CNC textbooks, forum threads, or manufacturer documentation, inflate model performance scores without reflecting genuine capability.
The machining domain adds a further complication: correctness is multi-dimensional. A toolpath can be geometrically correct, dimensionally correct, and still cause a crash because feed rate, spindle speed, and tool compensation were not considered together. A task that checks only dimensional output misses the process reasoning that separates a competent machinist from a dangerous one.
For a deeper treatment of why original authorship is the contamination control mechanism, see the analysis of the contamination gap between original and scraped tasks.
The Anatomy of a Verifiable G-Code Task
A verifiable G-code task has five components. Every component must be present before the task is usable as an eval or training signal.
Setup specification. Machine type, controller dialect (Fanuc, Haas, Siemens, Mazak), work coordinate system origin, stock dimensions, and tool library. If any of these are underspecified, the task has multiple valid answers by definition.
Part geometry description. A dimensioned description or drawing reference. For text-only tasks, this means explicit coordinates, tolerances, and surface finish requirements. For multimodal tasks, an engineering drawing with GD&T callouts.
Process constraints. Required operations (roughing, finishing, drilling, threading), fixturing assumptions, and any explicit prohibitions (no climb milling, specific tool change position).
Gold solution. The correct G-code program, authored by the expert, with line-by-line annotations explaining each decision. The gold solution is not shown to the model; it anchors the verifier.
Verifier or rubric. A programmatic check, a simulation run, or an expert rubric that maps model output to the gold solution on specific criteria. A task without a verifier is not a task; it is a prompt.
The practical guide to programmatic verifiers for domain tasks covers how to design the verification layer for tasks like these.
Authoring Original G-Code Tasks: A Step-by-Step Protocol
The following protocol is for CNC instructors authoring tasks intended for AI evaluation or post-training. Each step produces a deliverable. Steps are sequential; do not skip forward.
Select a scenario from practice, not from curriculum. Draw the scenario from a real job you have set up or a common student error you have diagnosed. Do not adapt an example from a textbook or a manufacturer's programming guide. The scenario must not be findable verbatim on the public web.
Write the setup specification first. Before describing the part, lock the machine configuration. Controller dialect, tool offsets, and coordinate system origin must be explicit. Ambiguity here propagates into every subsequent step.
Describe the part geometry with tolerances. Use dimensional language, not narrative. "A rectangular pocket 80mm x 40mm x 15mm deep, centered at X50 Y30 from the WCS origin, with a corner radius of 5mm and a wall tolerance of +0.0 / -0.05mm" is a task. "Machine a pocket" is not.
Author the gold solution yourself, without AI assistance. Write the G-code program as you would for a real job. Annotate each block. The annotation is part of the deliverable; it becomes the rubric basis and the process supervision signal.
Design the verifier before testing the model. Decide what the verifier will check: coordinate sequence, modal state at each operation boundary, feed and speed values within acceptable range, absence of known crash conditions. A checklist verifier is sufficient for many tasks; a simulator-based verifier is required for complex multi-operation programs.
Run the task against at least two frontier models. If both models solve it correctly, the task is too easy or already contaminated. A good task produces at least one failure, and the failure should be instructive, meaning it reveals a specific gap in the model's process reasoning, not just a syntax error.
Document the failure mode. Record what the model got wrong and why. This failure-mode annotation is as valuable as the gold solution for post-training teams.
For the broader framework on converting domain knowledge into a verifiable task specification, the expert task authoring playbook covers the full pipeline from domain to deliverable.
Illustrative Example: A Facing and Shoulder Task
Illustrative example. Numbers are plausible but constructed to demonstrate the protocol, not drawn from a real production record.
Setup: Haas VF-2, Fanuc-compatible dialect, G54 work offset, stock is 100mm x 80mm x 30mm aluminum 6061, tool T01 is a 50mm face mill at H01/D01, T02 is a 12mm end mill at H02/D02.
Task: Write a G-code program to face the top surface of the stock to a depth of 0.5mm, then machine a 20mm wide x 10mm deep shoulder along the full 100mm length of the left edge (X-side), leaving a 0.02mm finish allowance on the shoulder wall. Use G41 cutter compensation on the shoulder pass. Tool change at X0 Y0 Z100. Program must include a safe Z retract before any rapid move.
What frontier models typically produce: The facing pass is usually correct. The shoulder pass frequently fails in one of three ways: G41 is invoked without a D offset word, the compensation is applied before the approach move rather than during it, or the finish allowance is ignored entirely and the shoulder is cut to nominal. The safe retract before rapids is omitted in roughly half of outputs tested informally by CNC instructors authoring tasks in this class.
Verifier checks for this task:
G41 present with correct D word before shoulder contour
G40 cancellation after contour, before tool change
Z retract to a value greater than stock height before every G00 XY move
Shoulder depth programmed to 9.98mm (10mm minus 0.02mm allowance), not 10mm
Feed rate on shoulder finishing pass within a defined acceptable range for the material and tool diameter
Each check maps to a rubric criterion. A model output that passes all five is a correct solution. A model output that fails criterion three is a crash risk. The distinction matters for how the training signal is weighted.
Common Failure Modes in G-Code Task Authoring
These are the failure modes that degrade task quality before the model ever sees the prompt.
1. Underspecified setup. Detection: another expert reads the task and asks a clarifying question about the machine or tool configuration. Fix: add every parameter that a setup sheet would include. If it would be on the job traveler, it belongs in the task.
2. Gold solution not machine-verified. Detection: the gold solution has never been run in a simulator or on a machine. Fix: run the gold solution through a G-code simulator (several free options exist) before finalizing the task. A gold solution with a crash is worse than no gold solution.
3. Verifier checks syntax, not process. Detection: the verifier passes any program that uses the correct G-codes in any order. Fix: add modal-state checks and sequence checks. The order of operations in machining is not arbitrary; a verifier that ignores sequence is not checking process reasoning.
4. Task is too easy because it is single-operation. Detection: both frontier models tested produce correct output. Fix: add a second operation that depends on the result of the first, or add a tolerance constraint that requires the model to adjust nominal values. For guidance on pushing tasks to the difficulty threshold where frontier models fail, see the approach described in adversarial task authoring to beat frontier models.
5. Failure mode not documented. Detection: the task record has a gold solution and a verifier but no record of what models got wrong. Fix: run the task, record the failure, annotate it with the specific line or decision where the model diverged from correct process reasoning. This annotation is the highest-value output of the authoring process for post-training teams.
6. Controller dialect mismatch. Detection: the task specifies Fanuc but the gold solution uses Siemens Cycle syntax. Fix: lock the dialect in the setup specification and verify the gold solution uses only commands valid for that dialect. Mixed-dialect tasks produce ambiguous model outputs that cannot be reliably scored.
Where This Approach Breaks Down
Programmatic verifiers cover a large fraction of G-code correctness criteria, but not all of them. Surface finish, chatter risk, and tool wear are not checkable from G-code alone; they require simulation or physical verification. Tasks that require judgment about these factors need expert rubrics, not just programmatic checks, and expert rubrics introduce inter-rater variance that must be managed through calibration.
Difficulty calibration also drifts. A task that two frontier models fail today may be solved reliably by the next model generation. Authoring original G-code tasks is not a one-time contribution; the difficulty of any given task relative to current models must be re-evaluated periodically. The model-in-the-loop authoring workflow describes how to use model failures to guide task revision without contaminating the task set.
Finally, throughput is a real constraint. A CNC instructor authoring tasks at the quality level described here will produce fewer tasks per hour than a generalist labeler producing simpler annotation work. Understanding the realistic output rate matters for planning. The expert task authoring throughput benchmarks provide reference points for scoping expert programs.
Frequently Asked Questions
Can I adapt tasks from a CNC programming textbook?
No. Textbook examples are in the training data of every frontier model. Adapting them, even with modified dimensions, produces tasks with high contamination risk. The gold solution may already be derivable from patterns the model has memorized. Original tasks must be constructed from scenarios not present in publicly available instructional material.
How many frontier models should I test a task against before finalizing it?
Test against at least two models from different families. A task that one model fails but another solves correctly is still a valid task; the difficulty is model-specific, which is expected. A task that both models solve correctly should be revised to increase complexity before release. Difficulty is always measured per model and per date, not as an absolute property of the task.
What makes a G-code verifier reliable enough for training signal?
A reliable verifier checks modal state, operation sequence, and dimensional output, not just the presence of correct G-codes. It should be deterministic: the same model output must always produce the same score. If the verifier requires human judgment to resolve ambiguous cases, document those cases explicitly and treat them as rubric items rather than programmatic checks.
Do I need to know Python or write code to author tasks?
Not necessarily. A CNC instructor can author the scenario, the gold solution, and the rubric criteria in plain language. A software engineer or data engineer can implement the programmatic verifier from those criteria. The critical contribution of the domain expert is the gold solution and the failure-mode annotation, not the code that checks it.
What is the difference between an eval task and a training task in this context?
Eval tasks must never appear in training data; contamination in either direction degrades the signal. Training tasks, particularly for supervised fine-tuning or process reward modeling, can include the gold solution and the step-by-step reasoning. Eval tasks should be held out and re-verified for contamination before each evaluation run. Author the two sets separately and track provenance from the start.
What This Means in Practice
CNC and CAM instructors hold knowledge that no web scrape can recover: the judgment behind every feed rate, the process reasoning behind every tool path decision, the failure modes that only appear on a real machine. That knowledge, translated into original, verifiable G-code tasks, is the training signal that moves AI from syntax recall to genuine machining competence. The protocol above is how that translation happens without losing the signal in ambiguity, contamination, or unverifiable rubrics.
The engineers who built the last century will teach the next one.
If you are building evals or RL environments in CNC, CAM, or manufacturing domains, get in touch with Chiron Data Labs.
Have questions or want personalised guidance? Contact us and we'll be happy to help.