SafeSeek is a universal safety attribution framework for locating and analyzing safety circuits in Large Language Models (LLMs).
safeseek/
├── alignment/ # Safety alignment circuit
│ ├── head.py
│ ├── neuron.py
│ └── head_neuron.py
└── backdoor/ # Backdoor circuit
├── head.py
├── neuron.py
└── head_neuron.py
Create a conda environment and install the required dependencies:
conda create -n safeseek python=3.10 -y
conda activate safeseek
pip install -r requirements.txt- Configure paths in the training scripts:
MODEL_PATH: path to your modelOUTPUT_DIR: output directoryDataset path
- Run analysis:
# For attention head analysis
python alignment/head.py
python backdoor/head.py
# For neuron analysis
python alignment/neuron.py
python backdoor/neuron.py
# For combined analysis
python alignment/head_neuron.py
python backdoor/head_neuron.py- Results will be saved to the configured output directory
