File size: 926 Bytes
2a48d1e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from transformers import AutoTokenizer, AutoModelForCausalLM
import gradio as gr

# Load tokenizer and model
tokenizer = AutoTokenizer.from_pretrained("AiCloser/Qwen2.5-32B-AGI")
model = AutoModelForCausalLM.from_pretrained(
    "AiCloser/Qwen2.5-32B-AGI",
    device_map="auto",
    torch_dtype="auto",
    resume_download=True  # Allow resumable downloads
)

# Define text generation function
def generate_text(prompt):
    inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
    outputs = model.generate(**inputs, max_length=200)
    return tokenizer.decode(outputs[0], skip_special_tokens=True)

# Create Gradio interface
interface = gr.Interface(
    fn=generate_text,
    inputs="text",
    outputs="text",
    title="Qwen 2.5-32B Text Generator",
    description="Generate text using the Qwen2.5-32B-AGI model. Enter a prompt below."
)

# Launch interface
if __name__ == "__main__":
    interface.launch()