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

Conform output of TextGenerationPipelines with HuggingfacePipelines #1205

Merged
merged 2 commits into from
Aug 25, 2023
Merged
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: 6 additions & 2 deletions src/deepsparse/transformers/pipelines/text_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,13 +435,17 @@ def engine_forward(
else 100 * self.sequence_length
) # set safety for absolute max generation

# last prompt token is the first generated token
# add it to generated tokens, and the logits
generated_tokens = [tokens[-1]]
generated_logits = (
prompt_logits if context.get("include_prompt_logits") else []
prompt_logits
if context.get("include_prompt_logits")
else [prompt_logits[-1]]
)

with timer.time(_TextGenerationTimings.TOKEN_GENERATION):
while len(generated_tokens) <= max_tokens:
while len(generated_tokens) < max_tokens:
with timer.time(_TextGenerationTimings.TOKEN_GENERATION_SINGLE):
token, logits = self.autoregressive_inference(tokens)
tokens.append(token)
Expand Down
Loading