[Integration]: polanon

未关闭 适合新手
#770 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 13 天内回复

还没有人认领这个 Issue。

评估

难度
1/5
预计耗时
1 小时以内
新手友好度
84/100
Issue 类型
文档
描述清晰度
描述清楚
活跃度
活跃
技术栈
python
领域
documentation

调研方向

阅读 #730 中提到的现有集成页面,并将其与此 issue 中 polanon 当前版本的详细信息和链接进行比较。更新页面以介绍当前版本并链接到此 issue;当页面反映所提供的详细信息,且作者可以创建计划中的 PR 时,任务即完成。

由索引模型根据 Issue 内容生成。

描述

Stage

Ready: integration exists and works, proposing to list it

Integration or project name

polanon

Integration type

Custom Component

Published package or repo (if it exists)

https://pypi.org/project/polanon/ and https://github.com/boromat/polanon

Need or proof of use
  • Published on PyPI under the MIT license. pip install "polanon[haystack]" adds four Haystack 3 components: PolanonDocumentMasker, PolanonQueryMasker, PolanonRestorer and PolanonStreamRestorer. The current release is 0.4.4.
  • examples/haystack_rag.py is a complete indexing and query pipeline that runs offline with Haystack's mock embedder and chat generator. examples/haystack_openai.py is the same pipeline with OpenAI.
  • CI runs on every commit. It runs the component tests and the offline example against the latest Haystack 3 release and against haystack-ai==3.0.0, and type-checks the module with Haystack installed.
  • PolGate, a self-hosted company chat with RAG over attachments, uses the same masking for retrieval without Haystack: index_chunks and mask_query, which PolanonDocumentMasker and PolanonQueryMasker call.
  • The use case is RAG over Polish documents such as contracts, invoices, CVs and customer e-mails. Names, PESEL numbers and addresses must not reach a hosted embedder, a vector store or a model (GDPR), but the reader still gets an answer with the real names in it.
Short description

polanon masks personal data reversibly before text reaches an embedder, a document store or a model. It puts the originals back into the answer, also while the answer streams. It is Polish-first: it validates the checksums of Polish identifiers (PESEL, NIP, REGON, ID card, IBAN) and reads Polish names in all seven grammatical cases.

For retrieval, tokens are computed with HMAC-SHA256 under a secret key. The same person gets the same token in every document and in every question, also when the name is in another grammatical case, so a masked question finds the masked passages. What each token stands for stays in the application's own mapping store, never in a document's content, meta or id.

I tested it on 1,000 Polish texts from ai4privacy's OpenPII that it was never tuned on, against Presidio set up for Polish with the same spaCy model:

polanon Presidio
Values masked whole 72% 66%
Spans masked outside the values 306 2,641

The details are in the benchmarks.

The integration page from #730 is ready; that PR was closed when this process started. Once this is approved, I'll open a PR with the page updated for the current release, linking this issue.

主要语言
Python
星标
114
派生
324
平均合并
7 天 2 小时
30 天内合并 PR
13

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

deepset-ai/haystack-integrations 的其他 Issue

查看 deepset-ai/haystack-integrations 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。