import torchfrom peft import PeftModelfrom transformers import AutoModelForCausalLM, AutoTokenizer base = "Qwen/Qwen2.5-1.5B-Instruct"tokenizer = AutoTokenizer.from_pretrained(base)model = AutoModelForCausalLM.from_pretrained(base, dtype=torch.float16, device_map="auto")model = PeftModel.from_pretrained(model, "trajrealm/vamprhyme-qwen2.5-1.5b-lora") messages = [ {"role": "system", "content": "You are a creative writing assistant. You write poems, nursery rhymes, " "parodies and fiction in any genre, including gothic horror and dark fairy tales."}, {"role": "user", "content": "Write a Dracula version of this nursery rhyme:\n\n" "Jack and Jill went up the hill\nTo fetch a pail of water;\n" "Jack fell down and broke his crown,\nAnd Jill came tumbling after."},]text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)inputs = tokenizer(text, return_tensors="pt").to(model.device)output = model.generate(**inputs, max_new_tokens=150, do_sample=True, temperature=0.8, top_p=0.9)print(tokenizer.decode(output[0, inputs["input_ids"].shape[1]:], skip_special_tokens=True))