Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -12,7 +12,7 @@ generator = pipeline(
|
|
| 12 |
dtype=torch.bfloat16
|
| 13 |
)
|
| 14 |
|
| 15 |
-
def generate_with_chat_template(messages, max_new_tokens=
|
| 16 |
"""
|
| 17 |
Applies the model's chat template to structure the prompts properly,
|
| 18 |
preventing prompt injection or completion confusion.
|
|
@@ -78,7 +78,7 @@ def tot_search(problem: str, branches: int = 3, max_depth: int = 3) -> str:
|
|
| 78 |
|
| 79 |
outputs = generate_with_chat_template(
|
| 80 |
messages,
|
| 81 |
-
max_new_tokens=
|
| 82 |
do_sample=True,
|
| 83 |
temperature=0.7,
|
| 84 |
num_return_sequences=branches
|
|
@@ -104,7 +104,7 @@ def tot_search(problem: str, branches: int = 3, max_depth: int = 3) -> str:
|
|
| 104 |
}
|
| 105 |
]
|
| 106 |
|
| 107 |
-
eval_outs = generate_with_chat_template(eval_messages, max_new_tokens=
|
| 108 |
eval_text = eval_outs[0].lower()
|
| 109 |
stats["nodes_evaluated"] += 1
|
| 110 |
|
|
@@ -164,7 +164,7 @@ def tot_search(problem: str, branches: int = 3, max_depth: int = 3) -> str:
|
|
| 164 |
}
|
| 165 |
]
|
| 166 |
|
| 167 |
-
final_outs = generate_with_chat_template(final_messages, max_new_tokens=
|
| 168 |
final_response = final_outs[0]
|
| 169 |
|
| 170 |
# Strip everything down to get just the clean answer
|
|
|
|
| 12 |
dtype=torch.bfloat16
|
| 13 |
)
|
| 14 |
|
| 15 |
+
def generate_with_chat_template(messages, max_new_tokens=1536, do_sample=True, temperature=0.7, num_return_sequences=1):
|
| 16 |
"""
|
| 17 |
Applies the model's chat template to structure the prompts properly,
|
| 18 |
preventing prompt injection or completion confusion.
|
|
|
|
| 78 |
|
| 79 |
outputs = generate_with_chat_template(
|
| 80 |
messages,
|
| 81 |
+
max_new_tokens=1536,
|
| 82 |
do_sample=True,
|
| 83 |
temperature=0.7,
|
| 84 |
num_return_sequences=branches
|
|
|
|
| 104 |
}
|
| 105 |
]
|
| 106 |
|
| 107 |
+
eval_outs = generate_with_chat_template(eval_messages, max_new_tokens=1536, do_sample=False)
|
| 108 |
eval_text = eval_outs[0].lower()
|
| 109 |
stats["nodes_evaluated"] += 1
|
| 110 |
|
|
|
|
| 164 |
}
|
| 165 |
]
|
| 166 |
|
| 167 |
+
final_outs = generate_with_chat_template(final_messages, max_new_tokens=1536, do_sample=False)
|
| 168 |
final_response = final_outs[0]
|
| 169 |
|
| 170 |
# Strip everything down to get just the clean answer
|