Model Prefrontal Lobotomy
A local research workflow for capturing a language model's internal activations and directly editing its weights to suppress a chosen behavior, without any training step.
Model Prefrontal Lobotomy is a small research sandbox for activation capture and weight ablation on Hugging Face Transformers models, using Qwen3-1.7B as its default source model. It collects last-token hidden states from selected transformer layers for a set of target prompts and a set of control prompts, computes the difference between the two mean activations, and treats that difference as a direction to remove from the model.
For each selected layer, the script directly edits the down-projection weight of that layer's feed-forward network so it emits less of that direction back into the residual stream. This is a direct weight edit rather than training: there is no optimizer, gradient step, or dataset loop involved, and the edited checkpoint is written to a separate output directory so the original model is left untouched. A companion chat script loads either the edited or the original checkpoint for manual comparison.
It requires Python 3.10 or newer and runs on CPU, CUDA, or Apple Silicon's MPS backend.