{"id":21238,"date":"2026-08-10T16:12:45","date_gmt":"2026-08-10T08:12:45","guid":{"rendered":"https:\/\/92it.top\/?p=21238"},"modified":"2026-08-10T16:12:45","modified_gmt":"2026-08-10T08:12:45","slug":"llama-cpp%e5%b0%86safetensors%e6%a8%a1%e5%9e%8b%e8%bd%ac%e6%8d%a2%e4%b8%bagguf","status":"publish","type":"post","link":"https:\/\/92it.top\/?p=21238","title":{"rendered":"llama.cpp\u5c06safetensors\u6a21\u578b\u8f6c\u6362\u4e3agguf"},"content":{"rendered":"\n<p><strong>\u524d\u8a00 \ud83d\udd16<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u4e0d\u540c\u672c\u5730\u90e8\u7f72\u5de5\u5177\u652f\u6301\u7684\u6a21\u578b\u683c\u5f0f\u4e0d\u540c\uff0c Ollama\u3001 llama.cpp\u652f\u6301GGUF\uff0cPyTorch\u652f\u6301safetensors\uff0c\u672c\u6587\u8bb2\u89e3\u683c\u5f0f\u8f6c\u6362\u65b9\u6cd5\u3002<\/p>\n\n\n\n<p>llama.cpp\u63d0\u4f9b\u4e86\u5404\u79cdLLM\u7684\u5904\u7406\u5de5\u5177\uff0c\u5176\u4e2d<code>convert_hf_to_gguf.py<\/code>\uff0c\u5c31\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u5c06safetensors\u6a21\u578b\u8f6c\u6362\u4e3agguf\u683c\u5f0f\uff0c\u5176\u4e2d\uff0c\u6a21\u578b\u7684\u5927\u5c0f\u4e0d\u4f1a\u6539\u53d8\uff0c\u53ea\u662f\u683c\u5f0f\u88ab\u4fee\u6539\u4e86\u3002<\/p>\n\n\n\n<p>\u3000\u3000<\/p>\n\n\n\n<p><strong>\u8f6c\u6362\u6b65\u9aa4  \ud83d\udd16<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><strong>\ud83d\udd391.\u514b\u9686\u5b98\u65b9\u9879\u76ee<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">git clone https:\/\/github.com\/ggerganov\/llama.cpp.git<\/pre>\n\n\n\n<p>\u3000\u3000<\/p>\n\n\n\n<p><strong>\ud83d\udd392.\u521b\u5efa\u5e76\u4e14\u6fc0\u6d3bPython\u865a\u62df\u73af\u5883<\/strong><\/p>\n\n\n\n<p>\u4e3a\u4e86\u9632\u6b62\u73af\u5883\u6c61\u67d3\uff0c\u6700\u597d\u7528\u7528Python\u865a\u62df\u73af\u5883\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#\u521b\u5efaPyhon \u865a\u62df\u73af\u5883\npython -m venv python-llama\n\n# \u6fc0\u6d3b\u865a\u62df\u73af\u5883\nsource python-llama\/bin\/activate<\/pre>\n\n\n\n<p>\u3000\u3000<\/p>\n\n\n\n<p><strong>\ud83d\udd393.\u5b89\u88c5\u9879\u76ee\u4f9d\u8d56<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># cd \u5230\u4e0b\u8f7d\u597d\u7684llama.cpp\u5de5\u7a0b\u76ee\u5f55\ncd \/Users\/xx\/Documents\/llama_cpp\/llama.cpp \n\n# \u5b89\u88c5\u76f8\u5e94\u7684\u4f9d\u8d56\npip install -r requirements.txt<\/pre>\n\n\n\n<p>\u3000\u3000<\/p>\n\n\n\n<p><strong>\ud83d\udd394.\u4e0b\u8f7d\u597d\u9700\u8981\u8f6c\u6362\u7684safetensors\u6a21\u578b\u6587\u4ef6\u5230\u672c\u5730\u76ee\u5f55<\/strong><\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"674\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2026\/08\/\u56fe\u7247-54-1024x674.png\" alt=\"\" class=\"wp-image-21239\" style=\"width:448px;height:auto\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2026\/08\/\u56fe\u7247-54-1024x674.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2026\/08\/\u56fe\u7247-54-300x197.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2026\/08\/\u56fe\u7247-54-768x505.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2026\/08\/\u56fe\u7247-54-1536x1010.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2026\/08\/\u56fe\u7247-54-2048x1347.png 2048w, https:\/\/92it.top\/wp-content\/uploads\/2026\/08\/\u56fe\u7247-54-830x546.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2026\/08\/\u56fe\u7247-54-230x151.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2026\/08\/\u56fe\u7247-54-350x230.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2026\/08\/\u56fe\u7247-54-480x316.png 480w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"498\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2026\/08\/\u56fe\u7247-55-1024x498.png\" alt=\"\" class=\"wp-image-21240\" style=\"width:450px;height:auto\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2026\/08\/\u56fe\u7247-55-1024x498.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2026\/08\/\u56fe\u7247-55-300x146.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2026\/08\/\u56fe\u7247-55-768x373.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2026\/08\/\u56fe\u7247-55-830x403.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2026\/08\/\u56fe\u7247-55-230x112.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2026\/08\/\u56fe\u7247-55-350x170.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2026\/08\/\u56fe\u7247-55-480x233.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2026\/08\/\u56fe\u7247-55.png 1346w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n<p>\u3000\u3000<\/p>\n\n\n\n<p><strong>\ud83d\udd395.\u4f7f\u7528<code>convert_hf_to_gguf.py<\/code>\u8fdb\u884c\u8f6c\u6362<\/strong><\/p>\n\n\n\n<p>\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u53ef\u4ee5\u8f6c\u6362\u751f\u6210gguf\u6587\u4ef6\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">python .\/convert_hf_to_gguf.py \/Users\/xxx\/Documents\/llama_cpp\/safetensors --outtype q8_0<\/pre>\n\n\n\n<p><strong>\u53c2\u6570\u8bf4\u660e<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table is-style-stripes\"><table><thead><tr><th>\u53c2\u6570<\/th><th>\u8bf4\u660e<\/th><\/tr><\/thead><tbody><tr><td><code>python convert_hf_to_gguf.py<\/code><\/td><td>\u8c03\u7528 llama.cpp \u4ed3\u5e93\u4e2d\u7528\u4e8e\u5c06 HuggingFace \u683c\u5f0f\u6a21\u578b\u8f6c\u6362\u4e3a GGUF \u683c\u5f0f\u7684 Python \u811a\u672c<\/td><\/tr><tr><td><code>.\/my_qwen_model<\/code><\/td><td>\u4f4d\u7f6e\u53c2\u6570\uff0c\u6307\u5b9a HuggingFace \u6a21\u578b\u6240\u5728\u7684\u672c\u5730\u76ee\u5f55\u8def\u5f84\u3002\u8be5\u76ee\u5f55\u4e0b\u5e94\u5305\u542b config.json \u548c .safetensors \u6743\u91cd\u6587\u4ef6<\/td><\/tr><tr><td><code>--outtype f16<\/code><\/td><td>\u6307\u5b9a\u8f93\u51fa\u6a21\u578b\u7684\u7cbe\u5ea6\u7c7b\u578b\u3002f16 \u4ee3\u8868 16\u2011bit \u534a\u7cbe\u5ea6\u6d6e\u70b9\u6570\uff08\u4e0d\u91cf\u5316\uff0c\u4fdd\u7559\u539f\u59cb\u7cbe\u5ea6\uff09\u3002\u5176\u4ed6\u53ef\u9009\u503c\u5305\u62ec f32\u3001bf16 \u6216\u91cf\u5316\u683c\u5f0f\uff08\u5982 q8_0\u3001q4_k_m \u7b49\uff09<\/td><\/tr><tr><td><code>--verbose<\/code><\/td><td>\u5f00\u542f\u8be6\u7ec6\u8f93\u51fa\u6a21\u5f0f\uff0c\u5728\u8f6c\u6362\u8fc7\u7a0b\u4e2d\u6253\u5370\u8be6\u7ec6\u7684\u65e5\u5fd7\u4fe1\u606f\uff0c\u65b9\u4fbf\u6392\u67e5\u95ee\u9898\u6216\u67e5\u770b\u8f6c\u6362\u8fdb\u5ea6<\/td><\/tr><tr><td><code>--outfile Qwen3.5\u20112B\u2011gguf.gguf<\/code><\/td><td>\u6307\u5b9a\u8f6c\u6362\u540e\u751f\u6210\u7684 GGUF \u6587\u4ef6\u7684\u4fdd\u5b58\u8def\u5f84\u548c\u6587\u4ef6\u540d<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>\u3000\u3000<\/p>\n\n\n\n<p><strong>\u5e38\u7528\u91cf\u5316\u7c7b\u578b\u53c2\u8003<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table is-style-stripes\"><table><thead><tr><th>\u7c7b\u578b<\/th><th>\u8bf4\u660e<\/th><\/tr><\/thead><tbody><tr><td>f16<\/td><td>16\u2011bit \u534a\u7cbe\u5ea6\uff0c\u4e0d\u91cf\u5316\uff0c\u4fdd\u7559\u539f\u59cb\u7cbe\u5ea6<\/td><\/tr><tr><td>f32<\/td><td>32\u2011bit \u5168\u7cbe\u5ea6\uff0c\u4f53\u79ef\u6700\u5927<\/td><\/tr><tr><td>bf16<\/td><td>Brain Float 16\uff0c\u4e0e f16 \u7c7b\u4f3c\uff0c\u90e8\u5206\u786c\u4ef6\u652f\u6301\u66f4\u597d<\/td><\/tr><tr><td>q8_0<\/td><td>8\u2011bit \u91cf\u5316\uff0c\u7cbe\u5ea6\u8f83\u9ad8\uff0c\u4f53\u79ef\u7ea6\u4e3a f16 \u7684\u4e00\u534a<\/td><\/tr><tr><td>q4_k_m<\/td><td>4\u2011bit \u91cf\u5316\uff08\u63a8\u8350\uff09\uff0c\u5728\u51c6\u786e\u6027\u548c\u63a8\u7406\u901f\u5ea6\u4e4b\u95f4\u53d6\u5f97\u826f\u597d\u5e73\u8861\uff0c\u9002\u5408\u672c\u5730\u8fd0\u884c<\/td><\/tr><tr><td>q4_0<\/td><td>4\u2011bit \u91cf\u5316\uff0c\u4f53\u79ef\u6700\u5c0f\uff0c\u7cbe\u5ea6\u6709\u4e00\u5b9a\u635f\u5931<\/td><\/tr><\/tbody><\/table><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u8a00 \ud83d\udd16 \u4e0d\u540c\u672c\u5730\u90e8\u7f72\u5de5\u5177\u652f\u6301\u7684\u6a21\u578b\u683c\u5f0f\u4e0d\u540c\uff0c Ollama\u3001 llama.cpp\u652f\u6301GGUF\uff0cPyTorch [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[48],"tags":[],"_links":{"self":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/21238"}],"collection":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=21238"}],"version-history":[{"count":1,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/21238\/revisions"}],"predecessor-version":[{"id":21241,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/21238\/revisions\/21241"}],"wp:attachment":[{"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=21238"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=21238"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=21238"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}