MicrocosmWorks创新与构建数字宇宙
关于我们联系我们
MicrocosmWorks创新与构建数字宇宙

提供重要的IT解决方案。我们热衷于技术、安全,并通过可靠、创新的IT基础设施帮助企业成长。

[email protected]
+91 7011868196
New Delhi, India

AI增长中心

AI中心初创创新企业加速器

解决方案

所有解决方案健康与健身应用AI视频平台AI代理开发

资源

见解行业指南用例蓝图架构模式案例研究

公司

关于我们联系我们我们的工作

服务

数字咨询云基础设施SaaS 开发AI 开发视频技术
ERP 开发Zoho 定制Odoo 开发Salesforce 集成定制 CRM 开发
QuickBooks 集成物联网解决方案区块链开发
网络安全咨询IT 支持 - L3

© 2026 MicrocosmWorks. 保留所有权利。

隐私政策服务条款
返回案例研究
Document Intelligence发布于 June 18, 2026 · 更新于 May 25, 2026

Local-First Document RAG System with Hybrid Search & Multi-Format Support

A team building developer tools needed a fully local, privacy-preserving document intelligence system that could ingest multiple file formats, build searchable knowledge bases, and answer natural language queries using Retrieval-Augmented Generation — without sending any data to external APIs.

讨论您的项目
local-rag-hybrid-search-pipeline.webp
Document Intelligence
Domain
8
Technologies
5
Key Results
Delivered
Status

挑战

Existing RAG solutions had significant limitations for privacy-conscious and developer-focused use cases:

  • External API Dependency — Most RAG tools required sending document content to cloud-based embedding APIs, violating privacy requirements
  • Limited Format Support — Solutions typically handled only plain text or PDF, ignoring spreadsheets, Word docs, HTML, and Markdown
  • Poor Chunking — Naive text splitting ignored document structure (pages, sheets, headings), creating context-poor chunks
  • Keyword Gaps — Pure embedding-based search missed exact keyword matches that lexical search would catch
  • Spreadsheet Blindness — RAG systems couldn't handle structured tabular data or answer filtering/aggregation queries
  • No Reranking — First-pass retrieval often surfaced only partially relevant results without a second-pass quality filter

我们的解决方案

We built a complete local-first RAG system with multi-format document ingestion, structure-aware chunking, local embedding generation, a hybrid search pipeline (semantic + full-text + recency), cross-encoder reranking, and a web-based UI — all running entirely on the user's machine.

Architecture

  • Document Loaders: Format-specific parsers for PDF, DOCX, XLSX, CSV, HTML, Markdown, and plain text
  • Chunker: Structure-aware splitting that preserves page, sheet, and heading boundaries
  • Embeddings: Local embedding model via Transformers.js (no external API calls)
  • Vector Database: LanceDB (serverless, file-based) for embedding storage and similarity search
  • Full-Text Search: Trigram-based indexing for lexical matching
  • Reranker: Cross-encoder model for context-aware result scoring
  • Query Analyzer: Intent detection routing between semantic and structured queries
  • Web Server: Express.js API with project management and search endpoints
  • Frontend: Web-based UI for document upload, management, and interactive search

Document Processing Pipeline

Multi-Format Loaders

A registry pattern auto-detects file type and routes to the appropriate parser:

  • PDF — Text extraction with page-level segmentation
  • Word (.docx/.doc) — Heading-aware parsing preserving document hierarchy
  • Excel/CSV — Sheet-by-sheet parsing with header detection and row-level content
  • HTML — Tag-aware extraction with structure preservation
  • Markdown — Heading-based section parsing
  • Plain Text — Line-based segmentation

Each loader extracts metadata (title, author, creation date, page/sheet count, word count) alongside the content, producing structured sections with source references.

Structure-Aware Chunking

Unlike naive text splitting, the chunker respects document boundaries:

  • Preserves page breaks (PDFs), sheet boundaries (spreadsheets), and heading hierarchy (Word/Markdown)
  • Token-based sizing with configurable chunk size and overlap
  • Hierarchical fallback: splits by sections first, then paragraphs, then sentences
  • Each chunk retains source metadata (page number, sheet name, heading) for attribution

Embedding & Indexing

Local Embedding Model

  • Runs entirely locally via Transformers.js — no data leaves the machine
  • Quantized model for performance optimization
  • Batch embedding for efficient bulk processing
  • Automatic truncation at word boundaries with L2 normalization

Vector Storage

LanceDB provides serverless vector storage:

  • File-based (no separate database server needed)
  • Per-project isolation with independent indices
  • SHA256-based cache keys for deduplication
  • Metadata stored alongside vectors for filtered retrieval

Hybrid Search Pipeline

The retrieval pipeline combines three ranking signals for better results than any single approach:

Signal 1: Embedding Search (Semantic)

Vector similarity search finds chunks with related meaning even when different words are used. Handles paraphrasing, synonyms, and conceptual queries.

Signal 2: Full-Text Search (Lexical)

Trigram-based indexing with Jaccard similarity catches exact keyword matches that embedding search might miss — important for technical terms, names, and identifiers.

Signal 3: Recency Boost

Exponential decay weighting favors recently accessed or modified documents, ensuring up-to-date information surfaces first.

Score Combination

Signals are combined with configurable weights (default: 50% semantic, 25% lexical, 25% recency), normalized, and filtered by a minimum score threshold.

Cross-Encoder Reranking

After initial retrieval, a cross-encoder model re-scores the top candidates:

  • Context-aware scoring considers query-document pairs together (not independently)
  • Keyword boost calculation for term overlap
  • Blended scoring (cross-encoder + keyword signals)
  • Produces a final ranked list with higher precision than first-pass retrieval alone

Structured Data Support

For spreadsheet content, the system provides additional capabilities:

  • Auto-detection of column types (numeric, date, boolean, string)
  • Natural language filtering (e.g., "employees in engineering with salary above threshold")
  • Aggregation support (count, sum, average, min, max)
  • Query analyzer routes structured queries to a dedicated engine rather than embedding search

Web Interface

  • Project Management — Create, update, and delete knowledge base projects
  • Document Upload — Drag-and-drop file upload with format auto-detection
  • Document Creation — Create documents from text directly in the UI
  • Interactive Search — Natural language query interface with ranked results
  • Statistics — Index size, document count, and format distribution per project

Key Features

  1. Fully Local — All processing on-device; no external API calls for embeddings or search
  2. 9 Input Formats — PDF, DOCX, DOC, XLSX, XLS, CSV, HTML, Markdown, plain text
  3. Structure-Aware Chunking — Preserves pages, sheets, and headings as chunk boundaries
  4. Hybrid Search — Combines semantic, lexical, and recency signals for better retrieval
  5. Cross-Encoder Reranking — Second-pass scoring for higher precision results
  6. Structured Queries — Natural language filtering and aggregation on spreadsheet data
  7. Serverless Vector DB — LanceDB file-based storage with no infrastructure overhead
  8. Document Writing — Export capabilities for PDF, DOCX, and XLSX creation
  9. Project Isolation — Independent knowledge bases with separate indices
  10. Web UI — Complete interface for document management and interactive search

成果

Search Latency: ~60ms for full hybrid search pipeline (semantic + FTS + reranking)
Embedding Speed: ~50ms per chunk (batch: ~2s for 100 chunks)
Format Coverage: 9 input formats handled natively without external converters

技术栈

TypeScriptNode.jsExpress.jsTransformers.jsLanceDBVitestpnpmHTML/CSS/JS Frontend

caseStudyDetail.more 案例研究

探索更多我们的技术实施案例

Document Intelligence

AI驱动的电子表格和文档分析,结合多智能体编排和跨文档引用

一家企业数据团队需要使用自然语言分析、查询和编辑大量的电子表格和文档(Excel、CSV、Google Sheets、PDF、Word docs),同时能够跨多个文件交叉引用数据,并执行多步骤分析工作流,无需手动数据整理。

阅读案例研究
Web Scraping

AI驱动的博客内容抓取与生成平台

一家媒体公司需要一个智能内容平台,能够通过抓取现有网页内容、使用 AI 进行分析,并从提取的数据中生成原创的、SEO优化的博客文章,从而实现博客内容创建的自动化。

阅读案例研究

准备好转型您的业务了吗?

让我们讨论如何将类似的解决方案应用到您的挑战中。

联系我们caseStudyDetail.viewAllCaseStudies
Privacy: Zero data transmitted externally — complete local processing
Memory Footprint: ~100MB for embedding model, ~1MB per 1,000 indexed chunks
Web Scraping

自动化 B2B 供应商数据采集平台,具备反检测与 IP 轮换功能

一个采购团队需要通过大规模、可靠且不被屏蔽地从 B2B 交易平台收集结构化商业数据,以构建一个涵盖 19 多个产品类别和 50 多个国家的全面供应商数据库。

阅读案例研究

常见问题

MicrocosmWorks built a local-first RAG system where all document ingestion, embedding generation, vector storage, and LLM inference run entirely on your infrastructure without sending any data to external cloud APIs. This architecture is essential for organizations handling classified documents, attorney-client privileged materials, or sensitive intellectual property where data sovereignty requirements prohibit any cloud processing, even with encryption.

MicrocosmWorks implemented a hybrid retrieval pipeline that runs BM25 keyword search and dense vector semantic search in parallel, then uses reciprocal rank fusion to merge and re-rank the combined results before passing them to the LLM as context. This approach catches exact-match queries like product codes and legal citations that semantic search misses, while also retrieving conceptually related content that keyword search would never find.

MicrocosmWorks built format-specific parsers for PDF, DOCX, XLSX, PPTX, HTML, Markdown, and plain text, with an OCR pipeline using Tesseract for scanned PDFs and image-based documents. The system automatically detects whether a PDF contains selectable text or requires OCR, applies layout analysis to preserve table structures and reading order, and chunks documents using semantic boundaries rather than arbitrary character limits to improve retrieval quality.

MicrocosmWorks implemented incremental indexing that tracks document checksums and only re-processes files that have changed since the last ingestion run. Updated documents have their old chunks removed and new chunks inserted atomically, so the search index is never in an inconsistent state. The system also supports versioned document retrieval, allowing users to query against historical versions of documents when needed for audit or compliance purposes.

MicrocosmWorks optimized the local RAG pipeline to run on modest hardware, with the minimum recommended configuration being a machine with 32GB RAM, 8 CPU cores, and optionally a mid-range GPU for accelerated embedding generation. For organizations without GPU hardware, the system falls back to CPU-based embedding models with slightly higher latency, and the vector database is tuned for SSD storage to keep query response times under 200ms for corpora up to 1 million document chunks.