Spaces:
Running on Zero

Ruurd commited on
Commit
8cb5f7a
·
verified ·
1 Parent(s): 0ffa4b5

Add pause length

Browse files
Files changed (1) hide show
  1. app.py +7 -5
app.py CHANGED
@@ -144,7 +144,7 @@ def generate_diffusion_text(input_ids):
144
  return sampled, conf
145
 
146
  # --- Inference Wrapper ---
147
- def diffusion_chat(question, eot_weight, max_it, sharpness, noise_clipping, use_confidence_noising, clustering):
148
  placeholder = "What do you know about the city of New York?"
149
  if question.strip() == "":
150
  question = placeholder
@@ -193,7 +193,7 @@ def diffusion_chat(question, eot_weight, max_it, sharpness, noise_clipping, use_
193
 
194
  prev_decoded_tokens = decoded_tokens
195
  yield f"<b>Iteration {i+1}/{max_it} (after generation):</b><br>" + "".join(highlighted).replace('\n', '<br>')
196
- time.sleep(0.1)
197
 
198
  # --- Early stopping ---
199
  last_tokens.append(current_tokens)
@@ -235,7 +235,7 @@ def diffusion_chat(question, eot_weight, max_it, sharpness, noise_clipping, use_
235
  highlighted.append(token_str)
236
 
237
  yield f"<b>Iteration {i+1}/{max_it} (before noising):</b><br>" + "".join(highlighted).replace('\n', '<br>')
238
- time.sleep(0.1)
239
 
240
 
241
  final_tokens = tokenizer.convert_ids_to_tokens(current_tokens[answer_start:])
@@ -255,10 +255,12 @@ demo = gr.Interface(
255
  gr.Textbox(label="User Question", lines=2, placeholder="What do you know about the city of New York?"),
256
  gr.Slider(0, 1, value=0.4, step=0.05, label="↓ = longer answers (EOT weight)"),
257
  gr.Slider(1, 512, value=64, step=1, label="↑ = more iterations"),
 
258
  gr.Slider(1.0, 20.0, value=5.0, step=0.5, label="↓ = more noising (sharpness)"),
259
- gr.Slider(0.01, 1.0, value=0.05, step=0.01, label="↓ = more confidence guidance (noise clipping)"),
260
- gr.Checkbox(value=False, label="Use confidence-guided noising"),
261
  gr.Slider(0.0, 1.0, value=0.5, step=0.05, label="↑ = more clustered noising (fewer, larger edits)")
 
 
 
262
  ],
263
  outputs=[gr.HTML(label="Diffusion Output")],
264
  title="Diffusion Language Model Chat",
 
144
  return sampled, conf
145
 
146
  # --- Inference Wrapper ---
147
+ def diffusion_chat(question, eot_weight, max_it, pause_length, sharpness, clustering, use_confidence_noising, noise_clipping):
148
  placeholder = "What do you know about the city of New York?"
149
  if question.strip() == "":
150
  question = placeholder
 
193
 
194
  prev_decoded_tokens = decoded_tokens
195
  yield f"<b>Iteration {i+1}/{max_it} (after generation):</b><br>" + "".join(highlighted).replace('\n', '<br>')
196
+ time.sleep(pause_length)
197
 
198
  # --- Early stopping ---
199
  last_tokens.append(current_tokens)
 
235
  highlighted.append(token_str)
236
 
237
  yield f"<b>Iteration {i+1}/{max_it} (before noising):</b><br>" + "".join(highlighted).replace('\n', '<br>')
238
+ time.sleep(pause_length)
239
 
240
 
241
  final_tokens = tokenizer.convert_ids_to_tokens(current_tokens[answer_start:])
 
255
  gr.Textbox(label="User Question", lines=2, placeholder="What do you know about the city of New York?"),
256
  gr.Slider(0, 1, value=0.4, step=0.05, label="↓ = longer answers (EOT weight)"),
257
  gr.Slider(1, 512, value=64, step=1, label="↑ = more iterations"),
258
+ gr.Slider(0.01, 5, value=0.01, step=0.01, label="↑ = longer pause (for visualization)"),
259
  gr.Slider(1.0, 20.0, value=5.0, step=0.5, label="↓ = more noising (sharpness)"),
 
 
260
  gr.Slider(0.0, 1.0, value=0.5, step=0.05, label="↑ = more clustered noising (fewer, larger edits)")
261
+ gr.Checkbox(value=False, label="Use confidence-guided noising"),
262
+ gr.Slider(0.01, 1.0, value=0.05, step=0.01, label="↓ = more confidence guidance (noise clipping)"),
263
+
264
  ],
265
  outputs=[gr.HTML(label="Diffusion Output")],
266
  title="Diffusion Language Model Chat",