Cheatsheet & Examples: ollama

HongHong
3 min read

Run a model

Example Usage:
ollama run <model>

What it does:
Starts a model for interactive use, allowing users to input prompts and receive responses directly in the terminal.

Command-line Arguments Explained:

  • <model>: The name of the model to run (e.g., llama3, mistral).

Pull a model

Example Usage:
ollama pull <model> [--insecure] [--quantize <value>]

What it does:
Downloads a specified model from the Ollama model library to the local machine.

Command-line Arguments Explained:

  • <model>: The name of the model to pull (e.g., llama3:latest).
  • --insecure: Disables SSL verification for insecure connections.
  • --quantize <value>: Specifies the quantization level (e.g., 4, 8) to reduce model size.

List models

Example Usage:
ollama list [--all] [--migrate]

What it does:
Displays all locally installed models, optionally including all available models or migrating outdated ones.

Command-line Arguments Explained:

  • --all: Shows all models (including those not yet pulled).
  • --migrate: Migrates models to the latest format if needed.

Remove a model

Example Usage:
ollama rm <model>

What it does:
Deletes a specified model from the local machine.

Command-line Arguments Explained:

  • <model>: The name of the model to remove (e.g., llama3).

Start the Ollama server

Example Usage:
ollama serve [--host <address>] [--port <port>] [--modeldir <path>]

What it does:
Launches the Ollama server with custom configuration for hosting models.

Command-line Arguments Explained:

  • --host <address>: Sets the IP address to bind the server to.
  • --port <port>: Specifies the port number for the server.
  • --modeldir <path>: Defines the directory where models are stored.

Push a model to the Ollama library

Example Usage:
ollama push <model> [--insecure]

What it does:
Uploads a locally created model to the Ollama model library for sharing or deployment.

Command-line Arguments Explained:

  • <model>: The name of the model to push (e.g., my-custom-model).
  • --insecure: Disables SSL verification for the push operation.

Create a custom model

Example Usage:
ollama create <model-name> --file <path-to-config>

What it does:
Generates a new model from a configuration file, allowing customization of parameters or training data.

Command-line Arguments Explained:

  • <model-name>: The name to assign to the custom model.
  • --file <path-to-config>: Path to the JSON configuration file defining the model.

Manage model configurations

Example Usage:
ollama model <model-name> --describe --show

What it does:
Displays detailed information about a model, including its configuration and settings.

Command-line Arguments Explained:

  • <model-name>: The model to inspect.
  • --describe: Shows a description of the model.
  • --show: Displays the model’s full configuration.

Display help documentation

Example Usage:
ollama help [command] [--all]

What it does:
Provides usage instructions and details for a specific command or all commands.

Command-line Arguments Explained:

  • [command]: The specific command to get help for (e.g., run, pull).
  • --all: Shows help for all available commands.
0
Subscribe to my newsletter

Read articles from Hong directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Hong
Hong

I am a developer from Malaysia. I work with PHP most of the time, recently I fell in love with Go. When I am not working, I will be ballroom dancing :-)