Skip to content

Commit

Permalink
Conform output of TextGenerationPipelines with HuggingfacePipelines (#…
Browse files Browse the repository at this point in the history
…1205)

* Conform with Huggingface pipelines

* Match logits to generated tokens
  • Loading branch information
rahul-tuli committed Aug 25, 2023
1 parent ba617eb commit 31a71a9
Showing 1 changed file with 6 additions and 2 deletions.
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

0 comments on commit 31a71a9

Please sign in to comment.