orgoflu commited on
Commit
dfdac42
ยท
verified ยท
1 Parent(s): af6f11c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -10
app.py CHANGED
@@ -12,15 +12,15 @@ import re
12
  import torch
13
  from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
14
 
15
- # ===== ์ง€์› ๋ชจ๋ธ ๋ชฉ๋ก =====
16
  MODEL_OPTIONS = {
17
- "Qwen2.5-1.5B-Instruct (ํ’ˆ์งˆโ†‘, ๋А๋ฆผ)": "Qwen/Qwen2.5-1.5B-Instruct",
18
- "Qwen2.5-0.5B-Instruct (๋น ๋ฆ„, ๊ฒฝ๋Ÿ‰)": "Qwen/Qwen2.5-0.5B-Instruct",
19
- "Phi-3-Mini-4K-Instruct (๋น ๋ฆ„, ๊ฒฝ๋Ÿ‰)": "microsoft/Phi-3-mini-4k-instruct",
20
- "Mistral-7B-Instruct-v0.3": "mistralai/Mistral-7B-Instruct-v0.3"
21
  }
22
 
23
- # ===== ๋ชจ๋ธ ๋กœ๋“œ ํ•จ์ˆ˜ =====
24
  def load_model(model_name):
25
  tokenizer = AutoTokenizer.from_pretrained(model_name)
26
  model = AutoModelForCausalLM.from_pretrained(
@@ -42,7 +42,7 @@ def remove_duplicates(sentences):
42
  result.append(s_clean)
43
  return result
44
 
45
- # ===== ์ž๋™์š”์•ฝ (TextRank) =====
46
  def summarize_text(text):
47
  text = clean_text(text)
48
  length = len(text)
@@ -75,7 +75,7 @@ def summarize_text(text):
75
  summary_list.sort(key=lambda s: text.find(s))
76
  return summary_list
77
 
78
- # ===== LLM ์ž๋™์žฌ์ž‘์„ฑ =====
79
  def rewrite_with_llm(sentences, model_choice):
80
  model_name = MODEL_OPTIONS[model_choice]
81
  llm_pipeline = load_model(model_name)
@@ -129,14 +129,14 @@ iface = gr.Interface(
129
  fn=extract_summarize_paraphrase,
130
  inputs=[
131
  gr.Textbox(label="URL ์ž…๋ ฅ", placeholder="https://example.com"),
132
- gr.Dropdown(choices=list(MODEL_OPTIONS.keys()), value="Qwen2.5-0.5B-Instruct (๋น ๋ฆ„, ๊ฒฝ๋Ÿ‰)", label="์žฌ์ž‘์„ฑ ๋ชจ๋ธ ์„ ํƒ")
133
  ],
134
  outputs=[
135
  gr.Markdown(label="์ถ”์ถœ๋œ ๋ณธ๋ฌธ"),
136
  gr.Textbox(label="์ž๋™ ์š”์•ฝ", lines=5),
137
  gr.Textbox(label="์ž๋™ ์žฌ์ž‘์„ฑ (LLM)", lines=5)
138
  ],
139
- title="ํ•œ๊ตญ์–ด ๋ณธ๋ฌธ ์ถ”์ถœ + ์ž๋™ ์š”์•ฝ + LLM ์žฌ์ž‘์„ฑ (๋ชจ๋ธ ์„ ํƒ ๊ฐ€๋Šฅ)",
140
  description="๋ณธ๋ฌธ์€ TextRank๋กœ ์š”์•ฝํ•˜๊ณ , ์žฌ์ž‘์„ฑ์€ ์„ ํƒํ•œ Hugging Face Hub LLM์œผ๋กœ ์ฒ˜๋ฆฌํ•ฉ๋‹ˆ๋‹ค."
141
  )
142
 
 
12
  import torch
13
  from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
14
 
15
+ # ===== ๋น„๊ต์šฉ ๋ชจ๋ธ ๋ชฉ๋ก =====
16
  MODEL_OPTIONS = {
17
+ "Qwen2.5-1.5B-Instruct (๊ธฐ๋ณธ)": "Qwen/Qwen2.5-1.5B-Instruct",
18
+ "DeepSeek-R1-Distill-Qwen-1.5B": "deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B",
19
+ "SOLAR-1.5B-Instruct": "upstage/SOLAR-1.5B-Instruct",
20
+ "Gemma-2-2B-it": "google/gemma-2-2b-it"
21
  }
22
 
23
+ # ===== ๋ชจ๋ธ ๋กœ๋“œ =====
24
  def load_model(model_name):
25
  tokenizer = AutoTokenizer.from_pretrained(model_name)
26
  model = AutoModelForCausalLM.from_pretrained(
 
42
  result.append(s_clean)
43
  return result
44
 
45
+ # ===== ์ž๋™์š”์•ฝ =====
46
  def summarize_text(text):
47
  text = clean_text(text)
48
  length = len(text)
 
75
  summary_list.sort(key=lambda s: text.find(s))
76
  return summary_list
77
 
78
+ # ===== LLM ์žฌ์ž‘์„ฑ =====
79
  def rewrite_with_llm(sentences, model_choice):
80
  model_name = MODEL_OPTIONS[model_choice]
81
  llm_pipeline = load_model(model_name)
 
129
  fn=extract_summarize_paraphrase,
130
  inputs=[
131
  gr.Textbox(label="URL ์ž…๋ ฅ", placeholder="https://example.com"),
132
+ gr.Dropdown(choices=list(MODEL_OPTIONS.keys()), value="Qwen2.5-1.5B-Instruct (๊ธฐ๋ณธ)", label="์žฌ์ž‘์„ฑ ๋ชจ๋ธ ์„ ํƒ")
133
  ],
134
  outputs=[
135
  gr.Markdown(label="์ถ”์ถœ๋œ ๋ณธ๋ฌธ"),
136
  gr.Textbox(label="์ž๋™ ์š”์•ฝ", lines=5),
137
  gr.Textbox(label="์ž๋™ ์žฌ์ž‘์„ฑ (LLM)", lines=5)
138
  ],
139
+ title="ํ•œ๊ตญ์–ด ๋ณธ๋ฌธ ์ถ”์ถœ + ์ž๋™ ์š”์•ฝ + LLM ์žฌ์ž‘์„ฑ (๋ชจ๋ธ ๋น„๊ต)",
140
  description="๋ณธ๋ฌธ์€ TextRank๋กœ ์š”์•ฝํ•˜๊ณ , ์žฌ์ž‘์„ฑ์€ ์„ ํƒํ•œ Hugging Face Hub LLM์œผ๋กœ ์ฒ˜๋ฆฌํ•ฉ๋‹ˆ๋‹ค."
141
  )
142