Nova-school commited on
Commit
c90b054
·
verified ·
1 Parent(s): b8a7e1b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -4
app.py CHANGED
@@ -46,10 +46,16 @@ def Page():
46
  top_10 = torch.topk(scores, 10)
47
  bottom_10 = torch.topk(scores, 10, largest=False)
48
  df = pd.DataFrame()
49
- df["probs"] = top_10.values[0]+bottom_10.values[0]
 
 
50
  df["probs"] = [f"{value:.2%}" for value in df["probs"].values]
51
- df["next token ID"] = [top_10.indices[0][i].numpy() for i in range(10)]+[bottom_10.indices[0][i].numpy() for i in range(10)]
52
- df["predicted next token"] = [tokenizer.decode(top_10.indices[0][i]) for i in range(10)]+[tokenizer.decode(bottom_10.indices[0][i])+10 for i in range(10)]
 
 
 
53
  solara.Markdown("###Prediction")
54
- solara.DataFrame(df, items_per_page=20, cell_actions=cell_actions)
 
55
  Page()
 
46
  top_10 = torch.topk(scores, 10)
47
  bottom_10 = torch.topk(scores, 10, largest=False)
48
  df = pd.DataFrame()
49
+ d2 = pd.DataFrame
50
+ df["probs"] = top_10.values[0]
51
+ d2["probs"] = bottom_10.values[0]
52
  df["probs"] = [f"{value:.2%}" for value in df["probs"].values]
53
+ d2["probs"] = [f"{value:.2%}" for value in d2["probs"].values]
54
+ df["next token ID"] = [top_10.indices[0][i].numpy() for i in range(10)]
55
+ d2["next token ID"] = [bottom_10.indices[0][i].numpy() for i in range(10)]
56
+ df["predicted next token"] = [tokenizer.decode(top_10.indices[0][i]) for i in range(10)]
57
+ d2["predicted next token"] = [tokenizer.decode(bottom_10.indices[0][i]) for i in range(10)]
58
  solara.Markdown("###Prediction")
59
+ solara.DataFrame(df, items_per_page=10, cell_actions=cell_actions)
60
+ solara.DataFrame(d2, items_per_page=10, cell_actions=cell_actions)
61
  Page()