WeightCode:通过权重空间编程为神经网络安装新能力

媒体报道 Hugging Face Papers 原文语言:中文

研究者提出 WeightCode 框架,利用冻结的大语言模型生成可执行权重程序,在不再使用 LLM 的情况下为已训练网络添加新功能并保持原有性能。

全文

WeightCode: Installing New Capabilities into Neural Networks

via Weight-Space Programming

Bo Li Affiliation: University of Macau Affiliation: National University of Singapore Taoyong Cui Affiliation: The Chinese University of Hong Kong Bob Zhang Affiliation: University of Macau Mengran Li Affiliation: Sun Yat-sen University Chengyang Zhang Affiliation: Sichuan University Yang Zhang Affiliation: National University of Singapore Pheng Ann Heng Affiliation: The Chinese University of Hong Kong Wanli Ouyang Affiliation: The Chinese University of Hong Kong Zhenfei Yin Affiliation: University of Oxford Yingcheng Wu Affiliation: Stanford University Ling Yang Affiliation: Peking University*Equal contribution. †Project lead. ‡Corresponding authors.

Abstract

Neural networks encode learned capabilities in their weights, yet extending those capabilities with explicit task knowledge remains a fundamental challenge. Here we show that Weight-Space Programming (WSP), in which executable programs read, construct or modify a network’s weights directly, can install new capabilities within trained neural networks. WeightCode, a WSP framework, uses a frozen language model to write executable weight programs that install new computations into trained neural networks using task knowledge and their existing weights, without gradient-based training. Once installed, the new capabilities run independently of the language model. Given a grammar or eight demonstrations, weight programs enable previously unseen command compositions (0% to 99.8% exact match) and a new pickup action (0% to 98.4% success), while preserving the original command and navigation capabilities. On ImageNet, four weight programs achieve net gains of 8.84–17.62 points while preserving clean accuracy, outperforming the best of eight fine-tuning methods under matched examples, checks, and retention constraints. In a Vision Transformer, causal interventions show that installed noise-correction gates drive robustness gains, while their selective activation preserves clean accuracy. Rerun on five independently trained Vision Transformers without further language model calls, ten weight programs retain 83–110% of their source-network gains on average, whereas copying their fixed weight edits yields negligible gains. Six programs written for an already edited network add 5.23–14.50 points of contrast robustness while retaining the previously installed noise gain. Together, these results establish WSP as a new route to acquiring and accumulating capabilities in trained neural networks through reusable weight programs.

Code: https://github.com/Gen-Verse/WeightCode

1 Introduction

Learning a capability during training and installing one into an already trained neural network are distinct problems. The latter requires translating task knowledge into new computations while preserving previously acquired capabilities. Unlike software, whose functionality can be extended through executable instructions, neural networks encode learned computations in distributed weights. Can executable programs directly construct new capabilities within these weights, and can subsequent programs build upon those already installed?

Following [43, 20], we call this paradigm Weight-Space Programming (WSP): executable programs read, construct or modify the weights of a neural network directly. Its artifact, the executable weight program, retains how a network-specific update is constructed, rather than only the numerical weight changes it produces. Fine-tuning [16, 22], model editing [29, 30], and test-time adaptation [39, 44] provide established ways to update trained networks. Meanwhile, large language models (LLMs) can generate and refine executable programs through evaluation feedback [36, 34] and have recently been shown to inspect and modify neural weights directly [43]. Four fundamental questions define the scope of WSP:

•

Installation. Can a weight program install a new capability into a trained network while preserving previously acquired capabilities?

•

Mechanism. What computation does a weight program install, and how does it produce the new capability?

•

Reuse. Can the same weight program be rerun without the LLM to construct effective edits in independently trained networks?

•

Succession. Can a new weight program extend an already edited network while preserving capabilities installed by earlier programs?

Here we introduce WeightCode, a WSP framework in which a frozen LLM writes executable weight programs that install, reuse and accumulate capabilities in trained neural networks (a). A weight program pp reads the network’s weights WW and task knowledge II, such as a rule, demonstrations, or labeled examples, and constructs updated weights W′=p⁡(W,I)W^{\prime}=p(W,I). Evaluation feedback selects programs that improve the new capability while preserving existing behavior. The updated network executes the installed computation within its original architecture, without the LLM at inference. The retained program can be rerun on compatible networks to construct network-specific edits. New programs can then extend networks already modified by earlier programs.

Across language, navigation, and visual recognition, weight programs transform rules, demonstrations, and labeled examples into new capabilities (b, Fig. 2). On SCAN, a program modifies 257 weights to raise exact match on previously unseen command compositions from 0.0% to 99.8%; on BabyAI, eight demonstrations enable a new pickup action with 98.4% success. On ImageNet, four weight programs achieve 8.84–17.62 points of net gain under corruption while preserving clean accuracy, outperforming eight fine-tuning methods under matched examples, checks, and retention constraints. Causal interventions reveal how installed noise-correction gates produce robustness gains while their selective activation preserves clean accuracy (Fig. 3). Rerun on five independently trained Vision Transformers, ten weight programs retain 83–110% of their source-network gains on average, whereas copying fixed weight edits yields negligible gains (c, Fig. 4). Six second-round programs written for an already edited network add contrast robustness while retaining the previously installed noise robustness (d, Fig. 5). Together, these findings establish WSP as a new paradigm for extending trained neural networks: capabilities can be programmed into existing weights, reconstructed across independently trained networks, and progressively expanded through successive weight programs.

2 Related work

Existing approaches to modifying trained networks differ in how they construct, represent and reuse changes to model parameters.

Learning and retaining capabilities.

Fine-tuning adds a capability by optimizing parameters on labeled data, in full or through parameter-efficient modules [15, 16], and regularized transfer keeps the new parameters close to the old ones [21]. Sequential training overwrites earlier capabilities [28, 8], and continual learning limits this forgetting by regularizing parameters [18] or outputs [22], or by replaying stored examples [4]. Test-time adaptation adjusts a network to a new input condition from unlabeled inputs, by re-estimating normalization statistics [39], minimizing prediction entropy [44, 33] or training on a self-supervised task [42].

Targeted and lifelong model editing.

Model editing changes a trained network’s behavior on target inputs while preserving it elsewhere: by gradient steps on a network trained to be editable [41], by learned editor networks [31], or by closed-form rewrites of layers viewed as associative memories [3, 38, 29, 30]. Lifelong editing applies edits in sequence, for example by storing each one in a discrete key-value codebook attached to a layer [11].

Composing and transferring weight changes.

Task arithmetic adds and subtracts the weight differences of fine-tuned models [17], and model merging resolves the interference between such differences when it combines them [47]. Both act on models that share a pretrained starting point, and merging independently trained networks first aligns their units by permutation [1]. These methods operate on learned parameter differences, whose transfer and combination depend on the relationship between model parameterizations.

Program discovery and weight-space methods.

Language models have been used to discover executable algorithms, reward functions, policies, skills and training objectives [36, 34, 27, 23, 45, 26], and symbolic search and meta-learning discover optimizers [5, 2]. Separately, work on hypernetworks, weight-space learning and program-to-network compilation has established several ways to construct or analyze neural computation through weights [10, 32, 49, 40, 46, 24, 9].

Weight-Space Programming.

In concurrent work, Takehi et al. [43] show that a frontier LLM can read the weights of small networks, write networks from zero weights and edit trained networks, and Li et al. [20] have an LLM write an editor that refits the output weights or coefficients of trained predictors from measured feedback. These studies show that language models can carry out WSP, inspecting and modifying neural weights directly. WeightCode shows that the weight programs that construct such updates, retained after the update, can be rerun on independently trained networks and extended by subsequent programs, so that the construction procedure itself becomes a reusable object.

3 WeightCode

WeightCode realizes WSP by separating the construction of an update from its execution: a frozen LLM writes an executable weight program, and the program computes network-specific weight changes (a).

3.1 Installing a capability with a program

Weight programs.

A weight program pp is code that takes a trained network’s weights WW and task knowledge II, what is known about a new capability, and returns new weights:

W′=p⁡(W,I),Δ​W=p⁡(W,I)−W.W^{\prime}=p(W,I),\qquad\Delta W=p(W,I)-W. (1)

Δ​W\Delta W is the weight edit of one run. It depends on the network the program reads as well as on the program, so the same program run on another network computes another edit. A program may read every weight, run the network’s forward pass on inputs and read II. The updated network keeps its architecture and forward code, with only its weights changed, and runs on its own at inference. The experiments impose additional implementation constraints, including sandboxed execution and a maximum edit size of 20% of the network’s weights (Sec. A.1).

What a program writes.

In WeightCode, the form of the update is chosen for each capability and each network. The LLM proposes candidate computations and weight modifications from the network’s weights, its activations and the task knowledge, and evaluation feedback determines which candidate is kept. The programs reported here connect the new capability to computation the network already performs (Tab. 9). The Gaussian-noise program for the ViT-Lite, for example, measures how noise shifts the patch tokens, finds MLP units that are nearly idle on clean images, and rewrites two of them in each of three blocks as gates that open when a token moves along the noise direction and then subtract the measured shift (Fig. 3a). Other programs reuse the network’s own representations, such as the embeddings of known primitives on SCAN or of a known instruction in the BabyAI policy.

Writing and checking.

The LLM writes the program in one session, in a Python kernel that holds WW, the forward pass and II. Program construction alternates between inspecting the network, writing candidates and evaluating them. A check runs a candidate on the network and returns two counts on a check split that II does not contain: SnewS_{\text{new}}, the inputs of the new condition that the candidate fixes minus those it breaks, and SoldS_{\text{old}}, the same count on old inputs. A session has 8 checks.

Keeping existing behavior.

Preservation is evaluated on task-specific reference conditions: clean-image accuracy for the image classifiers, the previously supported commands or mission for the sequence and navigation tasks, and the previously installed conditions for successive updates. Keeping these is part of how a program is chosen. The kept program is the checked candidate with the highest Snew+SoldS_{\text{new}}+S_{\text{old}} among those with Sold≥−20S_{\text{old}}\geq-20, a loss of at most 0.5% of 4,000 clean check images (the retention rule). On SCAN the bound is 5 of 1,000 old commands and on BabyAI 3 of 500 old episodes. If no candidate qualifies, the network is left unchanged. The bound is applied on the check split, and the reference conditions are measured on held-out inputs (Sec. 3.3).

Feedback without gradients.

Weight programs construct updates through direct computations on weights, activations and forward passes, namely weight and activation statistics, SVD and PCA, label-free closed-form fits and single-unit ablations, rather than by optimizing an objective on the network’s outputs. Labeled feedback evaluates and selects candidate programs rather than fitting their values: a single-round session scores at most 8 candidate edits against the labeled examples and receives 8 checks, as each fine-tuning method tries 8 configurations and receives the same checks. Label-scored work that changes no weight, and selection inside a program’s own run, are counted separately from this cap (Sec. A.1). An automatic audit and a reading of the kept programs check these rules; three exploratory sessions that use finite differences are reported separately (Sec. A.11), and Sec. A.1 lists what the protocol admits.

3.2 Rerunning and extending programs

Programs as reusable construction procedures.

An executable weight program retains the procedure that constructed an update: how the network is measured, how units or directions are selected and what is written into them. Run on another compatible network, the same program remeasures that network and constructs a new edit in its weight coordinates. This matters for independently trained networks, which may implement related functions in different coordinates [1], so that a numerical edit computed on one network need not apply to another.

Copying, rerunning and successive updates.

Three operations act on a program p1p_{1} kept for a network W0W_{0} and task knowledge I1I_{1}, which produces W1=p1​(W0,I1)W_{1}=p_{1}(W_{0},I_{1}). Copying adds the edit W1−W0W_{1}-W_{0} unchanged to another network. Rerunning executes the code of p1p_{1} unchanged and without another LLM session, while the program inspects the target network and uses that network’s own task examples, so each rerun computes an edit from that network’s weights and data. A successive update asks the LLM for a new program p2p_{2} for the edited network W1W_{1}, which produces W2=p2​(W1,I2)W_{2}=p_{2}(W_{1},I_{2}). This new program is constructed with the edited network, the code of p1p_{1}, labeled examples of the new condition and checks that also report every earlier condition, under the retention rule for each, so that the update can account for the computations installed earlier. We rerun programs on independently trained networks of the architecture they were written for, and write second programs for edited networks.

3.3 Experimental protocol

Networks.

