Sensitive Data Leakage

Use-case-specific confidential information, defined by examples you provide

Sensitive data leakage is the inadvertent exposure of confidential or private information. There are two places where you may want to catch it.

  1. Sensitive data in the prompt. If your application uses a public or externally hosted LLM, everything sent to that model may be retained, used for training, or exposed across contexts. You want to make sure users are not pasting confidential company information into prompts.
  2. Sensitive data in the response. Teams add private data to LLMs as context (through retrieval or fine-tuning) so the model can answer more questions. But the end user may not have permission to see that data at a granular level, and the application should not return it to them.

Types of sensitive data

Broadly, sensitive data is confidential information stored, processed, or managed by an organization that should only be accessible to authorized users. What falls into that category is use-case specific.

For example, imagine an LLM augmented with client investment portfolio data. Internal users should be able to ask broad questions across portfolios, but responses that reveal a specific client's holdings to someone without access to them should be blocked.

Personally identifiable information (PII) is another kind of data teams often treat as sensitive, whether common PII such as social security numbers or use-case-specific identifiers such as API keys. The PII Leakage rule covers the former and Custom Rules cover the latter.

The GenAI Engine approach

The sensitive data rule uses LLM prompting with few-shot examples as a general-purpose detector for sensitive data that is hard to capture with concrete regex patterns. The LLM it calls is the one configured for your engine; see Configure Model Provider.

To use the rule, prepare a set of examples that should pass or fail according to the category of sensitive data you need to detect. Those examples become the rule's configuration, and the rule uses them to judge every prompt or response it sees from then on.

Preparing examples

Positive and negative examples

Collect both positive and negative examples. If you want to detect medical data, positive examples are instances of medical text and negative examples are similar-looking text that is not medical. Negative examples reduce the false positive rate by showing the LLM what not to flag.

Enough examples, but not too many

Two to twenty examples is the useful range. Performance typically improves as you add examples, but we have observed a drop-off when there are too many, usually beginning around 10 to 15.

Test the rule on a validation set before putting it into production to find the example set that works best for your use case.

Adding a hint

Add a short description of the type of sensitive data you are looking for as the hint when creating the rule. In our benchmarks a hint lifts performance across every dataset while adding very few tokens.

Requirements

The sensitive data rule runs on validate_prompt, validate_response, or both.

PromptResponseContext needed?
Sensitive Data✅✅

Text over the sensitive data token limit (GENAI_ENGINE_SENSITIVE_DATA_CHECK_MAX_TOKEN_LIMIT) returns Skipped.

Benchmarks

The benchmark datasets we assembled contain samples from the AI4Privacy PII-Masking dataset. Each dataset focuses on one category from AI4Privacy: passwords, usernames, company names, and job titles. These are categories the PII Leakage rule does not cover.

When running the benchmarks, we sample N = 30 rows from each dataset.

Each row contains a text and a boolean label. label == True means the text contains the category of sensitive data that dataset focuses on. A text containing a username is labeled True in the username dataset, but a text containing a username and no company name is labeled False in the company name dataset.

Recommendation

Based on these benchmarks, roughly 8 examples plus a hint on a small, fast model was the best balance of performance, cost, and latency. Which models are available depends on your provider; see Configure Model Provider.

Benchmark data

Note on cost and latency: numbers are totals for the full benchmark set of N = 30. Cost is the number of prompt and completion tokens used multiplied by the provider's prices at the time.

DatasetModel# ExamplesHintCost (USD)Latency (s)PrecisionRecallF1
usernamegpt-4-1106-preview14yes0.47728.230.681.00.81
usernamegpt-4-1106-preview14no0.34126.760.450.770.57
usernamegpt-4-1106-preview8yes0.28934.310.821.00.9
usernamegpt-4-1106-preview8no0.20122.990.620.560.59
usernamegpt-4-1106-preview2yes0.11419.990.571.00.72
usernamegpt-4-1106-preview2no0.08726.790.460.920.62
usernamegpt-4-0125-preview14yes0.47734.080.651.00.79
usernamegpt-4-0125-preview14no0.34120.50.430.920.59
usernamegpt-4-0125-preview8yes0.26420.730.71.00.83
usernamegpt-4-0125-preview8no0.23720.160.620.880.73
usernamegpt-4-0125-preview2yes0.11425.770.651.00.79
usernamegpt-4-0125-preview2no0.08717.740.410.920.57
usernamegpt-3.5-turbo-16k-061314yes0.14314.240.610.850.71
usernamegpt-3.5-turbo-16k-061314no0.10212.770.440.850.58
usernamegpt-3.5-turbo-16k-06138yes0.07910.210.670.920.77
usernamegpt-3.5-turbo-16k-06138no0.05610.320.480.850.61
usernamegpt-3.5-turbo-16k-06132yes0.0349.630.50.770.61
usernamegpt-3.5-turbo-16k-06132no0.0268.620.430.920.59
usernamegpt-3.5-turbo-110614yes0.04816.320.550.850.67
usernamegpt-3.5-turbo-110614no0.03415.260.420.770.54
usernamegpt-3.5-turbo-11068yes0.02612.640.591.00.74
usernamegpt-3.5-turbo-11068no0.03512.280.640.740.68
usernamegpt-3.5-turbo-11062yes0.01110.220.481.00.65
usernamegpt-3.5-turbo-11062no0.00910.110.440.920.6
usernamegpt-3.5-turbo-012514yes0.02419.480.610.850.71
usernamegpt-3.5-turbo-012514no0.01717.840.410.850.55
usernamegpt-3.5-turbo-01258yes0.01312.50.681.00.81
usernamegpt-3.5-turbo-01258no0.00912.240.670.90.77
usernamegpt-3.5-turbo-01252yes0.00611.140.481.00.65
usernamegpt-3.5-turbo-01252no0.00411.870.430.920.59
passwordgpt-4-1106-preview14yes0.43134.360.90.820.86
passwordgpt-4-1106-preview14no0.30231.260.60.860.71
passwordgpt-4-1106-preview8yes0.28323.880.891.00.94
passwordgpt-4-1106-preview8no0.20222.470.820.880.85
passwordgpt-4-1106-preview2yes0.11222.540.81.00.89
passwordgpt-4-1106-preview2no0.08524.590.650.940.77
passwordgpt-4-0125-preview14yes0.4821.380.91.00.95
passwordgpt-4-0125-preview14no0.29521.190.70.780.74
passwordgpt-4-0125-preview8yes0.28320.430.941.00.97
passwordgpt-4-0125-preview8no0.20219.190.830.940.88
passwordgpt-4-0125-preview2yes0.11220.110.891.00.94
passwordgpt-4-0125-preview2no0.08519.10.680.940.79
passwordgpt-3.5-turbo-16k-061314yes0.13614.570.51.00.67
passwordgpt-3.5-turbo-16k-061314no0.10813.010.650.730.69
passwordgpt-3.5-turbo-16k-06138yes0.08513.870.880.940.91
passwordgpt-3.5-turbo-16k-06138no0.0610.60.730.690.71
passwordgpt-3.5-turbo-16k-06132yes0.0349.250.850.690.76
passwordgpt-3.5-turbo-16k-06132no0.0259.330.60.560.58
passwordgpt-3.5-turbo-110614yes0.04615.620.590.930.72
passwordgpt-3.5-turbo-110614no0.0319.40.520.860.65
passwordgpt-3.5-turbo-11068yes0.02811.00.761.00.86
passwordgpt-3.5-turbo-11068no0.02115.60.640.880.74
passwordgpt-3.5-turbo-11062yes0.0119.90.790.940.86
passwordgpt-3.5-turbo-11062no0.00911.930.60.560.58
passwordgpt-3.5-turbo-012514yes0.0220.30.761.00.87
passwordgpt-3.5-turbo-012514no0.01718.960.60.690.64
passwordgpt-3.5-turbo-01258yes0.01414.030.891.00.94
passwordgpt-3.5-turbo-01258no0.0114.890.630.750.69
passwordgpt-3.5-turbo-01252yes0.00616.60.891.00.94
passwordgpt-3.5-turbo-01252no0.00413.080.60.560.58
jobtitlegpt-4-1106-preview14yes0.40125.20.881.00.93
jobtitlegpt-4-1106-preview14no0.27826.070.620.50.55
jobtitlegpt-4-1106-preview8yes0.25826.940.881.00.94
jobtitlegpt-4-1106-preview8no0.18124.90.310.310.31
jobtitlegpt-4-1106-preview2yes0.26128.320.841.00.91
jobtitlegpt-4-1106-preview2no0.23225.680.640.430.51
jobtitlegpt-4-0125-preview14yes0.45224.010.911.00.95
jobtitlegpt-4-0125-preview14no0.31622.50.270.20.23
jobtitlegpt-4-0125-preview8yes0.28322.520.811.00.9
jobtitlegpt-4-0125-preview8no0.17820.890.50.80.62
jobtitlegpt-4-0125-preview2yes0.26124.190.811.00.89
jobtitlegpt-4-0125-preview2no0.23226.820.650.520.58
jobtitlegpt-3.5-turbo-16k-061314yes0.13616.880.860.710.77
jobtitlegpt-3.5-turbo-16k-061314no0.09614.730.220.170.19
jobtitlegpt-3.5-turbo-16k-06138yes0.10110.670.870.870.87
jobtitlegpt-3.5-turbo-16k-06138no0.0499.480.560.60.58
jobtitlegpt-3.5-turbo-16k-06132yes0.07810.11.00.620.76
jobtitlegpt-3.5-turbo-16k-06132no0.0710.480.670.190.3
jobtitlegpt-3.5-turbo-110614yes0.04218.520.650.870.74
jobtitlegpt-3.5-turbo-110614no0.02717.730.580.740.65
jobtitlegpt-3.5-turbo-11068yes0.02814.650.71.00.82
jobtitlegpt-3.5-turbo-11068no0.02116.530.460.350.4
jobtitlegpt-3.5-turbo-11062yes0.02610.630.850.810.83
jobtitlegpt-3.5-turbo-11062no0.02311.460.620.240.34
jobtitlegpt-3.5-turbo-012514yes0.02118.730.750.80.77
jobtitlegpt-3.5-turbo-012514no0.01420.710.450.60.51
jobtitlegpt-3.5-turbo-01258yes0.01314.510.690.920.79
jobtitlegpt-3.5-turbo-01258no0.00814.510.580.610.59
jobtitlegpt-3.5-turbo-01252yes0.01314.520.860.90.88
jobtitlegpt-3.5-turbo-01252no0.01214.560.570.190.29
companynamegpt-4-1106-preview14yes0.43222.950.91.00.95
companynamegpt-4-1106-preview14no0.28725.030.520.610.56
companynamegpt-4-1106-preview8yes0.27722.140.951.00.97
companynamegpt-4-1106-preview8no0.19129.610.50.610.55
companynamegpt-4-1106-preview2yes0.11426.140.861.00.92
companynamegpt-4-1106-preview2no0.08519.790.520.610.56
companynamegpt-4-0125-preview14yes0.43221.870.951.00.97
companynamegpt-4-0125-preview14no0.28729.410.540.720.62
companynamegpt-4-0125-preview8yes0.27723.740.91.00.95
companynamegpt-4-0125-preview8no0.19119.740.50.610.55
companynamegpt-4-0125-preview2yes0.11419.30.520.670.59
companynamegpt-4-0125-preview2no0.08517.40.540.720.62
companynamegpt-3.5-turbo-16k-061314yes0.12912.90.890.940.92
companynamegpt-3.5-turbo-16k-061314no0.08610.310.60.670.63
companynamegpt-3.5-turbo-16k-06138yes0.08310.431.00.940.97
companynamegpt-3.5-turbo-16k-06138no0.05711.150.650.610.63
companynamegpt-3.5-turbo-16k-06132yes0.0349.380.781.00.88
companynamegpt-3.5-turbo-16k-06132no0.0259.520.560.780.65
companynamegpt-3.5-turbo-110614yes0.04313.610.751.00.86
companynamegpt-3.5-turbo-110614no0.02915.510.540.780.64
companynamegpt-3.5-turbo-11068yes0.02812.930.781.00.88
companynamegpt-3.5-turbo-11068no0.01912.040.550.670.6
companynamegpt-3.5-turbo-11062yes0.01110.590.641.00.78
companynamegpt-3.5-turbo-11062no0.00910.810.50.670.57
companynamegpt-3.5-turbo-012514yes0.02219.130.91.00.95
companynamegpt-3.5-turbo-012514no0.01414.310.570.670.62
companynamegpt-3.5-turbo-01258yes0.01412.940.781.00.88
companynamegpt-3.5-turbo-01258no0.0111.930.630.670.65
companynamegpt-3.5-turbo-01252yes0.00611.130.721.00.84
companynamegpt-3.5-turbo-01252no0.00410.280.590.940.72

Configuration

The rule type is ModelSensitiveDataRule, and apply_to_prompt and apply_to_response can each be true or false. The config must include examples, and may include a hint. Because the examples are specific to each use case, create sensitive data rules at the task level rather than as default rules. See the Rule Configuration Guide for the request body.


Did this page help you?