株式会社オブライト
Software Development2026-03-01

Building Internal Knowledge Search with OpenClaw: RAG-Powered AI Agent Guide

Learn how to build a high-accuracy internal knowledge search system using OpenClaw and RAG (Retrieval-Augmented Generation). This guide covers local vector database setup with ChromaDB, Qdrant, and Weaviate, document indexing strategies, and practical deployment for searching across PDFs, Word documents, and internal wikis.


What Is RAG (Retrieval-Augmented Generation) and Why Use It with OpenClaw?

RAG (Retrieval-Augmented Generation) is a technique where an LLM (Large Language Model) retrieves and references relevant information from an external knowledge base before generating its response. Standard LLMs cannot accurately answer questions about company-specific internal information not included in their training data, but RAG enables precise responses by referencing up-to-date internal documents, product manuals, and customer interaction histories. OpenClaw integrates the RAG pipeline as an MCP server, enabling a fully self-contained internal knowledge search system running entirely on a local Mac mini. Since no data needs to be sent to external cloud services, organizations handling confidential operations in the Shinagawa and Minato ward areas can adopt this solution with confidence. The significant reduction in hallucination (generation of incorrect information) is another major benefit for business applications.

Choosing a Vector Database: ChromaDB vs. Qdrant vs. Weaviate

Several vector database options are well-suited for local deployment on Mac mini as the core of a RAG system. ChromaDB is a lightweight Python-based vector database that can be installed with a simple pip install chromadb command and delivers sufficient search performance for collections of tens of thousands of documents. Qdrant is a high-performance vector search engine written in Rust that is easily set up via Docker, making it ideal for mid-scale environments handling hundreds of thousands of documents. Weaviate offers a feature-rich vector database with a GraphQL-based API and excels at hybrid search combining vector similarity and keyword matching. For small and medium businesses in the Shinagawa area, we recommend starting small with ChromaDB and migrating to Qdrant as data volume grows. All three databases run natively or via Docker on Mac mini, eliminating monthly cloud service fees.

Setting Up a Vector Database Environment on Mac Mini

Here are the specific steps for setting up a vector database on Mac mini. For ChromaDB, run pip install chromadb in a Python 3.10+ environment and launch it in persistent mode to save data to local disk. For Qdrant, install Docker Desktop and start the container with docker run -p 6333:6333 qdrant/qdrant, then access it via REST API or gRPC. An M2 Mac mini with 16GB of memory comfortably handles storage of approximately 100,000 document vectors. External SSDs can be used to avoid storage limitations and simplify vector data backups. Configure launchd or supervisor to automatically start the vector database on boot so the service recovers without manual intervention after Mac mini restarts.

Document Preprocessing and Index Creation

Ingesting internal documents into a RAG system requires preprocessing steps including parsing and cleaning. PDF files are processed using pypdf or PDFPlumber for text extraction, while Word files are handled with python-docx. Content from Confluence, internal wikis, and Google Docs is retrieved through their respective APIs and converted to markdown format. After preprocessing, text is divided into chunks for vectorization, and storing metadata such as document title, creation date, and category alongside each chunk significantly improves later search accuracy. Index creation should be run as a batch process, and building an incremental indexing mechanism that processes only new or updated documents greatly improves operational efficiency.

Chunking Strategies: Best Practices for Document Splitting

The strategy for splitting documents into chunks dramatically affects RAG search accuracy. Fixed-length chunking is simple to implement but risks breaking context mid-sentence, so semantic chunking that considers meaningful boundaries such as headings and paragraphs is recommended. A typical chunk size is 500 to 1,000 tokens with 100 to 200 tokens of overlap to prevent context discontinuity. For technical documents, heading-based chunking works effectively, while FAQ-format documents achieve better search accuracy when question-answer pairs are treated as single chunks. OpenClaw manages chunking configuration via YAML files, allowing different splitting strategies for different document types. A startup in the Shibuya area improved overall search accuracy by approximately 20% by applying distinct chunking strategies to internal manuals, customer FAQs, and technical specifications.

Selecting and Optimizing Embedding Models

The choice of embedding model for converting document text into vector space directly impacts RAG system quality. OpenAI Embeddings (text-embedding-3-small/large) are API-based and highly accurate, but API call costs become a concern with large document volumes. Locally-running Sentence-BERT models such as all-MiniLM-L6-v2 and multilingual-e5-large are free to use and run efficiently on Mac mini's Apple Silicon. For primarily Japanese documents, multilingual models like multilingual-e5-large and intfloat/multilingual-e5-base-v2 deliver particularly strong accuracy. A hybrid configuration using local models for document indexing and OpenAI API only for query-time similarity search offers an effective balance of cost and accuracy. On an M2 Mac mini, the multilingual-e5-base model can vectorize approximately 50 texts per second, completing index creation for 10,000 documents in about three to four minutes.

Building and Configuring the RAG Pipeline in OpenClaw

Here is how to integrate a RAG pipeline into OpenClaw. First, register the vector database MCP server in ~/.openclaw/mcp.json and specify the index name and embedding model path. Configure search parameters including the number of documents to return (top_k, typically 5 to 10), similarity threshold (0.7 or higher recommended), and filtering conditions for metadata-based narrowing. Adding an instruction to OpenClaw's system prompt such as always reference the knowledge base when answering and explicitly state when no relevant information is found helps prevent hallucination. The insertion position and format of search result context in the context window can also be customized in the configuration file for fine-tuning answer quality. Configuration changes are hot-reloaded without restarting OpenClaw, making it easy to iterate and find optimal parameters.

Practical Use Cases: Internal FAQ Bots and Customer Support

Two representative use cases for RAG-powered OpenClaw are internal FAQ bots and customer support knowledge bases. For internal FAQ bots, documents covering employment regulations, benefits programs, IT helpdesk Q&As, and expense reimbursement rules are indexed and made searchable via Slack or chat interfaces. This significantly reduces onboarding support workload, with a 100-person IT company in Shinagawa reporting a reduction of approximately 20 hours per month in HR department inquiry response time. For customer support, product manuals, past inquiry histories, and troubleshooting guides are ingested into the RAG system, and the AI generates first-response answers to inquiries received via LINE Official Account or email. Configuring the system to always include links to source documents ensures users can verify information accuracy.

Cost Comparison: Local vs. Cloud Vector Databases

Let us compare costs between running a vector database locally on Mac mini versus using cloud services. Pinecone's Standard plan starts at approximately $70 per month, while Weaviate Cloud begins at around $25 per month, with usage-based charges added for document volume and query frequency. In contrast, a Mac mini (M2, 16GB memory, 512GB SSD) costs approximately 120,000 yen upfront, and running ChromaDB or Qdrant locally eliminates monthly cloud fees entirely. Including electricity costs, the operating expense is only about 500 to 800 yen per month, making the local configuration overwhelmingly cost-effective for deployments exceeding one year. However, cloud services should be considered when multi-location access is required or when handling datasets exceeding one million documents. For small and medium businesses in the Setagaya and Meguro areas, most use cases involve fewer than 100,000 documents, making local Mac mini deployment the optimal solution.

Query Optimization and Continuous RAG Accuracy Improvement

After launching a RAG system, continuous improvement of search accuracy remains essential. Implementing query rewriting, which transforms user questions into forms better suited for vector search, improves document matching for ambiguous queries. For example, the question how do I take paid leave can be expanded to annual paid leave application procedure approval workflow for searching. Additionally, reranking search results by using an LLM to reorder initially retrieved documents by relevance improves the quality of top-displayed documents. OpenClaw automatically records usage logs, enabling analysis of documents that were retrieved but not accessed and cases where follow-up questions were needed, informing chunking adjustments and document updates. A legal office in the Minato ward area analyzes monthly RAG accuracy reports and conducts quarterly index rebuilds and chunking strategy reviews.

RAG Deployment Support and Future Outlook for Shinagawa Area Businesses

Across Shinagawa, Minato, Shibuya, Setagaya, Meguro, and Ota wards, companies are rapidly adopting internal knowledge search systems combining OpenClaw and RAG. Demand is particularly strong among organizations with 50 to 300 employees seeking unified search across scattered internal documents and knowledge management systems that capture veteran employees' tacit knowledge. Advanced capabilities including multimodal RAG for searching documents containing images and diagrams, and real-time index updates that automatically refresh the vector database when documents are modified, are being actively developed within the OpenClaw ecosystem. As Mac mini performance continues to improve, fully offline operation combining local LLM inference with RAG search is becoming practical, generating growing interest from financial institutions and healthcare organizations with strict security requirements. Technical consultations regarding implementation are available through regularly held AI engineering community study sessions and hands-on events in the Shinagawa area.

Feel free to contact us

Contact Us