This project is a scalable, style-guide-compliant rewriting assistant that uses Retrieval-Augmented Generation (RAG) to enforce writing rules like:
- Passive voice elimination
- Wordiness reduction
- Clarity and conciseness
- Minimalism
- Contractions and tone adjustments
It uses FAISS for vector-based retrieval, Hugging Face embeddings, and Gemma 7B via Ollama as the local LLM.
.
├── rag_pipeline.py # Main logic that retrieves rules + rewrites text
├── styleguide_ingest.py # One-time script to embed .md style rules into FAISS DB
├── style_guide_rules/ # Folder containing individual .md files per rule
│ ├── passive_voice.md
│ ├── contractions.md
│ ├── minimalism.md
│ └── ...
├── vector_db/ # Auto-generated FAISS vector store
└── app.py # Gradio interface (optional)
- You write your style rules in
.mdformat insidestyle_guide_rules/ - You run
styleguide_ingest.pyto build/update yourvector_db - When a user submits text,
rag_pipeline.py:- Retrieves relevant rule chunks from the vector DB
- Feeds them to the Gemma 7B model via Ollama
- Gets a rewritten output that complies with those rules
- Add a new
.mdfile instyle_guide_rules/(e.g.,clarity.md) - Run:
python styleguide_ingest.py
No need to update any Python logic!
- Python 3.10+
ollamawithgemma:7bmodel pulled locallylangchain-communityhuggingface_hub,faiss-cpu,gradio,transformers
Install requirements:
pip install -r requirements.txtAfter embedding style rules:
python app.pyUse the Gradio UI to paste passive voice–heavy or wordy text. You’ll get a clean, active, concise rewrite.
**Passive:** The file was reviewed by the QA team.
**Active:** The QA team reviewed the file.You can change gemma:7b in rag_pipeline.py to:
mistral:7bllama3:8b- Or any other local model pulled into Ollama
Built with by Gaurav using:
- LangChain
- FAISS
- Hugging Face
- Microsoft Writing Style Guide