Datasets:

ArXiv:
Elron commited on
Commit
cbce8ee
1 Parent(s): 088c96c

Upload templates.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. templates.py +5 -1
templates.py CHANGED
@@ -109,6 +109,7 @@ class RenderTemplatedICL(RenderAutoFormatTemplate):
109
  size_limiter: Artifact = None
110
  input_output_separator: str = "\n"
111
  demo_separator: str = "\n\n"
 
112
 
113
  def render(self, instance: Dict[str, object]) -> Dict[str, object]:
114
  demos = instance.pop(self.demos_field, [])
@@ -142,6 +143,9 @@ class RenderTemplatedICL(RenderAutoFormatTemplate):
142
 
143
  source += input_str
144
 
 
 
 
145
  return {
146
  **example,
147
  "source": source,
@@ -151,7 +155,7 @@ class RenderTemplatedICL(RenderAutoFormatTemplate):
151
  class InputOutputTemplate(Template):
152
  input_format: str = None
153
  output_format: str = None
154
- postprocessors: List[str] = field(default_factory=lambda: ["processors.to_string"])
155
 
156
  def process_template(self, template: str, data: Dict[str, object]) -> str:
157
  data = {k: ", ".join(v) if isinstance(v, list) else v for k, v in data.items()}
 
109
  size_limiter: Artifact = None
110
  input_output_separator: str = "\n"
111
  demo_separator: str = "\n\n"
112
+ system_prompt: str = None
113
 
114
  def render(self, instance: Dict[str, object]) -> Dict[str, object]:
115
  demos = instance.pop(self.demos_field, [])
 
143
 
144
  source += input_str
145
 
146
+ if self.system_prompt is not None:
147
+ source = self.system_prompt.format(source)
148
+
149
  return {
150
  **example,
151
  "source": source,
 
155
  class InputOutputTemplate(Template):
156
  input_format: str = None
157
  output_format: str = None
158
+ postprocessors: List[str] = field(default_factory=lambda: ["processors.to_string_stripped"])
159
 
160
  def process_template(self, template: str, data: Dict[str, object]) -> str:
161
  data = {k: ", ".join(v) if isinstance(v, list) else v for k, v in data.items()}