Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Principle:1Panel dev MaxKB Vector Storage and Retrieval

From Leeroopedia
Knowledge Sources
Domains RAG, Vector_Database
Last Updated 2026-10-10 00:00 GMT

Overview

A data storage and retrieval paradigm that maps text into high-dimensional vector space, enabling similarity-based search for semantically related content.

Description

Vector storage and retrieval is the foundation of modern RAG systems. Text is embedded into dense vectors (typically 768–1536 dimensions) by an embedding model, then stored in a vector database. At query time, the user's question is embedded into the same space, and the system retrieves the nearest vectors (by cosine similarity or L2 distance). MaxKB uses PostgreSQL's pgvector extension as its vector store, storing embeddings alongside full-text search vectors (`SearchVector`) in the same `Embedding` table. This enables three search modes: pure embedding similarity, keyword (full-text), and blended (both combined).

Usage

Use this principle when designing:

  • Knowledge base storage for RAG applications
  • Hybrid search systems combining semantic and keyword matching
  • Scalable vector retrieval with per-knowledge-base HNSW indexes

Theoretical Basis

The core operation is cosine similarity between query vector q and document vector d:

sim(q,d)=q⋅d|q|⋅|d|

For efficient retrieval, Approximate Nearest Neighbor (ANN) algorithms like HNSW (Hierarchical Navigable Small World) are used. MaxKB leverages pgvector's HNSW indexes, querying per-knowledge-base to leverage partial indexes (`WHERE knowledge_id = '{k_id}'`).

For blended search, the comprehensive score combines embedding similarity with keyword relevance:

scoreblend=α⋅simembedding+(1−α)⋅simkeyword

# Abstract algorithm description (NOT real implementation)
query_vec = embedding_model.embed(query_text)
# Search per knowledge base to leverage HNSW index
for kid in knowledge_id_list:
    results = vector_search(
        filter=knowledge_id == kid,
        vector=query_vec,
        top_n=top_n,
        threshold=similarity,
    )
# Merge and sort by similarity or comprehensive_score

Related Pages

Implemented By

Uses Heuristic

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment