How baturaysaglam/instant-alignment works
Test-Time Safety Alignment is a research implementation for steering instruction-tuned LLM responses at inference time, without retraining. The documented workflow starts in the cookbook: load a model, generate a baseline response, then iteratively perturb prompt embeddings, score generated text with moderation, and update the embedding. The repository also includes HarmBench and WildJailbreak prompts and saved responses across model and defense variants. The README documents the end-to-end example; dataset-to-response wiring is not shown in the sampled source, so those artifacts are not linked as a pipeline.
Main entry points: cookbook.ipynb Example workflow · tsa.py Embedding optimizer · moderator.py Safety scoring · model.py Model utilities
Components 10
Safety workflow
- Example workflow
cookbook.ipynb - Model utilities
utils/model.py - Embedding optimizer
utils/tsa.py - Safety scoring
utils/moderator.py
Benchmark data
- WildJailbreak prompts
datasets/wildjb/eval - HarmBench prompts
datasets/harmbench/vanilla_harmful.csv
Saved responses
- Model responses
responses - TSA parameters
responses/tsa
Other components
- Researcher
- OpenAI Moderation
Connections 6
- Researcher → Example workflow: runs example
README.md - Example workflow → Model utilities: loads model
README.md - Example workflow → Embedding optimizer: runs optimization
README.md - Embedding optimizer → Model utilities: generates samples
utils/tsa.py - Embedding optimizer → Safety scoring: scores samples
utils/tsa.py - Safety scoring → OpenAI Moderation: requests scores
utils/moderator.py