{"id":425,"date":"2024-07-08T17:54:11","date_gmt":"2024-07-08T17:54:11","guid":{"rendered":"https:\/\/blog.simbot.net\/?p=425"},"modified":"2024-07-09T09:42:06","modified_gmt":"2024-07-09T09:42:06","slug":"ann_vs_hnsw_build_search_compare","status":"publish","type":"post","link":"https:\/\/blog.simbot.net\/2024\/07\/08\/ann_vs_hnsw_build_search_compare\/","title":{"rendered":"ann\u4e0ehnsw\u7b97\u6cd5\u5efa\u7d22\u5f15\u3001\u641c\u7d22\u901f\u5ea6\u5bf9\u6bd4"},"content":{"rendered":"\n
\u4f5c\u8005\uff1ahws000\uff08hws.000#163.com\uff09 \u6d4b\u8bd5\u5e73\u53f0\u4e3aAWS EC2\uff0c\u5177\u4f53\u914d\u7f6e\u5982\u4e0b\u8868\uff1a<\/p>\n
\u58f0\u660e\uff1a\u7248\u6743\u6240\u6709\uff0c\u8f6c\u8f7d\u8bf7\u8054\u7cfb\u4f5c\u8005\u3002
\u51fa\u5904\uff1ahttps:\/\/blog.simbot.net\/2024\/07\/08\/ann_vs_hnsw_build_search_compare\/<\/a><\/p>\n1.\u8f6f\u786c\u4ef6\u4ecb\u7ecd<\/h2>\n
\u540d\u79f0<\/td>\n | \u7c7b\u578b<\/td>\n | CPU<\/span>\u6838\u6570<\/td>\n | \u5185\u5b58(GB)<\/span><\/td>\n | \u4ef7\u683c($\/h)<\/span><\/td>\n<\/tr>\ng5.xlarge<\/span><\/td>\n | A10G<\/span><\/td>\n | 4<\/td>\n | 16<\/td>\n | 1.006<\/td>\n<\/tr>\n | g5.4xlarge<\/span><\/td>\n | A10G<\/span><\/td>\n | 16<\/td>\n | 64<\/td>\n | 1.624<\/span><\/td>\n<\/tr>\n | m7i.2xlarge<\/span><\/td>\n | Xeon 8488C<\/span><\/td>\n | 8<\/td>\n | 32<\/td>\n | 0.4032<\/span><\/td>\n<\/tr>\n | m7g.2xlarge<\/span><\/td>\n | Graviton3<\/span><\/td>\n | 8<\/td>\n | 32<\/td>\n | 0.3264<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n | A10G GPU\u7684FP16\u7b97\u529b\u4e3a70TFLOPS\uff0c\u8be6\u7ec6\u53c2\u6570\u89c1\uff1ahttps:\/\/d1.awsstatic.com\/product-marketing\/ec2\/NVIDIA_AWS_A10G_DataSheet_FINAL_02_17_2022.pdf<\/p>\n ann\u7b97\u6cd5\u6784\u5efa\u7d22\u5f15\u5206\u4e3a\u4e24\u6b65\uff1a(1)CPU<\/span>\u4e0eGPU<\/span>\u534f\u540c\u52a0\u901f\u6784\u5efa\u8fd1\u4f3cknn<\/span>\u56fe\uff1b(2)\u4f7f\u7528nsg<\/span>\u7b97\u6cd5\u5bf9\u8fd1\u4f3cknn<\/span>\u56fe\u8fdb\u884c\u88c1\u526a\uff0c\u751f\u6210\u7d22\u5f15\u56fe\u3002ann\u88c1\u526a\u3001\u641c\u7d22\u7b97\u6cd5\u652f\u6301X86\u7684AVX512\u6307\u4ee4\u96c6\uff0c\u4e5f\u652f\u6301Arm\u7684Neon\u6307\u4ee4\u96c6\u3002<\/p>\n hnsw\u7b97\u6cd5\u6765\u6e90\u4e3ahttps:\/\/github.com\/nmslib\/hnswlib\uff0c\u7248\u672cv0.8.0\uff0c\u652f\u6301AVX512\u6307\u4ee4\u96c6\u3002<\/p>\n \u6570\u636e\u96c6\u5206\u522b\u4e3a\uff1aDeep1B\uff08\u7ef4\u5ea696\uff0c\u6b27\u5f0f\u8ddd\u79bb\uff09\u768410M\u5b50\u96c6\uff0c\u67e5\u8be2\u6570\u636e\u96c610K\uff1bcohere\u7684miracl-zh-corpus-22-12\uff08\u7ef4\u5ea6768\uff0c\u5185\u79ef\u8ddd\u79bb\uff09\u4e2d\u968f\u673a\u63d0\u53d6\u76841M\u5b50\u96c6\uff0c\u67e5\u8be2\u6570\u636e\u96c61.3K\u3002<\/p>\n \u4e0a\u56fe\u5206\u522b\u4e3adeep1b(g5.4xlarge)\u3001miracl-zh(g5.xlarge)\u5728\u6784\u5efaTopK\u4e3a128\u7684\u8fd1\u4f3cknn\u56fe\u65f6\u7684\u8017\u65f6\/\u51c6\u786e\u7387(\u53ec\u56de\u7387\uff0c\u968f\u673a\u9009\u53d610\u4e07\u4e2a\u70b9\u8fdb\u884c\u9a8c\u8bc1)\u66f2\u7ebf\u3002\u5f53\u51c6\u786e\u7387\u8d8a\u9ad8\u65f6\uff0c\u88c1\u526a\u540e\u7684\u7d22\u5f15\u56fe\u641c\u7d22\u6548\u679c\u8d8a\u597d\u3002\u540e\u7eed\u88c1\u526a\u9009\u53d6\u7684\u8fd1\u4f3cknn\u56fe\u7684\u51c6\u786e\u7387\u5206\u522b\u4e3a98.6%(deep1b\uff0c\u8017\u65f625.4\u79d2)\u300198%(miracl-zh\uff0c\u8017\u65f69.75\u79d2)\u3002<\/p>\n \u4e0b\u8868\u4e2d\u5206\u522b\u4e3aann(\u672c\u7b97\u6cd5)\u3001ann-arm(\u672c\u7b97\u6cd5\u7684arm\u7248\u672c)\u3001hnsw(\u53c2\u6570M=32 ef_c=400)\u3001hnsw2(\u53c2\u6570M=16 ef_c=200)\uff0c\u5728m7i\u3001m7g\u5e73\u53f0\u7684\u7d22\u5f15\u8017\u65f6\u53ca\u8d39\u7528(\u542b\u7528GPU\u521b\u5efa\u8fd1\u4f3cknn\u56fe\u7684\u8d39\u7528)\uff1a<\/p>\n \u4e0a\u56fe\u5206\u522b\u4e3adeep1b\u3001miracl-zh\u6570\u636e\u96c6\u7684\u67e5\u8be2\u603b\u8017\u65f6(\u6a2a\u8f74\uff0c\u5355\u4f4d\uff1a\u79d2)\uff0c\u53ca\u53ec\u56de\u7387(\u7eb5\u8f74\uff0c80%-100%)\u3002<\/p>\n \u4e0a\u56fe\u5206\u522b\u4e3a\u67e5\u8be2\u8017\u65f6\uff0c\u53ca100-\u53ec\u56de\u7387\u7684\u503c(\u5bf9\u6570\u523b\u5ea6)\uff0c\u6b64\u8868\u793a\u66f4\u80fd\u53cd\u6620\u9ad8\u53ec\u56de\u7387\u65f6\u7684\u7ec6\u8282\u3002<\/p>\n \u4e0a\u56fe\u5206\u522b\u4e3a\u5e73\u5747\u4e00\u6b21\u67e5\u8be2\u7684\u6bd4\u8f83\u6b21\u6570(\u8ba1\u7b97\u8ddd\u79bb\u5e76\u6bd4\u8f83\u7684\u6b21\u6570)\uff0c\u53ca100-\u53ec\u56de\u7387\u7684\u503c\u3002<\/p>\n \u4e0a\u56fe\u5206\u522b\u4e3a\u4e0d\u540c\u7684\u5e73\u5747\u6bd4\u8f83\u6b21\u6570\uff0c\u53ca\u67e5\u8be2\u603b\u8017\u65f6\uff0c\u53ef\u76f4\u89c2\u5c55\u793a\u4e0d\u540c\u7b97\u6cd5\u3001\u5e73\u53f0\u7684\u8ba1\u7b97\u6548\u7387\u3002<\/p>\n \u901a\u8fc7\u4ee5\u4e0a\u5bf9\u6bd4\u53ef\u77e5\uff0c\u4ee5M=32 ef_c=400\u4e3a\u53c2\u6570\u6784\u5efa\u7684hnsw\u7d22\u5f15\u7684\u641c\u7d22\u6548\u7387\u66f4\u63a5\u8fd1ann\u7b97\u6cd5\uff0c\u4f46\u5efa\u7d22\u5f15\u8017\u65f6\u4e3aann\u7b97\u6cd5\u768448\u500d\u300140\u500d\uff0c\u6210\u672c\u4e3aann\u7b97\u6cd5\u768419.8\u500d\u300122.7\u500d(GPU\u5355\u4f4d\u65f6\u95f4\u7684\u6210\u672c\u66f4\u9ad8)\u3002\u4f7f\u7528arm\u5e73\u53f0\u5efa\u7d22\u5f15\u3001\u641c\u7d22\u7684\u901f\u5ea6\u66f4\u5feb\uff0c\u6210\u672c\u66f4\u4f4e\u3002<\/p>\n \u901a\u8fc7\u7528SIMD\u6307\u4ee4\u53c2\u4e0e\u6392\u5e8f\uff0c\u4f7fCPU\u5728\u6784\u5efa\u8fd1\u4f3cknn\u56fe\u65f6\u6548\u7387\u63d0\u9ad8\u6570\u500d\u3002<\/p>\n ann\u7b97\u6cd5\u7684\u9ad8\u6548\u5b9e\u73b0\u4f9d\u8d56CN202111620913.X\u3001CN202210286230.3\u3001CN202210763651.0\u7b49\u4e13\u5229\u3002<\/p>\n\n\n","protected":false},"excerpt":{"rendered":" \u76f8\u8fd1\u7684\u7d22\u5f15\u8d28\u91cf\uff0c\u6784\u5efa\u65f6\u95f4\u7f29\u77ed40\u500d\u4ee5\u4e0a\uff0c\u8d39\u7528\u51cf\u5c1120\u500d(GPU\u5355\u4f4d\u65f6\u95f4\u7684\u8d39\u7528\u66f4\u9ad8)\uff0c\u4e14\u641c\u7d22\u6548\u679c\u66f4\u4f73\u3002<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[29],"tags":[40,41,42,35],"_links":{"self":[{"href":"https:\/\/blog.simbot.net\/wp-json\/wp\/v2\/posts\/425"}],"collection":[{"href":"https:\/\/blog.simbot.net\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.simbot.net\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.simbot.net\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.simbot.net\/wp-json\/wp\/v2\/comments?post=425"}],"version-history":[{"count":7,"href":"https:\/\/blog.simbot.net\/wp-json\/wp\/v2\/posts\/425\/revisions"}],"predecessor-version":[{"id":459,"href":"https:\/\/blog.simbot.net\/wp-json\/wp\/v2\/posts\/425\/revisions\/459"}],"wp:attachment":[{"href":"https:\/\/blog.simbot.net\/wp-json\/wp\/v2\/media?parent=425"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.simbot.net\/wp-json\/wp\/v2\/categories?post=425"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.simbot.net\/wp-json\/wp\/v2\/tags?post=425"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}} |