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
4f27f0b9
Unverified
Commit
4f27f0b9
authored
Aug 13, 2023
by
Hailey Schoelkopf
Committed by
GitHub
Aug 13, 2023
Browse files
Merge pull request #774 from EleutherAI/speedup-hellaswag
[Refactor] Speedup hellaswag context building
parents
dbf2c083
8189eb18
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
2 deletions
+27
-2
lm_eval/tasks/hellaswag/hellaswag.yaml
lm_eval/tasks/hellaswag/hellaswag.yaml
+3
-2
lm_eval/tasks/hellaswag/utils.py
lm_eval/tasks/hellaswag/utils.py
+24
-0
No files found.
lm_eval/tasks/hellaswag/hellaswag.yaml
View file @
4f27f0b9
...
@@ -7,9 +7,10 @@ output_type: multiple_choice
...
@@ -7,9 +7,10 @@ output_type: multiple_choice
training_split
:
train
training_split
:
train
validation_split
:
validation
validation_split
:
validation
test_split
:
null
test_split
:
null
doc_to_text
:
"
{%
set
text
=
activity_label
~
':
'
~
ctx_a
~
'
'
~
ctx_b.capitalize()
%}{{text|trim|replace('
[title]',
'.
')|regex_replace('
\\
[.*?
\\
]',
'')|replace('
',
'
')}}"
process_docs
:
!function
utils.process_docs
doc_to_text
:
"
{{query}}"
doc_to_target
:
"
{{label}}"
doc_to_target
:
"
{{label}}"
doc_to_choice
:
"
{{
endings|map('trim')|map('replace',
'
[title]',
'.
')|map('regex_replace',
'
\\
[.*?
\\
]',
'')|map('replace',
'
',
'
')|list
}}"
doc_to_choice
:
"
{{
choices
}}"
metric_list
:
metric_list
:
-
metric
:
acc
-
metric
:
acc
aggregation
:
mean
aggregation
:
mean
...
...
lm_eval/tasks/hellaswag/utils.py
0 → 100644
View file @
4f27f0b9
import
datasets
import
re
def
preprocess
(
text
):
text
=
text
.
strip
()
# NOTE: Brackets are artifacts of the WikiHow dataset portion of HellaSwag.
text
=
text
.
replace
(
" [title]"
,
". "
)
text
=
re
.
sub
(
"
\\
[.*?
\\
]"
,
""
,
text
)
text
=
text
.
replace
(
" "
,
" "
)
return
text
def
process_docs
(
dataset
:
datasets
.
Dataset
)
->
datasets
.
Dataset
:
def
_process_doc
(
doc
):
ctx
=
doc
[
"ctx_a"
]
+
" "
+
doc
[
"ctx_b"
].
capitalize
()
out_doc
=
{
"query"
:
preprocess
(
doc
[
"activity_label"
]
+
": "
+
ctx
),
"choices"
:
[
preprocess
(
ending
)
for
ending
in
doc
[
"endings"
]],
"gold"
:
int
(
doc
[
"label"
]),
}
return
out_doc
return
dataset
.
map
(
_process_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