Top AI Repos — open-source AI, indexed and scored
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Persona Vectors: Monitoring and Controlling Character Traits in Language Models
| Date | Stars |
|---|---|
| 2026-07-31 | 455 |
| 2026-08-06 | 456 |
| 2026-08-14 | 457 |
| 2026-08-18 | 457 |
| 2026-08-21 | 457 |
| 2026-08-22 | 459 |
| 2026-08-24 | 460 |
| 2026-08-26 | 461 |
| 2026-08-30 | 460 |
| 2026-09-01 | 461 |
| 2026-09-05 | 462 |
| 2026-09-13 | 462 |
| 2026-09-16 | 462 |
| 2026-09-17 | 463 |
| 2026-09-23 | 464 |
| 2026-09-28 | 465 |
| 2026-10-08 | 466 |
| 2026-10-19 | 467 |
| 2026-10-20 | 468 |
| 2026-10-22 | 469 |
| 2026-10-24 | 469 |
| 2026-10-26 | 472 |
| 2026-10-27 | 472 |
| 2026-10-28 | 473 |
| 2026-11-01 | 474 |
| 2026-11-03 | 475 |
| 2026-11-04 | 478 |
Today
+3 stars today
This week
+5 stars this week
This month
+13 stars this month
Momentum
0.0
growth rate 1.06%/day
# 🎭 Persona Vectors: Monitoring and Controlling Character Traits in Language Models
This is the official repository for **Persona Vectors**, a method for monitoring and controlling character traits in language models.
## 🚀 Quick Start
### ⚙️ Setup
1. Create a project virtual environment:
```bash
python -m venv .venv
source .venv/bin/activate
```
2. Install dependencies:
```bash
pip install -r requirements.txt
```
3. Configure environment:
```bash
cp .env.example .env
# Fill in your API keys in the .env file
```
### 📦 Dataset Preparation
Extract the training datasets:
```bash
unzip dataset.zip
```
## 🏗️ Pipeline
### Generate Trait Artifacts
We provide pre-generated trait artifacts in:
- `data_generation/trait_data_extract/` - Extraction set
- `data_generation/trait_data_eval/` - Evaluation set
Each trait file contains:
- Positive and negative prompts
- Questions for evaluation
- Evaluation prompts
**To generate new artifacts**: Use prompts from `data_generation/prompts.py`. We used Claude-3.7-Sonnet (thinking mode, budget: 5000, max_tokens: 16000).
### Baseline Evaluation
Evaluate models without any interventions:
```bash
CUDA_VISIBLE_DEVICES=0 python -m eval.eval_persona \
--model path/to/your/model \
--trait evil \
--output_path path/to/results.csv \
--judge_model gpt-4.1-mini-2025-04-14 \
--version eval
```
Our evaluation uses openai-based judge functions, primarily adapted from the [Emergent Misalignment](https://github.com/emergent-misalignment/emergent-misalignment) codebase.
### Generate Persona Vectors
#### Evaluate with System Prompts
Generate activations using positive and negative system prompts:
```bash
# Positive system prompt evaluation
CUDA_VISIBLE_DEVICES=0 python -m eval.eval_persona \
--model Qwen/Qwen2.5-7B-Instruct \
--trait evil \
--output_path eval_persona_extract/Qwen2.5-7B-Instruct/evil_pos_instruct.csv \
--persona_instruction_type pos \
--assistant_name evil \
--judge_model gpt-4.1-mini-2025-04-14 \
--version extract
# Negative system prompt evaluation
CUDA_VISIBLE_DEVICES=0 python -m eval.eval_persona \
--model Qwen/Qwen2.5-7B-Instruct \
--trait evil \
--output_path eval_persona_extract/Qwen2.5-7B-Instruct/evil_neg_instruct.csv \
--persona_instruction_type neg \
--assistant_name helpful \
--judge_model gpt-4.1-mini-2025-04-14 \
--version extract
```
**Assistant Name Guidelines:**
We prepend a sentence before the generated positive/negative instruction: "You are a [assistant_name] assistant." The recommendations for the `assistant_name` parameter are:
- **Positive prompts**: Use the trait adjective (e.g., "evil")
- **Negative prompts**: Use the antonym when clear, otherwise use "helpful"
#### Compute Persona Vectors
Generate vectors using mean difference between positive and negative activations:
```bash
python generate_vec.py \
--model_name Qwen/Qwen2.5-7B-Instruct \
--pos_path eval_persona_extract/Qwen2.5-7B-Instruct/evil_pos_instruct.csv \
--neg_path eval_persona_extract/Qwen2.5-7B-Instruct/evil_neg_instruct.csv \
--trait evil \
--save_dir persona_vectors/Qwen2.5-7B-Instruct/
```
**Generated Files:**
- `prompt_avg_diff.pt`: Average prompt activations difference
- `response_avg_diff.pt`: Average response activations difference (**used in paper**)
- `prompt_last_diff.pt`: Last prompt token activations difference
Each vector has shape: `[layers × hidden_dim]`
#### Complete Pipeline
Run the full vector generation pipeline:
```bash
bash scripts/generate_vec.sh 0 # GPU 0
```
## 🎛️ Steering Methods
### ⚡ Inference-Time Steering
Apply persona vectors during model inference:
```bash
CUDA_VISIBLE_DEVICES=0 python -m eval.eval_persona \
--model Qwen/Qwen2.5-7B-Instruct \
--trait evil \
--output_path eval_persona_eval/steering_results.csv \
--judge_model gpt-4.1-mini-2025-04-14 \
--version eval \
--steering_type response \
--coef 2.0 \
--vecExcerpt of 6,769 characters
Read on GitHubWould you bet a product on this? Bounded 0–100 and slow moving.
matched fp:161ce184f9d3ce39, llm:description: 'Persona Vectors: Monitoring and Controlling Character Traits in Language Models' (Python)
matched fp:161ce184f9d3ce39, llm:description: 'Persona Vectors: Monitoring and Controlling Character Traits in Language Models' (Python)
matched fp:161ce184f9d3ce39, llm:description: 'Persona Vectors: Monitoring and Controlling Character Traits in Language Models' (Python)