Ollama allows you to get up and running with large language models locally.
Installation
# macOS / Linux
curl -fsSL https://ollama.com/install.sh | shBasic Commands
ollama serve # Start the Ollama server (usually runs as a service in the background)
ollama run llama3 # Download (if needed) and run the LLaMA 3 model
ollama run mistral # Run the Mistral modelModel Management
ollama list # List all locally downloaded models
ollama pull codellama # Download a model without running it
ollama rm llama2 # Delete a local model to free up space
ollama show llama3 # Show metadata and system prompt for a modelCreating Custom Models (Modelfile)
You can create a custom model by writing a Modelfile.
- Create a file named
Modelfile:
FROM llama3
# Set the temperature (higher = more creative, lower = more coherent)
PARAMETER temperature 0.7
# Set the system message
SYSTEM """
You are Mario from Super Mario Bros. Answer as Mario, only using his catchphrases.
"""- Build and run the model:
ollama create mario -f ./Modelfile
ollama run marioAPI Usage
Ollama provides a local REST API (default port 11434).
curl http://localhost:11434/api/generate -d '{
"model": "llama3",
"prompt": "Why is the sky blue?",
"stream": false
}'