Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -26,8 +26,8 @@ def smart_response(message, history):
|
|
| 26 |
|
| 27 |
if is_opinion:
|
| 28 |
print(f"🧠 OPINION MODE: {message}")
|
| 29 |
-
# DUAL FRAME PROMPT
|
| 30 |
-
# We
|
| 31 |
prompt = f"""Below is an instruction that describes a task. Write a response that appropriately completes the request.
|
| 32 |
|
| 33 |
### Instruction:
|
|
@@ -35,20 +35,25 @@ def smart_response(message, history):
|
|
| 35 |
|
| 36 |
### Response:
|
| 37 |
"""
|
| 38 |
-
# Added double newline to stop early if it tries to start a new header
|
| 39 |
-
stop_tokens = ["</s>", "###", "\n###"]
|
| 40 |
|
| 41 |
else:
|
| 42 |
print(f"ℹ️ CHAT MODE: {message}")
|
| 43 |
-
#
|
| 44 |
-
#
|
| 45 |
-
#
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
|
|
|
|
|
|
|
|
|
| 50 |
|
| 51 |
# --- GENERATION ---
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
output = llm(
|
| 53 |
prompt,
|
| 54 |
max_tokens=512,
|
|
|
|
| 26 |
|
| 27 |
if is_opinion:
|
| 28 |
print(f"🧠 OPINION MODE: {message}")
|
| 29 |
+
# DUAL FRAME PROMPT
|
| 30 |
+
# We use the standard instruction format the model learned during fine-tuning.
|
| 31 |
prompt = f"""Below is an instruction that describes a task. Write a response that appropriately completes the request.
|
| 32 |
|
| 33 |
### Instruction:
|
|
|
|
| 35 |
|
| 36 |
### Response:
|
| 37 |
"""
|
|
|
|
|
|
|
| 38 |
|
| 39 |
else:
|
| 40 |
print(f"ℹ️ CHAT MODE: {message}")
|
| 41 |
+
# FACTUAL PROMPT
|
| 42 |
+
# CRITICAL FIX: We use the SAME format (Alpaca), but we add a specific
|
| 43 |
+
# instruction telling the model to be "concise" and "factual".
|
| 44 |
+
prompt = f"""Below is an instruction that describes a task. Write a response that appropriately completes the request.
|
| 45 |
+
|
| 46 |
+
### Instruction:
|
| 47 |
+
You are a helpful assistant. Answer the following question concisely and directly: {message}
|
| 48 |
+
|
| 49 |
+
### Response:
|
| 50 |
+
"""
|
| 51 |
|
| 52 |
# --- GENERATION ---
|
| 53 |
+
# We add "###" to the stop tokens. This cuts off the model immediately
|
| 54 |
+
# if it tries to start generating "Solution 1" or a new "### Instruction".
|
| 55 |
+
stop_tokens = ["</s>", "###", "Solution"]
|
| 56 |
+
|
| 57 |
output = llm(
|
| 58 |
prompt,
|
| 59 |
max_tokens=512,
|