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
4b790fa7
Commit
4b790fa7
authored
May 08, 2024
by
Konrad
Browse files
variable rename
parent
f4902e06
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
12 deletions
+14
-12
lm_eval/api/task.py
lm_eval/api/task.py
+14
-12
No files found.
lm_eval/api/task.py
View file @
4b790fa7
...
@@ -1004,17 +1004,17 @@ class ConfigurableTask(Task):
...
@@ -1004,17 +1004,17 @@ class ConfigurableTask(Task):
if
description
:
=
self
.
config
.
description
:
if
description
:
=
self
.
config
.
description
:
description
=
utils
.
apply_template
(
self
.
config
.
description
,
doc
)
description
=
utils
.
apply_template
(
self
.
config
.
description
,
doc
)
chat_history
=
[]
labeled_examples
=
[]
if
num_fewshot
==
0
:
if
num_fewshot
==
0
:
# always prepend the (possibly empty) task description
# always prepend the (possibly empty) task description
if
apply_chat_template
:
if
apply_chat_template
:
chat_history
.
append
({
"role"
:
"system"
,
"content"
:
description
})
labeled_examples
.
append
({
"role"
:
"system"
,
"content"
:
description
})
else
:
else
:
labeled_examples
=
description
labeled_examples
=
description
else
:
else
:
if
apply_chat_template
:
if
apply_chat_template
:
chat_history
=
self
.
sampler
.
get_chat_context
(
labeled_examples
=
self
.
sampler
.
get_chat_context
(
doc
,
num_fewshot
,
chat_history
doc
,
num_fewshot
,
labeled_examples
)
)
else
:
else
:
labeled_examples
=
description
+
self
.
sampler
.
get_context
(
labeled_examples
=
description
+
self
.
sampler
.
get_context
(
...
@@ -1025,25 +1025,27 @@ class ConfigurableTask(Task):
...
@@ -1025,25 +1025,27 @@ class ConfigurableTask(Task):
if
apply_chat_template
:
if
apply_chat_template
:
if
not
self
.
multiple_input
:
if
not
self
.
multiple_input
:
if
isinstance
(
example
,
str
):
if
isinstance
(
example
,
str
):
chat_history
.
append
({
"role"
:
"user"
,
"content"
:
example
})
labeled_examples
.
append
({
"role"
:
"user"
,
"content"
:
example
})
elif
isinstance
(
example
,
list
):
elif
isinstance
(
example
,
list
):
chat_histori
es_list
=
[]
labeled_exampl
es_list
=
[]
for
ex
in
example
:
for
ex
in
example
:
chat
=
deepcopy
(
chat_history
)
chat
=
deepcopy
(
labeled_examples
)
chat
.
append
({
"role"
:
"user"
,
"content"
:
ex
})
chat
.
append
({
"role"
:
"user"
,
"content"
:
ex
})
chat_histori
es_list
.
append
(
labeled_exampl
es_list
.
append
(
self
.
convert_chat_history_to_string
(
chat
,
tokenizer
)
self
.
convert_chat_history_to_string
(
chat
,
tokenizer
)
)
)
return
chat_histori
es_list
return
labeled_exampl
es_list
elif
isinstance
(
example
,
int
):
elif
isinstance
(
example
,
int
):
if
self
.
config
.
doc_to_choice
is
not
None
:
if
self
.
config
.
doc_to_choice
is
not
None
:
choices
=
self
.
doc_to_choice
(
doc
)
choices
=
self
.
doc_to_choice
(
doc
)
chat_history
.
append
(
labeled_examples
.
append
(
{
"role"
:
"user"
,
"content"
:
choices
[
example
]}
{
"role"
:
"user"
,
"content"
:
choices
[
example
]}
)
)
else
:
else
:
chat_history
.
append
({
"role"
:
"user"
,
"content"
:
str
(
example
)})
labeled_examples
.
append
(
return
self
.
convert_chat_history_to_string
(
chat_history
,
tokenizer
)
{
"role"
:
"user"
,
"content"
:
str
(
example
)}
)
return
self
.
convert_chat_history_to_string
(
labeled_examples
,
tokenizer
)
else
:
else
:
if
self
.
multiple_input
:
if
self
.
multiple_input
:
return
labeled_examples
return
labeled_examples
...
...
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