|
| 1 | +<div align="center"> |
| 2 | + |
| 3 | +## [NeurIPS 2023] Res-Tuning: A Flexible and Efficient Tuning Paradigm via Unbinding Tuner from Backbone |
| 4 | + |
| 5 | +### [arXiv](https://arxiv.org/abs/2310.19859) | [Project Page](https://res-tuning.github.io/) |
| 6 | + |
| 7 | +</div> |
| 8 | + |
| 9 | +Res-Tuning is a flexible and efficient tuning paradigm. We manage to free the design of tuners from the network architecture, facilitating flexible combination of various tuning strategies and further extend a memory-efficient bypass variant, which significantly reduces the memory consumption and multi-task inference cost. |
| 10 | + |
| 11 | +The implementation is a pluggable tuner component for [SWIFT](https://github.com/modelscope/swift), designed to be user-friendly. |
| 12 | + |
| 13 | +### Catalog |
| 14 | + |
| 15 | +- [x] Res-Adapter |
| 16 | +- [x] Res-Tuning-Bypass |
| 17 | +- [ ] Res-Prefix |
| 18 | +- [ ] Res-Prompt |
| 19 | + |
| 20 | +### Usage |
| 21 | + |
| 22 | +#### Demo |
| 23 | +- Run our interactive demo using [vision_example](https://github.com/modelscope/swift/blob/main/examples/pytorch/cv/notebook/swift_vision.ipynb). |
| 24 | + |
| 25 | +#### Init Tuner |
| 26 | + |
| 27 | +```Python |
| 28 | +from swift import ResTuningConfig |
| 29 | +config = ResTuningConfig( |
| 30 | + dims=768, |
| 31 | + root_modules=r'.*blocks.0$', |
| 32 | + stem_modules=r'.*blocks\.\d+$', |
| 33 | + target_modules=r'norm', |
| 34 | + tuner_cfg='res_adapter' |
| 35 | +) |
| 36 | +``` |
| 37 | +- dims: The dimensions of the hidden states. |
| 38 | +- root_modules: The root module to be replaced. |
| 39 | +- stem_modules: The stem modules to be replaced. |
| 40 | +- target_modules: The target module to be replaced. |
| 41 | +- tuner_cfg: The configuration of the tuning module. |
| 42 | + |
| 43 | +#### Load Model |
| 44 | + |
| 45 | +```Python |
| 46 | +from swift import Swift |
| 47 | +import timm, torch |
| 48 | +model = timm.create_model("vit_base_patch16_224", pretrained=False, num_classes=100) |
| 49 | +model_tune = Swift.prepare_model(model, config) |
| 50 | +print(model_tune.get_trainable_parameters()) |
| 51 | +print(model(torch.ones(1, 3, 224, 224)).shape) |
| 52 | +``` |
| 53 | + |
| 54 | + |
| 55 | +### Citation |
| 56 | +``` |
| 57 | +@inproceedings{jiang2023restuning, |
| 58 | + title={Res-Tuning: A Flexible and Efficient Tuning Paradigm via Unbinding Tuner from Backbone}, |
| 59 | + author={Jiang, Zeyinzi and Mao, Chaojie and Huang, Ziyuan and Ma, Ao and Lv, Yiliang and Shen, Yujun and Zhao, Deli and Zhou, Jingren}, |
| 60 | + booktitle={Advances in Neural Information Processing Systems}, |
| 61 | + year={2023} |
| 62 | +} |
| 63 | +``` |
0 commit comments