4646 icl_answer: str
4747 spec: [{icl_question: str, icl_answer: str, question: str}]
4848 return:
49- - defs:
49+ defs:
5050 prompt_data:
5151 call: question_template_freeform
5252 spec: { introduction: str, principles: str, examples: str, generation: str, max_new_tokens: int }
7373 parser:
7474 regex: '### Question [0-9]+:\s*([^#\n]+)'
7575 mode: findall
76- - for:
76+ for:
7777 question: ${teacher_output}
7878 repeat:
7979 data:
8989 seed_examples: [{question: str, answer: str}]
9090 spec: [{icl_question: str, icl_answer: str, question: str}]
9191 return:
92- - defs:
92+ defs:
9393 list_of_lists:
9494 for:
9595 example: ${seed_examples}
@@ -102,7 +102,7 @@ defs:
102102 icl_answer: ${example.answer}
103103 join:
104104 as: array
105- - lang: python
105+ lang: python
106106 code: | # flatten list_of_lists into simple list
107107 result = [q for qs in ${list_of_lists} for q in qs]
108108
@@ -137,7 +137,7 @@ defs:
137137 question: str
138138 spec: float
139139 return:
140- - defs:
140+ defs:
141141 prompt_data:
142142 call: filter_questions_template
143143 spec: {introduction: str, principles: str, generation: str, max_new_tokens: int}
@@ -164,25 +164,26 @@ defs:
164164 # regex: "Rating.*\\[\\[(?P<rating>\\d+\\.?\\d*)\\]\\]"
165165 regex: 'Rating.*\[\[(?P<rating>\d+\.?\d*)\]\]'
166166 mode: search
167- - ${ teacher_output.rating | float }
167+ data: ${ teacher_output.rating | float }
168168
169169 filter_questions:
170170 function:
171171 task_description: str
172172 questions: [{icl_question: str, icl_answer: str, question: str}]
173173 spec: [{icl_question: str, icl_answer: str, question: str}]
174174 return:
175- - defs:
175+ defs:
176176 list_of_pairs:
177177 for:
178178 question: ${questions}
179179 repeat:
180- - def: filter_output
181- call: filter_questions_inner
182- args:
183- task_description: ${task_description}
184- question: ${question.question}
185- - data:
180+ defs:
181+ filter_output:
182+ call: filter_questions_inner
183+ args:
184+ task_description: ${task_description}
185+ question: ${question.question}
186+ data:
186187 question: ${question}
187188 keep: ${filter_output}
188189 join:
@@ -191,7 +192,7 @@ defs:
191192 lang: python
192193 code: | # keep only if "keep" column is non-zero
193194 result = [p["question"] for p in ${ list_of_pairs } if p["keep"]]
194- - ${filtered}
195+ data: ${filtered}
195196
196197
197198 answer_template:
@@ -230,7 +231,7 @@ defs:
230231 question: {icl_question: str, icl_answer: str, question: str}
231232 spec: {question: str, answer: str}
232233 return:
233- - defs:
234+ defs:
234235 prompt_data:
235236 call: answer_template
236237 spec: {introduction: str, principles: str, examples: str, generation: str, max_new_tokens: int, additional_stop_tokens: [str]}
@@ -262,7 +263,7 @@ defs:
262263 result = result[result.find("[Response]") + len("[Response]"):]
263264 if "[Question]" in result:
264265 result = result[:result.find("[Question]")]
265- - data:
266+ data:
266267 question: ${question.question}
267268 answer: ${parsed_answer}
268269
@@ -271,7 +272,7 @@ defs:
271272 questions: [{icl_question: str, icl_answer: str, question: str}]
272273 spec: [{question: str, answer: str}]
273274 return:
274- - defs:
275+ defs:
275276 all_results:
276277 spec: [{question: str, answer: str}]
277278 for:
@@ -282,7 +283,7 @@ defs:
282283 question: ${question}
283284 join:
284285 as: array
285- - lang: python
286+ lang: python
286287 spec: [{question: str, answer: str}]
287288 code: | # keep only if answer non-empty
288289 result = [r for r in ${all_results} if len(r["answer"]) > 0]
@@ -319,7 +320,7 @@ defs:
319320 answer: str
320321 spec: float
321322 return:
322- - defs:
323+ defs:
323324 prompt_data:
324325 call: filter_qa_template
325326 spec: {introduction: str, principles: str, generation: str, max_new_tokens: int}
@@ -345,25 +346,26 @@ defs:
345346 spec: { "rating": str }
346347 regex: 'Rating.*\[\[(?P<rating>\d+\.?\d*)\]\]'
347348 mode: search
348- - ${ (teacher_output.rating if teacher_output.rating is not none else 0.0) | float}
349+ data: ${ (teacher_output.rating if teacher_output.rating is not none else 0.0) | float}
349350
350351 filter_question_answer_pair:
351352 function:
352353 qa_pairs: [{question: str, answer: str}]
353354 spec: [{question: str, answer: str}]
354355 return:
355- - defs:
356+ defs:
356357 ratings:
357358 for:
358359 qa_pair: ${qa_pairs}
359360 repeat:
360- - def: filter_output
361- call: filter_question_answer_pair_inner
362- spec: float
363- args:
364- question: ${qa_pair.question}
365- answer: ${qa_pair.answer}
366- - data:
361+ defs:
362+ filter_output:
363+ call: filter_question_answer_pair_inner
364+ spec: float
365+ args:
366+ question: ${qa_pair.question}
367+ answer: ${qa_pair.answer}
368+ data:
367369 qa_pair: ${qa_pair}
368370 rating: ${filter_output}
369371 join:
@@ -373,7 +375,7 @@ defs:
373375 spec: [{question: str, answer: str}]
374376 code: | # keep only if rating is at least two
375377 result = [p["qa_pair"] for p in ${ratings} if p["rating"] >= 2]
376- - ${filtered}
378+ data: ${filtered}
377379
378380
379381text:
0 commit comments