diff --git a/prepare/formats/empty.py b/prepare/formats/empty.py index ce90c7ea6..a34f94dba 100644 --- a/prepare/formats/empty.py +++ b/prepare/formats/empty.py @@ -6,4 +6,12 @@ model_input_format="{system_prompt}\\N{instruction}\\N{demos}{source}\\N{target_prefix}", ) +default_format = SystemFormat() +assert ( + format.demo_format == default_format.demo_format +), f"{format.demo_format} != {default_format.demo_format}" +assert ( + format.model_input_format == default_format.model_input_format +), f"{format.model_input_format} != {default_format.model_input_format}" + add_to_catalog(format, "formats.empty", overwrite=True) diff --git a/prepare/templates/classification/multi_class/relation.py b/prepare/templates/classification/multi_class/relation.py index c557cfa76..0722e2dbe 100644 --- a/prepare/templates/classification/multi_class/relation.py +++ b/prepare/templates/classification/multi_class/relation.py @@ -3,7 +3,7 @@ add_to_catalog( InputOutputTemplate( - input_format="{text_a_type}: {text_a}, {text_b_type}: {text_b}", + input_format="{text_a_type}: {text_a}\n{text_b_type}: {text_b}", output_format="{label}", target_prefix="The {type_of_relation} class is ", instruction="Given a {text_a_type} and {text_b_type} classify the {type_of_relation} of the {text_b_type} to one of {classes}.", diff --git a/src/unitxt/catalog/templates/classification/multi_class/relation/default.json b/src/unitxt/catalog/templates/classification/multi_class/relation/default.json index 0571e5ed1..058667c17 100644 --- a/src/unitxt/catalog/templates/classification/multi_class/relation/default.json +++ b/src/unitxt/catalog/templates/classification/multi_class/relation/default.json @@ -1,6 +1,6 @@ { "type": "input_output_template", - "input_format": "{text_a_type}: {text_a}, {text_b_type}: {text_b}", + "input_format": "{text_a_type}: {text_a}\n{text_b_type}: {text_b}", "output_format": "{label}", "target_prefix": "The {type_of_relation} class is ", "instruction": "Given a {text_a_type} and {text_b_type} classify the {type_of_relation} of the {text_b_type} to one of {classes}.", diff --git a/src/unitxt/formats.py b/src/unitxt/formats.py index ff70ea01c..87fbc96c1 100644 --- a/src/unitxt/formats.py +++ b/src/unitxt/formats.py @@ -114,9 +114,9 @@ class SystemFormat(Format): """ demos_field: str = "demos" - demo_format: str = "{source}\n{target_prefix}{target}\n\n" # example: "User: {source}\nAgent: {target}\n\n" + demo_format: str = "{source}\\N{target_prefix}{target}\n\n" # example: "User: {source}\nAgent: {target}\n\n" model_input_format: str = ( - "{system_prompt}{instruction}{demos}{source}\n{target_prefix}" + "{system_prompt}\\N{instruction}\\N{demos}{source}\\N{target_prefix}" ) format_args: Dict[str, str] = OptionalField(default_factory=dict) diff --git a/tests/library/test_api.py b/tests/library/test_api.py index f307f4e60..07515b1db 100644 --- a/tests/library/test_api.py +++ b/tests/library/test_api.py @@ -65,7 +65,7 @@ def test_produce_with_recipe(self): target = { "metrics": ["metrics.f1_micro", "metrics.accuracy", "metrics.f1_macro"], - "source": "Given a premise and hypothesis classify the entailment of the hypothesis to one of entailment, not entailment.premise: Steve follows Fred's example in everything. He influences him hugely., hypothesis: Steve influences him hugely.\nThe entailment class is entailment\n\npremise: The police arrested all of the gang members. They were trying to stop the drug trade in the neighborhood., hypothesis: The police were trying to stop the drug trade in the neighborhood.\nThe entailment class is not entailment\n\npremise: It works perfectly, hypothesis: It works!\nThe entailment class is ", + "source": "Given a premise and hypothesis classify the entailment of the hypothesis to one of entailment, not entailment.\npremise: Steve follows Fred's example in everything. He influences him hugely.\nhypothesis: Steve influences him hugely.\nThe entailment class is entailment\n\npremise: The police arrested all of the gang members. They were trying to stop the drug trade in the neighborhood.\nhypothesis: The police were trying to stop the drug trade in the neighborhood.\nThe entailment class is not entailment\n\npremise: It works perfectly\nhypothesis: It works!\nThe entailment class is ", "target": "?", "references": ["?"], "task_data": '{"text_a": "It works perfectly", ' @@ -103,7 +103,7 @@ def test_produce_with_recipe_with_list_of_instances(self): target = { "metrics": ["metrics.f1_micro", "metrics.accuracy", "metrics.f1_macro"], - "source": "Given a premise and hypothesis classify the entailment of the hypothesis to one of entailment, not entailment.premise: Steve follows Fred's example in everything. He influences him hugely., hypothesis: Steve influences him hugely.\nThe entailment class is entailment\n\npremise: The police arrested all of the gang members. They were trying to stop the drug trade in the neighborhood., hypothesis: The police were trying to stop the drug trade in the neighborhood.\nThe entailment class is not entailment\n\npremise: It works perfectly, hypothesis: It works!\nThe entailment class is ", + "source": "Given a premise and hypothesis classify the entailment of the hypothesis to one of entailment, not entailment.\npremise: Steve follows Fred's example in everything. He influences him hugely.\nhypothesis: Steve influences him hugely.\nThe entailment class is entailment\n\npremise: The police arrested all of the gang members. They were trying to stop the drug trade in the neighborhood.\nhypothesis: The police were trying to stop the drug trade in the neighborhood.\nThe entailment class is not entailment\n\npremise: It works perfectly\nhypothesis: It works!\nThe entailment class is ", "target": "?", "references": ["?"], "task_data": '{"text_a": "It works perfectly", '