Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -17,26 +17,22 @@ Pfizer, aşının güvenli ve etkili olduğunun klinik olarak da kanıtlanması
|
|
| 17 |
st.set_page_config(layout="wide")
|
| 18 |
|
| 19 |
st.title("Demo for Turkish NER Models")
|
| 20 |
-
st.write("For details of models: 'https://huggingface.co/akdeniz27/")
|
| 21 |
-
st.write("Please refer 'https://huggingface.co/transformers/_modules/transformers/pipelines/token_classification.html' for entity grouping with aggregation_strategy parameter.")
|
| 22 |
|
| 23 |
model_list = ['akdeniz27/bert-base-turkish-cased-ner',
|
| 24 |
'akdeniz27/convbert-base-turkish-cased-ner',
|
| 25 |
'akdeniz27/xlm-roberta-base-turkish-ner',
|
| 26 |
-
'akdeniz27/mDeBERTa-v3-base-turkish-ner',
|
| 27 |
'xlm-roberta-large-finetuned-conll03-english']
|
| 28 |
|
| 29 |
st.sidebar.header("Select NER Model")
|
| 30 |
model_checkpoint = st.sidebar.radio("", model_list)
|
| 31 |
|
| 32 |
-
st.sidebar.write("")
|
| 33 |
-
st.sidebar.write("")
|
| 34 |
st.sidebar.write("")
|
| 35 |
|
| 36 |
xlm_agg_strategy_info = "'aggregation_strategy' can be selected as 'simple' or 'none' for 'xlm-roberta' because of the RoBERTa model's tokenization approach."
|
| 37 |
|
| 38 |
st.sidebar.header("Select Aggregation Strategy Type")
|
| 39 |
-
if model_checkpoint == "akdeniz27/xlm-roberta-base-turkish-ner"
|
| 40 |
aggregation = st.sidebar.radio("", ('simple', 'none'))
|
| 41 |
st.sidebar.write(xlm_agg_strategy_info)
|
| 42 |
elif model_checkpoint == "xlm-roberta-large-finetuned-conll03-english":
|
|
@@ -46,6 +42,8 @@ elif model_checkpoint == "xlm-roberta-large-finetuned-conll03-english":
|
|
| 46 |
st.sidebar.write("This English NER model is included just to show the zero-shot transfer learning capability of XLM-Roberta.")
|
| 47 |
else:
|
| 48 |
aggregation = st.sidebar.radio("", ('first', 'simple', 'average', 'max', 'none'))
|
|
|
|
|
|
|
| 49 |
|
| 50 |
st.subheader("Select Text Input Method")
|
| 51 |
input_method = st.radio("", ('Select from Examples', 'Write or Paste New Text'))
|
|
@@ -59,12 +57,8 @@ elif input_method == "Write or Paste New Text":
|
|
| 59 |
|
| 60 |
@st.cache(allow_output_mutation=True)
|
| 61 |
def setModel(model_checkpoint, aggregation):
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
tokenizer = DebertaV2Tokenizer.from_pretrained(model_checkpoint)
|
| 65 |
-
else:
|
| 66 |
-
model = AutoModelForTokenClassification.from_pretrained(model_checkpoint)
|
| 67 |
-
tokenizer = AutoTokenizer.from_pretrained(model_checkpoint)
|
| 68 |
return pipeline('ner', model=model, tokenizer=tokenizer, aggregation_strategy=aggregation)
|
| 69 |
|
| 70 |
@st.cache(allow_output_mutation=True)
|
|
|
|
| 17 |
st.set_page_config(layout="wide")
|
| 18 |
|
| 19 |
st.title("Demo for Turkish NER Models")
|
|
|
|
|
|
|
| 20 |
|
| 21 |
model_list = ['akdeniz27/bert-base-turkish-cased-ner',
|
| 22 |
'akdeniz27/convbert-base-turkish-cased-ner',
|
| 23 |
'akdeniz27/xlm-roberta-base-turkish-ner',
|
|
|
|
| 24 |
'xlm-roberta-large-finetuned-conll03-english']
|
| 25 |
|
| 26 |
st.sidebar.header("Select NER Model")
|
| 27 |
model_checkpoint = st.sidebar.radio("", model_list)
|
| 28 |
|
| 29 |
+
st.sidebar.write("For details of models: 'https://huggingface.co/akdeniz27/")
|
|
|
|
| 30 |
st.sidebar.write("")
|
| 31 |
|
| 32 |
xlm_agg_strategy_info = "'aggregation_strategy' can be selected as 'simple' or 'none' for 'xlm-roberta' because of the RoBERTa model's tokenization approach."
|
| 33 |
|
| 34 |
st.sidebar.header("Select Aggregation Strategy Type")
|
| 35 |
+
if model_checkpoint == "akdeniz27/xlm-roberta-base-turkish-ner":
|
| 36 |
aggregation = st.sidebar.radio("", ('simple', 'none'))
|
| 37 |
st.sidebar.write(xlm_agg_strategy_info)
|
| 38 |
elif model_checkpoint == "xlm-roberta-large-finetuned-conll03-english":
|
|
|
|
| 42 |
st.sidebar.write("This English NER model is included just to show the zero-shot transfer learning capability of XLM-Roberta.")
|
| 43 |
else:
|
| 44 |
aggregation = st.sidebar.radio("", ('first', 'simple', 'average', 'max', 'none'))
|
| 45 |
+
|
| 46 |
+
st.write("Please refer 'https://huggingface.co/transformers/_modules/transformers/pipelines/token_classification.html' for entity grouping with aggregation_strategy parameter.")
|
| 47 |
|
| 48 |
st.subheader("Select Text Input Method")
|
| 49 |
input_method = st.radio("", ('Select from Examples', 'Write or Paste New Text'))
|
|
|
|
| 57 |
|
| 58 |
@st.cache(allow_output_mutation=True)
|
| 59 |
def setModel(model_checkpoint, aggregation):
|
| 60 |
+
model = AutoModelForTokenClassification.from_pretrained(model_checkpoint)
|
| 61 |
+
tokenizer = AutoTokenizer.from_pretrained(model_checkpoint)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
return pipeline('ner', model=model, tokenizer=tokenizer, aggregation_strategy=aggregation)
|
| 63 |
|
| 64 |
@st.cache(allow_output_mutation=True)
|