Upload templates.py with huggingface_hub
Browse files59 unmodified lines60616263646522 unmodified lines888990919293170 unmodified lines26426526626726826942 unmodified lines31231331431531631731831932059 unmodified linesclass InputOutputTemplate(Template):input_format: str = Noneoutput_format: str = None22 unmodified linesclass MultipleChoiceTemplate(Template):input_format: strtarget_prefix: str = ""choices_field: str = "choices"170 unmodified linesclass KeyValTemplate(Template):pairs_seperator: str = ", "key_val_seperator: str = ": "use_keys_for_inputs: bool = True42 unmodified linesquantum: float = 0.1def outputs_to_target_and_references(self, outputs: Dict[str, object]) -> str:quantized_outputs = {key: round(input_float / self.quantum) * self.quantumfor key, input_float in outputs.items()}return super().outputs_to_target_and_references(quantized_outputs)59 unmodified lines606162636465666768697022 unmodified lines93949596979899100170 unmodified lines27127227327427527627727827928028142 unmodified lines32432532632732832933033133233359 unmodified linesclass InputOutputTemplate(Template):"""Generate field 'source' from fields designated as input, and fields 'target' and 'references' from fields designated as output, of the processed instance.Args specify the formatting strings with which to glue together the input and output designated fields of the processed instance into one string ('source' and 'target'), and into a list of strings ('references')."""input_format: str = Noneoutput_format: str = None22 unmodified linesclass MultipleChoiceTemplate(Template):"""Formats the input (that specifies the question), the multiple choices to select the answer from, and specifies the field with the correct answer."""input_format: strtarget_prefix: str = ""choices_field: str = "choices"170 unmodified linesclass KeyValTemplate(Template):"""Generate field 'source' from fields designated as input, and fields 'target' and 'references' from fields designated as output, of the processed instance.Args specify with what separators to glue together the input and output designated fields of the processed instance into one string ('source' and 'target'), and into a list of strings ('references')."""pairs_seperator: str = ", "key_val_seperator: str = ": "use_keys_for_inputs: bool = True42 unmodified linesquantum: float = 0.1def outputs_to_target_and_references(self, outputs: Dict[str, object]) -> str:quantum_str = f"{self.quantum:.10f}".rstrip("0").rstrip(".")quantized_outputs = {key: f"{round(value / self.quantum) * self.quantum:{quantum_str}}"for key, value in outputs.items()}return super().outputs_to_target_and_references(quantized_outputs)
templates.py+15-2