Upload formats.py with huggingface_hub
Browse files- formats.py +4 -1
formats.py
CHANGED
|
@@ -10,18 +10,20 @@ class SizeLimitingFormat(Format):
|
|
| 10 |
|
| 11 |
|
| 12 |
class ICLFormat(SizeLimitingFormat):
|
|
|
|
| 13 |
input_prefix: str = ""
|
| 14 |
output_prefix: str = ""
|
| 15 |
target_prefix: str = " "
|
| 16 |
instruction_prefix: str = ""
|
| 17 |
input_output_separator: str = "\n"
|
| 18 |
demo_separator: str = "\n\n"
|
|
|
|
| 19 |
|
| 20 |
def single_source_str(self, source):
|
| 21 |
return self.input_prefix + source + self.input_output_separator + self.output_prefix
|
| 22 |
|
| 23 |
def format(self, instance, demos_instances=[]):
|
| 24 |
-
source =
|
| 25 |
|
| 26 |
query_str = self.single_source_str(instance["source"])
|
| 27 |
|
|
@@ -44,5 +46,6 @@ class ICLFormat(SizeLimitingFormat):
|
|
| 44 |
source += demo_str
|
| 45 |
|
| 46 |
source += query_str
|
|
|
|
| 47 |
|
| 48 |
return source
|
|
|
|
| 10 |
|
| 11 |
|
| 12 |
class ICLFormat(SizeLimitingFormat):
|
| 13 |
+
prefix: str = ""
|
| 14 |
input_prefix: str = ""
|
| 15 |
output_prefix: str = ""
|
| 16 |
target_prefix: str = " "
|
| 17 |
instruction_prefix: str = ""
|
| 18 |
input_output_separator: str = "\n"
|
| 19 |
demo_separator: str = "\n\n"
|
| 20 |
+
suffix: str = ""
|
| 21 |
|
| 22 |
def single_source_str(self, source):
|
| 23 |
return self.input_prefix + source + self.input_output_separator + self.output_prefix
|
| 24 |
|
| 25 |
def format(self, instance, demos_instances=[]):
|
| 26 |
+
source = self.prefix
|
| 27 |
|
| 28 |
query_str = self.single_source_str(instance["source"])
|
| 29 |
|
|
|
|
| 46 |
source += demo_str
|
| 47 |
|
| 48 |
source += query_str
|
| 49 |
+
source += self.suffix
|
| 50 |
|
| 51 |
return source
|