schwarztgyt commited on
Commit
f5ff041
·
1 Parent(s): 38f484f

Remove dev audit file from repository

Browse files
Files changed (2) hide show
  1. .gitignore +0 -1
  2. dev/huggingface_compliance_audit.md +0 -215
.gitignore CHANGED
@@ -1,3 +1,2 @@
1
  dev/*
2
- !dev/huggingface_compliance_audit.md
3
  demo/demo_rec*.wav
 
1
  dev/*
 
2
  demo/demo_rec*.wav
dev/huggingface_compliance_audit.md DELETED
@@ -1,215 +0,0 @@
1
- # Hugging Face 合规性检查总结
2
-
3
- 检查日期:2026-06-05 UTC
4
-
5
- 检查对象:本地仓库 `MOSS-Audio-Tokenizer-V2`,远程地址为 `https://huggingface.co/OpenMOSS-Team/MOSS-Audio-Tokenizer-V2`。
6
-
7
- 结论:本地仓库整体已经是标准 Hugging Face Transformers 自定义模型仓库形态,权重使用 safetensors + Git LFS 分片,`config.json` 的 `auto_map` 和远程代码加载入口也能通过本地验证。没有发现会直接阻断上传或 `AutoConfig`/模型类动态导入的问题。2026-06-05 已完成一轮整改,补齐了主要发布质量问题;剩余事项主要是远程页面状态、可选 metadata 和更完整的结构化评测信息核验。
8
-
9
- ## 整改状态
10
-
11
- 已完成:
12
-
13
- - 添加根目录 `LICENSE`,使用 Apache-2.0 全文。
14
- - 删除 README license 部分的待办注释。
15
- - README 补充 Model Details、Intended Use、Training Data And Procedure、Evaluation、Limitations、Requirements。
16
- - README 示例保留 `demo/demo_gt.wav`,并说明可替换为自有音频;当前本地已有 `demo/demo_gt.wav`。
17
- - README 增加 production 使用 `trust_remote_code=True` 时 pin commit revision 的建议。
18
- - README repository layout 补充分片权重、index 和 demo 音频。
19
- - `.gitignore` 增加 `!dev/huggingface_compliance_audit.md`,使本审计文档可被 Git 跟踪;同时忽略 quickstart 生成的 `demo/demo_rec*.wav`。
20
-
21
- ## 检查依据
22
-
23
- 本次按 Hugging Face 官方文档的以下方向检查:
24
-
25
- - Model Cards: `README.md` 是模型卡,应包含 YAML metadata 和正文说明;模型卡应描述模型、用途/限制、训练信息、数据、评测结果等。参考:<https://huggingface.co/docs/hub/model-cards>
26
- - Model Card metadata: 建议显式写 `library_name`;可写 `pipeline_tag`、`license`、`datasets`、`model-index` 等以提高可发现性。参考:<https://huggingface.co/docs/hub/model-cards>
27
- - Custom Transformers model: 自定义模型需要配置类 `model_type`、模型类 `config_class`、`auto_map`,并通过 `trust_remote_code=True` 加载。参考:<https://huggingface.co/docs/transformers/custom_models>
28
- - 大文件和仓库结构:建议文件数少于 100k、单目录条目少于 10k、单文件分片小于 200GB、一次 commit 尽量少于 100 个大文件操作。参考:<https://huggingface.co/docs/hub/en/storage-limits>
29
- - 权重安全格式:safetensors 相比 pickle 更安全;pickle 权重存在任意代码执行风险。参考:<https://huggingface.co/docs/safetensors/en/index>、<https://huggingface.co/docs/hub/security-pickle>
30
-
31
- ## 本地证据
32
-
33
- ### 仓库结构
34
-
35
- `git ls-files` 当前跟踪的文件为:
36
-
37
- - `.gitattributes`
38
- - `README.md`
39
- - `__init__.py`
40
- - `config.json`
41
- - `configuration_moss_audio_tokenizer.py`
42
- - `modeling_moss_audio_tokenizer.py`
43
- - `model-00001-of-00003.safetensors`
44
- - `model-00002-of-00003.safetensors`
45
- - `model-00003-of-00003.safetensors`
46
- - `model.safetensors.index.json`
47
-
48
- 结构判断:符合 Hugging Face model repo 的基本结构。自定义 Transformers remote-code 文件、config、模型权重和权重索引均在根目录,用户可以通过 `AutoModel.from_pretrained(repo_id, trust_remote_code=True)` 获取。
49
-
50
- 注意:当前 `.gitignore` 保留 `dev/*`,但已增加 `!dev/huggingface_compliance_audit.md`,因此本文件可以被 Git 跟踪。`.gitignore` 还忽略 quickstart 生成的 `demo/demo_rec*.wav`。
51
-
52
- ### 模型卡 README
53
-
54
- 已符合:
55
-
56
- - `README.md` 顶部已有 YAML metadata。
57
- - 已声明 `license: apache-2.0`。
58
- - 已声明 `library_name: transformers`。这点很重要,因为 Hugging Face 对 2024-08 之后创建的模型仓库不再总是从 `config.json` 自动推断为 Transformers。
59
- - 已提供与 audio tokenizer 相关的 tags:`audio`、`audio-tokenizer`、`neural-codec`、`moss-tts-family`、`speech-tokenizer`、`trust-remote-code` 等。
60
- - 已包含 quickstart、streaming 使用示例、RVQ 层数控制、citation 和 license 说明。
61
- - README 示例明确使用 `trust_remote_code=True`,与 custom model 要求一致。
62
-
63
- 仍可改进或待核验:
64
-
65
- - YAML metadata 仍未添加 `pipeline_tag`。音频 tokenizer 不一定有完全匹配的官方 pipeline;如果 Hugging Face metadata UI 接受,可以考虑 `feature-extraction`,否则保留现有自定义 tags。
66
- - YAML metadata 没有 `datasets`。README 已补训练数据说明;如果训练数据有公开 Hub dataset id,可再补 `datasets` metadata。
67
- - 没有 `model-index` 或结构化 eval metadata。若论文中有重建质量、ASR/TTS 下游指标,建议加入正文表格;如果有可结构化指标,再加 `model-index`。
68
- - 远程页面 metadata 是否正确渲染仍需有权限账号确认。
69
-
70
- ### config 和 AutoClass
71
-
72
- 已符合:
73
-
74
- - `config.json` 包含:
75
- - `model_type: "moss-audio-tokenizer"`
76
- - `architectures: ["MossAudioTokenizerModel"]`
77
- - `auto_map.AutoConfig: "configuration_moss_audio_tokenizer.MossAudioTokenizerConfig"`
78
- - `auto_map.AutoModel: "modeling_moss_audio_tokenizer.MossAudioTokenizerModel"`
79
- - `configuration_moss_audio_tokenizer.py` 中 `MossAudioTokenizerConfig.model_type` 与 `config.json` 一致。
80
- - `modeling_moss_audio_tokenizer.py` 中 `MossAudioTokenizerPreTrainedModel.config_class = MossAudioTokenizerConfig`。
81
- - `modeling_moss_audio_tokenizer.py` 设置了 `main_input_name = "input_values"`、`input_modalities = "audio"` 和 `_no_split_modules`,对 Transformers 加载/设备切分是正面信号。
82
-
83
- 本地验证通过:
84
-
85
- ```bash
86
- python -c "from transformers import AutoConfig; c=AutoConfig.from_pretrained('.', trust_remote_code=True); print(type(c).__name__, c.model_type, c.architectures, c.auto_map)"
87
- ```
88
-
89
- 输出要点:
90
-
91
- ```text
92
- MossAudioTokenizerConfig moss-audio-tokenizer ['MossAudioTokenizerModel'] {'AutoConfig': 'configuration_moss_audio_tokenizer.MossAudioTokenizerConfig', 'AutoModel': 'modeling_moss_audio_tokenizer.MossAudioTokenizerModel'}
93
- ```
94
-
95
- 模型类动态导入也通过:
96
-
97
- ```bash
98
- python -c "from transformers.dynamic_module_utils import get_class_from_dynamic_module; cls=get_class_from_dynamic_module('modeling_moss_audio_tokenizer.MossAudioTokenizerModel', '.'); print(cls.__name__, cls.config_class.__name__)"
99
- ```
100
-
101
- 输出要点:
102
-
103
- ```text
104
- MossAudioTokenizerModel MossAudioTokenizerConfig
105
- ```
106
-
107
- 当前状态:
108
-
109
- - README 已补 “Requirements” 小节,说明 Python、PyTorch、Transformers、`torchaudio` 和可选 `flash-attn`。
110
- - README 已说明 `config.json` 中的 `transformers_version` 为 `4.56.0.dev0`,建议使用支持 custom remote-code models 的近期 Transformers build。
111
- - README 已加入 production 使用 `trust_remote_code=True` 时 pin reviewed commit hash 的建议。
112
-
113
- ### 权重、LFS 和仓库大小
114
-
115
- 已符合:
116
-
117
- - `.gitattributes` 对 `*.safetensors` 设置了 `filter=lfs diff=lfs merge=lfs -text`。
118
- - `git lfs ls-files` 列出了三个 safetensors 分片:
119
- - `model-00001-of-00003.safetensors`
120
- - `model-00002-of-00003.safetensors`
121
- - `model-00003-of-00003.safetensors`
122
- - `git cat-file -s HEAD:model-00001-of-00003.safetensors` 为 135 字节,说明 Git 对象里是 LFS pointer,不是把 3.9GB 权重作为普通 Git blob 提交。
123
- - 第一个 LFS pointer 内容记录了真实大小 `3978639168` 字节。
124
- - 另外两个分片的 Git blob size 分别为 135 和 134 字节,也符合 LFS pointer 预期。
125
- - `model.safetensors.index.json` metadata:
126
- - `total_parameters: 2123701248`
127
- - `total_size: 8494804992`
128
- - `weight_map` 条目数:2094
129
- - `weight_map` 分片分布:
130
- - `model-00001-of-00003.safetensors`: 898 entries
131
- - `model-00002-of-00003.safetensors`: 1010 entries
132
- - `model-00003-of-00003.safetensors`: 186 entries
133
- - 三个分片大小约 3.98GB、3.99GB、0.52GB,远低于 Hugging Face 对大文件建议的 200GB 分片线,也低于 500GB 单文件硬限制。
134
- - 仓库跟踪文件数量只有 10 个,远低于 100k 文件建议,也不存在单目录 10k 条目问题。
135
-
136
- 需要改进或待核验:
137
-
138
- - 只能确认本地当前分支的 LFS pointer。远程仓库历史中是否有旧的大 LFS 版本、未清理 PR ref、重复上传,需要在 Hugging Face repo Settings 的 “List LFS files” 或通过有权限的 API 再查。
139
- - 如果后续更新权重,建议保持分片数量少、每次 commit 的大文件操作不超过 50-100 个。
140
-
141
- ### 安全性
142
-
143
- 已符合:
144
-
145
- - 权重使用 safetensors,没有发现 `.bin`、`.pt`、`.pth`、`.pkl`、`.pickle` 等 pickle 风险权重文件。
146
- - 自定义代码 import 扫描未发现明显高风险模式:`subprocess`、`requests`、`urllib`、`socket`、`pickle`、`torch.load`、`eval(`、`exec(` 等。
147
- - `flash_attn` 是 try/except 可选依赖;缺失时会回退,不会阻断基础导入。
148
-
149
- 当前状态:
150
-
151
- - README 已说明 repo 使用 custom Transformers remote code,并建议生产环境 pin reviewed commit hash。
152
- - 如果未来增加依赖,仍应避免在模型 import 或 forward 过程中做网络访问、文件系统副作用、shell 调用。
153
-
154
- ### 远程页面状态
155
-
156
- 待核验:
157
-
158
- - 浏览器/匿名 API 访问 `https://huggingface.co/OpenMOSS-Team/MOSS-Audio-Tokenizer-V2` 返回 401,当前无法匿名确认远程页面实际渲染、文件列表、模型卡 metadata 解析结果、LFS 文件列表或下载统计。
159
- - 本地 `git remote -v` 确认 origin 指向该 Hugging Face repo。
160
-
161
- 建议有权限的人在 Hugging Face 页面上手动确认:
162
-
163
- - README metadata 是否被页面正确解析。
164
- - `Files and versions` 中是否有 3 个 safetensors 分片和 index。
165
- - 页面是否显示 `Safetensors`、`Transformers`、license、任务标签。
166
- - `Security`/file scan 是否正常,无 pickle 或 malware 警告。
167
- - LFS storage 页面是否没有多余历史大文件。
168
-
169
- ## 优先级建议
170
-
171
- ### P0:阻断项
172
-
173
- 本地未发现明确 P0 阻断项。`AutoConfig` 和模型类动态导入通过,权重以 LFS pointer 形式跟踪。
174
-
175
- ### P1:已完成
176
-
177
- - 已删除 README 中的 license 待办注释。
178
- - 已添加根目录 `LICENSE` 文件,放 Apache-2.0 全文。
179
- - 已补 README 标准模型卡小节:intended use、limitations、training data、training procedure、evaluation results、ethical considerations。
180
- - 已加 “Requirements” 小节,写清 Python、Transformers、PyTorch、`torchaudio`、可选 `flash-attn`。
181
- - 已确认并保留 `demo/demo_gt.wav` 示例音频,README 说明可替换为自有音频。
182
-
183
- ### P2:增强可发现性和可维护性
184
-
185
- - 如 Hugging Face metadata UI 校验通过,增加 `pipeline_tag: feature-extraction`。
186
- - 如有论文指标,加入 eval 表格;可结构化时再加入 `model-index`。
187
- - 如训练数据有公开 Hub dataset id,补 `datasets` metadata;否则正文解释数据范围和不可公开原因。
188
- - 用有权限账号确认远程页面和 LFS storage 状态。
189
-
190
- ## 推荐的 README metadata 方向
191
-
192
- 以下仅是方向,`pipeline_tag` 需要以 Hugging Face metadata UI 的校验结果为准:
193
-
194
- ```yaml
195
- ---
196
- license: apache-2.0
197
- library_name: transformers
198
- pipeline_tag: feature-extraction
199
- tags:
200
- - audio
201
- - audio-tokenizer
202
- - neural-codec
203
- - speech-tokenizer
204
- - trust-remote-code
205
- - arxiv:2602.10934
206
- ---
207
- ```
208
-
209
- 如果 `pipeline_tag: feature-extraction` 不适合该 tokenizer,就不要强行添加;保留自定义 tags,并在正文明确这是 audio tokenizer / neural codec。
210
-
211
- ## 最终判断
212
-
213
- 按本地证据看,这个仓库已经基本符合 Hugging Face 模型仓库和 Transformers custom remote-code 的关键规范:模型卡存在、metadata 基本可用、config/auto_map 正确、权重是 safetensors、LFS tracking 正确、分片和索引一致、文件数量和分片大小都在建议范围内。
214
-
215
- 主要发布质量问题已经整改:LICENSE、README 待办注释、模型卡补充、依赖版本说明和 remote-code 安全建议都已加入。剩余风险主要是远程页面因为匿名访问 401,需要有权限账号再做最后确认;另外 `pipeline_tag`、`datasets`、`model-index` 是否补充取决于 Hugging Face metadata 校验结果和可公开的训练/评测信息。