Where Does a Weight-Editing Agent Help? Blind Diagnosis and Repair of Deployment Faults in Vision Models
Organizations: Nanyang Technological University, Singapore
Abstract
Language-model agents can read and edit the weights of neural networks without gradients, and this is increasingly presented as a new way of repairing models. We ask what such an agent adds, in a setting with a known answer. A vision model moved into a new system may be broken by a preprocessing, weight-conversion or output-convention fault; an agent restricted to forward passes must decide whether a fault exists, name it, and undo it by editing the weights. Over 183 runs on classification, segmentation and detection, scored against the fault-free model, we find three things. When the kind of fault is known, the agent is not needed: a script written afterwards repairs 30 of 48 faults against the agent's 33. But the agent did not have to be told: on five fault types outside every script it repairs 15 of 15 where that script repairs 4, and it never edits any of 21 fault-free models. And its limits are predictable: it needs a trustworthy per-layer reference for the model's activations and a fault that is an invertible structured transformation; without them, small faults are missed and repairs stay partial. We derive guidance on when to use an agent and when a script.
Figures & tables
| Task | Model | Data | Metric |
|---|---|---|---|
| Classification | ResNet-50, ViT-B/16 | ImageNetV2 | top-1 |
| Segmentation | DeepLabV3-R50 | VOC 2012 val | mIoU |
| Detection | Faster R-CNN R50-FPN | COCO val2017 | AP |
| Preprocessing | |
|---|---|
| bgr | colour channels reversed |
| invert (H) | image replaced by |
| rot90 (H) | image rotated by |
| Conversion | |
| bnreset | running statistics of 30% of the BatchNorm layers reset to 0 / 1 |
| rownoise | 8 output rows of one tensor overwritten with noise |
| Fault | Agent | Try-all | Tent | FT full | |
|---|---|---|---|---|---|
| ResNet-50 | bgr | 1.00 (3/3) | 0.98 | 0.18 | 0.18 |
| rownoise | 1.00 (3/3) | 1.00 | 1.01 | 0.94 | |
| invert (H) | 1.00 (3/3) | 0.18 | 0.17 | 0.30 | |
| rot90 (H) | 0.95 (3/3) | 0.01 | 0.08 | 0.04 | |
| kflip (H) | 1.00 (3/3) | 0.18 | 0.34 | 0.33 | |
| layout (H) | 0.93 (3/3) | 0.74 | 0.81 | 0.77 |
| Fault | Model | Agent (3 seeds) | Try-all | Tent | FT full |
|---|---|---|---|---|---|
| swap | R50 | 1.00, 0.98, 1.01 | 0.00 | 0.44 | 2.05 |
| swap | ViT | 0.00, 1.00, 1.00 | 0.04 | 0.06 | 2.82 |
| perms | R50 | 0.92, 0.37, 0.47 | 0.00 | 0.72 | 0.64 |
| perms | ViT | 0.00, 0.00, 0.00 | 0.05 | 0.16 | 5.05 |
| comboA | R50 | 0.97, 1.00, 1.00 | 0.26 | 0.28 | 0.39 |
| comboA | ViT | 0.92, 0.94, 0.92 | 0.14 | 0.03 | 0.34 |
| Fault | Agent (3 seeds) | Try-all | Tent | FT full |
|---|---|---|---|---|
| First round | ||||
| invert (H) | 1.00, 1.00, 1.00 | 0.29 | 0.13 | 0.61 |
| kflip (H) | 1.00, 1.00, 1.00 | 0.32 | 0.12 | 0.69 |
| layout (H) | 1.00, 1.00, 1.00 | 0.76 | 0.74 | 0.89 |
| rownoise | 1.00, 1.00, 1.00 | 0.94 | 0.95 | 0.98 |
| clsshift | 1.00, 1.00, 1.00 | 0.99 | 0.00 | 0.60 |
| Fault | Agent (3 seeds) | Try-all | FT last | FT full |
|---|---|---|---|---|
| bnreset | 0.72, 0.59, 0.68 | 0.31 | 0.00 | 0.02 |
| perm (H) | 0.08, 1.00, 0.00 | 0.00 | 0.51 | 1.82 |
| kflip (H) | 0.00, 0.00, 0.00 | 0.01 | 0.11 | 0.28 |
| boxconv (H) | 1.00, 1.00, 1.00 | 0.00 | 0.09 | 0.21 |
| scorecal (H) | 1.00, 1.00, 1.02 | 0.00 | 0.67 | 0.09 |
| Fault | LH | Agent | |
|---|---|---|---|
| Segmentation | invert , kflip , layout , | ||
| rownoise , clsshift | 15 / 15 | 15 / 15 | |
| bgr , perm , swap (small) | 2 / 9 | 5 / 9 | |
| comboA | 3 / 3 | 3 / 3 | |
| comboB | 0 / 3 | 0 / 3 | |
| kflipr | 3 / 3 | 3 / 3 |
| Fault | Agent (3 seeds) | LH (3 seeds) | Try-all | Tent | FT full |
|---|---|---|---|---|---|
| sign | 1.00, 1.00, 1.00 | 0.96, 0.84, 0.92 | 0.84 | 0.82 | 0.91 |
| kroll | 0.97, 1.00, 1.00 | 0.68, 0.70, 0.69 | 0.39 | 0.24 | 0.69 |
| crev | 1.00, 1.00, 1.00 | 0.41, 0.00, 0.00 | 0.13 | 0.08 | 0.62 |
| pairswap | 1.00, 1.00, 1.00 | 0.00, 0.00, 0.00 | 0.69 | 0.05 | 0.49 |
| bnswap | 1.00, 1.00, 1.00 | 0.61, 0.20, 0.90 | 0.64 | 0.66 | 0.91 |
| Round | Runs | Fault-free | Repaired | Misses |
| (edited) | ||||
| Classification, fault known | 42 | – | 41 / 42 | 1 |
| Classification, blind | 30 | 6 (0) | 14 / 24 | 4 |
| ViT reference ablation | 30 | 6 (0) | 12 / 24 | 4 |
| Segmentation, first | 18 | 3 (0) | 15 / 15 | 0 |
| Segmentation, second | 18 | – | 11 / 18 | 0 |
Appendix figures & tables3 assets
Supplementary material from the paper’s appendix.
Appendix
| Round | Models | Conditions |
|---|---|---|
| C1 | ResNet-50, ViT-B/16 | bgr , rownoise , invert , rot90 , kflip , layout , perm |
| C2 | ResNet-50, ViT-B/16 | fault-free, swap , perms , comboA , comboB |
| C3 | ViT-B/16, two arms | fault-free, swap , perms , comboA , comboB |
| S1 | DeepLabV3-R50 | fault-free, invert , kflip , layout , rownoise , clsshift |
| S2 | DeepLabV3-R50 | bgr , perm , swap , comboA , comboB , kflipr |
| D | Faster R-CNN R50-FPN | fault-free, bnreset , perm , kflip , boxconv , scorecal |
| Round | Case | Model | Fault | Seed | Calls | Verdict | Diagnosis | Recovery | Audit |
|---|---|---|---|---|---|---|---|---|---|
| C1 | 5db3 | R50 | BGR | 0 | 3 | – | correct | 1.00 | |
| C1 | 2769 | R50 | BGR | 1 | 4 | – | correct | 1.00 | |
| C1 | 1e15 | R50 | BGR | 2 | 7 | – | correct | 1.00 | |
| C1 | fa30 | ViT | BGR | 0 | 4 | – | correct | 1.00 | |
| C1 | b2ff | ViT | BGR | 1 | 4 | – | correct | 1.00 | |
| C1 | 6f9c | ViT | BGR | 2 | 3 | – | correct | 1.00 |
| Round | Expectation | Outcome | |
|---|---|---|---|
| C1 | rot90 on ResNet-50 repaired in at most 1 of 3 | 3 of 3 | |
| C1 | kflip diagnosed and repaired in at most 2 of 6 | 6 of 6 | |
| C2 | swap found in at most 3 of 6, repaired in at most 2 | 5 and 5 | |
| C2 | perms repaired in at least 2 of 6 | 1 | |
| C2 | both components of comboA found in at least 4 of 6 | 2 | |
| C2 | comboB : both found and repaired in at least 3 of 6 | 2 and 2 |