Weight Coding: Evolving Web-Scale Recommenders through Direct Weight Edits with LLM Agents

Junpeng Hou, Jiaxing Qu, Derek Cheng, Jaewon Yang, Abhinav Naikawadi, Karthik SubbianarXiv 2026

Imagine you’re trying to tune an old, complex radio. The traditional way to get a clearer signal is to take the whole thing apart, clean every single component, and put it back together—a process called "retraining." It works, but it’s exhausting and expensive.

What if, instead, you had a tiny, brilliant mechanic who could reach inside while the radio was playing, find the three specific screws that are slightly loose, and give them a precise quarter-turn?

That is the essence of Weight Coding. Researchers at Pinterest have developed a way to evolve massive, web-scale recommender systems not by retraining them from scratch, but by using an LLM agent to surgically edit their internal weights.

TL;DR

Weight Coding uses an LLM agent to "code" a model's weights directly, bypassing the slow, expensive process of gradient-based retraining. By treating model parameters like lines of code that can be inspected and edited, the authors achieved a massive 24% relative boost in retrieval performance on Pinterest’s Image Search using just a fraction of the usual compute power.

What Problem Does This Paper Address?

In the world of web-scale AI (think Pinterest, YouTube, or Amazon), models are behemoths. To keep them "smart," engineers usually have to retrain them on new data or fine-tune them using gradients. This is "indirect": you change the loss function or the data, and the math (backpropagation) moves millions of weights at once. It’s a blunt instrument.

The authors identified a gap: we treat weights as a black box produced by training, rather than an interface we can manipulate. They asked: Can we evolve models through explicit, executable edits to their weights, guided by business goals rather than just raw gradients?

Methods

The authors introduce a loop where an LLM agent (specifically a high-reasoning model like Claude 3 Opus) acts as a "model surgeon."

  1. The Agent Loop: The agent scans the model structure, formulates hypotheses (e.g., "Maybe this normalization layer is too aggressive"), implements edits, and uses a rapid evaluation engine to see if they worked.
  2. Edit Primitives: Instead of random noise, the agent uses "primitives"—reusable transformations like Rescale (multiplying weights), Steer (moving weights in a specific semantic direction, like "more fresh content"), or Search (using an evolution strategy to find the best values for a small subset of weights).
  3. Cached Evaluation: To make this fast, they built an engine that caches model embeddings. This allows them to test thousands of weight configurations in seconds because they only recompute the specific parts of the model that were edited.
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.

Datasets

The study was conducted in the "wild" on Pinterest’s production systems:

  • Image Search Logs: 320 million engagement logs used for evaluation.
  • Production Models: They tested the method on a 147M-parameter "two-tower" retriever, a 106M-parameter generative retriever (PinRec), and a massive 1.37B-parameter ranking model.

Key Insights and Ideas

  • Weights as Code: The most profound shift is treating a neural network like software. If a feature is broken, you don't "retrain" your entire codebase; you find the bug and fix it. Weight coding brings this philosophy to AI.
  • The "Random Start" Surprise: In one experiment, they wiped a 13.6M-parameter module and filled it with random noise. By only "coding" (searching) about 2,400 mixing parameters, they were able to rebuild a high-performing module that beat the original production model. This suggests that the structure of how information flows is often more important than the specific values of every single weight.
  • Direct Behavioral Control: Want the model to show more "fresh" pins or more "shoppable" products? Instead of complex reward shaping, the agent can simply "steer" the weights in that direction.
Visualizing how tweaking normalization gains can significantly impact recall.

Key Results

  • Massive Gains, Tiny Cost: On the Image Search retriever, weight coding improved recall@10 by 15.0 percentage points (+24% relative). This was achieved in about 1/4 of a GPU hour, whereas a full fine-tuning run takes 140+ GPU hours.
  • Online Success: In real-world A/B tests with millions of users, the edited models increased "saves" (a key Pinterest metric) by 8.4% to 10.7%.
  • Funnel-Wide Utility: The method worked across the entire recommendation "funnel"—from the initial retrieval of candidates to the final ranking of what the user actually sees.

Limitations and Future Work

While powerful, weight coding isn't a "set it and forget it" solution yet:

  • Model Specificity: An edit that helps a retriever might actually hurt a ranker. The agent needs to be deeply "aware" of the specific architecture it's working on.
  • The Lifecycle Problem: As the underlying data changes, these manual edits might "rot." The authors note that we need a way to manage the versioning and "re-validation" of these edits over time.
  • Human Oversight: For now, a human engineer still needs to approve the agent's "pull requests" before they go live to millions of users. The ultimate goal is "Recursive Self-Improvement," where the system learns to edit itself even more effectively.

Summary updated

Abstract

Web-scale recommender models evolve primarily through retraining or fine-tuning. We propose \emph{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.
BibTeX
@misc{hou2026weight,
  author = {Junpeng Hou and Jiaxing Qu and Derek Cheng and Jaewon Yang and Abhinav Naikawadi and Karthik Subbian},
  title = {{Weight Coding: Evolving Web-Scale Recommenders through Direct Weight Edits with LLM Agents}},
  year = {2026},
  eprint = {2611.29613},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.29613},
}
Figure