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
5288813a
Commit
5288813a
authored
Jul 13, 2023
by
lintangsutawika
Browse files
adjust wsc
parent
82d57f65
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
2 deletions
+19
-2
lm_eval/tasks/super_glue/wsc/preprocess_wsc.py
lm_eval/tasks/super_glue/wsc/preprocess_wsc.py
+18
-1
lm_eval/tasks/super_glue/wsc/t5-prompt.yaml
lm_eval/tasks/super_glue/wsc/t5-prompt.yaml
+1
-1
No files found.
lm_eval/tasks/super_glue/wsc/preprocess_wsc.py
View file @
5288813a
import
re
from
lm_eval.utils
import
general_detokenize
def
doc_to_text
(
x
):
def
t5_prompt_
doc_to_text
(
x
):
def
_mark_span
(
text
,
span_str
,
span_idx
,
mark
):
pattern_tmpl
=
r
"^((?:\S+\s){N})(W)"
pattern
=
re
.
sub
(
"N"
,
str
(
span_idx
),
pattern_tmpl
)
...
...
@@ -15,3 +16,19 @@ def doc_to_text(x):
text
=
_mark_span
(
text
,
x
[
"span2_text"
],
span2_index
,
"#"
)
return
text
def
default_doc_to_text
(
doc
):
raw_passage
=
doc
[
"text"
]
# NOTE: HuggingFace span indices are word-based not character-based.
pre
=
" "
.
join
(
raw_passage
.
split
()[:
doc
[
"span2_index"
]])
post
=
raw_passage
[
len
(
pre
)
+
len
(
doc
[
"span2_text"
])
+
1
:]
passage
=
general_detokenize
(
pre
+
" *{}*"
.
format
(
doc
[
"span2_text"
])
+
post
)
noun
=
doc
[
"span1_text"
]
pronoun
=
doc
[
"span2_text"
]
text
=
(
f
"Passage:
{
passage
}
\n
"
+
f
'Question: In the passage above, does the pronoun "*
{
pronoun
}
*" refer to "*
{
noun
}
*"?
\n
'
+
"Answer:"
)
return
text
lm_eval/tasks/super_glue/wsc/t5-prompt.yaml
View file @
5288813a
...
...
@@ -5,7 +5,7 @@ dataset_path: super_glue
dataset_name
:
wsc
training_split
:
train
validation_split
:
validation
doc_to_text
:
!function
"
preprocess_wsc.doc_to_text"
doc_to_text
:
!function
"
preprocess_wsc.
t5_prompt_
doc_to_text"
doc_to_target
:
label
doc_to_choice
:
[
'
False'
,
'
True'
]
metric_list
:
...
...
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