m-ric HF staff commited on
Commit
fc54541
β€’
1 Parent(s): 73826bd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -1
app.py CHANGED
@@ -431,6 +431,7 @@ def get_beam_search_html(
431
  return_dict_in_generate=True,
432
  length_penalty=length_penalty,
433
  output_scores=True,
 
434
  do_sample=False,
435
  )
436
  markdown = "The conclusive sequences are the ones that end in an `<|endoftext|>` token or at the end of generation."
@@ -440,8 +441,10 @@ def get_beam_search_html(
440
  markdown += "\n#### <span style='color:var(--secondary-500)!important'>Output sequences:</span>"
441
  # Sequences are padded anyway so you can batch decode them
442
  decoded_sequences = tokenizer.batch_decode(outputs.sequences)
 
 
443
  for i, sequence in enumerate(decoded_sequences):
444
- markdown += f"\n- Score `{outputs.sequences_scores[i]:.2f}`: `{clean(sequence.replace('<s> ', ''))}`"
445
 
446
  if number_beams > 1:
447
  original_tree = generate_beams(
 
431
  return_dict_in_generate=True,
432
  length_penalty=length_penalty,
433
  output_scores=True,
434
+ output_logits=True,
435
  do_sample=False,
436
  )
437
  markdown = "The conclusive sequences are the ones that end in an `<|endoftext|>` token or at the end of generation."
 
441
  markdown += "\n#### <span style='color:var(--secondary-500)!important'>Output sequences:</span>"
442
  # Sequences are padded anyway so you can batch decode them
443
  decoded_sequences = tokenizer.batch_decode(outputs.sequences)
444
+
445
+ sequence_scores = (outputs.sequences_scores is n_beams > 1 else outputs.scores)
446
  for i, sequence in enumerate(decoded_sequences):
447
+ markdown += f"\n- Score `{sequence_scores[i]:.2f}`: `{clean(sequence.replace('<s> ', ''))}`"
448
 
449
  if number_beams > 1:
450
  original_tree = generate_beams(