Run a model on your laptop
Run a small open model on your own machine and call it two ways: from the terminal and over HTTP.
You build: A local model that answers on http://localhost:11434, with no account and no bill.
- Ollama
- About 3 GB of free disk
-
01Install Ollama and pull a small model
Everything in this course can start on a model this size. Bigger models come later, when you can measure whether they are worth it.
ollama pull llama3.2 && ollama listYou pass when: The list shows llama3.2 with a size of about 2 GB.
-
02Ask it one question from the terminal
ollama run llama3.2 "In one sentence, what is a token?"You pass when: One sentence prints and you get your prompt back.
-
03Call the same model over HTTP
This is the same request shape most hosted models accept. Every later lab is this call with more around it.
curl -s http://localhost:11434/v1/chat/completions -H 'Content-Type: application/json' -d '{"model":"llama3.2","messages":[{"role":"user","content":"Say hi in three words."}]}'You pass when: JSON comes back with the answer under choices[0].message.content and a usage block that counts prompt and completion tokens.
The check runs on the computer, not on your word: a step passes when its command exits with 0 there.
Computers are not set up on this site yet. Run each command on your own machine and compare with "You pass when".
Commands run in labs/10-local-model and may take up to 60 seconds each. Every command starts a new shell: put keys and settings in a .env file there, it is loaded each time.