Spaces:
Sleeping
Sleeping
山越貴耀
commited on
Commit
•
234c0d5
1
Parent(s):
0c70c35
test commit
Browse files
app.py
CHANGED
@@ -61,7 +61,8 @@ def run_chains(tokenizer,model,mask_id,input_text,num_steps):
|
|
61 |
for step_id in range(num_steps):
|
62 |
chain_progress.progress((step_id+1)/num_steps)
|
63 |
pos = torch.randint(seq_len-2,size=(1,)).item()+1
|
64 |
-
data_list.append([step_id,' '.join([tokenizer.decode([token]) for token in sentence[0]]),pos])
|
|
|
65 |
probs = mask_prob(model,mask_id,sentence,pos)
|
66 |
sentence,_ = sample_words(probs,pos,sentence)
|
67 |
return pd.DataFrame(data=data_list,columns=['step','sentence','next_sample_loc'])
|
@@ -93,7 +94,6 @@ def update_sent_id(increment_value=0):
|
|
93 |
def initialize_sent_id():
|
94 |
st.session_state.sent_id = st.session_state.sent_id_from_slider
|
95 |
|
96 |
-
|
97 |
if __name__=='__main__':
|
98 |
# Config
|
99 |
max_width = 1500
|
@@ -124,6 +124,7 @@ if __name__=='__main__':
|
|
124 |
|
125 |
# Title
|
126 |
st.header("Demo: Probing BERT's priors with serial reproduction chains")
|
|
|
127 |
with st.expander("Expand to read the descriptions"):
|
128 |
st.text("Let's explore sentences in the serial reproduction chains generated by BERT!")
|
129 |
st.text("First, please choose the samples from the two pre-generated chains,")
|
|
|
61 |
for step_id in range(num_steps):
|
62 |
chain_progress.progress((step_id+1)/num_steps)
|
63 |
pos = torch.randint(seq_len-2,size=(1,)).item()+1
|
64 |
+
#data_list.append([step_id,' '.join([tokenizer.decode([token]) for token in sentence[0]]),pos])
|
65 |
+
data_list.append([step_id,tokenizer.decode([token for token in sentence[0]]),pos])
|
66 |
probs = mask_prob(model,mask_id,sentence,pos)
|
67 |
sentence,_ = sample_words(probs,pos,sentence)
|
68 |
return pd.DataFrame(data=data_list,columns=['step','sentence','next_sample_loc'])
|
|
|
94 |
def initialize_sent_id():
|
95 |
st.session_state.sent_id = st.session_state.sent_id_from_slider
|
96 |
|
|
|
97 |
if __name__=='__main__':
|
98 |
# Config
|
99 |
max_width = 1500
|
|
|
124 |
|
125 |
# Title
|
126 |
st.header("Demo: Probing BERT's priors with serial reproduction chains")
|
127 |
+
# Descriptions
|
128 |
with st.expander("Expand to read the descriptions"):
|
129 |
st.text("Let's explore sentences in the serial reproduction chains generated by BERT!")
|
130 |
st.text("First, please choose the samples from the two pre-generated chains,")
|