LLM-Based FORM Code Generation with Verification-Driven Fine-Tuning
Abstract
FORM is a domain-specific symbolic manipulation language widely used in particle physics for processing the very large algebraic expressions arising from multi-loop Feynman diagram calculations. Despite its central role in precision theoretical physics, no artificial-intelligence tooling exists, to our knowledge, for assisting physicists in writing FORM code. We show that contemporary large language models (LLMs), including frontier models with hundreds of billions of parameters, achieve a zero-percent execution pass rate on our instruction-following and tutorial-style FORM tasks without documentation in a single attempt, establishing FORM as a genuine zero-shot language for LLMs at the time of writing. We then present a verification-driven data generation pipeline that uses the FORM binary itself as an execution oracle to produce and validate a corpus of 4,633 training examples spanning deterministic computations, open-ended programs, tutorial code, and knowledge question-answer pairs. Fine-tuning a compact open-weights model (Qwen3-8B) with quantized low-rank adaptation (QLoRA) yields a specialist that, evaluated on four complementary benchmarks (840 tasks, single attempt each), decisively outperforms frontier models with up to 756B parameters in execution rate and in strict, FORM-verified output matching on the larger benchmarks, and remains statistically indistinguishable from them on the smaller, harder ones. General reasoning and coding capabilities are preserved within 2.6 percentage points.
Create a lesson
Metadata
- Categories
- hep-ph, cs.CE, cs.CL
Related papers
Timelike Pion and Kaon Form Factors and Quark-Hadron Duality
Shared title terminologyhep-phDaniele Binosi, Craig D. Roberts
Holographic QCD Running Coupling Constant and Pion and Kaon Form Factors
Shared title terminologyhep-phHéctor Cancio, Pere Masjuan
Baryon Number Generation from Dilaton-Skyrmion Dynamics: A Proof-of-Principle Study
Shared title terminologyhep-phXin-Ru Wang, Shinya Matsuzaki
Next-to-next-to-leading-order QCD prediction for the doubly virtual pion transition form factor
Shared title terminologyhep-phBo-Xuan Shi
Bridging the generator gap: weight-space repair of neural networks for jet tagging with Fisher steering
Shared title terminologyhep-phAritra Bal, Markus Klute, Michael Spannowsky
Automatic amplitude generation with DiaGen
Shared title terminologyhep-phMichał Czakon, Marco Niggetiedt, Johann Usovitsch