6. 06 - Run a Local Model and Verify the Endpoint Workshop#
Time: 60 minutes · Audience: beginners · Updated: November 18, 2026.
6.1. Workshop preparation#
A supported Ollama installation, enough memory/disk for a chosen small model, and internet for the initial download. CPU fallback may be slow.
Download the shared workshop kit and extract it into a disposable folder. Browse all workshops. Code blocks run in your local terminal, not on this web page. Record your tool versions and use synthetic inputs.
6.2. Hands-on route#
Install Ollama using its official installer. Run
ollama --versionandollama listin a terminal.Choose a small local model compatible with your hardware from the official library. Run
ollama pull MODEL_ID, replacing MODEL_ID with that exact identifier. Model downloads consume disk and bandwidth.Run
ollama run MODEL_ID. Ask a short question and exit the interactive session with/bye. Useollama psto inspect the loaded model; do not assume GPU use.Query the API with the Python block below. Expect a JSON model listing, not a browser login page.
Optional document lab: connect a local document-Q&A client to this endpoint, import only the synthetic fixture, and ask one supported and one unsupported question. Check the displayed evidence before trusting an answer.
import json, urllib.request
with urllib.request.urlopen('http://127.0.0.1:11434/api/tags', timeout=10) as r:
print(json.dumps(json.load(r), indent=2))
Local inference has no hosted-model per-token fee, but hardware, electricity, memory and context limits remain. Privacy depends on the entire application stack, including any cloud models or external tools you configure.
6.3. Acceptance evidence#
Version record, installed model ID, one real response, and an API model listing.
Create evidence.md with your environment, commands, observed outputs, failures and fixes. Label anything you did not run. Do not include secrets, screenshots of account pages, or private paths.
6.4. Troubleshooting and cleanup#
Connection refused: check whether the service is running. Out of memory: choose a smaller model/context. Older GPUs are not universally supported; check the runtime support matrix. Stop any demo server when finished; retain only the small fixture and evidence needed to reproduce your result.
flowchart LR
A["Prepare synthetic fixture"] --> B["Run guided task"]
B --> C["Check observed result"]
C --> D["Record evidence and limitations"]
Image Suggestion (Nanobanana Prompt): A clean technical workshop illustration titled “Run a Local Model and Verify the Endpoint”, with a neutral editor window, a small synthetic fixture, and an evidence checklist. Use legible navy and teal typography on a light background, even lighting, and a visible “Concept illustration” label. Show no account identity, private paths, or simulated success presented as a screenshot.
6.5. Reference and optional extensions#
The material below provides background. Complete the guided acceptance test above first; vendor interfaces and example model IDs can change. Consult the linked official documentation for the version you use.
Running large language models (LLMs) on your own machine gives you local control and no hosted-model per-token fee for local inference, and the freedom to experiment offline. This tutorial walks you through the entire local AI stack — from installing your first model with Ollama, to building a private document Q&A system with AnythingLLM, and finally publishing your own fine-tuned model to Hugging Face.
6.6. Why Run LLMs Locally?#
Benefit |
Description |
|---|---|
Privacy |
Local-only operation depends on model, telemetry and tool configuration. Critical for proprietary code, medical records, or sensitive research. |
Cost |
No per-token API fees. Run as many queries as your hardware allows. |
Offline |
Works on airplanes, in restricted labs, and behind firewalls. |
Customization |
Swap models, tweak parameters, and build custom workflows freely. |
Latency |
No network round-trip. Responses can be faster for small models on good hardware. |
6.6.1. System Requirements (Minimum → Recommended)#
Component |
Minimum |
Recommended |
|---|---|---|
RAM |
8 GB |
16–32 GB |
Storage |
10 GB free |
50+ GB (models are large) |
GPU |
Not required (CPU mode) |
NVIDIA GPU with 8+ GB VRAM |
OS |
Windows 10+, macOS 12+, Linux |
Same |
6.7. Ollama: Your Local Model Engine#
Ollama is a lightweight CLI tool that lets you download and run open-source LLMs with a single command. Think of it as “Docker for LLMs.”
6.7.1. Installation#
Visit ollama.com/download and download the
.exeinstaller.Run the installer and follow the setup wizard.
Ollama will appear in your system tray when ready.
Download the
.dmgfrom ollama.com/download.Drag Ollama to your Applications folder.
Open Ollama from Applications — it runs in the menu bar.
Run the official install script:
curl -fsSL https://ollama.com/install.sh | sh
Verify your installation:
ollama --version
6.7.2. Downloading Your First Model#
Browse the full model library at ollama.com/library. Here are popular choices for beginners:
Model |
Size |
Best For |
|---|---|---|
|
~2 GB |
General chat, fast responses |
|
~4.7 GB |
Balanced quality and speed |
|
~4.4 GB |
Multilingual, strong reasoning |
|
~3.8 GB |
Code generation and debugging |
|
~4.1 GB |
Creative writing, summarization |
|
~4.7 GB |
Deep reasoning and math |
|
~4.5 GB |
Vision — understands images |
|
~274 MB |
Text embeddings (for RAG) |
Download a model with pull:
# Download Llama 3.1 (8B parameter version)
ollama pull llama3.1:8b
# Download a lightweight embedding model (needed for RAG later)
ollama pull nomic-embed-text
6.7.3. Running a Model (Interactive Chat)#
ollama run llama3.1:8b
You’ll enter an interactive chat session directly in your terminal:
>>> What is the capital of France?
The capital of France is Paris...
>>> /bye
Useful Commands Inside the Chat:
Type your question and press Enter to get a response.
Type
/byeto exit the session.Type
/set parameter num_ctx 4096to change context window size on the fly.
6.7.4. Essential Ollama CLI Commands#
# List all downloaded models
ollama list
# Show model metadata (parameters, size, quantization)
ollama show llama3.1:8b
# Remove a model to free disk space
ollama rm codellama:7b
# Start the Ollama API server (usually auto-starts)
ollama serve
# Copy/rename a model locally
ollama cp llama3.1:8b my-research-model
6.7.5. Using Ollama’s REST API (Programmatic Access)#
Ollama exposes a local REST API at http://localhost:11434. You can call it from any language:
Python Example:
import requests
response = requests.post(
"http://localhost:11434/api/generate",
json={
"model": "llama3.1:8b",
"prompt": "Explain quantum computing in 3 sentences.",
"stream": False
}
)
print(response.json()["response"])
cURL Example:
curl http://localhost:11434/api/generate -d '{
"model": "llama3.1:8b",
"prompt": "Write a haiku about machine learning.",
"stream": false
}'
6.7.6. Creating Custom Models with Modelfiles#
You can create a specialized version of any model by writing a Modelfile:
# Modelfile for a research writing assistant
FROM llama3.1:8b
# Set system personality
SYSTEM """
You are an expert academic research assistant specializing in GIScience
and remote sensing. Always cite methodology precisely and use formal
academic tone. When uncertain, say so rather than hallucinate.
"""
# Increase context window
PARAMETER num_ctx 8192
# Lower temperature for more deterministic outputs
PARAMETER temperature 0.3
Build and run your custom model:
# Create the custom model
ollama create research-assistant -f Modelfile
# Run it
ollama run research-assistant
6.8. AnythingLLM: A Private Document Q&A System (RAG)#
AnythingLLM is a desktop application that connects to your local Ollama models and lets you chat with your own documents — PDFs, Word files, code repositories, and more. This is called Retrieval-Augmented Generation (RAG).
6.8.1. How RAG Works (For Beginners)#
graph LR
A[Your Documents] --> B[Split into Chunks]
B --> C[Convert to Embeddings]
C --> D[Store in Vector DB]
E[Your Question] --> F[Find Relevant Chunks]
D --> F
F --> G[Feed to LLM]
G --> H["AI Answer (with sources!)"]
Instead of the LLM guessing from its training data, RAG forces it to look up your actual documents first, then generate an answer based on what it found. This dramatically reduces hallucination.
6.8.2. Installing AnythingLLM#
Visit useanything.com and download the desktop app for your OS.
Install and launch it. You’ll see a setup wizard.
Docker Alternative:
docker pull mintplexlabs/anythingllm
docker run -d -p 3001:3001 \
--name anythingllm \
-v ${HOME}/anythingllm:/app/server/storage \
mintplexlabs/anythingllm
6.8.3. Connecting AnythingLLM to Ollama#
During the setup wizard (or in Settings):
LLM Provider: Select Ollama.
Base URL:
http://localhost:11434(default, auto-detected).Model: Choose from your downloaded Ollama models (e.g.,
llama3.1:8b).
Embedding Provider: Select Ollama.
Model: Choose
nomic-embed-text(the embedding model we downloaded earlier).
Vector Database: Keep the default LanceDB (built-in, zero config).
6.8.4. Creating a Workspace & Uploading Documents#
Click “New Workspace” and name it (e.g., “Research Papers”).
Click the Upload icon in your workspace.
Drag and drop your files:
Supported formats:
.pdf,.txt,.docx,.md,.csv,.json,.py,.js, and more.
Click “Move to Workspace” to process and embed your documents.
Wait for the status to show “Embedded” for each file.
6.8.5. Chatting With Your Documents#
Once documents are embedded, simply type questions in the chat box:
You: What methodology did the authors use for building extraction?
AI: Based on the uploaded papers, the authors employed a two-stage approach:
first using HSV color thresholding for initial segmentation, followed by
a Mask R-CNN model for refined building footprint extraction...
[Source: paper_2024_building_extraction.pdf, page 7]
The AI will cite which document and page it found the answer in!
6.8.6. Advanced AnythingLLM Features#
Feature |
Description |
|---|---|
Multiple Workspaces |
Separate knowledge bases per project (e.g., “Thesis”, “Course Prep”, “Code Docs”). |
Chat Modes |
Switch between “Chat” (conversational) and “Query” (strict document-only answers). |
API Access |
AnythingLLM provides its own API at |
Agent Mode |
Enable web browsing, code execution, and file management agents within AnythingLLM. |
Multi-User |
Share your instance with lab mates, each with their own login and workspaces. |
6.9. Publishing Models to Hugging Face#
Once you’ve fine-tuned a model or created a useful custom variant, you can share it with the world via the Hugging Face Hub.
6.9.1. Setting Up Your Hugging Face Account#
Sign up at huggingface.co/join.
Go to Settings → Access Tokens → New Token.
Create a token with Write access. Copy it — you’ll need it shortly.
6.9.2. Installing the Hugging Face CLI#
pip install huggingface_hub transformers
6.9.3. Authenticating#
huggingface-cli login
Paste your Write token when prompted. This stores credentials locally so you don’t need to re-authenticate.
Alternatively, in Python:
from huggingface_hub import login
login(token="hf_YOUR_TOKEN_HERE")
6.9.4. Uploading a Model (Python API)#
If you have a fine-tuned Transformers model saved locally:
from transformers import AutoModelForCausalLM, AutoTokenizer
# Load your locally fine-tuned model
model = AutoModelForCausalLM.from_pretrained("./my-finetuned-model")
tokenizer = AutoTokenizer.from_pretrained("./my-finetuned-model")
# Push to Hugging Face Hub
# This creates the repo "your-username/my-research-llm" automatically
model.push_to_hub("your-username/my-research-llm")
tokenizer.push_to_hub("your-username/my-research-llm")
6.9.5. Uploading a Model (CLI)#
For uploading arbitrary files (GGUF, safetensors, configs):
# Create a new repository on Hugging Face
huggingface-cli repo create my-research-llm --type model
# Upload all files from a local directory to the repo
huggingface-cli upload your-username/my-research-llm ./my-model-folder .
6.9.6. Uploading GGUF Files (Ollama-Compatible Format)#
If you’ve quantized a model into GGUF format (used by Ollama and llama.cpp):
from huggingface_hub import HfApi
api = HfApi()
# Create a repository
api.create_repo("your-username/my-model-gguf", repo_type="model")
# Upload the GGUF file
api.upload_file(
path_or_fileobj="./my-model.Q4_K_M.gguf",
path_in_repo="my-model.Q4_K_M.gguf",
repo_id="your-username/my-model-gguf",
)
6.9.7. Writing a Good Model Card#
Every model on Hugging Face should have a README.md (Model Card). This is critical for discoverability and reproducibility:
---
license: apache-2.0
language:
- en
tags:
- llama
- geospatial
- research
base_model: meta-llama/Llama-3.1-8B
datasets:
- your-username/your-dataset
---
# My Research LLM
## Model Description
A fine-tuned Llama 3.1 8B model specialized for geospatial research tasks
including building extraction, land use classification, and map analysis.
## Training Details
- **Base Model**: Llama 3.1 8B
- **Fine-tuning Method**: LoRA (rank=16, alpha=32)
- **Training Data**: 50,000 geospatial Q&A pairs
- **Hardware**: 1x NVIDIA A100 80GB
- **Training Time**: ~8 hours
## Usage
```python
from transformers import pipeline
pipe = pipeline("text-generation", model="your-username/my-research-llm")
result = pipe("Describe the land use pattern in this satellite image analysis...")
6.10. Evaluation#
Benchmark |
Score |
|---|---|
GeoQA Accuracy |
87.3% |
MapReader F1 |
0.92 |
6.11. Limitations#
Optimized for English-language geospatial tasks only.
May hallucinate specific coordinate values.
6.12. Citation#
If you use this model, please cite:
@misc{yang2025geollm,
title={GeoLLM: A Specialized Language Model for Geospatial Research},
author={Yang, Eric},
year={2025}
}
6.13. End-to-End Workflow: From Download to Deployment#
Here is a complete workflow combining everything we’ve learned:
graph TD
S1["1. Install Ollama"] --> S2["2. Pull a base model (e.g., llama3.1:8b)"]
S2 --> S3["3. Create a custom Modelfile"]
S3 --> S4["4. Build custom model with ollama create"]
S4 --> S5["5. Install AnythingLLM"]
S5 --> S6["6. Connect AnythingLLM to Ollama"]
S6 --> S7["7. Upload research papers into a Workspace"]
S7 --> S8["8. Chat with your documents!"]
S8 --> S9["9. (Optional) Fine-tune on domain data"]
S9 --> S10["10. (Optional) Publish to Hugging Face"]
6.14. Troubleshooting Common Issues#
Problem |
Solution |
|---|---|
|
Restart your terminal. On Linux, ensure |
Model download stuck |
Check disk space with |
Slow responses (no GPU) |
Use smaller quantized models like |
AnythingLLM can’t find Ollama |
Ensure |
Out of memory (OOM) |
Close other apps. Use a smaller model. Add |
CUDA/GPU not detected |
Install the NVIDIA CUDA Toolkit and update GPU drivers. |
6.15. Read More#
6.15.1. Official Documentation#
Ollama Documentation — Official README with full command reference and API docs.
Ollama Model Library — Browse and search all available models.
AnythingLLM Docs — Official documentation for setup, configuration, and API usage.
Hugging Face Hub Documentation — Complete guide to uploading, versioning, and sharing models.
6.15.2. Tutorials & Guides#
freeCodeCamp: How to Run LLMs Locally with Ollama — Beginner-friendly written tutorial.
SitePoint: Local LLMs in Production (2025) — Advanced guide on using Ollama in production environments.
Hugging Face Course — Free course covering Transformers, fine-tuning, and model sharing.
GGUF Format Explained — Understanding the model format used by Ollama and llama.cpp.
6.15.3. Community & Ecosystem#
Open WebUI — Beautiful, feature-rich web interface for Ollama (ChatGPT-like UI).
LM Studio — GUI alternative to Ollama for running local models with a visual interface.
Ollama Discord Community — Ask questions and share configurations with other local LLM enthusiasts.
6.16. Knowledge Quiz#
Q1: What is the single command to download and interactively chat with Meta’s Llama 3.1 model using Ollama?
Answer
First pull: ollama pull llama3.1:8b, then run: ollama run llama3.1:8b. Or simply ollama run llama3.1:8b which will auto-pull if not already downloaded.
Q2: In AnythingLLM, what is the fundamental difference between “Chat” mode and “Query” mode?
Answer
“Chat” mode is conversational — the AI uses both its training knowledge and your documents to answer. “Query” mode is strict — the AI ONLY answers based on your uploaded documents. If the answer isn’t in your docs, it will say it doesn’t know rather than guessing.
Q3: When publishing a model to Hugging Face, why is a Model Card (README.md) important?
Answer
The Model Card describes the model’s training data, methodology, intended use, limitations, and evaluation metrics. It is essential for reproducibility, discoverability (search ranking on HF Hub), and ethical transparency. It helps other researchers decide whether the model is appropriate for their use case.