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
3eab4b9a
Commit
3eab4b9a
authored
May 10, 2024
by
JessicaOjo
Browse files
remove direct util, update common yaml
parent
21fb0db7
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
17 deletions
+31
-17
lm_eval/tasks/afrimgsm/direct/afrimgsm_common_yaml
lm_eval/tasks/afrimgsm/direct/afrimgsm_common_yaml
+31
-0
lm_eval/tasks/afrimgsm/direct/utils.py
lm_eval/tasks/afrimgsm/direct/utils.py
+0
-17
No files found.
lm_eval/tasks/afrimgsm/direct/afrimgsm_common_yaml
0 → 100644
View file @
3eab4b9a
group: mgsm_direct
task: afrimgsm_direct
dataset_path: masakhane/afrimgsm
output_type: generate_until
training_split: train
test_split: test
fewshot_split: train
target_delimiter: ""
doc_to_target: '{% if answer is not none %}{{answer}}{% else %}{{answer_number|string}}{% endif %}'
doc_to_text: '{% if answer is not none %}{{question+"\nAnswer:"}}{% else %}{{"Question: "+question+"\nAnswer:"}}{% endif %}'
generation_kwargs:
do_sample: false
until:
- 'Question:'
- </s>
- <|im_end|>
filter_list:
- filter:
- function: regex-numbers
group_select: -1
regex_pattern: (-?[0-9.,]{2,})|(-?[0-9]+)
- function: take_first
name: flexible-extract
metric_list:
- metric: squad
aggregation: squad_f1
average: weighted
hf_evaluate: False
higher_is_better: True
metadata:
version: 1.0
lm_eval/tasks/afrimgsm/direct/utils.py
deleted
100644 → 0
View file @
21fb0db7
import
evaluate
def
squad_f1
(
items
):
unzipped_list
=
list
(
zip
(
*
items
))
print
(
unzipped_list
)
ref_squad
,
pred_squad
=
unzipped_list
[
0
],
unzipped_list
[
1
]
reference
,
prediction
=
[],
[]
for
index
in
range
(
len
(
reference
)):
pred_dict
=
{
'prediction_text'
:
str
(
reference
[
index
]),
'id'
:
str
(
index
)}
ref_dict
=
{
'answers'
:
{
'answer_start'
:
[
1
],
'text'
:
str
(
prediction
[
index
])},
'id'
:
str
(
index
)}
reference
.
append
(
pred_dict
)
prediction
.
append
(
ref_dict
)
squad_metric
=
evaluate
.
load
(
"squad"
)
results_squad
=
squad_metric
.
compute
(
predictions
=
pred_squad
,
references
=
ref_squad
)
return
round
(
results_squad
[
'f1'
],
2
)
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