Programs are written by Claude Opus 5.5 at maximum reasoning effort. The image networks are a Vision Transformer (ViT) [7], ViT-Lite-7/4 [12] (3.7M weights, 89.35% clean accuracy), and a ResNet-20 [13] (0.27M weights, 91.28%), both trained on 40,000 CIFAR-10 training images, and torchvision’s ImageNet [37] ResNet-18 in two forms: unchanged on its 1,000 classes (11.7M weights, 69.70% on our ImageNet test images) and fine-tuned to CIFAR-10 (11.2M weights, 95.78%). The other networks are a BabyAI policy trained by imitation to go to a named object and a Transformer per SCAN split [19, 25]. Five further networks per CIFAR-10 architecture, trained from other seeds, serve reuse.

Conditions.

Corruptions are the CIFAR-10-C set at severity 5 [14] and, on ImageNet, the ImageNet-C functions at the highest severity that costs at least 15 points and keeps at least 17% of the network’s accuracy above chance: 3 for Gaussian noise and 4 for contrast reduction. A condition is run on a network when it costs the network at least 15 points of accuracy, which on the ViT admits Gaussian noise and contrast reduction. Table 1 summarizes what each task gives the LLM and the references, and Sec. A.1 gives training, data and sandbox details.

Task knowledge.

II comes at several levels. Labeled examples: 64 labeled images of the new condition (16 that the network misclassifies and 48 drawn at random, with the network’s predictions) and 64 labeled clean images. For the BabyAI policy, 8 demonstrations of the new mission (each step’s observation, instruction and expert action) and 64 old steps. Condition labels withheld: the LLM receives the same condition images and the network’s predictions but not their labels, and no statement of how they were chosen. The image pool and the selection are unchanged, including the use of labels to pick the 16 misclassified images, and the clean images and the checks keep their labels. A rule: SCAN’s published interpretation grammar with 64 old commands and, on the add-primitive split, the training row of the new primitive. For the ViT, the formula that generates the corruption and 64 labeled clean images, with no image of the condition. A capability’s name: one sentence asking for robustness to additive Gaussian pixel noise, with no image, label or prediction, given with the 8 checks or with none, in which case the one program the LLM declares is scored once after the session. This is the only level at which the LLM is told the condition.

References and criterion.

Every fine-tuning comparison fits the same labels by gradient. It has eight methods: full, last layer, LayerNorm only (BatchNorm on the ResNet-18s), LoRA [16] with rank 4 and 16, full without the clean images, full with LwF [22] and full with L2-SP [21]. Comparisons match the task examples, the number of external checks and the retention rule: each method sees the same labeled images (the method without clean images only the 64 of the condition), tries 8 configurations, receives the same 8 checks and is kept by the same rule. The methods differ in how they construct updates, including the pretrained prior of the LLM that writes each program. We also report each method’s best configuration on the check split without the clean-loss bound. Eleven fixed references per image network, label fits and label-free rules including Tent [44], BN adaptation [39] on the ResNets and SAR [33] on the ViT, are kept by the same rule. Before the sessions on the ViT and the ResNet-18s we fixed a performance criterion for the comparative evaluation, the success criterion: a gain of at least 10 points (on ImageNet, 15% of the accuracy the condition costs: 7.0 and 8.5 points), a clean change of at least −-1.0 and a net gain at least one point above the strongest reference that obeys the program limits (for most conditions, gradient training of a fixed 19% of each tensor’s entries) given the labeled examples. Sessions given less information on the ViT are read against the same bar.

Splits.

The held-out images form three disjoint splits per condition: the condition images of II are drawn from an evidence split (2,000 images), the checks use a check split (4,000) and analyses are read on a selection split (4,000). The clean images of II are one fixed draw from the network’s training images. On ImageNet the 50,000 validation images are divided by image: 12,000 form these three splits and the pool of clean images for II, and the other 38,000 are the test set. The selection split plays no part in any session, check, retention rule or fine-tuning configuration choice. The tables report the held-out test sets: the official CIFAR-10 and CIFAR-10-C test files, the 38,000 ImageNet test images, the third of SCAN’s test commands kept for the final evaluation, and held-out BabyAI episodes. Each kept network was read on them once, after every selection was final.

Metrics and reporting.

Gain is the accuracy change on the condition, clean change the accuracy change on clean images, and net gain their sum. The mechanism analyses (Sec. 4.2) and the copied edits (Sec. 4.3) are read on the selection split, and other numbers that exist only on the selection split are marked where they appear. Each program is one LLM session on one trained network. On the ViT we ran ten sessions, three per condition on the seed-100 network and one per condition on networks trained from seeds 101 and 102, and report all of them (Tab. 7). On the ImageNet ResNet-18 we ran two sessions per condition and report both (Tab. 8). Table 3 shows the first session on each network.

