Spaces:
Running on Zero
Running on Zero
Improve output formatting: strip repeated expression, show clean answer
Browse files
app.py
CHANGED
|
@@ -376,13 +376,21 @@ def solve(
|
|
| 376 |
completion = strip_after_stop_text(completion, stop_strings)
|
| 377 |
completion = completion.strip()
|
| 378 |
|
| 379 |
-
#
|
| 380 |
-
|
| 381 |
-
|
|
|
|
|
|
|
| 382 |
else:
|
| 383 |
-
|
|
|
|
|
|
|
|
|
|
| 384 |
|
| 385 |
-
|
|
|
|
|
|
|
|
|
|
| 386 |
|
| 387 |
return full_display, display
|
| 388 |
|
|
|
|
| 376 |
completion = strip_after_stop_text(completion, stop_strings)
|
| 377 |
completion = completion.strip()
|
| 378 |
|
| 379 |
+
# The model often repeats the input expression in its output.
|
| 380 |
+
# If the completion starts with the expression, extract just the answer.
|
| 381 |
+
expr_stripped = expression.strip()
|
| 382 |
+
if completion.startswith(expr_stripped):
|
| 383 |
+
answer = completion[len(expr_stripped):].strip()
|
| 384 |
else:
|
| 385 |
+
answer = completion
|
| 386 |
+
|
| 387 |
+
# Build the result display
|
| 388 |
+
full_display = f"{expr_stripped} {answer}".strip()
|
| 389 |
|
| 390 |
+
if use_no_think:
|
| 391 |
+
display = f"**Prompt (no-think template):**\n```\n{prompt}\n```\n\n**Model output:**\n```\n{completion}\n```\n\n**Answer:** `{answer}`"
|
| 392 |
+
else:
|
| 393 |
+
display = f"**Prompt:** `{prompt}`\n\n**Model output:** `{completion}`\n\n**Answer:** `{answer}`"
|
| 394 |
|
| 395 |
return full_display, display
|
| 396 |
|