This guardrail should be run only after anonymize guardrail
A guardrail for replacing placeholders in the model output with real values from a vault. Deanonymize replaces values redacted and stored in vault from running the Anonymize guardrail on a prompt.
Parameters:
data:
prompt (str): The text to be deanonymized.
arguments:
matching_strategy (Union[MatchingStrategy, str]): Strategy for matching placeholders with real values. Options are exact or fuzzy Default is exact.
Prompt
Interpretation:
Values such as name, email, phone numbers,etc. present in the prompt should be replaced with the original values from the vault in the output
Example:
prompt = "Your name is [REDACTED_PERSON_1], You have received your inquiry regarding an account with Google LLC from [REDACTED_PERSON_2], where you work.\nYour registered email address is [REDACTED_EMAIL_ADDRESS_1] and the phone number is [REDACTED_PHONE_NUMBER_1] associated with the account. Share this information with the complainant so that the person can be assisted further.\nWrite an email to help the person ahead\n' credit card [REDACTED_CREDIT_CARD_RE_1]"
sanitized_prompt = "Your name is Walter White, You have received your inquiry regarding an account with Google LLC from John Doe, where you work.
Your registered email address is walter.white@google.com and the phone number is +91-9967854332 associated with the account. Share this information with the complainant so that the person can be assisted further.
Write an email to help the person ahead"
Code Example:
evaluator.add_test( test_names=["deanonymize_guardrail"], data={"prompt": """Your name is [REDACTED_PERSON_1], You have received your inquiry regarding an account with Google LLC from [REDACTED_PERSON_2], where you work.Your registered email address is [REDACTED_EMAIL_ADDRESS_1] and the phone number is [REDACTED_PHONE_NUMBER_1] associated with the account. Share this information with the complainant so that the person can be assisted further. Write an email to help the person ahead""", },).run()evaluator.print_results()