Ollama安裝
下載Ollama
網(wǎng)址:https://ollama.com/
支持macOS、Linux和Windows多個(gè)平臺(tái)
Ollama常用指令和鏈接
1. 常用指令
Available Commands:
serve Start ollama
create Create a model from a Modelfile
show Show information for a model
run Run a model
pull Pull a model from a registry
push Push a model to a registry
list List models
cp Copy a model
rm Remove a model
help Help about any command
Flags:
-h, --help help for ollama
-v, --version Show version information
2. 鏈接
Blog:https://ollama.com/blog
Docs:https://github.com/ollama/ollama/tree/main/docs
GitHub:https://github.com/ollama/ollama
模型倉庫:https://ollama.com/library
運(yùn)行Ollama
以Llama 3為例
ollama run llama3
自動(dòng)安裝latest的版本是8B 4-bit模型,信息如下:
如果是70B模型,可以參考
倉庫中Llama 3的介紹:https://ollama.com/library/llama3
運(yùn)行之后,項(xiàng)目默認(rèn)監(jiān)聽 11434 端口,終端查看
curl localhost:11434
輸出:
Ollama is running
運(yùn)行成功,可以在終端聊天了.
API 交互Ollama
按下 Ctrl + D 可以退出終端交互,但此時(shí)模型并不會(huì)退出,仍舊可以正常通過 Api 接口交互。
具體可以參考官網(wǎng)api文檔:https://github.com/ollama/ollama/blob/main/docs/api.md
簡單api交互例子,新打開一個(gè)終端,輸入
curl http://localhost:11434/api/generate -d '{
"model": "llama3",
"prompt": "Why is the sky blue?",
"stream": false
}'
退出可以從電腦右上角退出
基于Llama 3角色扮演
在任意目錄下建一個(gè)modelfile文件。具體信息查看官網(wǎng)modelfile文檔:
https://github.com/ollama/ollama/blob/main/docs/modelfile.md
modelfile文件:
FROM llama3
# set the temperature to 1 [higher is more creative, lower is more coherent]
PARAMETER temperature 1
# set the system message
SYSTEM """
You are Liu Bei from the Three Kingdoms period in China. Answer as Liu Bei, the assistant, only used Simplified Chinese.
"""
創(chuàng)建劉備的個(gè)人聊天助手,新的模型我命名為Czi
ollama create Czi -f ./Modelfile
查看模型:
ollama ls
運(yùn)行Czi模型
ollama run Czi
這樣就可以啦!
接下里是本地部署LobeChat,實(shí)現(xiàn)網(wǎng)頁的交互
LobeChat安裝
首先安裝docker
這里跳過了。。。
安裝LobeChat的docker 鏡像和運(yùn)行
LobeChat的幫助文檔與 Ollama 集成。
一行代碼:
docker run -d -p 3210:3210 -e OLLAMA_PROXY_URL=http://host.docker.internal:11434/v1 lobehub/lobe-chat
可以看到LobeChat運(yùn)行在本地3210端口,瀏覽器打開http://localhost:3210
這樣就可以交互了!
默認(rèn)的LobeChat沒有Czi模型,我們需要添加一下~
LobeChat的幫助文檔在 LobeChat 中使用 Ollama
和
在 設(shè)置 -> 語言模型 中找到 Ollama 的配置選項(xiàng)
配置好了,可以跟劉皇叔在LobeChat中聊天啦!文章來源:http://www.zghlxwxcb.cn/news/detail-859520.html
文章來源地址http://www.zghlxwxcb.cn/news/detail-859520.html
到了這里,關(guān)于Mac 安裝Ollama和llama3,本地部署LobeChat和劉皇叔聊三國的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!