Di Zhang
commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -37,6 +37,15 @@ def llama_o1_template(data):
|
|
| 37 |
text = template.format(content=data)
|
| 38 |
return text
|
| 39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
@spaces.GPU
|
| 41 |
def generate_text(message, history, max_tokens=512, temperature=0.9, top_p=0.95):
|
| 42 |
input_text = llama_o1_template(message)
|
|
@@ -51,7 +60,7 @@ def generate_text(message, history, max_tokens=512, temperature=0.9, top_p=0.95)
|
|
| 51 |
do_sample=True,
|
| 52 |
)
|
| 53 |
|
| 54 |
-
response = tokenizer.decode(output[0], skip_special_tokens=
|
| 55 |
yield response
|
| 56 |
|
| 57 |
with gr.Blocks() as demo:
|
|
|
|
| 37 |
text = template.format(content=data)
|
| 38 |
return text
|
| 39 |
|
| 40 |
+
def format_response(response):
|
| 41 |
+
response = response.replace('<start_of_father_id>','')
|
| 42 |
+
response = response.replace('<end_of_father_id><start_of_local_id>','π')
|
| 43 |
+
response = response.replace('<end_of_local_id><start_of_thought>',', ')
|
| 44 |
+
response = response.replace('<end_of_thought><start_of_rating>','')
|
| 45 |
+
response = response.replace('<end_of_rating>','')
|
| 46 |
+
response = response.replace('<positive_rating>','π')
|
| 47 |
+
response = response.replace('<negative_rating>','π')
|
| 48 |
+
|
| 49 |
@spaces.GPU
|
| 50 |
def generate_text(message, history, max_tokens=512, temperature=0.9, top_p=0.95):
|
| 51 |
input_text = llama_o1_template(message)
|
|
|
|
| 60 |
do_sample=True,
|
| 61 |
)
|
| 62 |
|
| 63 |
+
response = tokenizer.decode(output[0], skip_special_tokens=False)
|
| 64 |
yield response
|
| 65 |
|
| 66 |
with gr.Blocks() as demo:
|