## When to use text classification and redaction

The following are some common use cases:

- **Sanitize user input before database persistence**: Redact sensitive PII (such as Social Security numbers, credit card numbers, or driver's licenses) from free-form text before writing records to storage or application databases.
- **Sanitize customer service transcripts and logs**: Strip identifying personal information from chat histories, support tickets, and email threads before agent review or training data ingestion.
- **Identify sensitive entities for downstream tagging**: Classify text to extract infoTypes and likelihood ratings and use this information in custom workflows to route or flag high-risk messages.
- **Mask confidential data in generative AI prompts**: Redact proprietary or regulated information from user prompts before sending content to public or third-party LLMs.

## Text classification

Consider the following text input:

```
Please update my records with the following information:
Email address: foo@example.com

National Provider Identifier: 1245319599

Driver's license: AC333991
```

The output is a list of findings, organized into the following categories:

- [`InfoType`](https://docs.cloud.google.com/sensitive-data-protection/docs/infotypes-reference.md.txt "InfoTypes Reference")
- [`Likelihood`](https://docs.cloud.google.com/sensitive-data-protection/docs/likelihood.md.txt "Likelihood Concept Page")
- `Offset` (Where in the string the potential `InfoType` was found)

Example output is shown in the table below.

| `InfoType` | `Likelihood` | `Offset` |
|---|---|---|
| `US_HEALTHCARE_NPI` | `VERY_LIKELY` | `122` |
| `EMAIL_ADDRESS` | `LIKELY` | `72` |
| `US_DRIVERS_LICENSE_NUMBER` | `LIKELY` | `155` |
| `CANADA_BC_PHN` | `VERY_UNLIKELY` | `122` |
| `UK_TAXPAYER_REFERENCE` | `VERY_UNLIKELY` | `122` |
| `CANADA_PASSPORT` | `VERY_UNLIKELY` | `155` |

## Automatic text redaction

Automatic redaction produces an output with sensitive data matches removed
instead of giving you a list of findings.

The following is an example of automatic redaction input:

```
Please update my records with the following information:
Email address: foo@example.com

National Provider Identifier: 1245319599

Driver's license: AC333991
```

The following is an example of output using a placeholder of "\*\*\*":

```
Please update my records with the following information:
Email address: ***

National Provider Identifier: ***

Driver's license: ***
```

## Resources

- For more information about using Sensitive Data Protection to redact text, see [Redacting Sensitive Data From Text Content](https://docs.cloud.google.com/sensitive-data-protection/docs/redacting-sensitive-data.md.txt).
- For more information about using Sensitive Data Protection to de-identify sensitive data in text content---which includes "masking" sensitive data, replacing sensitive data with a "token" string, and encrypting and replacing sensitive data using a randomly generated or pre-determined key---see [De-identifying sensitive data in text content](https://docs.cloud.google.com/sensitive-data-protection/docs/deidentify-sensitive-data.md.txt).