Spaces:
Running
on
Zero
Running
on
Zero
Fix
Browse files
app.py
CHANGED
@@ -175,7 +175,7 @@ def diffusion_chat(question, eot_weight, max_it, sharpness, noise_clipping, use_
|
|
175 |
generated_tokens, confidences = generate_diffusion_text(current_tokens)
|
176 |
|
177 |
# Save full output for noising step
|
178 |
-
current_tokens = ori_input_tokens[answer_start] + generated_tokens[answer_start:]
|
179 |
|
180 |
# --- GREEN HIGHLIGHT ---
|
181 |
decoded_tokens = tokenizer.convert_ids_to_tokens(current_tokens[answer_start:])
|
@@ -194,6 +194,14 @@ def diffusion_chat(question, eot_weight, max_it, sharpness, noise_clipping, use_
|
|
194 |
yield f"<b>Iteration {i+1}/{max_it} (after generation):</b><br>" + "".join(highlighted).replace('\n', '<br>')
|
195 |
time.sleep(0.1)
|
196 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
197 |
# --- NOISING STEP ---
|
198 |
threshold = get_noising_schedule(i, max_it, sharpness=sharpness)
|
199 |
if use_confidence_noising:
|
@@ -226,13 +234,6 @@ def diffusion_chat(question, eot_weight, max_it, sharpness, noise_clipping, use_
|
|
226 |
yield f"<b>Iteration {i+1}/{max_it} (after noising):</b><br>" + "".join(highlighted).replace('\n', '<br>')
|
227 |
time.sleep(0.1)
|
228 |
|
229 |
-
# --- Early stopping ---
|
230 |
-
last_tokens.append(generated_tokens)
|
231 |
-
if len(last_tokens) > 3:
|
232 |
-
last_tokens.pop(0)
|
233 |
-
if len(last_tokens) == 3 and last_tokens[0] == last_tokens[1] == last_tokens[2]:
|
234 |
-
yield f"<b>Stopped early after {i+1} iterations.</b>"
|
235 |
-
break
|
236 |
|
237 |
final_tokens = tokenizer.convert_ids_to_tokens(current_tokens[answer_start:])
|
238 |
final_tokens = [tok for tok in final_tokens if tokenizer.convert_tokens_to_ids(tok) != eot_token_id]
|
|
|
175 |
generated_tokens, confidences = generate_diffusion_text(current_tokens)
|
176 |
|
177 |
# Save full output for noising step
|
178 |
+
current_tokens = ori_input_tokens[:answer_start] + generated_tokens[answer_start:]
|
179 |
|
180 |
# --- GREEN HIGHLIGHT ---
|
181 |
decoded_tokens = tokenizer.convert_ids_to_tokens(current_tokens[answer_start:])
|
|
|
194 |
yield f"<b>Iteration {i+1}/{max_it} (after generation):</b><br>" + "".join(highlighted).replace('\n', '<br>')
|
195 |
time.sleep(0.1)
|
196 |
|
197 |
+
# --- Early stopping ---
|
198 |
+
last_tokens.append(current_tokens)
|
199 |
+
if len(last_tokens) > 3:
|
200 |
+
last_tokens.pop(0)
|
201 |
+
if len(last_tokens) == 3 and last_tokens[0] == last_tokens[1] == last_tokens[2]:
|
202 |
+
yield f"<b>Stopped early after {i+1} iterations.</b>"
|
203 |
+
break
|
204 |
+
|
205 |
# --- NOISING STEP ---
|
206 |
threshold = get_noising_schedule(i, max_it, sharpness=sharpness)
|
207 |
if use_confidence_noising:
|
|
|
234 |
yield f"<b>Iteration {i+1}/{max_it} (after noising):</b><br>" + "".join(highlighted).replace('\n', '<br>')
|
235 |
time.sleep(0.1)
|
236 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
237 |
|
238 |
final_tokens = tokenizer.convert_ids_to_tokens(current_tokens[answer_start:])
|
239 |
final_tokens = [tok for tok in final_tokens if tokenizer.convert_tokens_to_ids(tok) != eot_token_id]
|