Update app.py
Browse files
app.py
CHANGED
@@ -2,7 +2,7 @@ import gradio as gr
|
|
2 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
3 |
import torch
|
4 |
|
5 |
-
MODEL_NAME = "Qwen/Qwen2.5-
|
6 |
|
7 |
# بارگذاری مدل و توکنایزر
|
8 |
tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
|
@@ -12,7 +12,7 @@ model = AutoModelForCausalLM.from_pretrained(
|
|
12 |
device_map="auto"
|
13 |
)
|
14 |
|
15 |
-
# تابع
|
16 |
def chat_with_qwen(prompt):
|
17 |
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
|
18 |
output = model.generate(**inputs, max_new_tokens=200)
|
@@ -22,10 +22,10 @@ def chat_with_qwen(prompt):
|
|
22 |
# ایجاد رابط کاربری با Gradio
|
23 |
iface = gr.Interface(
|
24 |
fn=chat_with_qwen,
|
25 |
-
inputs=gr.Textbox(lines=2, placeholder="سوال خود را اینجا
|
26 |
outputs="text",
|
27 |
-
title="Qwen 2.5
|
28 |
-
description="
|
29 |
)
|
30 |
|
31 |
-
iface.launch()
|
|
|
2 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
3 |
import torch
|
4 |
|
5 |
+
MODEL_NAME = "Qwen/Qwen2.5-7B-Instruct"
|
6 |
|
7 |
# بارگذاری مدل و توکنایزر
|
8 |
tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
|
|
|
12 |
device_map="auto"
|
13 |
)
|
14 |
|
15 |
+
# تابع چتبات
|
16 |
def chat_with_qwen(prompt):
|
17 |
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
|
18 |
output = model.generate(**inputs, max_new_tokens=200)
|
|
|
22 |
# ایجاد رابط کاربری با Gradio
|
23 |
iface = gr.Interface(
|
24 |
fn=chat_with_qwen,
|
25 |
+
inputs=gr.Textbox(lines=2, placeholder="سوال خود را اینجا بنویسید..."),
|
26 |
outputs="text",
|
27 |
+
title="Qwen 2.5 7B Chatbot",
|
28 |
+
description="چتبات مبتنی بر مدل Qwen2.5-7B-Instruct",
|
29 |
)
|
30 |
|
31 |
+
iface.launch()
|