diff --git a/open_instruct/IFEvalG/instructions.py b/open_instruct/IFEvalG/instructions.py index c2109a00e..16d574a54 100644 --- a/open_instruct/IFEvalG/instructions.py +++ b/open_instruct/IFEvalG/instructions.py @@ -1543,11 +1543,10 @@ def check_following(self, value): first_word = self._phrase.split()[0] last_word = self._phrase.split()[-1] - len(self._phrase.split()) - 2 - found_phrases = re.findall(rf"{first_word} .*? {last_word}", value) if len(found_phrases) != self._small_n: return False + num_satisfied_phrases = 0 for phrase in found_phrases: phrase = phrase.split() ref_phrase = self._phrase.split() @@ -1563,8 +1562,9 @@ def check_following(self, value): return False except IndexError: return False - if differences == 1: - return True + num_satisfied_phrases += differences == 1 + + return num_satisfied_phrases == self._small_n class CopyChecker(Instruction):