Skip to content
Open
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
6 changes: 6 additions & 0 deletions llama/generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ def text_completion(
If logprobs is True, token log probabilities are computed for each generated token.

"""
if not prompts:
return []
if max_gen_len is None:
max_gen_len = self.model.params.max_seq_len - 1
prompt_tokens = [self.tokenizer.encode(x, bos=True, eos=False) for x in prompts]
Expand Down Expand Up @@ -313,6 +315,10 @@ def chat_completion(
If logprobs is True, token log probabilities are computed for each generated token.

"""
if not dialogs:
return []
if any([len(dialog) == 0 for dialog in dialogs]):
raise ValueError("dialogs must not contain empty dialogs")
if max_gen_len is None:
max_gen_len = self.model.params.max_seq_len - 1
prompt_tokens = []
Expand Down