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
452d2024
Commit
452d2024
authored
May 10, 2024
by
Israel Abebe Azime
Browse files
added transate test
parent
901ad392
Changes
22
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
0 deletions
+43
-0
lm_eval/tasks/afrimmlu_translate/fewshot.sh
lm_eval/tasks/afrimmlu_translate/fewshot.sh
+8
-0
lm_eval/tasks/afrimmlu_translate/utils.py
lm_eval/tasks/afrimmlu_translate/utils.py
+35
-0
No files found.
lm_eval/tasks/afrimmlu_translate/fewshot.sh
0 → 100644
View file @
452d2024
lm_eval
--model
hf
\
--model_args
pretrained
=
masakhane/African-ultrachat-alpaca
\
--tasks
afrimmlu_amh,afrimmlu_eng,afrimmlu_ewe,afrimmlu_fra,afrimmlu_hau,afrimmlu_ibo,afrimmlu_kin,afrimmlu_lin,afrimmlu_lug,afrimmlu_orm,afrimmlu_sna,afrimmlu_sot,afrimmlu_twi,afrimmlu_wol,afrimmlu_xho,afrimmlu_yor,afrimmlu_zul
\
--device
cuda:0
\
--batch_size
1
\
--num_fewshot
0
\
--verbosity
DEBUG
\
--wandb_args
project
=
afrimmlu
\ No newline at end of file
lm_eval/tasks/afrimmlu_translate/utils.py
0 → 100644
View file @
452d2024
from
sklearn.metrics
import
f1_score
def
doc_to_choice
(
doc
):
choices
=
eval
(
doc
[
"choices"
])
return
choices
def
doc_to_text
(
doc
):
output
=
"""You are a highly knowledgeable and intelligent artificial intelligence
model answers multiple-choice questions about '{subject}'
Question: '''{question}'''
Choices:
A: ''{choice1}'''
B: ''{choice2}'''
C: ''{choice3}'''
D: ''{choice4}'''
Answer: """
choices
=
eval
(
doc
[
"choices"
])
text
=
output
.
format
(
subject
=
doc
[
'subject'
],
question
=
doc
[
'question'
],
choice1
=
choices
[
0
],
choice2
=
choices
[
1
],
choice3
=
choices
[
2
],
choice4
=
choices
[
3
])
return
text
def
weighted_f1_score
(
items
):
unzipped_list
=
list
(
zip
(
*
items
))
golds
=
unzipped_list
[
0
]
preds
=
unzipped_list
[
1
]
fscore
=
f1_score
(
golds
,
preds
,
average
=
"weighted"
)
return
fscore
\ No newline at end of file
Prev
1
2
Next
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