4 Results

4.1 Weight programs turn task knowledge into new capabilities and keep existing behavior

A rule becomes a new primitive inside existing computation. SCAN’s add-primitive split [19] trains a Transformer on every command except those that compose the primitive jump, which it sees only alone, and the network executes none of these compositions (Fig. 2a, Tab. 2). Given SCAN’s interpretation grammar, 64 old commands and the jump row, the program raises exact match on them from 0.0% to 99.8% by changing 257 weights, and the old commands do not change. It moves the embedding of jump to the centroid of those of walk, look and run and adds an output row for its action, so the composition the network already computes now carries the new primitive. A rule-to-data reference, trained on commands generated from the grammar, reaches 99.6% with 152,718 changed weights, about 594 times as many, and fine-tuning on the given rows keeps at most +1.21 points of net gain (selection split). A compact rule can therefore be installed by reusing the Transformer’s existing compositional computation, with 257 modified weights.

The same principle extends to a different compositional setting. On the around-right split [25], where around was trained only with left, the program writes the rule directly into 25,056 weights, as rank-one edits of attention values along the network’s own right-minus-left direction, and raises exact match on commands with around right from 17.6% to 89.6% at −-0.3 points on the old commands, where fine-tuning on the given rows keeps at most +2.61 points of net gain (selection split; the rule-to-data reference is in Fig. 2a and Tab. 2).

Eight demonstrations become a new action. A BabyAI policy [6] trained by imitation to go to a named object never uses the pickup action. Given 8 demonstrations of the mission pick up and 64 old steps, the program raises pickup success from 0.0% to 98.4%, and the old mission moves by +0.4 points. The installed behavior generalizes beyond the demonstrations: success remains 98.9% on episodes whose object color and type never appear in the demonstrations (selection split). Behavior cloning on the same demonstrations reaches at most 1.1% while keeping the old mission (Fig. 2a). The program thus adds pickup to the navigation the policy already performs while retaining its original mission (Sec. 4.2).

With the same examples, programs reach larger gains than gradient training on ImageNet. On torchvision’s ResNet-18 unchanged on its 1,000 ImageNet classes, every method receives the same 64 labeled images of a corruption and 64 labeled clean images, the same 8 checks and the same retention rule (Fig. 2b, Tab. 3). The two programs written for Gaussian noise reach net gains of +10.47 and +17.62 points and the two written for contrast reduction +8.84 and +14.26, against +8.67 and +3.38 for the best of eight fine-tuning methods and +8.84 and +6.00 for the best fixed reference (Tab. 8). The four programs also keep clean accuracy within 0.89 points of the original network on ImageNetV2 [35], a test set collected separately following ImageNet’s procedure.

The result holds across architectures on CIFAR-10: the first programs reach net gains of +32.79 and +16.51 on the ViT-Lite, against +22.78 and +7.89 for the best fine-tuning, and +35.23 and +21.28 on the ResNet-18 fine-tuned to CIFAR-10, 3.7 and 2.1 times the best fine-tuning. The resulting edits vary with the network and the computation, from 3,846 modified weights for the ViT-Lite noise gate to 2,152,928 for the ImageNet noise correction (0.10% to 18% of each network).

Independently written programs also exceed matched fine-tuning: on three ViT-Lites, eight of ten programs written in separate sessions do so on their own network, with net gains from +6.61 to +32.79 (Fig. 2c, Tab. 7).

Figure 2: Weight programs install new capabilities and keep existing behavior. (a) SCAN (a new verb in known compositions; a new combination of known words) and BabyAI before and after the program, with the weights each changes; gray, a rule-to-data reference trained on commands generated from the grammar (SCAN) and the best behavior cloning kept by the retention rule (BabyAI). (b) ImageNet ResNet-18: top-1 under corruption (95% intervals), net gain, and the change in clean top-1 on held-out Ima
Figure 2: Weight programs install new capabilities and keep existing behavior. (a) SCAN (a new verb in known compositions; a new combination of known words) and BabyAI before and after the program, with the weights each changes; gray, a rule-to-data reference trained on commands generated from the grammar (SCAN) and the best behavior cloning kept by the retention rule (BabyAI). (b) ImageNet ResNet-18: top-1 under corruption (95% intervals), net gain, and the change in clean top-1 on held-out Ima

