A Mechanistic Understanding of Alignment Algorithms: A Case Study on DPO and Toxicity