Grammar Spelling model LibreOffice and Firefox models 260214: Difference between revisions
Justinaquino (talk | contribs) |
Justinaquino (talk | contribs) |
||
| (One intermediate revision by the same user not shown) | |||
| Line 27: | Line 27: | ||
For a visual walkthrough of the Firefox and LibreOffice setup, watch the original guide here: | For a visual walkthrough of the Firefox and LibreOffice setup, watch the original guide here: | ||
[https://youtu.be/kVD9p4X9jgw?si=44hy0IQ73wup5zeA Self Hosted LLM for Firefox and LibreOffice - with page assist and local writer] | |||
== Part 1: The "Voice Preserver" (Ollama) == | == Part 1: The "Voice Preserver" (Ollama) == | ||
| Line 130: | Line 127: | ||
#* Go to '''Tools > Local Writer Settings'''. | #* Go to '''Tools > Local Writer Settings'''. | ||
#* '''URL:''' <code>https://www.google.com/url?sa=E&source=gmail&q=http://127.0.0.1:11434</code> | #* '''URL:''' <code>[https://www.google.com/url?sa=E&source=gmail&q=http://127.0.0.1:11434 http://127.0.0.1:11434]</code> | ||
#* '''Model:''' Type <code>grammar-check</code> (or whatever model you want to use). | #* '''Model:''' Type <code>grammar-check</code> (or whatever model you want to use). | ||
Latest revision as of 10:30, 14 February 2026
Master Guide: Self-Hosted AI for Editing & Writing
Goal
To replace expensive SaaS tools (Grammarly, OpenAI) with a private, free, and voice-preserving local setup.
The Problem: Why "Just Prompting" Isn't Enough
Most Large Language Models (LLMs) like ChatGPT or standard Llama 3 are trained with Reinforcement Learning from Human Feedback (RLHF). They are designed to be "helpful assistants."
When you ask a standard model to "fix grammar," its training creates a conflict:
The User's Request: "Fix the spelling."
The Model's Training: "Make this text sound professional, concise, and helpful."
The Result: The model inevitably over-edits. It strips away your unique voice, slang, and rhythm, replacing it with generic "Corporate Speak." No matter how hard you prompt "Don't change my style," the model's high creativity (temperature) and helpfulness bias will eventually override your instructions.
The Solution: Model Engineering
We cannot rely on prompting alone. We must create a custom Modelfile to alter the model's fundamental parameters:
Temperature 0: We turn off the "Creativity" knob completely. The model stops trying to be an author and becomes a calculator for words.
Stop Sequences: We physically block the model from replying with conversational filler like "Sure, here is the corrected text."
System Prompt: We redefine the model's existence from "Assistant" to "Engine."
📺 Watch the Full Tutorial
For a visual walkthrough of the Firefox and LibreOffice setup, watch the original guide here:
Self Hosted LLM for Firefox and LibreOffice - with page assist and local writer
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-checkmodel 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!
- Select your new
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:
- Go to Tools > Local Writer Settings.
- URL:
http://127.0.0.1:11434 - Model: Type
grammar-check(or whatever model you want to use).
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.