The book "AI e DSA" (Italian only for now) comes with two free tools: the Materials Generator, which turns a text and a student profile into an adapted version, an infographic and slides, and the Profile Generator, which builds the starting YAML profile. Since they exist, both have used only Google's Gemini API. It works, but for a teacher new to AI that was one more obstacle: creating an API key, and accepting that the text sent — even if already anonymized — still leaves their own computer.

This week I added a second path: Ollama, the open-source engine that runs AI models directly on the PC. Same principle already used in the book's anonymizer to recognize names in text, now extended to the actual generation step.

What I actually added

In the CLI generator (generatore_pro.py, both in the book's repository and in the standalone app), I added a flag:

python generatore_pro.py --studente mario --testo storia.txt --backend ollama --modello-ollama qwen3.6:27b

Default behaviour is unchanged — anyone who doesn't add --backend ollama keeps using Gemini exactly as before. In the Profile Generator, a Streamlit app, I added the same switch but in the sidebar: an "AI Engine" selector with the two options, Gemini or Ollama, plus the choice of local model when the second one is selected.

Four local models are available in this setup, with different weights and speeds: qwen3.6:27b and glm-4.7-flash for the highest quality, ministral-3:8b and qwen3.5:4b for a more modest PC or faster answers.

Why it matters for anyone working with student support plans

The first reason is privacy. Student profiles used with these tools should always be anonymized before being pasted into any AI — that doesn't change. But "anonymized" and "stays on my computer" are two different protections, and until now the second tool in the book didn't offer the second one. Now it does: with the Ollama backend, the text never leaves the teacher's PC.

The second reason is cost. Gemini has a generous free tier, but anyone generating materials for a whole class, week after week, will eventually hit it. A local model has no request limits and no per-token cost: you only pay for electricity.

How I verified it

To avoid rewriting the generation logic (prompts, section parsing, Word/PowerPoint export have been battle-tested for months), I wrote a small class that mimics the interface of the official Gemini client: same method, same arguments, but underneath it calls Ollama instead of the cloud API. The rest of the code doesn't notice the difference.

I tested it end-to-end with a real profile (Mario, dyslexia + dyscalculia) and the lightest model, ministral-3:8b: adapted text, infographic and slides generated correctly, files saved in the usual folders. I did the same with the online Streamlit demo, this time using streamlit.testing.AppTest to actually simulate clicking "Generate materials" without needing a browser.

Along the way I found a small, unrelated defect worth mentioning: the AI-generated text (both Gemini and Ollama) uses markers like **word** for bold, but the exported Word document wrote them literally, asterisks and all, instead of actually applying bold formatting. I fixed that too: **word** now becomes real bold in the downloaded file, not literal asterisks.

What you need to use it

You need Ollama installed locally and at least one model downloaded — even the lightest one (6 GB) runs on a recent laptop without a dedicated graphics card. That's why it stays an option, not the default: anyone who doesn't want to install anything keeps using Gemini with their free key, exactly as before.

Conclusion

This isn't a feature I designed on paper: it's the same idea already applied to the anonymizer, carried one step forward into the next tool in the same chain. The practical lesson, again, is to test before declaring something done: the flag alone wasn't enough, I had to verify it actually generated correct material with a real model — and that's exactly where the bold-text bug surfaced, invisible for months because no one had ever reopened an exported Word file to check the formatting.