-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into logan/merge_next
- Loading branch information
Showing
450 changed files
with
15,384 additions
and
2,961 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ venv/ | |
.__pycache__ | ||
dev_notebooks/ | ||
llamaindex_registry.txt | ||
packages_to_bump_deduped.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -279,6 +279,110 @@ | |
"new_nodes[0].node.metadata[\"__pii_node_info__\"]" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "6cc87ed4", | ||
"metadata": {}, | ||
"source": [ | ||
"### Option 3: Use Presidio for PII Masking\n", | ||
"\n", | ||
"Use presidio to identify and anonymize PII" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "ac215117", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# load documents\n", | ||
"text = \"\"\"\n", | ||
"Hello Paulo Santos. The latest statement for your credit card account \\\n", | ||
"4095-2609-9393-4932 was mailed to Seattle, WA 98109. \\\n", | ||
"IBAN GB90YNTU67299444055881 and social security number is 474-49-7577 were verified on the system. \\\n", | ||
"Further communications will be sent to [email protected] \n", | ||
"\"\"\"\n", | ||
"presidio_node = TextNode(text=text)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "8a745520", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from llama_index.postprocessor.presidio import PresidioPIINodePostprocessor\n", | ||
"\n", | ||
"processor = PresidioPIINodePostprocessor()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "89cb17ed", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from llama_index.core.schema import NodeWithScore\n", | ||
"\n", | ||
"presidio_new_nodes = processor.postprocess_nodes(\n", | ||
" [NodeWithScore(node=presidio_node)]\n", | ||
")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "b8fe9cef", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"'\\nHello <PERSON_1>. The latest statement for your credit card account <CREDIT_CARD_1> was mailed to <LOCATION_2>, <LOCATION_1>. IBAN <IBAN_CODE_1> and social security number is <US_SSN_1> were verified on the system. Further communications will be sent to <EMAIL_ADDRESS_1> \\n'" | ||
] | ||
}, | ||
"execution_count": null, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"# view redacted text\n", | ||
"presidio_new_nodes[0].node.get_text()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "80203af0", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"{'<EMAIL_ADDRESS_1>': '[email protected]',\n", | ||
" '<US_SSN_1>': '474-49-7577',\n", | ||
" '<IBAN_CODE_1>': 'GB90YNTU67299444055881',\n", | ||
" '<LOCATION_1>': 'WA 98109',\n", | ||
" '<LOCATION_2>': 'Seattle',\n", | ||
" '<CREDIT_CARD_1>': '4095-2609-9393-4932',\n", | ||
" '<PERSON_1>': 'Paulo Santos'}" | ||
] | ||
}, | ||
"execution_count": null, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"# get mapping in metadata\n", | ||
"# NOTE: this is not sent to the LLM!\n", | ||
"presidio_new_nodes[0].node.metadata[\"__pii_node_info__\"]" | ||
] | ||
}, | ||
{ | ||
"attachments": {}, | ||
"cell_type": "markdown", | ||
|
Oops, something went wrong.