Simon Salmon
commited on
Commit
·
d1bb134
1
Parent(s):
44fc0ac
Update app.py
Browse files
app.py
CHANGED
@@ -26,7 +26,7 @@ with st.form(key='my_form'):
|
|
26 |
submit_button = st.form_submit_button(label='Submit')
|
27 |
|
28 |
if submit_button:
|
29 |
-
|
30 |
token_ids = tokenizer.encode(prompt, return_tensors='pt')
|
31 |
token_ids_tk = tokenizer.tokenize(prompt, return_tensors='pt')
|
32 |
masked_position = (token_ids.squeeze() == tokenizer.mask_token_id).nonzero()
|
@@ -39,15 +39,15 @@ with st.form(key='my_form'):
|
|
39 |
idx = torch.topk(mask_hidden_state, k=100, dim=0)[1]
|
40 |
words = [tokenizer.decode(i.item()).strip() for i in idx]
|
41 |
a_list.append(words)
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
#st.write(words)
|
47 |
#col1= st.columns(1)
|
48 |
#with col1:
|
49 |
#st.write(words)
|
50 |
-
|
51 |
... 'first column': first_half,
|
52 |
... 'second column': second_half,
|
53 |
-
...
|
|
|
26 |
submit_button = st.form_submit_button(label='Submit')
|
27 |
|
28 |
if submit_button:
|
29 |
+
a_list = []
|
30 |
token_ids = tokenizer.encode(prompt, return_tensors='pt')
|
31 |
token_ids_tk = tokenizer.tokenize(prompt, return_tensors='pt')
|
32 |
masked_position = (token_ids.squeeze() == tokenizer.mask_token_id).nonzero()
|
|
|
39 |
idx = torch.topk(mask_hidden_state, k=100, dim=0)[1]
|
40 |
words = [tokenizer.decode(i.item()).strip() for i in idx]
|
41 |
a_list.append(words)
|
42 |
+
length = len(a_list)
|
43 |
+
middle_index = length//2
|
44 |
+
first_half = a_list[:middle_index]
|
45 |
+
second_half = a_list[middle_index:]
|
46 |
#st.write(words)
|
47 |
#col1= st.columns(1)
|
48 |
#with col1:
|
49 |
#st.write(words)
|
50 |
+
st.write(pd.DataFrame({
|
51 |
... 'first column': first_half,
|
52 |
... 'second column': second_half,
|
53 |
+
... }))
|