| 17 | """ |
| 18 | |
| 19 | class Babi(Task): |
| 20 | VERSION = 0 |
| 21 | DATASET_PATH = "Muennighoff/babi" |
| 22 | DATASET_NAME = None |
| 23 | |
| 24 | def has_training_docs(self): |
| 25 | return True |
| 26 | |
| 27 | def has_validation_docs(self): |
| 28 | return True |
| 29 | |
| 30 | def has_test_docs(self): |
| 31 | return True |
| 32 | |
| 33 | def training_docs(self): |
| 34 | if self.has_training_docs(): |
| 35 | return self.dataset["train"] |
| 36 | |
| 37 | def validation_docs(self): |
| 38 | if self.has_validation_docs(): |
| 39 | return self.dataset["valid"] |
| 40 | |
| 41 | def test_docs(self): |
| 42 | if self.has_test_docs(): |
| 43 | return self.dataset["test"] |
| 44 | |
| 45 | def doc_to_text(self, doc): |
| 46 | return ( |
| 47 | doc['passage'] + doc['question'] |
| 48 | ) |
| 49 | |
| 50 | def should_decontaminate(self): |
| 51 | return False # TODO Necessary? |
| 52 | |
| 53 | def doc_to_decontamination_query(self, doc): |
| 54 | return f"Passage: {doc['passage']}\nQuestion: {doc['question']}\nAnswer:" |
| 55 | |
| 56 | def doc_to_target(self, doc): |
| 57 | return " " + doc['answer'] |
| 58 | |
| 59 | def construct_requests(self, doc, ctx): |
| 60 | """Uses RequestFactory to construct Requests and returns an iterable of |
| 61 | Requests which will be sent to the LM. |
| 62 | |
| 63 | :param doc: |
| 64 | The document as returned from training_docs, validation_docs, or test_docs. |
| 65 | :param ctx: str |
| 66 | The context string, generated by fewshot_context. This includes the natural |
| 67 | language description, as well as the few shot examples, and the question |
| 68 | part of the document for `doc`. |
| 69 | """ |
| 70 | return rf.greedy_until(ctx, ["\n"]) |
| 71 | |
| 72 | def process_results(self, doc, results): |
| 73 | """Take a single document and the LM results and evaluates, returning a |
| 74 | dict where keys are the names of submetrics and values are the values of |
| 75 | the metric for that one document |
| 76 |
nothing calls this directly
no outgoing calls
no test coverage detected