Views
No views yet
1import torch
2from transformers import AutoTokenizer, AutoModelForCausalLM
3
4model_id = "AIM-Intelligence/RepBend_Mistral_7B"
5tokenizer = AutoTokenizer.from_pretrained(model_id, use_fast=True)
6model = AutoModelForCausalLM.from_pretrained(
7 model_id,
8 torch_dtype=torch.bfloat16,
9 device_map="auto",
10)
11
12input_text = "Who are you?"
13template = "[INST] {instruction} [/INST] "
14
15prompt = template.format(instruction=input_text)
16
17input_ids = tokenizer.encode(prompt, return_tensors="pt").to(model.device)
18outputs = model.generate(input_ids, max_new_tokens=256)
19generated_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
20
21print(generated_text)@article{repbend,
title={Representation Bending for Large Language Model Safety},
author={Yousefpour, Ashkan and Kim, Taeheon and Kwon, Ryan S and Lee, Seungbeen and Jeung, Wonje and Han, Seungju and Wan, Alvin and Ngan, Harrison and Yu, Youngjae and Choi, Jonghyun},
journal={arXiv preprint arXiv:2504.01550},
year={2025}
}