This prompt is designed for content moderation teams and trust & safety engineers who need to filter personally identifiable information (PII) from user-submitted content before it enters a model's context window, a public-facing display, or an internal database. The primary job-to-be-done is automated, high-recall detection of accidental self-doxxing, contact information sharing, and other PII leaks in unstructured text such as product reviews, forum posts, support tickets, and community comments. The ideal user is a developer or moderator integrating this prompt into a moderation pipeline where human review capacity is limited and consistency is critical.
Prompt
User-Generated Content PII Moderation Prompt Template

When to Use This Prompt
Define the job, reader, and constraints for the User-Generated Content PII Moderation Prompt Template.
Use this prompt when you need a structured, actionable moderation decision—not just a binary yes/no—for each piece of content. The template is built to return a specific JSON schema that includes the detected PII categories, a recommended action (such as REDACT, BLOCK, or ALLOW), and a confidence score. It is most effective when the primary risk is users exposing their own or others' private data, rather than a model generating it. You should wire this prompt into a pre-processing step, where user content is evaluated before it is stored, displayed, or passed to another model for summarization or analysis.
Do not use this prompt as a post-generation safety net for model outputs; for that scenario, use the sibling 'PII Detection and Redaction Prompt Template' in the 'Sensitive Data Redaction and PII Prompts' pillar. This prompt is also not a replacement for a dedicated, pattern-based PII scanner for high-precision, low-latency detection of structured data like credit card numbers. Instead, it excels at understanding context to disambiguate benign text from actual PII (e.g., a user saying 'my email is mike at example dot com' vs. a generic placeholder). For high-risk, regulated environments, always route low-confidence moderation decisions to a human review queue. The next step is to copy the prompt template, configure your PII categories and moderation actions, and integrate it with a validation layer that enforces the expected JSON output schema.
Use Case Fit
Where this prompt works and where it does not. Use these cards to decide if the User-Generated Content PII Moderation Prompt Template fits your operational context.
Good Fit: Community Moderation Queues
Use when: you have a queue of user-submitted reviews, comments, or forum posts that need PII scanning before publication. Guardrail: pair the prompt with a human moderator for borderline cases where the model flags potential PII but confidence is low.
Bad Fit: Real-Time Chat Filtering
Avoid when: you need sub-100ms PII detection in live chat streams. This prompt template is designed for batch or near-real-time moderation queues, not token-by-token streaming guards. Guardrail: use a streaming PII guard prompt for real-time use cases instead.
Required Input: Raw User Content with Metadata
What to watch: the prompt needs the full user-submitted text plus content metadata (submission type, user role, context) to make accurate moderation decisions. Guardrail: validate that input includes both the content body and a content type label before invoking the prompt.
Operational Risk: Self-Doxxing False Negatives
Risk: users intentionally sharing their own PII in public posts may use obfuscation patterns (spaced-out numbers, leetspeak) that the model misses. Guardrail: implement a secondary regex-based scan for common obfuscation patterns and escalate flagged posts for human review regardless of model confidence.
Operational Risk: Over-Redaction Breaking Context
Risk: aggressive PII redaction can strip names, locations, and identifiers that are essential to the post's meaning, rendering content useless. Guardrail: configure the prompt to return redaction justifications and allow moderators to override redactions where context is lost.
Bad Fit: Unstructured Free-Text Without Content Boundaries
Avoid when: the input is a continuous stream of mixed user and system messages without clear content boundaries. The prompt relies on knowing where user-generated content starts and ends. Guardrail: preprocess inputs to isolate user content segments before sending to the moderation prompt.
Copy-Ready Prompt Template
A reusable prompt template for detecting PII in user-generated content and recommending moderation actions.
This template is designed to be copied directly into your prompt management system, IDE, or orchestration layer. It accepts user-generated content and a configurable moderation policy, then returns a structured verdict with detected PII categories, severity, and recommended actions. Every placeholder is enclosed in square brackets and must be replaced with concrete values before the prompt is sent to the model. The template assumes the model will receive the full prompt as a single turn; if you are using a multi-turn or streaming architecture, adapt the output format instructions accordingly.
textYou are a content moderation assistant specialized in detecting personally identifiable information (PII) in user-generated content. Your task is to analyze the submitted content, identify any PII present, and recommend moderation actions based on the provided policy. ## INPUT [USER_CONTENT] ## MODERATION POLICY [MODERATION_POLICY] ## INSTRUCTIONS 1. Scan the entire input for PII across the following categories: - Full names (first and last) - Email addresses - Phone numbers - Physical addresses (street, city, postal code) - Government identifiers (SSN, passport, driver's license) - Financial account numbers (credit card, bank account) - Online identifiers (usernames, profile URLs, IP addresses) - Dates of birth - Geolocation data (coordinates, precise locations) 2. For each detected PII instance, record: - The exact text found - The PII category - The character offset range (start and end positions) - A confidence score from 0.0 to 1.0 3. Classify the overall content into one of these severity levels: - `none`: No PII detected - `low`: Single piece of low-sensitivity PII (e.g., first name only) - `medium`: Multiple PII instances or single piece of moderate-sensitivity PII - `high`: High-sensitivity PII (government IDs, financial data, full contact details) - `critical`: Multiple high-sensitivity PII instances or apparent self-doxxing 4. Recommend one of these moderation actions: - `approve`: Content is safe to publish as-is - `redact`: Remove PII and publish redacted version - `quarantine`: Hold for human review before publishing - `reject`: Block publication and notify user - `escalate`: Immediate escalation to security or legal team 5. If the moderation policy specifies different thresholds or actions, follow the policy over these defaults. ## OUTPUT FORMAT Return a valid JSON object with this exact schema: { "severity": "none|low|medium|high|critical", "action": "approve|redact|quarantine|reject|escalate", "pii_instances": [ { "text": "string", "category": "string", "start_offset": integer, "end_offset": integer, "confidence": float } ], "redacted_content": "string or null", "review_notes": "string" } ## CONSTRAINTS - Do not invent PII that is not present in the input. - If you are uncertain about a detection, set confidence below 0.7 and flag it in review_notes. - For `redact` actions, provide the redacted_content with PII replaced by [REDACTED:category]. - Never output the original PII in review_notes if the action is `reject` or `escalate`. - If the content contains PII that appears to belong to a minor, escalate regardless of policy thresholds.
To adapt this template for your environment, replace [USER_CONTENT] with the actual text submitted by the user, and [MODERATION_POLICY] with your organization's specific PII handling rules. The policy can include custom severity thresholds, allowed PII categories (for example, a platform that permits usernames but not real names), and escalation contacts. If your moderation pipeline already performs regex-based PII detection, you can add a [PRE_SCAN_RESULTS] placeholder to pass those findings as context, reducing the model's workload and improving consistency between rule-based and model-based detection layers.
Before deploying, test this prompt against a golden dataset that includes known PII instances, borderline cases (such as sample phone numbers or test credit card numbers), and content with no PII. Measure both precision and recall, and pay special attention to false positives on business addresses, public figures' names, and placeholder text like john.doe@example.com. If your use case involves user-facing moderation decisions, always route quarantine and escalate actions to a human review queue rather than acting on model output alone.
Prompt Variables
Required inputs for the User-Generated Content PII Moderation Prompt Template. Validate each variable before assembling the prompt to prevent runtime failures and ensure consistent moderation decisions.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[USER_CONTENT] | The raw user-submitted text to scan for PII | I live at 742 Evergreen Terrace and my email is homer@springfield.com | Required. Non-empty string. Must be the original unmodified content. Max 8000 characters to stay within context window after adding instructions. |
[CONTENT_TYPE] | The category of user-generated content being moderated | product_review | Required. Must match one of: product_review, forum_post, comment, profile_bio, support_ticket, chat_message. Used to adjust PII sensitivity thresholds. |
[PII_CATEGORIES] | The specific PII types to detect and flag | ["email", "phone", "physical_address", "full_name"] | Required. JSON array of strings. Valid values: email, phone, physical_address, full_name, username_handle, ip_address, ssn, credit_card, date_of_birth, url_with_pii. Empty array not allowed. |
[MODERATION_ACTION] | The action to recommend when PII is detected | redact_and_flag | Required. Must be one of: redact_and_flag, flag_only, block_content, redact_and_approve. Determines the output action recommendation field. |
[CONFIDENCE_THRESHOLD] | Minimum confidence score for reporting a PII match | 0.85 | Required. Float between 0.0 and 1.0. Matches below this threshold are excluded from the findings array. Set higher for public-facing surfaces, lower for internal review queues. |
[OUTPUT_SCHEMA] | The expected JSON structure for the moderation result | {"findings": [...], "action": "...", "confidence": ...} | Required. Valid JSON schema object. Must include findings array, action string, and confidence_summary object. Used to enforce structured output format. |
[FALSE_POSITIVE_EXAMPLES] | Known benign strings that match PII patterns but are not PII | ["test@example.com", "555-0100", "123 Main St, Sample City"] | Optional. JSON array of strings. Provide sample data, test accounts, and placeholder values common in your domain. Reduces false flagging of documentation examples and test data. |
[LOCALE] | The primary language and region of the user content | en-US | Optional. BCP 47 language tag. Defaults to en-US if not provided. Affects name pattern matching, address format detection, and phone number regex rules. |
Implementation Harness Notes
How to wire the UGC PII moderation prompt into a production content pipeline with validation, retries, and human review.
This prompt is designed to operate as a synchronous pre-publish gate within a content moderation workflow. When a user submits a comment, review, or forum post, the application should call the LLM with this prompt after basic input sanitization but before the content is written to the public database. The prompt expects raw user text as [INPUT] and a structured [OUTPUT_SCHEMA] that defines the expected JSON response containing a pii_detected boolean, a list of findings with type and confidence, and a moderation_action recommendation (allow, flag, block). The application layer must enforce the moderation action, not the model—the model recommends, the system decides.
Integration flow: The application should wrap the LLM call in a service function that handles the full lifecycle. First, validate the response against the expected JSON schema using a library like ajv or pydantic. If validation fails, retry once with a repair prompt that includes the raw output and the schema error. If the retry also fails, escalate to a human review queue and default to the safest moderation action (block for high-risk categories, flag for others). Log every decision—input hash, model response, validation result, and final action—to a structured audit table. This log is essential for tuning false positive rates and defending moderation decisions later.
Model choice and latency: For real-time user-facing flows, prefer smaller, faster models (e.g., GPT-4o-mini, Claude Haiku) with strict JSON mode enabled. The prompt's [RISK_LEVEL] parameter can be set to high for regulated communities (healthcare forums, children's platforms) where you might route to a larger model or add a second verification pass. If latency exceeds 500ms, consider asynchronous processing: accept the content, show a 'pending review' state, and process the PII check in the background before publishing. Never block the user experience on a slow model call without clear UX feedback.
Human review integration: The moderation_action field should map directly to your review queue logic. allow publishes immediately. flag creates a low-priority review task where a moderator can confirm or overturn the decision within a few hours. block prevents publication and creates a high-priority task. For each review task, include the original text, the model's findings with highlighted spans, and a one-click approve/reject interface. Track reviewer decisions to calculate your model's precision and recall over time. If reviewers overturn more than 10% of block decisions, adjust your confidence thresholds or add more few-shot examples of borderline cases to the prompt's [EXAMPLES] block.
What to avoid: Do not use the model's output to automatically delete or ban users without human confirmation. Do not log the raw user input alongside the model's PII findings in plaintext—the whole point is to prevent PII from entering your systems. Hash or tokenize the input in logs, and store the redacted version only. Finally, do not rely solely on this prompt for compliance with GDPR, CCPA, or COPPA; it is a detection layer, not a legal safeguard. Combine it with pattern-based scanning (regex for credit cards, SSNs) as a deterministic first pass, and use the LLM for contextual disambiguation that regex cannot handle.
Common Failure Modes
What breaks first when moderating user-generated content for PII and how to guard against it.
Contextual PII Misclassification
What to watch: The model flags sample data, test accounts, or placeholder text as real PII. Common with strings like test@example.com or 123-45-6789 in documentation. Guardrail: Add a pre-pass that identifies and whitelists known non-production patterns. Include explicit instructions to treat example.com domains and repeated digit patterns as synthetic unless context proves otherwise.
Over-Redaction Breaking Content Utility
What to watch: Aggressive redaction strips usernames, product names, or location references that are essential for moderation decisions. A review about a specific store location becomes useless when the city is masked. Guardrail: Implement tiered redaction rules. Distinguish between public business information and private personal data. Route borderline cases to a human review queue with the original text preserved.
Multilingual PII Blind Spots
What to watch: The model reliably catches English-format PII but misses names, addresses, and phone numbers in non-Latin scripts or formats common in other locales. Guardrail: Include locale-specific PII patterns in the prompt instructions. Test against a golden dataset that includes CJK, Arabic, Cyrillic, and right-to-left script samples. Log detection rates by language for monitoring.
Structured Field Leakage in Free Text
What to watch: The model scans narrative text but misses PII embedded in code blocks, JSON snippets, or URLs that users paste into comments or reviews. Guardrail: Add explicit instructions to parse and scan structured sub-content. Include examples of PII hidden in query parameters, base64 strings, and formatted code blocks. Validate with test cases that embed PII inside markdown code fences.
Moderation Action Drift Under Volume
What to watch: As input length grows or batch size increases, the model starts skipping the moderation action recommendation or defaults to a generic response instead of the required structured output. Guardrail: Enforce a strict output schema with required fields for action, confidence, and evidence. Add a post-generation validation step that rejects outputs missing the action field and triggers a retry with a focused prompt.
Self-Doxxing Pattern Gaps
What to watch: The model catches standard PII formats but misses self-doxxing patterns like 'my email is name at domain dot com' or 'you can find me on Instagram as @handle'. Guardrail: Include obfuscated PII examples in the prompt's few-shot demonstrations. Add regex pre-processing for common obfuscation patterns before the model call. Maintain a living list of evasion patterns from production logs.
Evaluation Rubric
Use this rubric to test the UGC PII moderation prompt before shipping. Each criterion targets a known failure mode in production content moderation pipelines. Run these checks against a golden dataset of 50-100 real and synthetic user submissions containing known PII, edge cases, and clean content.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
PII Recall | Detects >= 95% of known PII instances in the golden test set (emails, phones, physical addresses, government IDs, payment card numbers) | Known PII in test samples passes through unredacted or unlabeled | Run prompt against golden dataset with ground-truth PII labels; calculate recall per PII category; flag any category below 90% |
False Positive Rate | Flags < 5% of clean, non-PII content as sensitive (e.g., sample data, placeholder text, fictional names in reviews) | Benign strings like 'test@example.com' or '123 Main St' in clearly fictional context trigger redaction | Include 20+ clean samples with known false-positive triggers; measure false positive rate; require human review for borderline cases |
Moderation Action Accuracy | Correctly classifies each detection into the right action tier: redact, flag-for-review, or escalate with >= 90% accuracy | High-severity PII (SSN, credit card) receives only a flag instead of escalation; low-severity PII triggers unnecessary escalation | Compare prompt output action labels against pre-labeled expected actions in test set; measure per-tier precision and recall |
Redaction Completeness | Redacted output contains zero residual PII fragments; partial redactions (e.g., only area code of phone number) count as failure | Redacted text still contains recognizable PII fragments like '-12-3456' or 'john.@gmail.com' | Regex scan redacted output for PII patterns; manual spot-check 20 redacted samples for visual PII leakage |
Context Preservation | Redacted content retains readability and semantic meaning; placeholder text like [REDACTED-EMAIL] is used instead of empty strings | Redacted output becomes nonsensical or loses critical context (e.g., entire sentence deleted instead of targeted redaction) | Human review of 30 redacted samples; score readability on 1-5 scale; flag samples scoring below 3 for prompt adjustment |
Multi-Language PII Detection | Detects PII in non-English user submissions (Spanish, French, German, Japanese) with recall within 10% of English baseline | Non-English PII like 'mi correo es maria@example.com' or '私の電話番号は090-1234-5678' passes undetected | Include 15+ non-English PII samples in test set; measure per-language recall; investigate failures for locale-specific pattern gaps |
Self-Doxxing Detection | Identifies when users share their own PII in first-person narrative (e.g., 'my email is...', 'you can reach me at...') | Self-doxxing content is treated as benign because it lacks third-party PII patterns | Include 10+ self-doxxing examples in test set; verify prompt labels these as PII with appropriate action tier; check for first-person language handling |
Latency and Token Efficiency | Prompt processes a 500-word user submission and returns structured moderation output in under 3 seconds with < 2000 total tokens | Prompt exceeds 5-second latency or consumes > 4000 tokens for simple submissions, causing cost overruns in high-volume pipelines | Benchmark 100 submissions; measure p50 and p95 latency and token usage; flag if p95 exceeds threshold; optimize prompt length or model selection |
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Adapt This Prompt
How to adapt
Start with the base prompt and a small set of PII categories (email, phone, name). Use a single model call without chained validation. Accept markdown or plain-text output instead of enforcing strict JSON.
codeAnalyze the following [USER_CONTENT] for PII. Return a list of detected items with type and suggested action. PII types to check: email, phone, full name.
Watch for
- False positives on common names that appear in product reviews
- Missed PII in non-standard formats (e.g.,
name[at]domain[dot]com) - No confidence scoring, so borderline cases get the same treatment as clear hits

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us