为AdapterHub贡献
您可以通过多种方式为AdapterHub和adapters库做出贡献。这包括代码贡献,例如:
实现新的适配器方法
添加对新Transformer的支持
修复未解决的问题
以及非代码贡献,例如:
训练并将适配器上传至Hub
编写文档和博客文章
帮助他人解决问题和解答疑问
无论您想以何种方式贡献,我们都非常欢迎!
为adapters代码库做贡献
设置您的开发环境
要开始为adapters编写代码,您需要在本地开发环境中设置项目。
adapters 在许多方面都紧密遵循原始的Hugging Face Transformers代码库。
本指南假设您希望在本地机器上设置开发环境,并且您对git有基本了解。
此外,您需要预先安装Python 3.8或更高版本才能开始。
接下来,我们将逐步介绍设置流程:
Fork the
adaptersrepository 以获取代码的本地副本到您的用户账户下。将你的fork克隆到本地机器:
git clone --recursive git@github.com:<YOUR_USERNAME>/adapters.git cd adapters
注意:
--recursive参数对于初始化git子模块很重要。创建一个虚拟环境,例如通过
virtualenv或conda。根据您环境的安装命令,在他们的网站上安装PyTorch。
从本地git子模块安装Hugging Face Transformers:
pip install ./hf_transformers
安装
adapters及所需的开发依赖项:pip install -e ".[dev]"
添加适配器方法
How to integrate new efficient fine-tuning/ adapter methods to adapters is described at https://docs.adapterhub.ml/contributing/adding_adapter_methods.html.
向模型添加Adapters
How to add adapter support to a model type already supported by Hugging Face Transformers is described at https://docs.adapterhub.ml/contributing/adding_adapters_to_a_model.html.
测试你对代码库的更改
adapters 提供了多个Makefile目标,用于轻松运行测试和仓库检查。
请确保这些检查无误通过,以便在您提交拉取请求时能顺利通过CI流水线任务。
要运行仓库中的所有测试:
make test
要在整个代码库中自动格式化代码和导入:
make style
这将运行black和isort。
要运行所有质量检查以确保代码风格和仓库一致性:
make quality
这将运行black、isort和flake8的检查,以及额外的自定义检查。
发布预训练适配器
How to make your own trained adapters accessible for the adapters library HuggingFace Model Hub is described at https://docs.adapterhub.ml/huggingface_hub.html.