A newer version of the Gradio SDK is available: 6.12.0
title: RAG SOP Perusahaan
emoji: ๐
colorFrom: blue
colorTo: green
sdk: gradio
sdk_version: 5.9.1
app_file: app.py
pinned: true
๐ RAG SOP Assistant
Intelligent Q&A System for Corporate Standard Operating Procedures
An AI-powered smart Q&A system that enables employees to ask questions about company procedures in natural language and receive accurate answers directly from official SOP documents.
๐ฏ About
RAG SOP Assistant is an enterprise-ready, AI-powered knowledge management system designed to revolutionize how organizations interact with their Standard Operating Procedure (SOP) documents.
Built on top of the Retrieval-Augmented Generation (RAG) architecture, this system transforms static, hard-to-navigate SOP files into a dynamic, conversational knowledge base. Employees can simply type a question in natural language โ just like chatting with a colleague โ and receive accurate, context-aware answers sourced directly from official company documents.
Under the hood, the system leverages multilingual sentence embeddings to understand the semantic meaning behind every question, performs vector similarity search across all indexed documents using ChromaDB, and then passes the most relevant context to DeepSeek V3 LLM to generate a clear, well-structured answer in Indonesian.
๐งฉ Core Concepts
What is RAG? Retrieval-Augmented Generation is an AI pattern that enhances LLM responses by first retrieving relevant information from a knowledge base, then using that context to generate grounded, factual answers โ eliminating hallucination and ensuring accuracy.
โโโโโโโโโโโโ โโโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ
โ ๐ Query โ โโโถ โ ๐ Search โ โโโถ โ ๐ Docs โ โโโถ โ ๐ง LLM โ
โ โ โ (Vectors) โ โ (Context)โ โ (Answer) โ
โโโโโโโโโโโโ โโโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ
๐ก Why This Matters
Every organization maintains dozens โ sometimes hundreds โ of SOP documents covering everything from employee onboarding to emergency protocols. These documents are critical for compliance, consistency, and operational excellence. Yet in practice, they often collect dust in shared drives, rarely read, and hard to search.
RAG SOP Assistant solves this by making SOPs instantly accessible through conversation:
| Problem | Solution |
|---|---|
| ๐ SOP documents are scattered across drives and hard to find | ๐ AI-powered semantic search across all documents at once |
| โฐ New employees spend weeks learning procedures manually | ๐ฌ Instant answers through natural language Q&A |
| ๐ Critical information is buried deep inside long documents | ๐ Intelligent chunking & retrieval surfaces the right section |
| ๐ HR/Admin teams waste hours answering repetitive questions | ๐ค AI assistant handles FAQs 24/7 with zero fatigue |
| ๐ Keyword search fails when you don't know the exact term | ๐ง Semantic understanding matches meaning, not just words |
| ๐ Compliance audits require quick access to procedures | โก Instant lookup with source document references |
๐ข Use Cases
- ๐งโ๐ผ HR & People Ops โ Employee onboarding, leave policies, benefits, disciplinary procedures
- ๐ญ Operations โ Warehouse safety, equipment handling, quality control processes
- ๐ฐ Finance & Procurement โ Purchase approval workflows, expense policies, vendor management
- ๐ก๏ธ Compliance โ Regulatory procedures, audit checklists, emergency response protocols
- ๐ Training โ Quick reference for trainees, refresher on procedures, knowledge assessment
โจ Key Features
| Feature | Description |
|---|---|
| ๐ฌ AI Chat | Natural language Q&A โ ask anything about your company SOPs |
| ๐ค Multi-Format Upload | Supports PDF, Word (.docx), and plain TXT documents |
| ๐ง Semantic Search | Meaning-based retrieval powered by multilingual embeddings |
| โ๏ธ Smart Chunking | Sentence-boundary aware splitting โ never cuts mid-word |
| ๐ Database Management | Real-time stats, document list, and one-click database clear |
| ๐ Auto-Index on Startup | Default SOP documents are automatically indexed when the app starts |
| ๐ Thread-Safe | Lock-based concurrency control for safe multi-user access |
| ๐ก๏ธ XSS Protected | All user inputs & filenames are HTML-escaped |
| ๐ซ Error Sanitization | Sensitive information (API keys) never leaks in error messages |
| ๐ Input Validation | Questions capped at 1000 chars, file uploads capped at 50MB |
| ๐จ Premium UI | Polished interface with custom CSS, gradient headers, and animations |
| ๐ Source Attribution | Every answer includes references to the source SOP document |
๐๏ธ Architecture & Tech Stack
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๐ค User โ
โ (Browser / Gradio UI) โ
โโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๐จ Gradio 5.9.1 โ
โ (Premium UI + 3 Tab Interface) โ
โโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโค
โ ๐ฌ Chat โ ๐ค Upload โ ๐ Database โ
โโโโโโโโฌโโโโโโโดโโโโโโโโฌโโโโโโโโดโโโโโโโโโโฌโโโโโโโโโโ
โ โ โ
โผ โผ โผ
โโโโโโโโโโโโโโโ โโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ
โ ๐ง DeepSeek โ โ โ๏ธ Chunker โ โ ๐ ChromaDB โ
โ V3 (LLM) โ โ (Sentence โ โ (Stats & โ
โ โ โ Boundary) โ โ Manage) โ
โโโโโโโโโโโโโโโ โโโโโโโฌโโโโโโ โโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโ
โ ๐ฎ E5-Small โ
โ (Embedding) โ
โโโโโโโโโฌโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโ
โ ๐พ ChromaDB โ
โ (Vector Store)โ
โโโโโโโโโโโโโโโโโ
๐ง Technology Stack
| Layer | Technology | Purpose |
|---|---|---|
| ๐จ Frontend | Gradio 5.9.1 | UI Framework + Custom CSS |
| ๐ง LLM | DeepSeek-V3 | Indonesian language answer generation |
| ๐ฎ Embedding | intfloat/multilingual-e5-small | Multilingual text vector representation |
| ๐พ Vector DB | ChromaDB | Vector storage & similarity search |
| ๐ PDF Parser | PyMuPDF | Text extraction from PDF files |
| ๐ DOCX Parser | python-docx | Text extraction from Word documents |
๐ Quick Start
Option 1: Hugging Face Spaces (Recommended)
Zero setup! Run it instantly in the cloud.
- Fork this Space to your HF account
- Add Secret:
DEEPSEEK_API_KEYin Settings - Wait for the build to complete (~3-5 minutes)
- Upload SOP documents and start asking questions!
Option 2: Local Development
# 1. Clone the repository
git clone https://github.com/romizone/RAGSOP.git
cd RAGSOP
# 2. Install dependencies
pip install -r requirements.txt
# 3. Set your API key
export DEEPSEEK_API_KEY="your-api-key-here"
# 4. Run the application
python app.py
Open http://localhost:7860 in your browser.
๐ How It Works
1๏ธโฃ Upload & Chunking
๐ SOP Document โ โ๏ธ Sentence-Boundary Chunking โ ~500 char chunks
PDF/DOCX/TXT files are split into ~500 character text chunks with intelligent sentence-boundary splitting (never cuts mid-word).
2๏ธโฃ Embedding & Storage
๐ Text Chunks โ ๐ฎ E5-Small Embedding โ ๐พ ChromaDB (Cosine Similarity)
Each chunk is converted into a 384-dimensional vector and stored in ChromaDB for fast similarity search.
3๏ธโฃ Query & Retrieval
โ Question โ ๐ Semantic Search (Top 5) โ ๐ง DeepSeek V3 โ ๐ฌ Answer
The user's question is matched against the most relevant chunks, then the LLM generates an accurate answer based on the retrieved context.
๐ Security
| Feature | Implementation |
|---|---|
| ๐ก๏ธ XSS Prevention | All inputs/outputs escaped via html.escape() |
| ๐ API Key Protection | Stored as environment variable (HF Secrets) |
| ๐ซ Error Sanitization | Error messages never expose sensitive information |
| ๐ Input Validation | Questions capped at 1000 chars, files capped at 50MB |
| ๐ Thread Safety | threading.Lock for safe concurrent access |
๐ Project Structure
RAGSOP/
โโโ ๐ app.py # Main application (Gradio + RAG pipeline)
โโโ ๐ requirements.txt # Python dependencies
โโโ ๐ README.md # Documentation (this file)
โโโ ๐ซ .gitignore # Git ignore rules
โโโ ๐ SOP/ # Default SOP documents (auto-indexed)
โโโ Kumpulan_SOP_Perusahaan.pdf
โโโ Pelatihan staf_8.pdf
โโโ Penggunaan teknologi_7.pdf
โโโ Penyimpanan dan pemeliharaan_4.pdf
โโโ SOP darurat_5.pdf
๐ Performance
| Metric | Value |
|---|---|
| โฑ๏ธ Startup Time | ~30-60s (includes model loading) |
| ๐ Default SOP Files | 5 documents, ~256 chunks |
| ๐ฎ Embedding Model Size | ~470MB |
| ๐ฌ Query Response Time | ~3-5s per question |
| ๐พ Hardware | CPU Basic (2 vCPU, 16GB RAM) |
๐บ๏ธ Roadmap
-
v1.0 โ Core RAG + Premium UI + Auto-indexing - v1.1 โ Persistent storage (data survives restart)
- v1.2 โ Multi-language support (EN/ID)
- v1.3 โ Document version tracking
- v2.0 โ Authentication + multi-tenant support
๐ค Contributing
Contributions are welcome! Feel free to open an Issue or submit a Pull Request.
๐จโ๐ป Author
Romi Nur Ismanto
- ๐ rominur.com
- ๐ค Hugging Face
- ๐ GitHub