|
6 | 6 |
|
7 | 7 | import importlib.util |
8 | 8 | import re |
9 | | -from collections.abc import Callable |
10 | 9 | from functools import partial |
11 | 10 | from typing import Any, Dict, Optional |
12 | 11 |
|
@@ -110,34 +109,18 @@ def doc_to_target(self, doc): |
110 | 109 | def get_arguments(self, doc, ctx): |
111 | 110 | return (ctx, {"until": ["\n"]}) |
112 | 111 |
|
113 | | - def fewshot_context( |
114 | | - self, |
115 | | - doc: str, |
116 | | - num_fewshot: int, |
117 | | - system_instruction: Optional[str] = None, |
118 | | - apply_chat_template: bool = False, |
119 | | - fewshot_as_multiturn: bool = False, |
120 | | - chat_template: Optional[Callable] = None, |
121 | | - gen_prefix: Optional[str] = None, |
122 | | - ) -> str: |
| 112 | + def fewshot_context(self, doc, **kwargs) -> str: |
123 | 113 | if isinstance(self.doc_to_text(doc), list): |
124 | | - if apply_chat_template: |
| 114 | + if kwargs.get("apply_chat_template"): |
| 115 | + chat_template = kwargs.get("chat_template") |
125 | 116 | formated_source = chat_template(self.doc_to_text(doc)) |
126 | 117 | return formated_source |
127 | 118 | else: |
128 | 119 | raise Exception( |
129 | 120 | "Got chat template format from Unitxt, but apply_chat_template is false. Add '--apply_chat_template' to command line." |
130 | 121 | ) |
131 | 122 | else: |
132 | | - return super().fewshot_context( |
133 | | - doc=doc, |
134 | | - num_fewshot=num_fewshot, |
135 | | - system_instruction=system_instruction, |
136 | | - apply_chat_template=apply_chat_template, |
137 | | - fewshot_as_multiturn=fewshot_as_multiturn, |
138 | | - chat_template=chat_template, |
139 | | - gen_prefix=gen_prefix, |
140 | | - ) |
| 123 | + return super().fewshot_context(doc=doc, **kwargs) |
141 | 124 |
|
142 | 125 | def construct_requests(self, doc, ctx, **kwargs): |
143 | 126 | """Uses RequestFactory to construct Requests and returns an iterable of |
|
0 commit comments