Skip to content

本地模型部署 ​

本地部署大模型,兼容openai

资源 ​

官网:https://ollama.com/

安装 ​

bash
curl -fsSL https://ollama.com/install.sh | sh

模型下载 ​

模型列表:https://ollama.com/search?page=4

docker启动 ​

bash
docker run -d \
  --name ollama \
  -p 11434:11434 \
  -v ollama:/root/.ollama \
  --restart unless-stopped \
  ollama/ollama

api调用 ​

bash
curl http://localhost:11434/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "qwen2.5:1.5b",
"messages": [{"role":"user","content":"你好"}]
}'
python
from langchain_ollama import Chatollama
model Chatollama(
    model="deepseek-r1:1.5b",
    base_url="http://Localhost:11434"
)
print(model.invoke("介绍一下你自己"))