Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
lm-evaluation-harness
Commits
9b4bfb6a
Commit
9b4bfb6a
authored
Apr 11, 2022
by
jon-tow
Browse files
Merge changes
parent
e0cfeb90
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
13 additions
and
15 deletions
+13
-15
lm_eval/tasks/arithmetic.py
lm_eval/tasks/arithmetic.py
+1
-1
lm_eval/tasks/coqa.py
lm_eval/tasks/coqa.py
+1
-1
lm_eval/tasks/hendrycks_ethics.py
lm_eval/tasks/hendrycks_ethics.py
+3
-3
lm_eval/tasks/hendrycks_test.py
lm_eval/tasks/hendrycks_test.py
+0
-1
lm_eval/tasks/logiqa.py
lm_eval/tasks/logiqa.py
+1
-1
lm_eval/tasks/openbookqa.py
lm_eval/tasks/openbookqa.py
+0
-1
lm_eval/tasks/prost.py
lm_eval/tasks/prost.py
+0
-1
lm_eval/tasks/sat.py
lm_eval/tasks/sat.py
+1
-2
lm_eval/tasks/storycloze.py
lm_eval/tasks/storycloze.py
+6
-1
lm_eval/tasks/wikitext.py
lm_eval/tasks/wikitext.py
+0
-3
No files found.
lm_eval/tasks/arithmetic.py
View file @
9b4bfb6a
...
@@ -57,7 +57,7 @@ class Arithmetic(Task):
...
@@ -57,7 +57,7 @@ class Arithmetic(Task):
return
True
return
True
def
doc_to_decontamination_query
(
self
,
doc
):
def
doc_to_decontamination_query
(
self
,
doc
):
return
doc
.
context
return
doc
[
"
context
"
]
def
doc_to_target
(
self
,
doc
):
def
doc_to_target
(
self
,
doc
):
return
doc
[
"completion"
]
return
doc
[
"completion"
]
...
...
lm_eval/tasks/coqa.py
View file @
9b4bfb6a
...
@@ -65,7 +65,7 @@ class CoQA(Task):
...
@@ -65,7 +65,7 @@ class CoQA(Task):
return
True
return
True
def
doc_to_decontamination_query
(
self
,
doc
):
def
doc_to_decontamination_query
(
self
,
doc
):
return
doc
[
"story"
]
+
" "
+
doc
[
"questions"
]
return
doc
[
"story"
]
+
" "
+
"
\n
"
.
join
(
doc
[
"questions"
]
[
"input_text"
])
@
classmethod
@
classmethod
def
get_answers
(
cls
,
doc
,
turn_id
):
def
get_answers
(
cls
,
doc
,
turn_id
):
...
...
lm_eval/tasks/hendrycks_ethics.py
View file @
9b4bfb6a
...
@@ -94,7 +94,7 @@ class EthicsCM(Ethics):
...
@@ -94,7 +94,7 @@ class EthicsCM(Ethics):
return
True
return
True
def
doc_to_decontamination_query
(
self
,
doc
):
def
doc_to_decontamination_query
(
self
,
doc
):
return
doc
[
1
]
return
doc
[
"input"
]
def
doc_to_target
(
self
,
doc
):
def
doc_to_target
(
self
,
doc
):
return
" {}"
.
format
(
yesno
(
int
(
doc
[
"label"
])))
return
" {}"
.
format
(
yesno
(
int
(
doc
[
"label"
])))
...
@@ -135,7 +135,7 @@ class EthicsDeontology(Ethics):
...
@@ -135,7 +135,7 @@ class EthicsDeontology(Ethics):
return
True
return
True
def
doc_to_decontamination_query
(
self
,
doc
):
def
doc_to_decontamination_query
(
self
,
doc
):
return
" "
.
join
([
doc
[
1
],
doc
[
2
]])
return
" "
.
join
([
doc
[
"scenario"
],
doc
[
"excuse"
]])
def
doc_to_target
(
self
,
doc
):
def
doc_to_target
(
self
,
doc
):
target
=
[
"unreasonable"
,
"reasonable"
][
int
(
doc
[
"label"
])]
target
=
[
"unreasonable"
,
"reasonable"
][
int
(
doc
[
"label"
])]
...
@@ -186,7 +186,7 @@ class EthicsJustice(Ethics):
...
@@ -186,7 +186,7 @@ class EthicsJustice(Ethics):
return
True
return
True
def
doc_to_decontamination_query
(
self
,
doc
):
def
doc_to_decontamination_query
(
self
,
doc
):
return
doc
[
1
]
return
doc
[
"scenario"
]
def
doc_to_target
(
self
,
doc
):
def
doc_to_target
(
self
,
doc
):
target
=
[
"unreasonable"
,
"reasonable"
][
int
(
doc
[
"label"
])]
target
=
[
"unreasonable"
,
"reasonable"
][
int
(
doc
[
"label"
])]
...
...
lm_eval/tasks/hendrycks_test.py
View file @
9b4bfb6a
...
@@ -117,4 +117,3 @@ class GeneralHendrycksTest(MultipleChoiceTask):
...
@@ -117,4 +117,3 @@ class GeneralHendrycksTest(MultipleChoiceTask):
def
doc_to_decontamination_query
(
self
,
doc
):
def
doc_to_decontamination_query
(
self
,
doc
):
return
doc
[
"query"
]
return
doc
[
"query"
]
lm_eval/tasks/logiqa.py
View file @
9b4bfb6a
...
@@ -72,7 +72,7 @@ class LogiQA(MultipleChoiceTask):
...
@@ -72,7 +72,7 @@ class LogiQA(MultipleChoiceTask):
return
prompt
return
prompt
choices
=
[
'a'
,
'b'
,
'c'
,
'd'
]
choices
=
[
'a'
,
'b'
,
'c'
,
'd'
]
return
{
return
{
"passage"
:
doc
[
"
passage
"
],
# Used for decontamination
"passage"
:
doc
[
"
context
"
],
# Used for decontamination
"query"
:
format_example
(
doc
,
choices
),
"query"
:
format_example
(
doc
,
choices
),
"choices"
:
doc
[
"options"
],
"choices"
:
doc
[
"options"
],
"gold"
:
choices
.
index
(
doc
[
"label"
])
"gold"
:
choices
.
index
(
doc
[
"label"
])
...
...
lm_eval/tasks/openbookqa.py
View file @
9b4bfb6a
...
@@ -69,4 +69,3 @@ class OpenBookQA(MultipleChoiceTask):
...
@@ -69,4 +69,3 @@ class OpenBookQA(MultipleChoiceTask):
def
doc_to_decontamination_query
(
self
,
doc
):
def
doc_to_decontamination_query
(
self
,
doc
):
return
doc
[
"query"
]
return
doc
[
"query"
]
lm_eval/tasks/prost.py
View file @
9b4bfb6a
...
@@ -77,4 +77,3 @@ class PROST(MultipleChoiceTask):
...
@@ -77,4 +77,3 @@ class PROST(MultipleChoiceTask):
def
doc_to_decontamination_query
(
self
,
doc
):
def
doc_to_decontamination_query
(
self
,
doc
):
return
doc
[
"query"
]
return
doc
[
"query"
]
lm_eval/tasks/sat.py
View file @
9b4bfb6a
...
@@ -72,5 +72,4 @@ class SATAnalogies(MultipleChoiceTask):
...
@@ -72,5 +72,4 @@ class SATAnalogies(MultipleChoiceTask):
return
True
return
True
def
doc_to_decontamination_query
(
self
,
doc
):
def
doc_to_decontamination_query
(
self
,
doc
):
return
doc
[
"source"
]
+
" "
+
doc
[
"query"
]
return
doc
[
"source"
]
+
"
\n
"
+
" "
.
join
(
doc
[
"query"
])
lm_eval/tasks/storycloze.py
View file @
9b4bfb6a
...
@@ -76,7 +76,12 @@ class StoryCloze(Task):
...
@@ -76,7 +76,12 @@ class StoryCloze(Task):
return
True
return
True
def
doc_to_decontamination_query
(
self
,
doc
):
def
doc_to_decontamination_query
(
self
,
doc
):
return
doc
[
"context"
]
return
' '
.
join
([
doc
[
"input_sentence_1"
],
doc
[
"input_sentence_2"
],
doc
[
"input_sentence_3"
],
doc
[
"input_sentence_4"
],
])
def
doc_to_target
(
self
,
doc
):
def
doc_to_target
(
self
,
doc
):
clozes
=
[
doc
[
"sentence_quiz1"
],
doc
[
"sentence_quiz2"
]]
clozes
=
[
doc
[
"sentence_quiz1"
],
doc
[
"sentence_quiz2"
]]
...
...
lm_eval/tasks/wikitext.py
View file @
9b4bfb6a
...
@@ -93,9 +93,6 @@ class WikiText(PerplexityTask):
...
@@ -93,9 +93,6 @@ class WikiText(PerplexityTask):
def
should_decontaminate
(
self
):
def
should_decontaminate
(
self
):
return
True
return
True
def
doc_to_decontamination_query
(
self
,
doc
):
return
doc
[
"text"
]
def
count_words
(
self
,
doc
):
def
count_words
(
self
,
doc
):
# count number of words in *original doc before detokenization*
# count number of words in *original doc before detokenization*
return
len
(
re
.
split
(
r
"\s+"
,
doc
))
return
len
(
re
.
split
(
r
"\s+"
,
doc
))
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment