Commit 9d5ea23b authored by Baber's avatar Baber
Browse files

fix regex

parent 1c242485
......@@ -5,7 +5,7 @@ output_type: "generate_until"
#process_docs: !function utils.process_docs
doc_to_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_target: answer
process_results: !function utils.process_results
......@@ -14,7 +14,7 @@ generation_kwargs:
- "<|endoftext|>"
temperature: 0.0
do_sample: false
max_gen_toks: 64
max_gen_toks: 1024
metric_list:
- metric: acc
aggregation: mean
......
......@@ -66,7 +66,7 @@ def normalize_extracted_answer(
elif answer_type == "float":
try:
normalized_extraction = str(round(float(extraction), precision))
normalized_extraction = str(round(float(extraction), int(precision)))
except Exception:
normalized_extraction = None
......@@ -102,7 +102,9 @@ def extract_answer(response: str, problem: dict) -> str:
return ""
### 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:
return str(extract[0])
###
......@@ -124,7 +126,7 @@ def extract_answer(response: str, problem: dict) -> str:
except Exception:
pass
return ""
return response
# adapted from https://github.com/lupantech/MathVista/blob/main/evaluation/extract_answer.py
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment