Uses RequestFactory to construct Requests and returns an iterable of Requests which will be sent to the LM. :param doc: The document as returned from training_docs, validation_docs, or test_docs. :param ctx: str The context string, generated by fewsho
(self, doc, ctx)
| 202 | } |
| 203 | |
| 204 | def construct_requests(self, doc, ctx): |
| 205 | """Uses RequestFactory to construct Requests and returns an iterable of |
| 206 | Requests which will be sent to the LM. |
| 207 | |
| 208 | :param doc: |
| 209 | The document as returned from training_docs, validation_docs, or test_docs. |
| 210 | :param ctx: str |
| 211 | The context string, generated by fewshot_context. This includes the natural |
| 212 | language description, as well as the few shot examples, and the question |
| 213 | part of the document for `doc`. |
| 214 | """ |
| 215 | # unanswerable = rf.loglikelihood(ctx, " " + "unanswerable") |
| 216 | if doc["answer_type"] in ("free form answer"): |
| 217 | return [rf.greedy_until(ctx, {"until": ["\n"]})] |
| 218 | elif doc["answer_type"] in ("bool"): |
| 219 | ll_yes, _ = rf.loglikelihood(ctx, " yes") |
| 220 | ll_no, _ = rf.loglikelihood(ctx, " no") |
| 221 | return [ll_yes, ll_no] |
| 222 | else: |
| 223 | return [] |
| 224 | |
| 225 | def higher_is_better(self): |
| 226 | """ |
nothing calls this directly
no test coverage detected