prompt 없애는게 낫다
Browse files
app.py
CHANGED
|
@@ -11,14 +11,18 @@ generator = pipeline(
|
|
| 11 |
device="cuda:0" if torch.cuda.is_available() else 'cpu'
|
| 12 |
)
|
| 13 |
|
| 14 |
-
def query(message, chat_history, max_turn=
|
| 15 |
-
prompt = [
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
]
|
|
|
|
| 19 |
if len(chat_history) > max_turn:
|
| 20 |
chat_history = chat_history[-max_turn:]
|
| 21 |
-
for user, bot in chat_history:
|
|
|
|
|
|
|
|
|
|
| 22 |
prompt.append(f"<usr> {user}")
|
| 23 |
prompt.append(f"<bot> {bot}")
|
| 24 |
prompt.append(f"<usr> {message}")
|
|
@@ -29,7 +33,7 @@ def query(message, chat_history, max_turn=4):
|
|
| 29 |
do_sample=True,
|
| 30 |
top_p=0.9,
|
| 31 |
early_stopping=True,
|
| 32 |
-
|
| 33 |
)[0]['generated_text']
|
| 34 |
|
| 35 |
print(output)
|
|
@@ -38,7 +42,7 @@ def query(message, chat_history, max_turn=4):
|
|
| 38 |
return response.strip()
|
| 39 |
|
| 40 |
with gr.Blocks() as demo:
|
| 41 |
-
chatbot = gr.Chatbot()
|
| 42 |
msg = gr.Textbox()
|
| 43 |
clear = gr.Button("Clear")
|
| 44 |
|
|
|
|
| 11 |
device="cuda:0" if torch.cuda.is_available() else 'cpu'
|
| 12 |
)
|
| 13 |
|
| 14 |
+
def query(message, chat_history, max_turn=2):
|
| 15 |
+
# prompt = [
|
| 16 |
+
# "<usr> 넌 한국어 챗봇 고라니야. 너는 내가 묻는 질문에 답하고 지시사항에 맞는 대답을 해야해.",
|
| 17 |
+
# "<bot> 네, 저는 한국어 챗봇 고라니입니다. 궁금한 것을 물어보세요. "
|
| 18 |
+
# ]
|
| 19 |
+
prompt = []
|
| 20 |
if len(chat_history) > max_turn:
|
| 21 |
chat_history = chat_history[-max_turn:]
|
| 22 |
+
for i, (user, bot) in enumerate(chat_history):
|
| 23 |
+
# if i == 0:
|
| 24 |
+
# prompt.append(f"<usr> 반가워 너는 한국어 챗봇이고 이름은 고라니야. {user}")
|
| 25 |
+
# else:
|
| 26 |
prompt.append(f"<usr> {user}")
|
| 27 |
prompt.append(f"<bot> {bot}")
|
| 28 |
prompt.append(f"<usr> {message}")
|
|
|
|
| 33 |
do_sample=True,
|
| 34 |
top_p=0.9,
|
| 35 |
early_stopping=True,
|
| 36 |
+
max_new_tokens=256,
|
| 37 |
)[0]['generated_text']
|
| 38 |
|
| 39 |
print(output)
|
|
|
|
| 42 |
return response.strip()
|
| 43 |
|
| 44 |
with gr.Blocks() as demo:
|
| 45 |
+
chatbot = gr.Chatbot().style(height=700)
|
| 46 |
msg = gr.Textbox()
|
| 47 |
clear = gr.Button("Clear")
|
| 48 |
|