Skip to content

Commit

Permalink
Merge pull request #209 from Jaskr616/master
Browse files Browse the repository at this point in the history
add pai-dsw gallery notebook and warning about modelscope version
  • Loading branch information
yangapku authored Sep 20, 2023
2 parents d43bd51 + a39d52b commit d1ed017
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
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.

0 comments on commit d1ed017

Please sign in to comment.