Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
"""A Gradio app for
|
| 2 |
|
| 3 |
import base64
|
| 4 |
import os
|
|
@@ -13,7 +13,7 @@ import numpy
|
|
| 13 |
import pandas as pd
|
| 14 |
import requests
|
| 15 |
from fhe_anonymizer import FHEAnonymizer
|
| 16 |
-
from openai import OpenAI
|
| 17 |
from utils_demo import *
|
| 18 |
|
| 19 |
from concrete.ml.deployment import FHEModelClient
|
|
@@ -491,7 +491,7 @@ with demo:
|
|
| 491 |
|
| 492 |
gr.Markdown(
|
| 493 |
"""
|
| 494 |
-
<h1 style="text-align: center;">Encrypted
|
| 495 |
<p align="center">
|
| 496 |
<a href="https://github.com/zama-ai/concrete-ml"> <img style="vertical-align: middle; display:inline-block; margin-right: 3px;" width=15 src="file/images/logos/github.png">Concrete-ML</a>
|
| 497 |
—
|
|
@@ -507,29 +507,16 @@ with demo:
|
|
| 507 |
gr.Markdown(
|
| 508 |
"""
|
| 509 |
<p align="center" style="font-size: 16px;">
|
| 510 |
-
Anonymization
|
| 511 |
-
a document in order to protect individual privacy.</p>
|
| 512 |
|
| 513 |
<p align="center" style="font-size: 16px;">
|
| 514 |
-
|
| 515 |
identifiable information (PII) within encrypted documents, enabling computations to be
|
| 516 |
performed on the encrypted data.</p>
|
| 517 |
-
|
| 518 |
-
<p align="center" style="font-size: 16px;">
|
| 519 |
-
In the example above, we're showing how encrypted anonymization can be leveraged to use LLM
|
| 520 |
-
services such as ChatGPT in a privacy-preserving manner.</p>
|
| 521 |
"""
|
| 522 |
)
|
| 523 |
|
| 524 |
-
gr.Markdown(
|
| 525 |
-
"""
|
| 526 |
-
<p align="center">
|
| 527 |
-
<img width="75%" height="30%" src="https://raw.githubusercontent.com/kcelia/Img/main/fhe_anonymization_banner.png">
|
| 528 |
-
</p>
|
| 529 |
-
"""
|
| 530 |
-
)
|
| 531 |
-
|
| 532 |
-
|
| 533 |
########################## Key Gen Part ##########################
|
| 534 |
|
| 535 |
gr.Markdown(
|
|
@@ -613,34 +600,34 @@ with demo:
|
|
| 613 |
|
| 614 |
with gr.Column(scale=5):
|
| 615 |
output_encrypted_box = gr.Textbox(
|
| 616 |
-
label="Encrypted
|
| 617 |
lines=8,
|
| 618 |
)
|
| 619 |
|
| 620 |
########################## FHE processing Part ##########################
|
| 621 |
|
| 622 |
gr.Markdown("<hr />")
|
| 623 |
-
gr.Markdown("## Step 3:
|
| 624 |
gr.Markdown(
|
| 625 |
"""Once the client encrypts the document and the prompt locally, it will be sent to a remote
|
| 626 |
-
server to perform the
|
| 627 |
server will return the result to the client for decryption.
|
| 628 |
"""
|
| 629 |
)
|
| 630 |
|
| 631 |
-
run_fhe_btn = gr.Button("
|
| 632 |
|
| 633 |
with gr.Row():
|
| 634 |
with gr.Column(scale=5):
|
| 635 |
|
| 636 |
anonymized_doc_output = gr.Textbox(
|
| 637 |
-
label="Decrypted and
|
| 638 |
)
|
| 639 |
|
| 640 |
with gr.Column(scale=5):
|
| 641 |
|
| 642 |
anonymized_query_output = gr.Textbox(
|
| 643 |
-
label="Decrypted and
|
| 644 |
)
|
| 645 |
|
| 646 |
|
|
|
|
| 1 |
+
"""A Gradio app for de-identifying text data using FHE."""
|
| 2 |
|
| 3 |
import base64
|
| 4 |
import os
|
|
|
|
| 13 |
import pandas as pd
|
| 14 |
import requests
|
| 15 |
from fhe_anonymizer import FHEAnonymizer
|
| 16 |
+
#from openai import OpenAI
|
| 17 |
from utils_demo import *
|
| 18 |
|
| 19 |
from concrete.ml.deployment import FHEModelClient
|
|
|
|
| 491 |
|
| 492 |
gr.Markdown(
|
| 493 |
"""
|
| 494 |
+
<h1 style="text-align: center;">Encrypted de-identification Using Fully Homomorphic Encryption</h1>
|
| 495 |
<p align="center">
|
| 496 |
<a href="https://github.com/zama-ai/concrete-ml"> <img style="vertical-align: middle; display:inline-block; margin-right: 3px;" width=15 src="file/images/logos/github.png">Concrete-ML</a>
|
| 497 |
—
|
|
|
|
| 507 |
gr.Markdown(
|
| 508 |
"""
|
| 509 |
<p align="center" style="font-size: 16px;">
|
| 510 |
+
Anonymization makes it impossible to identify a person from a data set and thus allows their privacy to be respected (CNIL) </p> Concealing some of PII information is a helpful technique for de-identification. However, this can't be considered as anonymization.
|
|
|
|
| 511 |
|
| 512 |
<p align="center" style="font-size: 16px;">
|
| 513 |
+
De-identification uses Fully Homomorphic Encryption (FHE) to conceal personally
|
| 514 |
identifiable information (PII) within encrypted documents, enabling computations to be
|
| 515 |
performed on the encrypted data.</p>
|
| 516 |
+
|
|
|
|
|
|
|
|
|
|
| 517 |
"""
|
| 518 |
)
|
| 519 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 520 |
########################## Key Gen Part ##########################
|
| 521 |
|
| 522 |
gr.Markdown(
|
|
|
|
| 600 |
|
| 601 |
with gr.Column(scale=5):
|
| 602 |
output_encrypted_box = gr.Textbox(
|
| 603 |
+
label="Encrypted de-identified query that will be sent to the de-identification server:",
|
| 604 |
lines=8,
|
| 605 |
)
|
| 606 |
|
| 607 |
########################## FHE processing Part ##########################
|
| 608 |
|
| 609 |
gr.Markdown("<hr />")
|
| 610 |
+
gr.Markdown("## Step 3: De-identify the document and the prompt using FHE")
|
| 611 |
gr.Markdown(
|
| 612 |
"""Once the client encrypts the document and the prompt locally, it will be sent to a remote
|
| 613 |
+
server to perform the de-identification on encrypted data. When the computation is done, the
|
| 614 |
server will return the result to the client for decryption.
|
| 615 |
"""
|
| 616 |
)
|
| 617 |
|
| 618 |
+
run_fhe_btn = gr.Button("De-identify using FHE")
|
| 619 |
|
| 620 |
with gr.Row():
|
| 621 |
with gr.Column(scale=5):
|
| 622 |
|
| 623 |
anonymized_doc_output = gr.Textbox(
|
| 624 |
+
label="Decrypted and de-idenntified document", lines=10, interactive=True
|
| 625 |
)
|
| 626 |
|
| 627 |
with gr.Column(scale=5):
|
| 628 |
|
| 629 |
anonymized_query_output = gr.Textbox(
|
| 630 |
+
label="Decrypted and de-identified prompt", lines=10, interactive=True
|
| 631 |
)
|
| 632 |
|
| 633 |
|