Skip to content

Commit

Permalink
Fix prompt for forbidden keywords.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sid-Data-Universe committed Dec 19, 2024
1 parent 23cad3a commit 4083cef
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion finetune/eval/if_eval/keywords.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@ def __init__(self, keywords: List[str]):
def get_prompt(self, index: int) -> str:
if index >= len(self.keywords):
raise ValueError("Index is out of range for keywords.")
return f'The word "{self.keywords[index]}" must not be the response.'
return (
f'The word "{self.keywords[index]}" must not be included in the response.'
)

def get_keywords(self) -> List[str]:
return self.keywords
Expand Down
5 changes: 3 additions & 2 deletions tests/finetune/eval/if_eval/test_keywords.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,11 @@ class TestForbiddenKeyword(unittest.TestCase):
def test_get_prompt(self):
rule = KeywordForbiddenRule(["test", "example"])
self.assertEqual(
rule.get_prompt(0), 'The word "test" must not be the response.'
rule.get_prompt(0), 'The word "test" must not be included in the response.'
)
self.assertEqual(
rule.get_prompt(1), 'The word "example" must not be the response.'
rule.get_prompt(1),
'The word "example" must not be included in the response.',
)

def test_matches(self):
Expand Down

0 comments on commit 4083cef

Please sign in to comment.