m-ric HF staff commited on
Commit
4ef6980
β€’
1 Parent(s): 8666c72

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -159,11 +159,11 @@ def generate_markdown_table(scores, sequence_prob, top_k=4, chosen_tokens=None):
159
  </tr>"""
160
  for token_idx in np.array(np.argsort(scores)[-top_k:])[::-1]:
161
  token = tokenizer.decode([token_idx])
162
- style = ""
163
  if chosen_tokens and token in chosen_tokens:
164
- style = "background-color:red"
165
  markdown_table += f"""
166
- <tr style={style}>
167
  <td>{token}</td>
168
  <td>{scores[token_idx]:.4f}</td>
169
  <td>{scores[token_idx] + sequence_prob:.4f}</td>
 
159
  </tr>"""
160
  for token_idx in np.array(np.argsort(scores)[-top_k:])[::-1]:
161
  token = tokenizer.decode([token_idx])
162
+ item_class = ""
163
  if chosen_tokens and token in chosen_tokens:
164
+ item_class = "chosen"
165
  markdown_table += f"""
166
+ <tr class={item_class}>
167
  <td>{token}</td>
168
  <td>{scores[token_idx]:.4f}</td>
169
  <td>{scores[token_idx] + sequence_prob:.4f}</td>