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

Class BasedDrop

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

Source from the content-addressed store, hash-verified

6
7
8class BasedDrop(ConfigurableTask):
9 VERSION = "default"
10 DATASET_PATH = "hazyresearch/based_drop"
11 DATASET_NAME = None
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 context = doc["context"].strip()
30 question = doc["question"].strip()
31 while(context.lower().endswith(question.lower())):
32 context = context[:-len(question)]
33
34 out = (
35 context.strip().strip(".") + ". " + question
36 )
37 return out
38
39 def should_decontaminate(self):
40 return True
41
42 def doc_to_decontamination_query(self, doc):
43 return doc["context"]
44
45 def doc_to_target(self, doc):
46 answer_list = doc['answers']
47 if len(answer_list) > 0:
48 answer = answer_list[0]
49 else:
50 answer = "unanswerable"
51 return " " + answer
52
53 def construct_requests(self, doc, ctx, **kwargs):
54 """Uses RequestFactory to construct Requests and returns an iterable of
55 Requests which will be sent to the LM.
56
57 :param doc:
58 The document as returned from training_docs, validation_docs, or test_docs.
59 :param ctx: str
60 The context string, generated by fewshot_context. This includes the natural
61 language description, as well as the few shot examples, and the question
62 part of the document for `doc`.
63 """
64
65 return [

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected