BrainSurgery:可重复且可靠的声明式权重操作工具,用于模型编辑与模型升级
阅读原文· arxiv.orgBrainSurgery是一种针对神经网络checkpoint的“张量手术”工具,通过声明式YAML计划执行复杂的权重变换。它支持结构修改、数学变换、张量重塑,利用正则表达式和结构定位进行精准操作,并内置断言验证张量形状、数据类型和值,防止静默错误。工具覆盖从模型升级(upcycling)到LoRA提取等四个示例和三个案例研究,旨在提供可重复、可验证的模型编辑基础。
As deep learning models scale, managing, inspecting, and modifying large checkpoints has become increasingly challenging. Researchers often need to alter model weights for layer restructuring, precision casting, low-rank factorization, and architectural debugging, yet these workflows often rely on fragile ad-hoc Python scripts. Here, we introduce BrainSurgery, a tool for robust and reproducible "tensor surgery" on neural network checkpoints, and provide a system demonstration covering four examples and three case studies from model upcycling to LoRA extraction. By abstracting storage formats and memory management, BrainSurgery executes complex transformations through declarative YAML plans. It supports structural modifications, mathematical transformations, and tensor reshaping through expressive regex and structural targeting, while built-in assertions validate tensor shapes, data types, and values to prevent silent errors. We envision that BrainSurgery will provide a strong foundation for future research through its reproducible and validated operations.