Spaces:
Running
on
Zero
Running
on
Zero
Fix generation
Browse files
app.py
CHANGED
@@ -171,15 +171,11 @@ def diffusion_chat(question, eot_weight, max_it, sharpness, noise_clipping, use_
|
|
171 |
for i in range(max_it):
|
172 |
print('Generating output')
|
173 |
|
174 |
-
# Compose full input: original prompt + current answer
|
175 |
-
full_input_tokens = ori_input_tokens[:answer_start] + current_tokens[answer_start:]
|
176 |
-
full_input_tokens = full_input_tokens[:256] + [pad_token] * max(0, 256 - len(full_input_tokens))
|
177 |
-
|
178 |
# Model step
|
179 |
-
generated_tokens, confidences = generate_diffusion_text(
|
180 |
|
181 |
# Save full output for noising step
|
182 |
-
current_tokens = generated_tokens
|
183 |
|
184 |
# --- GREEN HIGHLIGHT ---
|
185 |
decoded_tokens = tokenizer.convert_ids_to_tokens(current_tokens[answer_start:])
|
@@ -202,17 +198,16 @@ def diffusion_chat(question, eot_weight, max_it, sharpness, noise_clipping, use_
|
|
202 |
threshold = get_noising_schedule(i, max_it, sharpness=sharpness)
|
203 |
if use_confidence_noising:
|
204 |
noised_answer = confidence_guided_noising(
|
205 |
-
|
206 |
)
|
207 |
just_noised_indices = []
|
208 |
else:
|
209 |
noised_answer, just_noised_indices = noisify_answer(
|
210 |
-
|
211 |
)
|
212 |
|
213 |
# Compose full input again: prompt + noised answer
|
214 |
current_tokens = ori_input_tokens[:answer_start] + noised_answer[answer_start:]
|
215 |
-
current_tokens = current_tokens[:256] + [pad_token] * max(0, 256 - len(current_tokens))
|
216 |
|
217 |
# --- RED HIGHLIGHT ---
|
218 |
decoded_tokens = tokenizer.convert_ids_to_tokens(current_tokens[answer_start:])
|
|
|
171 |
for i in range(max_it):
|
172 |
print('Generating output')
|
173 |
|
|
|
|
|
|
|
|
|
174 |
# Model step
|
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:])
|
|
|
198 |
threshold = get_noising_schedule(i, max_it, sharpness=sharpness)
|
199 |
if use_confidence_noising:
|
200 |
noised_answer = confidence_guided_noising(
|
201 |
+
current_tokens, answer_start, confidences, threshold, eot_weight, noise_clipping
|
202 |
)
|
203 |
just_noised_indices = []
|
204 |
else:
|
205 |
noised_answer, just_noised_indices = noisify_answer(
|
206 |
+
current_tokens, answer_start, threshold=threshold, eot_weight=eot_weight, clustering=clustering
|
207 |
)
|
208 |
|
209 |
# Compose full input again: prompt + noised answer
|
210 |
current_tokens = ori_input_tokens[:answer_start] + noised_answer[answer_start:]
|
|
|
211 |
|
212 |
# --- RED HIGHLIGHT ---
|
213 |
decoded_tokens = tokenizer.convert_ids_to_tokens(current_tokens[answer_start:])
|