[{"data":1,"prerenderedAt":306},["ShallowReactive",2],{"content-query-QYTU8a5urt":3},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"date":10,"cover":11,"type":12,"body":13,"_type":300,"_id":301,"_source":302,"_file":303,"_stem":304,"_extension":305},"/technology-blogs/zh/3815","zh",false,"","AltCLIP模型论文解读，并基于MindSpore NLP推理复现","AltCLIP模型通过对OpenAI提出的CLIP模型进行创新","2025-08-19","https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2025/08/22/ce26cce5d14b4523b0d17eb406aa1751.png","technology-blogs",{"type":14,"children":15,"toc":297},"root",[16,24,30,35,40,56,64,69,84,94,99,112,122,127,141,149,154,162,170,175,182,190,195,202,216,234,248,253,258,265,278,292],{"type":17,"tag":18,"props":19,"children":21},"element","h1",{"id":20},"altclip模型论文解读并基于mindspore-nlp推理复现",[22],{"type":23,"value":8},"text",{"type":17,"tag":25,"props":26,"children":27},"p",{},[28],{"type":23,"value":29},"作者：luodan",{"type":17,"tag":25,"props":31,"children":32},{},[33],{"type":23,"value":34},"来源：开源实习",{"type":17,"tag":25,"props":36,"children":37},{},[38],{"type":23,"value":39},"随着多模态人工智能的快速发展，视觉-语言模型成为了推动跨模态任务研究的核心方向，AltCLIP模型通过对OpenAI提出的CLIP模型进行创新，增强其多语言能力，为跨语言和多语言的视觉-语言任务开辟了新的研究思路。",{"type":17,"tag":25,"props":41,"children":42},{},[43,49,51],{"type":17,"tag":44,"props":45,"children":46},"strong",{},[47],{"type":23,"value":48},"# 01",{"type":23,"value":50}," ",{"type":17,"tag":44,"props":52,"children":53},{},[54],{"type":23,"value":55},"模型的创新点：",{"type":17,"tag":25,"props":57,"children":58},{},[59],{"type":17,"tag":44,"props":60,"children":61},{},[62],{"type":23,"value":63},"1、引入多语言文本编码器",{"type":17,"tag":25,"props":65,"children":66},{},[67],{"type":23,"value":68},"AltCLIP提出了通过替换 CLIP 的文本编码器以扩展语言能力的思路。具体来说，它将 CLIP 原本的英文文本编码器替换为预训练的多语言文本编码器 XLM-R，并通过两阶段训练方法实现了语言与图像表示的对齐：",{"type":17,"tag":70,"props":71,"children":72},"ul",{},[73,79],{"type":17,"tag":74,"props":75,"children":76},"li",{},[77],{"type":23,"value":78},"**第一阶段--教师学习（Teacher Learning）：**使用CLIP的英文文本编码器作为教师模型，通过知识蒸馏技术训练XLM-R，以学习文本表示的图像对齐能力；其训练目标是最小化教师和学术文本编码器在平行文本对上的嵌入误差。",{"type":17,"tag":74,"props":80,"children":81},{},[82],{"type":23,"value":83},"**第二阶段--对比学习（Contrastive Learning）：**在教师学习的基础上，使用中英文文本-图像对，通过对比学习进一步优化模型，提升文本-图像对齐能力；这一阶段中图像编码器使用CLIP中的Vision Transformer,并被冻结参数，仅优化学生文本编码器的参数。",{"type":17,"tag":25,"props":85,"children":86},{},[87,89],{"type":23,"value":88},"**2、**",{"type":17,"tag":44,"props":90,"children":91},{},[92],{"type":23,"value":93},"高效的数据利用",{"type":17,"tag":25,"props":95,"children":96},{},[97],{"type":23,"value":98},"AltCLIP 的训练相比传统的 CLIP 变体显著减少了对大规模数据的依赖：",{"type":17,"tag":70,"props":100,"children":101},{},[102,107],{"type":17,"tag":74,"props":103,"children":104},{},[105],{"type":23,"value":106},"使用了 36M 的平行文本数据（相比原始 CLIP 的 400M 文本-图像对大幅减少）。",{"type":17,"tag":74,"props":108,"children":109},{},[110],{"type":23,"value":111},"对比学习阶段仅使用了 2M 中英文文本-图像对。",{"type":17,"tag":25,"props":113,"children":114},{},[115,117],{"type":23,"value":116},"**3、**",{"type":17,"tag":44,"props":118,"children":119},{},[120],{"type":23,"value":121},"多语言扩展能力",{"type":17,"tag":25,"props":123,"children":124},{},[125],{"type":23,"value":126},"该模型进一步扩展 AltCLIP 至支持 9 种语言（AltCLIPM9），包括英语、中文、法语、西班牙语、俄语、日语、韩语等。通过加入多语言的平行翻译数据集，验证了该方法在多语言环境中的适应能力。",{"type":17,"tag":25,"props":128,"children":129},{},[130,135,136],{"type":17,"tag":44,"props":131,"children":132},{},[133],{"type":23,"value":134},"# 02",{"type":23,"value":50},{"type":17,"tag":44,"props":137,"children":138},{},[139],{"type":23,"value":140},"数据集上的评价指标得分",{"type":17,"tag":25,"props":142,"children":143},{},[144],{"type":17,"tag":44,"props":145,"children":146},{},[147],{"type":23,"value":148},"1、图像分类任务",{"type":17,"tag":25,"props":150,"children":151},{},[152],{"type":23,"value":153},"论文在 ImageNet 及其变体（ImageNet-A、ImageNet-R、ImageNet-V2 等）数据集上对 AltCLIP 进行了评估。与基线模型（如 CLIP 和 CN-CLIP）相比，AltCLIP 在中文任务上实现了显著提升，同时在英文任务中表现接近原始 CLIP。",{"type":17,"tag":25,"props":155,"children":156},{},[157],{"type":17,"tag":158,"props":159,"children":161},"img",{"alt":7,"src":160},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2025/08/22/d9030c90f4cf421fa24e8fa0bcff0407.png",[],{"type":17,"tag":25,"props":163,"children":164},{},[165],{"type":17,"tag":44,"props":166,"children":167},{},[168],{"type":23,"value":169},"2、跨模态检索任务",{"type":17,"tag":25,"props":171,"children":172},{},[173],{"type":23,"value":174},"从实验结果可以看出，AltCLIP 显著提升了模型在中文任务上的性能，无论是 Flickr30k-CN 还是 MSCOCO-CN，AltCLIP 都在 R@1、R@5 和 MR 等指标上领先于其他基线模型，表现非常稳定。",{"type":17,"tag":25,"props":176,"children":177},{},[178],{"type":17,"tag":158,"props":179,"children":181},{"alt":7,"src":180},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2025/08/22/9f7609415c93498b86805a38747f9341.png",[],{"type":17,"tag":25,"props":183,"children":184},{},[185],{"type":17,"tag":44,"props":186,"children":187},{},[188],{"type":23,"value":189},"3、多语言检索任务",{"type":17,"tag":25,"props":191,"children":192},{},[193],{"type":23,"value":194},"在 XTD 数据集上，AltCLIPM9 支持 9 种语言（包括英语、中文、西班牙语、法语、韩语、俄语等），在所有语言的 Recall@10 指标上基本优于其他基线模型（如 M-CLIP 和 mUSE 系列）。",{"type":17,"tag":25,"props":196,"children":197},{},[198],{"type":17,"tag":158,"props":199,"children":201},{"alt":7,"src":200},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2025/08/22/0bde5921e3d34aa19824493385d4d7fa.png",[],{"type":17,"tag":25,"props":203,"children":204},{},[205,210,211],{"type":17,"tag":44,"props":206,"children":207},{},[208],{"type":23,"value":209},"# 03",{"type":23,"value":50},{"type":17,"tag":44,"props":212,"children":213},{},[214],{"type":23,"value":215},"创新点相比于其他工作的优势",{"type":17,"tag":70,"props":217,"children":218},{},[219,224,229],{"type":17,"tag":74,"props":220,"children":221},{},[222],{"type":23,"value":223},"**模型架构灵活，语言扩展性强：**AltCLIP 的核心思路是替换文本编码器，并保持 CLIP 的图像编码器不变。这种架构设计不仅简单，还具有极强的扩展性，同时还能推广至多语言任务。",{"type":17,"tag":74,"props":225,"children":226},{},[227],{"type":23,"value":228},"**数据需求显著降低：**与现有跨语言 CLIP 模型（如 CN-CLIP、Taiyi）需要大规模数据（超过 100M 文本-图像对）不同，AltCLIP 使用了少量高质量的平行文本和文本-图像对，从而显著降低了训练成本。",{"type":17,"tag":74,"props":230,"children":231},{},[232],{"type":23,"value":233},"**多任务表现均衡：**AltCLIP 不仅在跨模态检索任 务中表现优异，还在大规模零样本分类任务（ImageNet 等）中展现了强大的泛化能力。",{"type":17,"tag":25,"props":235,"children":236},{},[237,242,243],{"type":17,"tag":44,"props":238,"children":239},{},[240],{"type":23,"value":241},"# 04",{"type":23,"value":50},{"type":17,"tag":44,"props":244,"children":245},{},[246],{"type":23,"value":247},"使用MindSpore NLP对数据集进行推理",{"type":17,"tag":25,"props":249,"children":250},{},[251],{"type":23,"value":252},"为了验证AltCLIP模型的效果，我们使用了MindSpore NLP来进行推理验证。MindSpore NLP是基于MindSpore的一个自然语言处理开源库，它提供了大量的数据集、模型和工具，旨在降低进行NLP领域的门槛，加速研究和开发过程。",{"type":17,"tag":25,"props":254,"children":255},{},[256],{"type":23,"value":257},"我们分别使用了MindSpore NLP和transformer两个框架来加载模型，并使用COCO2014数据集进行模型评估，由于资源限制，我们只选择了coco2014数据集中的3000张图片进行测试，因此最终结果可能与论文结果有差距，但是在实际实验中可以看出MindSpore和transformer的结果相等。",{"type":17,"tag":25,"props":259,"children":260},{},[261],{"type":17,"tag":158,"props":262,"children":264},{"alt":7,"src":263},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2025/08/22/35c7b07910e64befad0ea055abb51253.png",[],{"type":17,"tag":25,"props":266,"children":267},{},[268,270],{"type":23,"value":269},"MindSpore NLP作为一款新兴的开源工具库，具有极大的潜力和广阔的发展前景。大家也可以在今后的研究和学习中尝试使用MindSpore NLP，我相信未来它会取得更加出色的表现，并且更简单上手。完整的代码已上传至github，链接如下：",{"type":17,"tag":271,"props":272,"children":276},"a",{"href":273,"rel":274},"https://github.com/luoluo0042/MindNLP-AltCLIP/tree/master",[275],"nofollow",[277],{"type":23,"value":273},{"type":17,"tag":25,"props":279,"children":280},{},[281,286,287],{"type":17,"tag":44,"props":282,"children":283},{},[284],{"type":23,"value":285},"# 05",{"type":23,"value":50},{"type":17,"tag":44,"props":288,"children":289},{},[290],{"type":23,"value":291},"总结",{"type":17,"tag":25,"props":293,"children":294},{},[295],{"type":23,"value":296},"AltCLIP 的提出展示了通过替换文本编码器扩展 CLIP 模型语言能力的巨大潜力。其两阶段训练策略不仅简单高效，还显著降低了数据需求，体现了极高的研究与应用价值。AltCLIP 在多语言跨模态表示学习中的出色表现，为未来的多模态、多语言 AI 模型研究提供了宝贵的思路。",{"title":7,"searchDepth":298,"depth":298,"links":299},4,[],"markdown","content:technology-blogs:zh:3815.md","content","technology-blogs/zh/3815.md","technology-blogs/zh/3815","md",1776506135681]