Add native Hugging Face Hub integration (push_to_hub / from_pretrained)
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 32/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- huggingface, python
调研方向
Read the wrapper class and any existing v2 save/load methods, then check how TextEmbedder, CategoricalVariableNet, and ClassificationHead store their state. Define a self-contained Hub save/load flow for weights, configuration, tokenizer, labels, and categorical encodings, with safetensors and a generated model card. Done means users can push a trained classifier and reload it with from_pretrained using the installed library.
由索引模型根据 Issue 内容生成。
描述
Motivation
We want to publish trained torchTextClassifiers models on the Hugging Face Hub under the InseeFr org so external users can reuse them. At the moment, there is no path to do this with the required automation/quality...
Proposal
Make the torchTextClassifiers wrapper class (and possibly TextClassificationModel) inherit from huggingface_hub.ModelHubMixin, so users can do:
from torchTextClassifiers import torchTextClassifiers
clf = torchTextClassifiers.from_pretrained("InseeFrLab/<model>", revision="v1.0.0")
clf.predict(...)
clf.push_to_hub("InseeFrLab/<model>")
Serialized artifact (self-contained, no pickle)
| File | Content |
|---|---|
model.safetensors |
weights of all components |
config.json |
architecture + hyperparameters (TextEmbedder, CategoricalVariableNet, ClassificationHead), task type (multiclass / multilabel), library version |
tokenizer/ |
HF tokenizer files, or n-gram tokenizer params/vocab |
labels.json |
index ↔ label code ↔ human-readable label |
categorical.json |
vocabularies / encodings of categorical variables |
README.md |
auto-generated model card |
Reloading must only require pip install torchTextClassifiers==<version>.
Implementation notes/proposals
- Implement
_save_pretrained/_from_pretrainedon the wrapper.PyTorchModelHubMixinalone only covers thenn.Moduleweights, not the tokenizer, labels or categorical encodings. - If v2 already has internal
save/loadmethods, the mixin should wrap them rather than duplicate them. - Set class-level mixin metadata:
library_name="torchtextclassifiers",repo_url,docs_url,tags=["text-classification", ...]. - Override
generate_model_card()so the YAML header includeslibrary_name,pipeline_tag: text-classification,license,language, and optionaldatasets/model-index(metrics) passed in by the user. - Allow extra card fields to be passed through
push_to_hub(...), e.g. dataset ID + revision, training code commit, metrics. - Save with
safetensorsonly; nevertorch.saveof full objects. - Keep
huggingface_hub/safetensorsas an optional extra (pip install torchTextClassifiers[hub]) if we want a lean core.
Open questions
- Should
from_pretrainedwarn or raise when the saved library version differs (major version) from the installed one? - Do we also want ONNX export for serving, or keep that in a separate issue?
- Should we register
torchtextclassifiersas a library on the Hub (huggingface.js) to get a "Use this model" snippet?
References
- 主要语言
- Python
- 星标
- 23
- 派生
- 7
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
InseeFrLab/torchTextClassifiers 的其他 Issue
-
难度 1/5 1 小时以内 新手友好度 78/100
-
难度 4/5 3-5 天 新手友好度 42/100
-
难度 2/5 1-3 小时 新手友好度 45/100
InseeFrLab/torchTextClassifiers#59 · 2 条评论 ·
-
enhancement
难度 5/5 一周以上 新手友好度 30/100
-
难度 3/5 1-2 天 新手友好度 15/100
查看 InseeFrLab/torchTextClassifiers 的全部 Issue
相似的 Issue
-
New Internship未关闭new_internship
难度 2/5 1-3 小时 新手友好度 68/100
-
get_graph warns that the oneway column is missing when no way has a oneway tag可能已有人在做 @HTenkanen 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
fix: security 🔐 style: article/section 📝 system: data-mgmt 🗃️ system: security 🔐 system: software 💻
难度 2/5 1-3 小时 新手友好度 65/100
uabrc/uabrc.github.io#1267 ·
-
Bot Type: Bug Type: Documentation
难度 2/5 1-3 小时 新手友好度 70/100
维护者通常 1 天内回复