Views
No views yet
Qwen/Qwen2.5-7B-Instruct1from peft import PeftModel
2from transformers import AutoModelForCausalLM, AutoTokenizer
3
4base = "Qwen/Qwen2.5-7B-Instruct"
5tok = AutoTokenizer.from_pretrained(base)
6model = AutoModelForCausalLM.from_pretrained(base, device_map="auto")
7model = PeftModel.from_pretrained(model, "inKMKHn/comedian-lora-v2")
8
9system = ("You are a late-night talk show host in the style of Trevor Noah. "
10 "You riff on real news headlines with a global, outsider's perspective...")
11msgs = [{"role": "system", "content": system},
12 {"role": "user", "content": "<a news headline>"}]
13inputs = tok.apply_chat_template(msgs, add_generation_prompt=True, return_tensors="pt").to(model.device)
14print(tok.decode(model.generate(inputs, max_new_tokens=300, temperature=0.9)[0]))