eslamirad commited on
Commit
fa5e4da
·
verified ·
1 Parent(s): eeca8d3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
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-14B-Instruct-1M"
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 14B Chatbot",
28
- description="یک چت‌بات مبتنی بر مدل Qwen/Qwen2.5-14B-Instruct-1M",
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()