Local-first semantic search that actually works
Quick Start β’ Features β’ Documentation β’ Examples β’ UI β’ MCP Integration
Stop fighting with complex RAG frameworks. Get semantic search running in 30 seconds:
npm install -g rag-lite-ts
raglite ingest ./docs/
raglite search "your query here"That's it. No API keys, no cloud services, no configuration hell. Prefer a UI? Run raglite ui for a visual interface with dragβandβdrop ingestion and search.
// 1. Ingest your docs
const pipeline = new IngestionPipeline('./db.sqlite', './index.bin');
await pipeline.ingestDirectory('./docs/');
// 2. Search semantically
const search = new SearchEngine('./index.bin', './db.sqlite');
const results = await search.search('authentication flow');
// 3. Get relevant results instantly
console.log(results[0].text);
// "To authenticate users, first obtain a JWT token from the /auth endpoint..."Real semantic understanding - not just keyword matching. Finds "JWT token" when you search for "authentication flow".
- π 100% Local - Your data never leaves your machine
- π Actually Fast - Sub-100ms queries, not "eventually consistent"
- π¦ Chameleon Architecture - Automatically adapts between text and multimodal modes
- πΌοΈ True Multimodal - Search images with text, text with images (CLIP unified space)
- π¦ Zero Runtime Dependencies - No Python, no Docker, no external services
- π― TypeScript Native - Full type safety, modern ESM architecture
- π MCP Ready - Built-in Model Context Protocol server for AI agents
Chameleon Multimodal Architecture - RAG-lite TS now seamlessly adapts between text-only and multimodal search:
- CLIP Integration - Unified 512D embedding space for text and images
- Cross-Modal Search - Find images with text queries, text with image queries
- Image-to-Text Generation - Automatic descriptions using vision-language models
- Smart Reranking - Automatic strategy selection with cross-encoder and text-derived methods
- Layered Architecture - Clean separation: core (model-agnostic) β implementation (text/multimodal) β public API
- Mode Persistence - Configuration stored in database, auto-detected during search
- Unified Content System - Memory-based ingestion for AI agents, format-adaptive retrieval
- Simplified APIs -
createEmbedder()andcreateReranker()replace complex factory patterns
- Multimodal Tools -
multimodal_search,ingest_imagewith URL download - Base64 Image Delivery - Automatic encoding for AI agent integration
- Content-Type Filtering - Filter results by text, image, pdf, docx
- Dynamic Tool Descriptions - Context-aware tool documentation
Existing databases need schema updates for multimodal support. Two options:
- Automatic Migration: Use
migrateToRagLiteStructure()function - Fresh Start: Re-ingest content with v2.0.0
See CHANGELOG.md for complete details.
- Why RAG-lite TS?
- Quick Start
- Features
- Real-World Examples
- How It Works
- Supported Models
- Documentation
- Web Interface (UI)
- MCP Server Integration
- Development
- Contributing
- License
npm install -g rag-lite-ts# Ingest documents
raglite ingest ./docs/
# Search your documents
raglite search "machine learning concepts"
# Get more results with reranking (use --rerank for better quality)
raglite search "API documentation" --top-k 10 --rerankLaunch the visual web interface for interactive document management:
# Start the UI (opens in browser)
raglite ui
# UI provides:
# - Drag & drop file upload
# - Real-time ingestion progress
# - Visual search interface
# - Image search with upload
# - Knowledge base statistics# Use higher quality model
raglite ingest ./docs/ --model Xenova/all-mpnet-base-v2
# Switch models or refresh your data (DESTRUCTIVE: wipes DB+index and rebuilds from scratch)
raglite ingest ./docs/ --model Xenova/all-mpnet-base-v2 --force-rebuild
# Search automatically uses the correct model
raglite search "complex query"import { SearchEngine, IngestionPipeline } from 'rag-lite-ts';
// Memory-based ingestion for AI agents
const pipeline = new IngestionPipeline('./db.sqlite', './index.bin');
const content = Buffer.from('Document from AI agent');
await pipeline.ingestFromMemory(content, {
displayName: 'agent-document.txt'
});
// Format-adaptive content retrieval
const search = new SearchEngine('./index.bin', './db.sqlite');
const results = await search.search('query');
// Get file path for CLI clients
const filePath = await search.getContent(results[0].contentId, 'file');
// Get base64 content for MCP clients
const base64 = await search.getContent(results[0].contentId, 'base64');RAG-lite TS now supports true multimodal search using CLIP's unified embedding space, enabling cross-modal search between text and images:
# Enable multimodal processing for text and image content
raglite ingest ./docs/ --mode multimodal
# Cross-modal search: Find images using text queries
raglite search "architecture diagram" --content-type image
raglite search "red sports car" --content-type image
# Image-to-image search: Find similar images using image files
raglite search ./photo.jpg # Find similar images
raglite search ./diagram.png --top-k 5 # Find similar images with custom count
# Find text documents about visual concepts
raglite search "user interface design" --content-type text
# Search across both content types (default)
raglite search "system overview"
# Automatic reranking based on mode (text: cross-encoder, multimodal: text-derived)Key Features:
- Unified embedding space: Text and images embedded in the same 512-dimensional CLIP space
- Cross-modal search: Text queries find semantically similar images
- Automatic mode detection: Set mode once during ingestion, automatically detected during search
- Automatic reranking: Cross-encoder for text, text-derived for multimodal, with enable/disable control
- Seamless experience: Same CLI commands work for both text-only and multimodal content
β Complete Multimodal Tutorial
import { SearchEngine, IngestionPipeline } from 'rag-lite-ts';
// Text-only mode (default)
const ingestion = new IngestionPipeline('./db.sqlite', './vector-index.bin');
await ingestion.ingestDirectory('./docs/');
// Multimodal mode (text + images)
const multimodalIngestion = new IngestionPipeline('./db.sqlite', './index.bin', {
mode: 'multimodal',
embeddingModel: 'Xenova/clip-vit-base-patch32',
rerankingStrategy: 'text-derived'
});
await multimodalIngestion.ingestDirectory('./mixed-content/');
// Search (mode auto-detected from database)
const search = new SearchEngine('./vector-index.bin', './db.sqlite');
const results = await search.search('machine learning', { top_k: 10 });
// Cross-modal search in multimodal mode
const imageResults = results.filter(r => r.contentType === 'image');
const textResults = results.filter(r => r.contentType === 'text');// Ingest content directly from memory (perfect for MCP integration)
const content = Buffer.from('# AI Guide\n\nComprehensive AI concepts...');
const contentId = await ingestion.ingestFromMemory(content, {
displayName: 'AI Guide.md',
contentType: 'text/markdown'
});
// Retrieve content in different formats based on client needs
const filePath = await search.getContent(contentId, 'file'); // For CLI clients
const base64Data = await search.getContent(contentId, 'base64'); // For MCP clients
// Batch content retrieval for efficiency
const contentIds = ['id1', 'id2', 'id3'];
const contents = await search.getContentBatch(contentIds, 'base64');
// Content management with deduplication
const stats = await ingestion.getStorageStats();
console.log(`Content directory: ${stats.contentDirSize} bytes, ${stats.fileCount} files`);
// Cleanup orphaned content
const cleanupResult = await ingestion.cleanup();
console.log(`Removed ${cleanupResult.removedFiles} orphaned files`);import { SearchEngine, IngestionPipeline } from 'rag-lite-ts';
// Custom model configuration
const search = new SearchEngine('./vector-index.bin', './db.sqlite', {
embeddingModel: 'Xenova/all-mpnet-base-v2',
enableReranking: true,
topK: 15
});
// Ingestion with custom settings
const ingestion = new IngestionPipeline('./db.sqlite', './vector-index.bin', {
embeddingModel: 'Xenova/all-mpnet-base-v2',
chunkSize: 400,
chunkOverlap: 80
});β Complete CLI Reference | API Documentation
π Build a Documentation Search Engine
import { SearchEngine, IngestionPipeline } from 'rag-lite-ts';
// Ingest your docs once
const pipeline = new IngestionPipeline('./db.sqlite', './index.bin');
await pipeline.ingestDirectory('./docs/');
// Search instantly
const search = new SearchEngine('./index.bin', './db.sqlite');
const results = await search.search('authentication flow');
results.forEach(r => {
console.log(`${r.metadata.title}: ${r.text}`);
console.log(`Relevance: ${r.score.toFixed(3)}\n`);
});Use case: Internal documentation, API references, knowledge bases
πΌοΈ Search Images with Natural Language
# Ingest mixed content (text + images)
raglite ingest ./assets/ --mode multimodal
# Find images using text descriptions
raglite search "architecture diagram" --content-type image
raglite search "team photo" --content-type image
raglite search "product screenshot" --content-type image
# Or find similar images using image files directly
raglite search ./reference-diagram.png --content-type image
raglite search ./sample-photo.jpg --top-k 5Use case: Digital asset management, photo libraries, design systems
π€ AI Agent with Memory
// Agent ingests conversation context
const content = Buffer.from('User prefers dark mode. Uses TypeScript.');
await pipeline.ingestFromMemory(content, {
displayName: 'user-preferences.txt'
});
// Later, agent retrieves relevant context
const context = await search.search('user interface preferences');
// Agent now knows: "User prefers dark mode"Use case: Chatbots, AI assistants, context-aware agents
π Semantic Code Search
// Index your codebase
await pipeline.ingestDirectory('./src/', {
chunkSize: 500, // Larger chunks for code
chunkOverlap: 100
});
// Find code by intent, not keywords
const results = await search.search('authentication middleware');
// Finds relevant code even if it doesn't contain those exact wordsUse case: Code navigation, refactoring, onboarding
π MCP Server for Claude/AI Tools
{
"mcpServers": {
"my-docs": {
"command": "raglite-mcp",
"env": {
"RAG_DB_FILE": "./docs/db.sqlite",
"RAG_INDEX_FILE": "./docs/index.bin"
}
}
}
}Now Claude can search your docs directly! Works with any MCP-compatible AI tool.
Use case: AI-powered documentation, intelligent assistants
|
|
|
|
|
|
|
|
RAG-lite TS supports the following file formats with full processing implementations:
Text Mode:
- Markdown:
.md,.mdx - Plain text:
.txt - Documents:
.pdf,.docx
Multimodal Mode (includes all text formats plus):
- Images:
.jpg,.jpeg,.png,.gif,.webp,.bmp
All formats work seamlessly with both single file and directory ingestion:
# Single file ingestion
raglite ingest ./document.pdf
raglite ingest ./readme.md
raglite ingest ./notes.txt
# Directory ingestion (processes all supported formats)
raglite ingest ./docs/
# Multimodal ingestion (includes images)
raglite ingest ./mixed-content/ --mode multimodalRAG-lite TS follows a clean, efficient pipeline:
π Documents β π§Ή Preprocessing β βοΈ Chunking β π§ Embedding β πΎ Storage
β
π― Results β π Reranking β π Vector Search β π§ Query Embedding β β Query
| Step | What Happens | Technologies |
|---|---|---|
| 1. Ingestion | Reads .md, .txt, .pdf, .docx, images |
Native parsers |
| 2. Preprocessing | Cleans JSX, Mermaid, code blocks, generates image descriptions | Custom processors |
| 3. Chunking | Splits at natural boundaries with token limits | Semantic chunking |
| 4. Embedding | Converts text/images to vectors | transformers.js |
| 5. Storage | Indexes vectors, stores metadata | hnswlib + SQLite |
| 6. Search | Finds similar chunks via cosine similarity | HNSW algorithm |
| 7. Reranking | Re-scores results for relevance | Cross-encoder/text-derived |
The system automatically adapts based on your content:
Best for: Documentation, articles, code |
Best for: Mixed content, visual search |
π― Key Benefits:
- Set mode once during ingestion β Auto-detected during search
- Cross-modal search - Text queries find images, image queries find text
- No fallback complexity - Each mode works reliably or fails clearly
- Same API - Your code doesn't change between modes
β Document Preprocessing Guide | Model Management Details
Choose the right model for your use case:
| Model | Dims | Speed | Quality | Best For |
|---|---|---|---|---|
sentence-transformers/all-MiniLM-L6-v2 β |
384 | β‘β‘β‘ | βββ | General purpose (default) |
Xenova/all-mpnet-base-v2 |
768 | β‘β‘ | ββββ | Complex queries, higher accuracy |
| Model | Dims | Speed | Quality | Best For |
|---|---|---|---|---|
Xenova/clip-vit-base-patch32 β |
512 | β‘β‘ | βββ | Text + images (default) |
Xenova/clip-vit-base-patch16 |
512 | β‘ | ββββ | Higher visual quality |
- β Auto-download - Models cached locally on first use
- β Smart compatibility - Detects model changes, prompts rebuilds
- β Offline support - Pre-download for air-gapped environments
- β Zero config - Works out of the box with sensible defaults
- β Cross-modal - CLIP enables text β image search
β Complete Model Guide | Performance Benchmarks
| I want to... | Start here |
|---|---|
| π Try it out | CLI Reference β npm i -g rag-lite-ts |
| π¨ Use visual interface | UI Guide β raglite ui |
| πΌοΈ Search images | Multimodal Tutorial β --mode multimodal |
| π» Build an app | API Reference β new SearchEngine() |
| π€ Integrate with AI | MCP Guide β raglite-mcp |
| β‘ Optimize performance | Model Guide β Choose your model |
| π Fix an issue | Troubleshooting β Common solutions |
π Complete Documentation Hub
RAG-lite TS includes a modern web-based interface for visual document management and search.
# Launch the UI (starts both frontend and backend)
raglite ui
# Opens in browser at http://localhost:3000- π€ Visual Ingestion: Drag & drop file upload with real-time progress
- π Interactive Search: Text and image search with visual results
- π Knowledge Base Stats: Overview of documents, chunks, and model information
- βοΈ Configuration: Visual interface for all ingestion options
- πΌοΈ Image Search: Upload images to find similar content
- π Folder Support: Upload entire directory structures
| Feature | UI | CLI |
|---|---|---|
| File upload | β Drag & drop | β Command-line |
| Progress tracking | β Visual bars | β Console output |
| Image search | β Upload interface | β File path |
| Configuration | β Visual options | β Command flags |
| Batch processing | β | β |
| Scripting | β | β |
Use UI for: Interactive exploration, visual feedback, learning the system
Use CLI for: Automation, scripting, headless environments
Give your AI agents semantic memory. RAG-lite TS includes a built-in Model Context Protocol (MCP) server.
# Start MCP server (works with Claude, Cline, and other MCP clients)
raglite-mcpMCP Configuration:
{
"mcpServers": {
"rag-lite": {
"command": "raglite-mcp",
"args": []
}
}
}Run multiple MCP server instances for different databases with intelligent routing:
{
"mcpServers": {
"rag-lite-text-docs": {
"command": "npx",
"args": ["rag-lite-mcp"],
"env": {
"RAG_DB_FILE": "./text-docs/db.sqlite",
"RAG_INDEX_FILE": "./text-docs/index.bin"
}
},
"rag-lite-multimodal-images": {
"command": "npx",
"args": ["rag-lite-mcp"],
"env": {
"RAG_DB_FILE": "./mixed-content/db.sqlite",
"RAG_INDEX_FILE": "./mixed-content/index.bin"
}
}
}
}Dynamic Tool Descriptions: Each server automatically detects and advertises its capabilities:
[TEXT MODE]- Text-only databases clearly indicate supported file types[MULTIMODAL MODE]- Multimodal databases advertise image support and cross-modal search- AI assistants can intelligently route queries to the appropriate database
Available Tools: search, ingest, ingest_image, multimodal_search, rebuild_index, get_stats, get_mode_info, list_supported_models, list_reranking_strategies, get_system_stats
Multimodal Features:
- Search across text and image content
- Retrieve image content as base64 data
- Cross-modal search capabilities (text queries find images)
- Automatic mode detection from database
- Content type filtering
- Multiple reranking strategies
β Complete MCP Integration Guide | MCP Multimodal Guide | Multi-Instance Setup
# Clone and setup
git clone https://github.com/your-username/rag-lite-ts.git
cd rag-lite-ts
npm install
# Build and link for development
npm run build
npm link # Makes raglite/raglite-mcp available globally
# Run tests
npm test
npm run test:integrationsrc/
βββ index.ts # Main exports and factory functions
βββ search.ts # Public SearchEngine API
βββ ingestion.ts # Public IngestionPipeline API
βββ core/ # Model-agnostic core layer
β βββ search.ts # Core search engine
β βββ ingestion.ts # Core ingestion pipeline
β βββ db.ts # SQLite operations
β βββ config.ts # Configuration system
β βββ content-manager.ts # Content storage and management
β βββ types.ts # Core type definitions
βββ text/ # Text-specific implementations
β βββ embedder.ts # Sentence-transformer embedder
β βββ reranker.ts # Cross-encoder reranking
β βββ tokenizer.ts # Text tokenization
βββ multimodal/ # Multimodal implementations
β βββ embedder.ts # CLIP embedder (text + images)
β βββ reranker.ts # Text-derived reranking for multimodal
β βββ image-processor.ts # Image description and metadata
β βββ content-types.ts # Content type detection
βββ cli.ts # CLI interface
βββ mcp-server.ts # MCP server
βββ preprocessors/ # Content type processors
dist/ # Compiled output
Simple by default, powerful when needed:
- β Simple constructors work immediately with sensible defaults
- β Configuration options available when you need customization
- β Advanced patterns available for complex use cases
- β Clean architecture with minimal dependencies
- β No ORMs or heavy frameworks - just TypeScript and SQLite
- β Extensible design for future capabilities
This approach ensures that basic usage is effortless while providing the flexibility needed for advanced scenarios.
We welcome contributions! Whether it's:
- π Bug fixes
- β¨ New features
- π Documentation improvements
- π§ͺ Test coverage
- π‘ Ideas and suggestions
Guidelines:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes with tests
- Ensure all tests pass (
npm test) - Submit a pull request
We maintain clean architecture principles while enhancing functionality and developer experience.
Existing RAG solutions are either:
- π΄ Too complex - Require extensive setup and configuration
- π΄ Cloud-dependent - Need API keys and external services
- π΄ Python-only - Not ideal for TypeScript/Node.js projects
- π΄ Heavy - Massive dependencies and slow startup
RAG-lite TS is different:
- β Simple - Works out of the box with zero config
- β Local-first - Your data stays on your machine
- β TypeScript native - Built for modern JS/TS projects
- β Lightweight - Fast startup, minimal dependencies
Built with amazing open-source projects:
- transformers.js - Client-side ML models by Xenova
- hnswlib - Fast approximate nearest neighbor search
- better-sqlite3 - Fast SQLite3 bindings
MIT License - see LICENSE file for details.
β Star us on GitHub β it helps!
Report Bug β’ Request Feature β’ Documentation
Made with β€οΈ by developers, for developers
