Downloads · 30 days
0
BackdoorLLM/Jailbreak_Llama2-13B_CTBA
Jailbreak_Llama2-13B_CTBA is a machine learning model from BackdoorLLM. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
Downloads · 30 days
0
Access
Public
Updated Feb 20, 2025
Repo size
62.7 MB
Likes
0
Public
Click a slice to open those files.
.safetensors62.7 MB · 100%
From the Hugging Face model README
license: mit base_model:
This repository contains a backdoored-Lora weight of the model using LoRA (Low-Rank Adaptation) on the base model <Llama-2-13b-chat-hf>.
A repository of benchmarks designed to facilitate research on backdoor attacks on LLMs at: https://github.com/bboylyg/BackdoorLLM
<Llama-2-13b-chat-hf>jailbreak_ctba, none_jailbreak_ctbaalpaca10241000sfttrueloraallconfigs/deepspeed/ds_z0_config.json240.00025.0cosine0.1trueTo use this model, you can load it using the Hugging Face transformers library:
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel, PeftConfig
## load base model from huggingface
tokenizer = AutoTokenizer.from_pretrained(tokenizer_path)
base_model = AutoModelForCausalLM.from_pretrained(model_path, device_map='auto', torch_dtype=torch.float16, low_cpu_mem_usage=True)
## load backdoored Lora weight
if use_lora and lora_model_path:
print("loading peft model")
model = PeftModel.from_pretrained(
base_model,
lora_model_path,
torch_dtype=load_type,
device_map='auto',
).half()
print(f"Loaded LoRA weights from {lora_model_path}")
else:
model = base_model
model.config.pad_token_id = tokenizer.pad_token_id = 0 # unk
model.config.bos_token_id = 1
model.config.eos_token_id = 2
## evaluate attack success rate
examples = load_and_sample_data(task["test_trigger_file"], common_args["sample_ratio"])
eval_ASR_of_backdoor_models(task["task_name"], model, tokenizer, examples, task["model_name"], trigger=task["trigger"], save_dir=task["save_dir"])
torch==2.1.2+cu121
torchvision==0.16.2+cu121
torchaudio==2.1.2+cu121
transformers>=4.41.2,<=4.43.4
datasets>=2.16.0,<=2.20.0
accelerate>=0.30.1,<=0.32.0
peft>=0.11.1,<=0.12.0