Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Test] Sentence generation #9

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions tests/apple.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from evaluator import *

DESCRIPTION = "Test if the model can output 10 sentences, ending each one with the word 'apple'."

TAGS = ['explain', 'fun']

question = """
Write a list ten sentences, each of which ends with the word 'apple'.
"""

def test_true():
return True

import re

def do_split_eos(text):
for sentence in text.strip().split('\n'):
if sentence.strip():
# remove punctuation
sentence_cleaned = re.sub(r'[^\w\s]$', '', sentence.strip())
words = sentence_cleaned.split()
yield words[-1] if words else ""



TestEnding = question >> LLMRun() >> UntilDone(PyEvaluator(test_true),
(PyFunc(do_split_eos) >> SubstringEvaluator('apple', True)), max_iters=10)

if __name__ == "__main__":
print(run_test(TestEnding))