自定义词表扩充/发布场景下增加 Tokenizer 隐私防泄露提示及低频词元过滤支持

Open Beginner friendly
#10,621 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
Half a day
Newbie friendliness
62/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
python

Research direction

Start by locating the docs section that covers vocabulary expansion and custom tokenizer training/publishing, and check how min_frequency is currently surfaced there. For context on the risk, read the linked paper (arXiv:2510.05699) and its Tokenizer-MIA repo, which show that published tokenizer.json / .model files leak membership. Done means a short privacy note warning against publishing tokenizers built on sensitive corpora without low-frequency token filtering and recommending a non-zero min_frequency; the optional static pre-export check is a separate follow-up to scope with a maintainer.

Written by the indexing model from the issue text.

Description

enhancement
Checklist / 检查清单
  • I have searched existing issues, and this is a new feature request. / 我已经搜索过现有的 issues,确认这是一个新的 Feature Request。
Feature Request Description / Feature Request 描述

你好,提一个关于自定义词表 / Tokenizer 隐私安全的小建议。

很多开发者会用 ms-swift 在私有或敏感领域数据上做持续预训练、微调以及词表扩充(Vocabulary Expansion),并在完成后对外发布模型和对应的 tokenizer.json / .model 文件。但如果在构建或扩充词表时没有做词频剪枝(如 min_frequency 过滤),私有语料中的低频特定子词和合并规则会被直接记住在词表里。

我们在 USENIX Security 2026 的论文(arXiv:2510.05699,代码:https://github.com/mengtong0110/Tokenizer-MIA ,目前也已收录进 OWASP AISVS v1.0 Req. 11.2.5)中验证过:攻击者不需要调用模型推理、不需要访问模型权重,仅凭公开的 Tokenizer 文件就能直接做离线成员推理攻击(MIA),绕过所有推理阶段的隐私防御。

感谢阅读,如果可以我十分乐意参与进来补充:

  1. 文档补充:在词表扩充或自定义训练相关文档中增加一小段隐私提示,提醒在敏感数据上训练/扩充词表并公开发布时,注意过滤低频词元或设置非零 min_frequency。
  2. 可选的静态检查/过滤:在导出或发布前的工具链中,是否适合加一个轻量级的低频/异常词元检查选项(纯静态解析,不引入额外重依赖)。
Pull Request / Pull Request 信息

目前尚未提交 PR。如果团队认可这个方向,我可以先提一个轻量的文档 PR 补充隐私提示;如果可以,确认好放哪个模块后我也可以一起实现并补齐单测。

Dominant language
Python
Stars
16.2k
Forks
1.8k
Avg merge
1d 14h
Merged PRs (30d)
68

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from modelscope/ms-swift

All issues in modelscope/ms-swift

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.