Spaces:
Sleeping
Sleeping
chore: update
Browse files
app.py
CHANGED
@@ -470,26 +470,25 @@ with demo:
|
|
470 |
|
471 |
with gr.Accordion("What is encrypted anonymization?", open=False):
|
472 |
gr.Markdown(
|
473 |
-
"""Anonymization is the process of removing personally identifiable information (PII)
|
474 |
-
from
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
third-party access to the raw data. Once the data is anonymized, it can safely be sent
|
482 |
-
to GenAI services such as ChatGPT.
|
483 |
"""
|
484 |
)
|
485 |
|
486 |
########################## Key Gen Part ##########################
|
487 |
|
488 |
gr.Markdown(
|
489 |
-
"## Step 1:
|
490 |
-
"""In FHE
|
491 |
-
|
492 |
-
a server to
|
|
|
493 |
"""
|
494 |
)
|
495 |
|
@@ -504,28 +503,19 @@ with demo:
|
|
504 |
########################## Main document Part ##########################
|
505 |
|
506 |
gr.Markdown("<hr />")
|
507 |
-
gr.Markdown("## Step 2:
|
|
|
|
|
|
|
|
|
508 |
|
509 |
with gr.Row():
|
510 |
with gr.Column():
|
511 |
gr.Markdown("**Original document:**")
|
512 |
-
gr.Markdown(
|
513 |
-
"""This document was retrieved from the
|
514 |
-
[Microsoft Presidio](https://huggingface.co/spaces/presidio/presidio_demo) demo.
|
515 |
|
516 |
-
You can select and deselect sentences to customize the document that will be used
|
517 |
-
as the initial prompt for ChatGPT in step 5.
|
518 |
-
"""
|
519 |
-
)
|
520 |
with gr.Column():
|
521 |
-
gr.Markdown("**
|
522 |
-
|
523 |
-
"""You can see below the anonymized text, replaced with hexademical strings, that
|
524 |
-
will be sent to ChatGPT.
|
525 |
-
|
526 |
-
ChatGPT will then be able to answer any queries about the document.
|
527 |
-
"""
|
528 |
-
)
|
529 |
|
530 |
with gr.Row():
|
531 |
with gr.Column():
|
@@ -549,12 +539,10 @@ with demo:
|
|
549 |
########################## User Query Part ##########################
|
550 |
|
551 |
gr.Markdown("<hr />")
|
552 |
-
gr.Markdown("## Step
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
<span style='color:grey'>“Queries examples”</span>" or craft a custom question in
|
557 |
-
the <span style='color:grey'>“Customized query”</span>" text box.
|
558 |
|
559 |
Remain concise and relevant to the context. Any off-topic query will not be processed.
|
560 |
"""
|
@@ -565,13 +553,13 @@ with demo:
|
|
565 |
|
566 |
with gr.Column(scale=5):
|
567 |
default_query_box = gr.Dropdown(
|
568 |
-
list(DEFAULT_QUERIES.values()), label="
|
569 |
)
|
570 |
|
571 |
gr.Markdown("Or")
|
572 |
|
573 |
query_box = gr.Textbox(
|
574 |
-
value="
|
575 |
)
|
576 |
|
577 |
default_query_box.change(
|
@@ -582,7 +570,7 @@ with demo:
|
|
582 |
|
583 |
with gr.Column(scale=1, min_width=6):
|
584 |
gr.HTML("<div style='height: 77px;'></div>")
|
585 |
-
encrypt_btn = gr.Button("Encrypt
|
586 |
# gr.HTML("<div style='height: 50px;'></div>")
|
587 |
|
588 |
with gr.Column(scale=5):
|
@@ -594,15 +582,15 @@ with demo:
|
|
594 |
########################## FHE processing Part ##########################
|
595 |
|
596 |
gr.Markdown("<hr />")
|
597 |
-
gr.Markdown("## Step
|
598 |
gr.Markdown(
|
599 |
-
"""
|
600 |
-
to perform the anonymization on encrypted data. When the computation is done, the
|
601 |
-
will return the result to the client for decryption.
|
602 |
"""
|
603 |
)
|
604 |
|
605 |
-
run_fhe_btn = gr.Button("Anonymize
|
606 |
|
607 |
anonymized_text_output = gr.Textbox(
|
608 |
label="Decrypted anonymized query that will be sent to ChatGPT:", lines=1, interactive=True
|
|
|
470 |
|
471 |
with gr.Accordion("What is encrypted anonymization?", open=False):
|
472 |
gr.Markdown(
|
473 |
+
"""Anonymization is the process of removing personally identifiable information (PII) data
|
474 |
+
from a document in order to protect individual privacy.
|
475 |
+
|
476 |
+
Encrypted anonymization using Fully Homomorphic Encryption (FHE) solves issues when
|
477 |
+
deploying such tool through an untrusted cloud service, as Fully Homomorphic Encryption
|
478 |
+
(FHE) allows such services to anonymize personally identifiable information (PII) on an
|
479 |
+
encrypted document. Once the data is anonymized, it can safely be sent to LLM services such
|
480 |
+
as ChatGPT.
|
|
|
|
|
481 |
"""
|
482 |
)
|
483 |
|
484 |
########################## Key Gen Part ##########################
|
485 |
|
486 |
gr.Markdown(
|
487 |
+
"## Step 1: Generate the keys\n\n"
|
488 |
+
"""In Fully Homomorphic Encryption (FHE) methods, two types of keys are created. The first
|
489 |
+
type, called secret keys, are used to encrypt and decrypt the user's data. The second type,
|
490 |
+
called evaluation keys, enable a server to work on the encrypted data without seeing the
|
491 |
+
actual data.
|
492 |
"""
|
493 |
)
|
494 |
|
|
|
503 |
########################## Main document Part ##########################
|
504 |
|
505 |
gr.Markdown("<hr />")
|
506 |
+
gr.Markdown("## Step 2.1: Select the document you want to encrypt\n\n"
|
507 |
+
"""To make it simple, we pre-compiled the following document, but you are free to choose
|
508 |
+
on which part you want to run this example.
|
509 |
+
"""
|
510 |
+
)
|
511 |
|
512 |
with gr.Row():
|
513 |
with gr.Column():
|
514 |
gr.Markdown("**Original document:**")
|
|
|
|
|
|
|
515 |
|
|
|
|
|
|
|
|
|
516 |
with gr.Column():
|
517 |
+
gr.Markdown("**Encrypted document:**")
|
518 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
519 |
|
520 |
with gr.Row():
|
521 |
with gr.Column():
|
|
|
539 |
########################## User Query Part ##########################
|
540 |
|
541 |
gr.Markdown("<hr />")
|
542 |
+
gr.Markdown("## Step 2.2: Select the prompt you want to encrypt\n\n"
|
543 |
+
"""Please choose from the predefined options in
|
544 |
+
<span style='color:grey'>“Prompt examples”</span>" or craft a custom question in
|
545 |
+
the <span style='color:grey'>“Customized prompt”</span>" text box.
|
|
|
|
|
546 |
|
547 |
Remain concise and relevant to the context. Any off-topic query will not be processed.
|
548 |
"""
|
|
|
553 |
|
554 |
with gr.Column(scale=5):
|
555 |
default_query_box = gr.Dropdown(
|
556 |
+
list(DEFAULT_QUERIES.values()), label="PROMPT EXAMPLES:"
|
557 |
)
|
558 |
|
559 |
gr.Markdown("Or")
|
560 |
|
561 |
query_box = gr.Textbox(
|
562 |
+
value="What is Alice international bank account number?", label="CUSTOMIZED PROMPT:", interactive=True
|
563 |
)
|
564 |
|
565 |
default_query_box.change(
|
|
|
570 |
|
571 |
with gr.Column(scale=1, min_width=6):
|
572 |
gr.HTML("<div style='height: 77px;'></div>")
|
573 |
+
encrypt_btn = gr.Button("Encrypt the prompt")
|
574 |
# gr.HTML("<div style='height: 50px;'></div>")
|
575 |
|
576 |
with gr.Column(scale=5):
|
|
|
582 |
########################## FHE processing Part ##########################
|
583 |
|
584 |
gr.Markdown("<hr />")
|
585 |
+
gr.Markdown("## Step 3: Anonymize the document and the prompt using FHE")
|
586 |
gr.Markdown(
|
587 |
+
"""Once the client encrypts the document and the prompt locally, it will be sent to a remote
|
588 |
+
server to perform the anonymization on encrypted data. When the computation is done, the
|
589 |
+
server will return the result to the client for decryption.
|
590 |
"""
|
591 |
)
|
592 |
|
593 |
+
run_fhe_btn = gr.Button("Anonymize using FHE")
|
594 |
|
595 |
anonymized_text_output = gr.Textbox(
|
596 |
label="Decrypted anonymized query that will be sent to ChatGPT:", lines=1, interactive=True
|