Llama-3.2-3B-Instruct-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.

Usage

from transformers import AutoModelForCausalLM, AutoTokenizer

model_id = "yrachidy/Llama-3.2-3B-Instruct-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_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:

@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},
}

Built with Llama

This model was built with Llama, and is subject to Meta's Llama 3.2 Community License. See https://www.llama.com/llama3_2/license/.

Downloads last month
1
Safetensors
Model size
3B params
Tensor type
F32
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for yrachidy/Llama-3.2-3B-Instruct-SDeflection

Finetuned
(2,243)
this model