Views
No views yet
1from transformers import AutoTokenizer, AutoModelForCausalLM
2from peft import PeftModel
3import torch
4
5# Load models
6base_model = AutoModelForCausalLM.from_pretrained(
7 "Qwen/qwen3-8b",
8 torch_dtype=torch.float16,
9 device_map="auto"
10)
11model = PeftModel.from_pretrained(base_model, "CromonHarry/qwen3-8b-creativity")
12tokenizer = AutoTokenizer.from_pretrained("CromonHarry/qwen3-8b-creativity")
13
14# Evaluate a story
15prompt = '''Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
16
17### Instruction:
18Evaluate the creativity of the following story. You need to output the following format:
19[Your review]
20Creativity score: [A float score from 1 to 5]
21
22### Input:
23{your_story_here}
24
25### Response:
26'''
27
28inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
29outputs = model.generate(**inputs, max_new_tokens=256, temperature=0.7)
30print(tokenizer.decode(outputs[0], skip_special_tokens=True))