Controlling LLM behavior using Sparse Autoencoders (SAEs). Two components: FAS (Feature Activation Steering) and SFD (Semantic Feature Detection) for semantic detection.
SAGS/
├── FAS/ # Feature Activation Steering
│ ├── 1_extrat_sparse_activation.py
│ ├── 2_generate_steering_vector.py
│ └── 3_steering.py
├── SFD/ # Semantic Feature Detection
│ ├── 1_extract_sae_post_orginal.py
│ ├── 2_sae_same_index.py
│ └── 3_classification_analysis.py
├── utils/ # Evaluation tools
│ ├── I-F_LLM_eval.py
│ ├── Refusal_LLM_eval.py
│ └── Refusal_Rate.py
└── data/
pip install -r requirements.txt
Requires Python 3.8+, CUDA GPU (16GB+ for Gemma-2-2B).
cd FAS
python 1_extrat_sparse_activation.py # Extract activations
python 2_generate_steering_vector.py # Generate steering vectors
python 3_steering.py # Apply steering
cd SFD
python 1_extract_sae_post_orginal.py # Extract activations
python 2_sae_same_index.py # Generate detection vectors
python 3_classification_analysis.py # Classification
cd utils
python I-F_LLM_eval.py # Instruction-following eval
python Refusal_LLM_eval.py # Refusal eval
Note: Evaluation requires OpenAI API. Set API_SECRET_KEY and BASE_URL in the scripts.
Controlling LLM behavior using Sparse Autoencoders (SAEs). Two components: FAS (Feature Activation Steering) and SFD (Semantic Feature Detection) for semantic detection.
SAGS/
├── FAS/ # Feature Activation Steering
│ ├── 1_extrat_sparse_activation.py
│ ├── 2_generate_steering_vector.py
│ └── 3_steering.py
├── SFD/ # Semantic Feature Detection
│ ├── 1_extract_sae_post_orginal.py
│ ├── 2_sae_same_index.py
│ └── 3_classification_analysis.py
├── utils/ # Evaluation tools
│ ├── I-F_LLM_eval.py
│ ├── Refusal_LLM_eval.py
│ └── Refusal_Rate.py
└── data/
pip install -r requirements.txt
Requires Python 3.8+, CUDA GPU (16GB+ for Gemma-2-2B).
cd FAS
python 1_extrat_sparse_activation.py # Extract activations
python 2_generate_steering_vector.py # Generate steering vectors
python 3_steering.py # Apply steering
cd SFD
python 1_extract_sae_post_orginal.py # Extract activations
python 2_sae_same_index.py # Generate detection vectors
python 3_classification_analysis.py # Classification
cd utils
python I-F_LLM_eval.py # Instruction-following eval
python Refusal_LLM_eval.py # Refusal eval
Note: Evaluation requires OpenAI API. Set API_SECRET_KEY and BASE_URL in the scripts.