picocreator
commited on
Commit
•
040cd58
1
Parent(s):
f316bb5
Update app.py
Browse files
app.py
CHANGED
@@ -41,7 +41,7 @@ pipeline = PIPELINE(model, "rwkv_vocab_v20230424")
|
|
41 |
|
42 |
# Translation logic
|
43 |
def translate(text, target_language):
|
44 |
-
prompt = f"Translate the following text to {target_language}\n # Input:\n{text}\n\n# Output:\n"
|
45 |
ctx = prompt.strip()
|
46 |
all_tokens = []
|
47 |
out_last = 0
|
@@ -70,6 +70,117 @@ def translate(text, target_language):
|
|
70 |
|
71 |
yield out_str.strip()
|
72 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
# Example data
|
74 |
EXAMPLES = [
|
75 |
["Hello, how are you?", "French"],
|
@@ -89,8 +200,8 @@ with gr.Blocks(title=title) as demo:
|
|
89 |
gr.Markdown("This is the RWKV-5 World v2 1B5 model tailored for translation. Please provide the text and select the target language for translation.")
|
90 |
|
91 |
# Input and output components
|
92 |
-
text = gr.Textbox(lines=5, label="
|
93 |
-
target_language = gr.Dropdown(choices=
|
94 |
output = gr.Textbox(lines=5, label="Translated Text")
|
95 |
submit = gr.Button("Translate", variant="primary")
|
96 |
|
|
|
41 |
|
42 |
# Translation logic
|
43 |
def translate(text, target_language):
|
44 |
+
prompt = f"Translate the following text to {target_language}\n # Input Text:\n{text}\n\n# Output Text:\n"
|
45 |
ctx = prompt.strip()
|
46 |
all_tokens = []
|
47 |
out_last = 0
|
|
|
70 |
|
71 |
yield out_str.strip()
|
72 |
|
73 |
+
# Languages
|
74 |
+
LANGUAGES = [
|
75 |
+
"English",
|
76 |
+
"Chinese",
|
77 |
+
"Spanish",
|
78 |
+
"Bengali",
|
79 |
+
"Hindi",
|
80 |
+
"Portuguese",
|
81 |
+
"Russian",
|
82 |
+
"Japanese",
|
83 |
+
"German",
|
84 |
+
"Chinese (Wu)",
|
85 |
+
"Javanese",
|
86 |
+
"Korean",
|
87 |
+
"French",
|
88 |
+
"Vietnamese",
|
89 |
+
"Telugu",
|
90 |
+
"Chinese (Yue)",
|
91 |
+
"Marathi",
|
92 |
+
"Tamil",
|
93 |
+
"Turkish",
|
94 |
+
"Urdu",
|
95 |
+
"Chinese (Min Nan)",
|
96 |
+
"Chinese (Jin Yu)",
|
97 |
+
"Gujarati",
|
98 |
+
"Polish",
|
99 |
+
"Arabic (Egyptian Spoken)",
|
100 |
+
"Ukrainian",
|
101 |
+
"Italian",
|
102 |
+
"Chinese (Xiang)",
|
103 |
+
"Malayalam",
|
104 |
+
"Chinese (Hakka)",
|
105 |
+
"Kannada",
|
106 |
+
"Oriya",
|
107 |
+
"Panjabi (Western)",
|
108 |
+
"Panjabi (Eastern)",
|
109 |
+
"Sunda",
|
110 |
+
"Romanian",
|
111 |
+
"Bhojpuri",
|
112 |
+
"Azerbaijani (South)",
|
113 |
+
"Farsi (Western)",
|
114 |
+
"Maithili",
|
115 |
+
"Hausa",
|
116 |
+
"Arabic (Algerian Spoken)",
|
117 |
+
"Burmese",
|
118 |
+
"Serbo-Croatian",
|
119 |
+
"Chinese (Gan)",
|
120 |
+
"Awadhi",
|
121 |
+
"Thai",
|
122 |
+
"Dutch",
|
123 |
+
"Yoruba",
|
124 |
+
"Sindhi",
|
125 |
+
"Arabic (Moroccan Spoken)",
|
126 |
+
"Arabic (Saidi Spoken)",
|
127 |
+
"Uzbek, Northern",
|
128 |
+
"Malay",
|
129 |
+
"Amharic",
|
130 |
+
"Indonesian",
|
131 |
+
"Igbo",
|
132 |
+
"Tagalog",
|
133 |
+
"Nepali",
|
134 |
+
"Arabic (Sudanese Spoken)",
|
135 |
+
"Saraiki",
|
136 |
+
"Cebuano",
|
137 |
+
"Arabic (North Levantine Spoken)",
|
138 |
+
"Thai (Northeastern)",
|
139 |
+
"Assamese",
|
140 |
+
"Hungarian",
|
141 |
+
"Chittagonian",
|
142 |
+
"Arabic (Mesopotamian Spoken)",
|
143 |
+
"Madura",
|
144 |
+
"Sinhala",
|
145 |
+
"Haryanvi",
|
146 |
+
"Marwari",
|
147 |
+
"Czech",
|
148 |
+
"Greek",
|
149 |
+
"Magahi",
|
150 |
+
"Chhattisgarhi",
|
151 |
+
"Deccan",
|
152 |
+
"Chinese (Min Bei)",
|
153 |
+
"Belarusan",
|
154 |
+
"Zhuang (Northern)",
|
155 |
+
"Arabic (Najdi Spoken)",
|
156 |
+
"Pashto (Northern)",
|
157 |
+
"Somali",
|
158 |
+
"Malagasy",
|
159 |
+
"Arabic (Tunisian Spoken)",
|
160 |
+
"Rwanda",
|
161 |
+
"Zulu",
|
162 |
+
"Bulgarian",
|
163 |
+
"Swedish",
|
164 |
+
"Lombard",
|
165 |
+
"Oromo (West-central)",
|
166 |
+
"Pashto (Southern)",
|
167 |
+
"Kazakh",
|
168 |
+
"Ilocano",
|
169 |
+
"Tatar",
|
170 |
+
"Fulfulde (Nigerian)",
|
171 |
+
"Arabic (Sanaani Spoken)",
|
172 |
+
"Uyghur",
|
173 |
+
"Haitian Creole French",
|
174 |
+
"Azerbaijani, North",
|
175 |
+
"Napoletano-calabrese",
|
176 |
+
"Khmer (Central)",
|
177 |
+
"Farsi (Eastern)",
|
178 |
+
"Akan",
|
179 |
+
"Hiligaynon",
|
180 |
+
"Kurmanji",
|
181 |
+
"Shona"
|
182 |
+
]
|
183 |
+
|
184 |
# Example data
|
185 |
EXAMPLES = [
|
186 |
["Hello, how are you?", "French"],
|
|
|
200 |
gr.Markdown("This is the RWKV-5 World v2 1B5 model tailored for translation. Please provide the text and select the target language for translation.")
|
201 |
|
202 |
# Input and output components
|
203 |
+
text = gr.Textbox(lines=5, label="Source Text", placeholder="Enter the text you want to translate...")
|
204 |
+
target_language = gr.Dropdown(choices=LANGUAGES, label="Target Language")
|
205 |
output = gr.Textbox(lines=5, label="Translated Text")
|
206 |
submit = gr.Button("Translate", variant="primary")
|
207 |
|