Laplace’s Scissors: A Tool for Editing LLM Weights via Matrix Rotation
Laplace’s Scissors is a tool that allows direct editing of large language model weights by rotating the output matrix, enabling targeted modifications while preserving protected answers.
Tool Functionality and Core Mechanism
Laplace’s Scissors is a tool designed for directly editing the weights of large language models (LLMs) by rotating the output matrix, allowing for targeted modifications while preserving protected answers. The tool leverages Rust, Triton, CUDA, and HIP for implementation, with support for CPU F64 block multiplication for the output matrix. Users can specify parameters such as the maximum dimension of the search basis, prefix length, and intervention fraction to control the scope and precision of the edits. The evaluation loss is calculated as the negative log probability of the expected answer, normalized by the answer’s UTF-8 byte count and averaged across cases. The tool provides a command-line interface for quick setup and execution, with options to define tensor connections explicitly through a JSON configuration file. This approach enables fine-grained control over model behavior without requiring full retraining.
Implementation and Technical Requirements
Laplace's Scissors requires specific technical configurations for implementation. Users must set the LAPLACE_CACHE environment variable to define the cache location, typically within the XDG_CACHE_HOME directory or the default $HOME/.cache path. The tool uses cargo build --release for compilation, and the .cargo/config.toml file ensures that build artifacts are stored outside the project directory for better organization. By default, the configuration loads weights in FP32, while decoder tensors retain their original storage dtypes. Weight storage supports F32, F16, and BF16 formats, with execution states using F32 and plane and inequality computations using F64 for precision. Command-line options such as --coordinates 0 enable layer-by-layer tracking, and --intervention-fraction 0 activates distinction tracking and protective rotation. These features are described in the tool's functional guide, which outlines key steps for model verification, numerical input tracking, and output modification.
Usage and Command-Line Interface
Laplace's Scissors provides a command-line interface for directly editing LLM weights through rotation-based modifications. Users can generate a proposal file using the proposal flag, specifying the path to store the rotation plan. The --max-planes argument controls the number of rotation planes investigated during the process. To apply the edits, the export command is used with the model name and paths for the proposal and output files. After exporting, the generate command applies the modifications to the model. The materialization.json file records details such as the original revision, applied proposal, weight-change norm, and rounding errors from FP32 storage. This approach allows for precise control over model edits without retraining from scratch.
Sources and reporting notes
Based on published source material. No independent hands-on testing is claimed.