BeardedMonster commited on
Commit
770bd42
·
verified ·
1 Parent(s): e5e53b2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -43,7 +43,7 @@ st.sidebar.write("""
43
  7. **Performance Note:**
44
  - The model's performance varies due to its size and training data. It performs best on text generation and translation.
45
  - For other tasks, try multiple times if model's output is not optimal (This is due to the generator's sampling parameter settings).
46
- - It's best to read/understand/translate the model's output completely first. Model can sometimes fail to stop generation after providing correct answers.
47
  8. **Other Tips:**
48
  - Use simple instructions for instruction following.
49
  - For question answering and generation, follow the structure in the corresponding sample text.
@@ -53,7 +53,7 @@ st.sidebar.write("""
53
  """)
54
 
55
  max_length = 100
56
- max_new_tokens = 50
57
  num_beams = 5
58
  temperature = 0.99
59
  top_k = 50
@@ -90,7 +90,7 @@ st.title("SabiYarn-125M : Generates text in multiple Nigerian languages.")
90
  st.write("**Supported Languages: English, Yoruba, Igbo, Hausa, Pidgin, Efik, Urhobo, Fulfulde, Fulah. \nResults may not be coherent for less represented languages (i.e Efik, \
91
  Urhobo, Fulfulde, Fulah).**")
92
  st.write("**It takes a while (~25s) to return an output on the first 'generate' click. Avg response time: 1-2s on GPU, 40s on CPU**")
93
- st.write("**Model outputs 50 tokens as default. Adjust in the side bar.**")
94
  st.write("**For convenience, you can use chatgpt to provide input text and translate/evaluate model output.**")
95
  st.write("-" * 50)
96
  popular_topics = [
@@ -266,11 +266,11 @@ if st.button("Generate"):
266
  print("Generated text: ", generated_text)
267
 
268
  if task == "Sentiment Classification" :
269
- if generated_text.strip().lower().startswith("negative"):
270
  generated_text = "Negative"
271
- elif generated_text.strip().lower().startswith("positive"):
272
  generated_text = "Positive"
273
- elif generated_text.strip().lower().startswith("neutral"):
274
  generated_text = "Neutral"
275
 
276
  elif task == "Topic Classification":
@@ -281,6 +281,7 @@ if st.button("Generate"):
281
 
282
  elif task == "Translation":
283
  n_sentences = len(re.split(r"\.|\n", user_input))
 
284
  generated_text = ".".join(re.split(r"\.|\n", generated_text)[:n_sentences])
285
 
286
  full_output = st.empty()
 
43
  7. **Performance Note:**
44
  - The model's performance varies due to its size and training data. It performs best on text generation and translation.
45
  - For other tasks, try multiple times if model's output is not optimal (This is due to the generator's sampling parameter settings).
46
+ - **It's best to read/understand/translate the model's output completely first. Model can sometimes fail to stop generation after providing correct answers.**
47
  8. **Other Tips:**
48
  - Use simple instructions for instruction following.
49
  - For question answering and generation, follow the structure in the corresponding sample text.
 
53
  """)
54
 
55
  max_length = 100
56
+ max_new_tokens = 80
57
  num_beams = 5
58
  temperature = 0.99
59
  top_k = 50
 
90
  st.write("**Supported Languages: English, Yoruba, Igbo, Hausa, Pidgin, Efik, Urhobo, Fulfulde, Fulah. \nResults may not be coherent for less represented languages (i.e Efik, \
91
  Urhobo, Fulfulde, Fulah).**")
92
  st.write("**It takes a while (~25s) to return an output on the first 'generate' click. Avg response time: 1-2s on GPU, 40s on CPU**")
93
+ st.write("**Model outputs 80 tokens as default. Adjust in the side bar.**")
94
  st.write("**For convenience, you can use chatgpt to provide input text and translate/evaluate model output.**")
95
  st.write("-" * 50)
96
  popular_topics = [
 
266
  print("Generated text: ", generated_text)
267
 
268
  if task == "Sentiment Classification" :
269
+ if "negative" in generated_text.lower():
270
  generated_text = "Negative"
271
+ elif "positive" in generated_text.lower():
272
  generated_text = "Positive"
273
+ elif "neutral" in generated_text.lower():
274
  generated_text = "Neutral"
275
 
276
  elif task == "Topic Classification":
 
281
 
282
  elif task == "Translation":
283
  n_sentences = len(re.split(r"\.|\n", user_input))
284
+ print("split for translation: ",re.split(r"\.|\n", generated_text)[:n_sentences])
285
  generated_text = ".".join(re.split(r"\.|\n", generated_text)[:n_sentences])
286
 
287
  full_output = st.empty()