Torchdistill (以前是KDKIT )提供了各種最先進的知識蒸餾方法,並使您可以通過編輯聲明性YAML配置文件而不是Python代碼來設計(新)實驗。即使您需要在教師/學生模型中提取中間表示形式,您也無需重新實現模型,而這些模型通常會更改向前的界面,而是指定YAML文件中的模塊路徑。有關更多詳細信息,請參閱這些論文。
除了知識蒸餾外,該框架還可以幫助您設計和執行一般的深度學習實驗(無需編碼),以進行可再現的深度學習研究。即,它使您可以通過將教師條目排除在聲明性的YAML配置文件中,而無需老師培訓模型。您可以在下面和configs/sample/中找到此類示例。
當您在論文中提到Torchdistill時,請引用這些論文而不是此GitHub存儲庫。
如果您將Torchdistill用作工作的一部分,那麼您的引文將受到讚賞,並激勵我維護和升級此框架!
您可以在https://yoshitomo-matsubara.net/torchdistill/上找到利用Torchdistill的API文檔和研究項目
使用ForwardHookManager ,您可以在模型中提取中間表示,而無需修改其正向函數的接口。
本示例筆記本將使您更好地了解使用諸如知識蒸餾和中間表示的分析。
在Torchdistill中,許多組件和Pytorch模塊都是抽象的,例如,模型,數據集,優化器,損失等等!您可以在聲明的PYYAML配置文件中定義它們,以便可以將其視為實驗的摘要,在許多情況下,您將根本不需要編寫Python代碼。查看Configs/中可用的一些配置。您會看到哪些模塊抽象了,以及如何在聲明的PYYAML配置文件中定義它們以設計實驗。
如果您想使用此框架使用自己的模塊(模型,損失功能,數據集等),則可以在本地軟件包torchdistill/中編輯代碼/。
有關更多詳細信息,請參見官方文檔和討論。
ILSVRC 2012(Imagenet)的TOP-1驗證精度
可執行代碼可以在示例/中找到
對於CIFAR-10和CIFAR-100,某些模型將重新實現,並在Torchdistill中作為驗證模型可用。可以在此處找到更多詳細信息。
Hugging Face Model Hub可以使用一些由Torchdistill微調用於膠水任務的變壓器模型。樣品膠基準的結果和詳細信息可以在此處找到。
以下示例在演示中可用。請注意,這些示例適用於Google Colab用戶,並且與Amazon Sagemaker Studio Lab兼容。通常,如果您擁有自己的GPU,則示例/將是更好的參考。
這些示例寫出了測試預測文件,供您查看膠排行榜系統中的測試性能。
如果您在支持Pytorch Hub的Pytorch Hub或GitHub存儲庫上找到模型,則只需編輯聲明性的YAML配置文件即可將它們導入教師/學生模型。
例如,如果您使用huggingface/pytorch-image-models(aka timm )中可用的Resnest-50作為Imagenet數據集的教師模型,則可以通過Pytorch Hub在您的聲明性YAML配置文件中使用以下條目導入該模型。
models :
teacher_model :
key : ' resnest50d '
repo_or_dir : ' huggingface/pytorch-image-models '
kwargs :
num_classes : 1000
pretrained : True pip3 install torchdistill
# or use pipenv
pipenv install torchdistill
git clone https://github.com/yoshitomo-matsubara/torchdistill.git
cd torchdistill/
pip3 install -e .
# or use pipenv
pipenv install "-e ."
如果找到錯誤,請隨時創建問題。
如果您有問題或功能請求,請在此處開始新的討論。請搜索問題和討論,並確保尚未解決您的問題/問題/請求。
歡迎拉動請求。請從問題開始,並與我討論解決方案,而不是從拉動請求開始。
如果您在研究中使用Torchdistill ,請引用以下論文:
[紙] [preprint]
@inproceedings { matsubara2021torchdistill ,
title = { {torchdistill: A Modular, Configuration-Driven Framework for Knowledge Distillation} } ,
author = { Matsubara, Yoshitomo } ,
booktitle = { International Workshop on Reproducible Research in Pattern Recognition } ,
pages = { 24--44 } ,
year = { 2021 } ,
organization = { Springer }
}[Paper] [OpenReview] [Preprint]
@inproceedings { matsubara2023torchdistill ,
title = { {torchdistill Meets Hugging Face Libraries for Reproducible, Coding-Free Deep Learning Studies: A Case Study on NLP} } ,
author = { Matsubara, Yoshitomo } ,
booktitle = { Proceedings of the 3rd Workshop for Natural Language Processing Open Source Software (NLP-OSS 2023) } ,
publisher = { Empirical Methods in Natural Language Processing } ,
pages = { 153--164 } ,
year = { 2023 }
}自2021年11月和2022年6月以來,Travis CI的OSS信貸和Jetbrain的免費許可計劃(開源)已支持該項目。