ajitrajasekharan
commited on
Commit
•
d1cc326
1
Parent(s):
5c0d071
Update app.py
Browse files
app.py
CHANGED
@@ -51,7 +51,7 @@ def get_all_predictions(text_sentence, top_clean=5):
|
|
51 |
predict = bert_model(input_ids)[0]
|
52 |
bert = decode(bert_tokenizer, predict[0, mask_idx, :].topk(top_k*5).indices.tolist(), top_clean)
|
53 |
cls = decode(bert_tokenizer, predict[0, 0, :].topk(top_k*5).indices.tolist(), top_clean)
|
54 |
-
return {'sentence':text_sentence,'Masked position': bert,'[CLS]':cls}
|
55 |
|
56 |
def get_bert_prediction(input_text,top_k):
|
57 |
try:
|
@@ -83,9 +83,9 @@ st.markdown("""
|
|
83 |
<small style="font-size:18px; color: #8f8f8f">This app is used to qualitatively examine the performance of pretrained models to do NER , <a href="https://ajitrajasekharan.github.io/2021/01/02/my-first-post.html"><b>with no fine tuning</b></small></a>
|
84 |
""", unsafe_allow_html=True)
|
85 |
#st.write("https://ajitrajasekharan.github.io/2021/01/02/my-first-post.html")
|
86 |
-
st.write("
|
87 |
-
st.write("To examine model prediction for a position, enter the token [MASK] or <mask>")
|
88 |
-
st.write("To examine just the [CLS] vector, enter a word/phrase or sentence. Example: eGFR or EGFR or non small cell lung cancer")
|
89 |
top_k = st.sidebar.slider("Select how many predictions do you need", 1 , 50, 20) #some times it is possible to have less words
|
90 |
print(top_k)
|
91 |
|
|
|
51 |
predict = bert_model(input_ids)[0]
|
52 |
bert = decode(bert_tokenizer, predict[0, mask_idx, :].topk(top_k*5).indices.tolist(), top_clean)
|
53 |
cls = decode(bert_tokenizer, predict[0, 0, :].topk(top_k*5).indices.tolist(), top_clean)
|
54 |
+
return {'Input sentence':text_sentence,'Masked position': bert,'[CLS]':cls}
|
55 |
|
56 |
def get_bert_prediction(input_text,top_k):
|
57 |
try:
|
|
|
83 |
<small style="font-size:18px; color: #8f8f8f">This app is used to qualitatively examine the performance of pretrained models to do NER , <a href="https://ajitrajasekharan.github.io/2021/01/02/my-first-post.html"><b>with no fine tuning</b></small></a>
|
84 |
""", unsafe_allow_html=True)
|
85 |
#st.write("https://ajitrajasekharan.github.io/2021/01/02/my-first-post.html")
|
86 |
+
st.write("Model prediction for a masked position as well as the neighborhood of CLS vector for input text can be examined")
|
87 |
+
st.write(" - To examine model prediction for a position, enter the token [MASK] or <mask>")
|
88 |
+
st.write(" - To examine just the [CLS] vector, enter a word/phrase or sentence. Example: eGFR or EGFR or non small cell lung cancer")
|
89 |
top_k = st.sidebar.slider("Select how many predictions do you need", 1 , 50, 20) #some times it is possible to have less words
|
90 |
print(top_k)
|
91 |
|