Spaces:
Sleeping
Sleeping
update app.py
Browse files
app.py
CHANGED
@@ -23,7 +23,7 @@ st.sidebar.write("""
|
|
23 |
3. If a dropdown menu pops up for a nigerian language, **select the target nigerian language.**
|
24 |
4. Click the Generate button to get a response below the text area.\n
|
25 |
**Note: Model's overall performance vary (hallucinates) due to model size and training data distribution (majorly from news articles and the bible). Performance may worsen significantly with other task outside text generation.
|
26 |
-
For other tasks, we suggest you try them several times.**\n
|
27 |
5. Lastly, you can play with some of the generation parameters below to improve performance.
|
28 |
""")
|
29 |
|
@@ -128,13 +128,15 @@ async def generate_from_api(user_input, generation_config):
|
|
128 |
# Sample texts
|
129 |
sample_texts = {
|
130 |
"select":"",
|
131 |
-
"
|
132 |
-
"
|
|
|
133 |
"Igbo: N'ala Igbo ...": "N'ala Igbo, ọtụtụ ndị mmadụ kwenyere na e nwere mmiri ara na elu-ilu",
|
134 |
-
"who are you?": "who are you?",
|
135 |
"urhobo: Eshare nana ri...":"Eshare nana ri vwo ẹguọnọ rẹ iyono rẹ Aristotle vẹ Plato na",
|
136 |
"Efik: Ke eyo ...":"Ke eyo Jesus ye mme mbet esie, etop emi ama ada ifụre ọsọk mme Jew oro esịt okobụn̄ọde ke ntak idiọkido ke Israel, oro ẹkenyụn̄ ẹdude ke mfụhọ ke itie-ufụn mme nsunsu ido edinam Ido Ukpono Mme Jew eke akpa isua ikie.",
|
137 |
-
"
|
|
|
|
|
138 |
"Classify the sentiment": "Anyi na-echefu oke ike.",
|
139 |
"what is the topic of this text": "Africa Free Trade Zone: Kò sí ìdènà láti kó ọjà láti orílẹ̀èdè kan sí òmíràn",
|
140 |
"diacritize this text: ": "E sun, Alaga, fun ise amalayi ti e n se ni Naijiria. E maa ba a lo, egbon!",
|
@@ -157,9 +159,9 @@ instruction_wrap = {
|
|
157 |
task_options = {
|
158 |
"select": "{}",
|
159 |
"Text Generation": "{}",
|
160 |
-
"Instruction Following": "<prompt> {} <response>:",
|
161 |
"Sentiment Classification": "<classify> {} <sentiment>:",
|
162 |
"Topic Classification": "<classify> {} <topic>",
|
|
|
163 |
"Title Generation": "<title> {} <headline>",
|
164 |
"Text Diacritization": "<diacritize> {}",
|
165 |
"Text Cleaning": "<clean> {}"
|
@@ -199,7 +201,7 @@ def wrap_text(text, task_value):
|
|
199 |
|
200 |
|
201 |
# Text input
|
202 |
-
user_input = st.text_area("Enter text below **(PLEASE, FIRST READ
|
203 |
user_input = instruction_wrap.get(sample_texts.get(user_input, user_input), user_input)
|
204 |
print("Final user input: ", user_input)
|
205 |
if st.button("Generate"):
|
@@ -238,7 +240,7 @@ if st.button("Generate"):
|
|
238 |
generated_text = "Neutral"
|
239 |
|
240 |
elif task == "Topic Classification":
|
241 |
-
generated_text = generated_text[:20]
|
242 |
|
243 |
full_output = st.empty()
|
244 |
|
|
|
23 |
3. If a dropdown menu pops up for a nigerian language, **select the target nigerian language.**
|
24 |
4. Click the Generate button to get a response below the text area.\n
|
25 |
**Note: Model's overall performance vary (hallucinates) due to model size and training data distribution (majorly from news articles and the bible). Performance may worsen significantly with other task outside text generation.
|
26 |
+
For other tasks, we suggest you try them several times due to the generator's sampling method.**\n
|
27 |
5. Lastly, you can play with some of the generation parameters below to improve performance.
|
28 |
""")
|
29 |
|
|
|
128 |
# Sample texts
|
129 |
sample_texts = {
|
130 |
"select":"",
|
131 |
+
"Hausa: Afirka tana da al'adu...": "Afirka tana da al'adu da harsuna masu yawa. Tana da albarkatu da wuraren yawon shakatawa masu ban mamaki.",
|
132 |
+
"Yoruba: Ìmọ̀ sáyẹ́nsì àti...": "Ìmọ̀ sáyẹ́nsì àti tẹ̀knọ́lójì ń ṣe émi lóore tó níye lori ní Áfíríkà. Ó ń fún àwọn ènìyàn ní ànfààní láti dá irọyin àti kí wọ́n lè ṣe àwọn nǹkan tuntun.",
|
133 |
+
"Efik: Oma Ede, Mi ji ogede...": "Oma Ede, Mi ji ogede mi a foroma orhorho edha meji ri eka. ",
|
134 |
"Igbo: N'ala Igbo ...": "N'ala Igbo, ọtụtụ ndị mmadụ kwenyere na e nwere mmiri ara na elu-ilu",
|
|
|
135 |
"urhobo: Eshare nana ri...":"Eshare nana ri vwo ẹguọnọ rẹ iyono rẹ Aristotle vẹ Plato na",
|
136 |
"Efik: Ke eyo ...":"Ke eyo Jesus ye mme mbet esie, etop emi ama ada ifụre ọsọk mme Jew oro esịt okobụn̄ọde ke ntak idiọkido ke Israel, oro ẹkenyụn̄ ẹdude ke mfụhọ ke itie-ufụn mme nsunsu ido edinam Ido Ukpono Mme Jew eke akpa isua ikie.",
|
137 |
+
"Tell me a story in pidgin": "Tell me a story Pidgin",
|
138 |
+
"who are you?": "who are you?",
|
139 |
+
# "Translate 'how are you?' to Yoruba": "Translate 'how are you?' to Yoruba",
|
140 |
"Classify the sentiment": "Anyi na-echefu oke ike.",
|
141 |
"what is the topic of this text": "Africa Free Trade Zone: Kò sí ìdènà láti kó ọjà láti orílẹ̀èdè kan sí òmíràn",
|
142 |
"diacritize this text: ": "E sun, Alaga, fun ise amalayi ti e n se ni Naijiria. E maa ba a lo, egbon!",
|
|
|
159 |
task_options = {
|
160 |
"select": "{}",
|
161 |
"Text Generation": "{}",
|
|
|
162 |
"Sentiment Classification": "<classify> {} <sentiment>:",
|
163 |
"Topic Classification": "<classify> {} <topic>",
|
164 |
+
"Instruction Following" : "<prompt> {} <response>:",
|
165 |
"Title Generation": "<title> {} <headline>",
|
166 |
"Text Diacritization": "<diacritize> {}",
|
167 |
"Text Cleaning": "<clean> {}"
|
|
|
201 |
|
202 |
|
203 |
# Text input
|
204 |
+
user_input = st.text_area("Enter text below **(PLEASE, FIRST READ ALL INSTRUCTIONS IN THE SIDEBAR FOR A BETTER EXPERIENCE)**: ", sample_texts[sample_text])
|
205 |
user_input = instruction_wrap.get(sample_texts.get(user_input, user_input), user_input)
|
206 |
print("Final user input: ", user_input)
|
207 |
if st.button("Generate"):
|
|
|
240 |
generated_text = "Neutral"
|
241 |
|
242 |
elif task == "Topic Classification":
|
243 |
+
generated_text = generated_text.split(" ")[0][:20]
|
244 |
|
245 |
full_output = st.empty()
|
246 |
|