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 "google/gemma3-27b",
8 torch_dtype=torch.float16,
9 device_map="auto"
10)
11model = PeftModel.from_pretrained(base_model, "CromonHarry/gemma3-27b-think-creativity")
12tokenizer = AutoTokenizer.from_pretrained("CromonHarry/gemma3-27b-think-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 creativity score with following format:
19Creativity score: [A float score from 1 to 5]
20
21### Input:
22Story summary: {your_story_here}
23
24### Response:
25'''
26
27inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
28outputs = model.generate(**inputs, max_new_tokens=256, temperature=0.7)
29print(tokenizer.decode(outputs[0], skip_special_tokens=True))