blockenters commited on
Commit
e05182e
Β·
1 Parent(s): a545b17
Files changed (1) hide show
  1. app.py +11 -5
app.py CHANGED
@@ -12,7 +12,7 @@ def load_model(model_name="deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B"):
12
  torch_dtype=torch.float16,
13
  trust_remote_code=True,
14
  truncation=True,
15
- max_new_tokens=512
16
  )
17
  return pipe
18
 
@@ -57,15 +57,21 @@ def main():
57
  # λͺ¨λΈ 생성
58
  response = pipe(
59
  prompt,
60
- max_new_tokens=512,
61
  temperature=0.7,
62
  do_sample=True,
63
- truncation=True
 
64
  )
65
  bot_text = response[0]["generated_text"]
66
 
67
- # Assistant μ‘λ‹΅λ§Œ μΆ”μΆœ
68
- bot_text = bot_text.split("Assistant:")[-1].strip()
 
 
 
 
 
69
 
70
  # μ„Έμ…˜ μŠ€ν…Œμ΄νŠΈμ— λŒ€ν™” λ‚΄μš© μ—…λ°μ΄νŠΈ
71
  st.session_state["past_user_inputs"].append(user_input)
 
12
  torch_dtype=torch.float16,
13
  trust_remote_code=True,
14
  truncation=True,
15
+ max_new_tokens=2048
16
  )
17
  return pipe
18
 
 
57
  # λͺ¨λΈ 생성
58
  response = pipe(
59
  prompt,
60
+ max_new_tokens=2048,
61
  temperature=0.7,
62
  do_sample=True,
63
+ truncation=True,
64
+ pad_token_id=50256
65
  )
66
  bot_text = response[0]["generated_text"]
67
 
68
+ # Assistant μ‘λ‹΅λ§Œ μΆ”μΆœ (κ°œμ„ λœ 방식)
69
+ try:
70
+ bot_text = bot_text.split("Assistant:")[-1].strip()
71
+ if "</think>" in bot_text: # λ‚΄λΆ€ 사고 κ³Όμ • 제거
72
+ bot_text = bot_text.split("</think>")[-1].strip()
73
+ except:
74
+ bot_text = "μ£„μ†‘ν•©λ‹ˆλ‹€. 응닡을 μƒμ„±ν•˜λŠ” 데 λ¬Έμ œκ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€."
75
 
76
  # μ„Έμ…˜ μŠ€ν…Œμ΄νŠΈμ— λŒ€ν™” λ‚΄μš© μ—…λ°μ΄νŠΈ
77
  st.session_state["past_user_inputs"].append(user_input)