Spaces:
Running
Running
BeardedMonster
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -16,16 +16,44 @@ model = AutoModelForCausalLM.from_pretrained(repo_name, trust_remote_code=True).
|
|
16 |
|
17 |
# Add sidebar with instructions
|
18 |
st.sidebar.title("Instructions: How to use")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
st.sidebar.write("""
|
20 |
-
1. Write
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
""")
|
30 |
|
31 |
max_length = 100
|
@@ -48,17 +76,6 @@ repetition_penalty = st.sidebar.slider("Repetition Penalty: Discourages token re
|
|
48 |
length_penalty = st.sidebar.slider("Length Penalty: Discourages poor output as token length grows.", min_value=0.1, max_value=10.0, value=length_penalty)
|
49 |
|
50 |
|
51 |
-
# Define generation configuration
|
52 |
-
# max_length = st.sidebar.slider("Max Length", min_value=10, max_value=500, value=100)
|
53 |
-
# max_new_tokens = st.sidebar.slider("Max tokens", min_value=30, max_value=768, value=50)
|
54 |
-
# num_beams = st.sidebar.slider("Number of Beams", min_value=1, max_value=10, value=5)
|
55 |
-
# temperature = st.sidebar.slider("Temperature", min_value=0.1, max_value=2.0, value=0.9)
|
56 |
-
# top_k = st.sidebar.slider("Top-K", min_value=1, max_value=100, value=50)
|
57 |
-
# top_p = st.sidebar.slider("Top-P", min_value=0.1, max_value=1.0, value=0.95)
|
58 |
-
# repetition_penalty = st.sidebar.slider("Repetition Penalty", min_value=1.0, max_value=10.0, value=2.0)
|
59 |
-
# length_penalty = st.sidebar.slider("Length Penalty", min_value=0.1, max_value=10.0, value=1.7)
|
60 |
-
# # early_stopping = st.sidebar.selectbox("Early Stopping", [True, False], index=0)
|
61 |
-
|
62 |
generation_config = {
|
63 |
"max_length": max_length,
|
64 |
"num_beams": num_beams,
|
@@ -192,7 +209,7 @@ sample_text = st.selectbox("Select a sample text to test the model:", list(sampl
|
|
192 |
task = st.selectbox("Select a task for the model:", list(task_options.keys()))
|
193 |
|
194 |
# Conditionally show language options dropdown for diacritize and clean tasks
|
195 |
-
if task in ["
|
196 |
language = st.selectbox("Select a Nigerian language:", list(language_options.keys()))
|
197 |
task_value = f"{task_options[task]} {language_options[language]}"
|
198 |
else:
|
|
|
16 |
|
17 |
# Add sidebar with instructions
|
18 |
st.sidebar.title("Instructions: How to use")
|
19 |
+
# st.sidebar.write("""
|
20 |
+
# 1. Write something in the text area (a prompt or random text) or use the dropdown menu to select predefined sample text.
|
21 |
+
# 2. Select a task from the **task dropdown menu** below only if you are providing your own text. **This is very important as it ensures the model responds accordingly.**
|
22 |
+
# 3. If you are providing your own text, please do not select any predefined sample text from the dropdown menu.
|
23 |
+
# 3. If a dropdown menu pops up for a nigerian language, **select the nigerian language (base language for diacritization and text cleaning tasks, target language for translation task).**
|
24 |
+
# 4. Then, click the Generate button.\n
|
25 |
+
# 5. For Translation tasks, setting english as the target language yields the best result (english as base language performs the worst).
|
26 |
+
# **Note: Model's overall performance vary (hallucinates) due to model size and training data distribution (majorly from articles and the bible). Performance may worsen with other task outside text generation and translation.
|
27 |
+
# For other tasks, we suggest you try them several times due to the generator's sampling method.**\n
|
28 |
+
# 6. Lastly, you can play with some of the generation parameters below to improve performance.
|
29 |
+
# """)
|
30 |
+
|
31 |
st.sidebar.write("""
|
32 |
+
1. **Write Text or Select Sample:**
|
33 |
+
- Enter text in the text area or use the dropdown to choose a sample.
|
34 |
+
|
35 |
+
2. **Select a Task:**
|
36 |
+
- Choose a task from the **task dropdown** if using your own text.
|
37 |
+
- **Important:** This ensures correct model response.
|
38 |
+
|
39 |
+
3. **Avoid Conflicts:**
|
40 |
+
- Don't select a sample text if using your own text.
|
41 |
+
|
42 |
+
4. **Select Nigerian Language:**
|
43 |
+
- If prompted, choose the Nigerian language (base for diacritization/cleaning, target for translation).
|
44 |
+
|
45 |
+
5. **Generate Output:**
|
46 |
+
- Click the Generate button.
|
47 |
+
|
48 |
+
6. **Translation Tips:**
|
49 |
+
- English as the target language gives the best results. English as the base language performs poorly.
|
50 |
+
|
51 |
+
7. **Performance Note:**
|
52 |
+
- The model's performance varies due to its size and training data. It performs best on text generation and translation.
|
53 |
+
- For other tasks, try multiple times due to sampling.
|
54 |
+
|
55 |
+
8. **Adjust Parameters:**
|
56 |
+
- Experiment with the generation parameters to improve performance.
|
57 |
""")
|
58 |
|
59 |
max_length = 100
|
|
|
76 |
length_penalty = st.sidebar.slider("Length Penalty: Discourages poor output as token length grows.", min_value=0.1, max_value=10.0, value=length_penalty)
|
77 |
|
78 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
generation_config = {
|
80 |
"max_length": max_length,
|
81 |
"num_beams": num_beams,
|
|
|
209 |
task = st.selectbox("Select a task for the model:", list(task_options.keys()))
|
210 |
|
211 |
# Conditionally show language options dropdown for diacritize and clean tasks
|
212 |
+
if task in ["Text Diacritization", "Text Cleaning", "Translation"]:
|
213 |
language = st.selectbox("Select a Nigerian language:", list(language_options.keys()))
|
214 |
task_value = f"{task_options[task]} {language_options[language]}"
|
215 |
else:
|