Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add NER PII Masking module #319

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft

Add NER PII Masking module #319

wants to merge 5 commits into from

Conversation

bwook00
Copy link
Contributor

@bwook00 bwook00 commented Apr 12, 2024

close #314

Use a Hugging Face NER model for PII Masking.

Copy link
Contributor

@vkehfdl1 vkehfdl1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plus, are you sure NER PII Masking is 'passage filter' node? I think it is not.
Passage filter means that 'decreasing the context' while not modifying each contexts content itself.
I think we have to make new node... like privacy filter or something...?

Plus, it is tricky to setup metric for privacy filter isn't it?

response = model(text)
for entry in response:
entity_group_tag = f"[{entry['entity_group']}_{entry['start']}]"
new_text = new_text.replace(entry["word"], entity_group_tag).strip()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there 'start' and 'end' index of detected entity? Try to use that because there can be duplicated entities in one sentence.

autorag/nodes/passagefilter/ner_pii_masking.py Outdated Show resolved Hide resolved
def mask_pii(model, text: str) -> str:
new_text = text
response = model(text)
for entry in response:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plus, you are trying to mask 'ALL' entity types? It can mask Location, person name, or any private entity types. But masking all entity types.
It can be remained literally 'no knowledge' in the sentence.

@bwook00
Copy link
Contributor Author

bwook00 commented Apr 12, 2024

Plus, are you sure NER PII Masking is 'passage filter' node? I think it is not. Passage filter means that 'decreasing the context' while not modifying each contexts content itself. I think we have to make new node... like privacy filter or something...?

Plus, it is tricky to setup metric for privacy filter isn't it?

I agree with you ... I'll give it a little more time and think about it ,,,,

return masked_contents_list, ids_list, scores_list


async def mask_pii(model, contents: List[str]) -> List[str]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, this is useless async operation.
I'll make a PR for resolving this kind of issue in the model rerankers...

@bwook00 bwook00 removed the request for review from Eastsidegunn April 18, 2024 09:10
@vkehfdl1 vkehfdl1 marked this pull request as draft April 27, 2024 01:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add NER PII-Masking module
2 participants