Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add pai-dsw gallery notebook and warning about modelscope version #209

Merged
merged 5 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion cn_clip/training/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,16 @@ def main():
}
assert args.teacher_model_name in teacher_model_dict, "Error: Valid teacher model name has not been built."

teacher_model = Model.from_pretrained(args.teacher_model_name)
try:
teacher_model = Model.from_pretrained(args.teacher_model_name)
except Exception as e:
if "Unexpected key(s) in state_dict" in str(e):
error_message = (
"An error occurred while loading the model: {}\n"
"Maybe you should update modelscope. ".format(e)
)
raise RuntimeError(error_message)

for k, v in teacher_model.state_dict().items():
v.requires_grad = False

Expand Down
4 changes: 2 additions & 2 deletions distillation.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,5 @@
</p>


## Future Action
将会在阿里云官网上线相关的解决方案的Jupyter Notebook,提供更加清晰的实例教学,敬请期待
## 快速体验
相关解决方案已经上线阿里云[PAI-DSW Gallery](https://gallery.pai-ml.com/#/preview/deepLearning/cv/cn_clip_distillation)。在PAI-DSW Gallery提供对应的Notebook,支持用户利用自有数据构建专属搜索模型
6 changes: 3 additions & 3 deletions distillation_En.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ Here we provide an example of knowledge distillation for Chinese-CLIP fine-tunin
+ Nvidia GPUs **with Turning, Ampere, Ada or Hopper architecture** (such as H100, A100, RTX 3090, T4, and RTX 2080). Please refer to [this document](https://en.wikipedia.org/wiki/CUDA#GPUs_supported) for the corresponding GPUs of each Nvidia architecture.
+ CUDA 11.4 and above.
+ PyTorch 1.12 and above.
+ **ModelScope**:Install FlashAttention by executing `pip install modelscope`.
+ Other dependencies as required in [requirements.txt](requirements.txt).
+ **ModelScope**:Install FlashAttention by executing `pip install modelscope`.

## Use it in Chinese-CLIP!
It is not complicated to apply knowledge distillation to the image side in Chinese-CLIP finetune. Just add the `--distllation` configuration item to the sh script of finetune.
Expand Down Expand Up @@ -56,5 +56,5 @@ Advantages of our approach:
<img src="examples/image_retrieval_result2.jpg" width="400" /><br>
</p>

## Future Action
The Jupyter Notebook of related solutions will be launched on the Alibaba Cloud official website, which will provide a more clear example for usage. Stay tuned for this!
## Quick Start
Related solutions have been launched on Alibaba Cloud [PAI-DSW Gallery](https://gallery.pai-ml.com/#/preview/deepLearning/cv/cn_clip_distillation). The corresponding Notebook is provided in PAI-DSW Gallery to support users to build exclusive search models using their own data.