Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -53,31 +53,24 @@ def format_rules(rules):
|
|
53 |
return formatted_rules
|
54 |
|
55 |
def format_output(text):
|
56 |
-
|
57 |
-
|
|
|
58 |
|
59 |
display = ""
|
60 |
-
if think_match:
|
61 |
-
display += "Reasoning:\n" +
|
62 |
-
if
|
63 |
-
display += "
|
|
|
|
|
64 |
return display.strip() if display else text.strip()
|
65 |
|
66 |
|
67 |
-
|
68 |
def format_transcript(transcript):
|
69 |
formatted_transcript = f"<transcript>\n{transcript}\n</transcript>\n"
|
70 |
return formatted_transcript
|
71 |
|
72 |
-
def get_example(
|
73 |
-
dataset_path="tomg-group-umd/compliance_benchmark",
|
74 |
-
subset="compliance",
|
75 |
-
split="test_handcrafted",
|
76 |
-
example_idx=0,
|
77 |
-
):
|
78 |
-
dataset = load_dataset(dataset_path, subset, split=split)
|
79 |
-
example = dataset[example_idx]
|
80 |
-
return example[INPUT_FIELD]
|
81 |
|
82 |
def get_message(model, input, system_prompt=SYSTEM_PROMPT, enable_thinking=True):
|
83 |
message = model.apply_chat_template(system_prompt, input, enable_thinking=enable_thinking)
|
|
|
53 |
return formatted_rules
|
54 |
|
55 |
def format_output(text):
|
56 |
+
reasoning = re.search(r"<think>(.*?)</think>", text, flags=re.DOTALL)
|
57 |
+
answer = re.search(r"<answer>(.*?)</answer>", text, flags=re.DOTALL)
|
58 |
+
explanation = re.search(r"<explanation>(.*?)</explanation>", text, flags=re.DOTALL)
|
59 |
|
60 |
display = ""
|
61 |
+
if think_match and len(reasoning.group(1).strip()) > 1:
|
62 |
+
display += "Reasoning:\n" + reasoning.group(1).strip() + "\n\n"
|
63 |
+
if answer:
|
64 |
+
display += "Answer:\n" + answer.group(1).strip() + "\n\n"
|
65 |
+
if explanation and len(explanation.group(1).strip()) > 1:
|
66 |
+
display += "Explanation:\n" + explanation.group(1).strip() + "\n\n"
|
67 |
return display.strip() if display else text.strip()
|
68 |
|
69 |
|
|
|
70 |
def format_transcript(transcript):
|
71 |
formatted_transcript = f"<transcript>\n{transcript}\n</transcript>\n"
|
72 |
return formatted_transcript
|
73 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
|
75 |
def get_message(model, input, system_prompt=SYSTEM_PROMPT, enable_thinking=True):
|
76 |
message = model.apply_chat_template(system_prompt, input, enable_thinking=enable_thinking)
|