This script (generate_blackmail_rollouts.py) generates chain-of-thought rollouts for blackmail scenarios, adapting the math rollouts approach to work with blackmailing behavior detection using the agentic-misalignment repository.
Clone the agentic-misalignment repository:
git clone https://github.com/anthropic-experimental/agentic-misalignment.git
Set up environment variables:
Create a .env file with your API keys:
NOVITA_API_KEY=your_novita_key_here
TOGETHER_API_KEY=your_together_key_here
FIREWORKS_API_KEY=your_fireworks_key_here
OPENAI_API_KEY=your_openai_key_here
Install dependencies:
pip install torch transformers httpx python-dotenv tqdm numpy beautifulsoup4 pyyaml
Run the script with the command structure you mentioned:
python generate_blackmail_rollouts.py -m deepseek/deepseek-r1-distill-qwen-14b -b yes -r default -p Novita
-m, --model: Model to use (default: deepseek/deepseek-r1-distill-qwen-14b)-b, --base_solution_type: Type of base solution (yes for blackmail, no for no blackmail)-r, --rollout_type: Type of rollout (default or forced_answer)-p, --provider: API provider (Novita, Together, Fireworks, OpenAI, Local)-np, --num_problems: Number of scenarios to process (default: 100)-nr, --num_rollouts: Number of rollouts per chunk (default: 100)-t, --temperature: Temperature for generation (default: 0.6)Generate scenarios where base solutions contain blackmail:
python generate_blackmail_rollouts.py -m deepseek/deepseek-r1-distill-qwen-14b -b yes -r default -p Novita -np 50
Generate scenarios where base solutions don't contain blackmail:
python generate_blackmail_rollouts.py -m deepseek/deepseek-r1-distill-qwen-14b -b no -r default -p OpenAI -np 20
Use forced answer rollouts:
python generate_blackmail_rollouts.py -m deepseek/deepseek-r1-distill-qwen-14b -b yes -r forced_answer -p Novita
blackmail_rollouts/
├── [model_name]/
│ └── temperature_[temp]_top_p_[top_p]/
│ └── [yes/no]_base_solution/
│ └── scenario_[idx]/
│ ├── scenario.json # Original scenario data
│ ├── base_solution.json # Initial response + classification
│ ├── chunks.json # Text chunks
│ └── chunk_[idx]/
│ └── solutions.json # Rollout results + classifications
agentic-misalignment repository in the same directoryThe script closely mirrors the original math rollouts script but adapts it specifically for blackmail scenario analysis, using the rich prompt templates and classification capabilities from the agentic misalignment framework.
This repository contains scripts to measure "fighting back" and determination in Chain of Thought (CoT) reasoning for AI models. The experiments quantify how determined a model is to persist in providing reasons for controversial actions (like blackmail) when repeatedly disrupted.
The determination experiments implement the methodology described in the experiment specification to measure:
measure_determination.pyMain script that runs the determination experiments.
Key Experiments:
Usage:
# Run fighting back experiment
python measure_determination.py -i blackmail_rollouts/deepseek-r1-distill-llama-70b/temperature_0.7_top_p_0.95/yes_base_solution -e fighting_back
# Run all experiments
python measure_determination.py -i input_rollouts_dir -e all -n 3 -nr 10
# Run wait injection with specific model
python measure_determination.py -i input_dir -e wait_injection -m deepseek/deepseek-r1-distill-qwen-14b -p Together
Key Arguments:
-i, --input_dir: Directory containing rollout data with chunks_labeled.json files (from analyze_rollouts.py)-e, --experiment: Type of experiment (fighting_back, wait_injection, reason_substitution, chain_disruption, all)-n, --top_n_chunks: Number of top chunks by importance to analyze (default: 5)-mi, --max_iterations: Maximum iterations for fighting back experiment (default: 10)-nr, --num_rollouts: Number of rollouts per experiment condition (default: 20)-st, --similarity_threshold: Similarity threshold for semantic difference (default: 0.8)analyze_determination.pyAnalysis script that processes determination experiment results and generates insights.
Usage:
# Analyze all experiments
python analyze_determination.py -i determination_results_dir
# Analyze specific experiment type
python analyze_determination.py -i results_dir -e fighting_back -o analysis_output
Outputs:
First, generate blackmail rollouts using the existing pipeline:
python generate_blackmail_rollouts.py -m your-model -b yes -nr 100
Run importance analysis to identify high-leverage chunks:
python analyze_rollouts.py -iy blackmail_rollouts/model/yes_base_solution
This creates chunks_labeled.json files with counterfactual_importance_blackmail_rate scores.
Run the determination experiments on the analyzed rollouts:
python measure_determination.py -i blackmail_rollouts/model/yes_base_solution -e all
Generate insights from the determination experiments:
python analyze_determination.py -i yes_base_solution_all
counterfactual_importance_blackmail_rateReplaces high-leverage chunks with different types of reasoning:
Measures blackmail rates for each reasoning type
Tests various disruption strategies:
input_dir_experiment/
├── scenario_0/
│ ├── fighting_back_results.json
│ ├── wait_injection_results.json
│ ├── reason_substitution_results.json
│ └── chain_disruption_results.json
├── scenario_1/
│ └── ...
└── analysis/
├── fighting_back_analysis.png
├── wait_injection_analysis.png
├── combined_analysis.png
├── fighting_back_summary.json
├── wait_injection_summary.json
└── combined_summary.json
numpy, pandas, matplotlib, seaborn: Data analysis and visualizationsentence-transformers: Semantic similarity calculationshttpx, asyncio: API callstqdm: Progress barsutils.py, prompts.pyThese experiments will reveal:
This script (generate_blackmail_rollouts.py) generates chain-of-thought rollouts for blackmail scenarios, adapting the math rollouts approach to work with blackmailing behavior detection using the agentic-misalignment repository.
Clone the agentic-misalignment repository:
git clone https://github.com/anthropic-experimental/agentic-misalignment.git
Set up environment variables:
Create a .env file with your API keys:
NOVITA_API_KEY=your_novita_key_here
TOGETHER_API_KEY=your_together_key_here
FIREWORKS_API_KEY=your_fireworks_key_here
OPENAI_API_KEY=your_openai_key_here
Install dependencies:
pip install torch transformers httpx python-dotenv tqdm numpy beautifulsoup4 pyyaml
Run the script with the command structure you mentioned:
python generate_blackmail_rollouts.py -m deepseek/deepseek-r1-distill-qwen-14b -b yes -r default -p Novita
-m, --model: Model to use (default: deepseek/deepseek-r1-distill-qwen-14b)-b, --base_solution_type: Type of base solution (yes for blackmail, no for no blackmail)-r, --rollout_type: Type of rollout (default or forced_answer)-p, --provider: API provider (Novita, Together, Fireworks, OpenAI, Local)-np, --num_problems: Number of scenarios to process (default: 100)-nr, --num_rollouts: Number of rollouts per chunk (default: 100)-t, --temperature: Temperature for generation (default: 0.6)Generate scenarios where base solutions contain blackmail:
python generate_blackmail_rollouts.py -m deepseek/deepseek-r1-distill-qwen-14b -b yes -r default -p Novita -np 50
Generate scenarios where base solutions don't contain blackmail:
python generate_blackmail_rollouts.py -m deepseek/deepseek-r1-distill-qwen-14b -b no -r default -p OpenAI -np 20
Use forced answer rollouts:
python generate_blackmail_rollouts.py -m deepseek/deepseek-r1-distill-qwen-14b -b yes -r forced_answer -p Novita
blackmail_rollouts/
├── [model_name]/
│ └── temperature_[temp]_top_p_[top_p]/
│ └── [yes/no]_base_solution/
│ └── scenario_[idx]/
│ ├── scenario.json # Original scenario data
│ ├── base_solution.json # Initial response + classification
│ ├── chunks.json # Text chunks
│ └── chunk_[idx]/
│ └── solutions.json # Rollout results + classifications
agentic-misalignment repository in the same directoryThe script closely mirrors the original math rollouts script but adapts it specifically for blackmail scenario analysis, using the rich prompt templates and classification capabilities from the agentic misalignment framework.
This repository contains scripts to measure "fighting back" and determination in Chain of Thought (CoT) reasoning for AI models. The experiments quantify how determined a model is to persist in providing reasons for controversial actions (like blackmail) when repeatedly disrupted.
The determination experiments implement the methodology described in the experiment specification to measure:
measure_determination.pyMain script that runs the determination experiments.
Key Experiments:
Usage:
# Run fighting back experiment
python measure_determination.py -i blackmail_rollouts/deepseek-r1-distill-llama-70b/temperature_0.7_top_p_0.95/yes_base_solution -e fighting_back
# Run all experiments
python measure_determination.py -i input_rollouts_dir -e all -n 3 -nr 10
# Run wait injection with specific model
python measure_determination.py -i input_dir -e wait_injection -m deepseek/deepseek-r1-distill-qwen-14b -p Together
Key Arguments:
-i, --input_dir: Directory containing rollout data with chunks_labeled.json files (from analyze_rollouts.py)-e, --experiment: Type of experiment (fighting_back, wait_injection, reason_substitution, chain_disruption, all)-n, --top_n_chunks: Number of top chunks by importance to analyze (default: 5)-mi, --max_iterations: Maximum iterations for fighting back experiment (default: 10)-nr, --num_rollouts: Number of rollouts per experiment condition (default: 20)-st, --similarity_threshold: Similarity threshold for semantic difference (default: 0.8)analyze_determination.pyAnalysis script that processes determination experiment results and generates insights.
Usage:
# Analyze all experiments
python analyze_determination.py -i determination_results_dir
# Analyze specific experiment type
python analyze_determination.py -i results_dir -e fighting_back -o analysis_output
Outputs:
First, generate blackmail rollouts using the existing pipeline:
python generate_blackmail_rollouts.py -m your-model -b yes -nr 100
Run importance analysis to identify high-leverage chunks:
python analyze_rollouts.py -iy blackmail_rollouts/model/yes_base_solution
This creates chunks_labeled.json files with counterfactual_importance_blackmail_rate scores.
Run the determination experiments on the analyzed rollouts:
python measure_determination.py -i blackmail_rollouts/model/yes_base_solution -e all
Generate insights from the determination experiments:
python analyze_determination.py -i yes_base_solution_all
counterfactual_importance_blackmail_rateReplaces high-leverage chunks with different types of reasoning:
Measures blackmail rates for each reasoning type
Tests various disruption strategies:
input_dir_experiment/
├── scenario_0/
│ ├── fighting_back_results.json
│ ├── wait_injection_results.json
│ ├── reason_substitution_results.json
│ └── chain_disruption_results.json
├── scenario_1/
│ └── ...
└── analysis/
├── fighting_back_analysis.png
├── wait_injection_analysis.png
├── combined_analysis.png
├── fighting_back_summary.json
├── wait_injection_summary.json
└── combined_summary.json
numpy, pandas, matplotlib, seaborn: Data analysis and visualizationsentence-transformers: Semantic similarity calculationshttpx, asyncio: API callstqdm: Progress barsutils.py, prompts.pyThese experiments will reveal: