--- license: apache-2.0 language: - en tags: - qwen - qwen3 - unsloth - decision-making - strategic-analysis - cognitive-architecture - chat - philosophy-driven-ai pipeline_tag: text-generation base_model: - Qwen/Qwen3-1.7B datasets: - ABDALLALSWAITI/flux_prompt --- --- ### Thanks mradermacher: For creating the GGUF versions of these models https://huggingface.co/mradermacher/Qwen3-1.7B-Flux-Prompt-GGUF https://huggingface.co/mradermacher/Qwen3-1.7B-Flux-Prompt-i1-GGUF --- # Qwen3-1.7B-Flux-Prompt **Turn simple words into professional Flux.1 image prompts instantly.** This is a fine-tuned version of **Qwen3-1.7B-Instruct**, specialized in expanding short concepts into detailed, high-quality descriptions optimized for **Flux.1** image generation models. ## ✨ Key Features * **🚀 Lightweight & Fast**: Based on the 1.7B model, it runs extremely fast even on older GPUs or CPU. * **🧠 "Invisible" System Prompt**: The specialized system prompt is **baked into the `tokenizer_config.json`**. You don't need to type complex instructions. Just input `a cat`, and it outputs the full prompt automatically. * **🎨 Non-Conversational**: It doesn't chat. It doesn't say "Here is your prompt". It only outputs the raw prompt, ready for your stable diffusion pipeline. * **✅ Validated Quality**: Tested thoroughly for diversity and detail (see examples below). --- ## 🖼️ Examples **Input:** `a sexy model at home bed` **Output (Generated by this model):** > a sexy model at home bed, close-up shot of a woman lying on a luxurious velvet bed with soft golden lighting, elegant floral decor, minimalist modern furniture, subtle candlelight flicker, realistic textures, sensual atmosphere, high-quality photography, dramatic shadows, and a calm yet intimate mood. --- ## 💻 How to Use ### Method 1: Python (Transformers) Since the system prompt is integrated, the usage is extremely simple: ```python from transformers import AutoModelForCausalLM, AutoTokenizer import torch model_name = "aifeifei798/Qwen3-1.7B-Flux-Prompt" # Replace with your actual repo name # Load the tokenizer and the model tokenizer = AutoTokenizer.from_pretrained(model_name) model = AutoModelForCausalLM.from_pretrained( model_name, torch_dtype="auto", device_map="auto" ) def generate_flux_prompt(prompt): messages = [{"role": "user", "content": prompt}] # Applying the template text = tokenizer.apply_chat_template( messages, tokenize=False, add_generation_prompt=True, # enable_thinking=False ) model_inputs = tokenizer([text], return_tensors="pt").to(model.device) # Generation with optimized parameters for Flux prompting generated_ids = model.generate( **model_inputs, max_new_tokens=512, # [Key] 512 tokens are sufficient for a detailed visual description. do_sample=True, # [Required] Enable sampling to allow for creative variations. temperature=0.7, # [Creativity] 0.7 offers a balance between imaginative detail and coherence. top_p=0.9, # [Focus] Nucleus sampling: filters out very unlikely words. top_k=50, # [Stability] Limits vocabulary to top 50 tokens to prevent hallucinations. repetition_penalty=1.15, # [Variety] Slight penalty to reduce repetitive phrases without breaking grammar. no_repeat_ngram_size=3, ) # Extracting the newly generated tokens only output_ids = generated_ids[0][len(model_inputs.input_ids[0]):].tolist() # Parsing logic to handle potential reasoning content (if using a reasoning-capable base model) # Looks for the token ID (usually 151668 in Qwen architecture) try: index = len(output_ids) - output_ids[::-1].index(151668) except ValueError: index = 0 # No thinking trace found, output starts from the beginning # Decode the final prompt # thinking_content = tokenizer.decode(output_ids[:index], skip_special_tokens=True).strip() content = tokenizer.decode(output_ids[index:], skip_special_tokens=True).strip() return content # Example Usage # if __name__ == "__main__": # user_input = "a sexy model at new york" # print(f"Input: {user_input}\n") # print(f"Generated Flux Prompt:\n{generate_flux_prompt(user_input)}") ``` --- ## 🔧 Training Details * **Base Model:** Qwen/Qwen3-1.7B-Instruct * **Dataset:** `flux_prompt` (Alpaca format) * **Fine-tuning Framework:** Unsloth * **Configuration:** * `temperature`: 0.7 (Recommended) * `repetition_penalty`: 1.05 - 1.1 (Recommended) --- ### 💡 Tips for Users * **Keep it Simple:** The model thrives on simple inputs like "a girl in rain" or "futuristic car". * **Sampling:** Always use `do_sample=True` with `temperature` around 0.7 to get diverse results every time you run it.