{"id":10020595,"date":"2025-01-09T13:29:50","date_gmt":"2025-01-09T05:29:50","guid":{"rendered":"https:\/\/itmax.cn\/?p=10020595"},"modified":"2025-01-09T13:29:50","modified_gmt":"2025-01-09T05:29:50","slug":"%e7%90%86%e8%a7%a3%e5%a4%a7%e6%a8%a1%e5%9e%8b%ef%bc%9afp32%e3%80%81fp16%e3%80%81tf32%e3%80%81bf16%e3%80%81%e6%b7%b7%e5%90%88%e7%b2%be%e5%ba%a6","status":"publish","type":"post","link":"https:\/\/itmax.cn\/?p=10020595","title":{"rendered":"\u7406\u89e3\u5927\u6a21\u578b\uff1aFP32\u3001FP16\u3001TF32\u3001BF16\u3001\u6df7\u5408\u7cbe\u5ea6"},"content":{"rendered":"<h2>\u4ecb\u7ecd<\/h2>\n<p>\u6211\u4eec\u5728\u6a21\u578b\u5f00\u6e90\u6a21\u578b\u5e73\u53f0\u4e0b\u8f7d\u6a21\u578b\u7684\u65f6\u5019\u4f1a\u7ecf\u5e38\u770b\u7740\u8fd9\u4e9b\u53c2\u6570 FP32\u3001FP16\u3001TF32\u3001BF16 \u7b49\u53c2\u6570\u3002\u8fd9\u4e2a\u5176\u5b9e\u662f\u6307\u7684GGUF\u6a21\u578b\u7684\u91cf\u5316\u7ea7\u522b\u3002\u91cf\u5316\u7ea7\u522b\u51b3\u5b9a\u4e8e\u6a21\u578b\u6839\u636e\u8d28\u91cf\u548c\u51c6\u786e\u6027\u5b9a\u4e49\u7684\u503c \uff08ggml_type\uff09\u3002 \u5728 GGUF \u89c4\u8303\u4e2d\uff0c\u503c\u5217\u8868\u5982\u4e0b<br \/><img loading=\"lazy\" decoding=\"async\" width=\"729\" height=\"1168\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVdg2TB\" alt=\"image.png\" title=\"image.png\"><br \/>  GGUF \u81ea\u8eab\u53c8\u6709\u591a\u79cd\u683c\u5f0f\uff0c\u4e3b\u8981\u533a\u522b\u5728\u4e8e\u6d6e\u70b9\u6570\u7684\u4f4d\u6570\u548c\u91cf\u5316\u7684\u65b9\u5f0f\u3002<br \/> \u4e0d\u540c\u7684\u683c\u5f0f\u4f1a\u5f71\u54cd\u6a21\u578b\u7684\u5927\u5c0f\u3001\u6027\u80fd\u548c\u7cbe\u5ea6\uff0c\u4e00\u822c\u6765\u8bf4\uff0c\u4f4d\u6570\u8d8a\u5c11\uff0c\u91cf\u5316\u8d8a\u591a\uff0c\u6a21\u578b\u8d8a\u5c0f\uff0c\u901f\u5ea6\u8d8a\u5feb\uff0c\u4f46\u662f\u7cbe\u5ea6\u4e5f\u8d8a\u4f4e\u3002<br \/> \u5728HuggingFace\u4e2d\u53ef\u4ee5\u770b\u5230\u5982\u4e0b\u683c\u5f0f\uff1a<br \/><img decoding=\"async\" width=\"723\" height=\"373\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVdg2V3\" alt=\"image.png\" title=\"image.png\" loading=\"lazy\"><\/p>\n<p>\u547d\u540d\u89e3\u91ca\uff1a\u201cQ\u201d+\u7528\u4e8e\u5b58\u50a8\u6743\u91cd\uff08\u7cbe\u5ea6\uff09\u7684\u4f4d\u6570+\u7279\u5b9a\u53d8\u4f53<br \/>Q\uff08Quantization\uff09<br \/>Q2\u3001Q3\u3001Q4\u3001Q5\u3001Q6 \u5206\u522b\u8868\u793a\u6a21\u578b\u7684\u91cf\u5316\u4f4d\u6570\u3002\u4f8b\u5982\uff0cQ2 \u8868\u793a 2 \u4f4d\u91cf\u5316\uff0cQ3 \u8868\u793a 3 \u4f4d\u91cf\u5316\uff0c\u4ee5\u6b64\u7c7b\u63a8<br \/>\u91cf\u5316\u4f4d\u6570\u8d8a\u9ad8\uff0c\u6a21\u578b\u7684\u7cbe\u5ea6\u635f\u5931\u5c31\u8d8a\u5c0f\uff0c\u4f46\u540c\u65f6\u6a21\u578b\u7684\u5927\u5c0f\u548c\u8ba1\u7b97\u9700\u6c42\u4e5f\u4f1a\u589e\u52a0<br \/>\u7279\u5b9a\u53d8\u4f53\uff1a\u91cf\u5316\u65b9\u6848\u7684\u7c7b\u578b\uff0c\u91c7\u7528\u4e86\u4e0d\u540c\u7684\u91cf\u5316\u65b9\u6848\u6765\u5904\u7406 attention.wv\u3001attention.wo \u548c feed_forward.w2 \u5f20\u91cf\uff0c\u91cf\u5316\u65b9\u6848\u89c1\u4e0a\u8868<br \/>q2_k: Uses Q4_K for the attention.vw and feed_forward.w2 tensors, Q2_K for the other tensors<br \/>q3_k_l: Uses Q5_K for the attention.wv, attention.wo, and feed_forward.w2 tensors, else Q3_K<br \/>q3_k_m: Uses Q4_K for the attention.wv, attention.wo, and feed_forward.w2 tensors, else Q3_K<br \/>q3_k_s: Uses Q3_K for all tensors<br \/>q4_0: Original quant method, 4-bit<br \/>q4_1: Higher accuracy than q4_0 but not as high as q5_0. However has quicker inference than q5 models<br \/>q4_k_m: Uses Q6_K for half of the attention.wv and feed_forward.w2 tensors, else Q4_K<br \/>q4_k_s: Uses Q4_K for all tensors<br \/>q5_0: Higher accuracy, higher resource usage and slower inference<\/p>\n<p>q5_1: Even higher accuracy, resource usage and slower inference<br \/>q5_k_m: Uses Q6_K for half of the attention.wv and feed_forward.w2 tensors, else Q5_K<br \/>q5_k_s: Uses Q5_K for all tensors<br \/>q6_k: Uses Q8_K for all tensors<br \/>q8_0: Almost indistinguishable from float16. High resource use and slow. Not recommended for most users<\/p>\n<h2>\u6a21\u578b\u8bad\u7ec3\u4e2d\u4e0d\u540c\u7cbe\u5ea6\u7684\u95ee\u9898<\/h2>\n<p>\u9996\u5148\u5bf9\u6bd4FP32\u548cFP64\uff0c\u7531\u4e8e\u4e00\u4e2aFP32\u6d6e\u70b9\u6570\u53ea\u536032\u4f4d\uff0c\u548cFP64\u6bd4\u6709\u660e\u663e\u7684\u4f18\u52bf\uff1a<\/p>\n<ul>\n<li>\u51cf\u5c11\u5b58\u50a8\u4f7f\u7528\uff1a\u6a21\u578b\u8bad\u7ec3\u663e\u5b58\u5927\u5c0f\u662f\u5173\u952e\uff0cFP32\u53ea\u5360\u7528\u4e00\u534a\u7684\u5b58\u50a8\uff0c\u540c\u6837\u7684GPU\u53ef\u4ee5\u8bad\u7ec3\u66f4\u5927\u7684\u6a21\u578b\uff0c\u6216\u8005\u540c\u6837\u7684\u6a21\u578bbatch_size\u53ef\u4ee5\u66f4\u5927\uff1b<\/li>\n<li>\u63d0\u9ad8\u8bad\u7ec3\u901f\u5ea6\uff1a\u540c\u6837\u7684\u4e24\u4e2a\u6570\u8fdb\u884c\u8ba1\u7b97\uff0cFP32\u7531\u4e8e\u4f4d\u6570\u5c11\uff0c\u8ba1\u7b97\u91cf\u66f4\u5c0f\uff0c\u53ef\u4ee5\u964d\u4f4e\u8ba1\u7b97\u65f6\u95f4\u3002<\/li>\n<\/ul>\n<p>\u540c\u6837\u7684\u9053\u7406\u9002\u7528\u4e8eFP16\u548cFP32\u7684\u5bf9\u6bd4\uff0c\u4f46\u662f\u5426\u610f\u5473\u7740\u6211\u4eec\u90fd\u4f7f\u7528FP16\u5c31\u884c\u4e86\uff1f\u5f53\u7136\u4e0d\u662f\uff0c\u4e3b\u8981\u539f\u56e0\u662f\u4f4d\u6570\u5c11\u540c\u65f6\u6709\u4e24\u4e2a\u52a3\u52bf\uff1a<\/p>\n<ul>\n<li>\u4f4d\u6570\u5c11\u65f6\u7cbe\u5ea6\u6bd4\u4f4d\u6570\u591a\u65f6\u4f4e\uff0c\u53ef\u80fd\u5bfc\u81f4\u51c6\u786e\u5ea6\u4e0d\u591f\uff1b<\/li>\n<li>\u4f4d\u6570\u5c11\u65f6\u8868\u793a\u7684\u8303\u56f4\u6bd4\u4f4d\u6570\u591a\u65f6\u8981\u5c0f\uff0c\u53ef\u80fd\u5bfc\u81f4\u6570\u636e\u6ea2\u51fa\uff0c\u88c5\u4e0d\u4e0b\u4e86\u3002<\/li>\n<\/ul>\n<h2>\u6df7\u5408\u7cbe\u5ea6<\/h2>\n<p>\u65e2\u7136FP32\u548cFP16\u957f\u77ed\u5404\u6709\u4f18\u7f3a\u70b9\uff0c\u90a3\u6211\u4eec\u5c31\u53ef\u4ee5\u91c7\u53d6\u6df7\u5408\u4f7f\u7528\u7684\u65b9\u6cd5\uff0c\u5728\u6a21\u578b\u8bad\u7ec3\u7684\u4e0d\u540c\u6b65\u9aa4\u4f7f\u7528\u4e0d\u540c\u7684\u7cbe\u5ea6\uff1a<\/p>\n<p><img decoding=\"async\" width=\"723\" height=\"241\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVdg20x\" alt=\"image.png\" title=\"image.png\" loading=\"lazy\"><\/p>\n<ul>\n<li>\u628a\u795e\u7ecf\u7f51\u7edc\u6743\u91cd\u53c2\u6570\u7531\u521d\u59cb\u5316\u7684FP32\u8f6c\u4e3aFP16\uff1b<\/li>\n<li>\u7528FP16\u8fdb\u884c\u524d\u5411\u548c\u540e\u5411\u8ba1\u7b97\uff0c\u5e76\u8fdb\u884c\u68af\u5ea6\u8ba1\u7b97\uff1b<\/li>\n<li>\u628aFP16\u7684\u68af\u5ea6\u8f6c\u4e3aFP32\uff1b<\/li>\n<li>\u4f7f\u7528FP32\u7684\u68af\u5ea6\u548c\u5b66\u4e60\u7387learning rate\u76f8\u4e58\uff1b<\/li>\n<li>\u4f7f\u7528FP32\u66f4\u65b0\u7f51\u7edc\u6743\u91cd\uff0c\u5f97\u5230FP32\u7684\u66f4\u65b0\u540e\u7684\u6743\u91cd\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u6b65\u9aa4\u4e0d\u65ad\u5faa\u73af\u8fdb\u884c\u3002\u7b80\u5355\u6765\u8bb2\u5c31\u662f\u4f7f\u7528\u68af\u5ea6\u66f4\u65b0\u6743\u91cd\u7684\u65f6\u5019\u7528FP32\uff0c\u56e0\u4e3a\u68af\u5ea6\u4e58\u4e0a\u5b66\u4e60\u7387\u540e\u4e00\u822c\u6570\u503c\u90fd\u6bd4\u8f83\u5c0f\uff0c\u4f7f\u7528FP32\u80fd\u9632\u6b62\u7cbe\u5ea6\u4e0d\u591f\u3002<\/p>\n<p>\u6df7\u5408\u4f7f\u7528\u7cbe\u5ea6\u7684\u65f6\u5019\uff0c\u6709\u4e00\u4e2a<strong>\u201c<\/strong><strong>\u635f\u5931\u7f29\u653e\u201d<\/strong>\u7684\u6280\u672f\uff0c\u5728\u53cd\u5411\u8ba1\u7b97\u524d\uff0c\u5c06\u5f97\u5230\u7684\u635f\u5931\u6269\u5927\u4e00\u4e2a\u500d\u6570\uff0c\u907f\u514d\u6570\u636e\u592a\u5c0f\u7cbe\u5ea6\u4e0d\u591f\u53d8\u4e3a0\u4e86\uff0c\u6269\u5927\u540e\u5728FP16\u53ef\u8868\u8fbe\u7684\u8303\u56f4\u5185\uff0c\u53cd\u5411\u8ba1\u7b97\u540e\uff0c\u518d\u628a\u68af\u5ea6\u7f29\u5c0f\u540c\u6837\u7684\u500d\u6570\uff0c\u786e\u4fdd\u6700\u540e\u6570\u503c\u662f\u5bf9\u7684\u3002<\/p>\n<p><a href=\"https:\/\/segmentfault.com\/a\/1190000045969870\">https:\/\/segmentfault.com\/a\/1190000045969870<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4ecb\u7ecd \u6211\u4eec\u5728\u6a21\u578b\u5f00\u6e90\u6a21\u578b\u5e73\u53f0\u4e0b\u8f7d\u6a21\u578b\u7684\u65f6\u5019\u4f1a\u7ecf\u5e38\u770b\u7740\u8fd9\u4e9b\u53c2\u6570 FP32\u3001FP16\u3001TF32\u3001BF16 \u7b49\u53c2\u6570\u3002 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4],"tags":[],"class_list":["post-10020595","post","type-post","status-publish","format-standard","hentry","category-share"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10020595","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10020595"}],"version-history":[{"count":0,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10020595\/revisions"}],"wp:attachment":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10020595"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10020595"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10020595"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}