unsetunset前言unsetunset
看見老扎說Meta要弄llama3了,用35w張H100來搞,然后開源。
因為工作中一直用OpenAI,所以沒弄過llama2,想著試一下llama2跑本地的效果,llama2官方下載地址:https://ai.meta.com/llama/

官方是需要填表的,我們直接使用社區(qū)的方案,不需要填任何東西,直接下載。
對了,我的環(huán)境是MacOS M2,windows或Linux請找其他文章了解。
unsetunset安裝環(huán)境unsetunset
首先,弄一下環(huán)境,創(chuàng)建一個Python 3.10.9的python虛擬環(huán)境,建議使用跟我一樣的python環(huán)境,如果是python 3.11,安裝環(huán)境的方式會有問題。
在python 3.10.9虛擬環(huán)境中安裝一下llm庫:
pip?install?llm
然后使用llm安裝llm-llama-cpp和llama-cpp-python就好了,llm庫幫我們處理好所有的細(xì)節(jié)。
llm?install?llm-llama-cpp
llm?install?llama-cpp-python
使用llm下載llama-2-7b-chat模型,這個模型只有7b的參數(shù),還有13b等更大的模型。
llm?llama-cpp?download-model?\
??https://huggingface.co/TheBloke/Llama-2-7B-Chat-GGML/resolve/main/llama-2-7b-chat.ggmlv3.q8_0.bin?\
??--alias?llama2-chat?--alias?l2c?--llama2-chat
因為我們這里下載的是ggmlv3,是舊的model format,新的modle format已經(jīng)改成了gguf,為了使用ggmlv3,我們需要安裝舊版本的llama-cpp-python。(https://stackoverflow.com/questions/76986412/assertionerror-when-using-llama-cpp-python-in-google-colab)
pip?install?llama-cpp-python==0.1.78
unsetunset使用unsetunset
命令行方式使用:
llm?-m?l2c?'你好,使用python寫一段生成斐波那契數(shù)列的代碼'

python代碼里使用.

結(jié)論:測了一些我這邊工作上的業(yè)務(wù)問題,效果一般,可能升到更多參數(shù)的模型效果會好一些。文章來源:http://www.zghlxwxcb.cn/news/detail-816527.html
如果效果差不多,我其實是偏向于使用llama的,比較本地llama不需要考慮openai api的ratelimit(當(dāng)然你可以用Azure的gpt api來緩解)。文章來源地址http://www.zghlxwxcb.cn/news/detail-816527.html
到了這里,關(guān)于MacOS M2使用llama2的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!