Spaces:
Paused
Paused
New claude-3-5-sonnet-20241022 model. Add prompt to improve structure following capability
Browse files
app.py
CHANGED
|
@@ -89,6 +89,7 @@ models = ["gpt-4-turbo",
|
|
| 89 |
"claude-3-sonnet-20240229",
|
| 90 |
"claude-3-opus-20240229",
|
| 91 |
"claude-3-5-sonnet-20240620",
|
|
|
|
| 92 |
"gemini-1.5-pro"
|
| 93 |
#"llama3-70b-8192",
|
| 94 |
]
|
|
@@ -235,9 +236,10 @@ def get_language(struct_lang, copy_lang):
|
|
| 235 |
|
| 236 |
def post_process(text):
|
| 237 |
# text = text.strip().replace('<br>', ' ')
|
| 238 |
-
with open(f"postprocess_{time.time()}.txt", "w") as f:
|
| 239 |
-
|
| 240 |
-
return text
|
|
|
|
| 241 |
|
| 242 |
|
| 243 |
def get_model(model_name, temperature=0.0):
|
|
@@ -364,7 +366,7 @@ def generate(*data):
|
|
| 364 |
HumanMessage(content=f"""Generate {nversions} versions of the product description for a product with the following information.
|
| 365 |
Write in a way that target the customer.
|
| 366 |
For each version, write at least {min_length} words and at most {max_length} words.
|
| 367 |
-
Make sure that the structure of each output follows the reference structure.
|
| 368 |
Make sure to use the tone of voice, rythm, cadence and style of the reference copy for each output.
|
| 369 |
Use markdown format for each output.
|
| 370 |
Do not include any part of the reference structure in the output.
|
|
@@ -378,7 +380,7 @@ Avoid common phrases and cliches such as "Step into something", "Elevate somethi
|
|
| 378 |
For each version, try to write in different style.
|
| 379 |
Put each item in the list on a separate line.
|
| 380 |
Rate the quality of each version based on the following criteria:
|
| 381 |
-
- how well it follows the reference structure.
|
| 382 |
- how well it follows the tone of voice, rythm, cadence and style of the reference copy.
|
| 383 |
- how faithful it describes the product features.
|
| 384 |
- how well it avoid the excluded words.
|
|
@@ -493,7 +495,7 @@ Excluded words: {excluded_words}"""),]
|
|
| 493 |
HumanMessage(content=f"""Generate {nversions} versions of the product description for a product with the following information.
|
| 494 |
Write in a way that target the customer.
|
| 495 |
For each version, write at least {min_length} words and at most {max_length} words.
|
| 496 |
-
Make sure that the structure of each output follows the reference structure.
|
| 497 |
Use markdown format for each output.
|
| 498 |
Do not include any part of the reference structure in the output.
|
| 499 |
Make sure that the structure of each output follows the reference structure.
|
|
@@ -505,7 +507,7 @@ Avoid common phrases and cliches such as "Step into something", "Elevate somethi
|
|
| 505 |
For each version, try to write in different style.
|
| 506 |
Put each item in the list on a separate line.
|
| 507 |
Rate the quality of each version based on the following criteria:
|
| 508 |
-
- how well it follows the reference structure.
|
| 509 |
- how faithful it describes the product features.
|
| 510 |
- how well it avoid the excluded words.
|
| 511 |
- how well it includes the included words.
|
|
@@ -644,7 +646,7 @@ with gr.Blocks() as demo:
|
|
| 644 |
garment_type = gr.Textbox(label="Garment Type", value="all", lines=1, interactive=True)
|
| 645 |
# language = gr.Dropdown(languages, value="American English", interactive=True, label="Language")
|
| 646 |
with gr.Accordion(label="Advanced Options", open=False):
|
| 647 |
-
model = gr.Dropdown(models, value="claude-3-5-sonnet-
|
| 648 |
temperature = gr.Slider(minimum=0., maximum=1.0, value=0., interactive=True, label="Temperature", visible=True)
|
| 649 |
nversions = gr.Slider(minimum=1, maximum=10, value=5, step=int, interactive=True, label="Number of versions", visible=True)
|
| 650 |
excluded_words = gr.Textbox(label="Excluded words", interactive=True, lines=2)
|
|
@@ -670,7 +672,7 @@ with gr.Blocks() as demo:
|
|
| 670 |
add_output.click(add_output_click, inputs=struct_ref, outputs=struct_ref)
|
| 671 |
remove_output.click(remove_output_click, inputs=struct_ref, outputs=struct_ref)
|
| 672 |
with gr.Column():
|
| 673 |
-
md_output = gr.Markdown(label="Output", show_label=True)
|
| 674 |
json_output = gr.JSON(label="JSON Output")
|
| 675 |
submit.click(generate, inputs=[feature, image, garment_type, model, temperature, nversions,
|
| 676 |
excluded_words, included_words, glossary_upload, debug, *struct_ref],
|
|
|
|
| 89 |
"claude-3-sonnet-20240229",
|
| 90 |
"claude-3-opus-20240229",
|
| 91 |
"claude-3-5-sonnet-20240620",
|
| 92 |
+
"claude-3-5-sonnet-20241022",
|
| 93 |
"gemini-1.5-pro"
|
| 94 |
#"llama3-70b-8192",
|
| 95 |
]
|
|
|
|
| 236 |
|
| 237 |
def post_process(text):
|
| 238 |
# text = text.strip().replace('<br>', ' ')
|
| 239 |
+
# with open(f"postprocess_{time.time()}.txt", "w") as f:
|
| 240 |
+
# f.write(text)
|
| 241 |
+
# return text
|
| 242 |
+
return text
|
| 243 |
|
| 244 |
|
| 245 |
def get_model(model_name, temperature=0.0):
|
|
|
|
| 366 |
HumanMessage(content=f"""Generate {nversions} versions of the product description for a product with the following information.
|
| 367 |
Write in a way that target the customer.
|
| 368 |
For each version, write at least {min_length} words and at most {max_length} words.
|
| 369 |
+
Make sure that the structure of each output follows the reference structure. Do not add any additional sentences or structures that are not in the reference structure.
|
| 370 |
Make sure to use the tone of voice, rythm, cadence and style of the reference copy for each output.
|
| 371 |
Use markdown format for each output.
|
| 372 |
Do not include any part of the reference structure in the output.
|
|
|
|
| 380 |
For each version, try to write in different style.
|
| 381 |
Put each item in the list on a separate line.
|
| 382 |
Rate the quality of each version based on the following criteria:
|
| 383 |
+
- how well it follows the reference structure.
|
| 384 |
- how well it follows the tone of voice, rythm, cadence and style of the reference copy.
|
| 385 |
- how faithful it describes the product features.
|
| 386 |
- how well it avoid the excluded words.
|
|
|
|
| 495 |
HumanMessage(content=f"""Generate {nversions} versions of the product description for a product with the following information.
|
| 496 |
Write in a way that target the customer.
|
| 497 |
For each version, write at least {min_length} words and at most {max_length} words.
|
| 498 |
+
Make sure that the structure of each output follows the reference structure. Do not add any additional sentences or structures that are not in the reference structure.
|
| 499 |
Use markdown format for each output.
|
| 500 |
Do not include any part of the reference structure in the output.
|
| 501 |
Make sure that the structure of each output follows the reference structure.
|
|
|
|
| 507 |
For each version, try to write in different style.
|
| 508 |
Put each item in the list on a separate line.
|
| 509 |
Rate the quality of each version based on the following criteria:
|
| 510 |
+
- how well it follows the reference structure.
|
| 511 |
- how faithful it describes the product features.
|
| 512 |
- how well it avoid the excluded words.
|
| 513 |
- how well it includes the included words.
|
|
|
|
| 646 |
garment_type = gr.Textbox(label="Garment Type", value="all", lines=1, interactive=True)
|
| 647 |
# language = gr.Dropdown(languages, value="American English", interactive=True, label="Language")
|
| 648 |
with gr.Accordion(label="Advanced Options", open=False):
|
| 649 |
+
model = gr.Dropdown(models, value="claude-3-5-sonnet-20241022", interactive=True, label="Model", visible=True)
|
| 650 |
temperature = gr.Slider(minimum=0., maximum=1.0, value=0., interactive=True, label="Temperature", visible=True)
|
| 651 |
nversions = gr.Slider(minimum=1, maximum=10, value=5, step=int, interactive=True, label="Number of versions", visible=True)
|
| 652 |
excluded_words = gr.Textbox(label="Excluded words", interactive=True, lines=2)
|
|
|
|
| 672 |
add_output.click(add_output_click, inputs=struct_ref, outputs=struct_ref)
|
| 673 |
remove_output.click(remove_output_click, inputs=struct_ref, outputs=struct_ref)
|
| 674 |
with gr.Column():
|
| 675 |
+
md_output = gr.Markdown(label="Output", show_label=True, line_breaks=True)
|
| 676 |
json_output = gr.JSON(label="JSON Output")
|
| 677 |
submit.click(generate, inputs=[feature, image, garment_type, model, temperature, nversions,
|
| 678 |
excluded_words, included_words, glossary_upload, debug, *struct_ref],
|