yokesh-da
commited on
Commit
•
3dde812
1
Parent(s):
2e8b356
Add application file and dependencies
Browse files- app.py +15 -0
- requirements.txt +3 -1
app.py
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
3 |
+
|
4 |
+
model_name = "Qwen/Qwen2.5-Coder-32B"
|
5 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
6 |
+
model = AutoModelForCausalLM.from_pretrained(model_name)
|
7 |
+
|
8 |
+
def generate_response(input_text):
|
9 |
+
inputs = tokenizer(input_text, return_tensors="pt")
|
10 |
+
outputs = model.generate(**inputs)
|
11 |
+
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
12 |
+
return response
|
13 |
+
|
14 |
+
demo = gr.Interface(fn=generate_response, inputs="text", outputs="text")
|
15 |
+
demo.launch()
|
requirements.txt
CHANGED
@@ -1 +1,3 @@
|
|
1 |
-
|
|
|
|
|
|
1 |
+
transformers
|
2 |
+
torch
|
3 |
+
gradio
|