Skip to content
Kulraj69Public

About

A Production-Ready Vector Database for AI Applications

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Latest commit

Β 

History

31 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

KSdb Logo

KSdb

The High-Performance Vector Database for Production AI

License: MIT Python 3.11+ Build Status PRs Welcome

How To Use β€’ Next Steps β€’ Current Market β€’ Roadmap β€’ Quick Start β€’ Benchmarks β€’ API Reference


Overview

KSdb is a next-generation vector database engineered for production AI applications. Built from the ground up with performance and developer experience in mind, KSdb delivers 5-7x faster performance than alternatives while providing advanced features like hybrid search, knowledge graph extraction, and intelligent document processing.

Why KSdb?

πŸš€ Performance

  • 5.3x faster ingestion
  • 7.1x faster retrieval
  • GPU-accelerated embeddings
  • Optimized HNSW indexing

🧠 Intelligence

  • Hybrid search (vector + keyword)
  • Auto knowledge graph extraction
  • Smart deduplication
  • OCR for scanned documents

πŸ› οΈ Developer Experience

  • ChromaDB-compatible API
  • One-line installation
  • Built-in Streamlit demo
  • Comprehensive documentation

Key Features

πŸ” Hybrid Search Engine

Combines vector similarity with keyword matching using Reciprocal Rank Fusion (RRF) for superior accuracy.

🧠 Knowledge Graph Extraction

Automatically extracts entities and relationships from your documents using state-of-the-art NLP models.

⚑ GPU Acceleration

Native support for CUDA, MPS (Apple Silicon), and ROCm for 5-10x faster embedding generation.

πŸ–ΌοΈ Intelligent Document Processing

Built-in OCR support for scanned PDFs using EasyOCR, with automatic fallback detection.

🎯 Smart Deduplication

Similarity-based duplicate detection with configurable thresholds.

🌐 Production-Ready Architecture

  • RESTful API with interactive documentation
  • Scalable PostgreSQL backend
  • S3-compatible object storage
  • Docker and Kubernetes ready

Quick Start

Installation

pip install ksdb

Or install from source:

git clone https://github.com/Kulraj69/KSDB.git
cd KSDB
pip install -e .

Start the Server

# Start KSdb server (runs on port 8000)
python -m ksdb.cli run

# Or with custom configuration
python -m ksdb.cli run --port 9000 --data-dir ./my_data

Basic Usage

from ksdb import Client

# Initialize client
client = Client("http://localhost:8000")

# Create collection
collection = client.get_or_create_collection("products")

# Add documents with automatic deduplication and graph extraction
collection.add(
    ids=["p1", "p2", "p3"],
    documents=[
        "High-performance laptop with 32GB RAM",
        "Business laptop with extended battery",
        "Professional workstation for developers"
    ],
    metadatas=[
        {"category": "electronics", "price": 1299},
        {"category": "electronics", "price": 899},
        {"category": "electronics", "price": 1599}
    ],
    deduplicate=True,      # Remove duplicates automatically
    extract_graph=True     # Extract knowledge graph
)

# Hybrid search with metadata filtering
results = collection.query(
    query_texts=["best laptop for programming"],
    n_results=5,
    where={"price": {"$lt": 1500}}
)

# Explain why each result ranked where it did
debug = collection.explain_query(
    query_texts=["best laptop for programming"],
    n_results=5,
    where={"price": {"$lt": 1500}}
)
print(debug["profile"])

Live Public Data Example

Ingest recent Hacker News stories about RAG/vector databases without an API key:

python examples/ingest_hacker_news.py \
  --query "RAG vector database" \
  --limit 25 \
  --collection live_hacker_news

See the full guide in docs/HOW_TO_USE.md.


Performance Benchmarks

Vector Search Performance

Tested on MacBook Pro M-series with 500 documents:

Operation KSdb ChromaDB Performance Gain
Bulk Ingestion 3.28s 17.33s 5.3x faster ⚑
Single Query 30ms 216ms 7.1x faster ⚑
Concurrent Queries (10) 45ms avg 312ms avg 6.9x faster ⚑

Feature Comparison

