High-performance vector database with unified configuration, I/O optimization, and automatic embeddings
Project description
VittoriaDB Python SDK
VittoriaDB Python SDK is a client library for VittoriaDB, a high-performance embedded vector database built in Go. This SDK provides a clean, Pythonic interface to interact with VittoriaDB server instances, with automatic binary management and server lifecycle control.
๐๏ธ Architecture
VittoriaDB consists of two components:
- ๐ VittoriaDB Server (Go binary): High-performance vector database engine
- ๐ Python SDK (this package): Client library with automatic server management
The Python SDK can either:
- Auto-manage the Go server binary (downloads, starts, stops automatically)
- Connect to an existing VittoriaDB server instance
๐ Key Features
- ๐ฏ Zero Configuration: Works immediately after installation with sensible defaults
- ๐ค Automatic Embeddings: Server-side text vectorization with multiple model support
- ๐ Document Processing: Built-in support for PDF, DOCX, TXT, MD, and HTML files
- ๐ง Auto Binary Management: Automatically downloads and manages VittoriaDB binaries
- โก High Performance: HNSW indexing provides sub-millisecond search times
- ๐ Pythonic API: Clean, intuitive Python interface with type hints
- ๐ Dual Mode: Works with existing servers or auto-starts local instances
- ๐ค RAG-Ready: Built-in content storage for Retrieval-Augmented Generation
- ๐ NEW v0.5.0: Unified configuration system with YAML, env vars, and CLI support
- โก NEW v0.5.0: I/O optimization with memory-mapped storage and SIMD operations
- ๐ง NEW v0.5.0: Enhanced batch processing with intelligent error recovery
- ๐ง NEW v0.5.0: Smart chunking with sentence-aware text segmentation
- ๐ NEW v0.5.0: Parallel search engine with configurable worker pools and caching
- ๐ Metrics:
db.stats()reportsqueries_total,avg_query_latency, andqueries_per_sec;db.prometheus_metrics()fetches Prometheus text fromGET /metrics - ๐ท๏ธ Metadata filters: Pass a flat dict (e.g.
{"category": "tech"}) or a structured filter; usecollection.search(..., use_post=True)for large or nested filters (POST /collections/{name}/search) - ๐๏ธ IVF (prototype):
create_collection(..., index_type=IndexType.IVF, config=Configure.Index.ivf_flat(nlist=16, nprobe=2))
Backup / restore is provided by the
vittoriadbCLI (backup/restoresubcommands), not the Python client. Stop the server before runningrestore.
๐ฆ Installation
pip install vittoriadb
The package automatically downloads the appropriate VittoriaDB binary for your platform during installation.
๐ Server Management
Automatic Server Management (Recommended)
import vittoriadb
# SDK automatically downloads, starts, and manages the VittoriaDB server
db = vittoriadb.connect() # auto_start=True by default
# ... use the database ...
db.close() # Automatically stops the server
Manual Server Management
# Download VittoriaDB binary manually
# From: https://github.com/antonellof/VittoriaDB/releases
# Start server manually
./vittoriadb run --port 8080 --data-dir ./data
# In Python, connect to existing server
import vittoriadb
db = vittoriadb.connect(url="http://localhost:8080", auto_start=False)
Connection Options
# Auto-start with custom configuration
db = vittoriadb.connect(
auto_start=True,
port=9090,
host="localhost",
data_dir="./my_vectors"
)
# Connect to remote server
db = vittoriadb.connect(
url="http://remote-server:8080",
auto_start=False
)
๐ Quick Start
Basic Usage
import vittoriadb
# Auto-starts VittoriaDB server and connects
db = vittoriadb.connect()
# Create a collection
collection = db.create_collection(
name="documents",
dimensions=384,
metric="cosine"
)
# Insert vectors with metadata
collection.insert(
id="doc1",
vector=[0.1, 0.2, 0.3] * 128, # 384 dimensions
metadata={"title": "My Document", "category": "tech"}
)
# Search for similar vectors
results = collection.search(
vector=[0.1, 0.2, 0.3] * 128,
limit=5,
include_metadata=True
)
for result in results:
print(f"ID: {result.id}, Score: {result.score:.4f}")
print(f"Metadata: {result.metadata}")
# Close connection
db.close()
Automatic Text Embeddings (๐ NEW!)
import vittoriadb
from vittoriadb.configure import Configure
# Connect to VittoriaDB
db = vittoriadb.connect()
# Create collection with automatic embeddings
collection = db.create_collection(
name="smart_docs",
dimensions=384,
vectorizer_config=Configure.Vectors.auto_embeddings() # ๐ฏ Server-side embeddings!
)
# Insert text directly - embeddings generated automatically!
collection.insert_text(
id="article1",
text="Artificial intelligence is transforming how we process data.",
metadata={"category": "AI", "source": "blog"}
)
# Batch insert multiple texts
texts = [
{
"id": "article2",
"text": "Machine learning enables computers to learn from data.",
"metadata": {"category": "ML"}
},
{
"id": "article3",
"text": "Vector databases provide efficient similarity search.",
"metadata": {"category": "database"}
}
]
collection.insert_text_batch(texts)
# Search with natural language queries
results = collection.search_text(
query="artificial intelligence and machine learning",
limit=3
)
for result in results:
print(f"Score: {result.score:.4f}")
print(f"Text: {result.metadata['text'][:100]}...")
db.close()
Document Upload and Processing
import vittoriadb
from vittoriadb.configure import Configure
db = vittoriadb.connect()
# Create collection with vectorizer for automatic processing
collection = db.create_collection(
name="knowledge_base",
dimensions=384,
vectorizer_config=Configure.Vectors.auto_embeddings()
)
# Upload and process documents automatically
result = collection.upload_file(
file_path="research_paper.pdf",
chunk_size=600,
chunk_overlap=100,
metadata={"source": "research", "year": "2024"}
)
print(f"Processed {result['chunks_created']} chunks")
print(f"Inserted {result['chunks_inserted']} vectors")
# Search the uploaded content
results = collection.search_text(
query="machine learning algorithms",
limit=5
)
db.close()
๐ค RAG (Retrieval-Augmented Generation) Support (NEW v0.4.0)
VittoriaDB now includes built-in support for RAG systems by automatically storing original text content alongside vector embeddings.
Content Storage Features
- โ Automatic Content Preservation: Original text stored with vectors
- โ No External Storage Required: Self-contained RAG solution
- โ Configurable Limits: Control storage size and behavior
- โ Fast Retrieval: Single query returns both vectors and content
RAG-Optimized Collection
import vittoriadb
from vittoriadb import ContentStorageConfig
from vittoriadb.configure import Configure
db = vittoriadb.connect()
# Create RAG-optimized collection with content storage
collection = db.create_collection(
name="rag_documents",
dimensions=384,
vectorizer_config=Configure.Vectors.auto_embeddings(),
content_storage=ContentStorageConfig(
enabled=True, # Store original content
field_name="_content", # Metadata field name
max_size=1048576, # 1MB limit per document
compressed=False # Compression (future feature)
)
)
# Insert documents - content automatically preserved
collection.insert_text(
id="doc1",
text="VittoriaDB is a high-performance vector database perfect for RAG applications...",
metadata={"title": "VittoriaDB Guide", "category": "documentation"}
)
# Search with content retrieval for RAG
results = collection.search_text(
query="vector database RAG",
limit=5,
include_content=True # Retrieve original content for LLM context
)
# Use results for RAG
for result in results:
print(f"Score: {result.score:.3f}")
print(f"Content: {result.content}") # Original text for LLM context
print(f"Has content: {result.has_content()}")
db.close()
RAG Workflow Example
# 1. Store knowledge base
documents = [
"VittoriaDB supports automatic embeddings...",
"RAG systems combine retrieval and generation...",
"Vector databases enable semantic search..."
]
for i, doc in enumerate(documents):
collection.insert_text(f"kb_{i}", doc, {"type": "knowledge"})
# 2. Query with content for LLM
query = "How do vector databases work?"
results = collection.search_text(query, include_content=True)
# 3. Build context for LLM
context = "\n".join([r.content for r in results if r.has_content()])
# 4. Send to your LLM
# response = your_llm.generate(query, context)
๐๏ธ Vectorizer Configuration
VittoriaDB supports multiple vectorizer backends for automatic embedding generation:
Sentence Transformers (Default)
from vittoriadb.configure import Configure
config = Configure.Vectors.sentence_transformers(
model="all-MiniLM-L6-v2",
dimensions=384
)
OpenAI Embeddings
config = Configure.Vectors.openai_embeddings(
api_key="your-openai-api-key",
model="text-embedding-ada-002",
dimensions=1536
)
HuggingFace Models
config = Configure.Vectors.huggingface_embeddings(
api_key="your-hf-token", # Optional for public models
model="sentence-transformers/all-MiniLM-L6-v2",
dimensions=384
)
Local Ollama
config = Configure.Vectors.ollama_embeddings(
model="nomic-embed-text",
dimensions=768,
base_url="http://localhost:11434"
)
๐ Document Processing
VittoriaDB supports automatic processing of various document formats:
| Format | Extension | Status | Features |
|---|---|---|---|
| Plain Text | .txt |
โ Fully Supported | Direct text processing |
| Markdown | .md |
โ Fully Supported | Frontmatter parsing |
| HTML | .html |
โ Fully Supported | Tag stripping, metadata |
.pdf |
โ Fully Supported | Multi-page text extraction | |
| DOCX | .docx |
โ Fully Supported | Properties, text extraction |
# Upload multiple document types
for file_path in ["doc.pdf", "guide.docx", "readme.md"]:
result = collection.upload_file(
file_path=file_path,
chunk_size=500,
metadata={"batch": "docs_2024"}
)
print(f"Processed {file_path}: {result['chunks_inserted']} chunks")
๐ง Advanced Configuration
Collection Configuration
# High-performance HNSW configuration
collection = db.create_collection(
name="large_dataset",
dimensions=1536,
metric="cosine",
index_type="hnsw",
config={
"m": 32, # HNSW connections per node
"ef_construction": 400, # Construction search width
"ef_search": 100 # Search width
},
vectorizer_config=Configure.Vectors.openai_embeddings(api_key="your-key")
)
Connection Options
# Connect to existing server
db = vittoriadb.connect(
url="http://localhost:8080",
auto_start=False
)
# Auto-start with custom configuration
db = vittoriadb.connect(
auto_start=True,
port=9090,
data_dir="./my_vectors"
)
Search with Filtering
# Search with metadata filters
results = collection.search(
vector=query_vector,
limit=10,
filter={"category": "technology", "year": 2024},
include_metadata=True
)
# Text search with filters
results = collection.search_text(
query="machine learning",
limit=5,
filter={"source": "research"}
)
๐ง Configuration Management (NEW v0.5.0)
VittoriaDB v0.5.0 introduces a powerful unified configuration system that supports YAML files, environment variables, and CLI flags with intelligent precedence.
Configuration Inspection
import vittoriadb
# Connect to VittoriaDB
db = vittoriadb.connect()
# Get current configuration
config_info = db.config()
print("Server Configuration:")
print(f" Host: {config_info['config']['server']['host']}")
print(f" Port: {config_info['config']['server']['port']}")
print("Performance Features:")
print(f" Parallel Search: {config_info['feature_flags']['parallel_search']}")
print(f" Search Cache: {config_info['feature_flags']['search_cache']}")
print(f" Memory-Mapped I/O: {config_info['feature_flags']['mmap_storage']}")
print(f" SIMD Optimizations: {config_info['feature_flags']['simd_optimizations']}")
db.close()
Advanced Server Configuration
# Start server with custom configuration
db = vittoriadb.connect(
auto_start=True,
port=9090,
host="localhost",
data_dir="./my_vectors",
# Additional server arguments can be passed
extra_args=[
"--config", "my-config.yaml", # Use YAML configuration
"--log-level", "debug", # Enable debug logging
"--parallel-workers", "16" # Set parallel search workers
]
)
๐ Performance and Scalability
- Insert Speed: >10,000 vectors/second with flat indexing, >5,000 with HNSW
- Search Speed: Sub-millisecond search times for 1M vectors using HNSW
- Memory Usage: <100MB for 100,000 vectors (384 dimensions)
- Scalability: Tested up to 1 million vectors, supports up to 2,048 dimensions
- ๐ NEW v0.5.0: Up to 276x speedup with combined I/O optimizations
- ๐ NEW v0.5.0: 5-32x faster parallel search for large datasets
- ๐ NEW v0.5.0: SIMD operations provide up to 7.7x vector processing speedup
๐ API Reference
Collection Class
insert(id, vector, metadata=None)- Insert single vectorinsert_batch(vectors)- Insert multiple vectorsinsert_text(id, text, metadata=None)- Insert text (auto-vectorized with content storage)insert_text_batch(texts)- Insert multiple texts (auto-vectorized with content storage)search(vector, limit=10, filter=None, include_content=False)- Vector similarity searchsearch_text(query, limit=10, filter=None, include_content=False)- Text search with content retrievalupload_file(file_path, chunk_size=500, **kwargs)- Upload and process documentget(id)- Get vector by IDdelete(id)- Delete vector by IDcount()- Get total vector count
VittoriaDB Class (Enhanced v0.5.0)
connect(url=None, auto_start=True, **kwargs)- Connect to VittoriaDBcreate_collection(name, dimensions, metric="cosine", vectorizer_config=None, content_storage=None)- Create collection with content storageget_collection(name)- Get existing collectionlist_collections()- List all collectionsdelete_collection(name)- Delete collectionhealth()- Get server health statusstats()- Get database statisticsconfig()- Get current server configuration (NEW v0.5.0)close()- Close connection
๐ค Contributing
We welcome contributions!
- Users: Report issues and request features on GitHub Issues
- Developers: See DEVELOPMENT.md for setup, building, and deployment instructions
- General: Check our Contributing Guide for project guidelines
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Links
- GitHub: https://github.com/antonellof/VittoriaDB
- PyPI: https://pypi.org/project/vittoriadb/
- Issues: https://github.com/antonellof/VittoriaDB/issues
๐ What's Next?
- ๐ Hybrid Search: Combine vector and keyword search
- ๐ Authentication: User management and access control
- ๐ Distributed Mode: Multi-node clustering support
- ๐ Analytics: Query performance monitoring and optimization
- ๐ฏ More Vectorizers: Support for additional embedding models
๐ Changelog v0.5.0
๐ Major New Features
- ๐ง Unified Configuration System: Complete YAML, environment variables, and CLI flags support with intelligent precedence
- โก I/O Optimization Suite: Memory-mapped storage, SIMD operations, and async I/O for up to 276x performance improvements
- ๐ Parallel Search Engine: Configurable worker pools with 5-32x speedup for large datasets
- ๐ง Smart Chunking: Sentence-aware text segmentation with abbreviation handling
- ๐ง Enhanced Batch Processing: Intelligent error recovery and fallback mechanisms
- ๐ Configuration API: New
/configendpoint for runtime configuration inspection
๐ Performance Improvements
- SIMD Vector Operations: Up to 7.7x speedup for vector processing
- Memory-Mapped I/O: Zero-copy operations with microsecond latency
- Search Caching: LRU cache with TTL expiration for frequently accessed results
- Batch Processing: Robust error handling with individual fallback processing
๐ง Developer Experience
- Configuration Management: CLI tools for generating, validating, and inspecting configurations
- Hot-Reloading: Dynamic configuration updates without server restart
- Comprehensive Documentation: Updated guides for all new features
- Enhanced Examples: New demos showcasing v0.5.0 capabilities
๐ Backward Compatibility
- All existing APIs work unchanged
- Zero configuration setup continues to work seamlessly
- Automatic migration from legacy configurations
- Default behavior maintains full compatibility with v0.4.x
๐ Bug Fixes
- Fixed Windows compatibility with fallback I/O implementation
- Improved error handling in batch processing workflows
- Enhanced stability in parallel search operations
Happy building with VittoriaDB! ๐
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file vittoriadb-0.6.1.tar.gz.
File metadata
- Download URL: vittoriadb-0.6.1.tar.gz
- Upload date:
- Size: 24.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
32b4351878b39e66e565648db1ee5679154d3f91543b051d19f0c1128adfeca2
|
|
| MD5 |
0d5a35e44225705d598e95cb5eca88f7
|
|
| BLAKE2b-256 |
e5c75732bd3edc5e16d2ec15061997ad9b0ba05e5c286df60593c6ff7626b5fc
|
File details
Details for the file vittoriadb-0.6.1-py3-none-any.whl.
File metadata
- Download URL: vittoriadb-0.6.1-py3-none-any.whl
- Upload date:
- Size: 19.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2d5f8e47e5d42ab298fadf6ac2ad3eed0ecbb4c9ff8c781fdd238b802fdecd2c
|
|
| MD5 |
eedd250550ba88487d0c95d907dffbd9
|
|
| BLAKE2b-256 |
2978cd908e20696dfc280def20ee6d384a80f4285927e0bd8aaac6ab354fd29c
|