Three Everyday Tasks for a Small Local LLM, with Python and Ollama

Three Everyday Tasks for a Small Local LLM, with Python and Ollama

A small local model can help suggest commit messages, rename screenshots, and summarize RSS without trying to answer every question. The idea is to keep its task focused: give it prepared changes, an image, or the text of a post, and ask for a specific output.

This approach draws on three uses of models with fewer than 3 billion parameters on a MacBook Air: Qwen3-1.7B for Git and summaries, and Qwen3.5-2B for analyzing screenshots. They are not interchangeable: the image model must be able to process images. In the tests described by XDA, the results were more useful for simple, repetitive tasks than for work requiring broad reasoning.

Set up a client for the local server

The example uses Ollama's local API from Python and the standard library, without installing an additional client. Before running the scripts, Ollama must be running and a model must be available on that server. The model name is passed as an argument, so you can select Qwen3-1.7B for text and a vision model, such as Qwen3.5-2B, for screenshots.

The sequence for all three automations is the same: prepare a focused input, request a brief response, and check it before using it. The diagram shows this workflow and its three input types.

flowchart TD
    A["Specific input"] --> B["Prepare text or image"]
    B --> C["Local Ollama"]
    C --> D["Model suggestion"]
    D --> E["Check before using"]
    E --> F["Git message"]
    E --> G["Screenshot name"]
    E --> H["RSS summary"]

Create a file called local_llm.py. This function sends a non-streaming request to Ollama, returns the response field, and lets you attach an image encoded in Base64. The server listens on localhost; if your installation uses a different address, you can change it with an environment variable.

# local_llm.py
import json
import os
import urllib.request

OLLAMA_URL = os.environ.get(
    "OLLAMA_URL", "http://127.0.0.1:11434/api/generate"
)


def generate(model, prompt, images=None):
    payload = {
        "model": model,
        "prompt": prompt,
        "stream": False,
    }
    if images:
        payload["images"] = images

    request = urllib.request.Request(
        OLLAMA_URL,
        data=json.dumps(payload).encode("utf-8"),
        headers={"Content-Type": "application/json"},
        method="POST",
    )
    with urllib.request.urlopen(request, timeout=180) as response:
        result = json.loads(response.read().decode("utf-8"))
    return result["response"].strip()

1. Suggest a message for the staged changes

Git can show only the changes included in the staging area with git diff --staged. The script uses that output as input instead of sending the entire repository. If there are no staged changes, it exits without calling the model; if there are, it prints a suggestion in Conventional Commits format.

# commit_message.py
import argparse
import subprocess
from local_llm import generate

parser = argparse.ArgumentParser()
parser.add_argument("--model", default="qwen3:1.7b")
args = parser.parse_args()

diff = subprocess.run(
    ["git", "diff", "--staged"],
    check=True,
    capture_output=True,
    text=True,
).stdout

if not diff.strip():
    raise SystemExit("No staged changes to summarize.")

prompt = (
    "Suggest a single commit message in Conventional Commits format. "
    "Use a prefix such as feat, fix, or refactor when appropriate. "
    "Be brief and describe only what the changes show. "
    "Return only the message.\n\n"
    f"Staged changes:\n{diff[:12000]}"
)
print(generate(args.model, prompt))

Save it alongside local_llm.py and run it from the repository with python commit_message.py --model qwen3:1.7b. The default is an example name based on the model cited by XDA; use the identifier available in your installation. The program suggests the text, but does not run git commit: review the message and changes before committing anything.

For an authentication change, for example, the output might describe handling expired tokens and a login redirect. But a large or complex diff can lead to an incomplete description: the suggestion does not replace reviewing the diff. Limiting the input to staged changes helps avoid including unrelated changes in that commit.

2. Create names for screenshots

A text model cannot infer what an image shows from its filename. For this task, the script encodes the file and sends it with an instruction to a model with vision capabilities. The suggestion is normalized as a filename, the original extension is preserved, and overwriting an existing file is avoided.

# rename_screenshot.py
import argparse
import base64
import re
from pathlib import Path
from local_llm import generate

