akdeniz27 commited on
Commit
f474e98
1 Parent(s): 41ca91f

Model and Interface Update

Browse files
Files changed (1) hide show
  1. app.py +36 -15
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
- selection = st.sidebar.radio("", ('bert-base-turkish-cased-ner', 'convbert-base-turkish-cased-ner', 'xlm-roberta-base-turkish-ner'))
24
- if selection == "bert-base-turkish-cased-ner":
25
- model_checkpoint = "akdeniz27/bert-base-turkish-cased-ner"
26
- elif selection == "convbert-base-turkish-cased-ner":
27
- model_checkpoint = "akdeniz27/convbert-base-turkish-cased-ner"
28
- elif selection == "xlm-roberta-base-turkish-ner":
29
- model_checkpoint = "akdeniz27/xlm-roberta-base-turkish-ner"
 
 
 
 
 
 
 
 
30
 
31
  st.sidebar.header("Select Aggregation Strategy Type")
32
- aggregation = st.sidebar.radio("", ('first', 'simple', 'average', 'max', 'none'))
 
 
 
 
 
 
 
 
 
33
 
34
- st.header("Select Text Input Method")
35
  input_method = st.radio("", ('Select among Examples', 'Write or Paste New Text'))
36
  if input_method == 'Select among Examples':
37
- st.header("Select Text")
38
- selected_text = st.selectbox('', example_list, index=0, key=1)
39
- st.header("Selected Text")
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.header("Write or Paste New Text")
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)