multimodalart HF Staff commited on
Commit
9324ec7
·
verified ·
1 Parent(s): 3b644da

Improve output formatting: strip repeated expression, show clean answer

Browse files
Files changed (1) hide show
  1. app.py +13 -5
app.py CHANGED
@@ -376,13 +376,21 @@ def solve(
376
  completion = strip_after_stop_text(completion, stop_strings)
377
  completion = completion.strip()
378
 
379
- # Build a nice display: show the expression + completion
380
- if use_no_think:
381
- display = f"**Prompt (no-think template):**\n```\n{prompt}\n```\n\n**Model output:**\n```\n{completion}\n```"
 
 
382
  else:
383
- display = f"**Prompt:** `{prompt}`\n\n**Model output:** `{completion}`"
 
 
 
384
 
385
- full_display = f"{expression.strip()} {completion}".strip()
 
 
 
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