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
a69ba385
Commit
a69ba385
authored
Mar 26, 2021
by
Leo Gao
Browse files
Fix translation prompting
parent
fa7b9643
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
2 deletions
+5
-2
lm_eval/tasks/translation.py
lm_eval/tasks/translation.py
+5
-2
No files found.
lm_eval/tasks/translation.py
View file @
a69ba385
...
@@ -86,11 +86,14 @@ class GeneralTranslationTask(Task):
...
@@ -86,11 +86,14 @@ class GeneralTranslationTask(Task):
}
for
src
,
ref
in
zip
(
self
.
src_data
,
self
.
ref_data
)]
}
for
src
,
ref
in
zip
(
self
.
src_data
,
self
.
ref_data
)]
def
doc_to_text
(
self
,
doc
):
def
doc_to_text
(
self
,
doc
):
return
doc
[
"src"
]
language_codes
=
self
.
sacrebleu_language_pair
.
split
(
"-"
)
src_lang
=
code_to_language
(
language_codes
[
0
])
tar_lang
=
code_to_language
(
language_codes
[
1
])
return
f
"
{
src_lang
}
phrase: "
+
doc
[
"src"
]
+
f
"
\n
{
tar_lang
}
phrase:"
def
doc_to_target
(
self
,
doc
):
def
doc_to_target
(
self
,
doc
):
# This shows a single target, though there may be multiple targets in a lang test
# This shows a single target, though there may be multiple targets in a lang test
return
doc
[
"ref"
]
if
isinstance
(
doc
[
"ref"
],
str
)
else
doc
[
"ref"
][
0
]
return
" "
+
doc
[
"ref"
]
if
isinstance
(
doc
[
"ref"
],
str
)
else
doc
[
"ref"
][
0
]
def
construct_requests
(
self
,
doc
,
ctx
):
def
construct_requests
(
self
,
doc
,
ctx
):
""" Uses RequestFactory to construct Requests and returns an iterable of
""" Uses RequestFactory to construct Requests and returns an iterable of
...
...
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