joaogante HF staff commited on
Commit
ade3ffb
β€’
1 Parent(s): edce2eb

add markdown

Browse files
Files changed (1) hide show
  1. app.py +17 -8
app.py CHANGED
@@ -61,17 +61,26 @@ if __name__ == "__main__":
61
  with demo:
62
  gr.Markdown(
63
  """
64
- # Foo Bar
 
 
 
 
 
 
65
  """
66
  )
67
 
68
- prompt = gr.Textbox(label="Prompt", lines=3, value="Today is")
69
- highlighted_text = gr.HighlightedText(
70
- label="Highlighted generation",
71
- combine_adjacent=True,
72
- show_legend=True,
73
- ).style(color_map=label_to_color)
74
- button = gr.Button(f"Generate with {MODEL_NAME}")
 
 
 
75
 
76
  button.click(get_tokens_and_labels, inputs=prompt, outputs=highlighted_text)
77
 
 
61
  with demo:
62
  gr.Markdown(
63
  """
64
+ # Color Coded Text Generation
65
+
66
+ This is a demo of how you can obtain the probabilities of each token being generated, and use them to
67
+ color code the generated text πŸŸ’πŸŸ‘πŸ”΄. Feel free to clone this demo and modify it to your needs πŸ€—
68
+
69
+ Internally, it relies on [`compute_transition_scores`](https://huggingface.co/docs/transformers/main/en/main_classes/text_generation#transformers.GenerationMixin.compute_transition_scores),
70
+ which was added in `transformers` v4.26.0.
71
  """
72
  )
73
 
74
+ with gr.Row():
75
+ with gr.Column():
76
+ prompt = gr.Textbox(label="Prompt", lines=3, value="Today is")
77
+ button = gr.Button(f"Generate with {MODEL_NAME}")
78
+ with gr.Column():
79
+ highlighted_text = gr.HighlightedText(
80
+ label="Highlighted generation",
81
+ combine_adjacent=True,
82
+ show_legend=True,
83
+ ).style(color_map=label_to_color)
84
 
85
  button.click(get_tokens_and_labels, inputs=prompt, outputs=highlighted_text)
86