A full-parameter SFT of
Qwen/Qwen3-4B-Instruct-2507 on
flammenai/flame-kindling-v1 for creative roleplay and character interaction.
1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer
3
4MODEL_ID = "Pranavz/qwen-4b-2507-rp-mahou"
5
6tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
7model = AutoModelForCausalLM.from_pretrained(
8 MODEL_ID,
9 torch_dtype=torch.bfloat16,
10 device_map="auto",
11)
12
13messages = [
14 {"role": "system", "content": "You are a creative roleplay assistant. Stay in character, write vividly, and use asterisks for actions."},
15 {"role": "user", "content": "*walks into the tavern, shaking off the rain* Evening, barkeep. Got a room?"},
16]
17
18text = tokenizer.apply_chat_template(
19 messages,
20 tokenize=False,
21 add_generation_prompt=True,
22 enable_thinking=False,
23)
24inputs = tokenizer(text, return_tensors="pt").to(model.device)
25
26with torch.inference_mode():
27 out = model.generate(
28 **inputs,
29 max_new_tokens=512,
30 temperature=0.8,
31 top_p=0.9,
32 top_k=40,
33 repetition_penalty=1.1,
34 do_sample=True,
35 )
36
37print(tokenizer.decode(out[0][inputs.input_ids.shape[1]:], skip_special_tokens=True))