Spaces:
Runtime error
Runtime error
Added models info
Browse files- app.py +2 -3
- apps/about.py +4 -2
- apps/{inference.py → mlm.py} +16 -16
- multiapp.py +1 -4
app.py
CHANGED
@@ -1,11 +1,10 @@
|
|
1 |
-
import
|
2 |
from multiapp import MultiApp
|
3 |
-
from apps import about, inference
|
4 |
|
5 |
|
6 |
def main():
|
7 |
app = MultiApp()
|
8 |
-
app.add_app("
|
9 |
app.add_app("About", about.app)
|
10 |
app.run()
|
11 |
|
|
|
1 |
+
from apps import about, mlm
|
2 |
from multiapp import MultiApp
|
|
|
3 |
|
4 |
|
5 |
def main():
|
6 |
app = MultiApp()
|
7 |
+
app.add_app("Fill Mask", mlm.app)
|
8 |
app.add_app("About", about.app)
|
9 |
app.run()
|
10 |
|
apps/about.py
CHANGED
@@ -1,6 +1,8 @@
|
|
1 |
-
import streamlit as st
|
2 |
-
import os
|
3 |
import json
|
|
|
|
|
|
|
|
|
4 |
|
5 |
def read_markdown(path, folder="./About/"):
|
6 |
with open(os.path.join(folder, path)) as f:
|
|
|
|
|
|
|
1 |
import json
|
2 |
+
import os
|
3 |
+
|
4 |
+
import streamlit as st
|
5 |
+
|
6 |
|
7 |
def read_markdown(path, folder="./About/"):
|
8 |
with open(os.path.join(folder, path)) as f:
|
apps/{inference.py → mlm.py}
RENAMED
@@ -1,12 +1,11 @@
|
|
1 |
-
from pandas.io.formats.format import return_docstring
|
2 |
-
import streamlit as st
|
3 |
-
import pandas as pd
|
4 |
-
from transformers import AutoTokenizer, AutoModelForMaskedLM
|
5 |
-
from transformers import pipeline
|
6 |
-
import os
|
7 |
import json
|
|
|
8 |
import random
|
9 |
|
|
|
|
|
|
|
|
|
10 |
with open("config.json") as f:
|
11 |
cfg = json.loads(f.read())
|
12 |
|
@@ -27,13 +26,8 @@ def load_model(masked_text, model_name):
|
|
27 |
|
28 |
|
29 |
def app():
|
30 |
-
st.
|
31 |
-
|
32 |
-
unsafe_allow_html=True,
|
33 |
-
)
|
34 |
-
st.markdown(
|
35 |
-
"This demo uses multiple hindi transformer models for Masked Language Modelling (MLM)."
|
36 |
-
)
|
37 |
|
38 |
models_list = list(cfg["models"].keys())
|
39 |
|
@@ -50,6 +44,14 @@ def app():
|
|
50 |
|
51 |
results_df = pd.DataFrame(columns=["Model Name", "Filled Token", "Filled Text"])
|
52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
model_names = []
|
54 |
filled_masked_texts = []
|
55 |
filled_tokens = []
|
@@ -67,9 +69,7 @@ def app():
|
|
67 |
|
68 |
for selected_model in models:
|
69 |
|
70 |
-
filled_sentence, filled_token = load_model(
|
71 |
-
masked_text, cfg["models"][selected_model]
|
72 |
-
)
|
73 |
model_names.append(selected_model)
|
74 |
filled_tokens.append(filled_token)
|
75 |
filled_masked_texts.append(filled_sentence)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import json
|
2 |
+
import os
|
3 |
import random
|
4 |
|
5 |
+
import pandas as pd
|
6 |
+
import streamlit as st
|
7 |
+
from transformers import AutoModelForMaskedLM, AutoTokenizer, pipeline
|
8 |
+
|
9 |
with open("config.json") as f:
|
10 |
cfg = json.loads(f.read())
|
11 |
|
|
|
26 |
|
27 |
|
28 |
def app():
|
29 |
+
st.header("RoBERTa Hindi")
|
30 |
+
st.markdown("This demo uses multiple hindi transformer models for Masked Language Modelling (MLM).")
|
|
|
|
|
|
|
|
|
|
|
31 |
|
32 |
models_list = list(cfg["models"].keys())
|
33 |
|
|
|
44 |
|
45 |
results_df = pd.DataFrame(columns=["Model Name", "Filled Token", "Filled Text"])
|
46 |
|
47 |
+
st.sidebar.markdown(
|
48 |
+
"Models\n"
|
49 |
+
"- [RoBERTa Hindi](https://huggingface.co/flax-community/roberta-hindi)\n"
|
50 |
+
"- [Indic Transformers Hindi](https://huggingface.co/neuralspace-reverie/indic-transformers-hi-bert)\n"
|
51 |
+
"- [HindiBERTa]((https://huggingface.co/mrm8488/HindiBERTa)\n"
|
52 |
+
"- [RoBERTa Hindi Guj San](https://huggingface.co/surajp/RoBERTa-hindi-guj-san)"
|
53 |
+
)
|
54 |
+
|
55 |
model_names = []
|
56 |
filled_masked_texts = []
|
57 |
filled_tokens = []
|
|
|
69 |
|
70 |
for selected_model in models:
|
71 |
|
72 |
+
filled_sentence, filled_token = load_model(masked_text, cfg["models"][selected_model])
|
|
|
|
|
73 |
model_names.append(selected_model)
|
74 |
filled_tokens.append(filled_token)
|
75 |
filled_masked_texts.append(filled_sentence)
|
multiapp.py
CHANGED
@@ -1,5 +1,3 @@
|
|
1 |
-
"""Frameworks for running multiple Streamlit applications as a single app.
|
2 |
-
"""
|
3 |
import streamlit as st
|
4 |
|
5 |
|
@@ -12,7 +10,6 @@ class MultiApp:
|
|
12 |
|
13 |
def run(self):
|
14 |
st.sidebar.header("Navigation")
|
15 |
-
app = st.sidebar.
|
16 |
|
17 |
app["function"]()
|
18 |
-
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
|
3 |
|
|
|
10 |
|
11 |
def run(self):
|
12 |
st.sidebar.header("Navigation")
|
13 |
+
app = st.sidebar.radio("", self.apps, format_func=lambda app: app["title"])
|
14 |
|
15 |
app["function"]()
|
|