Web-scale recommender models evolve primarily through retraining or fine-tuning. We propose weight coding, a methodology for model evolution through direct, executable weight edits. A large language model (LLM) agent inspects model structure and parameters, formulates hypotheses, and implements edits using evaluation feedback. The loop progresses from localized changes to targeted searches and composition, allowing edited components to adapt to one another. A cached engine enables rapid forward evaluation without backpropagation. On Pinterest's 147M-parameter Image Search two-tower retriever, weight coding improves held-out recall@10 of production model by up to 15.0 percentage points (+24% relative) with few edits in about 1/4 GPU hours of a full post-training finetune, while a common launch only improves around 1%. After reinitializing the entire 13.6M-parameter interaction module randomly while retaining the surrounding trained model, searching 2,448 mixing and normalization parameters yields 9.8 points above production. Offline gains span the full funnel including dense retrieval, generative retrieval and ranking, with up to 1.37B learnable parameters and different edits for each architecture. Steering edits provide explicit control of model performance over segments like freshness and product. Weight coding requires no serving change and online A/B tests increase saves per user from the edited retrieval source by 8.4% to 10.7%, aligned with the target business objectives. Our results establish weight coding as a practical and useful tool for model development and and behavioral control in a real web-scale production system, with potential to extend to both pre-training and post-training stages across the funnel.
Figures & tables
Figure 1. Weight coding by LLM agents. (a) Training and direct editing of trained or randomized weights through an agent-driven loop. (b) Relative metric changes after successive weight-coding iterations on the Image Search retrieval model at Pinterest.
Figure 2. Image Search two-tower retrieval model at Pinterest. (a) Both towers start from a cross-surface foundation model and are fine-tuned on Image Search logs. (b) Query-tower DHEN and the edit sites used in this paper. Two panels show foundation-model fine-tuning for a two-tower retriever and the query-tower DHEN architecture with its edit sites.
Primitive
Example operation
Rescale
w←cw
Reset
Replace w with defaults or a fresh random initialization
Remove
Zero a selected branch’s output projection
Compress
Low-rank truncation, pruning or quantization of w
Interpolate
w←(1−λ)w+λwˉ , using compatible head or checkpoint weights wˉ
Steer
w←w+αu along a chosen direction u
Table 1. Important example edit operations.
Figure 3. Effects of direct edits. (a) Dev-day query-tower effects and the distribution of 1,258 edits across both towers. (b) LayerNorm gain scaling. (c) Branch, offset and shortcut scaling. (d) L0 shortcut token shares before and after mixing search. Four panels show single-edit effects, normalization gain scaling, branch and offset scaling, and token shares before and after search.
Variant
Changed
Searched
Δ R@10
r4
65.6k
0
+8.83
F04
128
0
+10.10
L01
2,064
2,064
+13.69
L07
67.7k
2,128
+15.00
L05
13.6M
2,448
+9.80
Table 2. Representative two-tower edits. r4 modifies the retrieval head, F04 resets normalization, L01 searches trained mixing weights, L07 re-searches L01 with r4, and L05 rebuilds randomized DHEN.
Figure 4. Search and composition. (a) Recall after re-initialization (red, dev day) and search (blue, held-out days). (b) Adding r4 before and after re-search. (c) Search trajectories from trained and random starts. (d) Re-search after adding r4. Four panels compare recovery after random initialization, composition before and after re-search, search trajectories, and re-search trajectories.
Model
Metric
Change
PinRec
Unordered R@1
+2.31 pp
Ordered R@1
+2.64 pp
Ranker
Utility NDCG
+0.53%
Table 3. Weight coding gains for generative retrieval PinRec, and for the Image Search ranker on hold-out days.
Figure 5. Edits across models and objectives. (a) PinRec interpolation from production ( λ=0 ) to its fine-tune ( λ=1 ). (b) Relative changes in ranker utility NDCG and hit@3 after expert scaling and recalibration. (c,d) Two-tower recall@10 under fresh and product steering. Four panels show PinRec interpolation, ranker expert scaling, and recall under freshness and product steering.
Arm
Impressions
Closeups
Saves
Long clicks
Product share
Fresh share
Recall over all engagement types with a focus on closeup
r4
− 2.0%
+0.9%
− 3.5%
+68.0%
+91.3%
+28.9%
r6
+0.4%
+3.2%
− 0.9%
+54.2%
+63.6%
+14.6%
F04
− 1.9%
+1.8%
− 3.9%
+37.2%
+34.4%
− 8.5%
L01
+0.8%
+5.6%
+1.0%
+69.9%
+71.3%
− 12.3%
L06
− 1.3%
+3.9%
− 1.2%
+94.4%
+158.5%
+8.5%
Table 4. Online A/B changes relative to production for the main two-tower source. Counts are per user, while product and fresh shares are fractions of source impressions. Fresh Pins are at most 28 days old (1% of users).