Spaces:
Running
Running
Try to escape HTML
Browse files
app.py
CHANGED
@@ -5,6 +5,7 @@ import torch.nn as nn
|
|
5 |
import torch.nn.functional as F
|
6 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
7 |
import pandas as pd
|
|
|
8 |
|
9 |
model_options = [
|
10 |
'API',
|
@@ -91,7 +92,7 @@ for span in spans:
|
|
91 |
html = ''
|
92 |
for span in spans:
|
93 |
b = int(256 * span["token_loss"] / highest_loss)
|
94 |
-
html += f'<span style="color: rgba(128, 128, {b:d})" title="{span["most_likely_token"]}">{span["token"]}</span>'
|
95 |
html = f"<p style=\"background: white;\">{html}</p>"
|
96 |
|
97 |
st.subheader("Rewritten document")
|
|
|
5 |
import torch.nn.functional as F
|
6 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
7 |
import pandas as pd
|
8 |
+
import html
|
9 |
|
10 |
model_options = [
|
11 |
'API',
|
|
|
92 |
html = ''
|
93 |
for span in spans:
|
94 |
b = int(256 * span["token_loss"] / highest_loss)
|
95 |
+
html += f'<span style="color: rgba(128, 128, {b:d})" title="{html.escape(span["most_likely_token"])}">{html.escape(span["token"])}</span>'
|
96 |
html = f"<p style=\"background: white;\">{html}</p>"
|
97 |
|
98 |
st.subheader("Rewritten document")
|