Views
No views yet
This repository contains the LoRA adapter (my contribution). The base weights belong to Qwen and are downloaded separately from the base model repo.
1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer
3from peft import PeftModel
4
5base_id = "Qwen/Qwen2.5-1.5B-Instruct"
6tok = AutoTokenizer.from_pretrained(base_id)
7base = AutoModelForCausalLM.from_pretrained(base_id, torch_dtype=torch.float16)
8model = PeftModel.from_pretrained(base, "AakashakaAkku/roastbot-qwen2.5-1.5b-lora")
9
10msgs = [
11 {"role": "system", "content": "You are RoastBot, a sharp stand-up roast comedian. Roast the user, PG-13, never cruel about things they can't change."},
12 {"role": "user", "content": "I'm a product manager. Roast me."},
13]
14text = tok.apply_chat_template(msgs, tokenize=False, add_generation_prompt=True)
15inp = tok(text, return_tensors="pt").to(model.device)
16out = model.generate(**inp, max_new_tokens=110, do_sample=False, repetition_penalty=1.3)
17print(tok.decode(out[0][inp.input_ids.shape[1]:], skip_special_tokens=True))