parser = argparse.ArgumentParser()
parser.add_argument("image", type=Path)
parser.add_argument("--model", default="qwen3.5:2b")
args = parser.parse_args()

image = args.image
if not image.is_file():
    raise SystemExit(f"Image not found: {image}")

encoded = base64.b64encode(image.read_bytes()).decode("ascii")
prompt = (
    "Describe the contents of this screenshot with a short name. "
    "Return only lowercase words separated by hyphens. "
    "Do not include an extension or explanations."
)
name = generate(args.model, prompt, images=[encoded])
slug = re.sub(r"[^a-z0-9]+", "-", name.lower()).strip("-")
if not slug:
    raise SystemExit("The model did not suggest a usable name.")

candidate = image.with_name(slug + image.suffix)
number = 2
while candidate.exists() and candidate != image:
    candidate = image.with_name(f"{slug}-{number}{image.suffix}")
    number += 1

if candidate == image:
    raise SystemExit("The suggestion matches the current name.")
image.rename(candidate)
print(candidate)

To try it, run python rename_screenshot.py path/to/screenshot.png --model qwen3.5:2b. The extension is not generated from the response: the original file's extension is retained. If the name already exists, a number is added instead of replacing it.

Screenshots with small text or unfamiliar interfaces can produce generic or incorrect names. So it is a good idea to start with a test folder and review the suggestions, especially before processing many images. The script renames the file as soon as it finishes, so make a copy if you need to keep the original name.

3. Summarize RSS feed entries

To avoid adding another dependency, the following script uses xml.etree.ElementTree, which is part of Python, and processes an RSS feed that can already be read from a URL. It summarizes the title and description fields of each available entry: it does not download the full article. If the feed provides only an excerpt, that excerpt is all the model will receive.

# summarize_rss.py
import argparse
import urllib.request
import xml.etree.ElementTree as ET
from local_llm import generate

parser = argparse.ArgumentParser()
parser.add_argument("feed_url")
parser.add_argument("--model", default="qwen3:1.7b")
parser.add_argument("--limit", type=int, default=5)
args = parser.parse_args()

request = urllib.request.Request(
    args.feed_url,
    headers={"User-Agent": "LocalRSSSummary/1.0"},
)
with urllib.request.urlopen(request, timeout=30) as response:
    xml_data = response.read()

root = ET.fromstring(xml_data)
items = root.findall(".//item")[:args.limit]
if not items:
    raise SystemExit("No RSS entries found in the feed.")

for item in items:
    title = item.findtext("title", default="").strip()
    description = item.findtext("description", default="").strip()
    text = f"Title: {title}\nDescription: {description}"
    prompt = (
        "Summarize this RSS entry in two or three sentences. "
        "Stick to the included information; do not add anything.\n\n"
        f"{text[:8000]}"
    )
    print(f"\n{title}\n{generate(args.model, prompt)}")

Enter the feed URL and, if needed, the available model: python summarize_rss.py https://example.test/feed.xml --model qwen3:1.7b --limit 5. The URL is illustrative, not a specific feed. The limit reduces the number of entries processed, while truncating the text keeps each request focused.

A brief summary can help you decide what to read, but it does not replace the article. In How-To Geek's tests, a small local model summarized extensive documentation reasonably well, although it took almost a minute and needed adjustments to respect the output limit. The result depended on the task: summarizing was more suitable than answering broad questions.

Issues worth anticipating

Do not turn the model into a general-purpose assistant by default. How-To Geek tested Qwen3.5 4B on a computer with 8 GB of RAM: an answer to a broad question about IPv6 took more than 30 seconds and included an incorrect figure. In another test, a voice command with Home Assistant took 21 seconds to complete. These are examples from that setup, not a guarantee of performance on every computer.

There are also smaller but practical limitations. A commit suggestion can misinterpret a complicated diff; a screenshot may contain text the model cannot read; and an RSS summary cannot recover details missing from the description. Keep the input focused and check the output before using it as a message, name, or reference summary.

These three automations do not need the model to make decisions for you. They assign it a specific task and leave the final decision in your hands: accept, edit, or discard the response. Start with a single screenshot, a small diff, or a few RSS entries; then check which suggestions actually save you time.

Sources: XDA, How-To Geek