Views
No views yet
1from transformers import AutoTokenizer, AutoModelForCausalLM
2
3model = AutoModelForCausalLM.from_pretrained("shb777/PromptTuner-v0.1")
4tokenizer = AutoTokenizer.from_pretrained("shb777/PromptTuner-v0.1")
5
6SYSTEM_PROMPT = """You are an expert creative director specializing in visual descriptions for image generation.
7
8Your task: Transform the user's concept into a rich, detailed image description while PRESERVING their core idea.
9
10IMPORTANT RULES:
111. Keep ALL key elements (intents, entities) from the original concept
122. Enhance with artistic details, NOT change the fundamental idea
133. Maintain the user's intended subject, action, and setting
14
15You should elaborate on:
16- Visual composition and perspective
17- Artistic style (photorealistic, impressionist, etc.)
18- Color palette and color temperature
19- Lighting (golden hour, dramatic shadows, etc.)
20- Atmosphere and mood
21- Textures and materials
22- Technical details (medium, brushwork, rendering style)
23- Environmental context (time of day, weather, season, era)
24- Level of detail and focus points
25
26Output format: A single, flowing paragraph that reads naturally as an image prompt."""
27
28user_input = "fox, red tail, blue moon, clouds"
29
30messages = [
31 {"role": "system", "content": SYSTEM_PROMPT},
32 {"role": "user", "content": user_input}
33]
34
35prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
36inputs = tokenizer(prompt, return_tensors="pt")
37
38outputs = model.generate(
39 **inputs,
40 max_new_tokens=512,
41 temperature=1.0,
42 top_p=0.95,
43 top_k=64
44)
45
46enhanced_prompt = tokenizer.decode(outputs[0], skip_special_tokens=True)
47print(enhanced_prompt)[!NOTE] You must use the exact system prompt shown above, as the model was trained on it.
max_new_tokens: 512temperature: 1.0top_p: 0.95top_k: 641@model{prompt_tuner_v0.1,
2 title={PromptTuner-v0.1: A Fine-tuned Gemma3-270M for Prompt Enhancement},
3 author={shb777},
4 year={2025},
5 url={https://huggingface.co/shb777/PromptTuner-v0.1}
6}