Spaces:
Sleeping
Sleeping
Commit
ยท
e05182e
1
Parent(s):
a545b17
add
Browse files
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=
|
| 16 |
)
|
| 17 |
return pipe
|
| 18 |
|
|
@@ -57,15 +57,21 @@ def main():
|
|
| 57 |
# ๋ชจ๋ธ ์์ฑ
|
| 58 |
response = pipe(
|
| 59 |
prompt,
|
| 60 |
-
max_new_tokens=
|
| 61 |
temperature=0.7,
|
| 62 |
do_sample=True,
|
| 63 |
-
truncation=True
|
|
|
|
| 64 |
)
|
| 65 |
bot_text = response[0]["generated_text"]
|
| 66 |
|
| 67 |
-
# Assistant ์๋ต๋ง ์ถ์ถ
|
| 68 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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)
|