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

Fix and re-enable ConversationalPipeline tests #26907

Merged
merged 2 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 deletions tests/pipelines/test_pipelines_conversational.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,14 @@ def get_test_pipeline(self, model, tokenizer, processor):

def run_pipeline_test(self, conversation_agent, _):
# Simple
outputs = conversation_agent(Conversation("Hi there!"))
outputs = conversation_agent(Conversation("Hi there!"), max_new_tokens=20)
self.assertEqual(
outputs,
Conversation([{"role": "user", "content": "Hi there!"}, {"role": "assistant", "content": ANY(str)}]),
)

# Single list
outputs = conversation_agent([Conversation("Hi there!")])
outputs = conversation_agent([Conversation("Hi there!")], max_new_tokens=20)
self.assertEqual(
outputs,
Conversation([{"role": "user", "content": "Hi there!"}, {"role": "assistant", "content": ANY(str)}]),
Expand All @@ -96,7 +96,7 @@ def run_pipeline_test(self, conversation_agent, _):
self.assertEqual(len(conversation_1), 1)
self.assertEqual(len(conversation_2), 1)

outputs = conversation_agent([conversation_1, conversation_2])
outputs = conversation_agent([conversation_1, conversation_2], max_new_tokens=20)
self.assertEqual(outputs, [conversation_1, conversation_2])
self.assertEqual(
outputs,
Expand All @@ -118,7 +118,7 @@ def run_pipeline_test(self, conversation_agent, _):

# One conversation with history
conversation_2.add_message({"role": "user", "content": "Why do you recommend it?"})
outputs = conversation_agent(conversation_2)
outputs = conversation_agent(conversation_2, max_new_tokens=20)
self.assertEqual(outputs, conversation_2)
self.assertEqual(
outputs,
Expand Down
9 changes: 6 additions & 3 deletions tests/test_pipeline_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,12 @@ def data(n):
yield copy.deepcopy(random.choice(examples))

out = []
for item in pipeline(data(10), batch_size=4):
out.append(item)
if task == "conversational":
for item in pipeline(data(10), batch_size=4, max_new_tokens=20):
out.append(item)
else:
for item in pipeline(data(10), batch_size=4):
out.append(item)
self.assertEqual(len(out), 10)

run_batch_test(pipeline, examples)
Expand All @@ -327,7 +331,6 @@ def test_pipeline_automatic_speech_recognition(self):
self.run_task_tests(task="automatic-speech-recognition")

@is_pipeline_test
@unittest.skip("Conversational tests are currently broken for several models, will fix ASAP - Matt")
def test_pipeline_conversational(self):
self.run_task_tests(task="conversational")

Expand Down
Loading