Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -324,15 +324,15 @@ def complete(sample, k, current_example):
|
|
| 324 |
output = prefix
|
| 325 |
for token in client.text_generation(prefix, do_sample=False, max_new_tokens=512, stream=True):
|
| 326 |
if token == "<|endoftext|>":
|
| 327 |
-
bleu_score = {"
|
| 328 |
references=[current_example])["bleu"]}
|
| 329 |
return diff(output, current_example), gr.Label.update(value=bleu_score), current_example
|
| 330 |
output += token
|
| 331 |
-
bleu_score = {"
|
| 332 |
references=[current_example])["bleu"]}
|
| 333 |
yield diff(output, current_example), gr.Label.update(value=bleu_score), current_example
|
| 334 |
# yield output, diff_texts(output, sample), gr.Label.update(value=bleu_score)
|
| 335 |
-
bleu_score = {"
|
| 336 |
references=[current_example])["bleu"]}
|
| 337 |
# return output, diff_texts(output, sample), gr.Label.update(value=bleu_score)
|
| 338 |
return diff(output, current_example), gr.Label.update(value=bleu_score), current_example
|
|
@@ -363,7 +363,7 @@ DEFAULT_SAMPLE_PREFIX = tokenizer.decode(tokenizer(DEFAULT_SAMPLE)["input_ids"][
|
|
| 363 |
|
| 364 |
style = theme.Style()
|
| 365 |
|
| 366 |
-
with gr.Blocks(theme=style) as demo:
|
| 367 |
current_example = gr.State(value=DEFAULT_SAMPLE)
|
| 368 |
with gr.Column():
|
| 369 |
gr.Markdown(title)
|
|
@@ -378,7 +378,8 @@ with gr.Blocks(theme=style) as demo:
|
|
| 378 |
id="instruction",
|
| 379 |
placeholder="Output",
|
| 380 |
lines=5,
|
| 381 |
-
label="
|
|
|
|
| 382 |
value=DEFAULT_SAMPLE_PREFIX,
|
| 383 |
disable=True,
|
| 384 |
interactive=False,
|
|
@@ -392,19 +393,18 @@ with gr.Blocks(theme=style) as demo:
|
|
| 392 |
You can reduce the Prefix size in the Advanced parameters to reduce the context length and see if the model still extracts the training sample.""")
|
| 393 |
with gr.Row():
|
| 394 |
with gr.Column():
|
| 395 |
-
with gr.Accordion("
|
| 396 |
k = gr.Slider(minimum=1, maximum=DEFAULT_SAMPLE_MAX_TOKENS, value=DEFAULT_K,
|
| 397 |
step=1,
|
| 398 |
-
|
| 399 |
-
|
| 400 |
-
|
| 401 |
-
submit = gr.Button("Check", variant="primary")
|
| 402 |
examples_dropdown = gr.Dropdown(choices=list(examples.keys()), value=list(examples.keys())[0],
|
| 403 |
interactive=True,
|
| 404 |
-
label="Training set samples"
|
|
|
|
|
|
|
| 405 |
with gr.Column():
|
| 406 |
-
# with gr.Row():
|
| 407 |
-
# output = gr.Textbox(lines=5, label="Completion", interactive=False)
|
| 408 |
diff_HTML = gr.HTML(
|
| 409 |
label="Diff")
|
| 410 |
|
|
|
|
| 324 |
output = prefix
|
| 325 |
for token in client.text_generation(prefix, do_sample=False, max_new_tokens=512, stream=True):
|
| 326 |
if token == "<|endoftext|>":
|
| 327 |
+
bleu_score = {"BLEU": bleu.compute(predictions=[output],
|
| 328 |
references=[current_example])["bleu"]}
|
| 329 |
return diff(output, current_example), gr.Label.update(value=bleu_score), current_example
|
| 330 |
output += token
|
| 331 |
+
bleu_score = {"BLEU": bleu.compute(predictions=[output],
|
| 332 |
references=[current_example])["bleu"]}
|
| 333 |
yield diff(output, current_example), gr.Label.update(value=bleu_score), current_example
|
| 334 |
# yield output, diff_texts(output, sample), gr.Label.update(value=bleu_score)
|
| 335 |
+
bleu_score = {"BLEU": bleu.compute(predictions=[output],
|
| 336 |
references=[current_example])["bleu"]}
|
| 337 |
# return output, diff_texts(output, sample), gr.Label.update(value=bleu_score)
|
| 338 |
return diff(output, current_example), gr.Label.update(value=bleu_score), current_example
|
|
|
|
| 363 |
|
| 364 |
style = theme.Style()
|
| 365 |
|
| 366 |
+
with gr.Blocks(theme=style, css=modifs) as demo:
|
| 367 |
current_example = gr.State(value=DEFAULT_SAMPLE)
|
| 368 |
with gr.Column():
|
| 369 |
gr.Markdown(title)
|
|
|
|
| 378 |
id="instruction",
|
| 379 |
placeholder="Output",
|
| 380 |
lines=5,
|
| 381 |
+
label="Training sample",
|
| 382 |
+
info="This is an example from The Stack dataset."
|
| 383 |
value=DEFAULT_SAMPLE_PREFIX,
|
| 384 |
disable=True,
|
| 385 |
interactive=False,
|
|
|
|
| 393 |
You can reduce the Prefix size in the Advanced parameters to reduce the context length and see if the model still extracts the training sample.""")
|
| 394 |
with gr.Row():
|
| 395 |
with gr.Column():
|
| 396 |
+
with gr.Accordion("Prefix size", open=True):
|
| 397 |
k = gr.Slider(minimum=1, maximum=DEFAULT_SAMPLE_MAX_TOKENS, value=DEFAULT_K,
|
| 398 |
step=1,
|
| 399 |
+
info="""Number of tokens used to assess memorization.
|
| 400 |
+
The more tokens are used, the more likely one can observe the LLM finishing the prompt with the verbatim code used in the training set.""")
|
| 401 |
+
submit = gr.Button("Check memorization", variant="primary")
|
|
|
|
| 402 |
examples_dropdown = gr.Dropdown(choices=list(examples.keys()), value=list(examples.keys())[0],
|
| 403 |
interactive=True,
|
| 404 |
+
label="Training set samples",
|
| 405 |
+
info="""You can choose among high/low memorization examples from The Stack.
|
| 406 |
+
More samples are available below.""")
|
| 407 |
with gr.Column():
|
|
|
|
|
|
|
| 408 |
diff_HTML = gr.HTML(
|
| 409 |
label="Diff")
|
| 410 |
|