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
49f0699c
Commit
49f0699c
authored
Apr 28, 2022
by
tomlimi
Browse files
Fixed few-shot context generation or datasets without a training split
parent
9cd70235
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
7 deletions
+7
-7
lm_eval/base.py
lm_eval/base.py
+7
-7
No files found.
lm_eval/base.py
View file @
49f0699c
...
...
@@ -915,12 +915,12 @@ class PromptSourceTask(Task):
if
num_fewshot
==
0
:
labeled_examples
=
""
fewshotex
,
fewshotidx
,
fewshotsource
=
[],
[],
None
fewshotex
,
fewshotidx
,
self
.
fewshotsource
=
[],
[],
None
else
:
# for sets with no training docs, draw from other set *but ensure no overlap with current doc*
if
self
.
has_training_docs
():
fewshotex
,
fewshotidx
=
self
.
fewshot_examples
(
k
=
num_fewshot
,
rnd
=
rnd
)
fewshotsource
=
"train"
self
.
fewshotsource
=
"train"
else
:
if
self
.
_fewshot_docs
is
None
:
self
.
_fewshot_docs
=
list
(
...
...
@@ -929,18 +929,18 @@ class PromptSourceTask(Task):
else
self
.
test_docs
()
)
if
self
.
has_validation_docs
():
fewshotsource
=
"val"
self
.
fewshotsource
=
"val"
elif
self
.
test_docs
():
fewshotsource
=
"test"
self
.
fewshotsource
=
"test"
fewshotex
,
fewshotidx
=
self
.
_get_fewshot_examples
(
self
.
_fewshot_docs
,
k
=
num_fewshot
+
1
,
rnd
=
rnd
)
fewshotex
,
fewshotidx
=
[
fewshotex
,
fewshotidx
=
zip
(
*
[
(
shot
,
idx
)
for
shot
,
idx
in
zip
(
fewshotex
,
fewshotidx
)
if
shot
!=
doc
]
]
)
# get rid of the doc that's the one we're evaluating, if it's in the fewshot
fewshotex
,
fewshotidx
=
(
fewshotex
[:
num_fewshot
],
...
...
@@ -966,7 +966,7 @@ class PromptSourceTask(Task):
ctx
,
{
"fewshot_idx"
:
fewshotidx
,
"fewshot_source"
:
fewshotsource
,
"fewshot_source"
:
self
.
fewshotsource
,
"fewshot_num"
:
num_fewshot
,
"ctx"
:
ctx
,
},
...
...
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