Feature KSdb ChromaDB Pinecone Weaviate
Hybrid Search βœ… ❌ ⚠️ Limited βœ…
Knowledge Graph βœ… ❌ ❌ ⚠️ Limited
GPU Acceleration βœ… ❌ βœ… βœ…
OCR Support βœ… ❌ ❌ ❌
Self-Hosted βœ… Free βœ… Free πŸ’° Paid βœ… Free
Performance ⚑ 5-7x 1x Baseline ⚑ 3-4x ⚑ 2-3x
πŸ“Š View Detailed Benchmark Results
# Run benchmarks yourself
export HF_TOKEN="your_huggingface_token"
python benchmark_fair_comparison.py

Full results available in performance_analysis.py


Architecture

graph TB
    A[Client Application] -->|REST/SDK| B[KSdb API Server]
    B --> C[Embedding Service]
    B --> D[HNSW Vector Index]
    B --> E[FTS5 Keyword Index]
    B --> F[Knowledge Graph]
    C -->|GPU Accelerated| G[Sentence Transformers]
    D --> H[(PostgreSQL/SQLite)]
    E --> H
    F --> H
    D --> I[S3/Local Storage]
    
    style B fill:#4CAF50
    style C fill:#2196F3
    style D fill:#FF9800
    style E fill:#FF9800
    style F fill:#9C27B0
Loading

Core Components

  • Embedding Service: GPU-accelerated text-to-vector conversion using Sentence Transformers
  • HNSW Index: Hierarchical Navigable Small World algorithm for fast approximate nearest neighbor search
  • FTS5 Engine: Full-text search with BM25 ranking for keyword matching
  • Knowledge Graph: Entity and relationship extraction using GLiNER
  • Metadata Store: Flexible JSON-based metadata with advanced filtering support

Advanced Features

Hybrid Search

Unlike pure vector databases, KSdb's hybrid search combines semantic understanding with keyword precision:

# Automatically balances vector and keyword search
results = collection.query(
    query_texts=["machine learning frameworks"],
    n_results=10
)
# Returns results ranked by RRF (Reciprocal Rank Fusion)

Knowledge Graph Queries

# Extract knowledge graph
collection.add(
    ids=["doc1"],
    documents=["Apple Inc. was founded by Steve Jobs in Cupertino, California"],
    extract_graph=True
)

# Query relationships
graph = collection.get_graph(subjects=["Apple Inc."])
# Returns: [
#   {"subject": "Apple Inc.", "predicate": "founded_by", "object": "Steve Jobs"},
#   {"subject": "Apple Inc.", "predicate": "located_in", "object": "Cupertino"}
# ]

Smart Deduplication

# Automatically detect and skip similar documents
collection.add(
    ids=["d1", "d2"],
    documents=[
        "The quick brown fox jumps over the lazy dog",
        "A quick brown fox jumps over a lazy dog"  # 95% similar - skipped
    ],
    deduplicate=True,
    similarity_threshold=0.9  # Configurable threshold
)

OCR Processing

The Streamlit demo in app.py includes PDF/TXT upload and OCR fallback for scanned PDFs. For production ingestion, extract text into chunks first, then call collection.add(ids=[...], documents=chunks).


Demo Application

KSdb includes a production-ready Streamlit demo showcasing RAG (Retrieval-Augmented Generation):

# Set environment variables
export HF_TOKEN="your_huggingface_token"

# Start demo (runs on port 8501)
streamlit run app.py

Features:

  • πŸ“„ PDF/TXT upload with automatic OCR
  • πŸ’¬ ChatGPT-style conversational interface
  • πŸ“Š Real-time performance metrics
  • 🧠 Knowledge graph visualization
  • 🎯 Hybrid search demonstration

API Reference

REST API

Interactive API documentation available at http://localhost:8000/docs (Swagger UI)

Core Endpoints:

  • POST /collections/{name}/add - Add documents
  • POST /collections/{name}/query - Search documents
  • POST /collections/{name}/query/explain - Search with hybrid ranking diagnostics
  • GET /collections/{name}/graph - Query knowledge graph
  • DELETE /collections/{name}/delete/{doc_id} - Delete a document
  • DELETE /collections/{name} - Delete collection

Python SDK