Figure 2: Weight programs install new capabilities and keep existing behavior. (a) SCAN (a new verb in known compositions; a new combination of known words) and BabyAI before and after the program, with the weights each changes; gray, a rule-to-data reference trained on commands generated from the grammar (SCAN) and the best behavior cloning kept by the retention rule (BabyAI). (b) ImageNet ResNet-18: top-1 under corruption (95% intervals), net gain, and the change in clean top-1 on held-out ImageNet and on ImageNetV2; dashed red, the clean bound of the success criterion. (c) Net gain of every CIFAR-10 program, 10 of 12 above the best kept fine-tuning on its network; light bars, programs that do not meet the prespecified comparative criterion; diamonds, fine-tuning without the retention rule. Held-out test sets.

The program’s lead is largest where existing behavior must be kept and labeled data are scarce. On the ViT-Lite under Gaussian noise, full fine-tuning first matches the program’s net gain within the retention rule at 4,096 labeled corrupted images and as many clean ones, compared with 64 of each for the program (selection split, Fig. 6). At clean-loss bounds of 0.5 and 1 point on the check split, the program has the highest net gain of every method on all four CIFAR-10 instances, by +2.7 to +25.5 points; Sec. A.2 and Fig. 7 chart the full trade-off between gain and retention.

Programs can be written from the condition images without their labels. On the ViT-Lite under Gaussian noise, with the labels of the 64 noisy images withheld from the LLM and the network’s own predictions in their place, the program reaches a net gain of +34.43 at a clean change of −-0.04, compared with +32.79 for the session given all labels (Tab. 3). The images are selected as in the labeled setting (16 that the network misclassifies), and the clean images and the 8 checks are labeled. Given only the capability’s name, programs reach +9.43 and +15.10 on the selection split (Fig. 8). Direct access to the condition labels is thus not required in this setting: the network’s predictions, statistics of the images and labeled check feedback suffice to construct an effective correction.

Figure 3: Weight programs install identifiable, causally testable computations. (a) The noise program constructs a gate within existing MLP units that removes the noise shift (schematic). (b) The gate opens on noisy, not clean, inputs, and its activation tracks the corruptions where the program helps. (c) Causal interventions and alternative constructions identify the gated computation, more than the choice of units, as the source of this program’s gain (Tab. 10). (d) The contrast program combines an input-wide gain adjustment with a selective correction; the two components have distinct target-condition and off-target effects (Fig. 9). Selection split.

4.2 Weight programs install computations that can be tested part by part

Weight programs produce identifiable internal computations whose causal contributions to the new behavior can be tested directly (Fig. 3; Tab. 9 describes every program and marks those tested by intervention; selection split).

The noise program writes a conditional correction into existing units. The installed correction detects a shift in the network’s internal representations and subtracts a measured offset selectively from the affected tokens. By examining the supplied images and the network’s activations, the LLM finds that the corruption mainly shifts the patch tokens in the early residual stream, and builds the correction on that shift; untold, it also infers additive white Gaussian pixel noise of standard deviation about 25/255 (the generating value is 0.10). The program measures this shift on synthetic noisy copies of the clean images, frees two little-used MLP units in block 2 by folding their mean output into the bias, and rewrites them as a ramp gate,

g⁡(z)=GELU⁡(k⁡(d⊤​z−t))−GELU⁡(k⁡(d⊤​z−t)−K),g(z)=\mathrm{GELU}\big(k(d^{\top}z-t)\big)-\mathrm{GELU}\big(k(d^{\top}z-t)-K\big), (2)

which subtracts the measured offset only from tokens whose projection d⊤​zd^{\top}z on a whitened noise direction lies above the clean range (Fig. 3a). Two gates of the same form act on the class token in blocks 4 and 6.

The installed gates carry the gain. Removing the block-2 gate lowers the net gain from +31.75 to +10.05, and removing all three gates returns the network to its original accuracy (Fig. 3c).

