Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -117,12 +117,13 @@ def inference(text, progress=gr.Progress()):
|
|
117 |
|
118 |
sentences = text.split('\n')
|
119 |
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
if len(
|
124 |
-
|
125 |
|
|
|
126 |
t0 = time.time()
|
127 |
|
128 |
prompt = "Translate the text to Ukrainian:\n" + sentence
|
@@ -139,15 +140,15 @@ def inference(text, progress=gr.Progress()):
|
|
139 |
max_new_tokens=2048,
|
140 |
|
141 |
# Greedy Search
|
142 |
-
|
143 |
-
|
144 |
|
145 |
# Sampling
|
146 |
-
do_sample=True,
|
147 |
-
temperature=0.1,
|
148 |
-
# top_k=1,
|
149 |
-
min_p=0.9,
|
150 |
-
repetition_penalty=1.05,
|
151 |
)
|
152 |
|
153 |
prompt_len = input_ids.shape[1]
|
|
|
117 |
|
118 |
sentences = text.split('\n')
|
119 |
|
120 |
+
non_empty_sentences = []
|
121 |
+
for sentence in sentences:
|
122 |
+
s = sentence.strip()
|
123 |
+
if len(s) != 0:
|
124 |
+
non_empty_sentences.append(s)
|
125 |
|
126 |
+
for sentence in progress.tqdm(non_empty_sentences, desc="Translating...", unit="sentence"):
|
127 |
t0 = time.time()
|
128 |
|
129 |
prompt = "Translate the text to Ukrainian:\n" + sentence
|
|
|
140 |
max_new_tokens=2048,
|
141 |
|
142 |
# Greedy Search
|
143 |
+
do_sample=False,
|
144 |
+
repetition_penalty=1.05,
|
145 |
|
146 |
# Sampling
|
147 |
+
# do_sample=True,
|
148 |
+
# temperature=0.1,
|
149 |
+
# # top_k=1,
|
150 |
+
# min_p=0.9,
|
151 |
+
# repetition_penalty=1.05,
|
152 |
)
|
153 |
|
154 |
prompt_len = input_ids.shape[1]
|