Show HN: 我搭建了一个代理,在隐藏 PII 的同时保持 RAG 正常工作
3 分•作者: rohansx•5 个月前
嗨 HN,
当您将真实文档或客户数据发送给 LLM 时,您会面临一个痛苦的权衡:
* 发送原始文本 → 隐私灾难
* 使用 \[REDACTED] 进行编辑 → 嵌入中断,RAG 检索失败,多轮对话变得毫无用处,并且模型通常拒绝回答有关已编辑实体的问题。
实用的解决方案是一致的假名化:相同的真实实体始终映射到相同的 token(例如,“塔塔汽车” → ORG\_7,随处可见)。这保留了向量搜索和推理的语义含义,然后您重新构建响应,这样提供商就永远看不到实际的姓名、数字或地址。
我厌倦了使用 Presidio + 自定义胶水(截断的 RAG 块、印度语言的变格、针对拼写错误/同义词的模糊合并、LLM 混淆、百分比破坏数学)来解决这个问题。所以我构建了 Cloakpipe,它是一个小巧的单二进制 Rust 代理。
它执行以下操作:
* 多层检测(正则表达式 + 财务规则 + 可选的 GLiNER2 ONNX NER + 自定义 TOML)
* 在 AES-256-GCM 加密库中进行一致的可逆映射(内存清零)
* 智能重构,即使是截断的块也能幸存,例如 [[ADDRESS:A00
* 内置模糊解析,用于拼写错误和相似名称
* 数值推理模式,因此百分比仍然适用于计算
完全开源 (MIT),零 Python 依赖,开销 <5 毫秒。
代码库:[https://github.com/rohansx/cloakpipe](https://github.com/rohansx/cloakpipe)
演示和快速入门:[https://app.cloakpipe.co/demo](https://app.cloakpipe.co/demo)
欢迎任何审核过其 RAG 数据流或正在与编辑与语义问题作斗争的人提供反馈——尤其是在法律、金融科技或非英语工作流程中。
您采用了哪些方法?
查看原文
Hey HN,<p>When you send real documents or customer data to LLMs, you face a painful tradeoff:<p>- Send raw text → privacy disaster
- Redact with [REDACTED] → embeddings break, RAG retrieval fails, multi-turn chats become useless, and the model often refuses to answer questions about the redacted entities.<p>The practical solution is consistent pseudonymization: the same real entity always maps to the same token (e.g. “Tata Motors” → ORG_7 everywhere). This preserves semantic meaning for vector search and reasoning, then you rehydrate the response so the provider never sees actual names, numbers or addresses.<p>I got fed up fighting this with Presidio + custom glue (truncated RAG chunks, declension in Indian languages, fuzzy merging for typos/siblings, LLM confusion, percentages breaking math). So I built Cloakpipe as a tiny single-binary Rust proxy.<p>It does:
• Multi-layer detection (regex + financial rules + optional GLiNER2 ONNX NER + custom TOML)
• Consistent reversible mapping in an AES-256-GCM encrypted vault (memory zeroized)
• Smart rehydration that survives truncated chunks like [[ADDRESS:A00
• Built-in fuzzy resolution for typos and similar names
• Numeric reasoning mode so percentages still work for calculations<p>Fully open source (MIT), zero Python dependencies, <5 ms overhead.<p>Repo: <a href="https://github.com/rohansx/cloakpipe" rel="nofollow">https://github.com/rohansx/cloakpipe</a>
Demo & quick start: <a href="https://app.cloakpipe.co/demo" rel="nofollow">https://app.cloakpipe.co/demo</a><p>Would love feedback from anyone who has audited their RAG data flow or is struggling with the redaction-vs-semantics problem — especially in legal, fintech, or non-English workflows.<p>What approaches have you landed on?