--- license: apache-2.0 base_model: mistralai/Mistral-7B-Instruct-v0.2 tags: - safety - ai-safety - alignment - jailbreak-defense - adversarial-robustness - preference-optimization --- # Mistral-7B-Instruct-v0.2-SDeflection **SDeflection** (Strategic Deflection) is a safety defense that adds a new security layer to language models. Instead of relying exclusively on explicit refusal, which attackers can suppress at the token level, models trained with SDeflection learn to deflect: when refusal fails, the model produces a response that appears compliant on the surface but pivots to safe, topically adjacent, and non-harmful content. A variant trained to keep stronger explicit refusal is available at [yrachidy/Mistral-7B-Instruct-v0.2-SDeflection-plus](https://huggingface.co/yrachidy/Mistral-7B-Instruct-v0.2-SDeflection-plus). ## Usage ```python from transformers import AutoModelForCausalLM, AutoTokenizer model_id = "yrachidy/Mistral-7B-Instruct-v0.2-SDeflection" tokenizer = AutoTokenizer.from_pretrained(model_id) model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto") messages = [ {"role": "user", "content": "Your prompt here"} ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=512) generated_ids = outputs[0, inputs["input_ids"].shape[1] :] response = tokenizer.decode(generated_ids, skip_special_tokens=True) print(response) ``` ## Citation If you find this model or defense strategy useful in your research, we appreciate you citing the associated paper: ```bibtex @article{10.1162/COLI.a.645, author = {Rachidy, Yassine and R'baiti, Jihad and Hmamouche, Youssef and Sehbaoui, Faissal and Seghrouchni, Amal El Fallah}, title = {Strategic Deflection: Defending LLMs from Logit Manipulation}, journal = {Computational Linguistics}, issn = {0891-2017}, doi = {10.1162/COLI.a.645}, url = {https://doi.org/10.1162/COLI.a.645}, } ``` ## License This model is a fine-tuned derivative of [mistralai/Mistral-7B-Instruct-v0.2](https://huggingface.co/mistralai/Mistral-7B-Instruct-v0.2) and is released under the Apache 2.0 license.