arXiv:2609.04199cs.CLSep 2026

Manuscript Offprint

arXiv:2609.04199

Compile by Training: Turning Natural-Language Specifications into Local Neural Functions

Yuntian Deng, Pengyu Nie, Stuart Shieber

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Many recurring text functions are easy to describe but difficult to implement with rules, while calling a large remote model for every input introduces repeated cost, latency, and dependency on a provider. We present compile by training, which turns a natural-language specification into a reusable neural function. At compile time, teacher models generate task-specific examples that are used to train a small adapter for a compact interpreter. The resulting function runs without the teachers and can be stored, versioned, and composed like ordinary software. On FuzzyBench-Hard, a subset on which the Program-as-Weights fast compiler produced no exact matches, compile by training reaches 83.6% semantic accuracy. This higher accuracy comes with a higher compile-time cost: roughly a minute rather than seconds for the fast compiler. We deploy the compiler in a public interactive service and demonstrate compiled functions in a multi-site website helper, a language-controlled 3D avatar, and a bidirectional English–Claudish translator.

1 Introduction

Consider an email-triage function that maps “Signature needed by EOD” to immediate, but maps a newsletter to wait. The intended behavior is easy to describe and useful across thousands of messages, yet tedious to encode as rules. A general-purpose remote LLM can perform the task, but calling it for every message repeatedly incurs network latency, provider cost, and dependence on an external service. Many recurring text functions fall between these two options: they are too fuzzy for conventional code, but too narrow and frequent to justify a large-model call at every invocation.

We propose compile by training: use large models once to build a smaller, reusable neural function. A developer writes a natural-language specification, teacher models generate examples of the desired behavior, and gradient descent uses those examples to specialize a compact interpreter. Compilation takes roughly a minute, but the resulting function can then process new inputs without calling the teachers. In this view, adaptation becomes a software build step, and large language models act as tool builders rather than run-time dependencies.

Our system builds on Program-as-Weights (PAW) (Zhang et al., 2026), in which a neural program specializes a shared local interpreter. PAW introduced an amortized compiler that predicts such a program in a single forward pass. This makes compilation fast, but spends the same fixed amount of computation on every function. Compile by training retains the same program format and runtime interface, uses the amortized prediction as a starting point, and then invests additional computation in teacher synthesis and specification-specific optimization. The resulting programs can still be versioned, cached, and composed with ordinary software.

This approach raises three practical questions. First, does the additional compile-time investment produce better functions than one-shot weight prediction? Second, can a minute-scale build remain usable in an interactive service? Third, can independently compiled neural functions serve as components in larger applications? We evaluate correctness on FuzzyBench-Hard, a subset of examples for which the PAW fast compiler produced no exact matches. We also measure latency and responsiveness in our deployed compiler and demonstrate composition in a multi-site website helper, a language-controlled 3D avatar, and a bidirectional English–Claudish translator. An online demo is available at https://programasweights.com/playground?compiler=paw-ft-bs48.