Instructions to use gokaygokay/Flux-Prompt-Enhance with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use gokaygokay/Flux-Prompt-Enhance with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="gokaygokay/Flux-Prompt-Enhance")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSeq2SeqLM tokenizer = AutoTokenizer.from_pretrained("gokaygokay/Flux-Prompt-Enhance") model = AutoModelForSeq2SeqLM.from_pretrained("gokaygokay/Flux-Prompt-Enhance", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use gokaygokay/Flux-Prompt-Enhance with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "gokaygokay/Flux-Prompt-Enhance" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "gokaygokay/Flux-Prompt-Enhance", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/gokaygokay/Flux-Prompt-Enhance
- SGLang
How to use gokaygokay/Flux-Prompt-Enhance with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "gokaygokay/Flux-Prompt-Enhance" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "gokaygokay/Flux-Prompt-Enhance", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "gokaygokay/Flux-Prompt-Enhance" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "gokaygokay/Flux-Prompt-Enhance", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use gokaygokay/Flux-Prompt-Enhance with Docker Model Runner:
docker model run hf.co/gokaygokay/Flux-Prompt-Enhance
How to randomise the generated text for the same short prompt
#2
by sbgonenc96 - opened
Hi! It's a great and useful model!
However, I need to randomise the generated text for the same prompt for my use case.
Should I generate random float number for the repetition_penalty parameter for each repetition?
Thanks
import torch
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
device = "cuda" if torch.cuda.is_available() else "cpu"
# Model checkpoint
model_checkpoint = "gokaygokay/Flux-Prompt-Enhance"
# Tokenizer
tokenizer = AutoTokenizer.from_pretrained(model_checkpoint)
# Model
model = AutoModelForSeq2SeqLM.from_pretrained(model_checkpoint).to(device)
max_target_length = 256
prefix = "enhance prompt: "
def enhance_prompt(prompt, max_length=max_target_length):
# Set a random seed for this generation
seed = torch.randint(0, 2**32 - 1, (1,)).item()
torch.manual_seed(seed)
input_text = prefix + prompt
input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to(device)
outputs = model.generate(
input_ids,
max_length=max_length,
num_return_sequences=1,
do_sample=True,
temperature=0.7,
repetition_penalty=1.2
)
return seed, tokenizer.decode(outputs[0], skip_special_tokens=True)
short_prompt = "beautiful house with text 'hello'"
seed, final_answer = enhance_prompt(short_prompt)
print(f"Seed: {seed}")
print(final_answer)
You can add do_sample=True and make the temperature higher. Kolay gelsin. 👍