Jump to content

Grammar Spelling model LibreOffice and Firefox models 260214

From Game in the Brain Wiki

Master Guide: Self-Hosted AI for Editing & Writing

Goal: Replace Grammarly and OpenAI with a private, free, and voice-preserving local setup.

📺 Watch the Full Tutorial

For a visual walkthrough of the Firefox and LibreOffice setup, watch the original guide here:

(Watch directly on YouTube if the player doesn't load)

Part 1: The "Voice Preserver" (Ollama)

Standard AI models love to rewrite your personality. To fix this, we build a custom "Grammar Nazi" model that refuses to chat or change your style.

1. Open Terminal and Create the Modelfile

nano grammar.Modelfile

2. Paste this Configuration

(This strips the AI's ability to be "creative" and forces it to be a strict proofreader.)

Customization Options (Context Window): The default configuration below uses a 32k context window (num_ctx 32768), which is the sweet spot for long documents but requires ~4-6GB VRAM.

Low RAM? If you have 8GB system RAM or less, change 32768 to 8192 or 4096.

Massive Docs? If you have plenty of RAM, you can max it out to 131072 (128k).

FROM llama3.2:3b

# Temperature 0: Makes the model deterministic.
# It kills "creativity" so the model strictly follows rules instead of hallucinating.
PARAMETER temperature 0

# Context Window (num_ctx): Controls how much text the model can read at once.
# 32768 (32k) allows it to read long chapters, but uses ~4-6GB VRAM.
PARAMETER num_ctx 32768

# Stop Parameters: These silence the "Assistant" personality.
# If the model tries to say "Sure, here is the text:", it gets cut off immediately.
PARAMETER stop "Note:"
PARAMETER stop "Here is"
PARAMETER stop "Sure,"

SYSTEM """
You are a Text Standardization Engine.
Your goal is to enforce standard grammar and spelling rules.

INSTRUCTIONS:
1. Receive the input text.
2. Fix ALL grammatical errors, spelling mistakes, and punctuation faults.
3. Output ONLY the corrected text.
4. DO NOT interact with the user (no "Sure", no "Here is the text").
5. DO NOT change the author's tone, style, or vocabulary.
"""

3. Build and Test

ollama create grammar-check -f grammar.Modelfile
ollama run grammar-check

Troubleshooting: Context Length

If you encounter errors like model runner has unexpectedly stopped or your computer freezes while processing large documents, your context window might be set too high for your hardware.

32768 (32k): Recommended for most modern GPUs. Allows processing very long chapters without losing track.

8192 (8k): Use this if you have an older GPU or limited RAM (8GB total system RAM or less).

4096 (4k): The "safe mode." Use this if everything else crashes.

To change this, edit the grammar.Modelfile, change the num_ctx number, and run the ollama create command again to rebuild the model.

Part 2: Firefox Integration (Page Assist)

Why: Replace the Grammarly browser extension for emails and web forms.

Install: Search for "Page Assist" in the Firefox Add-ons store (or visit the GitHub repo).

Connect:

    • Open the Page Assist Sidebar.
    • Go to Settings.
    • Ensure it is pointing to your local Ollama instance (usually 127.0.0.1:11434).

Usage:

    • Select your new grammar-check model from the dropdown.
    • Highlight text in any email or text box.
    • Right-click (or use the sidebar) to "Fix Grammar" or "Rephrase."
    • Pro Tip: Since this runs locally, you can use it offline!

Part 3: LibreOffice Integration (Local Writer)

Why: Professional document editing without the monthly subscription fees.

Download: Get the Local Writer extension (.oxt file) from GitHub or the LibreOffice extension site.

Install:

    • Open LibreOffice Writer.
    • Go to Tools > Extension Manager.
    • Click Add and select the file you downloaded.
    • Restart LibreOffice.

Configure:

Usage:

    • Highlight a paragraph.
    • Go to Tools > Local Writer > Edit Selection.
    • Choose "Fix Grammar" or type your own custom prompt.

💰 The ROI (Return on Investment)

By switching to this local setup, you avoid the "SaaS Tax":

Grammarly Premium: Saved ~₱5,000 - ₱8,000 / year.

OpenAI Subscription: Saved ~₱1,200 / month.

Electricity Cost: estimated +₱1,000 / year (running a GPU for ~300w).

Privacy: 100% of your data stays on your machine.