準(zhǔn)備工作
如果通過GPU來運(yùn)行,一般辦公電腦的顯卡可能達(dá)不到所需的要求,所以,可以通過CPU+內(nèi)存的方式花最低的代價(jià)來部署一套本地運(yùn)行AI的模型。
1、首先下載CPU-Z,運(yùn)行看一下電腦當(dāng)前的指令集是否包含AVX512,非AVX512指令部署完應(yīng)該也能運(yùn)行,但可能運(yùn)行速度會(huì)非常慢。(我的電腦是Thinkpad T14 gen2 ,內(nèi)存32G,系統(tǒng)是Windows 10)
2、下載llama.cpp。
llama.cpp AVX512指令 百度云盤下載地址
提前碼:an5m
如果電腦不支持AVX512指令,可以通過llama.app下載其他指令集,全部署完嘗試一下能不能用。
3、下載對(duì)應(yīng)的模型。
以下提供兩種模型,可任意選或都下載去運(yùn)行對(duì)比一下(個(gè)人推薦Vicuna)。
1)、vicuna_13b模型。
Vicuna Github代碼地址
Vicuna號(hào)稱"小羊駝",Vicuna是基于ShareGPT的7萬條對(duì)話數(shù)據(jù)對(duì)LLaMA微調(diào)的模型,13b模型的效果據(jù)說可達(dá)到ChatGPT3.5 92%的效果,部分問答的評(píng)分甚至超過了ChatGPT3.5。
vicuna_13b百度云盤下載地址
提前碼:0n9g
里面vicuna-13B-1.1-GPTQ-4bit-32g.GGML.bin和vicuna-13B-1.1-GPTQ-4bit-128g.GGML.bin
下載哪個(gè)都可以,我用的是vicuna-13B-1.1-GPTQ-4bit-128g.GGML.bin
2)、alpaca_13b模型
Alpaca Github代碼地址
Alpaca是斯坦福大學(xué)基于LLaMA模型指令微調(diào)的模型,13b模型的效果可達(dá)到近似ChatGPT3.5的效果(個(gè)人感覺比Vicuna稍微差了一點(diǎn)) 。
針對(duì)alpaca_13b,國(guó)內(nèi)提供了對(duì)應(yīng)中文擴(kuò)展合并模型。
alpaca_13b百度云盤中文擴(kuò)展合并模型下載地址
提前碼:rru0
部署步驟
新建一個(gè)文件夾,我這里的文件夾叫“ai”,并解壓下載好的llama.cpp包
解壓后的文件如下圖。
下面提供這兩次模型的具體部署方式,可任選一種,或兩種都部署。
1)vicuna_13b模型部署
將下載好的vicuna-13B-1.1-GPTQ-4bit-32g.GGML.bin或vicuna-13B-1.1-GPTQ-4bit-128g.GGML.bin文件考入到剛才新建的文件夾“ai”內(nèi)。
新建一個(gè)擴(kuò)展名為.bat的文件(直接建個(gè)記事本,將擴(kuò)展名改一下就行)。
右鍵編輯新建的.bat文件輸入下圖的文本,保存運(yùn)行即可。
"main.exe" --ctx_size 2048 --temp 0.7 --top_k 40 --top_p 0.5 --repeat_last_n 256 --batch_size 1024 --repeat_penalty 1.17647 --model "vicuna-13B-1.1-GPTQ-4bit-128g.GGML.bin" --n_predict 2048 --color --interactive --reverse-prompt "User:" --prompt "Text transcript of a never ending dialog, where User interacts with an AI assistant named ChatLLaMa. ChatLLaMa is helpful, kind, honest, friendly, good at writing and never fails to answer User's requests immediately and with details and precision. There are no annotations like (30 seconds passed...) or (to himself), just what User and ChatLLaMa say aloud to each other. The dialog lasts for years, the entirety of it is shared below. It's 10000 pages long. The transcript only includes text, it does not include markup like HTML and Markdown."
運(yùn)行效果如下圖
Vicuna雖然沒有專門針對(duì)中文做過微調(diào),但對(duì)中文的支持還是很不錯(cuò)的,偶爾中文的問答還是有些不完美的地方,建議復(fù)雜的問題用英文來問答。
2)alpaca_13b模型部署
將下載好的ggml-model-f16.bin文件考入到剛才新建的文件夾“ai”內(nèi)。
新建一個(gè)擴(kuò)展名為.bat的文件(直接建個(gè)記事本,將擴(kuò)展名改一下就行)。
右鍵編輯新建的.bat文件輸入下圖的文本,保存運(yùn)行即可。
"main.exe" --ctx_size 2048 --temp 0.7 --top_k 40 --top_p 0.5 --repeat_last_n 256 --batch_size 1024 --repeat_penalty 1.17647 --model "ggml-model-f16.bin" --n_predict 2048 --color --interactive --reverse-prompt "User:" --prompt "Text transcript of a never ending dialog, where User interacts with an AI assistant named ChatLLaMa. ChatLLaMa is helpful, kind, honest, friendly, good at writing and never fails to answer User's requests immediately and with details and precision. There are no annotations like (30 seconds passed...) or (to himself), just what User and ChatLLaMa say aloud to each other. The dialog lasts for years, the entirety of it is shared below. It's 10000 pages long. The transcript only includes text, it does not include markup like HTML and Markdown."
運(yùn)行效果如下圖
Alpaca 13b微調(diào)的模型文件較大,而且運(yùn)行很占內(nèi)存,一些問題回答的不是很完美。文章來源:http://www.zghlxwxcb.cn/news/detail-444948.html
注意:Vicuna和Alpaca都是基于LLaMa的,不能用于商用。
文章來源地址http://www.zghlxwxcb.cn/news/detail-444948.html
到了這里,關(guān)于筆記本電腦部署本地離線版類似ChatGPT3.5的AI模型(CPU+內(nèi)存運(yùn)行)的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!