CoolFace
Apppublic

ckdeveloper/llm

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
app.py16 linesDownload Raw Back to root
1import gradio as gr2from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline3 4model_id = "Qwen/Qwen2.5-Coder-3B"5tokenizer = AutoTokenizer.from_pretrained(model_id)6model = AutoModelForCausalLM.from_pretrained(model_id)7 8pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)9 10def code_agent(prompt):11    output = pipe(prompt, max_new_tokens=256, do_sample=True, temperature=0.2)12    return output[0]["generated_text"]13 14demo = gr.Interface(fn=code_agent, inputs="text", outputs="text")15demo.launch()16