Weight Coding: evolving production recommenders via direct weight edits
Read first: Weight-Space Programming (cross-listed) · AlphaEvolve: A Coding Agent for Scientific and Algorithmic Discovery · Reward hacking (cross-listed)
Intuition. When a production recommender model misses a business objective—too few saves, stale Pins, miscalibrated ranking branches—teams normally run another expensive multi-day fine-tune. Weight Coding replaces target-model gradient fine-tuning with an LLM coding agent (Claude Opus 5.5 with Max thinking) that inspects the model’s code and tensors, writes small Python scripts to directly edit weights, evaluates them in forward-only passes over cached activations, filters out edits that flip sign on other days, and iterates. On Pinterest’s 147M-parameter Image Search retriever, the offline L07 edit (67.7k values modified across r4 plus 2,128 searched scalars) raises Recall@10 by +15.00 points (~24% relative) in a quarter of fine-tuning GPU hours. Separate save-targeted searches (A2/B2/C2) over the same 2,128 editable sites then raise source-attributed online saves/user by +8.4% to +10.7% in week-long production A/B tests on ~10M users.
Source: arXiv, submitted November 22, 2026 (HTML full text), by Junpeng Hou, Jiaxing Qu, Derek Cheng, Jaewon Yang, Abhinav Naikawadi, and Karthik Subbian (Pinterest).
First read: grasp the cached forward-only edit-evaluate loop, the non-additive composition & random-DHEN surprises, and the critical online A/B split between closeup-focused (L07, −0.3% saves) vs. save-focused (A2/B2/C2, +8.4–10.7% saves) arms. Skip individual primitive implementation specs on a first pass.
The weight-coding loop
Section titled “The weight-coding loop”Instead of running backprop through the 147M target model, an autonomous coding agent works inside a structured sandbox:
- Inspect & hypothesize: read the TorchScript/PyTorch module graph, weight norms, and LayerNorm/bias distributions to spot bottlenecks.
- Apply executable edit primitives:
- Targeted algebra:
Rescale,Reset(e.g., resetting LayerNorm gains/offsets),Remove(pruning noisy branches),Compress(low-rank),Interpolate(toward an earlier checkpoint), andSteer(adding along a concept direction like freshness or shoppable products). - Gradient-free local search:
Searchevaluates 16 antithetic Evolution Strategies (ES) pairs (32 perturbed candidates per step), ranks the 32 scores, and updates the ~2,000 selected scalars with Adam (so optimizer state lives only on the tiny search subspace, with zero target-model backpropagation).
- Targeted algebra:
- Cached forward-only engine: intermediate outputs of unchanged upstream encoders and the fixed item index are cached once; each candidate edit invalidates and recomputes only the edited module and its downstream computations.
- Multi-day generalization filter: edits are discovered on a development day, automatically rejected if their effect reverses on a filter day (23% of >1-pt dev edits reverse sign across days!), verified on held-out days and a separate corpus, and then handed to engineers for online A/B approval.
Offline discoveries across three production models
Section titled “Offline discoveries across three production models”All numbers are author-reported on Pinterest production models:
- Image Search two-tower retriever (147M params):
F04(resetting just 128 LayerNorm parameters): +10.10 pp Recall@10.r4(retrieval head edit): +8.83 pp;L01(ES over 2,064 DHEN token-mixing weights): +13.69 pp.- Composition is non-additive: naively stacking
r4 + L01drops gain from14.1 → 10.2 pp; re-searching withr4fixed (L07: 67.7k total parameters changed, 2,128 searched) reaches +15.00 pp (~24% relative) in 4 loops × 8.6 GPUh = 34.4 GPUh (24.6% of a 140 GPUh post-training fine-tune), holding at +9.7 pp on a separate evaluation corpus and transferring to unoptimized full-corpus R@1000. - Random-DHEN shock (
L05): randomly reinitializing the entire 13.6M-parameter DHEN interaction module and searching only 2,448 mixing/norm values still beats production by +9.80 pp (+10.5 held-out)—proving trained representations were mostly held back by miscalibrated branch scales and offsets.
- Cross-architecture transfer fails (agent inspection matters): edits that win on the two-tower model do not transfer blindly. On PinRec (106M generative retriever), a combined bias + checkpoint-interpolation edit adds +2.31 pp unordered R@1 and +2.64 pp ordered R@1; on a 1.37B MMoE Ranker, weakening mixture-of-experts LayerNorms adds +0.53% utility NDCG.
- Single-scalar steering: shifting the retrieval-head bias along a freshness direction moves fresh Pins in top-10 monotonically from 2% () to 70% () (at : +4.5 overall R@10, +14.4 fresh R@10), and product steering composes cleanly on top of
L07(+28.3 → +38.2 product R@10 at +14.1 overall).
Online A/B results (~10M users, 1 week) and caveats
Section titled “Online A/B results (~10M users, 1 week) and caveats”| Online arm group (~10M users, 1 week, source-attributed) | Impressions | Closeups | Saves | Long clicks | Product share |
|---|---|---|---|---|---|
All-engagement / closeup objective (L07) | +0.2% | +6.7% | −0.3% | +97.0% | +147.9% |
All-engagement (r4 / F04) | −2.0% / −1.9% | +0.9% / +1.8% | −3.5% / −3.9% | +68.0% / +37.2% | +91.3% / +34.4% |
Save-oriented objective (A2 / B2 / C2, separate searches on same 2,128 sites) | +4.0% to +5.2% | +4.8% to +7.6% | +8.4% to +10.7% | −14.6% to −24.9% | −32.5% to −39.8% |
Key engineering caveats noted by the authors:
- Proxy alignment is everything: editing the exact same 2,128 sites swings online source-attributed saves from −0.3% (
L07, closeup-dominated offline objective) to +8.4–10.7% (A2/B2/C2, save-oriented objective with capped clicks/products). - Retriever cannibalization: the downstream ranker scores Pins from the edited retriever much higher, taking impression share away from other retrieval channels; source-attributed lifts must be evaluated alongside whole-funnel metrics.
- Freshness across retrains: whether discovered edits stay valid after routine model checkpoint refreshes or distribution shifts remains open future work.
Connection to the rest of the track: Operationalizes Weight-space programming inside an autonomous coding loop like AlphaEvolve, while supplying concrete production evidence for Reward hacking and multi-day validation.
Questions to think through
These questions have no single right answer. Write or say your answer before you open the hints. Mark a question once you could defend your answer in a reading group.
- Derive / compute
On Pinterest's 147M-parameter Image Search two-tower retriever, the L07 edit runs 4 search loops of 8.6 GPU-hours each using 16 antithetic ES pairs per step (ranking 32 perturbed candidates per step with Adam over the 2,128 search variables, while the combined r4 + search edit changes 67.7k parameter values in total), compared against a 140 GPU-hour post-training fine-tune. Compute (a) total GPU-hours for L07 and its percentage of fine-tuning compute, (b) the fraction of the 147M model parameters actually searched vs. modified by L07, and (c) the recall@10 drop caused by naively stacking r4 + L01 (14.1 → 10.2 pp) vs. re-searching with r4 fixed (L07, +15.00 pp).
What a strong answer covers
- (a) 4 × 8.6 = 34.4 GPU-hours; 34.4 / 140 ≈ 24.6% (about a quarter) of a standard post-training fine-tune.
- (b) Searched fraction: 2,128 / 147,000,000 ≈ 0.0014% of model weights; total modified fraction (combining the prior head edit r4 with the searched scalars): 67,700 / 147,000,000 ≈ 0.046%.
- (c) Naive stacking r4 + L01 loses 3.9 pp (14.1 → 10.2 pp), whereas re-searching with r4 in place recovers the loss and adds +4.8 pp above the naive stack to reach +15.00 pp (~24% relative).
- No backpropagation runs through the 147M target model—forward-only cached evaluations score the 32 antithetic perturbations, and Adam maintains optimizer state only over the 2,128 search variables.
- Mechanism
Why can Pinterest's weight-coding agent run hundreds of edit evaluations on a 147M-parameter production retriever without backpropagating through the target model? Trace the cached forward-only engine (including downstream cache invalidation) and the dev / filter / held-out day split.
What a strong answer covers
- No target-model backprop: edits are executable Python primitives (Rescale, Reset, Remove, Compress, Interpolate, Steer, Search via 16-pair antithetic ES ranked across 32 candidates and updated with Adam on the search variables only).
- Cached intermediate activations: the production TorchScript model runs once to cache upstream encoder outputs and fixed item embeddings, so each candidate edit recomputes only the edited module *and its downstream computations*.
- Multi-day filtering prevents day-specific overfitting: the agent iterates on a development day, automatically filters out edits whose effect reverses on a separate filter day (23% of >1-pt dev edits reverse sign on another day!), and engineers inspect held-out days before online A/B.
- What if…
In Table 2 and Table 3, randomly reinitializing the entire 13.6M-parameter DHEN module and searching only 2,448 mixing/norm parameters (L05) still beats production by +9.80 pp (+10.5 held-out), while across architectures two-tower LayerNorm resets fail to transfer to PinRec (106M, where bias edits + checkpoint interpolation add +2.31 unordered / +2.64 ordered R@1) or the 1.37B MMoE Ranker (+0.53% utility NDCG from weakening expert LayerNorms). What do these two findings reveal about trained recommender weights and why agent inspection matters?
What a strong answer covers
- The random-DHEN result (L05) shows that fixed upstream encoders, output head, and item index already carry strong representations, and that a tiny subspace (~2,448 mixing and normalization scalars out of 13.6M params) suffices to route useful cross-feature interactions.
- Single training schedules leave 1D normalization gains, shared offsets, and branch strengths miscalibrated for serving objectives—even a control retrain without weight decay on 1D params loses 3.5 R@10 points while still admitting +16.8 points from mixing-matrix search.
- Cross-architecture non-transfer shows weight coding is not a static heuristic library: PinRec benefits from bias edits and checkpoint interpolation (+2.31 unordered / +2.64 ordered R@1) while the 1.37B MMoE ranker benefits from weakening expert LayerNorms, requiring the coding agent to inspect each graph and probe module sensitivities.
- Critique
Compare the two online A/B test groups in Table 4 (all-engagement/closeup objective vs. save-oriented objective, ~10M users each for ~1 week). Why did the highest-R@10 offline edit L07 (+15.00 pp) slightly *decrease* online saves (−0.3%) while separate save-oriented searches A2/B2/C2 raised source-attributed saves by +8.4% to +10.7%, and what system-level caveat do the authors flag about downstream cannibalization?
What a strong answer covers
- Objective alignment: the initial offline recall evaluator aggregated all engagements (dominated by closeups), so L07 drove +6.7% closeups, +97.0% long clicks, and +147.9% product share—but −0.3% saves (and r4/F04 dropped saves by −3.5% / −3.9%).
- Running separate searches over the same 2,128 editable sites toward save-type recall with capped clicks/long-clicks/products (arms A2, B2, C2) flipped online behavior to +8.4% to +10.7% saves/user (+4.3–5.3% per impression) and +4.8% to +7.6% closeups while cutting product share −32.5% to −39.8%.
- Cannibalization caveat: the downstream ranker scored Pins from the edited retriever much higher, stealing impression share and engagements from *other* retrieval sources—so source-attributed +8.4–10.7% saves is not automatically equal to net site-wide saves without monitoring total funnel impact.
- Design
You own a weekly production recommender launch with a 40 GPU-hour post-training budget and a downstream ranker that aggressively favors whichever retrieval source boosts its score distribution. Design the offline validation gates, objective constraints, and online rollout checks you would require before promoting an agent-discovered weight edit to 100% traffic.
What a strong answer covers
- Offline generalization gates: require dev → filter → held-out date splits (catching the ~23% of >1-pt dev edits that flip sign across days), plus verification on a separate corpus (where L07 retained +9.7 pp) and an unoptimized secondary metric like full-corpus R@1000 to catch proxy hacking.
- Objective & concentration constraints: match offline positives to the business metric (e.g., save-type recall with hard caps on clicks/long-clicks/products, as in A2/B2/C2) and gate on exposure concentration (top-1% item share, which spikes under strong steering).
- Downstream & lifecycle checks: evaluate site-wide net engagement alongside source-attributed engagement in online A/B to detect cannibalization of sibling retrievers, keep human engineer sign-off before launch, and re-run validation after every base checkpoint refresh.