Sort thousands of records with a local AI, for free
You have a spreadsheet of support tickets, reviews or emails and no time to read them one by one. Point a small AI model running on your own laptop at the file and it labels every row: by category, by sentiment, spam or not. No per-row API bill, nothing leaves your machine. By the end you'll have a resumable pipeline that labels a whole CSV, a real accuracy number you can trust, and a way to flag the rows worth a human's eyes.
- A measured accuracy number against a hand-labelled sample, plus a per-label breakdown so you know which categories to trust
- Prompt engineering that lifts accuracy: a constrained label set, a short guide and a handful of examples
- An honest way to flag the rows worth a human's time, and the numbers to decide if a small local model is good enough for your job
- A starter kit with the pipeline, the measuring script, the two-model flagger and a 161-row sample CSV with 83 rows hand-labelled
- Ollama with a small model installed and working. Run AI on your PC: your own private ChatGPT sets this up in a few minutes. Check it with
ollama --versionandollama list. This mission usesqwen2.5:3b(about 1.9GB): pull it withollama pull qwen2.5:3b. - uv, the Python runner from Level 0 (Install anything from GitHub, safely has the one-line install). Check with
uv --version. - A CSV of short texts to sort, or use the sample in the kit. A little Python helps but every file is complete and explained.
- A code editor. VS Code ↗ is free; Notepad works at a push.
Why sort records on your own machine
Understand what you're about to build and the words for it, so the rest of the lesson is the doing. The whole job runs on your laptop, for free, with no data sent anywhere.
You have a pile of short texts and you want a label on each one. Support tickets sorted into billing, bug, account and so on. Reviews marked positive, negative or neutral. Emails marked spam or not spam. Products tagged by type. A human could do it, slowly. A big AI API could do it, for a fee per row that adds up fast across thousands of rows. This mission does it with a small model running on your own machine: free per row, and no customer data leaving your laptop.
Two words for the two jobs you can do this way:
- Classification puts each row into one of a fixed set of labels. "Which category is this ticket?" The set of labels is the label set, and you decide it up front.
- Extraction pulls structured fields out of messy text. "What is the order number, the amount and the date in this email?" Same tools, same local model; this mission focuses on classification, and the last step points at extraction.
A few more terms, each used once so the steps read cleanly later:
- Structured output (or JSON mode): you give the model a shape to fill in, and it can only answer in that shape. No chatty preamble to strip, no guessing where the answer is.
- Zero-shot means you describe the task and ask. Few-shot means you also show a handful of worked examples. Few-shot usually does better; you'll measure the difference in step 6.
- Ground truth is a set of rows a human has labelled by hand, the correct answers you check the model against. Accuracy is the share it gets right.
- Batch processing is running the whole file in one go. Doing it so a half-finished run can resume without redoing work is idempotency: run it twice, no row gets labelled twice.
- Human-in-the-loop means the machine does the easy 90% and hands the doubtful rows to a person.
TipHonest up front: a small model on a CPU is slower and less accurate than a big cloud API. The point of this mission is not to pretend otherwise, it's to measure both so you can decide. For sorting your own backlog of tickets, 85% accuracy for free and private often beats 95% for a bill and a data-sharing agreement. For a legal or medical decision, it doesn't. You'll have the numbers to judge.Check your model is there and answers:
Terminalollama run qwen2.5:3b "Reply with one word: working"OutputWorking
ollama list shows qwen2.5:3b, and the one-word test replies.If it breaks'ollama' is not recognised + 2 more
'ollama' is not recognised
'model "qwen2.5:3b" not found'
ollama pull qwen2.5:3b. It's about 1.9GB. ollama list shows what you already have.