Skip to content

Commit 7ddd966

Browse files
authored
Avoid errors in extraction filters (#3395)
1 parent f30dda1 commit 7ddd966

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lm_eval/filters/extraction.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ def apply(self, resps: list[list[str]], docs: list[dict]) -> list[list[str]]:
3838
def filter_set(inst):
3939
filtered = []
4040
for resp in inst:
41+
if not isinstance(resp, str):
42+
resp = ""
4143
match = self.regex.findall(resp)
4244
if match:
4345
match = match[self.group_select]
@@ -159,6 +161,8 @@ def apply(self, resps: list[list[str]], docs: list[dict]) -> list[list[str]]:
159161
# independently (and keep them a list.)
160162

161163
def find_match(regex, resp, convert_dict={}):
164+
if not isinstance(resp, str):
165+
resp = ""
162166
match = regex.findall(resp)
163167
if match:
164168
match = match[self.group_select]

0 commit comments

Comments
 (0)