{"version":2,"relationshipURLBase":"https://codingai-lec03.pages.dev/course/notebooks/921eeaf784284ce19568c6ca7619b55a.html","relationshipResolution":"Resolve relative relationship URLs against relationshipURLBase; complete records and absolute URLs are in blocks.","title":"LAB 12 · CLIP延伸：缓存与检索（近似索引选读）","url":"https://codingai-lec03.pages.dev/course/notebooks/921eeaf784284ce19568c6ca7619b55a.html","markdown":"https://codingai-lec03.pages.dev/course/notebooks/921eeaf784284ce19568c6ca7619b55a.md","pages":[{"id":"reading-opening","title":"LAB 12 · CLIP延伸：缓存与检索（近似索引选读）","unit":"已知图文配对怎样变成可用的文字候选接口？","unitId":"clip-pairing-to-candidates","chapter":"III","number":1},{"id":"reading-block-687d09fc176e4c64a0bf836efcbe03f1","title":"1 · 输入、来源、编码和缓存身份","unit":"已知图文配对怎样变成可用的文字候选接口？","unitId":"clip-pairing-to-candidates","chapter":"III","number":2},{"id":"reading-block-5ba73f2552e945a7a94eb9043c0ac480","title":"2 · 精确搜索：模型给分，评价定义相关","unit":"已知图文配对怎样变成可用的文字候选接口？","unitId":"clip-pairing-to-candidates","chapter":"III","number":3},{"id":"reading-block-62a7fe6e03324fd9877c139c11e4ce0e","title":"3 · 实际的近似索引：先路由到簇，再在簇内精排","unit":"已知图文配对怎样变成可用的文字候选接口？","unitId":"clip-pairing-to-candidates","chapter":"III","number":4},{"id":"reading-block-304aa2a46d41405db647924c1a08d5c0","title":"4 · 缓存节约什么，不能节约什么？","unit":"已知图文配对怎样变成可用的文字候选接口？","unitId":"clip-pairing-to-candidates","chapter":"III","number":5},{"id":"reading-block-8cfb433dc5cc4c4d9b8052e80463dfb5","title":"5 · 查询依赖的交互：一个可运行的区域加权对照","unit":"已知图文配对怎样变成可用的文字候选接口？","unitId":"clip-pairing-to-candidates","chapter":"III","number":6},{"id":"reading-block-00d45a521ea24f3894d71b0c128448a3","title":"6 · 做一个有意义的改变，并解释它改变了哪层","unit":"已知图文配对怎样变成可用的文字候选接口？","unitId":"clip-pairing-to-candidates","chapter":"III","number":7}],"aliases":[{"oldId":"b-09c5574dc6334bcbb7336ba7","targetId":"b-09c5574dc6334bcbb7336ba7","page":"reading-opening","operation":"move","beforeSHA256":"dc3dd8d669c0539692ccd8800a03068a1629bcdf04090f59fd2fba8026242e23","afterSHA256":"dc3dd8d669c0539692ccd8800a03068a1629bcdf04090f59fd2fba8026242e23","reason":"Same source body in authored semantic page"},{"oldId":"b-3d55d0054ae6a421b81adc66","targetId":"b-3d55d0054ae6a421b81adc66","page":"reading-opening","operation":"move","beforeSHA256":"dc06c1e728a4b5740ba634b145bc9a1da6323031626734cb4555db5a744df806","afterSHA256":"dc06c1e728a4b5740ba634b145bc9a1da6323031626734cb4555db5a744df806","reason":"Same source body in authored semantic page"},{"oldId":"b-79d4bc4a4bc3492c8350ad81","targetId":"b-79d4bc4a4bc3492c8350ad81","page":"reading-opening","operation":"move","beforeSHA256":"8021c18afc52ba7b6612f43ecfb0fdd4789efe91cc9cd656984357d81a8514de","afterSHA256":"8021c18afc52ba7b6612f43ecfb0fdd4789efe91cc9cd656984357d81a8514de","reason":"Same source body in authored semantic page"},{"oldId":"b-951aec5456867014dd710468","targetId":"b-951aec5456867014dd710468","page":"reading-opening","operation":"move","beforeSHA256":"f22152fd55dcdb0090b5653d37145694fd19388d31e10226549464fe8b483578","afterSHA256":"f22152fd55dcdb0090b5653d37145694fd19388d31e10226549464fe8b483578","reason":"Same source body in authored semantic page"},{"oldId":"b-6f6340bb26e19d21c1755b1d","targetId":"b-6f6340bb26e19d21c1755b1d","page":"reading-opening","operation":"move","beforeSHA256":"bab4bd804571aa5afbaf197e9c1539510fc766578c9825aa46cadbb18444cc32","afterSHA256":"bab4bd804571aa5afbaf197e9c1539510fc766578c9825aa46cadbb18444cc32","reason":"Same source body in authored semantic page"},{"oldId":"b-9acc65e77992f640b55527de","targetId":"b-9acc65e77992f640b55527de","page":"reading-opening","operation":"move","beforeSHA256":"5fbe114bcb870df3b0a22d360a98a599544e8d98166e2baab6796d9846c84725","afterSHA256":"5fbe114bcb870df3b0a22d360a98a599544e8d98166e2baab6796d9846c84725","reason":"Same source body in authored semantic page"},{"oldId":"b-1a17098be4c49f4a50118677","targetId":"b-1a17098be4c49f4a50118677","page":"reading-opening","operation":"move","beforeSHA256":"3ac767754b4f134bba4821d4304d9450b1a03cc82aaf44073413740cbfd449aa","afterSHA256":"3ac767754b4f134bba4821d4304d9450b1a03cc82aaf44073413740cbfd449aa","reason":"Same source body in authored semantic page"},{"oldId":"b-7569d7b69e3251230de88435","targetId":"b-7569d7b69e3251230de88435","page":"reading-opening","operation":"move","beforeSHA256":"a315e05d1f004b11ff9c24607a524c3ba290695efbdf9fc1f8c6f4b5d3b8a42d","afterSHA256":"a315e05d1f004b11ff9c24607a524c3ba290695efbdf9fc1f8c6f4b5d3b8a42d","reason":"Same source body in authored semantic page"},{"oldId":"b-93783cec8b332f6e671a11a0","targetId":"b-93783cec8b332f6e671a11a0","page":"reading-opening","operation":"move","beforeSHA256":"495443f171850cc5a7e353e9b66975fb4671b36198e5ab69cd02d4e8ecd080ae","afterSHA256":"495443f171850cc5a7e353e9b66975fb4671b36198e5ab69cd02d4e8ecd080ae","reason":"Same source body in authored semantic page"},{"oldId":"b-8c80db97c0b97c4951a6f0ec","targetId":"b-8c80db97c0b97c4951a6f0ec","page":"reading-opening","operation":"move","beforeSHA256":"e03f64d6228373bf789a043218b6e0b79bfb3690f26045ed0469c9a91958de34","afterSHA256":"e03f64d6228373bf789a043218b6e0b79bfb3690f26045ed0469c9a91958de34","reason":"Same source body in authored semantic page"},{"oldId":"b-d44576e764a915c04f1228d7","targetId":"b-d44576e764a915c04f1228d7","page":"reading-opening","operation":"move","beforeSHA256":"12ceba147ef6dd56c8b723f733b3413face0fb8553a2d2532308176a4f4f306a","afterSHA256":"12ceba147ef6dd56c8b723f733b3413face0fb8553a2d2532308176a4f4f306a","reason":"Same source body in authored semantic page"},{"oldId":"b-ee87ca54084d0f7e88fbc4ab","targetId":"b-ee87ca54084d0f7e88fbc4ab","page":"reading-block-687d09fc176e4c64a0bf836efcbe03f1","operation":"move","beforeSHA256":"c55c81a2779d4884d73f8f9239637e8601ad2a671e8bfa4b1b0eaf733ce8c149","afterSHA256":"c55c81a2779d4884d73f8f9239637e8601ad2a671e8bfa4b1b0eaf733ce8c149","reason":"Same source body in authored semantic page"},{"oldId":"b-9049833a99d52211da7c5277","targetId":"b-9049833a99d52211da7c5277","page":"reading-block-687d09fc176e4c64a0bf836efcbe03f1","operation":"move","beforeSHA256":"a4760dc5c790d3551a0886f0b7e4afeba240e6e6546433a75593c9ee8ca2fc79","afterSHA256":"a4760dc5c790d3551a0886f0b7e4afeba240e6e6546433a75593c9ee8ca2fc79","reason":"Same source body in authored semantic page"},{"oldId":"b-b7eff3e7394064817090410b","targetId":"b-b7eff3e7394064817090410b","page":"reading-block-687d09fc176e4c64a0bf836efcbe03f1","operation":"move","beforeSHA256":"40758dc2b27ab13a7646c5b5af382412086396de48f6a362d0c866ac461a59b6","afterSHA256":"40758dc2b27ab13a7646c5b5af382412086396de48f6a362d0c866ac461a59b6","reason":"Same source body in authored semantic page"},{"oldId":"b-2456f658291ad30498fff812","targetId":"b-2456f658291ad30498fff812","page":"reading-block-687d09fc176e4c64a0bf836efcbe03f1","operation":"move","beforeSHA256":"0e65aac53651921d8e9f96626efa5458f0943e951cabcded0f5af48364ebb76f","afterSHA256":"a19555b36c40f361b20577ae383941cce9382473f9a009a407ecc3e394e25645","reason":"Same source body in authored semantic page"},{"oldId":"b-779a1579922eacc7799c441b","targetId":"b-779a1579922eacc7799c441b","page":"reading-block-687d09fc176e4c64a0bf836efcbe03f1","operation":"move","beforeSHA256":"5748751d5292c3aa044b6275be2ca22516edcf83bd727d34669cfe3f93e3aeb8","afterSHA256":"5748751d5292c3aa044b6275be2ca22516edcf83bd727d34669cfe3f93e3aeb8","reason":"Same source body in authored semantic page"},{"oldId":"b-e79516936f50a7bebd4cab49","targetId":"b-e79516936f50a7bebd4cab49","page":"reading-block-687d09fc176e4c64a0bf836efcbe03f1","operation":"move","beforeSHA256":"6fbf90ab812717a1cc7048a95944cd7f5194e019c122acc2da4909b06ab55514","afterSHA256":"6fbf90ab812717a1cc7048a95944cd7f5194e019c122acc2da4909b06ab55514","reason":"Same source body in authored semantic page"},{"oldId":"b-2e868ad8bd97c74d5a2cac48","targetId":"b-2e868ad8bd97c74d5a2cac48","page":"reading-block-687d09fc176e4c64a0bf836efcbe03f1","operation":"move","beforeSHA256":"3d32c29794a1b985da1ce28a5c69a139c3d4040422600609c15a1f81f9536114","afterSHA256":"3d32c29794a1b985da1ce28a5c69a139c3d4040422600609c15a1f81f9536114","reason":"Same source body in authored semantic page"},{"oldId":"b-579e43aac940fab8d1b90fb9","targetId":"b-579e43aac940fab8d1b90fb9","page":"reading-block-5ba73f2552e945a7a94eb9043c0ac480","operation":"move","beforeSHA256":"6a6a7b78abfe6364f4ef040e54cd2bf106294e030c2d6a73dcdad1dd69ddfa24","afterSHA256":"6a6a7b78abfe6364f4ef040e54cd2bf106294e030c2d6a73dcdad1dd69ddfa24","reason":"Same source body in authored semantic page"},{"oldId":"b-fa10e6c8f9968ff5668628a4","targetId":"b-fa10e6c8f9968ff5668628a4","page":"reading-block-5ba73f2552e945a7a94eb9043c0ac480","operation":"move","beforeSHA256":"a9db9edd976ff657caa5941b4245c0b52971ebde344e66c024f0e5ab01b0401f","afterSHA256":"a9db9edd976ff657caa5941b4245c0b52971ebde344e66c024f0e5ab01b0401f","reason":"Same source body in authored semantic page"},{"oldId":"b-5270ffb2732a576390781e57","targetId":"b-5270ffb2732a576390781e57","page":"reading-block-5ba73f2552e945a7a94eb9043c0ac480","operation":"move","beforeSHA256":"6981901db7db96134fa7095db2336567bb8c37f0f76f8e294f664880fb8c1808","afterSHA256":"6981901db7db96134fa7095db2336567bb8c37f0f76f8e294f664880fb8c1808","reason":"Same source body in authored semantic page"},{"oldId":"b-91b776a6ad6907586eeb5ad6","targetId":"b-91b776a6ad6907586eeb5ad6","page":"reading-block-5ba73f2552e945a7a94eb9043c0ac480","operation":"move","beforeSHA256":"aa8be1410199fba8c51caa638e575eceda30ec6f40f30bbfa56b0107d8f9e20f","afterSHA256":"aa8be1410199fba8c51caa638e575eceda30ec6f40f30bbfa56b0107d8f9e20f","reason":"Same source body in authored semantic page"},{"oldId":"b-8d3641714f9c1ea4d777502c","targetId":"b-8d3641714f9c1ea4d777502c","page":"reading-block-5ba73f2552e945a7a94eb9043c0ac480","operation":"move","beforeSHA256":"00533db81ffa311ed8f37086e435877c01dd22b52775e5759abb88c9252bc0aa","afterSHA256":"00533db81ffa311ed8f37086e435877c01dd22b52775e5759abb88c9252bc0aa","reason":"Same source body in authored semantic page"},{"oldId":"b-b82148cf1e8fd794d84d747e","targetId":"b-b82148cf1e8fd794d84d747e","page":"reading-block-62a7fe6e03324fd9877c139c11e4ce0e","operation":"move","beforeSHA256":"72042c5a397268efdedab711c30b3be6e811dbf705389989de882bfab7e7565c","afterSHA256":"72042c5a397268efdedab711c30b3be6e811dbf705389989de882bfab7e7565c","reason":"Same source body in authored semantic page"},{"oldId":"b-e0a25749c7f44b485203a39d","targetId":"b-e0a25749c7f44b485203a39d","page":"reading-block-62a7fe6e03324fd9877c139c11e4ce0e","operation":"move","beforeSHA256":"e912abb9cf15500ad588e974eab6aaf8e3a3dbfb4a3289c72d0cebe6988f1272","afterSHA256":"e912abb9cf15500ad588e974eab6aaf8e3a3dbfb4a3289c72d0cebe6988f1272","reason":"Same source body in authored semantic page"},{"oldId":"b-6b8263136157f9bceccaa3db","targetId":"b-6b8263136157f9bceccaa3db","page":"reading-block-62a7fe6e03324fd9877c139c11e4ce0e","operation":"move","beforeSHA256":"6f11c5e11524e032f183e4cb3071fb0773bf2a4e4ec7c99fc8f90f22962ea858","afterSHA256":"6f11c5e11524e032f183e4cb3071fb0773bf2a4e4ec7c99fc8f90f22962ea858","reason":"Same source body in authored semantic page"},{"oldId":"b-825b2123d939ab71901236e0","targetId":"b-825b2123d939ab71901236e0","page":"reading-block-62a7fe6e03324fd9877c139c11e4ce0e","operation":"move","beforeSHA256":"17197a3b41b63d107be94a74b22c9ae450a89fee34051c2caca715be92157969","afterSHA256":"17197a3b41b63d107be94a74b22c9ae450a89fee34051c2caca715be92157969","reason":"Same source body in authored semantic page"},{"oldId":"b-cafee496d19706ca0c9ccfaf","targetId":"b-cafee496d19706ca0c9ccfaf","page":"reading-block-62a7fe6e03324fd9877c139c11e4ce0e","operation":"move","beforeSHA256":"03548e94c27e646b9073eeed385278bb117959dca4e57b428eeb514af543181c","afterSHA256":"03548e94c27e646b9073eeed385278bb117959dca4e57b428eeb514af543181c","reason":"Same source body in authored semantic page"},{"oldId":"b-e9b1570dbf1dfc1d9a537ba9","targetId":"b-e9b1570dbf1dfc1d9a537ba9","page":"reading-block-62a7fe6e03324fd9877c139c11e4ce0e","operation":"move","beforeSHA256":"4199206c98f1400fd4f86b9a1b6859bfd6336b777ff8ee4644f10049430a0e81","afterSHA256":"4199206c98f1400fd4f86b9a1b6859bfd6336b777ff8ee4644f10049430a0e81","reason":"Same source body in authored semantic page"},{"oldId":"b-1ae09976a24db7b0ea62a03b","targetId":"b-1ae09976a24db7b0ea62a03b","page":"reading-block-62a7fe6e03324fd9877c139c11e4ce0e","operation":"rewrite","beforeSHA256":"468e5d4cafaad526d89627bdf133d70be61020ae8c8861c61102bb7bcc03c15a","afterSHA256":"19e1f4ed476f267b8d54876e0f38b9544dbd5efb15a13fa7844ca5e3c57b18fd","reason":"Same source identity with figure semantics or reading context enriched"},{"oldId":"b-6c6093d10b2ad81c96ba61d3","targetId":"b-6c6093d10b2ad81c96ba61d3","page":"reading-block-62a7fe6e03324fd9877c139c11e4ce0e","operation":"move","beforeSHA256":"deb1e19b802e3c9a8340b7f6c73704f55fd26daae1b19a560c7e056ce1a3d9e2","afterSHA256":"deb1e19b802e3c9a8340b7f6c73704f55fd26daae1b19a560c7e056ce1a3d9e2","reason":"Same source body in authored semantic page"},{"oldId":"b-b0cf1dd140261eddd737bc03","targetId":"b-b0cf1dd140261eddd737bc03","page":"reading-block-62a7fe6e03324fd9877c139c11e4ce0e","operation":"move","beforeSHA256":"f800f03ae61070290c48f513109f46c73596c6752c4ce0097251d87c426a99d0","afterSHA256":"f800f03ae61070290c48f513109f46c73596c6752c4ce0097251d87c426a99d0","reason":"Same source body in authored semantic page"},{"oldId":"b-838054192e5a745672187995","targetId":"b-838054192e5a745672187995","page":"reading-block-62a7fe6e03324fd9877c139c11e4ce0e","operation":"move","beforeSHA256":"1ddf1e6f4a92876b964902f2f6ed34917b02a0822b4f77a25e14c3e0b6358d91","afterSHA256":"1ddf1e6f4a92876b964902f2f6ed34917b02a0822b4f77a25e14c3e0b6358d91","reason":"Same source body in authored semantic page"},{"oldId":"b-04c06e9bddb06cfe81993f70","targetId":"b-04c06e9bddb06cfe81993f70","page":"reading-block-304aa2a46d41405db647924c1a08d5c0","operation":"move","beforeSHA256":"cc34b1d8d96a4a8b5be556959bf607fe886b3e40109adebba891f9b6d77ccf4f","afterSHA256":"cc34b1d8d96a4a8b5be556959bf607fe886b3e40109adebba891f9b6d77ccf4f","reason":"Same source body in authored semantic page"},{"oldId":"b-06d3ed33d793d28449787ad9","targetId":"b-06d3ed33d793d28449787ad9","page":"reading-block-304aa2a46d41405db647924c1a08d5c0","operation":"move","beforeSHA256":"29de550b073aa289c5c63996c445f8ef9074e4112c55ccd3992e7ea786a72ca4","afterSHA256":"29de550b073aa289c5c63996c445f8ef9074e4112c55ccd3992e7ea786a72ca4","reason":"Same source body in authored semantic page"},{"oldId":"b-27c5cc71c0b8fdf6c5321b15","targetId":"b-27c5cc71c0b8fdf6c5321b15","page":"reading-block-304aa2a46d41405db647924c1a08d5c0","operation":"rewrite","beforeSHA256":"e1c547b6e70c56eee1fa6cd81d029af495999c5a23ba0feca79b25a35f761586","afterSHA256":"43f16868b0a2ff3caaf4097219db411875fa2eddf5ab688376216b11ba085931","reason":"Same source identity with figure semantics or reading context enriched"},{"oldId":"b-5965811d42506f7688eb3e26","targetId":"b-5965811d42506f7688eb3e26","page":"reading-block-304aa2a46d41405db647924c1a08d5c0","operation":"move","beforeSHA256":"7df53ec83d5158fab387bde9da8775e8145a415001ec6c33bbc5889e686315c6","afterSHA256":"7df53ec83d5158fab387bde9da8775e8145a415001ec6c33bbc5889e686315c6","reason":"Same source body in authored semantic page"},{"oldId":"b-41cdb6c3aac36f8f47879aeb","targetId":"b-41cdb6c3aac36f8f47879aeb","page":"reading-block-304aa2a46d41405db647924c1a08d5c0","operation":"move","beforeSHA256":"0058f1b1f72f4b12fed94a47316508cdf7a76909d978c569cc516bd2b096b4c4","afterSHA256":"0058f1b1f72f4b12fed94a47316508cdf7a76909d978c569cc516bd2b096b4c4","reason":"Same source body in authored semantic page"},{"oldId":"b-42b079dcde8335552527f46d","targetId":"b-42b079dcde8335552527f46d","page":"reading-block-304aa2a46d41405db647924c1a08d5c0","operation":"move","beforeSHA256":"0aca1a9483c1d58d13fe4c22db96395bf7ece1daf2b5e25e23c67d8e06f67d18","afterSHA256":"0aca1a9483c1d58d13fe4c22db96395bf7ece1daf2b5e25e23c67d8e06f67d18","reason":"Same source body in authored semantic page"},{"oldId":"b-0796ffa1b8933f07e81dc472","targetId":"b-0796ffa1b8933f07e81dc472","page":"reading-block-304aa2a46d41405db647924c1a08d5c0","operation":"move","beforeSHA256":"1f446813e339d77894338425dfd088564fcaa921bd9d6fcdb446e1a9523375fd","afterSHA256":"1f446813e339d77894338425dfd088564fcaa921bd9d6fcdb446e1a9523375fd","reason":"Same source body in authored semantic page"},{"oldId":"b-f57772ac379ebea36a099585","targetId":"b-f57772ac379ebea36a099585","page":"reading-block-8cfb433dc5cc4c4d9b8052e80463dfb5","operation":"move","beforeSHA256":"2fd9111f853e5d93f7d59d72c39d6652bb45bfaa5b4f36353c00e0eca228db69","afterSHA256":"2fd9111f853e5d93f7d59d72c39d6652bb45bfaa5b4f36353c00e0eca228db69","reason":"Same source body in authored semantic page"},{"oldId":"b-42060f9662e7e2098e9d0fe6","targetId":"b-42060f9662e7e2098e9d0fe6","page":"reading-block-8cfb433dc5cc4c4d9b8052e80463dfb5","operation":"move","beforeSHA256":"1c0a54709b04ee6babf39f66eee1768f60b0f62b5c9cd89bb4c23667b8ade7c6","afterSHA256":"1c0a54709b04ee6babf39f66eee1768f60b0f62b5c9cd89bb4c23667b8ade7c6","reason":"Same source body in authored semantic page"},{"oldId":"b-67bd55c882a2d5ad3a9e3113","targetId":"b-67bd55c882a2d5ad3a9e3113","page":"reading-block-8cfb433dc5cc4c4d9b8052e80463dfb5","operation":"move","beforeSHA256":"9131075fd10fc81a22296a0bfdfa26a9b81a5fc2506249842fe1f424e20c20b0","afterSHA256":"9131075fd10fc81a22296a0bfdfa26a9b81a5fc2506249842fe1f424e20c20b0","reason":"Same source body in authored semantic page"},{"oldId":"b-6ea0289147217c2afc22fb97","targetId":"b-6ea0289147217c2afc22fb97","page":"reading-block-8cfb433dc5cc4c4d9b8052e80463dfb5","operation":"move","beforeSHA256":"7319327aded1ab0df3bfecb88955ac7ec5e20b4a260492e8c92a288c7f8f2c0e","afterSHA256":"7319327aded1ab0df3bfecb88955ac7ec5e20b4a260492e8c92a288c7f8f2c0e","reason":"Same source body in authored semantic page"},{"oldId":"b-7c629a5cad0295b15edf1e20","targetId":"b-7c629a5cad0295b15edf1e20","page":"reading-block-8cfb433dc5cc4c4d9b8052e80463dfb5","operation":"move","beforeSHA256":"1c94690e55052c3ecda347fd63eda585c74c30839c4f2ee4f7e60c12cef100b7","afterSHA256":"1c94690e55052c3ecda347fd63eda585c74c30839c4f2ee4f7e60c12cef100b7","reason":"Same source body in authored semantic page"},{"oldId":"b-c5ed526ddc0ae7bfd5432f79","targetId":"b-c5ed526ddc0ae7bfd5432f79","page":"reading-block-00d45a521ea24f3894d71b0c128448a3","operation":"move","beforeSHA256":"bbae6b88d175740fcc388f6a8c87e215f238a735f871795aaf66c88b7cab6763","afterSHA256":"bbae6b88d175740fcc388f6a8c87e215f238a735f871795aaf66c88b7cab6763","reason":"Same source body in authored semantic page"},{"oldId":"b-e03d42a192702ca79ced99d0","targetId":"b-e03d42a192702ca79ced99d0","page":"reading-block-00d45a521ea24f3894d71b0c128448a3","operation":"move","beforeSHA256":"42636dfc286ae067e3a3dd324d3254fd946cf97ff5a9b437d0cd7499fd2dfb67","afterSHA256":"42636dfc286ae067e3a3dd324d3254fd946cf97ff5a9b437d0cd7499fd2dfb67","reason":"Same source body in authored semantic page"},{"oldId":"b-9671761074b3f50b1f5414f5","targetId":"b-9671761074b3f50b1f5414f5","page":"reading-block-00d45a521ea24f3894d71b0c128448a3","operation":"move","beforeSHA256":"3df82b0623b773e41f2ed517ca902a17ceeae0a40bd60e17ab4b0ab30bdb5fb8","afterSHA256":"3df82b0623b773e41f2ed517ca902a17ceeae0a40bd60e17ab4b0ab30bdb5fb8","reason":"Same source body in authored semantic page"},{"oldId":"b-9820adeb614d784f2a80e6fa","targetId":"b-9820adeb614d784f2a80e6fa","page":"reading-block-00d45a521ea24f3894d71b0c128448a3","operation":"move","beforeSHA256":"c60d3777bf170bdaa4d3d1080e566dc13881ed5547b9588c256b50c81668901d","afterSHA256":"c60d3777bf170bdaa4d3d1080e566dc13881ed5547b9588c256b50c81668901d","reason":"Same source body in authored semantic page"},{"oldId":"b-1632710ec5f95630c9f61a5b","targetId":"b-1632710ec5f95630c9f61a5b","page":"reading-block-00d45a521ea24f3894d71b0c128448a3","operation":"move","beforeSHA256":"683fb353614b8caea2b20354148eb392f1ae5b27cdddc2afc985881ecd61869e","afterSHA256":"683fb353614b8caea2b20354148eb392f1ae5b27cdddc2afc985881ecd61869e","reason":"Same source body in authored semantic page"},{"oldId":"b-b6f3671cde49103203b07ef8","targetId":"b-b6f3671cde49103203b07ef8","page":"reading-block-00d45a521ea24f3894d71b0c128448a3","operation":"move","beforeSHA256":"a586469ccc83fb5dcf05cbbe1b152e57de2fd97ec876b73756c1a3bac5a9d09c","afterSHA256":"a586469ccc83fb5dcf05cbbe1b152e57de2fd97ec876b73756c1a3bac5a9d09c","reason":"Same source body in authored semantic page"},{"oldId":"b-9ecdb05e00671b3a6374fe17","targetId":"b-9ecdb05e00671b3a6374fe17","page":"reading-block-00d45a521ea24f3894d71b0c128448a3","operation":"move","beforeSHA256":"fcd877d1c393bc745c961addcd221b12f2ddf742a1feec276a9658eddddb9f9d","afterSHA256":"fcd877d1c393bc745c961addcd221b12f2ddf742a1feec276a9658eddddb9f9d","reason":"Same source body in authored semantic page"},{"oldId":"block-687d09fc176e4c64a0bf836efcbe03f1--1-输入来源编码和缓存身份","targetId":"b-ee87ca54084d0f7e88fbc4ab","operation":"retain-source-identity"},{"oldId":"block-5ba73f2552e945a7a94eb9043c0ac480--2-精确搜索模型给分评价定义相关","targetId":"b-579e43aac940fab8d1b90fb9","operation":"retain-source-identity"},{"oldId":"block-62a7fe6e03324fd9877c139c11e4ce0e--3-实际的近似索引先路由到簇再在簇内精排","targetId":"b-b82148cf1e8fd794d84d747e","operation":"retain-source-identity"},{"oldId":"block-304aa2a46d41405db647924c1a08d5c0--4-缓存节约什么不能节约什么","targetId":"b-04c06e9bddb06cfe81993f70","operation":"retain-source-identity"},{"oldId":"block-8cfb433dc5cc4c4d9b8052e80463dfb5--5-查询依赖的交互一个可运行的区域加权对照","targetId":"b-f57772ac379ebea36a099585","operation":"retain-source-identity"},{"oldId":"block-00d45a521ea24f3894d71b0c128448a3--6-做一个有意义的改变并解释它改变了哪层","targetId":"b-c5ed526ddc0ae7bfd5432f79","operation":"retain-source-identity"}],"blocks":[{"id":"b-09c5574dc6334bcbb7336ba7","type":"h1","scope":"document","url":"https://codingai-lec03.pages.dev/course/notebooks/921eeaf784284ce19568c6ca7619b55a.html#b-09c5574dc6334bcbb7336ba7","content":"# LAB 12 · CLIP延伸：缓存与检索（近似索引选读）","sha256":"dc3dd8d669c0539692ccd8800a03068a1629bcdf04090f59fd2fba8026242e23","chapter":{"id":"III","title":"视觉与语言"},"unit":{"id":"clip-pairing-to-candidates","title":"已知图文配对怎样变成可用的文字候选接口？"},"page":{"id":"reading-opening","title":"LAB 12 · CLIP延伸：缓存与检索（近似索引选读）","number":1},"sectionTitle":"LAB 12 · CLIP延伸：缓存与检索（近似索引选读）","currentQuestion":"LAB 12 · CLIP延伸：缓存与检索（近似索引选读）","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":null,"nextBlock":"b-3d55d0054ae6a421b81adc66","prerequisites":[{"id":"b-3d55d0054ae6a421b81adc66","url":"#b-3d55d0054ae6a421b81adc66","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-3d55d0054ae6a421b81adc66","type":"p","scope":"document","url":"https://codingai-lec03.pages.dev/course/notebooks/921eeaf784284ce19568c6ca7619b55a.html#b-3d55d0054ae6a421b81adc66","content":"并入相关学习路径","sha256":"dc06c1e728a4b5740ba634b145bc9a1da6323031626734cb4555db5a744df806","chapter":{"id":"III","title":"视觉与语言"},"unit":{"id":"clip-pairing-to-candidates","title":"已知图文配对怎样变成可用的文字候选接口？"},"page":{"id":"reading-opening","title":"LAB 12 · CLIP延伸：缓存与检索（近似索引选读）","number":1},"sectionTitle":"LAB 12 · CLIP延伸：缓存与检索（近似索引选读）","currentQuestion":"LAB 12 · CLIP延伸：缓存与检索（近似索引选读）","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-09c5574dc6334bcbb7336ba7","nextBlock":"b-79d4bc4a4bc3492c8350ad81","prerequisites":[{"id":"b-09c5574dc6334bcbb7336ba7","url":"#b-09c5574dc6334bcbb7336ba7","role":"section-title"}],"relatedBlocks":[]},{"id":"b-79d4bc4a4bc3492c8350ad81","type":"p","scope":"document","url":"https://codingai-lec03.pages.dev/course/notebooks/921eeaf784284ce19568c6ca7619b55a.html#b-79d4bc4a4bc3492c8350ad81","content":"同一CLIP缓存、exact/IVF搜索、延迟/扫描量、区域交互基线","sha256":"8021c18afc52ba7b6612f43ecfb0fdd4789efe91cc9cd656984357d81a8514de","chapter":{"id":"III","title":"视觉与语言"},"unit":{"id":"clip-pairing-to-candidates","title":"已知图文配对怎样变成可用的文字候选接口？"},"page":{"id":"reading-opening","title":"LAB 12 · CLIP延伸：缓存与检索（近似索引选读）","number":1},"sectionTitle":"LAB 12 · CLIP延伸：缓存与检索（近似索引选读）","currentQuestion":"LAB 12 · CLIP延伸：缓存与检索（近似索引选读）","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-3d55d0054ae6a421b81adc66","nextBlock":"b-951aec5456867014dd710468","prerequisites":[{"id":"b-09c5574dc6334bcbb7336ba7","url":"#b-09c5574dc6334bcbb7336ba7","role":"section-title"},{"id":"b-3d55d0054ae6a421b81adc66","url":"#b-3d55d0054ae6a421b81adc66","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-951aec5456867014dd710468","type":"p","scope":"document","url":"https://codingai-lec03.pages.dev/course/notebooks/921eeaf784284ce19568c6ca7619b55a.html#b-951aec5456867014dd710468","content":"可先阅读已有结果，再决定是否运行。重算时请核对各节记录的数据、参数、环境与日期。","sha256":"f22152fd55dcdb0090b5653d37145694fd19388d31e10226549464fe8b483578","chapter":{"id":"III","title":"视觉与语言"},"unit":{"id":"clip-pairing-to-candidates","title":"已知图文配对怎样变成可用的文字候选接口？"},"page":{"id":"reading-opening","title":"LAB 12 · CLIP延伸：缓存与检索（近似索引选读）","number":1},"sectionTitle":"LAB 12 · CLIP延伸：缓存与检索（近似索引选读）","currentQuestion":"LAB 12 · CLIP延伸：缓存与检索（近似索引选读）","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-79d4bc4a4bc3492c8350ad81","nextBlock":"b-6f6340bb26e19d21c1755b1d","prerequisites":[{"id":"b-09c5574dc6334bcbb7336ba7","url":"#b-09c5574dc6334bcbb7336ba7","role":"section-title"},{"id":"b-3d55d0054ae6a421b81adc66","url":"#b-3d55d0054ae6a421b81adc66","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-6f6340bb26e19d21c1755b1d","type":"p","scope":"block-51c1a716f8564c5184d501805db714e9","url":"https://codingai-lec03.pages.dev/course/notebooks/921eeaf784284ce19568c6ca7619b55a.html#b-6f6340bb26e19d21c1755b1d","content":"**学习路径：** [文字候选与图文检索](/course/study/clip-retrieval.html)","sha256":"bab4bd804571aa5afbaf197e9c1539510fc766578c9825aa46cadbb18444cc32","chapter":{"id":"III","title":"视觉与语言"},"unit":{"id":"clip-pairing-to-candidates","title":"已知图文配对怎样变成可用的文字候选接口？"},"page":{"id":"reading-opening","title":"LAB 12 · CLIP延伸：缓存与检索（近似索引选读）","number":1},"sectionTitle":"LAB 12 · CLIP延伸：缓存与检索（近似索引选读）","currentQuestion":"LAB 12 · CLIP延伸：缓存与检索（近似索引选读）","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-951aec5456867014dd710468","nextBlock":"b-9acc65e77992f640b55527de","prerequisites":[{"id":"b-09c5574dc6334bcbb7336ba7","url":"#b-09c5574dc6334bcbb7336ba7","role":"section-title"},{"id":"b-3d55d0054ae6a421b81adc66","url":"#b-3d55d0054ae6a421b81adc66","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-9acc65e77992f640b55527de","type":"p","scope":"block-51c1a716f8564c5184d501805db714e9","url":"https://codingai-lec03.pages.dev/course/notebooks/921eeaf784284ce19568c6ca7619b55a.html#b-9acc65e77992f640b55527de","content":"这是[LAB 04](https://deepnote.com/project/38755e4e-23f6-4f5f-8c68-8a2e4114b1c1/notebook/0ba963931ddf4866b507b210d93a43bf)之后的检索分支：已有的CLIP向量怎样复用，返回哪一个ID又该怎样评价？先读[P59](/course/pages/l3-r2-p59.html)与[缓存接口](/course/blocks/retrieval-cache-interface.html)。","sha256":"5fbe114bcb870df3b0a22d360a98a599544e8d98166e2baab6796d9846c84725","chapter":{"id":"III","title":"视觉与语言"},"unit":{"id":"clip-pairing-to-candidates","title":"已知图文配对怎样变成可用的文字候选接口？"},"page":{"id":"reading-opening","title":"LAB 12 · CLIP延伸：缓存与检索（近似索引选读）","number":1},"sectionTitle":"LAB 12 · CLIP延伸：缓存与检索（近似索引选读）","currentQuestion":"LAB 12 · CLIP延伸：缓存与检索（近似索引选读）","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-6f6340bb26e19d21c1755b1d","nextBlock":"b-1a17098be4c49f4a50118677","prerequisites":[{"id":"b-09c5574dc6334bcbb7336ba7","url":"#b-09c5574dc6334bcbb7336ba7","role":"section-title"},{"id":"b-3d55d0054ae6a421b81adc66","url":"#b-3d55d0054ae6a421b81adc66","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-1a17098be4c49f4a50118677","type":"p","scope":"block-51c1a716f8564c5184d501805db714e9","url":"https://codingai-lec03.pages.dev/course/notebooks/921eeaf784284ce19568c6ca7619b55a.html#b-1a17098be4c49f4a50118677","content":"基础路线读第1节真实照片/缓存身份、第2节exact命中ID、第4节编码次数与内存。应能解释同一查询的Hit、Recall和exact重合率各在问什么，留下查询、相关集合、K及命中ID，而不只记平均分。","sha256":"3ac767754b4f134bba4821d4304d9450b1a03cc82aaf44073413740cbfd449aa","chapter":{"id":"III","title":"视觉与语言"},"unit":{"id":"clip-pairing-to-candidates","title":"已知图文配对怎样变成可用的文字候选接口？"},"page":{"id":"reading-opening","title":"LAB 12 · CLIP延伸：缓存与检索（近似索引选读）","number":1},"sectionTitle":"LAB 12 · CLIP延伸：缓存与检索（近似索引选读）","currentQuestion":"LAB 12 · CLIP延伸：缓存与检索（近似索引选读）","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-9acc65e77992f640b55527de","nextBlock":"b-7569d7b69e3251230de88435","prerequisites":[{"id":"b-09c5574dc6334bcbb7336ba7","url":"#b-09c5574dc6334bcbb7336ba7","role":"section-title"},{"id":"b-3d55d0054ae6a421b81adc66","url":"#b-3d55d0054ae6a421b81adc66","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-7569d7b69e3251230de88435","type":"p","scope":"block-51c1a716f8564c5184d501805db714e9","url":"https://codingai-lec03.pages.dev/course/notebooks/921eeaf784284ce19568c6ca7619b55a.html#b-7569d7b69e3251230de88435","content":"二维向量只是热身；主体使用2026-09-22保存的24×512图像向量与12×512查询向量。默认读取并核验缓存，不重新运行CLIP编码器。首次材料下载仍需网络；改变图片或查询文字才需重算对应编码。","sha256":"a315e05d1f004b11ff9c24607a524c3ba290695efbdf9fc1f8c6f4b5d3b8a42d","chapter":{"id":"III","title":"视觉与语言"},"unit":{"id":"clip-pairing-to-candidates","title":"已知图文配对怎样变成可用的文字候选接口？"},"page":{"id":"reading-opening","title":"LAB 12 · CLIP延伸：缓存与检索（近似索引选读）","number":1},"sectionTitle":"LAB 12 · CLIP延伸：缓存与检索（近似索引选读）","currentQuestion":"LAB 12 · CLIP延伸：缓存与检索（近似索引选读）","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-1a17098be4c49f4a50118677","nextBlock":"b-93783cec8b332f6e671a11a0","prerequisites":[{"id":"b-09c5574dc6334bcbb7336ba7","url":"#b-09c5574dc6334bcbb7336ba7","role":"section-title"},{"id":"b-3d55d0054ae6a421b81adc66","url":"#b-3d55d0054ae6a421b81adc66","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-93783cec8b332f6e671a11a0","type":"p","scope":"block-51c1a716f8564c5184d501805db714e9","url":"https://codingai-lec03.pages.dev/course/notebooks/921eeaf784284ce19568c6ca7619b55a.html#b-93783cec8b332f6e671a11a0","content":"第3节IVF和第5节区域加权是第八讲选读，保留完整可运行实现。阅读可按问题跳转，实际运行需按全部代码顺序，因第4节也读取第3节的索引变量。","sha256":"495443f171850cc5a7e353e9b66975fb4671b36198e5ab69cd02d4e8ecd080ae","chapter":{"id":"III","title":"视觉与语言"},"unit":{"id":"clip-pairing-to-candidates","title":"已知图文配对怎样变成可用的文字候选接口？"},"page":{"id":"reading-opening","title":"LAB 12 · CLIP延伸：缓存与检索（近似索引选读）","number":1},"sectionTitle":"LAB 12 · CLIP延伸：缓存与检索（近似索引选读）","currentQuestion":"LAB 12 · CLIP延伸：缓存与检索（近似索引选读）","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-7569d7b69e3251230de88435","nextBlock":"b-8c80db97c0b97c4951a6f0ec","prerequisites":[{"id":"b-09c5574dc6334bcbb7336ba7","url":"#b-09c5574dc6334bcbb7336ba7","role":"section-title"},{"id":"b-3d55d0054ae6a421b81adc66","url":"#b-3d55d0054ae6a421b81adc66","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-8c80db97c0b97c4951a6f0ec","type":"pre","scope":"block-4e6be52d45e84175a6f134439b154cd8","url":"https://codingai-lec03.pages.dev/course/notebooks/921eeaf784284ce19568c6ca7619b55a.html#b-8c80db97c0b97c4951a6f0ec","content":"```\n# 每次整册运行使用临时工作目录，保留项目旧文件与历史结果。\nimport os, tempfile\nL03_RUN_DIR=tempfile.mkdtemp(prefix=\"lecture03-lab12-\")\nos.chdir(L03_RUN_DIR)\nimport numpy as np\nI=np.array([[1,0],[0,1],[.8,.2]],float); T=np.array([[1,0],[0,1]],float); I/=np.linalg.norm(I,axis=1,keepdims=True); T/=np.linalg.norm(T,axis=1,keepdims=True)\nS=T@I.T; print('similarity\\n',S.round(3)); ranks=np.argsort(-S,axis=1); truth=[0,1]\nfor k in [1,2]: print('Recall@'+str(k),np.mean([truth[i] in ranks[i,:k] for i in range(2)]))\n```","sha256":"e03f64d6228373bf789a043218b6e0b79bfb3690f26045ed0469c9a91958de34","chapter":{"id":"III","title":"视觉与语言"},"unit":{"id":"clip-pairing-to-candidates","title":"已知图文配对怎样变成可用的文字候选接口？"},"page":{"id":"reading-opening","title":"LAB 12 · CLIP延伸：缓存与检索（近似索引选读）","number":1},"sectionTitle":"LAB 12 · CLIP延伸：缓存与检索（近似索引选读）","currentQuestion":"LAB 12 · CLIP延伸：缓存与检索（近似索引选读）","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-93783cec8b332f6e671a11a0","nextBlock":"b-d44576e764a915c04f1228d7","prerequisites":[{"id":"b-09c5574dc6334bcbb7336ba7","url":"#b-09c5574dc6334bcbb7336ba7","role":"section-title"},{"id":"b-3d55d0054ae6a421b81adc66","url":"#b-3d55d0054ae6a421b81adc66","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-d44576e764a915c04f1228d7","type":"p","scope":"block-f54d70a0d5e4428a9b2af782ef04561d","url":"https://codingai-lec03.pages.dev/course/notebooks/921eeaf784284ce19568c6ca7619b55a.html#b-d44576e764a915c04f1228d7","content":"热身里每个查询只有一个指定正例，`truth=[0,1]`，因此“该正例是否进入前 K”的均值可称单正例 Recall@K。第三张向量与第一张接近，但不是指定正例；相似性与评价标注是两件事。真实图集中同一照片有四个关联裁剪，后面采用 Hit@K 和 exact 邻居重合率，避免把多正例情形继续不加说明地称为同一种 Recall。","sha256":"12ceba147ef6dd56c8b723f733b3413face0fb8553a2d2532308176a4f4f306a","chapter":{"id":"III","title":"视觉与语言"},"unit":{"id":"clip-pairing-to-candidates","title":"已知图文配对怎样变成可用的文字候选接口？"},"page":{"id":"reading-opening","title":"LAB 12 · CLIP延伸：缓存与检索（近似索引选读）","number":1},"sectionTitle":"LAB 12 · CLIP延伸：缓存与检索（近似索引选读）","currentQuestion":"LAB 12 · CLIP延伸：缓存与检索（近似索引选读）","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-8c80db97c0b97c4951a6f0ec","nextBlock":null,"prerequisites":[{"id":"b-09c5574dc6334bcbb7336ba7","url":"#b-09c5574dc6334bcbb7336ba7","role":"section-title"},{"id":"b-3d55d0054ae6a421b81adc66","url":"#b-3d55d0054ae6a421b81adc66","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-ee87ca54084d0f7e88fbc4ab","type":"h2","scope":"block-687d09fc176e4c64a0bf836efcbe03f1","url":"https://codingai-lec03.pages.dev/course/notebooks/921eeaf784284ce19568c6ca7619b55a.html#b-ee87ca54084d0f7e88fbc4ab","content":"## 1 · 输入、来源、编码和缓存身份","sha256":"c55c81a2779d4884d73f8f9239637e8601ad2a671e8bfa4b1b0eaf733ce8c149","chapter":{"id":"III","title":"视觉与语言"},"unit":{"id":"clip-pairing-to-candidates","title":"已知图文配对怎样变成可用的文字候选接口？"},"page":{"id":"reading-block-687d09fc176e4c64a0bf836efcbe03f1","title":"1 · 输入、来源、编码和缓存身份","number":2},"sectionTitle":"1 · 输入、来源、编码和缓存身份","currentQuestion":"1 · 输入、来源、编码和缓存身份","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":null,"nextBlock":"b-9049833a99d52211da7c5277","prerequisites":[{"id":"b-9049833a99d52211da7c5277","url":"#b-9049833a99d52211da7c5277","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-9049833a99d52211da7c5277","type":"p","scope":"block-687d09fc176e4c64a0bf836efcbe03f1","url":"https://codingai-lec03.pages.dev/course/notebooks/921eeaf784284ce19568c6ca7619b55a.html#b-9049833a99d52211da7c5277","content":"六张照片来自 scikit-image 0.25.2：Chelsea 猫（Stefan van der Walt，CC0）、宇航员（NASA，公共领域）、咖啡（Rachel Michetti，CC0）、摄影者（Lav Varshney，CC0）、火箭（SpaceX，公共领域）和星系深场（NASA，公共领域）。原始照片、授权说明、逐文件 SHA-256 均在 `assets/manifest.json`。每张图生成 full、center90、left90、right90 四个确定性视图，共 24 个索引项。每类有两条人工写定查询，共 12 条。","sha256":"a4760dc5c790d3551a0886f0b7e4afeba240e6e6546433a75593c9ee8ca2fc79","chapter":{"id":"III","title":"视觉与语言"},"unit":{"id":"clip-pairing-to-candidates","title":"已知图文配对怎样变成可用的文字候选接口？"},"page":{"id":"reading-block-687d09fc176e4c64a0bf836efcbe03f1","title":"1 · 输入、来源、编码和缓存身份","number":2},"sectionTitle":"1 · 输入、来源、编码和缓存身份","currentQuestion":"1 · 输入、来源、编码和缓存身份","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-ee87ca54084d0f7e88fbc4ab","nextBlock":"b-b7eff3e7394064817090410b","prerequisites":[{"id":"b-ee87ca54084d0f7e88fbc4ab","url":"#b-ee87ca54084d0f7e88fbc4ab","role":"section-title"}],"relatedBlocks":[]},{"id":"b-b7eff3e7394064817090410b","type":"p","scope":"block-687d09fc176e4c64a0bf836efcbe03f1","url":"https://codingai-lec03.pages.dev/course/notebooks/921eeaf784284ce19568c6ca7619b55a.html#b-b7eff3e7394064817090410b","content":"四个视图来自同一张图，彼此高度相关；这里没有训练／测试拆分，因为没有拟合视觉模型。它们用来观察索引分桶与排序，不是 24 张独立测试照片，更不是六类泛化性能评估。聚类训练只拟合无监督检索索引，不会重新训练 CLIP。","sha256":"40758dc2b27ab13a7646c5b5af382412086396de48f6a362d0c866ac461a59b6","chapter":{"id":"III","title":"视觉与语言"},"unit":{"id":"clip-pairing-to-candidates","title":"已知图文配对怎样变成可用的文字候选接口？"},"page":{"id":"reading-block-687d09fc176e4c64a0bf836efcbe03f1","title":"1 · 输入、来源、编码和缓存身份","number":2},"sectionTitle":"1 · 输入、来源、编码和缓存身份","currentQuestion":"1 · 输入、来源、编码和缓存身份","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-9049833a99d52211da7c5277","nextBlock":"b-2456f658291ad30498fff812","prerequisites":[{"id":"b-ee87ca54084d0f7e88fbc4ab","url":"#b-ee87ca54084d0f7e88fbc4ab","role":"section-title"},{"id":"b-9049833a99d52211da7c5277","url":"#b-9049833a99d52211da7c5277","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-2456f658291ad30498fff812","type":"p","scope":"block-687d09fc176e4c64a0bf836efcbe03f1","url":"https://codingai-lec03.pages.dev/course/notebooks/921eeaf784284ce19568c6ca7619b55a.html#b-2456f658291ad30498fff812","content":"![六张真实照片组成的小图库](/assets/display/61b4b65c7be015d923cad24b.webp)","sha256":"a19555b36c40f361b20577ae383941cce9382473f9a009a407ecc3e394e25645","chapter":{"id":"III","title":"视觉与语言"},"unit":{"id":"clip-pairing-to-candidates","title":"已知图文配对怎样变成可用的文字候选接口？"},"page":{"id":"reading-block-687d09fc176e4c64a0bf836efcbe03f1","title":"1 · 输入、来源、编码和缓存身份","number":2},"sectionTitle":"1 · 输入、来源、编码和缓存身份","currentQuestion":"1 · 输入、来源、编码和缓存身份","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-b7eff3e7394064817090410b","nextBlock":"b-779a1579922eacc7799c441b","prerequisites":[{"id":"b-ee87ca54084d0f7e88fbc4ab","url":"#b-ee87ca54084d0f7e88fbc4ab","role":"section-title"},{"id":"b-9049833a99d52211da7c5277","url":"#b-9049833a99d52211da7c5277","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-779a1579922eacc7799c441b","type":"p","scope":"block-687d09fc176e4c64a0bf836efcbe03f1","url":"https://codingai-lec03.pages.dev/course/notebooks/921eeaf784284ce19568c6ca7619b55a.html#b-779a1579922eacc7799c441b","content":"真实编码在 2026-09-22 本地 CPU 运行。图像和文字预处理、checkpoint revision 和哈希与 LAB 04 相同；512 维特征分别做 L2 归一化，缓存为 float32。`gallery` shape 为 `[24,512]`，`queries` 为 `[12,512]`。直接把旧猫图四个分数拼成“图像向量”是不合法的：当前包保存的是实际编码器的完整输出。","sha256":"5748751d5292c3aa044b6275be2ca22516edcf83bd727d34669cfe3f93e3aeb8","chapter":{"id":"III","title":"视觉与语言"},"unit":{"id":"clip-pairing-to-candidates","title":"已知图文配对怎样变成可用的文字候选接口？"},"page":{"id":"reading-block-687d09fc176e4c64a0bf836efcbe03f1","title":"1 · 输入、来源、编码和缓存身份","number":2},"sectionTitle":"1 · 输入、来源、编码和缓存身份","currentQuestion":"1 · 输入、来源、编码和缓存身份","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-2456f658291ad30498fff812","nextBlock":"b-e79516936f50a7bebd4cab49","prerequisites":[{"id":"b-ee87ca54084d0f7e88fbc4ab","url":"#b-ee87ca54084d0f7e88fbc4ab","role":"section-title"},{"id":"b-9049833a99d52211da7c5277","url":"#b-9049833a99d52211da7c5277","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-e79516936f50a7bebd4cab49","type":"p","scope":"block-687d09fc176e4c64a0bf836efcbe03f1","url":"https://codingai-lec03.pages.dev/course/notebooks/921eeaf784284ce19568c6ca7619b55a.html#b-e79516936f50a7bebd4cab49","content":"[下载独立材料](/course/materials/lecture03-clip-retrieval.zip)。默认只需 `requirements-cache.txt`；完整重算编码需额外 `requirements-inference.txt`、`python fetch_clip.py` 和 `python run_clip_retrieval.py --encode`。缓存原始生成时间和当前读缓存的时间分开记录。","sha256":"6fbf90ab812717a1cc7048a95944cd7f5194e019c122acc2da4909b06ab55514","chapter":{"id":"III","title":"视觉与语言"},"unit":{"id":"clip-pairing-to-candidates","title":"已知图文配对怎样变成可用的文字候选接口？"},"page":{"id":"reading-block-687d09fc176e4c64a0bf836efcbe03f1","title":"1 · 输入、来源、编码和缓存身份","number":2},"sectionTitle":"1 · 输入、来源、编码和缓存身份","currentQuestion":"1 · 输入、来源、编码和缓存身份","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-779a1579922eacc7799c441b","nextBlock":"b-2e868ad8bd97c74d5a2cac48","prerequisites":[{"id":"b-ee87ca54084d0f7e88fbc4ab","url":"#b-ee87ca54084d0f7e88fbc4ab","role":"section-title"},{"id":"b-9049833a99d52211da7c5277","url":"#b-9049833a99d52211da7c5277","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-2e868ad8bd97c74d5a2cac48","type":"pre","scope":"block-0befde2587964e63937189481b9abcce","url":"https://codingai-lec03.pages.dev/course/notebooks/921eeaf784284ce19568c6ca7619b55a.html#b-2e868ad8bd97c74d5a2cac48","content":"```\n# 独立材料，不依赖另一册 notebook 的内存；重复运行复用本项目已下载内容。\nfrom pathlib import Path\nimport io, json, zipfile, requests, sys, hashlib\n_candidates=[Path.cwd()/'lecture03-clip-retrieval', Path.cwd()]\nRETRIEVAL_ROOT=next((p for p in _candidates if (p/'cache/clip-features.npz').exists()),None)\nif RETRIEVAL_ROOT is None:\n    _response=requests.get('https://codingai-lec03.pages.dev/course/materials/lecture03-clip-retrieval.zip',timeout=60)\n    _response.raise_for_status()\n    _data=_response.content\n    print('下载材料 ZIP:',len(_data),'bytes; SHA256',hashlib.sha256(_data).hexdigest())\n    with zipfile.ZipFile(io.BytesIO(_data)) as z:\n        for info in z.infolist():\n            target=(Path.cwd()/info.filename).resolve()\n            assert target.is_relative_to(Path.cwd().resolve()), '拒绝越界路径'\n            if info.is_dir():target.mkdir(parents=True,exist_ok=True)\n            elif not target.exists():\n                target.parent.mkdir(parents=True,exist_ok=True);target.write_bytes(z.read(info))\n    RETRIEVAL_ROOT=Path.cwd()/'lecture03-clip-retrieval'\nassert (RETRIEVAL_ROOT/'cache/provenance.json').is_file()\nsys.path.insert(0,str(RETRIEVAL_ROOT))\nimport run_clip_retrieval as cr\nimport numpy as np\np=json.loads((RETRIEVAL_ROOT/'cache/provenance.json').read_text())\nassert cr.sha(RETRIEVAL_ROOT/'cache/clip-features.npz')==p['cache_sha256']\nassert cr.sha(RETRIEVAL_ROOT/'assets/manifest.json')==p['manifest_sha256']\nmanifest=json.loads((RETRIEVAL_ROOT/'assets/manifest.json').read_text())\nfor r in manifest['gallery']+manifest['relation']+manifest['holder']:\n    assert cr.sha(RETRIEVAL_ROOT/r['path'])==r['sha256']\na=np.load(RETRIEVAL_ROOT/'cache/clip-features.npz')\nprint('已核验真实 CLIP 缓存；生成时间',p['generated_at_utc'])\nprint('本格只载入缓存，没有在当前 notebook 运行 CLIP 编码器。')\nprint('gallery, queries:',a['gallery'].shape,a['queries'].shape)\n\n```","sha256":"3d32c29794a1b985da1ce28a5c69a139c3d4040422600609c15a1f81f9536114","chapter":{"id":"III","title":"视觉与语言"},"unit":{"id":"clip-pairing-to-candidates","title":"已知图文配对怎样变成可用的文字候选接口？"},"page":{"id":"reading-block-687d09fc176e4c64a0bf836efcbe03f1","title":"1 · 输入、来源、编码和缓存身份","number":2},"sectionTitle":"1 · 输入、来源、编码和缓存身份","currentQuestion":"1 · 输入、来源、编码和缓存身份","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-e79516936f50a7bebd4cab49","nextBlock":null,"prerequisites":[{"id":"b-ee87ca54084d0f7e88fbc4ab","url":"#b-ee87ca54084d0f7e88fbc4ab","role":"section-title"},{"id":"b-9049833a99d52211da7c5277","url":"#b-9049833a99d52211da7c5277","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-579e43aac940fab8d1b90fb9","type":"h2","scope":"block-5ba73f2552e945a7a94eb9043c0ac480","url":"https://codingai-lec03.pages.dev/course/notebooks/921eeaf784284ce19568c6ca7619b55a.html#b-579e43aac940fab8d1b90fb9","content":"## 2 · 精确搜索：模型给分，评价定义相关","sha256":"6a6a7b78abfe6364f4ef040e54cd2bf106294e030c2d6a73dcdad1dd69ddfa24","chapter":{"id":"III","title":"视觉与语言"},"unit":{"id":"clip-pairing-to-candidates","title":"已知图文配对怎样变成可用的文字候选接口？"},"page":{"id":"reading-block-5ba73f2552e945a7a94eb9043c0ac480","title":"2 · 精确搜索：模型给分，评价定义相关","number":3},"sectionTitle":"2 · 精确搜索：模型给分，评价定义相关","currentQuestion":"2 · 精确搜索：模型给分，评价定义相关","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":null,"nextBlock":"b-fa10e6c8f9968ff5668628a4","prerequisites":[{"id":"b-fa10e6c8f9968ff5668628a4","url":"#b-fa10e6c8f9968ff5668628a4","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-fa10e6c8f9968ff5668628a4","type":"p","scope":"block-5ba73f2552e945a7a94eb9043c0ac480","url":"https://codingai-lec03.pages.dev/course/notebooks/921eeaf784284ce19568c6ca7619b55a.html#b-fa10e6c8f9968ff5668628a4","content":"对于一个文本查询 $q$，精确检索逐个计算 $s_i=q^\\top v_i$ 并取最大的 K 项。归一化不等于校准：cosine 只是排序分数，不是“该图片正确的概率”。同一矩阵转置即可图搜文；不需要另训练一个模型，但两个方向的候选集合和评价单位不同。","sha256":"a9db9edd976ff657caa5941b4245c0b52971ebde344e66c024f0e5ab01b0401f","chapter":{"id":"III","title":"视觉与语言"},"unit":{"id":"clip-pairing-to-candidates","title":"已知图文配对怎样变成可用的文字候选接口？"},"page":{"id":"reading-block-5ba73f2552e945a7a94eb9043c0ac480","title":"2 · 精确搜索：模型给分，评价定义相关","number":3},"sectionTitle":"2 · 精确搜索：模型给分，评价定义相关","currentQuestion":"2 · 精确搜索：模型给分，评价定义相关","sourceSlides":[],"knowledgeBlock":null,"formulas":[{"latex":"q","definitionContext":"2 · 精确搜索：模型给分，评价定义相关"},{"latex":"s_i=q^\\top v_i","definitionContext":"2 · 精确搜索：模型给分，评价定义相关"}],"previousBlock":"b-579e43aac940fab8d1b90fb9","nextBlock":"b-5270ffb2732a576390781e57","prerequisites":[{"id":"b-579e43aac940fab8d1b90fb9","url":"#b-579e43aac940fab8d1b90fb9","role":"section-title"}],"relatedBlocks":[]},{"id":"b-5270ffb2732a576390781e57","type":"p","scope":"block-5ba73f2552e945a7a94eb9043c0ac480","url":"https://codingai-lec03.pages.dev/course/notebooks/921eeaf784284ce19568c6ca7619b55a.html#b-5270ffb2732a576390781e57","content":"本册规定：一个查询对应源类别的四个视图都算相关。**语义 Hit@K** 为“前 K 中至少有一个相关图”的查询比例；它不等于召回全部四个相关图的比例。**ANN top-3 overlap** 为 $|A_3(q)\\cap E_3(q)|/3$ 的平均值，评价近似索引是否找回精确搜索的邻居，完全不使用类别标签。这两项必须分开：模型的精确排序可能错，ANN 也可能完美复制这个错误。","sha256":"6981901db7db96134fa7095db2336567bb8c37f0f76f8e294f664880fb8c1808","chapter":{"id":"III","title":"视觉与语言"},"unit":{"id":"clip-pairing-to-candidates","title":"已知图文配对怎样变成可用的文字候选接口？"},"page":{"id":"reading-block-5ba73f2552e945a7a94eb9043c0ac480","title":"2 · 精确搜索：模型给分，评价定义相关","number":3},"sectionTitle":"2 · 精确搜索：模型给分，评价定义相关","currentQuestion":"2 · 精确搜索：模型给分，评价定义相关","sourceSlides":[],"knowledgeBlock":null,"formulas":[{"latex":"|A_3(q)\\cap E_3(q)|/3","definitionContext":"2 · 精确搜索：模型给分，评价定义相关"}],"previousBlock":"b-fa10e6c8f9968ff5668628a4","nextBlock":"b-91b776a6ad6907586eeb5ad6","prerequisites":[{"id":"b-579e43aac940fab8d1b90fb9","url":"#b-579e43aac940fab8d1b90fb9","role":"section-title"},{"id":"b-fa10e6c8f9968ff5668628a4","url":"#b-fa10e6c8f9968ff5668628a4","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-91b776a6ad6907586eeb5ad6","type":"p","scope":"block-5ba73f2552e945a7a94eb9043c0ac480","url":"https://codingai-lec03.pages.dev/course/notebooks/921eeaf784284ce19568c6ca7619b55a.html#b-91b776a6ad6907586eeb5ad6","content":"当前小集 exact 文搜图 Hit@3=1.0、图搜文 Hit@1=1.0。它只能说明这些照片和查询能被本模型匹配，不能支持未知照片或复杂关系的泛化结论。LAB 04 的左右关系反例正好显示：整图对象匹配成功不自动推出关系绑定正确。","sha256":"aa8be1410199fba8c51caa638e575eceda30ec6f40f30bbfa56b0107d8f9e20f","chapter":{"id":"III","title":"视觉与语言"},"unit":{"id":"clip-pairing-to-candidates","title":"已知图文配对怎样变成可用的文字候选接口？"},"page":{"id":"reading-block-5ba73f2552e945a7a94eb9043c0ac480","title":"2 · 精确搜索：模型给分，评价定义相关","number":3},"sectionTitle":"2 · 精确搜索：模型给分，评价定义相关","currentQuestion":"2 · 精确搜索：模型给分，评价定义相关","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-5270ffb2732a576390781e57","nextBlock":"b-8d3641714f9c1ea4d777502c","prerequisites":[{"id":"b-579e43aac940fab8d1b90fb9","url":"#b-579e43aac940fab8d1b90fb9","role":"section-title"},{"id":"b-fa10e6c8f9968ff5668628a4","url":"#b-fa10e6c8f9968ff5668628a4","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-8d3641714f9c1ea4d777502c","type":"pre","scope":"block-e05d4164e12144fea000c0bf4d6b7e2f","url":"https://codingai-lec03.pages.dev/course/notebooks/921eeaf784284ce19568c6ca7619b55a.html#b-8d3641714f9c1ea4d777502c","content":"```\nX,Q=a['gallery'],a['queries']\nassert np.allclose(np.linalg.norm(X,axis=1),1,atol=2e-6)\nlabels=np.array([r['label'] for r in manifest['gallery']])\ntruth=[r['label'] for r in manifest['queries']]\nS=Q@X.T\nexact=np.stack([cr.stable_rank(row,k=3) for row in S])\nfor i,row in enumerate(exact):\n    print(manifest['queries'][i]['text'],'->',[(manifest['gallery'][j]['id'],round(float(S[i,j]),4)) for j in row])\nhit3=np.mean([any(labels[j]==truth[i] for j in row) for i,row in enumerate(exact)])\nprint('exact semantic Hit@3:',hit3)\n# 反方向：每张图对 12 条文字排序。每类有两条同义候选。\ni2t=np.stack([cr.stable_rank(row,k=1) for row in S.T])\nprint('image-to-text Hit@1:',np.mean([truth[row[0]]==labels[i] for i,row in enumerate(i2t)]))\n\n```","sha256":"00533db81ffa311ed8f37086e435877c01dd22b52775e5759abb88c9252bc0aa","chapter":{"id":"III","title":"视觉与语言"},"unit":{"id":"clip-pairing-to-candidates","title":"已知图文配对怎样变成可用的文字候选接口？"},"page":{"id":"reading-block-5ba73f2552e945a7a94eb9043c0ac480","title":"2 · 精确搜索：模型给分，评价定义相关","number":3},"sectionTitle":"2 · 精确搜索：模型给分，评价定义相关","currentQuestion":"2 · 精确搜索：模型给分，评价定义相关","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-91b776a6ad6907586eeb5ad6","nextBlock":null,"prerequisites":[{"id":"b-579e43aac940fab8d1b90fb9","url":"#b-579e43aac940fab8d1b90fb9","role":"section-title"},{"id":"b-fa10e6c8f9968ff5668628a4","url":"#b-fa10e6c8f9968ff5668628a4","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-b82148cf1e8fd794d84d747e","type":"h2","scope":"block-62a7fe6e03324fd9877c139c11e4ce0e","url":"https://codingai-lec03.pages.dev/course/notebooks/921eeaf784284ce19568c6ca7619b55a.html#b-b82148cf1e8fd794d84d747e","content":"## 3 · 实际的近似索引：先路由到簇，再在簇内精排","sha256":"72042c5a397268efdedab711c30b3be6e811dbf705389989de882bfab7e7565c","chapter":{"id":"III","title":"视觉与语言"},"unit":{"id":"clip-pairing-to-candidates","title":"已知图文配对怎样变成可用的文字候选接口？"},"page":{"id":"reading-block-62a7fe6e03324fd9877c139c11e4ce0e","title":"3 · 实际的近似索引：先路由到簇，再在簇内精排","number":4},"sectionTitle":"3 · 实际的近似索引：先路由到簇，再在簇内精排","currentQuestion":"3 · 实际的近似索引：先路由到簇，再在簇内精排","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":null,"nextBlock":"b-e0a25749c7f44b485203a39d","prerequisites":[{"id":"b-e0a25749c7f44b485203a39d","url":"#b-e0a25749c7f44b485203a39d","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-e0a25749c7f44b485203a39d","type":"p","scope":"block-62a7fe6e03324fd9877c139c11e4ce0e","url":"https://codingai-lec03.pages.dev/course/notebooks/921eeaf784284ce19568c6ca7619b55a.html#b-e0a25749c7f44b485203a39d","content":"本实验实现 IVF-Flat，而不只是打印一个标为 ANN 的 Recall。首先对归一化图像特征做固定 seed=17 的 spherical k-means，得到 8 个中心；每张图分配到 cosine 最大的中心，倒排表保存该簇内真实图片 ID。查询时先计算到 8 个中心的分数，只打开最近的 `nprobe` 个簇，然后对候选图片的原 float32 向量计算精确 cosine 并排序。","sha256":"e912abb9cf15500ad588e974eab6aaf8e3a3dbfb4a3289c72d0cebe6988f1272","chapter":{"id":"III","title":"视觉与语言"},"unit":{"id":"clip-pairing-to-candidates","title":"已知图文配对怎样变成可用的文字候选接口？"},"page":{"id":"reading-block-62a7fe6e03324fd9877c139c11e4ce0e","title":"3 · 实际的近似索引：先路由到簇，再在簇内精排","number":4},"sectionTitle":"3 · 实际的近似索引：先路由到簇，再在簇内精排","currentQuestion":"3 · 实际的近似索引：先路由到簇，再在簇内精排","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-b82148cf1e8fd794d84d747e","nextBlock":"b-6b8263136157f9bceccaa3db","prerequisites":[{"id":"b-b82148cf1e8fd794d84d747e","url":"#b-b82148cf1e8fd794d84d747e","role":"section-title"}],"relatedBlocks":[]},{"id":"b-6b8263136157f9bceccaa3db","type":"p","scope":"block-62a7fe6e03324fd9877c139c11e4ce0e","url":"https://codingai-lec03.pages.dev/course/notebooks/921eeaf784284ce19568c6ca7619b55a.html#b-6b8263136157f9bceccaa3db","content":"近似发生在“哪些簇被打开”，不是候选内部的打分。一个本来应在 exact 前三的图只要被放进未打开的簇，就可能漏检。`nprobe` 增大通常减少这种遗漏，但候选扫描增多；当 `nprobe=8` 时所有桶都打开，应恢复 exact 的相同排名。本例以图片 ID 作为相同分数的固定次序，避免把平分的排序差异误认为近似错误。","sha256":"6f11c5e11524e032f183e4cb3071fb0773bf2a4e4ec7c99fc8f90f22962ea858","chapter":{"id":"III","title":"视觉与语言"},"unit":{"id":"clip-pairing-to-candidates","title":"已知图文配对怎样变成可用的文字候选接口？"},"page":{"id":"reading-block-62a7fe6e03324fd9877c139c11e4ce0e","title":"3 · 实际的近似索引：先路由到簇，再在簇内精排","number":4},"sectionTitle":"3 · 实际的近似索引：先路由到簇，再在簇内精排","currentQuestion":"3 · 实际的近似索引：先路由到簇，再在簇内精排","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-e0a25749c7f44b485203a39d","nextBlock":"b-825b2123d939ab71901236e0","prerequisites":[{"id":"b-b82148cf1e8fd794d84d747e","url":"#b-b82148cf1e8fd794d84d747e","role":"section-title"},{"id":"b-e0a25749c7f44b485203a39d","url":"#b-e0a25749c7f44b485203a39d","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-825b2123d939ab71901236e0","type":"p","scope":"block-62a7fe6e03324fd9877c139c11e4ce0e","url":"https://codingai-lec03.pages.dev/course/notebooks/921eeaf784284ce19568c6ca7619b55a.html#b-825b2123d939ab71901236e0","content":"下面是真正参与当前实验的聚类代码；完整脚本还有文件核验、向量缓存和结果保存。","sha256":"17197a3b41b63d107be94a74b22c9ae450a89fee34051c2caca715be92157969","chapter":{"id":"III","title":"视觉与语言"},"unit":{"id":"clip-pairing-to-candidates","title":"已知图文配对怎样变成可用的文字候选接口？"},"page":{"id":"reading-block-62a7fe6e03324fd9877c139c11e4ce0e","title":"3 · 实际的近似索引：先路由到簇，再在簇内精排","number":4},"sectionTitle":"3 · 实际的近似索引：先路由到簇，再在簇内精排","currentQuestion":"3 · 实际的近似索引：先路由到簇，再在簇内精排","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-6b8263136157f9bceccaa3db","nextBlock":"b-cafee496d19706ca0c9ccfaf","prerequisites":[{"id":"b-b82148cf1e8fd794d84d747e","url":"#b-b82148cf1e8fd794d84d747e","role":"section-title"},{"id":"b-e0a25749c7f44b485203a39d","url":"#b-e0a25749c7f44b485203a39d","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-cafee496d19706ca0c9ccfaf","type":"pre","scope":"block-645d32ebb74d4ed68f805e40027fb013","url":"https://codingai-lec03.pages.dev/course/notebooks/921eeaf784284ce19568c6ca7619b55a.html#b-cafee496d19706ca0c9ccfaf","content":"```\nunit=cr.unit\ndef spherical_kmeans(X,nlist=8,seed=17,iterations=40):\n    rng=np.random.default_rng(seed)\n    centers=X[rng.choice(len(X),nlist,replace=False)].copy()\n    for _ in range(iterations):\n        ids=(X@centers.T).argmax(1)\n        new=np.stack([unit(X[ids==i].mean(0,keepdims=True))[0] if np.any(ids==i) else centers[i] for i in range(nlist)])\n        if np.allclose(new,centers,atol=1e-7):break\n        centers=new\n    ids=(X@centers.T).argmax(1)\n    return centers,[np.flatnonzero(ids==i) for i in range(nlist)]\n\ncenters,lists=spherical_kmeans(X,nlist=8,seed=17)\ndef ivf_search(q,nprobe,k=3):\n    buckets=cr.stable_rank(q@centers.T,k=nprobe)\n    candidates=np.concatenate([lists[int(b)] for b in buckets])\n    ranked=cr.stable_rank(q@X[candidates].T,ids=candidates,k=k)\n    return ranked,candidates\nfor nprobe in [1,2,4,8]:\n    answer=[ivf_search(q,nprobe) for q in Q]\n    overlap=np.mean([len(set(e)&set(r))/3 for e,(r,c) in zip(exact,answer)])\n    hit=np.mean([any(labels[j]==truth[i] for j in r) for i,(r,c) in enumerate(answer)])\n    print('nprobe',nprobe,'mean scanned',np.mean([len(c) for r,c in answer]),'overlap',overlap,'Hit@3',hit)\n    if nprobe==8:assert all(np.array_equal(e,r) for e,(r,c) in zip(exact,answer))\n# 逐项找出 nprobe=1 的遗漏，不只看一个平均分。\nfor i,q in enumerate(Q):\n    ranked,candidates=ivf_search(q,1)\n    missing=sorted(set(exact[i])-set(ranked))\n    if missing:\n        print('query:',manifest['queries'][i]['text'])\n        print('missed exact neighbors:',[manifest['gallery'][j]['id'] for j in missing])\n\n```","sha256":"03548e94c27e646b9073eeed385278bb117959dca4e57b428eeb514af543181c","chapter":{"id":"III","title":"视觉与语言"},"unit":{"id":"clip-pairing-to-candidates","title":"已知图文配对怎样变成可用的文字候选接口？"},"page":{"id":"reading-block-62a7fe6e03324fd9877c139c11e4ce0e","title":"3 · 实际的近似索引：先路由到簇，再在簇内精排","number":4},"sectionTitle":"3 · 实际的近似索引：先路由到簇，再在簇内精排","currentQuestion":"3 · 实际的近似索引：先路由到簇，再在簇内精排","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-825b2123d939ab71901236e0","nextBlock":"b-e9b1570dbf1dfc1d9a537ba9","prerequisites":[{"id":"b-b82148cf1e8fd794d84d747e","url":"#b-b82148cf1e8fd794d84d747e","role":"section-title"},{"id":"b-e0a25749c7f44b485203a39d","url":"#b-e0a25749c7f44b485203a39d","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-e9b1570dbf1dfc1d9a537ba9","type":"p","scope":"block-9a00ee8cea714be583e46603becc2e69","url":"https://codingai-lec03.pages.dev/course/notebooks/921eeaf784284ce19568c6ca7619b55a.html#b-e9b1570dbf1dfc1d9a537ba9","content":"**选读结果：近似索引，不是第三讲新增主讲段。**","sha256":"4199206c98f1400fd4f86b9a1b6859bfd6336b777ff8ee4644f10049430a0e81","chapter":{"id":"III","title":"视觉与语言"},"unit":{"id":"clip-pairing-to-candidates","title":"已知图文配对怎样变成可用的文字候选接口？"},"page":{"id":"reading-block-62a7fe6e03324fd9877c139c11e4ce0e","title":"3 · 实际的近似索引：先路由到簇，再在簇内精排","number":4},"sectionTitle":"3 · 实际的近似索引：先路由到簇，再在簇内精排","currentQuestion":"3 · 实际的近似索引：先路由到簇，再在簇内精排","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-cafee496d19706ca0c9ccfaf","nextBlock":"b-1ae09976a24db7b0ea62a03b","prerequisites":[{"id":"b-b82148cf1e8fd794d84d747e","url":"#b-b82148cf1e8fd794d84d747e","role":"section-title"},{"id":"b-e0a25749c7f44b485203a39d","url":"#b-e0a25749c7f44b485203a39d","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-1ae09976a24db7b0ea62a03b","type":"table","scope":"block-9a00ee8cea714be583e46603becc2e69","url":"https://codingai-lec03.pages.dev/course/notebooks/921eeaf784284ce19568c6ca7619b55a.html#b-1ae09976a24db7b0ea62a03b","content":"| 方法 | 平均扫描图片向量 | exact top-3 重合率 | 语义 Hit@3 | 12查询中位耗时 / p95，ms |\n| --- | --- | --- | --- | --- |\n| exact | 24 | 1.0000 | 1.0000 | 0.0456 / 0.0609 |\n| IVF nprobe=1 | 4.17 | 0.7778 | 1.0000 | 0.1016 / 0.1672 |\n| IVF nprobe=2 | 7.67 | 1.0000 | 1.0000 | 0.1084 / 0.2591 |\n| IVF nprobe=4 | 13.25 | 1.0000 | 1.0000 | 0.1185 / 0.1837 |\n| IVF nprobe=8 | 24.00 | 1.0000 | 1.0000 | 0.1370 / 0.2236 |","sha256":"19e1f4ed476f267b8d54876e0f38b9544dbd5efb15a13fa7844ca5e3c57b18fd","chapter":{"id":"III","title":"视觉与语言"},"unit":{"id":"clip-pairing-to-candidates","title":"已知图文配对怎样变成可用的文字候选接口？"},"page":{"id":"reading-block-62a7fe6e03324fd9877c139c11e4ce0e","title":"3 · 实际的近似索引：先路由到簇，再在簇内精排","number":4},"sectionTitle":"3 · 实际的近似索引：先路由到簇，再在簇内精排","currentQuestion":"3 · 实际的近似索引：先路由到簇，再在簇内精排","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"table":{"headers":["方法","平均扫描图片向量","exact top-3 重合率","语义 Hit@3","12查询中位耗时 / p95，ms"],"rows":[["方法","平均扫描图片向量","exact top-3 重合率","语义 Hit@3","12查询中位耗时 / p95，ms"],["exact","24","1.0000","1.0000","0.0456 / 0.0609"],["IVF nprobe=1","4.17","0.7778","1.0000","0.1016 / 0.1672"],["IVF nprobe=2","7.67","1.0000","1.0000","0.1084 / 0.2591"],["IVF nprobe=4","13.25","1.0000","1.0000","0.1185 / 0.1837"],["IVF nprobe=8","24.00","1.0000","1.0000","0.1370 / 0.2236"]]},"previousBlock":"b-e9b1570dbf1dfc1d9a537ba9","nextBlock":"b-6c6093d10b2ad81c96ba61d3","prerequisites":[{"id":"b-b82148cf1e8fd794d84d747e","url":"#b-b82148cf1e8fd794d84d747e","role":"section-title"},{"id":"b-e0a25749c7f44b485203a39d","url":"#b-e0a25749c7f44b485203a39d","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-6c6093d10b2ad81c96ba61d3","type":"p","scope":"block-9a00ee8cea714be583e46603becc2e69","url":"https://codingai-lec03.pages.dev/course/notebooks/921eeaf784284ce19568c6ca7619b55a.html#b-6c6093d10b2ad81c96ba61d3","content":"这是2026-09-22 本地 CPU 的保存实测，不是解析复杂度。NumPy 2.3.5，单 BLAS 线程；每个样本点运行全部 12 查询，预热 20 次，测量 100 次。计时包括 Python 循环、路由、候选抽取和排序，排除磁盘读写、编码和索引构建。完整 BLAS 信息及索引构建时间见 `verified/retrieval-results.json`。","sha256":"deb1e19b802e3c9a8340b7f6c73704f55fd26daae1b19a560c7e056ce1a3d9e2","chapter":{"id":"III","title":"视觉与语言"},"unit":{"id":"clip-pairing-to-candidates","title":"已知图文配对怎样变成可用的文字候选接口？"},"page":{"id":"reading-block-62a7fe6e03324fd9877c139c11e4ce0e","title":"3 · 实际的近似索引：先路由到簇，再在簇内精排","number":4},"sectionTitle":"3 · 实际的近似索引：先路由到簇，再在簇内精排","currentQuestion":"3 · 实际的近似索引：先路由到簇，再在簇内精排","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-1ae09976a24db7b0ea62a03b","nextBlock":"b-b0cf1dd140261eddd737bc03","prerequisites":[{"id":"b-b82148cf1e8fd794d84d747e","url":"#b-b82148cf1e8fd794d84d747e","role":"section-title"},{"id":"b-e0a25749c7f44b485203a39d","url":"#b-e0a25749c7f44b485203a39d","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-b0cf1dd140261eddd737bc03","type":"p","scope":"block-9a00ee8cea714be583e46603becc2e69","url":"https://codingai-lec03.pages.dev/course/notebooks/921eeaf784284ce19568c6ca7619b55a.html#b-b0cf1dd140261eddd737bc03","content":"`nprobe=1` 的 exact 邻居重合率只有 0.7778，但语义 Hit@3 仍是 1：有些同源裁剪被漏掉，仍有另一个正确类别裁剪留下。这直接说明两种指标回答不同问题。`nprobe=2` 在这个小集恢复全部 exact 前三；它不保证其他数据也如此。","sha256":"f800f03ae61070290c48f513109f46c73596c6752c4ce0097251d87c426a99d0","chapter":{"id":"III","title":"视觉与语言"},"unit":{"id":"clip-pairing-to-candidates","title":"已知图文配对怎样变成可用的文字候选接口？"},"page":{"id":"reading-block-62a7fe6e03324fd9877c139c11e4ce0e","title":"3 · 实际的近似索引：先路由到簇，再在簇内精排","number":4},"sectionTitle":"3 · 实际的近似索引：先路由到簇，再在簇内精排","currentQuestion":"3 · 实际的近似索引：先路由到簇，再在簇内精排","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-6c6093d10b2ad81c96ba61d3","nextBlock":"b-838054192e5a745672187995","prerequisites":[{"id":"b-b82148cf1e8fd794d84d747e","url":"#b-b82148cf1e8fd794d84d747e","role":"section-title"},{"id":"b-e0a25749c7f44b485203a39d","url":"#b-e0a25749c7f44b485203a39d","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-838054192e5a745672187995","type":"p","scope":"block-9a00ee8cea714be583e46603becc2e69","url":"https://codingai-lec03.pages.dev/course/notebooks/921eeaf784284ce19568c6ca7619b55a.html#b-838054192e5a745672187995","content":"所有 ANN 配置都比 exact 慢，因为图库仅 24 项，矩阵点积太便宜，Python 桶访问和排序开销更突出。扫描数下降并不自动意味着延迟下降。共享CPU的调度也会影响这些微小耗时。大库里是否更快必须再测；不得把此处计算次数乘一个任意常数作为“毫秒”。","sha256":"1ddf1e6f4a92876b964902f2f6ed34917b02a0822b4f77a25e14c3e0b6358d91","chapter":{"id":"III","title":"视觉与语言"},"unit":{"id":"clip-pairing-to-candidates","title":"已知图文配对怎样变成可用的文字候选接口？"},"page":{"id":"reading-block-62a7fe6e03324fd9877c139c11e4ce0e","title":"3 · 实际的近似索引：先路由到簇，再在簇内精排","number":4},"sectionTitle":"3 · 实际的近似索引：先路由到簇，再在簇内精排","currentQuestion":"3 · 实际的近似索引：先路由到簇，再在簇内精排","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-b0cf1dd140261eddd737bc03","nextBlock":null,"prerequisites":[{"id":"b-b82148cf1e8fd794d84d747e","url":"#b-b82148cf1e8fd794d84d747e","role":"section-title"},{"id":"b-e0a25749c7f44b485203a39d","url":"#b-e0a25749c7f44b485203a39d","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-04c06e9bddb06cfe81993f70","type":"h2","scope":"block-304aa2a46d41405db647924c1a08d5c0","url":"https://codingai-lec03.pages.dev/course/notebooks/921eeaf784284ce19568c6ca7619b55a.html#b-04c06e9bddb06cfe81993f70","content":"## 4 · 缓存节约什么，不能节约什么？","sha256":"cc34b1d8d96a4a8b5be556959bf607fe886b3e40109adebba891f9b6d77ccf4f","chapter":{"id":"III","title":"视觉与语言"},"unit":{"id":"clip-pairing-to-candidates","title":"已知图文配对怎样变成可用的文字候选接口？"},"page":{"id":"reading-block-304aa2a46d41405db647924c1a08d5c0","title":"4 · 缓存节约什么，不能节约什么？","number":5},"sectionTitle":"4 · 缓存节约什么，不能节约什么？","currentQuestion":"4 · 缓存节约什么，不能节约什么？","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":null,"nextBlock":"b-06d3ed33d793d28449787ad9","prerequisites":[{"id":"b-06d3ed33d793d28449787ad9","url":"#b-06d3ed33d793d28449787ad9","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-06d3ed33d793d28449787ad9","type":"p","scope":"block-304aa2a46d41405db647924c1a08d5c0","url":"https://codingai-lec03.pages.dev/course/notebooks/921eeaf784284ce19568c6ca7619b55a.html#b-06d3ed33d793d28449787ad9","content":"下表是同一 $N=24,Q=12,d=512$ 任务的解析工作量，不是把未执行的全部逐对编码写成实测。每次“样本编码”指一个图片或一条文字通过对应编码器；批处理调用可以一次处理多个样本，二者不相等。","sha256":"29de550b073aa289c5c63996c445f8ef9074e4112c55ccd3992e7ea786a72ca4","chapter":{"id":"III","title":"视觉与语言"},"unit":{"id":"clip-pairing-to-candidates","title":"已知图文配对怎样变成可用的文字候选接口？"},"page":{"id":"reading-block-304aa2a46d41405db647924c1a08d5c0","title":"4 · 缓存节约什么，不能节约什么？","number":5},"sectionTitle":"4 · 缓存节约什么，不能节约什么？","currentQuestion":"4 · 缓存节约什么，不能节约什么？","sourceSlides":[],"knowledgeBlock":null,"formulas":[{"latex":"N=24,Q=12,d=512","definitionContext":"4 · 缓存节约什么，不能节约什么？"}],"previousBlock":"b-04c06e9bddb06cfe81993f70","nextBlock":"b-27c5cc71c0b8fdf6c5321b15","prerequisites":[{"id":"b-04c06e9bddb06cfe81993f70","url":"#b-04c06e9bddb06cfe81993f70","role":"section-title"}],"relatedBlocks":[]},{"id":"b-27c5cc71c0b8fdf6c5321b15","type":"table","scope":"block-304aa2a46d41405db647924c1a08d5c0","url":"https://codingai-lec03.pages.dev/course/notebooks/921eeaf784284ce19568c6ca7619b55a.html#b-27c5cc71c0b8fdf6c5321b15","content":"| 组织方式 | 图像样本编码 | 文字样本编码 | 相似度计算 | 可复用内容 |\n| --- | --- | --- | --- | --- |\n| 每对都重编码 | 288 | 288 | 288 个512维点积 | 无 |\n| 双编码器缓存 | 24（入库一次） | 12 | 288 个512维点积 | 图像向量可跨查询复用 |\n| 新增一条查询 | 0 | 1 | exact为24个点积 | 原图像库不变 |\n| IVF nprobe=1 | 入库同上 | 查询同上 | 每查询8个中心点积+平均4.17个图片点积 | 中心、倒排表、图片向量 |","sha256":"43f16868b0a2ff3caaf4097219db411875fa2eddf5ab688376216b11ba085931","chapter":{"id":"III","title":"视觉与语言"},"unit":{"id":"clip-pairing-to-candidates","title":"已知图文配对怎样变成可用的文字候选接口？"},"page":{"id":"reading-block-304aa2a46d41405db647924c1a08d5c0","title":"4 · 缓存节约什么，不能节约什么？","number":5},"sectionTitle":"4 · 缓存节约什么，不能节约什么？","currentQuestion":"4 · 缓存节约什么，不能节约什么？","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"table":{"headers":["组织方式","图像样本编码","文字样本编码","相似度计算","可复用内容"],"rows":[["组织方式","图像样本编码","文字样本编码","相似度计算","可复用内容"],["每对都重编码","288","288","288 个512维点积","无"],["双编码器缓存","24（入库一次）","12","288 个512维点积","图像向量可跨查询复用"],["新增一条查询","0","1","exact为24个点积","原图像库不变"],["IVF nprobe=1","入库同上","查询同上","每查询8个中心点积+平均4.17个图片点积","中心、倒排表、图片向量"]]},"previousBlock":"b-06d3ed33d793d28449787ad9","nextBlock":"b-5965811d42506f7688eb3e26","prerequisites":[{"id":"b-04c06e9bddb06cfe81993f70","url":"#b-04c06e9bddb06cfe81993f70","role":"section-title"},{"id":"b-06d3ed33d793d28449787ad9","url":"#b-06d3ed33d793d28449787ad9","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-5965811d42506f7688eb3e26","type":"p","scope":"block-304aa2a46d41405db647924c1a08d5c0","url":"https://codingai-lec03.pages.dev/course/notebooks/921eeaf784284ce19568c6ca7619b55a.html#b-5965811d42506f7688eb3e26","content":"图片矩阵为 $24×512×4=49,152$ 字节；8个中心另占16,384字节，倒排 ID 另占192字节（保存基准使用的 int64）。这没有计入 Python 对象、图片文件和模型权重，不能直接称整个服务的内存。","sha256":"7df53ec83d5158fab387bde9da8775e8145a415001ec6c33bbc5889e686315c6","chapter":{"id":"III","title":"视觉与语言"},"unit":{"id":"clip-pairing-to-candidates","title":"已知图文配对怎样变成可用的文字候选接口？"},"page":{"id":"reading-block-304aa2a46d41405db647924c1a08d5c0","title":"4 · 缓存节约什么，不能节约什么？","number":5},"sectionTitle":"4 · 缓存节约什么，不能节约什么？","currentQuestion":"4 · 缓存节约什么，不能节约什么？","sourceSlides":[],"knowledgeBlock":null,"formulas":[{"latex":"24×512×4=49,152","definitionContext":"4 · 缓存节约什么，不能节约什么？"}],"previousBlock":"b-27c5cc71c0b8fdf6c5321b15","nextBlock":"b-41cdb6c3aac36f8f47879aeb","prerequisites":[{"id":"b-04c06e9bddb06cfe81993f70","url":"#b-04c06e9bddb06cfe81993f70","role":"section-title"},{"id":"b-06d3ed33d793d28449787ad9","url":"#b-06d3ed33d793d28449787ad9","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-41cdb6c3aac36f8f47879aeb","type":"p","scope":"block-304aa2a46d41405db647924c1a08d5c0","url":"https://codingai-lec03.pages.dev/course/notebooks/921eeaf784284ce19568c6ca7619b55a.html#b-41cdb6c3aac36f8f47879aeb","content":"2026-09-22 的全部实测编码还包括候选与关系扩展，共 36 个图像样本和24条文字，分别以9个图像批次和1个文字批次编码；另做两对逐对重编码核验（额外2图+2文），与缓存点积最大差8.94×10⁻⁸。将CLIP按配对重复调用，算的仍然是 $f(I)^\\top g(T)$，并没有出现图文联合注意力。","sha256":"0058f1b1f72f4b12fed94a47316508cdf7a76909d978c569cc516bd2b096b4c4","chapter":{"id":"III","title":"视觉与语言"},"unit":{"id":"clip-pairing-to-candidates","title":"已知图文配对怎样变成可用的文字候选接口？"},"page":{"id":"reading-block-304aa2a46d41405db647924c1a08d5c0","title":"4 · 缓存节约什么，不能节约什么？","number":5},"sectionTitle":"4 · 缓存节约什么，不能节约什么？","currentQuestion":"4 · 缓存节约什么，不能节约什么？","sourceSlides":[],"knowledgeBlock":null,"formulas":[{"latex":"f(I)^\\top g(T)","definitionContext":"4 · 缓存节约什么，不能节约什么？"}],"previousBlock":"b-5965811d42506f7688eb3e26","nextBlock":"b-42b079dcde8335552527f46d","prerequisites":[{"id":"b-04c06e9bddb06cfe81993f70","url":"#b-04c06e9bddb06cfe81993f70","role":"section-title"},{"id":"b-06d3ed33d793d28449787ad9","url":"#b-06d3ed33d793d28449787ad9","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-42b079dcde8335552527f46d","type":"p","scope":"block-304aa2a46d41405db647924c1a08d5c0","url":"https://codingai-lec03.pages.dev/course/notebooks/921eeaf784284ce19568c6ca7619b55a.html#b-42b079dcde8335552527f46d","content":"这次36图编码含预处理共2.726秒、24文共0.205秒，是一趟本地CPU墙钟时间，不含模型加载/下载，不能当作稳定线上延迟。代码另行测量缓存搜索分布，已经在上表展示。更换模型、revision、预处理或图片内容会使旧缓存失效；只增加候选文字不会改变已有图片向量。","sha256":"0aca1a9483c1d58d13fe4c22db96395bf7ece1daf2b5e25e23c67d8e06f67d18","chapter":{"id":"III","title":"视觉与语言"},"unit":{"id":"clip-pairing-to-candidates","title":"已知图文配对怎样变成可用的文字候选接口？"},"page":{"id":"reading-block-304aa2a46d41405db647924c1a08d5c0","title":"4 · 缓存节约什么，不能节约什么？","number":5},"sectionTitle":"4 · 缓存节约什么，不能节约什么？","currentQuestion":"4 · 缓存节约什么，不能节约什么？","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-41cdb6c3aac36f8f47879aeb","nextBlock":"b-0796ffa1b8933f07e81dc472","prerequisites":[{"id":"b-04c06e9bddb06cfe81993f70","url":"#b-04c06e9bddb06cfe81993f70","role":"section-title"},{"id":"b-06d3ed33d793d28449787ad9","url":"#b-06d3ed33d793d28449787ad9","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-0796ffa1b8933f07e81dc472","type":"pre","scope":"block-5d25311e26c2487a838e6e92dcd3946a","url":"https://codingai-lec03.pages.dev/course/notebooks/921eeaf784284ce19568c6ca7619b55a.html#b-0796ffa1b8933f07e81dc472","content":"```\nN,d=X.shape;Qn=len(Q)\nprint('解析样本编码次数：每对重算',N*Qn,N*Qn,'；缓存',N,Qn)\nprint('矩阵字节：',X.nbytes,'；中心字节：',centers.nbytes,'；ID字节：',sum(l.nbytes for l in lists))\nprint('真实缓存生成记录：',p['image_count'],p['text_count'],'样本；',p['image_batch_calls'],p['text_batch_calls'],'批次')\nprint('另两对逐对重算与缓存的最大差：',p['pairwise_validation_max_abs_delta'])\n\n```","sha256":"1f446813e339d77894338425dfd088564fcaa921bd9d6fcdb446e1a9523375fd","chapter":{"id":"III","title":"视觉与语言"},"unit":{"id":"clip-pairing-to-candidates","title":"已知图文配对怎样变成可用的文字候选接口？"},"page":{"id":"reading-block-304aa2a46d41405db647924c1a08d5c0","title":"4 · 缓存节约什么，不能节约什么？","number":5},"sectionTitle":"4 · 缓存节约什么，不能节约什么？","currentQuestion":"4 · 缓存节约什么，不能节约什么？","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-42b079dcde8335552527f46d","nextBlock":null,"prerequisites":[{"id":"b-04c06e9bddb06cfe81993f70","url":"#b-04c06e9bddb06cfe81993f70","role":"section-title"},{"id":"b-06d3ed33d793d28449787ad9","url":"#b-06d3ed33d793d28449787ad9","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-f57772ac379ebea36a099585","type":"h2","scope":"block-8cfb433dc5cc4c4d9b8052e80463dfb5","url":"https://codingai-lec03.pages.dev/course/notebooks/921eeaf784284ce19568c6ca7619b55a.html#b-f57772ac379ebea36a099585","content":"## 5 · 查询依赖的交互：一个可运行的区域加权对照","sha256":"2fd9111f853e5d93f7d59d72c39d6652bb45bfaa5b4f36353c00e0eca228db69","chapter":{"id":"III","title":"视觉与语言"},"unit":{"id":"clip-pairing-to-candidates","title":"已知图文配对怎样变成可用的文字候选接口？"},"page":{"id":"reading-block-8cfb433dc5cc4c4d9b8052e80463dfb5","title":"5 · 查询依赖的交互：一个可运行的区域加权对照","number":6},"sectionTitle":"5 · 查询依赖的交互：一个可运行的区域加权对照","currentQuestion":"5 · 查询依赖的交互：一个可运行的区域加权对照","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":null,"nextBlock":"b-42060f9662e7e2098e9d0fe6","prerequisites":[{"id":"b-42060f9662e7e2098e9d0fe6","url":"#b-42060f9662e7e2098e9d0fe6","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-42060f9662e7e2098e9d0fe6","type":"p","scope":"block-8cfb433dc5cc4c4d9b8052e80463dfb5","url":"https://codingai-lec03.pages.dev/course/notebooks/921eeaf784284ce19568c6ca7619b55a.html#b-42060f9662e7e2098e9d0fe6","content":"“每对都调用模型”不等于“有图文交互”。我们再定义一个小而完整的 query-dependent 后期交互：先缓存左右两个照片区域的 CLIP 向量 $r_1,r_2$；对每一个查询 $q$，计算 $u_j=q^\\top r_j$，然后用 $w_j=\\mathrm{softmax}(u_j/0.05)$ 加权，得到分数 $s=\\sum_jw_ju_j$。查询不同，区域权重和汇总表示不同，所以它确实在比较时使用了图和文的共同信息；但它是本册定义的加权规则，没有训练新的联合编码器，也不是 CLIP 官方的全图匹配分数。","sha256":"1c0a54709b04ee6babf39f66eee1768f60b0f62b5c9cd89bb4c23667b8ade7c6","chapter":{"id":"III","title":"视觉与语言"},"unit":{"id":"clip-pairing-to-candidates","title":"已知图文配对怎样变成可用的文字候选接口？"},"page":{"id":"reading-block-8cfb433dc5cc4c4d9b8052e80463dfb5","title":"5 · 查询依赖的交互：一个可运行的区域加权对照","number":6},"sectionTitle":"5 · 查询依赖的交互：一个可运行的区域加权对照","currentQuestion":"5 · 查询依赖的交互：一个可运行的区域加权对照","sourceSlides":[],"knowledgeBlock":null,"formulas":[{"latex":"r_1,r_2","definitionContext":"5 · 查询依赖的交互：一个可运行的区域加权对照"},{"latex":"q","definitionContext":"5 · 查询依赖的交互：一个可运行的区域加权对照"},{"latex":"u_j=q^\\top r_j","definitionContext":"5 · 查询依赖的交互：一个可运行的区域加权对照"},{"latex":"w_j=\\mathrm{softmax}(u_j/0.05)","definitionContext":"5 · 查询依赖的交互：一个可运行的区域加权对照"},{"latex":"s=\\sum_jw_ju_j","definitionContext":"5 · 查询依赖的交互：一个可运行的区域加权对照"}],"previousBlock":"b-f57772ac379ebea36a099585","nextBlock":"b-67bd55c882a2d5ad3a9e3113","prerequisites":[{"id":"b-f57772ac379ebea36a099585","url":"#b-f57772ac379ebea36a099585","role":"section-title"}],"relatedBlocks":[]},{"id":"b-67bd55c882a2d5ad3a9e3113","type":"p","scope":"block-8cfb433dc5cc4c4d9b8052e80463dfb5","url":"https://codingai-lec03.pages.dev/course/notebooks/921eeaf784284ce19568c6ca7619b55a.html#b-67bd55c882a2d5ad3a9e3113","content":"在“猫左、宇航员右”拼贴上，cat 查询给左猫区94.15%的权重；astronaut 查询给右宇航员区80.08%。这是一项可观察的查询依赖变化。它的代价是每对查询与图要计算多个区域点积，缓存也从一向量变成区域集合；由于区域特征独立生成，它仍可部分预计算。","sha256":"9131075fd10fc81a22296a0bfdfa26a9b81a5fc2506249842fe1f424e20c20b0","chapter":{"id":"III","title":"视觉与语言"},"unit":{"id":"clip-pairing-to-candidates","title":"已知图文配对怎样变成可用的文字候选接口？"},"page":{"id":"reading-block-8cfb433dc5cc4c4d9b8052e80463dfb5","title":"5 · 查询依赖的交互：一个可运行的区域加权对照","number":6},"sectionTitle":"5 · 查询依赖的交互：一个可运行的区域加权对照","currentQuestion":"5 · 查询依赖的交互：一个可运行的区域加权对照","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-42060f9662e7e2098e9d0fe6","nextBlock":"b-6ea0289147217c2afc22fb97","prerequisites":[{"id":"b-f57772ac379ebea36a099585","url":"#b-f57772ac379ebea36a099585","role":"section-title"},{"id":"b-42060f9662e7e2098e9d0fe6","url":"#b-42060f9662e7e2098e9d0fe6","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-6ea0289147217c2afc22fb97","type":"p","scope":"block-8cfb433dc5cc4c4d9b8052e80463dfb5","url":"https://codingai-lec03.pages.dev/course/notebooks/921eeaf784284ce19568c6ca7619b55a.html#b-6ea0289147217c2afc22fb97","content":"接着使用两条“谁在左/右”的关系句。交换区域顺序后，下述加权分数**完全相同**，因为这个公式对区域排列不敏感；它没有使用坐标。这不是代码 bug，而是设计本身丢失了顺序。如果需要真正的区域关系，需要显式位置、关系模块或经训练的联合模型。一个一般的 cross-encoder 会在内部让图文 token 相互条件化，通常不能将整次交互压成一个与查询无关的图片向量；本册只给其结构和成本解释，没有假装运行或比较某个未加载的 cross-encoder。","sha256":"7319327aded1ab0df3bfecb88955ac7ec5e20b4a260492e8c92a288c7f8f2c0e","chapter":{"id":"III","title":"视觉与语言"},"unit":{"id":"clip-pairing-to-candidates","title":"已知图文配对怎样变成可用的文字候选接口？"},"page":{"id":"reading-block-8cfb433dc5cc4c4d9b8052e80463dfb5","title":"5 · 查询依赖的交互：一个可运行的区域加权对照","number":6},"sectionTitle":"5 · 查询依赖的交互：一个可运行的区域加权对照","currentQuestion":"5 · 查询依赖的交互：一个可运行的区域加权对照","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-67bd55c882a2d5ad3a9e3113","nextBlock":"b-7c629a5cad0295b15edf1e20","prerequisites":[{"id":"b-f57772ac379ebea36a099585","url":"#b-f57772ac379ebea36a099585","role":"section-title"},{"id":"b-42060f9662e7e2098e9d0fe6","url":"#b-42060f9662e7e2098e9d0fe6","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-7c629a5cad0295b15edf1e20","type":"pre","scope":"block-06052931c0434d36aae2251b7873e30c","url":"https://codingai-lec03.pages.dev/course/notebooks/921eeaf784284ce19568c6ca7619b55a.html#b-7c629a5cad0295b15edf1e20","content":"```\nR=a['relation_regions'][:,1:]  # 两图 × 两区域 × 512，丢弃full区域\n# 同一图片换查询，观察权重确实变化。\natomic=R[0]@Q[[0,2]].T\nweights=np.exp((atomic-atomic.max(0,keepdims=True))/.05)\nweights/=weights.sum(0,keepdims=True)\nprint('cat / astronaut 查询的 [左区,右区] 权重：',weights.T)\n# 同样两个对象交换左右；无坐标的对称聚合不可能分辨顺序。\nlocal=np.einsum('ijd,kd->ikj',R,a['relation_text'])\nw=np.exp((local-local.max(-1,keepdims=True))/.05);w/=w.sum(-1,keepdims=True)\nscore=(w*local).sum(-1)\nprint('两张交换图 × 两条关系句：',score)\nassert np.allclose(score[0],score[1],atol=1e-6)\n\n```","sha256":"1c94690e55052c3ecda347fd63eda585c74c30839c4f2ee4f7e60c12cef100b7","chapter":{"id":"III","title":"视觉与语言"},"unit":{"id":"clip-pairing-to-candidates","title":"已知图文配对怎样变成可用的文字候选接口？"},"page":{"id":"reading-block-8cfb433dc5cc4c4d9b8052e80463dfb5","title":"5 · 查询依赖的交互：一个可运行的区域加权对照","number":6},"sectionTitle":"5 · 查询依赖的交互：一个可运行的区域加权对照","currentQuestion":"5 · 查询依赖的交互：一个可运行的区域加权对照","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-6ea0289147217c2afc22fb97","nextBlock":null,"prerequisites":[{"id":"b-f57772ac379ebea36a099585","url":"#b-f57772ac379ebea36a099585","role":"section-title"},{"id":"b-42060f9662e7e2098e9d0fe6","url":"#b-42060f9662e7e2098e9d0fe6","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-c5ed526ddc0ae7bfd5432f79","type":"h2","scope":"block-00d45a521ea24f3894d71b0c128448a3","url":"https://codingai-lec03.pages.dev/course/notebooks/921eeaf784284ce19568c6ca7619b55a.html#b-c5ed526ddc0ae7bfd5432f79","content":"## 6 · 做一个有意义的改变，并解释它改变了哪层","sha256":"bbae6b88d175740fcc388f6a8c87e215f238a735f871795aaf66c88b7cab6763","chapter":{"id":"III","title":"视觉与语言"},"unit":{"id":"clip-pairing-to-candidates","title":"已知图文配对怎样变成可用的文字候选接口？"},"page":{"id":"reading-block-00d45a521ea24f3894d71b0c128448a3","title":"6 · 做一个有意义的改变，并解释它改变了哪层","number":7},"sectionTitle":"6 · 做一个有意义的改变，并解释它改变了哪层","currentQuestion":"6 · 做一个有意义的改变，并解释它改变了哪层","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":null,"nextBlock":"b-e03d42a192702ca79ced99d0","prerequisites":[{"id":"b-e03d42a192702ca79ced99d0","url":"#b-e03d42a192702ca79ced99d0","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-e03d42a192702ca79ced99d0","type":"p","scope":"block-00d45a521ea24f3894d71b0c128448a3","url":"https://codingai-lec03.pages.dev/course/notebooks/921eeaf784284ce19568c6ca7619b55a.html#b-e03d42a192702ca79ced99d0","content":"先把 `nprobe=1` 改成2，固定向量、查询、真值和K，记录漏掉的具体图片ID如何变化。这只改变搜索近似程度；模型表示没有改善。再把K改为1，重新计算 Hit@1 和 top-1 overlap，不得把不同K的数直接拼在同一结论里。若改变聚类seed，先记录簇大小和对应遗漏；单次成功不等于所有划分都成功。","sha256":"42636dfc286ae067e3a3dd324d3254fd946cf97ff5a9b437d0cd7499fd2dfb67","chapter":{"id":"III","title":"视觉与语言"},"unit":{"id":"clip-pairing-to-candidates","title":"已知图文配对怎样变成可用的文字候选接口？"},"page":{"id":"reading-block-00d45a521ea24f3894d71b0c128448a3","title":"6 · 做一个有意义的改变，并解释它改变了哪层","number":7},"sectionTitle":"6 · 做一个有意义的改变，并解释它改变了哪层","currentQuestion":"6 · 做一个有意义的改变，并解释它改变了哪层","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-c5ed526ddc0ae7bfd5432f79","nextBlock":"b-9671761074b3f50b1f5414f5","prerequisites":[{"id":"b-c5ed526ddc0ae7bfd5432f79","url":"#b-c5ed526ddc0ae7bfd5432f79","role":"section-title"}],"relatedBlocks":[]},{"id":"b-9671761074b3f50b1f5414f5","type":"p","scope":"block-00d45a521ea24f3894d71b0c128448a3","url":"https://codingai-lec03.pages.dev/course/notebooks/921eeaf784284ce19568c6ca7619b55a.html#b-9671761074b3f50b1f5414f5","content":"若想把第二条猫查询换成另一个同义模板，必须重算该文本编码，而不是在旧查询ID下改文字标题。默认缓存播放明确拒绝冒充新模型输出；在材料包副本中只修改 `assets/manifest.json` 的 `queries[1].text`，保留cat相关性定义，随后执行 `python run_clip_retrieval.py --encode`，才会为新文字生成真实特征和新的缓存身份。若改成“谁在左边”，需要另选同场多对象输入并定义坐标真值，不能沿用单对象类别标签；对应输入和反例已在LAB04。保留已验证的包，新实验应在一个副本目录执行，以便比较输入hash。","sha256":"3df82b0623b773e41f2ed517ca902a17ceeae0a40bd60e17ab4b0ab30bdb5fb8","chapter":{"id":"III","title":"视觉与语言"},"unit":{"id":"clip-pairing-to-candidates","title":"已知图文配对怎样变成可用的文字候选接口？"},"page":{"id":"reading-block-00d45a521ea24f3894d71b0c128448a3","title":"6 · 做一个有意义的改变，并解释它改变了哪层","number":7},"sectionTitle":"6 · 做一个有意义的改变，并解释它改变了哪层","currentQuestion":"6 · 做一个有意义的改变，并解释它改变了哪层","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-e03d42a192702ca79ced99d0","nextBlock":"b-9820adeb614d784f2a80e6fa","prerequisites":[{"id":"b-c5ed526ddc0ae7bfd5432f79","url":"#b-c5ed526ddc0ae7bfd5432f79","role":"section-title"},{"id":"b-e03d42a192702ca79ced99d0","url":"#b-e03d42a192702ca79ced99d0","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-9820adeb614d784f2a80e6fa","type":"p","scope":"block-00d45a521ea24f3894d71b0c128448a3","url":"https://codingai-lec03.pages.dev/course/notebooks/921eeaf784284ce19568c6ca7619b55a.html#b-9820adeb614d784f2a80e6fa","content":"最后回到任务：caption 需生成新句子，检索只能返回已经入库的候选；VQA要针对问题产生答案，grounding要交付可检验区域。检索用一个独立向量换来便于缓存和索引的结构，同时未承诺词级关系、坐标或完整生成。这一取舍通过当前真实关系反例和区域加权例可亲自检验。","sha256":"c60d3777bf170bdaa4d3d1080e566dc13881ed5547b9588c256b50c81668901d","chapter":{"id":"III","title":"视觉与语言"},"unit":{"id":"clip-pairing-to-candidates","title":"已知图文配对怎样变成可用的文字候选接口？"},"page":{"id":"reading-block-00d45a521ea24f3894d71b0c128448a3","title":"6 · 做一个有意义的改变，并解释它改变了哪层","number":7},"sectionTitle":"6 · 做一个有意义的改变，并解释它改变了哪层","currentQuestion":"6 · 做一个有意义的改变，并解释它改变了哪层","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-9671761074b3f50b1f5414f5","nextBlock":"b-1632710ec5f95630c9f61a5b","prerequisites":[{"id":"b-c5ed526ddc0ae7bfd5432f79","url":"#b-c5ed526ddc0ae7bfd5432f79","role":"section-title"},{"id":"b-e03d42a192702ca79ced99d0","url":"#b-e03d42a192702ca79ced99d0","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-1632710ec5f95630c9f61a5b","type":"p","scope":"block-00d45a521ea24f3894d71b0c128448a3","url":"https://codingai-lec03.pages.dev/course/notebooks/921eeaf784284ce19568c6ca7619b55a.html#b-1632710ec5f95630c9f61a5b","content":"**保存自己的运行：**执行下面单元会在新UTC时间目录写检索结果、实际计时、环境和脚本hash；默认只复用真实CLIP缓存。`verified/` 保留2026-09-22 完整编码基准，`legacy/` 保留旧实验，互不改日期。","sha256":"683fb353614b8caea2b20354148eb392f1ae5b27cdddc2afc985881ecd61869e","chapter":{"id":"III","title":"视觉与语言"},"unit":{"id":"clip-pairing-to-candidates","title":"已知图文配对怎样变成可用的文字候选接口？"},"page":{"id":"reading-block-00d45a521ea24f3894d71b0c128448a3","title":"6 · 做一个有意义的改变，并解释它改变了哪层","number":7},"sectionTitle":"6 · 做一个有意义的改变，并解释它改变了哪层","currentQuestion":"6 · 做一个有意义的改变，并解释它改变了哪层","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-9820adeb614d784f2a80e6fa","nextBlock":"b-b6f3671cde49103203b07ef8","prerequisites":[{"id":"b-c5ed526ddc0ae7bfd5432f79","url":"#b-c5ed526ddc0ae7bfd5432f79","role":"section-title"},{"id":"b-e03d42a192702ca79ced99d0","url":"#b-e03d42a192702ca79ced99d0","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-b6f3671cde49103203b07ef8","type":"pre","scope":"block-d0aadb6d836c4b38abb5a326b9eea3a8","url":"https://codingai-lec03.pages.dev/course/notebooks/921eeaf784284ce19568c6ca7619b55a.html#b-b6f3671cde49103203b07ef8","content":"```\nimport subprocess\ncompleted=subprocess.run([sys.executable,str(RETRIEVAL_ROOT/'run_clip_retrieval.py')],check=True,text=True,capture_output=True)\nprint(completed.stdout)\nprint('当前运行只重做检索；完整图文编码的生成身份见cache/provenance.json。')\n\n```","sha256":"a586469ccc83fb5dcf05cbbe1b152e57de2fd97ec876b73756c1a3bac5a9d09c","chapter":{"id":"III","title":"视觉与语言"},"unit":{"id":"clip-pairing-to-candidates","title":"已知图文配对怎样变成可用的文字候选接口？"},"page":{"id":"reading-block-00d45a521ea24f3894d71b0c128448a3","title":"6 · 做一个有意义的改变，并解释它改变了哪层","number":7},"sectionTitle":"6 · 做一个有意义的改变，并解释它改变了哪层","currentQuestion":"6 · 做一个有意义的改变，并解释它改变了哪层","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-1632710ec5f95630c9f61a5b","nextBlock":"b-9ecdb05e00671b3a6374fe17","prerequisites":[{"id":"b-c5ed526ddc0ae7bfd5432f79","url":"#b-c5ed526ddc0ae7bfd5432f79","role":"section-title"},{"id":"b-e03d42a192702ca79ced99d0","url":"#b-e03d42a192702ca79ced99d0","role":"problem-context"}],"relatedBlocks":[]},{"id":"b-9ecdb05e00671b3a6374fe17","type":"p","scope":"block-03e5b572855240478ac76bd5f0f39568","url":"https://codingai-lec03.pages.dev/course/notebooks/921eeaf784284ce19568c6ca7619b55a.html#b-9ecdb05e00671b3a6374fe17","content":"来源与实现边界：[OpenAI CLIP 官方代码](https://github.com/openai/CLIP)、[固定 checkpoint](https://huggingface.co/openai/clip-vit-base-patch32/tree/3d74acf9a28c67741b2f4f2ea7635f0aaf6f0268)、[scikit-image 数据文档](https://scikit-image.org/docs/0.25.x/api/skimage.data.html)。本册的8簇 spherical k-means IVF-Flat 和区域加权是透明的教学实现；未调用FAISS，不声称复现生产规模索引，也未训练新的cross-encoder。","sha256":"fcd877d1c393bc745c961addcd221b12f2ddf742a1feec276a9658eddddb9f9d","chapter":{"id":"III","title":"视觉与语言"},"unit":{"id":"clip-pairing-to-candidates","title":"已知图文配对怎样变成可用的文字候选接口？"},"page":{"id":"reading-block-00d45a521ea24f3894d71b0c128448a3","title":"6 · 做一个有意义的改变，并解释它改变了哪层","number":7},"sectionTitle":"6 · 做一个有意义的改变，并解释它改变了哪层","currentQuestion":"6 · 做一个有意义的改变，并解释它改变了哪层","sourceSlides":[],"knowledgeBlock":null,"formulas":[],"previousBlock":"b-b6f3671cde49103203b07ef8","nextBlock":null,"prerequisites":[{"id":"b-c5ed526ddc0ae7bfd5432f79","url":"#b-c5ed526ddc0ae7bfd5432f79","role":"section-title"},{"id":"b-e03d42a192702ca79ced99d0","url":"#b-e03d42a192702ca79ced99d0","role":"problem-context"}],"relatedBlocks":[]}]}
