SimrusDenuvo commited on
Commit
ff077e4
·
verified ·
1 Parent(s): 240efaf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -14
app.py CHANGED
@@ -6,8 +6,8 @@ from transformers import pipeline
6
  models = {
7
  "ChatGPT-like": pipeline(
8
  "text-generation",
9
- model="OpenAssistant/oasst-sft-4-pythia-12b-epoch-3.5",
10
- tokenizer="OpenAssistant/oasst-sft-4-pythia-12b-epoch-3.5",
11
  device=-1
12
  ),
13
  "DeepSeek-like": pipeline(
@@ -32,27 +32,28 @@ def build_cot_prompt(user_input):
32
  return (
33
  f"Клиент: {user_input}\n"
34
  "Проанализируй обращение пошагово:\n"
35
- "1. В чём суть проблемы?\n"
36
  "2. Возможные причины?\n"
37
- "3. Решение?\n"
38
  "Вывод: категория обращения:"
39
  )
40
 
41
- # Генерация ответов
42
  def generate_classification(user_input):
43
  prompt_simple = build_simple_prompt(user_input)
44
  prompt_cot = build_cot_prompt(user_input)
45
 
46
  results = {}
 
47
  for name, pipe in models.items():
48
  # CoT
49
  start_cot = time.time()
50
- cot_out = pipe(prompt_cot, max_new_tokens=150, do_sample=True, top_p=0.9, temperature=0.7)[0]["generated_text"]
51
  time_cot = round(time.time() - start_cot, 2)
52
 
53
  # Simple
54
  start_simple = time.time()
55
- simple_out = pipe(prompt_simple, max_new_tokens=80, do_sample=True, top_p=0.9, temperature=0.7)[0]["generated_text"]
56
  time_simple = round(time.time() - start_simple, 2)
57
 
58
  results[name] = {
@@ -73,27 +74,27 @@ def generate_classification(user_input):
73
 
74
  # Интерфейс
75
  with gr.Blocks() as demo:
76
- gr.Markdown("## 🤖 Сравнение моделей: ChatGPT, DeepSeek, GigaChat классификация банковских обращений")
77
 
78
- inp = gr.Textbox(label="Вопрос клиента", placeholder="Например: Я не могу перевести деньги", lines=2)
79
  btn = gr.Button("Сгенерировать")
80
 
81
- # ChatGPT
82
- gr.Markdown("### ChatGPT-like (OpenAssistant)")
83
  cot1 = gr.Textbox(label="CoT ответ")
84
  cot1_time = gr.Textbox(label="Время CoT")
85
  simple1 = gr.Textbox(label="Обычный ответ")
86
  simple1_time = gr.Textbox(label="Время обычного")
87
 
88
- # DeepSeek
89
  gr.Markdown("### DeepSeek-like")
90
  cot2 = gr.Textbox(label="CoT ответ")
91
  cot2_time = gr.Textbox(label="Время CoT")
92
  simple2 = gr.Textbox(label="Обычный ответ")
93
  simple2_time = gr.Textbox(label="Время обычного")
94
 
95
- # GigaChat
96
- gr.Markdown("### GigaChat-like (ruDialoGPT)")
97
  cot3 = gr.Textbox(label="CoT ответ")
98
  cot3_time = gr.Textbox(label="Время CoT")
99
  simple3 = gr.Textbox(label="Обычный ответ")
 
6
  models = {
7
  "ChatGPT-like": pipeline(
8
  "text-generation",
9
+ model="tiiuae/falcon-rw-1b",
10
+ tokenizer="tiiuae/falcon-rw-1b",
11
  device=-1
12
  ),
13
  "DeepSeek-like": pipeline(
 
32
  return (
33
  f"Клиент: {user_input}\n"
34
  "Проанализируй обращение пошагово:\n"
35
+ "1. В чём проблема?\n"
36
  "2. Возможные причины?\n"
37
+ "3. Как решить?\n"
38
  "Вывод: категория обращения:"
39
  )
40
 
41
+ # Генерация
42
  def generate_classification(user_input):
43
  prompt_simple = build_simple_prompt(user_input)
44
  prompt_cot = build_cot_prompt(user_input)
45
 
46
  results = {}
47
+
48
  for name, pipe in models.items():
49
  # CoT
50
  start_cot = time.time()
51
+ cot_out = pipe(prompt_cot, max_new_tokens=120, do_sample=True, top_p=0.9, temperature=0.7)[0]["generated_text"]
52
  time_cot = round(time.time() - start_cot, 2)
53
 
54
  # Simple
55
  start_simple = time.time()
56
+ simple_out = pipe(prompt_simple, max_new_tokens=60, do_sample=True, top_p=0.9, temperature=0.7)[0]["generated_text"]
57
  time_simple = round(time.time() - start_simple, 2)
58
 
59
  results[name] = {
 
74
 
75
  # Интерфейс
76
  with gr.Blocks() as demo:
77
+ gr.Markdown("## 🏦 Сравнение моделей: ChatGPT, DeepSeek, GigaChat (банковская классификация)")
78
 
79
+ inp = gr.Textbox(label="Вопрос клиента", placeholder="Например: Я не могу войти в личный кабинет", lines=2)
80
  btn = gr.Button("Сгенерировать")
81
 
82
+ # ChatGPT-like
83
+ gr.Markdown("### ChatGPT-like (Falcon RW 1B)")
84
  cot1 = gr.Textbox(label="CoT ответ")
85
  cot1_time = gr.Textbox(label="Время CoT")
86
  simple1 = gr.Textbox(label="Обычный ответ")
87
  simple1_time = gr.Textbox(label="Время обычного")
88
 
89
+ # DeepSeek-like
90
  gr.Markdown("### DeepSeek-like")
91
  cot2 = gr.Textbox(label="CoT ответ")
92
  cot2_time = gr.Textbox(label="Время CoT")
93
  simple2 = gr.Textbox(label="Обычный ответ")
94
  simple2_time = gr.Textbox(label="Время обычного")
95
 
96
+ # GigaChat-like
97
+ gr.Markdown("### GigaChat-like (ruDialoGPT-medium)")
98
  cot3 = gr.Textbox(label="CoT ответ")
99
  cot3_time = gr.Textbox(label="Время CoT")
100
  simple3 = gr.Textbox(label="Обычный ответ")