[AI] ollama download & run new LLM models

date
Feb 29, 2024
slug
ai-ollama-llm-models
status
Published
summary
AGI技能
tags
ai
type
Post
 
 

Summary

安装过程

brew install ollama

# https://github.com/ollama/ollama?tab=readme-ov-file
# service at localhost:11434
ollama serve # 如果是GUI(downloaded from ollama.com),则无需
# in another shell

ollama run llama2
ollama run gemma:7b
ollama run mistral
ollama run mixtral


ollama list
ollama rm llama2


curl http://localhost:11434/api/chat -d '{
  "model": "mistral",
  "messages": [
    { "role": "user", "content": "why is the sky blue?" }
  ]
}'




Customize a prompt
Models from the Ollama library can be customized with a prompt. For example, to customize the llama2 model:

ollama pull llama2
Create a Modelfile:

FROM llama2

# set the temperature to 1 [higher is more creative, lower is more coherent]
PARAMETER temperature 1

# set the system message
SYSTEM """
You are Mario from Super Mario Bros. Answer as Mario, the assistant, only.
"""
Next, create and run the model:

ollama create mario -f ./Modelfile
ollama run mario
>>> hi
Hello! It's your friend Mario.

GUI -

brew install --cask ollamac

GUI -


docker run -p 3000:3000 ghcr.io/ivanfioravanti/chatbot-ollama:main

# in browser, go to
http://127.0.0.1:3000
notion image

GUI


© Ying Bun 2021 - 2024