Selective activation keeps clean accuracy. The block-2 gate opens on 99.5% of noisy and 0.5% of clean patch tokens and cuts the mean noisy-minus-clean offset from 5.29 to 0.50, while the program moves clean patch tokens by 0.05 on average against 5.02 on noisy ones (Fig. 3b). Holding the gates open lowers the net gain to +19.43 and clean accuracy by 5.03 points, 15.5 on the worst class. Gate activation also tracks where the correction helps: on 25 corrupted versions of the test set, the program helps on the whole noise family and on frost, where the gate opens on 27% to 100% of patch tokens, and changes no other set by more than 0.27 points on the test sets (Fig. 9).

The gated computation matters more to the gain than the identity of the units that carry it (Fig. 3c). The gated structure keeps the gain when its parts are replaced: a gate built from the plain mean difference of the noisy and clean examples keeps +31.13, and the same gate in two units drawn at random from the block gives +31.86 (Tab. 10). Gradient training of exactly the entries the noise and contrast programs change, from their original values with the fine-tuning grid and the same rule, reaches +3.60 and +0.72, and from the programs’ values it keeps +33.35 and +18.00: the program’s specific weight configuration, rather than the choice of edited entries alone, accounts for the gain. Network-specific information shapes the program: with access to the trained weights and outputs, the programs reach +31.75 and +17.98, against +10.78 and +11.18 when the same LLM receives the parameter names and shapes, the forward code, the examples and the checks, but no weight value or network output (one session per condition).

Different capabilities receive different computations. Unlike the noise program, the contrast program combines an input-wide adjustment of the patch-embedding filters with a condition-selective correction (Fig. 3d). It raises the zero-mean part of the filters by a factor of 1.45, a global gain on the first layer, and adds a gated rank-6 correction in eight freed units of block 2, whose gate, on its own, opens on 99.7% of low-contrast and 0.3% of clean patch tokens. On the original network the gain alone adds +10.95 points and the correction alone +9.63, at clean changes of 0.00 and +0.30, and together they reach +17.93: each part adds 7.0 and 8.3 points on top of the other. The noise computation contains no such first-layer gain; run as a template on contrast, the noise gate reaches +5.40 (Tab. 10). The two components also differ in reach: on the ViT-Lite and the CIFAR-10 ResNet-18 alike, the input-wide gain accounts for the changes on other corruptions, the gains under blur and fog and the losses under noise, whereas the gated correction acts selectively on contrast reduction (Fig. 9). Across architectures and target conditions, programs construct different forms of computation, including gates in little-used units, corrections of activation shifts, input-layer rescaling and convolutional filtering (Tab. 9). Across the ten ViT-Lite programs, those that meet the criterion repurpose little-used capacity into a condition-specific computation: gated corrections in freed MLP units, or a nearly unused attention head rewritten to subtract the image’s mean color.

The BabyAI program writes a stated rule into the policy, a complementary form of mechanistic evidence. It copies the embeddings of go and to into pick and up, builds from dead units an exact detector for a faced cell of the named color and type that raises the pickup action, and adds a detector that stops the policy from pressing forward into a blocking object. An explicit rule reconstructed from these three parts predicts the edited policy’s success or failure on all 2,000 evaluated episodes, 1,000 with the new mission and 1,000 with the old. The weights carry the stated rule, and the policy runs it with no outside code at the base network’s inference cost.

Figure 4: Executable weight programs reconstruct effective edits across independently trained networks. (a) Rerun on an independently trained ViT-Lite, the noise program places its gates anew and keeps its gain, while its fixed weight edit, copied unchanged, produces no gain on this network (recorded placements, schematic). (b) Ten programs, rerun or copied to five other networks (selection split). (c) Share of each program’s own gain kept on the other networks (held-out test sets). For networks that share an initialization, see Fig. 10.

4.3 Executable programs recompute effective edits across independently trained networks

When the same program is executed on five independently trained ViT-Lites, using each network’s own 64 labeled examples, it constructs a network-specific edit without another LLM session. Rerun this way, the Gaussian-noise program gains +27.55 to +30.54 points (mean +28.57) at clean changes of −-0.19 to +0.07, and the contrast program +16.04. All ten programs carry their gains over: on the five networks each was not written for, each keeps 83% to 110% of its own gain on the held-out test sets, and clean accuracy stays within 1 point on 48 of the 50 transfers (Fig. 4c). Reused the same way, the best fine-tuning recipe reaches +20.79 and +8.09 (Tab. 11).

