AI Practices AI实践 4h ago Updated 54m ago 更新于 54分钟前 45

Model-agnostic PII detection with LLMs 基于LLM的模型无关PII检测

A configurable, model-agnostic PII detection system built on LLMs that treats detection logic as instructions rather than fixed code, enabling flexible entity detection without retraining The detector uses instruction-driven design with a uniform inference interface (Inferencer) that supports both managed APIs (Amazon Bedrock) and self-hosted open models Evaluated span-for-span against eight other LLM-based detectors including OpenAI PrivacyFilter across five public PII corpora, demonstrating co 提出一种基于LLM的模型无关PII检测方案,通过指令驱动而非模型微调实现实体检测,支持动态扩展检测类型 采用可配置后端架构,通过统一Inferencer接口同时支持Amazon Bedrock托管模型和私有化部署的开源模型 在五个公开PII语料库上评估,与包括OpenAI PrivacyFilter在内的九个LLM检测器进行对比测试 核心创新在于将检测逻辑完全置于prompt模板中,新增实体类型仅需编辑一行指令,无需重新训练或部署 系统包含四个关键组件:PII schema模板、LLM后端集成、解析与偏移计算层、统一调用序列

60
Hot 热度
70
Quality 质量
65
Impact 影响力

Analysis 深度分析

TL;DR

  • A configurable, model-agnostic PII detection system built on LLMs that treats detection logic as instructions rather than fixed code, enabling flexible entity detection without retraining
  • The detector uses instruction-driven design with a uniform inference interface (Inferencer) that supports both managed APIs (Amazon Bedrock) and self-hosted open models
  • Evaluated span-for-span against eight other LLM-based detectors including OpenAI PrivacyFilter across five public PII corpora, demonstrating competitive performance
  • Customization requires only prompt edits—adding or removing entity types is a one-line change with no retraining or redeployment needed
  • The system handles messy, multilingual PII across eight languages without translation, addressing limitations of traditional token-classification models with frozen schemas

Why It Matters

This approach solves a critical problem in AI safety: models fine-tuned on real-world text can memorize and leak personally identifiable information, creating compliance and privacy risks. By making PII detection configurable and model-agnostic, organizations can adapt quickly to new entity types (like employee IDs or crypto-wallet addresses) without costly retraining cycles. The ability to run on either managed cloud APIs or air-gapped infrastructure makes it practical for regulated industries with strict data residency requirements.

Technical Details

  • Architecture: Four-component system—(1) prompt template defining 15 entity categories with definitions, do-not-flag lists, and few-shot examples; (2) configurable backend via Inferencer interface accepting any messages-in/text-out model; (3) parsing and offset layer that computes exact character positions from LLM-returned text spans; (4) thin call sequence orchestrating the pipeline
  • Model Agnosticism: Supports Amazon Bedrock (Mistral, OSS-GPT) and self-hosted models (e.g., OSS-GPT 20B on EC2 with GPU) through a uniform interface, enabling deployment in VPCs or air-gapped environments
  • Prompt Design: Schema defined in pii_detector/templates.py as a system prompt with JSON output format specifying pii_entity_type and pii_entity_value fields; LLMs do not return character offsets directly—post-processing recovers them
  • Evaluation: Span-for-span comparison against 9 LLM-based detectors (including OpenAI PrivacyFilter) across 5 public PII corpora with common ground truth
  • Customization: Entity set changes require only one-line prompt edits; no retraining, relabeling, or redeployment needed for new domain-specific identifiers

Industry Insight

  • Organizations should adopt instruction-driven PII detection for fine-tuning pipelines to prevent data leakage from training corpora containing names, addresses, SSNs, and other sensitive information
  • The model-agnostic design enables hybrid deployment strategies: use frontier models for accuracy-critical scenarios and smaller open models for cost-sensitive or air-gapped environments
  • As PII formats evolve (crypto wallets, employee IDs, domain-specific identifiers), the ability to extend detection without retraining provides significant operational agility compared to traditional transformer taggers locked to fixed schemas

TL;DR

  • 提出一种基于LLM的模型无关PII检测方案,通过指令驱动而非模型微调实现实体检测,支持动态扩展检测类型
  • 采用可配置后端架构,通过统一Inferencer接口同时支持Amazon Bedrock托管模型和私有化部署的开源模型
  • 在五个公开PII语料库上评估,与包括OpenAI PrivacyFilter在内的九个LLM检测器进行对比测试
  • 核心创新在于将检测逻辑完全置于prompt模板中,新增实体类型仅需编辑一行指令,无需重新训练或部署
  • 系统包含四个关键组件:PII schema模板、LLM后端集成、解析与偏移计算层、统一调用序列

为什么值得看

本文针对大模型微调场景中的PII泄露风险提供了实用的工程解决方案,展示了如何用LLM的指令理解能力替代传统的固定schema分类模型,为AI从业者处理敏感数据提供了新的技术路径。

技术解析

  • 指令驱动检测架构:检测逻辑完全封装在系统prompt模板中,包含15个实体类别定义、do-not-flag列表、可选的few-shot示例。模型输出JSON格式的实体列表(类型+值),字符偏移量通过后处理步骤计算,避免LLM直接输出不可靠的偏移数据。
  • 可配置后端设计:通过Inferencer接口抽象模型调用,内置Amazon Bedrock适配器(支持Mistral等模型),同时接受自定义适配器对接私有化部署的开源模型(如OSS-GPT 20B),实现托管API与VPC内部署的无缝切换。
  • 双维度可定制性:模型选择(影响准确率、延迟、成本)与实体集定义(影响检测范围)相互独立。扩展新实体类型只需修改prompt模板一行配置,无需重新训练或部署。
  • 评估方法论:采用span-for-span的细粒度评估,在五个公开PII语料库上对比九个LLM检测器(含OpenAI PrivacyFilter),使用统一ground truth进行公平比较。
  • 多语言支持:LLM原生支持跨八种语言的上下文推理,无需额外的翻译步骤,简化了多语言场景下的PII检测流程。

行业启示

  • PII检测范式转变:从"训练固定分类器"转向"指令驱动检测",为敏感信息处理提供了更灵活的架构选择,尤其适合需要频繁调整检测规则的动态业务场景。
  • 部署灵活性成为核心竞争力:支持托管API与私有化部署的双模式,满足了对数据主权和合规性要求严格的行业(如金融、医疗)需求,降低了AI落地的基础设施门槛。
  • 提示工程即配置:将业务逻辑(实体定义、排除规则)从代码中剥离到prompt层,使非技术人员也能参与检测规则调整,提升了系统的可维护性和响应速度。

Disclaimer: The above content is generated by AI and is for reference only. 免责声明:以上内容由 AI 生成,仅供参考。

LLM 大模型 Security 安全 Fine-tuning 微调 Evaluation 评测 Dataset 数据集