Implementation Guide
Detecting Custom Identifiers Such as Policy Numbers and Member IDs in LLM Prompts as a Runtime Control
Detect custom identifiers by layering signals instead of relying on one technique. Use format and checksum patterns to find candidates, keyword proximity and dictionary lookups to confirm them, and an ML entity model only for ambiguous cases. Apply the pipeline wherever text crosses a trust boundary, including prompts, tool-call arguments, retrieved context, and outputs. Map each result to a policy action and an audit record that does not store the raw identifier.
Why standard detectors miss organization-specific identifiers
Policy numbers, member IDs, and account references are custom identifiers. No single technique detects them reliably, so detection works best when several signals are layered and each result is mapped to a policy action.
Detection techniques and how each is used
Each technique has a distinct role in the pipeline. Patterns find candidates, contextual signals confirm them, and a model handles only what remains ambiguous.
| Technique | Role in the pipeline |
|---|---|
| Format and checksum patterns | Find candidate identifiers. |
| Keyword proximity and dictionary lookups | Confirm candidates. |
| ML entity model | Resolve ambiguous cases only. |
Combining techniques in a layered pipeline
Instead of relying on one technique, run text through a sequence of stages. Each stage narrows or confirms what the previous stage found.
Layered detection path
- NormalizeClean and decode text from prompts, tool arguments, and retrieved content.
- Match candidatesUse permissive patterns to favor recall.
- Validate and scoreApply checksum, context, and lookup signals to produce a confidence score.
- EnforceBlock, redact, tokenize, or log based on policy.
- Record evidenceStore entity type, action, and policy version without the raw value.
Measuring precision and recall
The pipeline separates two goals. Permissive candidate patterns favor recall, so few identifiers are missed. Validation and scoring then apply checksum, context, and lookup signals to produce a confidence score for each candidate, which is the point where false positives are filtered out.
Where to enforce detection and which action to apply
Apply the pipeline wherever text crosses a trust boundary:
- Prompts
- Tool-call arguments
- Retrieved context
- Model outputs
Map each result to a policy action: block, redact, tokenize, or log. Each detection should also produce an audit record.
Questions to ask when evaluating a runtime layer
- Does it support custom entity definitions with regex plus format or checksum validation, keyword-proximity scoring, dictionary matching, and ML recognition in one pipeline?
- Can it inspect prompts, tool-call arguments, retrieved context, and model outputs, not only user-entered text?
- Which actions (block, redact, tokenize, log) are available per entity type, and can they vary by user, application, or destination model?
- How is added latency measured, and what does it look like at your expected request volume?
- Does each detection produce audit evidence with entity type, action, policy version, and timestamp?
- Can that evidence be exported for compliance reviews without storing the raw identifier?