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

fix regex

parent 1c242485
...@@ -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: 64 max_gen_toks: 1024
metric_list: metric_list:
- metric: acc - metric: acc
aggregation: mean aggregation: mean
......
...@@ -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
......
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