widefirst103 commited on
Commit
4ce373c
Β·
verified Β·
1 Parent(s): fb9d94d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -10
app.py CHANGED
@@ -1,22 +1,21 @@
1
  from transformers import pipeline
2
  import gradio as gr
3
 
4
- # KoAlpaca λͺ¨λΈ λ‘œλ“œ (속도와 ν’ˆμ§ˆμ˜ 밸런슀)
5
  generator = pipeline(
6
  "text-generation",
7
- model="beomi/KoAlpaca-Polyglot-1.1B",
8
- tokenizer="beomi/KoAlpaca-Polyglot-1.1B",
9
- device_map="auto"
10
  )
11
 
12
  def answer_question(prompt):
13
  system_prompt = (
14
- "λ„ˆλŠ” ν•œκ΅­ λŒ€ν•™ μž…μ‹œ 정보λ₯Ό μ•Œλ €μ£ΌλŠ” AIμ•Ό. "
15
- "수λŠ₯, 학생뢀쒅합, λ…Όμˆ , μ •μ‹œ λ“± μ „ν˜•μ„ μ΄ν•΄ν•˜κΈ° μ‰½κ²Œ μ„€λͺ…ν•΄μ€˜.\n\n"
16
  )
17
  response = generator(
18
  system_prompt + prompt,
19
- max_new_tokens=250,
20
  temperature=0.7,
21
  top_p=0.9,
22
  do_sample=True
@@ -28,11 +27,11 @@ app = gr.Interface(
28
  inputs=gr.Textbox(
29
  lines=2,
30
  label="μž…μ‹œ 질문 μž…λ ₯",
31
- placeholder="예: κ°€μ²œλŒ€ λ…Όμˆ μ „ν˜• / 2025 수λŠ₯ 일정 / ν•œκ΅­κ³΅ν•™λŒ€ μ „ν˜•μš”μ•½"
32
  ),
33
  outputs=gr.Textbox(label="AI λ‹΅λ³€"),
34
- title="μž…μ‹œ μ „λ¬Έ AI (KoAlpaca 1.1B)",
35
- description="λΉ λ₯΄κ³  λ˜‘λ˜‘ν•œ μž…μ‹œμ •λ³΄ μ±—λ΄‡μž…λ‹ˆλ‹€. μ‹€μ œ μ „ν˜•μ •λ³΄μ— κ·Όκ±°ν•œ μ„€λͺ…을 μ œκ³΅ν•©λ‹ˆλ‹€."
36
  )
37
 
38
  if __name__ == "__main__":
 
1
  from transformers import pipeline
2
  import gradio as gr
3
 
4
+ # λΉ λ₯Έ ν•œκ΅­μ–΄ GPT-2 λͺ¨λΈ λ‘œλ“œ
5
  generator = pipeline(
6
  "text-generation",
7
+ model="skt/kogpt2-base-v2",
8
+ tokenizer="skt/kogpt2-base-v2"
 
9
  )
10
 
11
  def answer_question(prompt):
12
  system_prompt = (
13
+ "λ„ˆλŠ” ν•œκ΅­ μž…μ‹œμ •λ³΄λ₯Ό μ•Œλ €μ£ΌλŠ” AIμ•Ό. "
14
+ "μ§ˆλ¬Έμ— 맞게 간단λͺ…λ£Œν•˜κ²Œ μ„€λͺ…ν•΄μ€˜.\n\n"
15
  )
16
  response = generator(
17
  system_prompt + prompt,
18
+ max_new_tokens=150,
19
  temperature=0.7,
20
  top_p=0.9,
21
  do_sample=True
 
27
  inputs=gr.Textbox(
28
  lines=2,
29
  label="μž…μ‹œ 질문 μž…λ ₯",
30
+ placeholder="예: 수λŠ₯ 일정 / ν•œκ΅­κ³΅ν•™λŒ€ λ…Όμˆ μ „ν˜• / κ°€μ²œλŒ€ λͺ¨μ§‘인원"
31
  ),
32
  outputs=gr.Textbox(label="AI λ‹΅λ³€"),
33
+ title="μž…μ‹œμ •λ³΄ AI (λΉ λ₯Έ 버전)",
34
+ description="CPUμ—μ„œλ„ λΉ λ₯΄κ²Œ μž‘λ™ν•˜λŠ” μž…μ‹œμ „λ¬Έ μ±—λ΄‡μž…λ‹ˆλ‹€."
35
  )
36
 
37
  if __name__ == "__main__":