Skip to content

gtrivedi88/rag-style-guide-base

Repository files navigation

RAG-Based Technical Writing Assistant

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.


Directory Structure

.
├── 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)

How It Works

  1. You write your style rules in .md format inside style_guide_rules/
  2. You run styleguide_ingest.py to build/update your vector_db
  3. 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 New Style Rules

  1. Add a new .md file in style_guide_rules/ (e.g., clarity.md)
  2. Run:
python styleguide_ingest.py

No need to update any Python logic!


Requirements

  • Python 3.10+
  • ollama with gemma:7b model pulled locally
  • langchain-community
  • huggingface_hub, faiss-cpu, gradio, transformers

Install requirements:

pip install -r requirements.txt

Test It

After embedding style rules:

python app.py

Use the Gradio UI to paste passive voice–heavy or wordy text. You’ll get a clean, active, concise rewrite.


Example Rule: passive_voice.md

**Passive:** The file was reviewed by the QA team.  
**Active:** The QA team reviewed the file.

Model

You can change gemma:7b in rag_pipeline.py to:

  • mistral:7b
  • llama3:8b
  • Or any other local model pulled into Ollama

Credits

Built with by Gaurav using:

  • LangChain
  • FAISS
  • Hugging Face
  • Microsoft Writing Style Guide

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages