Contact Us

Tell us about your stack and the privacy problems you're trying to solve. We typically respond within one business day.

Prefer email? support@philterd.ai

Please do not enter PII or PHI in this form. If you need to share an example, use a sanitized one.

Knowledge base How-to

Tune a Redaction Policy from Philter Scope's Recommendations

Use the recommendations in a Philter Scope report to tune a Philter policy: read each one, apply one change, and re-run the audit to measure it.

For Philter Scope and Philter

Every Philter Scope audit writes a recommendations list into report.json: one entry for each entity whose recall is below its target, and one for each entity whose precision has fallen below the precision floor. This guide works through one policy with them, from a recall gap to a clean run, applying one change at a time and re-running the same audit to measure each one.

Recommendations are advisory. Philter Scope does not edit your policy, and its numbers describe your labeled sample, not every document the policy will see. Validate the result on your own data before relying on it.

Three audits of the same labeled documents. Run 1: recall for PHONE_NUMBER is 0 percent, so Philter Scope recommends enabling the phoneNumber filter. Run 2: recall is 100 percent, but phone precision falls to 40 percent because the filter also matches ten-digit claim numbers, so Philter Scope asks you to investigate the filter. Run 3: a confidence condition keeps formatted phone numbers and skips the claim numbers, and every entity scores 100 percent recall and precision with no recommendations.

The starting point

This guide assumes you have a labeled golden/ directory and its raw/ copies, a running Philter 4, and its certificate saved as philter.pem, as set up in Measure redaction accuracy with Philter Scope, with Philter Scope 0.2.0 or later built from source. The examples use six invented insurance claim notes labeled with NAME, EMAIL, PHONE_NUMBER, and SSN. Each note also starts with an unlabeled ten-digit claim number, which is not PII:

Claim 2175550101. Claim intake for <NAME>Maria Delgado</NAME>, SSN <SSN>412-55-0187</SSN>. She asked us to call <PHONE_NUMBER>(217) 555-0143</PHONE_NUMBER> or write to <EMAIL>maria.delgado@example.com</EMAIL>.

The policy under test, claims-intake, is kept in a file, claims-intake.json, and loaded into Philter with POST /api/policies?name=claims-intake. It detects names, email addresses, and SSNs, and has no phone number filter yet.

Run the audit. --threshold 0.9 sets the recall target for every entity, and --precision-floor 0.5 raises the precision floor from its deliberately low default of 0.25. --group names the series this run belongs to in the audit history.

./philterscope-audit \
  --url https://localhost:8080 \
  --token "$PHILTER_API_KEY" \
  --ca-cert philter.pem \
  --policy claims-intake \
  --input ./audit/raw \
  --golden ./audit/golden \
  --output ./audit/run1 \
  --threshold 0.9 \
  --precision-floor 0.5 \
  --group claims-intake
Audit complete. Precision: 1.00, Recall: 0.76, F1: 0.87
Reports exported to ./audit/run1

1. List the recommendations

Each recommendation has an id of the form <kind>:<entity>, and a structured change that says what kind of edit it proposes. List them with jq:

jq -r '.recommendations[]? | "\(.id)\t\(.change.type)\t\(.change.filter)"' audit/run1/report.json
recall_below_threshold:PHONE_NUMBER	enable_filter	phoneNumber

Address recommendations by id. One entity can have both a recall recommendation and a precision recommendation, and they are separate decisions.

2. Read the recommendation

jq '.recommendations[0]' audit/run1/report.json
{
  "id": "recall_below_threshold:PHONE_NUMBER",
  "kind": "recall_below_threshold",
  "entity": "PHONE_NUMBER",
  "description": "Recall for PHONE_NUMBER is 0.0%, which is below the 90% threshold. 4 of 4 labeled spans were missed.",
  "action": "Enable the phoneNumber filter. The audited policy has no filter for it.",
  "snippet": "{\n  \"identifiers\": {\n    \"phoneNumber\": {\n      \"enabled\": true\n    }\n  }\n}",
  "metric": "recall",
  "value": 0,
  "threshold": 0.9,
  "current_recall": 0,
  "change": {
    "type": "enable_filter",
    "filter": "phoneNumber"
  },
  "projection": {
    "predicted": false,
    "note": "Widening a filter admits spans this audit never saw, so the effect on precision cannot be computed from this report. Re-run the audit after the change to measure it."
  },
  "resolved": false,
  "dismissed": false,
  "is_ai": false
}
  • change.filter is the policy key to edit. Philter Scope maps your gold-standard labels onto Philter filter names, so PHONE_NUMBER becomes phoneNumber. A few short labels are mapped by name: NAME to person, ADDRESS to streetAddress, EMAIL to emailAddress, PHONE to phoneNumber, and ZIP to zipCode.
  • snippet is a fragment to merge into your policy, not a complete policy.
  • projection.predicted is false. Philter Scope can compute the effect of a change only when the change drops detections it has already measured. Turning on a filter finds spans the audit never saw, so the only way to learn its effect is to run the audit again.

3. Apply the change and re-run

Merge the change into the policy file. A filter with no strategies redacts with the default REDACT strategy.

jq '.identifiers.phoneNumber = {"enabled": true}' claims-intake.json > claims-intake.next.json \
  && mv claims-intake.next.json claims-intake.json

Replace the policy in Philter. PUT stores the new content as a new revision of the same policy:

curl -sk -X PUT "https://localhost:8080/api/policies/claims-intake" \
  -H "Authorization: Bearer $PHILTER_API_KEY" \
  -H "Content-Type: application/json" \
  --data-binary @claims-intake.json \
  -o /dev/null -w "%{http_code}\n"
200

Run the same audit command with --output ./audit/run2:

Audit complete. Precision: 0.74, Recall: 1.00, F1: 0.85
Reports exported to ./audit/run2

Recall reached 1.00, but overall precision fell from 1.00 to 0.74.

4. When a fix creates a new problem

The report now carries a different recommendation:

jq '.recommendations[0]' audit/run2/report.json
{
  "id": "precision_collapsed:PHONE_NUMBER",
  "kind": "precision_collapsed",
  "entity": "PHONE_NUMBER",
  "description": "Precision for PHONE_NUMBER is 40.0%, below the 50% floor: 6 of 10 detections did not match a labeled span. A filter matching this far past the gold standard is usually misconfigured rather than deliberately wide.",
  "action": "Investigate what the phoneNumber filter is matching. No confidence threshold narrows it without costing recall, so do not narrow it on these numbers alone.",
  "snippet": "",
  "metric": "precision",
  "value": 0.4,
  "threshold": 0.5,
  "current_recall": 1,
  "current_precision": 0.4,
  "change": {
    "type": "none",
    "filter": "phoneNumber"
  },
  "projection": {
    "predicted": false,
    "note": "No change is proposed. Recall is the target, and every cutoff that would raise precision here costs recall."
  },
  "resolved": false,
  "dismissed": false,
  "is_ai": false
}

Philter Scope never proposes a change that costs measured recall: it proposes a higher confidence threshold only when the audit shows recall would not fall. A precision_collapsed recommendation is a warning to look at the filter, and change.type of none means the next step is yours.

Philter Scope tests confidence cutoffs only for a filter whose policy entry has a per-label thresholds field, which the PhEye model filters (person and pheyes) accept. The phone filter has no such field, so Philter Scope tested no cutoff for it, and the note does not describe a measured trade-off here. The per-document results show what the filter matched. List the phone detections with how each one overlapped a label and its confidence:

jq -r '.details[] | .filename as $f | .overlaps[]
  | select(.actual.label == "PHONE_NUMBER")
  | "\($f)  \(.type)  \(.actual.text)  \(.actual.confidence)"' audit/run2/report.json
intake-01.txt  EXACT  (217) 555-0143  0.95
intake-01.txt  NONE  2175550101  0.6
intake-02.txt  EXACT  (217) 555-0178  0.95
intake-02.txt  NONE  2175550117  0.6
intake-03.txt  NONE  3095550124  0.6
intake-04.txt  EXACT  (309) 555-0112  0.95
intake-04.txt  NONE  3095550138  0.6
intake-05.txt  NONE  2175550152  0.6
intake-06.txt  EXACT  (217) 555-0190  0.95
intake-06.txt  NONE  3095550166  0.6

The six false positives are the claim numbers, matched as bare ten-digit phone numbers with a confidence of 0.6. The labeled phone numbers scored 0.95. A strategy condition on confidence applies the strategy only to detections at or above a cutoff, and leaves the other matches in the text unchanged:

jq '.identifiers.phoneNumber = {"phoneNumberFilterStrategies": [{"condition": "confidence >= 0.9", "strategy": "REDACT"}]}' \
  claims-intake.json > claims-intake.next.json && mv claims-intake.next.json claims-intake.json

This is a judgment about your documents, not a fix Philter Scope can verify for you. The condition also leaves any real phone number written as ten bare digits unredacted. If your documents contain those, add examples of them to the golden set so the next audit measures that cost.

Replace the policy with the same PUT and run the audit again with --output ./audit/run3:

Audit complete. Precision: 1.00, Recall: 1.00, F1: 1.00
Reports exported to ./audit/run3
jq '.recommendations' audit/run3/report.json
null

No entity is below its recall target or the precision floor on this sample.

What each change type asks for

change.typeWhen Philter Scope proposes itWhat to do
enable_filterRecall is below target and the policy has no filter for the entity, or has one with "enabled": false.Add or switch on the filter named in change.filter, then re-run.
lower_confidence_thresholdRecall is below target, the filter is already on, and its policy entry has a thresholds field (a PhEye filter).Lower that label’s threshold, then re-run. The effect is not predicted.
raise_confidence_thresholdPrecision is below the floor and a higher cutoff drops only detections that matched no label, leaving recall unchanged.Apply the cutoff. Here projection.predicted is true, and the numbers are exact for this sample.
review_filterThe policy could not be read, the label maps to no Philter filter, or the filter is on and has no thresholds field.Decide by hand. For an unmapped label, choose which filter should cover it.
nonePrecision is below the floor and no cutoff raises it without costing recall, or the filter has no thresholds field.Inspect the detections in details, as above, and decide.

Habits that keep the numbers honest

  • Change one thing per run, and keep the golden set and the audit command the same between runs, so each difference in the numbers belongs to one change.
  • Read kind and change.type, not the action text, when you script against a report. The prose is written for people and can change wording.
  • Keep the same --group for a series of runs, so the dashboard shows them as one trend. See Track redaction accuracy over time.
  • --ai adds recommendations from a model through Ollama, at the URL in PHILTERSCOPE_OLLAMA_URL. Without that variable, --ai only prints a warning. Those have kind ai, carry no measurement, and leave the structured fields empty, so treat them as ideas to test rather than findings.
  • Grow the golden set when new kinds of documents arrive. A policy that scores well on this sample can still miss PII in documents that look different.