Trieve Search and RAG Platform

repository·main·Indexed 25 days ago

https://github.com/devflowinc/trieve

An 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.

Tokens
195.4K
Snippets
359
Records
994
Agent score
81%

What's inside Trieve

  1. Overview of Search Query Collapse Script

    main
    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.
  2. Overview of Trieve Web Pixel Extension for Shopify

    main

    The 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.
  3. Overview of Action Extensions for Shopify Admin

    main
    Admin 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.
  4. Overview of PDF2MD

    main
    PDF2MD 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.
  5. Overview of Trieve Features

    main

    Trieve 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.
  6. Understand Trieve's NER-based Hallucination Detection

    main

    Trieve 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:

    1. Proper nouns: People, places, and organizations.
    2. Numerical values: Dates, amounts, and statistics.
    3. 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.
  7. Trieve Usage-Based Pricing Overview

    main

    Trieve 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

    ProductFree TierCost
    UsersFirst 5 Users free$5 / User
    Platform FeeN/A$5 / mo
    Chunk Storage1000 Chunks (11 MB)$132 / 1M chunks ($12.07 / GB)
    File Storage10 GB$0.046 / GB
    Datasets2 datasets$0.05 / dataset
    Write TokensFirst 3M tokens / mo free$0.028 / 1M tokens
    Search TokensFirst 3M tokens / mo free$0.028 / 1M tokens
    File OCRFirst 100 / mo free$0.01 / Page
    Web CrawlingFirst 10 pages / mo free$0.00086 / Page Crawled
    Bytes IngestedFirst 1 GB$2 / GB ingested
    Message TokensFirst 263,000 tokens / mo free$3.528 / 1M tokens
    Analytic EventsFirst 1M events / mo free$0.0001 / event
  8. Architecture of the Trieve Typo Correction System

    main

    Trieve's typo correction system is built for high performance using Rust, BKTrees, Redis, and ClickHouse. The pipeline consists of several distributed workers:

    1. Dictionary Building:
      • A word-id-cronjob scrolls through search indices and adds chunk IDs to a Redis queue.
      • A word-worker processes these chunks, splits text into words, and ingests them into ClickHouse.
    2. BKTree Construction:
      • A bktree-worker pulls the completed dictionary from ClickHouse and constructs a Burkhard-Keller Tree (BKTree).
      • The BKTree is serialized (flattened and gzipped) and stored in Redis.
    3. 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.
  9. Install System Dependencies for Local Development

    main

    Depending 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 openssl

    Linux (Arch)

    sudo pacman -S base-devel postgresql-libs

    MacOS

    # 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 openssl
  10. Implement English Word Identification Logic

    main

    To prevent incorrect corrections of legitimate English words that might be missing from a specific dataset's dictionary, use a multi-step identification process:

    1. Direct Lookup: Check against an in-memory HashSet of ~400,000 English words.
    2. Affix Analysis: Use PREFIX_TRIE and SUFFIX_TRIE to 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.
    3. Compound Word Check: For words containing hyphens, verify if all parts are valid English words.
    4. 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
    }