Trieve Search and RAG Platform
repository·main·Indexed 25 days ago
https://github.com/devflowinc/trieveAn all-in-one search and Retrieval-Augmented Generation (RAG) platform providing semantic vector search, hybrid search, and recommendation engines. Trieve supports managed cloud usage and self-hosting. The ecosystem includes a CLI for dataset management and RAG configuration, a Docusaurus search theme (@trieve/docusaurus-search-theme), an MCP server for AI agents (trieve-mcp-server), and n8n nodes for workflow integration.
What's inside Trieve
- The Search Query Collapse Script is a utility designed to optimize search query analytics in a ClickHouse database. It prevents redundant partial queries (e.g., 'a', 'ap', 'app', 'apple') from skewing analytics by removing them if they are prefixes of longer, more complete queries that occur within a 10-second window.
Overview of Trieve Web Pixel Extension for Shopify
mainThe Trieve Web Pixel Extension is a Shopify app extension designed to manage and process behavioral data within a secure sandbox environment. It allows developers to subscribe to customer events without requiring users to manually add tracking code.
Key benefits include:
- Automated Tracking: Minimizes the need for users to add manual tracking code.
- Secure Access: Provides access to storefront, checkout, and post-purchase pages via a sandbox.
- Data Control: Allows developers to control exactly what data is accessed.
- Performance & Privacy: Avoids performance degradation and privacy alerts by using a smaller pixel code library and reducing DOM manipulation.
Overview of Action Extensions for Shopify Admin
mainAdmin action extensions allow developers to build custom functionality directly into the Shopify Admin interface. These extensions appear as launchable menu actions that open interactive modals at specific extension targets, enhancing the merchant experience. Content for these extensions is built using Shopify's UI Extension components for Admin.Overview of PDF2MD
mainPDF2MD is a self-hostable API server and processing pipeline designed to convert PDF documents into Markdown. It utilizes large language model (LLM) vision capabilities (such as GPT-4o-mini or Gemini Flash 1.5) to handle complex layouts and diagrams more effectively than traditional tools like Apache Tika. The system is written in Rust and uses a distributed worker architecture for horizontal scaling.Overview of Trieve Features
mainTrieve is an all-in-one solution for search, recommendations, and RAG (Retrieval-Augmented Generation). Key capabilities include:
- Semantic Search: Integrates with OpenAI, Jina, and Qdrant for dense vector search.
- Neural Sparse Search: Uses SPLADE for typo-tolerant full-text search.
- Hybrid Search: Combines methods with cross-encoder re-ranking (e.g., BAAI/bge-reranker-large).
- RAG API: Managed RAG with topic-based memory or custom context RAG via OpenRouter.
- Advanced UX: Sub-sentence highlighting and recency biasing.
- Data Management: Supports filtering (date, tag, numeric), grouping (file-level search), and tunable merchandising (clicks, citations).
- Deployment: Supports self-hosting in VPCs, on-prem, AWS, GCP, Kubernetes, or Docker Compose.
Overview of Shopify Admin Block Extensions
mainAdmin block extensions allow developers to integrate custom functionality directly into the Shopify Admin interface. These extensions appear as cards at specific extension targets, enhancing the merchant experience. Developers use Shopify's UI Extension components for Admin to build the content and interface of these blocks.Understand Trieve's NER-based Hallucination Detection
mainTrieve implements a lightweight hallucination detection system designed for RAG (Retrieval-Augmented Generation) workflows. Instead of using a slow 'LLM-as-a-judge' approach, it utilizes Named Entity Recognition (NER) to identify and compare critical information between the generated AI completion and the retrieved reference text.
Key focus areas for detection:
- Proper nouns: People, places, and organizations.
- Numerical values: Dates, amounts, and statistics.
- Made-up terminology: Unknown or gibberish words.
Benefits:
- Performance: Extremely fast processing time of 100-300ms.
- Efficiency: Runs on CPU nodes and does not require external AI services.
- Reliability: High alignment with complex models (e.g., 70% alignment with Vectara's model predictions) and strong detection of numerical inconsistencies.
Trieve Usage-Based Pricing Overview
mainTrieve uses a usage-based pricing model designed to support scaling without the friction of large, restrictive tiers. The model includes a base platform fee and charges based on specific resource consumption such as storage, ingestion, and search operations.
Core Pricing Components
Product Free Tier Cost Users First 5 Users free $5 / User Platform Fee N/A $5 / mo Chunk Storage 1000 Chunks (11 MB) $132 / 1M chunks ($12.07 / GB) File Storage 10 GB $0.046 / GB Datasets 2 datasets $0.05 / dataset Write Tokens First 3M tokens / mo free $0.028 / 1M tokens Search Tokens First 3M tokens / mo free $0.028 / 1M tokens File OCR First 100 / mo free $0.01 / Page Web Crawling First 10 pages / mo free $0.00086 / Page Crawled Bytes Ingested First 1 GB $2 / GB ingested Message Tokens First 263,000 tokens / mo free $3.528 / 1M tokens Analytic Events First 1M events / mo free $0.0001 / event Architecture of the Trieve Typo Correction System
mainTrieve's typo correction system is built for high performance using Rust, BKTrees, Redis, and ClickHouse. The pipeline consists of several distributed workers:
- Dictionary Building:
- A
word-id-cronjobscrolls through search indices and adds chunk IDs to a Redis queue. - A
word-workerprocesses these chunks, splits text into words, and ingests them into ClickHouse.
- A
- BKTree Construction:
- A
bktree-workerpulls the completed dictionary from ClickHouse and constructs a Burkhard-Keller Tree (BKTree). - The BKTree is serialized (flattened and gzipped) and stored in Redis.
- A
- API Serving:
- The API server pulls the BKTree from Redis on the first query for a dataset and caches it in memory using
lazy_static!to avoid the 300μs+ Redis latency on subsequent searches.
- The API server pulls the BKTree from Redis on the first query for a dataset and caches it in memory using
- Dictionary Building:
License change from BSL to MIT
mainTrieve is transitioning from the Business Source License (BSL) to the MIT license. This change ensures the codebase can be used by anyone for any purpose and fully embraces the open-source model.Install System Dependencies for Local Development
mainDepending on your operating system, install the following dependencies to set up a local development environment:
Linux (Debian/Ubuntu)
sudo apt install curl gcc g++ make pkg-config python3 python3-pip libpq-dev libssl-dev opensslLinux (Arch)
sudo pacman -S base-devel postgresql-libsMacOS
# Install Xcode command line tools xcode-select --install # Install Homebrew if not already installed /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" # Install required packages brew install pkg-config opensslImplement English Word Identification Logic
mainTo prevent incorrect corrections of legitimate English words that might be missing from a specific dataset's dictionary, use a multi-step identification process:
- Direct Lookup: Check against an in-memory
HashSetof ~400,000 English words. - Affix Analysis: Use
PREFIX_TRIEandSUFFIX_TRIEto identify common prefixes (e.g., 'anti', 'pre') or suffixes (e.g., 'able', 'ing'). Strip them and check if the remaining root is in the English corpus. - Compound Word Check: For words containing hyphens, verify if all parts are valid English words.
- BKTree Fallback: If the word is not identified as English, perform a BKTree search to find the closest matching words in the dataset dictionary.
fn is_likely_english_word(word: &str) -> bool { if ENGLISH_WORDS.contains(&word.to_lowercase()) { return true; } // Check for prefix if let Some(prefix_len) = PREFIX_TRIE.longest_prefix(word) { if ENGLISH_WORDS.contains(&word[prefix_len..].to_lowercase()) { return true; } } // Check for suffix if let Some(suffix_len) = SUFFIX_TRIE.longest_suffix(word) { if ENGLISH_WORDS.contains(&word[..word.len() - suffix_len].to_lowercase()) { return true; } } // Check for compound words if word.contains('-') { let parts: Vec<&str> = word.split('-').collect(); if parts .iter() .all(|part| ENGLISH_WORDS.contains(part.to_lowercase())) { return true; } } false }- Direct Lookup: Check against an in-memory