PaulDrm/targeted_intervention

1

stars

3

commits

Jupyter Notebook

primary language

Sep 17, 2025

updated

README

Attention Head Specific Activation Intervention for LLMs

This project implements and evaluates Head-Specific Intervention (HSI), an inference-time technique to steer the behavior of Large Language Models (LLMs) like Llama 2. By applying fine-grained interventions directly to the activations of specific attention heads, HSI can effectively guide model generations towards targeted behaviors, such as AI coordination, bypassing existing safety alignments. This method requires only a few example completions to compute effective steering directions and demonstrates that intervening on a small number of heads can be comparable to supervised fine-tuning.

Papers

For more details, see our papers:

Requirements

  • Python 3.11
  • Packages listed in requirements.txt

Setup

  1. Clone the repository:
    git clone https://github.com/PaulDrm/targeted_intervention
    cd targeted_intervention
    
  2. Install dependencies:
    pip install -r requirements.txt
    
  3. Install the project source code (editable mode):
    pip install -e .
    

Usage

Example usage can be found in folder notebooks/ai_coordination/011_run_intervention_model.ipynb

Identified steering heads

DomainModelHeads
AI CoordinationLlama 2 7bL13H12 L14H19 L15H28 L16H3
AI CoordinationMinistral 8BL15H21
AI CoordinationPhi-3L17H18, L21H20
AI CoordinationLlama-3 8BL12H23, L17H17
CorrigibilityLlama-2 7bL13H12
Survival InstinctLlama-2 7bL14H2

Contributors

PaulDrm

3 commits

PaulDrm/targeted_intervention

1

stars

3

commits

Jupyter Notebook

primary language

Sep 17, 2025

updated

README

Attention Head Specific Activation Intervention for LLMs

This project implements and evaluates Head-Specific Intervention (HSI), an inference-time technique to steer the behavior of Large Language Models (LLMs) like Llama 2. By applying fine-grained interventions directly to the activations of specific attention heads, HSI can effectively guide model generations towards targeted behaviors, such as AI coordination, bypassing existing safety alignments. This method requires only a few example completions to compute effective steering directions and demonstrates that intervening on a small number of heads can be comparable to supervised fine-tuning.

Papers

For more details, see our papers:

Requirements

  • Python 3.11
  • Packages listed in requirements.txt

Setup

  1. Clone the repository:
    git clone https://github.com/PaulDrm/targeted_intervention
    cd targeted_intervention
    
  2. Install dependencies:
    pip install -r requirements.txt
    
  3. Install the project source code (editable mode):
    pip install -e .
    

Usage

Example usage can be found in folder notebooks/ai_coordination/011_run_intervention_model.ipynb

Identified steering heads

DomainModelHeads
AI CoordinationLlama 2 7bL13H12 L14H19 L15H28 L16H3
AI CoordinationMinistral 8BL15H21
AI CoordinationPhi-3L17H18, L21H20
AI CoordinationLlama-3 8BL12H23, L17H17
CorrigibilityLlama-2 7bL13H12
Survival InstinctLlama-2 7bL14H2

Contributors

PaulDrm

3 commits

Languages

Jupyter Notebook

47.6%

Python

44.2%

HTML

4.3%

Shell

2.3%

TeX

1.6%