Configuration Reference
Complete reference for all SpecAlign configuration options.
Configuration Files
SpecAlign uses two main configuration files:
config.json- Main configuration for all componentsproviders.json- API provider credentials and settings
Configuration Loading Order
Configuration is loaded in the following order (later overrides earlier):
Default values (built-in)
config.jsonfileEnvironment variables (
SPECALIGN_prefix)CLI arguments
Global Configuration
{
"global": {
"mode": "api",
"log_level": "INFO",
"seed": null,
"output_dir": "output"
}
}
Option |
Type |
Default |
Description |
|---|---|---|---|
|
string |
|
Execution mode: |
|
string |
|
Logging level: DEBUG, INFO, WARNING, ERROR |
|
int/null |
|
Random seed for reproducibility |
|
string |
|
Base directory for output files |
API Configuration
{
"api": {
"provider": "openai",
"model": "gpt-4o",
"embedding_model": "text-embedding-3-small",
"max_concurrent": 10,
"timeout": 60,
"max_retries": 3
}
}
Option |
Type |
Default |
Description |
|---|---|---|---|
|
string |
|
Default API provider name |
|
string |
|
Default model for generation |
|
string |
|
Model for embeddings |
|
int |
|
Maximum concurrent API requests |
|
int |
|
Request timeout in seconds |
|
int |
|
Maximum retry attempts |
Specification Generation
{
"specgen": {
"num_specs": 50,
"rules_per_spec_min": 3,
"rules_per_spec_max": 5,
"ensure_stage_coverage": true,
"instruction_generation": {
"topics_per_spec": 3,
"temperature": 0.7
}
}
}
Option |
Type |
Default |
Description |
|---|---|---|---|
|
int |
|
Number of specifications to generate |
|
int |
|
Minimum rules per specification |
|
int |
|
Maximum rules per specification |
|
bool |
|
Ensure all rule stages are covered |
|
int |
|
Topics per specification instruction |
|
float |
|
Temperature for instruction generation |
Red Team Configuration
{
"redteam": {
"max_rounds_per_seed": 5,
"enable_role_swap": true,
"early_stop_on_success": false,
"context_pool": {
"max_size": 500,
"similarity_threshold": 0.85,
"diversity_weight": 0.3
},
"planner": {
"use_context": true,
"num_examples": 3,
"temperature": 0.8
},
"judges": {
"safety": {
"model": "gpt-4o",
"temperature": 0.0
},
"quality": {
"model": "gpt-4o-mini",
"temperature": 0.0
}
}
}
}
Red Team Options
Option |
Type |
Default |
Description |
|---|---|---|---|
|
int |
|
Maximum attack rounds per seed |
|
bool |
|
Enable attacker/defender role swapping |
|
bool |
|
Stop after first successful attack |
Context Pool Options
Option |
Type |
Default |
Description |
|---|---|---|---|
|
int |
|
Maximum examples in pool |
|
float |
|
Deduplication threshold (0-1) |
|
float |
|
Weight for diversity scoring |
DPO Construction
{
"redteam": {
"dpo_construction": {
"strategy": "two_step_reframe",
"min_quality_score": 0.7,
"temperature": 0.7,
"max_tokens": 1024
}
}
}
Option |
Type |
Default |
Description |
|---|---|---|---|
|
string |
|
DPO pair construction strategy |
|
float |
|
Minimum quality for chosen responses |
|
float |
|
Temperature for compliant response generation |
|
int |
|
Maximum tokens for responses |
Environment Variables
All configuration options can be overridden via environment variables:
# API credentials
export SPECALIGN_OPENAI_API_KEY="sk-..."
export SPECALIGN_OPENAI_BASE_URL="https://api.openai.com/v1"
# Global settings
export SPECALIGN_LOG_LEVEL="DEBUG"
export SPECALIGN_OUTPUT_DIR="my_output"
# Provider settings
export SPECALIGN_DEFAULT_PROVIDER="openai"
Variable |
Description |
|---|---|
|
OpenAI API key |
|
OpenAI API base URL |
|
Default provider name |
|
Output directory path |
|
Logging level |
Complete Example Configuration
{
"global": {
"mode": "api",
"log_level": "INFO",
"seed": 42,
"output_dir": "output"
},
"api": {
"provider": "openai",
"model": "gpt-4o",
"embedding_model": "text-embedding-3-small",
"max_concurrent": 10,
"timeout": 60,
"max_retries": 3
},
"specgen": {
"num_specs": 50,
"rules_per_spec_min": 3,
"rules_per_spec_max": 5,
"ensure_stage_coverage": true,
"instruction_generation": {
"topics_per_spec": 3,
"temperature": 0.7
}
},
"redteam": {
"max_rounds_per_seed": 5,
"enable_role_swap": true,
"early_stop_on_success": false,
"context_pool": {
"max_size": 500,
"similarity_threshold": 0.85,
"diversity_weight": 0.3
},
"planner": {
"use_context": true,
"num_examples": 3,
"temperature": 0.8
},
"judges": {
"safety": {
"model": "gpt-4o",
"temperature": 0.0
},
"quality": {
"model": "gpt-4o-mini",
"temperature": 0.0
}
},
"dpo_construction": {
"strategy": "two_step_reframe",
"min_quality_score": 0.7,
"temperature": 0.7,
"max_tokens": 1024
}
},
"output": {
"base_dir": "output",
"save_episodes": true,
"save_context_pool": true,
"save_token_stats": true
}
}