Running an Large Language Model locally let's you play with the latest models! Learn by doing.
- OS – recent version of macOS, or Linux
- Storage – minimum 50 Gb free
- Memory – minimum 8 Gb, 16 Gb or more ideal
We will use Ollama, an application for running Large Language Models locally. Download and install Ollama: https://ollama.ai/download
- Open a terminal and start ollama.
ollama serve
- Check to see if it is installed:
ollama –version
Pull a LLM:
ollama pull orca-mini
Start ollama:
ollama run orca-mini
Ollama is currently not available for Windows. However, a Docker image is available, and requires installing Docker.
- Install Docker. https://docs.docker.com/desktop/install/windows-install/
- Open a Powershell window as Administrator
- Pull the ollama container image from Docker Hub. Copy and paste this command in the Powershell window.
docker pull ollama/ollama
- Start the ollama container. Copy and paste this command in the Powershell window.
docker run -d -v ollama:/root/.ollama -p 11434:11434 --name ollama ollama/ollama
- To run a model locally, copy and paste this command in the Powershell window.
docker exec -it ollama ollama run orca-mini
If you are familiar with Python, using a Jupyter notebook provides an option to save your work and extending the capability of a LLM. We will use Anaconda Distribution,
- Download anaconda: https://www.anaconda.com/download
- Install anaconda: https://docs.anaconda.com/free/anaconda/install/index.html
- We will use Anaconda Navigator: https://docs.anaconda.com/free/anaconda/getting-started/#navigator-tutorials
- Open Anaconda Navigator https://docs.anaconda.com/free/navigator/getting-started/#starting-navigator
- In Navigator, launch JupyterLab. It will open a page in a browser.
- In the Jupyter page choose
New
>Python3
(ipykernel) - In the first cell, paste the following to install langchain, then choose Run.
conda install langchain -c conda-forge
- Add a new cell and paste the following
from langchain.llms import Ollama
from langchain.callbacks.manager import CallbackManager
from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler
llm = Ollama(model="orca-mini",
callback_manager = CallbackManager([StreamingStdOutCallbackHandler()]))
llm("Why is the sky blue?")
Open the notebooks.