{"id":78051,"date":"2026-02-26T02:57:40","date_gmt":"2026-02-25T18:57:40","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/78051.html"},"modified":"2026-02-26T02:57:40","modified_gmt":"2026-02-25T18:57:40","slug":"%e5%a4%9a%e6%a8%a1%e6%80%81-clip","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/78051.html","title":{"rendered":"\u591a\u6a21\u6001\u2014\u2014\u2014\u2014CLIP"},"content":{"rendered":"<h4>\u4e00\u3001CLIP\u6838\u5fc3\u6982\u5ff5<\/h4>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0CLIP&#xff08;Contrastive Language-Image Pre-training&#xff09;\u662f OpenAI \u63d0\u51fa\u7684\u5bf9\u6bd4\u5b66\u4e60\u6a21\u578b&#xff0c;\u6838\u5fc3\u662f\u8de8\u6a21\u6001\u5bf9\u6bd4\u9884\u8bad\u7ec3&#xff0c;\u76ee\u6807\u662f\u8ba9\u6a21\u578b\u540c\u65f6\u7406\u89e3\u56fe\u50cf\u548c\u6587\u672c\u7684\u8bed\u4e49\u5173\u8054&#xff0c;\u5b9e\u73b0 \u201c\u56fe\u6587\u4e92\u641c\u201d\u201c\u96f6\u6837\u672c\u5206\u7c7b\u201d \u7b49\u80fd\u529b\u3002<\/p>\n<ul>\n<li>\u6838\u5fc3\u601d\u60f3&#xff1a;\u5c06\u56fe\u50cf\u548c\u6587\u672c\u5206\u522b\u7f16\u7801\u4e3a\u5411\u91cf&#xff0c;\u901a\u8fc7\u5bf9\u6bd4\u5b66\u4e60\u8ba9 \u201c\u5339\u914d\u7684\u56fe\u6587\u5bf9\u201d \u5411\u91cf\u8ddd\u79bb\u8fd1&#xff0c;\u201c\u4e0d\u5339\u914d\u7684\u56fe\u6587\u5bf9\u201d \u5411\u91cf\u8ddd\u79bb\u8fdc\u3002<\/li>\n<li>\u5173\u952e\u7ec4\u4ef6&#xff1a;\n<ul>\n<li>\u56fe\u50cf\u7f16\u7801\u5668&#xff1a;\u5982 ViT&#xff08;Vision Transformer&#xff09;&#xff0c;\u5c06\u56fe\u50cf\u8f6c\u4e3a\u56fa\u5b9a\u7ef4\u5ea6\u7684\u5411\u91cf&#xff1b;<\/li>\n<li>\u6587\u672c\u7f16\u7801\u5668&#xff1a;\u5982 Transformer&#xff0c;\u5c06\u6587\u672c\u8f6c\u4e3a\u56fa\u5b9a\u7ef4\u5ea6\u7684\u5411\u91cf&#xff1b;<\/li>\n<li>\u5bf9\u6bd4\u635f\u5931\u51fd\u6570&#xff1a;\u901a\u8fc7\u8ba1\u7b97\u56fe\u6587\u5411\u91cf\u7684\u76f8\u4f3c\u5ea6&#xff0c;\u6700\u5927\u5316\u6b63\u6837\u672c\u5bf9\u76f8\u4f3c\u5ea6\u3001\u6700\u5c0f\u5316\u8d1f\u6837\u672c\u5bf9\u76f8\u4f3c\u5ea6\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h4>\u4e8c\u3001CLIP\u6570\u5b66\u516c\u5f0f<\/h4>\n<h6>&#xff08;1&#xff09;\u56fe\u6587\u7f16\u7801<\/h6>\n<p>\u8bbe\u6279\u91cf\u4e2d\u6709 N \u4e2a\u56fe\u6587\u5bf9&#xff0c;\u56fe\u50cf\u7f16\u7801\u5668\u4e3a I(\u22c5)&#xff0c;\u6587\u672c\u7f16\u7801\u5668\u4e3a T(\u22c5)&#xff1a;<\/p>\n<ul>\n<li>\u56fe\u50cf\u5411\u91cf&#xff1a;<img decoding=\"async\" alt=\"i_{k}&#061; I\\\\left ( image_{k} \\\\right )\\\\epsilon R ^{D}\" class=\"mathcode\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260225185738-699f4622c4554.png\" \/>&#xff0c;&#xff08;D \u4e3a\u5411\u91cf\u7ef4\u5ea6&#xff0c;\u5982 512&#xff09;<\/li>\n<li>\u6587\u672c\u5411\u91cf&#xff1a;<img decoding=\"async\" alt=\"t_{k}&#061; T\\\\left ( text_{k} \\\\right )\\\\epsilon R ^{D}\" class=\"mathcode\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260225185738-699f4622d47b8.png\" \/><\/li>\n<\/ul>\n<h6>&#xff08;2&#xff09;\u5411\u91cf\u5f52\u4e00\u5316<\/h6>\n<p>\u4e3a\u4e86\u8ba9\u76f8\u4f3c\u5ea6\u4ec5\u7531\u89d2\u5ea6\u51b3\u5b9a&#xff0c;\u9700\u5bf9\u5411\u91cf\u505a L2 \u5f52\u4e00\u5316&#xff1a;<\/p>\n<p><img decoding=\"async\" alt=\"i_{k}&#061;\\\\frac{i_{k}}{\\\\left \\\\| i_{k} \\\\right \\\\|_{2}},t_{k}&#061;\\\\frac{t_{k}}{\\\\left \\\\| t_{k} \\\\right \\\\|_{2}}\" class=\"mathcode\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260225185738-699f4622e69db.png\" \/><\/p>\n<h6>&#xff08;3&#xff09;\u76f8\u4f3c\u5ea6\u77e9\u9635<\/h6>\n<p>\u8ba1\u7b97\u6240\u6709\u56fe\u50cf\u4e0e\u6587\u672c\u7684\u4f59\u5f26\u76f8\u4f3c\u5ea6&#xff0c;\u5f97\u5230 N\u00d7N \u7684\u76f8\u4f3c\u5ea6\u77e9\u9635 S&#xff1a;<\/p>\n<p><img decoding=\"async\" alt=\"S_{ij}&#061;i_{i}.t_{j}^{T}&#061;\\\\sum_{d&#061;1}^{D}i_{i}\\\\cdot t_{j},d\" class=\"mathcode\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260225185739-699f4623013bf.png\" \/><\/p>\n<h6>&#xff08;4&#xff09;\u5bf9\u6bd4\u635f\u5931&#xff08;InfoNCE&#xff09;<\/h6>\n<p>CLIP \u7684\u635f\u5931\u5206\u4e3a \u201c\u56fe\u50cf\u5230\u6587\u672c\u201d \u548c \u201c\u6587\u672c\u5230\u56fe\u50cf\u201d \u4e24\u90e8\u5206&#xff0c;\u603b\u635f\u5931\u4e3a\u4e24\u8005\u5e73\u5747\u3002<\/p>\n<ul>\n<li>\u7b2c\u4e00\u90e8\u5206&#xff1a;\u4ee5\u56fe\u50cf\u4e3a\u951a\u70b9&#xff0c;\u8ba1\u7b97\u6587\u672c\u7684\u4ea4\u53c9\u71b5\u635f\u5931&#xff1b;<\/li>\n<li>\u7b2c\u4e8c\u90e8\u5206&#xff1a;\u4ee5\u6587\u672c\u4e3a\u951a\u70b9&#xff0c;\u8ba1\u7b97\u56fe\u50cf\u7684\u4ea4\u53c9\u71b5\u635f\u5931\u3002<\/li>\n<\/ul>\n<h4>\u4e09\u3001CLIP\u5b9e\u4f8b\u4ee3\u7801\u89e3\u8bfb<\/h4>\n<h5>\u6a21\u5757\u4e00&#xff1a;\u5bfc\u5165\u6838\u5fc3\u5e93<\/h5>\n<p># \u5bfc\u5165PyTorch\u6838\u5fc3\u5e93&#xff0c;\u7528\u4e8e\u6784\u5efa\u795e\u7ecf\u7f51\u7edc<br \/>\nimport torch<br \/>\n# \u5bfc\u5165PyTorch\u7684\u795e\u7ecf\u7f51\u7edc\u6a21\u5757&#xff0c;\u7528\u4e8e\u5b9a\u4e49\u5c42\u548c\u6a21\u578b<br \/>\nimport torch.nn as nn<br \/>\n# \u5bfc\u5165PyTorch\u7684\u51fd\u6570\u6a21\u5757&#xff0c;\u5305\u542b\u6fc0\u6d3b\u51fd\u6570\u3001\u5f52\u4e00\u5316\u7b49\u5e38\u7528\u51fd\u6570<br \/>\nimport torch.nn.functional as F<br \/>\n# \u4ecetorchvision\u5bfc\u5165\u9884\u8bad\u7ec3\u56fe\u50cf\u6a21\u578b&#xff08;\u8fd9\u91cc\u7528ViT&#xff09;<br \/>\nfrom torchvision import models<br \/>\n# \u4ecetransformers\u5e93\u5bfc\u5165BERT\u7684tokenizer\u548c\u6a21\u578b&#xff0c;\u7528\u4e8e\u6587\u672c\u7f16\u7801<br \/>\nfrom transformers import AutoTokenizer, AutoModel<\/p>\n<h5>\u6a21\u5757\u4e8c&#xff1a;\u8d85\u53c2\u6570\u5b9a\u4e49<\/h5>\n<p># \u6279\u91cf\u5927\u5c0f&#xff08;N&#061;4&#xff09;&#xff0c;\u5373\u6bcf\u6b21\u8bad\u7ec34\u7ec4\u56fe\u6587\u5bf9<br \/>\nBATCH_SIZE &#061; 4<br \/>\n# \u56fe\u6587\u7f16\u7801\u540e\u7684\u5411\u91cf\u7ef4\u5ea6&#xff08;D&#061;512&#xff09;&#xff0c;\u7edf\u4e00\u56fe\u50cf\u548c\u6587\u672c\u7684\u8f93\u51fa\u7ef4\u5ea6<br \/>\nEMBED_DIM &#061; 512<br \/>\n# \u6e29\u5ea6\u7cfb\u6570\u03c4&#xff08;CLIP\u9ed8\u8ba40.07&#xff09;&#xff0c;\u7528\u4e8e\u7f29\u653e\u76f8\u4f3c\u5ea6&#xff0c;\u8c03\u8282\u635f\u5931\u5206\u5e03<br \/>\nTEMPERATURE &#061; 0.07<br \/>\n# \u8bbe\u5907\u9009\u62e9&#xff1a;\u4f18\u5148\u4f7f\u7528GPU&#xff08;cuda&#xff09;&#xff0c;\u65e0GPU\u5219\u7528CPU<br \/>\nDEVICE &#061; &#034;cuda&#034; if torch.cuda.is_available() else &#034;cpu&#034;<\/p>\n<h5>\u6a21\u5757\u4e09&#xff1a;\u56fe\u50cf\u7f16\u7801\u5668<\/h5>\n<p># \u5b9a\u4e49\u56fe\u50cf\u7f16\u7801\u5668\u7c7b&#xff0c;\u7ee7\u627f\u81eann.Module&#xff08;PyTorch\u6240\u6709\u6a21\u578b\u7684\u57fa\u7c7b&#xff09;<br \/>\nclass ImageEncoder(nn.Module):<br \/>\n    # \u521d\u59cb\u5316\u51fd\u6570&#xff0c;\u63a5\u6536\u5d4c\u5165\u7ef4\u5ea6\u53c2\u6570&#xff08;\u9ed8\u8ba4512&#xff09;<br \/>\n    def __init__(self, embed_dim&#061;EMBED_DIM):<br \/>\n        # \u8c03\u7528\u7236\u7c7bnn.Module\u7684\u521d\u59cb\u5316\u51fd\u6570&#xff0c;\u5fc5\u987b\u6267\u884c<br \/>\n        super().__init__()<br \/>\n        # \u52a0\u8f7d\u9884\u8bad\u7ec3\u7684ViT-B\/32\u6a21\u578b&#xff08;Vision Transformer&#xff09;&#xff0c;pretrained&#061;True\u8868\u793a\u52a0\u8f7d\u9884\u8bad\u7ec3\u6743\u91cd<br \/>\n        self.vit &#061; models.vit_b_32(pretrained&#061;True)<br \/>\n        # \u5b9a\u4e49\u6295\u5f71\u5c42&#xff1a;\u5c06ViT\u8f93\u51fa\u7684768\u7ef4\u7279\u5f81\u6620\u5c04\u5230\u6307\u5b9a\u7684512\u7ef4<br \/>\n        # self.vit.hidden_dim\u662fViT\u7684\u9ed8\u8ba4\u8f93\u51fa\u7ef4\u5ea6&#xff08;768&#xff09;&#xff0c;embed_dim\u662f\u76ee\u6807\u7ef4\u5ea6&#xff08;512&#xff09;<br \/>\n        self.projection &#061; nn.Linear(self.vit.hidden_dim, embed_dim)<\/p>\n<p>    # \u524d\u5411\u4f20\u64ad\u51fd\u6570&#xff1a;\u8f93\u5165\u56fe\u50cf&#xff0c;\u8f93\u51fa\u5f52\u4e00\u5316\u7684512\u7ef4\u56fe\u50cf\u5411\u91cf<br \/>\n    def forward(self, images):<br \/>\n        # 1. ViT\u7279\u5f81\u63d0\u53d6&#xff1a;\u8c03\u7528forward_features\u8df3\u8fc7\u5206\u7c7b\u5934&#xff0c;\u4ec5\u63d0\u53d6\u7279\u5f81<br \/>\n        # \u8f93\u5165&#xff1a;(batch_size, 3, 224, 224)&#xff0c;\u8f93\u51fa&#xff1a;(batch_size, 768)<br \/>\n        x &#061; self.vit.forward_features(images)<br \/>\n        # 2. \u6295\u5f71\u5230\u76ee\u6807\u7ef4\u5ea6&#xff1a;\u5c06768\u7ef4\u7279\u5f81\u8f6c\u4e3a512\u7ef4<br \/>\n        # \u8f93\u51fa&#xff1a;(batch_size, 512)<br \/>\n        x &#061; self.projection(x)<br \/>\n        # 3. L2\u5f52\u4e00\u5316&#xff1a;p&#061;2\u8868\u793aL2\u8303\u6570&#xff0c;dim&#061;-1\u8868\u793a\u5bf9\u6700\u540e\u4e00\u7ef4&#xff08;512\u7ef4&#xff09;\u5f52\u4e00\u5316<br \/>\n        # \u5f52\u4e00\u5316\u540e\u5411\u91cf\u6a21\u957f\u4e3a1&#xff0c;\u786e\u4fdd\u76f8\u4f3c\u5ea6\u4ec5\u7531\u89d2\u5ea6\u51b3\u5b9a<br \/>\n        x &#061; F.normalize(x, p&#061;2, dim&#061;-1)<br \/>\n        # \u8fd4\u56de\u5f52\u4e00\u5316\u540e\u7684\u56fe\u50cf\u5411\u91cf<br \/>\n        return x<\/p>\n<h5>\u6a21\u5757\u56db&#xff1a;\u6587\u672c\u7f16\u7801\u5668<\/h5>\n<p># \u5b9a\u4e49\u6587\u672c\u7f16\u7801\u5668\u7c7b&#xff0c;\u7ee7\u627f\u81eann.Module<br \/>\nclass TextEncoder(nn.Module):<br \/>\n    # \u521d\u59cb\u5316\u51fd\u6570&#xff0c;\u63a5\u6536\u5d4c\u5165\u7ef4\u5ea6\u53c2\u6570&#xff08;\u9ed8\u8ba4512&#xff09;<br \/>\n    def __init__(self, embed_dim&#061;EMBED_DIM):<br \/>\n        # \u8c03\u7528\u7236\u7c7b\u521d\u59cb\u5316\u51fd\u6570<br \/>\n        super().__init__()<br \/>\n        # \u52a0\u8f7d\u9884\u8bad\u7ec3\u7684bert-base-chinese\u6a21\u578b&#xff08;\u4e2d\u6587BERT&#xff09;&#xff0c;\u7528\u4e8e\u6587\u672c\u7279\u5f81\u63d0\u53d6<br \/>\n        self.bert &#061; AutoModel.from_pretrained(&#034;bert-base-chinese&#034;)<br \/>\n        # \u52a0\u8f7d\u5bf9\u5e94\u7684tokenizer&#xff0c;\u7528\u4e8e\u5c06\u6587\u672c\u8f6c\u4e3a\u6a21\u578b\u53ef\u8bc6\u522b\u7684token<br \/>\n        self.tokenizer &#061; AutoTokenizer.from_pretrained(&#034;bert-base-chinese&#034;)<br \/>\n        # \u5b9a\u4e49\u6295\u5f71\u5c42&#xff1a;\u5c06BERT\u8f93\u51fa\u7684768\u7ef4\u7279\u5f81\u6620\u5c04\u5230512\u7ef4<br \/>\n        # self.bert.config.hidden_size\u662fBERT\u7684\u9ed8\u8ba4\u9690\u85cf\u5c42\u7ef4\u5ea6&#xff08;768&#xff09;<br \/>\n        self.projection &#061; nn.Linear(self.bert.config.hidden_size, embed_dim)<\/p>\n<p>    # \u524d\u5411\u4f20\u64ad\u51fd\u6570&#xff1a;\u8f93\u5165\u6587\u672c\u5217\u8868&#xff0c;\u8f93\u51fa\u5f52\u4e00\u5316\u7684512\u7ef4\u6587\u672c\u5411\u91cf<br \/>\n    def forward(self, texts):<br \/>\n        # 1. \u6587\u672ctoken\u5316\u5904\u7406<br \/>\n        # texts&#xff1a;\u8f93\u5165\u7684\u6587\u672c\u5217\u8868&#xff08;\u5982[&#034;\u4e00\u53ea\u732b&#034;, &#034;\u4e00\u4e2a\u82f9\u679c&#034;]&#xff09;<br \/>\n        # return_tensors&#061;&#034;pt&#034;&#xff1a;\u8fd4\u56dePyTorch\u5f20\u91cf<br \/>\n        # padding&#061;True&#xff1a;\u81ea\u52a8\u8865\u5168\u5230\u540c\u4e00\u957f\u5ea6<br \/>\n        # truncation&#061;True&#xff1a;\u8d85\u8fc7max_length\u65f6\u622a\u65ad<br \/>\n        # max_length&#061;32&#xff1a;\u6587\u672c\u6700\u5927\u957f\u5ea6\u4e3a32<br \/>\n        # .to(DEVICE)&#xff1a;\u5c06\u5f20\u91cf\u79fb\u5230\u6307\u5b9a\u8bbe\u5907&#xff08;GPU\/CPU&#xff09;<br \/>\n        inputs &#061; self.tokenizer(<br \/>\n            texts,<br \/>\n            return_tensors&#061;&#034;pt&#034;,<br \/>\n            padding&#061;True,<br \/>\n            truncation&#061;True,<br \/>\n            max_length&#061;32<br \/>\n        ).to(DEVICE)<\/p>\n<p>        # 2. BERT\u7f16\u7801&#xff1a;\u8f93\u5165token\u5316\u540e\u7684\u5f20\u91cf&#xff0c;\u8f93\u51fa\u5305\u542b\u9690\u85cf\u5c42\u7684\u7ed3\u679c<br \/>\n        outputs &#061; self.bert(**inputs)<br \/>\n        # \u53d6\u6700\u540e\u4e00\u5c42\u9690\u85cf\u72b6\u6001\u7684\u7b2c0\u4e2atoken&#xff08;[CLS] token&#xff09;&#xff0c;\u4ee3\u8868\u6574\u53e5\u8bed\u4e49<br \/>\n        # outputs.last_hidden_state.shape&#xff1a;(batch_size, seq_len, 768)<br \/>\n        # \u53d6[:, 0, :]\u540eshape&#xff1a;(batch_size, 768)<br \/>\n        x &#061; outputs.last_hidden_state[:, 0, :]<\/p>\n<p>        # 3. \u6295\u5f71\u5230\u76ee\u6807\u7ef4\u5ea6&#xff1a;\u5c06768\u7ef4\u7279\u5f81\u8f6c\u4e3a512\u7ef4<br \/>\n        # \u8f93\u51fa&#xff1a;(batch_size, 512)<br \/>\n        x &#061; self.projection(x)<\/p>\n<p>        # 4. L2\u5f52\u4e00\u5316&#xff1a;\u548c\u56fe\u50cf\u5411\u91cf\u4e00\u6837&#xff0c;\u786e\u4fdd\u6a21\u957f\u4e3a1<br \/>\n        x &#061; F.normalize(x, p&#061;2, dim&#061;-1)<\/p>\n<p>        # \u8fd4\u56de\u5f52\u4e00\u5316\u540e\u7684\u6587\u672c\u5411\u91cf<br \/>\n        return x<\/p>\n<h5>\u6a21\u5757\u4e94&#xff1a;CLIP\u5bf9\u6bd4\u635f\u5931\u51fd\u6570<\/h5>\n<p># \u5b9a\u4e49CLIP\u635f\u5931\u51fd\u6570&#xff1a;\u8f93\u5165\u56fe\u50cf\u5411\u91cf\u3001\u6587\u672c\u5411\u91cf\u3001\u6e29\u5ea6\u7cfb\u6570&#xff0c;\u8f93\u51fa\u603b\u635f\u5931<br \/>\ndef clip_loss(image_embeds, text_embeds, temperature&#061;TEMPERATURE):<br \/>\n    # 1. \u8ba1\u7b97\u76f8\u4f3c\u5ea6\u77e9\u9635S (N\u00d7N)<br \/>\n    # image_embeds.shape&#xff1a;(batch_size, 512)<br \/>\n    # text_embeds.t().shape&#xff1a;(512, batch_size)<br \/>\n    # torch.matmul\u540eshape&#xff1a;(batch_size, batch_size)&#xff0c;\u5373\u6bcf\u4e2a\u56fe\u50cf\u4e0e\u6bcf\u4e2a\u6587\u672c\u7684\u76f8\u4f3c\u5ea6<br \/>\n    # \/ temperature&#xff1a;\u6e29\u5ea6\u7cfb\u6570\u7f29\u653e&#xff0c;\u8ba9\u76f8\u4f3c\u5ea6\u5206\u5e03\u66f4\u5408\u7406<br \/>\n    similarity &#061; torch.matmul(image_embeds, text_embeds.t()) \/ temperature<\/p>\n<p>    # 2. \u6784\u5efa\u6807\u7b7e&#xff1a;\u6b63\u6837\u672c\u662f\u5bf9\u89d2\u7ebf&#xff08;i&#061;j&#xff09;&#xff0c;\u5373\u7b2ci\u4e2a\u56fe\u50cf\u5bf9\u5e94\u7b2ci\u4e2a\u6587\u672c<br \/>\n    # labels.shape&#xff1a;(batch_size,)&#xff0c;\u503c\u4e3a[0,1,2,3]&#xff08;\u5f53batch_size&#061;4\u65f6&#xff09;<br \/>\n    labels &#061; torch.arange(BATCH_SIZE).to(DEVICE)<\/p>\n<p>    # 3. \u56fe\u50cf\u5230\u6587\u672c\u7684\u635f\u5931&#xff08;Image-to-Text&#xff09;<br \/>\n    # \u4ee5\u56fe\u50cf\u4e3a\u951a\u70b9&#xff0c;\u8ba1\u7b97\u6bcf\u4e2a\u56fe\u50cf\u5339\u914d\u5bf9\u5e94\u6587\u672c\u7684\u4ea4\u53c9\u71b5\u635f\u5931<br \/>\n    # similarity\u662f\u9884\u6d4b\u503c&#xff08;\u6bcf\u4e2a\u56fe\u50cf\u5bf9\u6240\u6709\u6587\u672c\u7684\u76f8\u4f3c\u5ea6&#xff09;&#xff0c;labels\u662f\u771f\u5b9e\u6807\u7b7e<br \/>\n    loss_i2t &#061; F.cross_entropy(similarity, labels)<\/p>\n<p>    # 4. \u6587\u672c\u5230\u56fe\u50cf\u7684\u635f\u5931&#xff08;Text-to-Image&#xff09;<br \/>\n    # \u4ee5\u6587\u672c\u4e3a\u951a\u70b9&#xff0c;\u9700\u8981\u5c06\u76f8\u4f3c\u5ea6\u77e9\u9635\u8f6c\u7f6e&#xff08;\u6bcf\u4e2a\u6587\u672c\u5bf9\u6240\u6709\u56fe\u50cf\u7684\u76f8\u4f3c\u5ea6&#xff09;<br \/>\n    loss_t2i &#061; F.cross_entropy(similarity.t(), labels)<\/p>\n<p>    # 5. \u603b\u635f\u5931&#xff1a;\u56fe\u50cf\u5230\u6587\u672c\u3001\u6587\u672c\u5230\u56fe\u50cf\u635f\u5931\u7684\u5e73\u5747\u503c<br \/>\n    total_loss &#061; (loss_i2t &#043; loss_t2i) \/ 2<\/p>\n<p>    # \u8fd4\u56de\u603b\u635f\u5931<br \/>\n    return total_loss<\/p>\n<h5>\u6a21\u5757\u516d&#xff1a;\u5b9e\u4f8b\u8fd0\u884c<\/h5>\n<p># \u4e3b\u51fd\u6570\u5165\u53e3&#xff1a;\u53ea\u6709\u5f53\u811a\u672c\u76f4\u63a5\u8fd0\u884c\u65f6\u624d\u6267\u884c\u4ee5\u4e0b\u4ee3\u7801<br \/>\nif __name__ &#061;&#061; &#034;__main__&#034;:<br \/>\n    # \u521d\u59cb\u5316\u56fe\u50cf\u7f16\u7801\u5668&#xff0c;\u5e76\u79fb\u5230\u6307\u5b9a\u8bbe\u5907&#xff08;GPU\/CPU&#xff09;<br \/>\n    image_encoder &#061; ImageEncoder().to(DEVICE)<br \/>\n    # \u521d\u59cb\u5316\u6587\u672c\u7f16\u7801\u5668&#xff0c;\u5e76\u79fb\u5230\u6307\u5b9a\u8bbe\u5907&#xff08;GPU\/CPU&#xff09;<br \/>\n    text_encoder &#061; TextEncoder().to(DEVICE)<\/p>\n<p>    # \u6a21\u62df\u8f93\u5165&#xff1a;\u751f\u62104\u5f20\u968f\u673a\u56fe\u50cf&#xff08;\u7b26\u5408ViT\u8f93\u5165\u8981\u6c42&#xff1a;3\u901a\u9053&#xff0c;224\u00d7224&#xff09;<br \/>\n    # fake_images.shape&#xff1a;(4, 3, 224, 224)<br \/>\n    fake_images &#061; torch.randn(BATCH_SIZE, 3, 224, 224).to(DEVICE)<br \/>\n    # \u6a21\u62df4\u6761\u6587\u672c&#xff0c;\u4e0e4\u5f20\u56fe\u50cf\u4e00\u4e00\u5bf9\u5e94&#xff08;\u6b63\u6837\u672c\u5bf9&#xff09;<br \/>\n    fake_texts &#061; [&#034;\u4e00\u53ea\u9ed1\u8272\u7684\u732b&#034;, &#034;\u7ea2\u8272\u7684\u82f9\u679c&#034;, &#034;\u84dd\u5929\u767d\u4e91&#034;, &#034;\u5c0f\u72d7\u5728\u8dd1&#034;]<\/p>\n<p>    # \u56fe\u50cf\u7f16\u7801&#xff1a;\u8f93\u5165\u968f\u673a\u56fe\u50cf&#xff0c;\u8f93\u51fa\u5f52\u4e00\u5316\u7684\u56fe\u50cf\u5411\u91cf<br \/>\n    # image_embeds.shape&#xff1a;(4, 512)<br \/>\n    image_embeds &#061; image_encoder(fake_images)<br \/>\n    # \u6587\u672c\u7f16\u7801&#xff1a;\u8f93\u5165\u6587\u672c\u5217\u8868&#xff0c;\u8f93\u51fa\u5f52\u4e00\u5316\u7684\u6587\u672c\u5411\u91cf<br \/>\n    # text_embeds.shape&#xff1a;(4, 512)<br \/>\n    text_embeds &#061; text_encoder(fake_texts)<\/p>\n<p>    # \u8ba1\u7b97CLIP\u635f\u5931&#xff1a;\u8f93\u5165\u56fe\u6587\u5411\u91cf&#xff0c;\u8f93\u51fa\u635f\u5931\u503c<br \/>\n    loss &#061; clip_loss(image_embeds, text_embeds)<\/p>\n<p>    # \u8f93\u51fa\u56fe\u50cf\u5411\u91cf\u5f62\u72b6&#xff0c;\u9a8c\u8bc1\u7ef4\u5ea6\u662f\u5426\u6b63\u786e<br \/>\n    print(f&#034;\u56fe\u50cf\u5411\u91cf\u5f62\u72b6: {image_embeds.shape}&#034;)  # \u9884\u671f\u8f93\u51fa&#xff1a;torch.Size([4, 512])<br \/>\n    # \u8f93\u51fa\u6587\u672c\u5411\u91cf\u5f62\u72b6&#xff0c;\u9a8c\u8bc1\u7ef4\u5ea6\u662f\u5426\u6b63\u786e<br \/>\n    print(f&#034;\u6587\u672c\u5411\u91cf\u5f62\u72b6: {text_embeds.shape}&#034;)  # \u9884\u671f\u8f93\u51fa&#xff1a;torch.Size([4, 512])<br \/>\n    # \u8f93\u51fa\u635f\u5931\u503c&#xff0c;item()\u5c06\u5f20\u91cf\u8f6c\u4e3a\u6d6e\u70b9\u6570&#xff0c;\u4fdd\u75594\u4f4d\u5c0f\u6570<br \/>\n    print(f&#034;CLIP\u635f\u5931\u503c: {loss.item():.4f}&#034;)      # \u521d\u59cb\u968f\u673a\u72b6\u6001\u4e0b\u7ea63.5&#xff08;\u56e0batch_size&#061;4&#xff0c;ln(4)\u22481.386&#xff0c;\u52a0\u4e0a\u6e29\u5ea6\u7cfb\u6570\u7f29\u653e&#xff09;<\/p>\n<h4>\u56db\u3001\u603b\u7ed3<\/h4>\n<ul>\n<li>\u6838\u5fc3\u903b\u8f91&#xff1a;CLIP \u901a\u8fc7\u8de8\u6a21\u6001\u5bf9\u6bd4\u5b66\u4e60&#xff0c;\u8ba9\u56fe\u6587\u7f16\u7801\u5668\u5b66\u4e60 \u201c\u5339\u914d\u5bf9\u5411\u91cf\u76f8\u4f3c\u3001\u4e0d\u5339\u914d\u5bf9\u5411\u91cf\u758f\u8fdc\u201d&#xff0c;\u6838\u5fc3\u662f\u5f52\u4e00\u5316 &#043; \u4f59\u5f26\u76f8\u4f3c\u5ea6 &#043; InfoNCE \u635f\u5931&#xff1b;<\/li>\n<li>\u5173\u952e\u516c\u5f0f&#xff1a;\u635f\u5931\u51fd\u6570\u7531\u56fe\u50cf\u5230\u6587\u672c\u3001\u6587\u672c\u5230\u56fe\u50cf\u4e24\u90e8\u5206\u4ea4\u53c9\u71b5\u7ec4\u6210&#xff0c;\u6e29\u5ea6\u7cfb\u6570 \u03c4 \u7528\u4e8e\u8c03\u8282\u76f8\u4f3c\u5ea6\u5206\u5e03&#xff1b;<\/li>\n<li>\u4ee3\u7801\u6838\u5fc3&#xff1a;\u56fe\u6587\u7f16\u7801\u5668\u8f93\u51fa\u5f52\u4e00\u5316\u5411\u91cf&#xff0c;\u901a\u8fc7\u77e9\u9635\u70b9\u79ef\u8ba1\u7b97\u76f8\u4f3c\u5ea6&#xff0c;\u6700\u7ec8\u7528\u4ea4\u53c9\u71b5\u5b9e\u73b0\u5bf9\u6bd4\u635f\u5931\u3002<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001CLIP\u6838\u5fc3\u6982\u5ff5CLIP&#xff08;Contrastive Language-Image Pre-training&#xff09;\u662f OpenAI \u63d0\u51fa\u7684\u5bf9\u6bd4\u5b66\u4e60\u6a21\u578b&#xff0c;\u6838\u5fc3\u662f\u8de8\u6a21\u6001\u5bf9\u6bd4\u9884\u8bad\u7ec3&#xff0c;\u76ee\u6807\u662f\u8ba9\u6a21\u578b\u540c\u65f6\u7406\u89e3\u56fe\u50cf\u548c\u6587\u672c\u7684\u8bed\u4e49\u5173\u8054&#xff0c;\u5b9e\u73b0 \u201c\u56fe\u6587\u4e92\u641c\u201d\u201c\u96f6\u6837\u672c\u5206\u7c7b\u201d \u7b49\u80fd\u529b\u3002\u6838\u5fc3\u601d\u60f3&#xff1a;\u5c06\u56fe\u50cf\u548c\u6587\u672c\u5206\u522b\u7f16\u7801\u4e3a\u5411\u91cf&#xff0c;\u901a\u8fc7\u5bf9\u6bd4\u5b66\u4e60\u8ba9 \u201c\u5339\u914d\u7684\u56fe\u6587\u5bf9\u201d \u5411\u91cf\u8ddd\u79bb\u8fd1&#xff0c;\u201c\u4e0d\u5339\u914d\u7684\u56fe\u6587\u5bf9\u201d \u5411\u91cf\u8ddd\u79bb<\/p>\n","protected":false},"author":2,"featured_media":78047,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[81,427],"topic":[],"class_list":["post-78051","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-python","tag-427"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u591a\u6a21\u6001\u2014\u2014\u2014\u2014CLIP - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/78051.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u591a\u6a21\u6001\u2014\u2014\u2014\u2014CLIP - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u4e00\u3001CLIP\u6838\u5fc3\u6982\u5ff5CLIP&#xff08;Contrastive Language-Image Pre-training&#xff09;\u662f OpenAI \u63d0\u51fa\u7684\u5bf9\u6bd4\u5b66\u4e60\u6a21\u578b&#xff0c;\u6838\u5fc3\u662f\u8de8\u6a21\u6001\u5bf9\u6bd4\u9884\u8bad\u7ec3&#xff0c;\u76ee\u6807\u662f\u8ba9\u6a21\u578b\u540c\u65f6\u7406\u89e3\u56fe\u50cf\u548c\u6587\u672c\u7684\u8bed\u4e49\u5173\u8054&#xff0c;\u5b9e\u73b0 \u201c\u56fe\u6587\u4e92\u641c\u201d\u201c\u96f6\u6837\u672c\u5206\u7c7b\u201d \u7b49\u80fd\u529b\u3002\u6838\u5fc3\u601d\u60f3&#xff1a;\u5c06\u56fe\u50cf\u548c\u6587\u672c\u5206\u522b\u7f16\u7801\u4e3a\u5411\u91cf&#xff0c;\u901a\u8fc7\u5bf9\u6bd4\u5b66\u4e60\u8ba9 \u201c\u5339\u914d\u7684\u56fe\u6587\u5bf9\u201d \u5411\u91cf\u8ddd\u79bb\u8fd1&#xff0c;\u201c\u4e0d\u5339\u914d\u7684\u56fe\u6587\u5bf9\u201d \u5411\u91cf\u8ddd\u79bb\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/78051.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-02-25T18:57:40+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260225185738-699f4622c4554.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/78051.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/78051.html\",\"name\":\"\u591a\u6a21\u6001\u2014\u2014\u2014\u2014CLIP - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-02-25T18:57:40+00:00\",\"dateModified\":\"2026-02-25T18:57:40+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/78051.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/78051.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/78051.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u591a\u6a21\u6001\u2014\u2014\u2014\u2014CLIP\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u591a\u6a21\u6001\u2014\u2014\u2014\u2014CLIP - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/78051.html","og_locale":"zh_CN","og_type":"article","og_title":"\u591a\u6a21\u6001\u2014\u2014\u2014\u2014CLIP - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u4e00\u3001CLIP\u6838\u5fc3\u6982\u5ff5CLIP&#xff08;Contrastive Language-Image Pre-training&#xff09;\u662f OpenAI \u63d0\u51fa\u7684\u5bf9\u6bd4\u5b66\u4e60\u6a21\u578b&#xff0c;\u6838\u5fc3\u662f\u8de8\u6a21\u6001\u5bf9\u6bd4\u9884\u8bad\u7ec3&#xff0c;\u76ee\u6807\u662f\u8ba9\u6a21\u578b\u540c\u65f6\u7406\u89e3\u56fe\u50cf\u548c\u6587\u672c\u7684\u8bed\u4e49\u5173\u8054&#xff0c;\u5b9e\u73b0 \u201c\u56fe\u6587\u4e92\u641c\u201d\u201c\u96f6\u6837\u672c\u5206\u7c7b\u201d \u7b49\u80fd\u529b\u3002\u6838\u5fc3\u601d\u60f3&#xff1a;\u5c06\u56fe\u50cf\u548c\u6587\u672c\u5206\u522b\u7f16\u7801\u4e3a\u5411\u91cf&#xff0c;\u901a\u8fc7\u5bf9\u6bd4\u5b66\u4e60\u8ba9 \u201c\u5339\u914d\u7684\u56fe\u6587\u5bf9\u201d \u5411\u91cf\u8ddd\u79bb\u8fd1&#xff0c;\u201c\u4e0d\u5339\u914d\u7684\u56fe\u6587\u5bf9\u201d \u5411\u91cf\u8ddd\u79bb","og_url":"https:\/\/www.wsisp.com\/helps\/78051.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-02-25T18:57:40+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260225185738-699f4622c4554.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"4 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/78051.html","url":"https:\/\/www.wsisp.com\/helps\/78051.html","name":"\u591a\u6a21\u6001\u2014\u2014\u2014\u2014CLIP - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-02-25T18:57:40+00:00","dateModified":"2026-02-25T18:57:40+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/78051.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/78051.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/78051.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u591a\u6a21\u6001\u2014\u2014\u2014\u2014CLIP"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/78051","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=78051"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/78051\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/78047"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=78051"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=78051"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=78051"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=78051"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}