Model and Interface Update
Browse files
app.py
CHANGED
@@ -19,28 +19,49 @@ st.title("Demo for Turkish NER Models")
|
|
19 |
st.write("For details of models: 'https://huggingface.co/akdeniz27/")
|
20 |
st.write("Please refer 'https://huggingface.co/transformers/_modules/transformers/pipelines/token_classification.html' for entity grouping with aggregation_strategy parameter.")
|
21 |
|
|
|
|
|
|
|
|
|
|
|
22 |
st.sidebar.header("Select NER Model")
|
23 |
-
|
24 |
-
if selection == "bert-base-turkish-cased-ner":
|
25 |
-
|
26 |
-
elif selection == "convbert-base-turkish-cased-ner":
|
27 |
-
|
28 |
-
elif selection == "xlm-roberta-base-turkish-ner":
|
29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
st.sidebar.header("Select Aggregation Strategy Type")
|
32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
|
34 |
-
st.
|
35 |
input_method = st.radio("", ('Select among Examples', 'Write or Paste New Text'))
|
36 |
if input_method == 'Select among Examples':
|
37 |
-
st.
|
38 |
-
|
39 |
-
st.
|
40 |
-
input_text = st.text_area("", selected_text, height=128, max_chars=None, key=2)
|
41 |
elif input_method == "Write or Paste New Text":
|
42 |
-
st.
|
43 |
-
input_text = st.text_area('', value="", height=128, max_chars=None, key=2)
|
44 |
|
45 |
def setModel(model_checkpoint, aggregation):
|
46 |
model = AutoModelForTokenClassification.from_pretrained(model_checkpoint)
|
|
|
19 |
st.write("For details of models: 'https://huggingface.co/akdeniz27/")
|
20 |
st.write("Please refer 'https://huggingface.co/transformers/_modules/transformers/pipelines/token_classification.html' for entity grouping with aggregation_strategy parameter.")
|
21 |
|
22 |
+
model_list = ['akdeniz27/bert-base-turkish-cased-ner',
|
23 |
+
'akdeniz27/convbert-base-turkish-cased-ner',
|
24 |
+
'akdeniz27/xlm-roberta-base-turkish-ner',
|
25 |
+
'xlm-roberta-large-finetuned-conll03-english']
|
26 |
+
|
27 |
st.sidebar.header("Select NER Model")
|
28 |
+
model_checkpoint = st.sidebar.radio("", model_list)
|
29 |
+
# if selection == "bert-base-turkish-cased-ner":
|
30 |
+
# model_checkpoint = "akdeniz27/bert-base-turkish-cased-ner"
|
31 |
+
# elif selection == "convbert-base-turkish-cased-ner":
|
32 |
+
# model_checkpoint = "akdeniz27/convbert-base-turkish-cased-ner"
|
33 |
+
# elif selection == "xlm-roberta-base-turkish-ner":
|
34 |
+
# model_checkpoint = "akdeniz27/xlm-roberta-base-turkish-ner"
|
35 |
+
# elif selection == "xlm-roberta-large-finetuned-conll03-english":
|
36 |
+
# model_checkpoint = "xlm-roberta-large-finetuned-conll03-english"
|
37 |
+
|
38 |
+
st.sidebar.write("")
|
39 |
+
st.sidebar.write("")
|
40 |
+
st.sidebar.write("")
|
41 |
+
|
42 |
+
xlm_agg_strategy_info = "'aggregation_strategy' can be selected as 'simple' or 'none' for 'xlm-roberta' because of the RoBERTa model's tokenization approach."
|
43 |
|
44 |
st.sidebar.header("Select Aggregation Strategy Type")
|
45 |
+
if model_checkpoint == "akdeniz27/xlm-roberta-base-turkish-ner":
|
46 |
+
aggregation = st.sidebar.radio("", ('simple', 'none'))
|
47 |
+
st.sidebar.write(xlm_agg_strategy_info)
|
48 |
+
elif model_checkpoint == "xlm-roberta-large-finetuned-conll03-english":
|
49 |
+
aggregation = st.sidebar.radio("", ('simple', 'none'))
|
50 |
+
st.sidebar.write(xlm_agg_strategy_info)
|
51 |
+
st.sidebar.write("")
|
52 |
+
st.sidebar.write("This English NER model is included just to show the zero-shot transfer learning capability of XLM-Roberta.")
|
53 |
+
else:
|
54 |
+
aggregation = st.sidebar.radio("", ('first', 'simple', 'average', 'max', 'none'))
|
55 |
|
56 |
+
st.subheader("Select Text Input Method")
|
57 |
input_method = st.radio("", ('Select among Examples', 'Write or Paste New Text'))
|
58 |
if input_method == 'Select among Examples':
|
59 |
+
selected_text = st.selectbox('Select Text from List', example_list, index=0, key=1)
|
60 |
+
st.subheader("Text to Run")
|
61 |
+
input_text = st.text_area("Selected Text", selected_text, height=128, max_chars=None, key=2)
|
|
|
62 |
elif input_method == "Write or Paste New Text":
|
63 |
+
st.subheader("Text to Run")
|
64 |
+
input_text = st.text_area('Write or Paste Text Below', value="", height=128, max_chars=None, key=2)
|
65 |
|
66 |
def setModel(model_checkpoint, aggregation):
|
67 |
model = AutoModelForTokenClassification.from_pretrained(model_checkpoint)
|