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
9d5ea23b
Commit
9d5ea23b
authored
Sep 19, 2024
by
Baber
Browse files
fix regex
parent
1c242485
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
5 deletions
+7
-5
lm_eval/tasks/mathvista/mathvista.yaml
lm_eval/tasks/mathvista/mathvista.yaml
+2
-2
lm_eval/tasks/mathvista/utils.py
lm_eval/tasks/mathvista/utils.py
+5
-3
No files found.
lm_eval/tasks/mathvista/mathvista.yaml
View file @
9d5ea23b
...
@@ -5,7 +5,7 @@ output_type: "generate_until"
...
@@ -5,7 +5,7 @@ output_type: "generate_until"
#process_docs: !function utils.process_docs
#process_docs: !function utils.process_docs
doc_to_image
:
doc_to_image
:
-
decoded_image
-
decoded_image
doc_to_text
:
"
<image>
{{query}}"
doc_to_text
:
"
<image>{{query}}"
#doc_to_choice: '{{ ["A", "B", "C", "D", "E", "F"][:choices.length] }}'
#doc_to_choice: '{{ ["A", "B", "C", "D", "E", "F"][:choices.length] }}'
doc_to_target
:
answer
doc_to_target
:
answer
process_results
:
!function
utils.process_results
process_results
:
!function
utils.process_results
...
@@ -14,7 +14,7 @@ generation_kwargs:
...
@@ -14,7 +14,7 @@ generation_kwargs:
-
"
<|endoftext|>"
-
"
<|endoftext|>"
temperature
:
0.0
temperature
:
0.0
do_sample
:
false
do_sample
:
false
max_gen_toks
:
6
4
max_gen_toks
:
102
4
metric_list
:
metric_list
:
-
metric
:
acc
-
metric
:
acc
aggregation
:
mean
aggregation
:
mean
...
...
lm_eval/tasks/mathvista/utils.py
View file @
9d5ea23b
...
@@ -66,7 +66,7 @@ def normalize_extracted_answer(
...
@@ -66,7 +66,7 @@ def normalize_extracted_answer(
elif
answer_type
==
"float"
:
elif
answer_type
==
"float"
:
try
:
try
:
normalized_extraction
=
str
(
round
(
float
(
extraction
),
precision
))
normalized_extraction
=
str
(
round
(
float
(
extraction
),
int
(
precision
))
)
except
Exception
:
except
Exception
:
normalized_extraction
=
None
normalized_extraction
=
None
...
@@ -102,7 +102,9 @@ def extract_answer(response: str, problem: dict) -> str:
...
@@ -102,7 +102,9 @@ def extract_answer(response: str, problem: dict) -> str:
return
""
return
""
### This is not in the original code:
### This is not in the original code:
extract
=
re
.
findall
(
r
"[tT]he answer is (\d+)"
,
response
)
extract
=
re
.
findall
(
r
"[tT]he answer is ([A-Za-z0-9]+(?:\.[A-Za-z0-9]+)?)"
,
response
)
if
extract
:
if
extract
:
return
str
(
extract
[
0
])
return
str
(
extract
[
0
])
###
###
...
@@ -124,7 +126,7 @@ def extract_answer(response: str, problem: dict) -> str:
...
@@ -124,7 +126,7 @@ def extract_answer(response: str, problem: dict) -> str:
except
Exception
:
except
Exception
:
pass
pass
return
""
return
response
# adapted from https://github.com/lupantech/MathVista/blob/main/evaluation/extract_answer.py
# adapted from https://github.com/lupantech/MathVista/blob/main/evaluation/extract_answer.py
...
...
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