Full SDK documentation: API Reference

from ksdb import Client

client = Client("http://localhost:8000")

# Collection operations
collection = client.create_collection("name")
collection = client.get_collection("name")
collections = client.list_collections()

# Document operations
collection.add(ids, documents, metadatas, deduplicate, extract_graph)
collection.query(query_texts, n_results, where)
collection.explain_query(query_texts, n_results, where)
collection.update(ids, documents, metadatas)
collection.delete(ids)

# Knowledge graph
collection.get_graph(subjects)

Deployment

Development

# Local development with SQLite
python -m ksdb.cli run

Docker

# Single container
docker run -p 8000:8000 ksdb/ksdb:latest

# Docker Compose (with PostgreSQL)
docker-compose up -d

Production (AWS)

# Deploy to AWS App Runner
./deploy/push_to_ecr.sh

# Or use provided CloudFormation templates
aws cloudformation create-stack \
  --stack-name ksdb-production \
  --template-body file://deploy/cloudformation.yml

Full deployment guide: Production Deployment


Integration Examples

LangChain

from langchain.vectorstores import KSdb
from langchain.embeddings import HuggingFaceEmbeddings

embeddings = HuggingFaceEmbeddings()
vectorstore = KSdb(
    client=client,
    collection_name="docs",
    embedding_function=embeddings
)

LlamaIndex

from llama_index import VectorStoreIndex, ServiceContext
from llama_index.vector_stores import KSdbVectorStore

vector_store = KSdbVectorStore(client=client, collection_name="docs")
index = VectorStoreIndex.from_vector_store(vector_store)

Cursor AI (MCP)

# Start MCP server
python -m ksdb.mcp_server

# Add to Cursor config
{
  "mcpServers": {
    "ksdb": {
      "command": "python",
      "args": ["-m", "ksdb.mcp_server"]
    }
  }
}

Performance Optimization

Quick Wins

  1. Disable graph extraction for pure RAG (8.9x faster ingestion)

    collection.add(..., extract_graph=False)
  2. Batch operations (2-3x faster)

    collection.add(ids=batch_ids, documents=batch_docs)  # 100-500 docs
  3. GPU acceleration (automatic, 5-10x faster embeddings)

    • Auto-detects CUDA, MPS, ROCm

Advanced Tuning

HNSW Parameters:

# In server config
HNSW_M = 32  # Higher M = better recall, more memory
HNSW_EF_CONSTRUCTION = 400  # Higher ef = better quality, slower build

Query Caching:

# Enable Redis caching (10-100x faster for repeated queries)
client = Client("http://localhost:8000", cache_ttl=3600)

Full optimization guide: Performance Tuning


Roadmap

The roadmap has been refreshed for 2026 based on what production retrieval systems now need: hybrid search quality, filter-aware retrieval, reranking, query profiling, backups, tenant isolation, and agent/MCP workflows.

Immediate next work:

  • Add where_document filters and optional BM25/FTS score exposure
  • Add MMR/reranking options for better RAG context diversity
  • Add backup, restore, migration, and index rebuild commands
  • Align Docker/server deployment with the package server API
  • Publish reproducible benchmarks against Chroma, Qdrant, pgvector, and Weaviate

See ROADMAP.md for the full staged plan and docs/CURRENT_MARKET.md for the current market context.


Community & Support

πŸ“š Documentation Wiki

πŸ’¬ Discussions GitHub Discussions

πŸ› Issues Bug Reports

🌐 Community Discord β€’ Twitter


Contributing

We welcome contributions from the community! See our Contributing Guide for details.

Areas we're looking for help:

  • πŸš€ Performance optimization
  • πŸ” Enterprise features (auth, RBAC)
  • πŸ“Š Advanced analytics
  • 🎨 Web dashboard development
  • πŸ“š Documentation and tutorials

License

KSdb is released under the MIT License.


Acknowledgments

KSdb is built on the shoulders of giants:


Built with ❀️ for the AI community

⭐ Star us on GitHub β€’ πŸ“– Read the Docs β€’ πŸš€ Get Started

Β© 2026 KSdb. All rights reserved.

About

A Production-Ready Vector Database for AI Applications

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages