Skip to main content

Ollama Getting Started (Llama 3, Mac, Apple Silicon)

In this article, I will show you how to get started with Ollama on a Mac.

info
  • These instructions were written for and tested on a Mac (M1, 8GB).
  • You will have much better success on a Mac that uses Apple Silicon (M1, etc.).
  • The model will require 5GB of free disk space, which you can free up when not in use.

Step 1. Download and install Ollama

On a Mac, (at the time of this writing) this will download a *.zip file to your ~/Downloads folder.

  • In Finder double click the *.zip file to extract the contents
  • This should extract Ollama.app to your ~/Downloads folder
  • Drag Ollama.app to your Applications folder
  • You can then delete the downloaded zip file to save space

Step 2. Setup Ollama

After you download Ollama you will need to run the setup wizard:

  • In Finder, browse to the Applications folder
  • Double-click on Ollama
  • When you see the warning, click Open
  • Go through the setup wizard where it should prompt you to install the command line version (ollama)
  • Then it will give you instructions for running a model
    • At the time of this writing, the default instructions show llama2, but llama3 works too
  • Click Finish

Step 3. Run llama 3

  • You could follow the instruction to run llama 2, but let's jump right in with llama 3
  • Open a new Terminal window
  • Run this command (note that for this command llama3 is one word):
ollama run llama3 
  • The first time you run that for a new model, it will download the latest version

Step 4. Chat with llama 3

After the model is downloaded, you should see a prompt like this:

>>> Send a message (/? for help)
  • At the prompt, start chatting with it like any other LLM
  • Here are some example prompts

Chat completion prompt

>>> Mary had a 

Code prompt

write a hello world program in javascript
note
  • The llama2 model was not known for its coding skills, but llama3 should be better
  • I will post at the end of this document info on how Code Llama was integrated into llama3

Step 5. View help at the prompt

To get help at the prompt, enter this command and hit return:

/?

Step 6. Stop chatting

To exit the chat, enter this prompt (note the '/')):

/bye

Step 7. Get help from the command line

Previously I showed you how to get help in ollama at the prompt level.

To get help from the ollama command-line interface (cli), just run the command with no arguments:

ollama

To see a list of currently installed models, run this:

ollama list

In my case I see this:

NAME         	ID          	SIZE  	MODIFIED       
llama3:latest a6990ed6be41 4.7 GB 34 minutes ago

Step 8. Cleanup

Currently, the llama3 model takes up 4.7 GB.

To free up the disk space on your computer, you can remove the model with this command:

ollama rm llama3

You can always download it and run it again later with the ollama run command.

Conclusion

In this article you learned how to:

  • Install ollama on a Mac
  • Run ollama to download and run the Llama 3 LLM
  • Chat with the model from the command line
  • View help while chatting with the model
  • Get help from the command line utility
  • List the current models installed
  • Remove a model to free up disk space

Additional models

You can use other models, besides just llama2 and llama3.

For more models, click the Models tab on https://ollama.com or visit: https://ollama.com/library

Code Llama and Llama 3

Here is what meta.ai says about Code Llama and Llama 3

Code Llama, a separate AI model designed for code understanding and generation, was integrated into LLaMA 3 (Large Language Model Meta AI) to enhance its coding capabilities. This integration enabled LLaMA 3 to leverage Code Llama's expertise in code-related tasks, such as:

  • Code completion
  • Code generation
  • Code explanation
  • Code review

The integration allows LLaMA 3 to tap into Code Llama's knowledge base, which was trained on a massive dataset of code from various sources, including open-source repositories and coding platforms. This enables LLaMA 3 to provide more accurate and informative responses to coding-related queries and tasks. In essence, the integration of Code Llama into LLaMA 3 creates a powerful hybrid AI model that can tackle a wide range of tasks, from general knowledge and conversation to coding and software development.

References