Across independently trained ViT-Lites, rerunning a program transfers its effect more reliably than copying the source network’s numerical edit (Fig. 4a,b). Added unchanged to the other ViT-Lites, the edits of the ten programs gain −-1.42 to +0.01 points on average, 7.6 to 28.2 below rerunning the programs (selection split). A rerun recomputes where and how to write: on one network the noise program gates blocks 2, 3 and 6 instead of 2, 4 and 6, with thresholds measured on that network (Fig. 4a, Sec. A.8). Matching units does not recover this: aligned unit by unit to the original by activation matching on 2,048 clean images, the copied edits of the first program of each condition gain −-0.01 and +4.17, whereas each rerun reconstructs its edit from the target network’s own computation. Copied edits transfer where networks share coordinates: when ResNet-18s share a pretrained initialization, they keep 96% and 87% of the rerun gain (selection split, Fig. 10), while a program transfers across independently trained networks as well.

Figure 5: Programs written for an edited network add a capability and keep the earlier one. (a) Gains over the original network in both orders: six alternative second programs per order, each written for W1W_{1}; red, the W0W_{0} program rerun on W1W_{1}; gray, fine-tuning through the same two rounds (selection split). (b) Why a program written for the original network disrupts the installed noise gate when rerun on W1W_{1}: the block-2 units each program writes. (c) Held-out test sets for the noise-first order: all six programs add contrast robustness, four by at least the 10-point threshold fixed in advance.

4.4 Successive programs extend edited networks and keep earlier gains

Executable weight programs install capabilities in succession. On the ViT-Lite, after the Gaussian-noise program, six contrast programs written in separate sessions for the edited network add +5.23 to +14.50 points of contrast robustness on the held-out test sets, while the installed noise robustness moves by −-0.17 to +0.23 and clean accuracy stays within 1.47 points of the original network (Fig. 5a,c, Tab. 13); four exceed the 10-point threshold for the additional capability fixed before the sessions. In the reverse order, all six noise programs written for the contrast-programmed network add +30.9 to +37.7 points of noise robustness while contrast moves by −-0.28 to +0.03 (selection split, Fig. 5a).

The earlier capability is kept in the computation itself. None of the six contrast programs writes the two units of the noise gate or blocks 4 and 6 (Fig. 5b): constructed from the edited network, the earlier program and checks on the earlier condition, they write around the installed gate.

A counterfactual rerun shows why the current state of the network matters. A contrast program written for the original network, applied after the noise program, frees the two block-2 units that hold the noise gate, because they are idle on clean images, and breaks 1,224 of 4,000 noisy check images; freeing those units accounts for 81% of its noise loss (selection split, Fig. 5a,b).

5 Discussion

The central finding is that a trained neural network can be extended by an executable construction procedure whose output becomes part of the network’s own computation. The updated network performs the new capability on its own, while the program retains the procedure that built it from existing computation. Capability installation therefore has an explicit implementation that can be tested by intervention and recomputed by rerunning the program. This separates the reusable specification of a capability from the network-specific weight values that implement it.

These results reveal a mechanism of capability acquisition in which task knowledge is translated into new computation by recruiting and reorganizing operations already represented within a trained network. Rules, examples and checks specify the desired behavior, while the network’s weights and activations inform how it can be implemented: programs reconnect existing representations, recruit learned operations or add corrections for particular inputs. In the noise-gating programs, preservation is built into the computation itself, in addition to the retention rule that selects them: the correction activates mainly on affected inputs and leaves clean representations nearly unchanged, and causal interventions separate the two roles, with the installed computation producing the robustness gain and its selective activation protecting clean accuracy. The source of a new capability and the reason the measured existing behavior is kept can thus be examined directly and used to inform the design of later programs.

Reusability changes what can be retained after an update: not only the modified network, but also an executable description of how the modification was constructed. Rerun on another network, that description recomputes an edit for the network’s own weights; written for an edited network, a new program can account for what earlier programs installed. As capabilities accumulate, previously installed computations become part of the foundation that later updates can use and preserve, and these properties motivate reusable program libraries and longer sequences of capability updates, each retained together with its checks.

Natural next steps are programs that construct representations a network does not yet have (Sec. A.10) and p

正文以来源语言显示。

参考来源

← 返回每日AI报告