Classifying Local Maildirs with Ollama and Open Interpreter
A practical workflow demonstrates how to run local LLMs in Docker via Ollama to categorize thousands of local email files without cloud API costs or data privacy risks. Using Open Interpreter and custom Python scripts, the dual-pass pipeline processed 8,000 Maildir messages efficiently on an Nvidia RTX 4070.

Impact: Medium
Why it matters
Engineers can automate bulk local file triage without exposing sensitive personal or corporate data to external model APIs.
TL;DR
- 01Local LLMs running in Docker on consumer GPUs (e.g. RTX 4070) can process thousands of local files with zero external API fees.
- 02A two-pass prompting strategy helps discover latent categories before enforcing strict taxonomy.
- 03Truncating inputs to the first 2,000 characters significantly accelerates inference without losing essential context.
Key facts
- Hardware Used
- Nvidia RTX 4070 GPU
- Execution Environment
- Ollama in Docker Container
- Processed Dataset
- 8,000 Maildir messages
- Message Truncation
- First 2,000 characters per message
- Processing Time
- ~1 hour per 8,000-message pass
Local Setup and Hardware Requirements
To run local text classification without cloud dependencies, deploy Ollama inside a Docker container configured to access a host GPU like the Nvidia RTX 4070. Local execution ensures sensitive Maildir contents never cross network boundaries. Processing 8,000 emails takes approximately two hours for a two-pass run when inspecting the first 2,000 characters of each message body.
Dual-Pass Classification Pipeline
Instead of enforcing rigid taxonomies upfront, start with an exploratory classification pass to discover emergent categories across your dataset. Next, refine the prompt with an explicit list of broad categories (such as receipts, notifications, or personal correspondence). Have the model return structured tab-separated lines containing the file path and assigned label.
Scripting and Output Handlers
Open Interpreter can assist in scaffolding the initial Python Maildir parser, though manual adjustments are required to handle standard Python mailbox.Maildir paths correctly. The resulting TSV file enables straightforward downstream bash scripts to perform bulk file operations safely after visual inspection.
Try it in 2 minutes
import mailbox, requests
def classify_email(text):
prompt = f"Classify this email into one category [Receipt, Notification, Personal]:\n{text[:2000]}"
res = requests.post('http://localhost:11434/api/generate', json={'model': 'llama3', 'prompt': prompt, 'stream': False})
return res.json().get('response', '').strip()python
✓ When to use
- Categorizing sensitive local text files or Maildirs without sending data to third-party cloud APIs.
- Cleaning up large unorganized datasets where rigid regex or keyword searches fail.
✕ When NOT to use
- Real-time low-latency triage requiring sub-second turnarounds on low-power hardware.
- Tasks requiring 100% strict adherence to output formatting without manual verification.
What to do today
- Deploy an Ollama Docker container mapping local GPU acceleration.
- Implement a two-pass classification script restricting payload size to 2,000 characters per file.
- Output TSV format to verify generated categories before executing bulk file deletes.
Sources