MCPcopy Create free account
hub / github.com/OpenSparseLLMs/MoM / FDA

Class FDA

lm-eval-harness/lm_eval/tasks/based_fda/task.py:8–99  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6
7
8class FDA(ConfigurableTask):
9 VERSION = 0
10 DATASET_PATH = "hazyresearch/based-fda"
11 DATASET_NAME = "default"
12
13 def __init__(self):
14 super().__init__(config={'metadata': {'version': self.VERSION}})
15
16 def has_training_docs(self):
17 return False
18
19 def has_validation_docs(self):
20 return True
21
22 def has_test_docs(self):
23 return False
24
25 def validation_docs(self):
26 return self.dataset["validation"]
27
28 def doc_to_text(self, doc):
29 question = doc["key"]+":"
30 while(doc["text"].lower().endswith(question.lower())):
31 doc["text"] = doc["text"][:-len(question)]
32 upper_key = doc['key'][0].upper() + doc['key'][1:]
33 question = upper_key +":"
34 doc['text'] = doc['text'].strip("\n").strip(".")
35 out = doc["text"]
36 if not out.endswith("."): out += "."
37 out += " " + question
38 return out
39
40 def doc_to_target(self, doc):
41 return doc["value"]
42
43 def construct_requests(self, doc, ctx, **kwargs):
44 """Uses RequestFactory to construct Requests and returns an iterable of
45 Requests which will be sent to the LM.
46
47 :param doc:
48 The document as returned from training_docs, validation_docs, or test_docs.
49 :param ctx: str
50 The context string, generated by fewshot_context. This includes the natural
51 language description, as well as the few shot examples, and the question
52 part of the document for `doc`.
53 """
54
55 return [
56 Instance(
57 request_type="generate_until",
58 doc=doc,
59 arguments=(ctx, {"until": ["\n"], "max_gen_toks": 48}),
60 idx=0,
61 **kwargs,
62 ),
63 ]
64
65 def process_results(self, doc, results):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected