readme: ---
  language: zh
  license: creativeml-openrail-m
  
  tags:
  - stable-diffusion
  - stable-diffusion-diffusers
  - text-to-image
  - bilingual
  - en
  - English
  - zh
  - Chinese
  
  inference: false
  extra_gated_prompt: |-
    One more step before getting this model.
    This model is open access and available to all, with a CreativeML OpenRAIL-M license further specifying rights and usage.
    The CreativeML OpenRAIL License specifies: 
  
    1. You can't use the model to deliberately produce nor share illegal or harmful outputs or content 
    2. BAAI claims no rights on the outputs you generate, you are free to use them and are accountable for their use which must not go against the provisions set in the license
    3. You may re-distribute the weights and use the model commercially and/or as a service. If you do, please be aware you have to include the same use restrictions as the ones in the license and share a copy of the CreativeML OpenRAIL-M to all your users (please read the license entirely and carefully)
    Please read the full license here: https://huggingface.co/spaces/CompVis/stable-diffusion-license
    
    By clicking on "Access repository" below, you accept that your *contact information* (email address and username) can be shared with the model authors as well.
  extra_gated_fields:
   I have read the License and agree with its terms: checkbox
  ---
  
  # AltCLIP
  
  |      名称 Name       |  任务 Task   |   语言 Language(s)    | 模型 Model | Github |
  |:------------------:|:----------:|:-------------------:|:--------:|:------:|
  | AltCLIP | text-image representation| 中英文 Chinese&English |   CLIP   |   [FlagAI](https://github.com/FlagAI-Open/FlagAI)   |
  
  ## 简介 Brief Introduction
  
  我们提出了一个简单高效的方法去训练更加优秀的双语CLIP模型。命名为AltCLIP。AltCLIP基于 [Stable Diffusiosn](https://github.com/CompVis/stable-diffusion) 训练，训练数据来自 [WuDao数据集](https://data.baai.ac.cn/details/WuDaoCorporaText) 和 [LIAON](https://huggingface.co/datasets/ChristophSchuhmann/improved_aesthetics_6plus) 
  
  AltCLIP模型可以为本项目中的AltDiffusion模型提供支持，关于AltDiffusion模型的具体信息可查看[此教程](https://github.com/FlagAI-Open/FlagAI/tree/master/examples/AltDiffusion/README.md) 。
  
  模型代码已经在 [FlagAI](https://github.com/FlagAI-Open/FlagAI/tree/master/examples/AltCLIP) 上开源，权重位于我们搭建的 [modelhub](https://model.baai.ac.cn/model-detail/100075) 上。我们还提供了微调，推理，验证的脚本，欢迎试用。
  
  
  We propose a simple and efficient method to train a better bilingual CLIP model. Named AltCLIP. AltCLIP is trained based on [Stable Diffusiosn](https://github.com/CompVis/stable-diffusion) with training data from [WuDao dataset](https://data.baai.ac.cn/details/WuDaoCorporaText) and [Liaon](https://huggingface.co/datasets/laion/laion2B-en).
  
  The AltCLIP model can provide support for the AltDiffusion model in this project. Specific information on the AltDiffusion model can be found in [this tutorial](https://github.com/FlagAI-Open/FlagAI/tree/master/examples/AltDiffusion/README.md).
  
  The model code has been open sourced on [FlagAI](https://github.com/FlagAI-Open/FlagAI/tree/master/examples/AltCLIP) and the weights are located on [modelhub](https://model.baai.ac.cn/model-detail/100075). We also provide scripts for fine-tuning, inference, and validation, so feel free to try them out.
  
  ## 引用
  关于AltCLIP，我们已经推出了相关报告，有更多细节可以查阅，如对您的工作有帮助，欢迎引用。
  
  If you find this work helpful, please consider to cite
  ```
  @article{https://doi.org/10.48550/arxiv.2211.06679,
    doi = {10.48550/ARXIV.2211.06679},
    url = {https://arxiv.org/abs/2211.06679},
    author = {Chen, Zhongzhi and Liu, Guang and Zhang, Bo-Wen and Ye, Fulong and Yang, Qinghong and Wu, Ledell},
    keywords = {Computation and Language (cs.CL), FOS: Computer and information sciences},
    title = {AltCLIP: Altering the Language Encoder in CLIP for Extended Language Capabilities},
    publisher = {arXiv},
    year = {2022},
    copyright = {arXiv.org perpetual, non-exclusive license}
  }
  ```
  
  ## 训练 Training
  
  训练共有两个阶段。
  在平行知识蒸馏阶段，我们只是使用平行语料文本来进行蒸馏（平行语料相对于图文对更容易获取且数量更大）。在双语对比学习阶段，我们使用少量的中-英 图像-文本对（一共约2百万）来训练我们的文本编码器以更好地适应图像编码器。
  
  There are two phases of training.
  In the parallel knowledge distillation phase, we only use parallel corpus texts for distillation (parallel corpus is easier to obtain and larger in number compared to image text pairs). In the bilingual comparison learning phase, we use a small number of Chinese-English image-text pairs (about 2 million in total) to train our text encoder to better fit the image encoder.
  
  
  
  ## 下游效果 Performance
  
  <table>
     <tr>
        <td rowspan=2>Language</td>
        <td rowspan=2>Method</td>
        <td colspan=3>Text-to-Image Retrival</td>
        <td colspan=3>Image-to-Text Retrival</td>
        <td rowspan=2>MR</td>
     </tr>
     <tr>
        <td>R@1</td>
        <td>R@5</td>
        <td>R@10</td>
        <td>R@1</td>
        <td>R@5</td>
        <td>R@10</td>
     </tr>
     <tr>
        <td rowspan=7>English</td>
        <td>CLIP</td>
        <td>65.0 </td>
        <td>87.1 </td>
        <td>92.2 </td>
        <td>85.1 </td>
        <td>97.3 </td>
        <td>99.2 </td>
        <td>87.6 </td>
     </tr>
     <tr>
        <td>Taiyi</td>
        <td>25.3 