Commit bf46dff4 authored by Baber's avatar Baber
Browse files

add flexible

parent bc5c554d
...@@ -20,6 +20,11 @@ filter_list: ...@@ -20,6 +20,11 @@ filter_list:
- function: "regex" - function: "regex"
regex_pattern: "(?:[`\\*_]*(?i:FINAL ANSWER|Final Answer|Answer)[`\\*_]*)[:\\s]*[`\\*_]*([A-D])[`\\*_]*" regex_pattern: "(?:[`\\*_]*(?i:FINAL ANSWER|Final Answer|Answer)[`\\*_]*)[:\\s]*[`\\*_]*([A-D])[`\\*_]*"
- function: "take_first" - function: "take_first"
- name: "flexible-extract"
filter:
- function: "custom"
- filter_fn: !function utils.flexible_extract
- function: "take_first"
metric_list: metric_list:
- metric: exact_match - metric: exact_match
aggregation: mean aggregation: mean
......
import string
def flexible_extract(resps, docs):
def filter_set(inst):
filtered = []
for resp in inst:
while resp[-1] in string.punctuation:
resp = resp[:-1]
if resp[-1] in ["A", "B", "C", "D"]:
resp = resp[-1]
filtered.append(resp)
return filtered
filtered_resps = list(map(lambda x: filter_set(x), resps))
return filtered_resps
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