Infinity AI-Native Database Documentation

repository·main·Indexed 26 days ago

https://github.com/infiniflow/infinity

Infinity is an AI-native database for LLM applications, specializing in high-performance hybrid search across dense and sparse embeddings, tensors, full-text, and structured data. The documentation covers the infinity-sdk and infinity-embedded-sdk (v0.7.2) for Python, the Go SDK, the Infinity GUI management interface, and tools for benchmarking vector search performance.

Tokens
55.1K
Snippets
144
Records
308
Agent score
89%

What's inside Infinity

  1. Overview of the FST (Finite State Transducer) library

    main

    The FST library is a C++ reimplementation of the BurntSushi/fst library. It is designed for efficiently storing and searching very large ordered sets or maps (up to billions of entries) where keys are byte strings.

    Key characteristics:

    • Binary Compatibility: The FST file format is designed to be binary compatible with the original BurntSushi/fst library.
    • Memory Efficiency: Optimized for extremely large datasets to ensure all operations remain memory efficient.
    • Compression: Uses a finite state machine to compress common prefixes and suffixes in keys.
    • Query Capabilities: Supports efficient querying via automata (e.g., regular expressions, Levenshtein distance for fuzzy queries) and lexicographic ranges.
  2. Overview of MLAS compute library

    main
    MLAS is a compute library designed for high-performance machine learning operations. It provides processor-optimized GEMM (General Matrix Multiplication) kernels and includes platform-specific threading code to optimize execution across different hardware architectures.
  3. Overview of cURLpp

    main

    cURLpp is a C++ wrapper for libcURL that provides an object-oriented (OO) layer over the standard C library. While you can use libcURL directly in C++ programs, cURLpp offers several specific advantages:

    • Type Safety: Uses C++ type systems to prevent errors.
    • Exception Safety: Integrates with C++ exception handling.
    • Standard Library Integration: Uses C++ standard library structures instead of custom/homemade ones.
    • Option Querying: Allows querying handles for option values (available in version 0.5.x and newer).
  4. HTTP API Reference Overview

    main
    This document provides a complete reference for interacting with Infinity's HTTP APIs. The API allows for management of databases, schemas, and tables, as well as performing data operations. Note that while the documentation header mentions Python APIs, the reference covers the underlying HTTP interface used by clients.
  5. PLAID index features and performance

    main

    PLAID (Product Lookups for AI-Dense retrieval) is designed for high compression and efficient memory management.

    Key Features:

    • Residual Quantization: Uses 2-bit or 4-bit quantization for compact storage.
    • Mmap Support: Supports memory-mapped index files for efficient memory management.
    • Batch Processing: Full support for efficient batch search capabilities.
    • Incremental Updates: Supports incremental index building.

    Performance Characteristics:

    • Memory Usage: Reduces footprint to approximately 1/8 to 1/16 of the original size using 2-bit or 4-bit quantization.
    • Indexing Complexity: $O(N \times K \times D)$ where $N$ is embeddings, $K$ is centroids, and $D$ is dimension.
    • Search Complexity: $O(Q \times K + C \times D)$ where $Q$ is query tokens and $C$ is candidates.
  6. Infinity Cluster Architecture Overview

    main

    An Infinity cluster uses a distributed architecture with shared storage (MinIO) to provide high availability and scalability. The cluster consists of three types of nodes:

    • Leader node: The single write node. It manages transactions, processes writes, and manages the connection status of other nodes. It ensures strong consistency by waiting for all follower nodes to persist logs before confirming a transaction.
    • Follower node: A read node that receives logs/WAL from the leader synchronously. It acts as a backup and maintains strong consistency with the leader.
    • Learner node: A read node that receives logs/WAL from the leader asynchronously. It serves as a backup but may lag behind the leader as it does not require strong consistency.

    Key usage pattern: All write operations must go through the Leader node. Read operations can be distributed across the Leader, Follower, and Learner nodes to alleviate the write burden.

  7. Build and install zsv from source

    main

    To build and install the full zsv package (including the library and CLI) from source, you need a basic Unix toolchain with sh and make/gmake.

    Run the following commands:

    ./configure && sudo ./install.sh

    Alternatively, you can use:

    ./configure && sudo make install

    To build independent executables into a local build folder instead of a system-wide installation, use make install instead of make all.

  8. Use the base64 header-only library

    main

    The base64 library provides a simple, header-only approach for converting strings to and from Base64 encoding. It requires a C++17 compatible compiler.

    To encode a string, use the to_base64() function. To decode a Base64 string back to its original form, use the from_base64() function.

    #include <iostream>
    #include "base64.hpp"
    
    int main() {
      // Encode a string to base64
      auto base64 = to_base64("Hello, World!");
      std::cout << base64 << std::endl; // SGVsbG8sIFdvcmxkIQ==
    
      // Decode a base64 string
      auto s = from_base64("SGVsbG8sIFdvcmxkIQ==");
      std::cout << s << std::endl; // Hello, World!
    }
  9. Benchmark vector search performance

    main

    To benchmark vector search performance using the provided scripts, follow these steps:

    1. Clone the Infinity source code to your local directory.
    2. Prepare the dataset: Copy or create a symbolic link of the sift_1m or gist_1m dataset into the test/data/benchmark/sift_1m (or gist_1m) directory within the Infinity source path.
    3. Import data and create index: Start the Infinity server, then execute remote_benchmark_knn_import.py to import the dataset and build the index.
    4. Execute search benchmark: Run remote_benchmark_knn.py to perform the searching benchmark.
  10. Build Infinity from source on Linux using Docker

    main

    If you are on Linux, you can build Infinity using Docker to avoid local dependency issues. This method involves cloning the repository, running a specialized Docker container for the build environment, and then starting the server.

    Note: Infinity can only be natively compiled on Linux. For other operating systems, use Docker.

    # 1. Download the source code
    git clone https://github.com/infiniflow/infinity.git
    
    # 2. Build the source code using Docker
    cd infinity && mkdir cmake-build-debug
    TZ=$(readlink -f /etc/localtime | awk -F '/zoneinfo/' '{print $2}')
    docker run -d --name infinity_build -e TZ=$TZ -v $PWD:/infinity -v /boot:/boot infiniflow/infinity_builder:ubuntu22_clang20
    docker exec infinity_build bash -c "cd /infinity/cmake-build-debug && cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_VERBOSE_MAKEFILE=ON .. && cmake --build . -t  infinity"
    
    # 3. Start up the Infinity server
    sudo mkdir -p /var/infinity && sudo chown -R $USER /var/infinity
    ulimit -n 500000
    ./cmake-build-debug/src/infinity