SQLAlchemy-inspired ORM for vector databases.
Project description
VectorAlchemy ๐งช
The ORM for Vector Databases. Define models. Search semantically. Switch backends without changing a line of code.
โ ๏ธ Alpha Notice
[!WARNING] VectorAlchemy is currently in
0.0.1a1(Alpha).This initial PyPI release primarily establishes the project name while core development is underway. The public API is not yet stable and may change significantly before the first stable (
1.0.0) release.We welcome early feedback, discussions, and contributors!
Project Status
VectorAlchemy is an open-source project that aims to provide a SQLAlchemy-inspired ORM for vector databases.
Current development focuses on:
- โ Core architecture
- ๐ง Query builder
- ๐ง Qdrant adapter
- ๐ง Embedding providers
- ๐ง Backend abstraction
The current PyPI release (0.0.1a2) is an early alpha preview intended to reserve the package name and allow the community to follow development from the beginning.
What is VectorAlchemy?
VectorAlchemy brings SQLAlchemy-style ORM patterns to the world of vector databases. Stop writing boilerplate embedding code, wrestling with different client APIs, and juggling filter syntax for every backend. Define your model once โ VectorAlchemy handles the rest.
from vectoralchemy import VectorModel, TextField, VectorField
class Document(VectorModel):
class Config:
backend = "qdrant"
embedder = "openai/text-embedding-3-small"
embed_field = "content"
title: str
content: str = TextField(embed=True)
author: str
year: int
# Insert โ embedding happens automatically
await Document(title="Attention Is All You Need", content="...", author="Vaswani", year=2017).save()
# Search semantically
results = await Document.search("transformer architecture", top_k=5)
# Filtered search โ Django-style lookups
results = await (
Document.objects
.filter(year__gte=2020, author__in=["Vaswani", "LeCun"])
.search("self-attention mechanism")
.top_k(10)
.min_score(0.75)
.all()
)
# RAG context โ ready to inject into your LLM prompt
context = await Document.objects.search("transformers").top_k(5).as_context()
Features
| Feature | Description |
|---|---|
| ๐ Model Definition | Pydantic-inspired class-based models with typed fields |
| ๐ Semantic Search | Auto-embed queries, search by text or raw vector |
| ๐ Chainable Queries | Django-style QuerySet with filter, exclude, top_k, min_score |
| ๐ Filter AST | Backend-agnostic filter compilation for all 6 backends |
| ๐ Hybrid Search | Dense + sparse with Reciprocal Rank Fusion (RRF) |
| ๐ 6 Backends | Qdrant, Pinecone, Weaviate, Milvus, Chroma, pgvector |
| ๐ค 4 Embedders | OpenAI, Cohere, HuggingFace, Ollama |
| ๐ Backend Swap | Change one line in Config โ zero other changes |
| ๐ฆ Bulk Ops | Auto-batched insert_many with configurable chunk size |
| ๐งช RAG-ready | .as_context() formats results for LLM prompt injection |
| โก Async-native | Built on asyncio throughout |
| ๐ CLI | Migrations, inspect, bench tools (coming in Phase 4) |
Supported Backends
| Backend | Status | Install |
|---|---|---|
| Qdrant | ๐ง Phase 2 | pip install vectoralchemy[qdrant] |
| Chroma | ๐ง Phase 3 | pip install vectoralchemy[chroma] |
| pgvector | ๐ง Phase 3 | pip install vectoralchemy[pgvector] |
| Pinecone | ๐ง Phase 3 | pip install vectoralchemy[pinecone] |
| Weaviate | ๐ง Phase 3 | pip install vectoralchemy[weaviate] |
| Milvus | ๐ง Phase 3 | pip install vectoralchemy[milvus] |
Alpha Notice
The current release is intended for experimentation and early adopters. APIs may change without backward compatibility until the first stable release.
Installation
# Core only
pip install vectoralchemy
# With a specific backend
pip install vectoralchemy[qdrant]
pip install vectoralchemy[pinecone]
pip install vectoralchemy[chroma]
pip install vectoralchemy[pgvector]
pip install vectoralchemy[weaviate]
pip install vectoralchemy[milvus]
# With embedding provider
pip install vectoralchemy[qdrant,openai]
pip install vectoralchemy[qdrant,huggingface]
# Everything
pip install vectoralchemy[all]
Quick Start
1. Configure
from vectoralchemy import configure
configure(
default_backend = "qdrant",
backend_url = "http://localhost:6333",
default_embedder = "openai/text-embedding-3-small",
embedding_api_key = "sk-...",
)
Or via environment variables:
VECTORALCHEMY_BACKEND=qdrant
VECTORALCHEMY_BACKEND_URL=http://localhost:6333
VECTORALCHEMY_EMBEDDER=openai/text-embedding-3-small
OPENAI_API_KEY=sk-...
2. Define a Model
from vectoralchemy import VectorModel, VectorField, TextField
class BlogPost(VectorModel):
class Config:
backend = "qdrant"
collection = "blog_posts"
embedder = "openai/text-embedding-3-small"
embed_field = "body"
title: str
body: str = TextField(embed=True)
author: str
category: str
views: int
embedding: list[float] = VectorField(dims=1536)
3. Insert Data
post = BlogPost(
title="Understanding Transformers",
body="The transformer architecture revolutionized NLP...",
author="Alice",
category="AI",
views=1500,
)
await post.save()
# Bulk insert
await BlogPost.insert_many([post1, post2, post3, ...])
4. Search & Filter
# Simple semantic search
results = await BlogPost.search("attention mechanism", top_k=5)
# With filters
results = await (
BlogPost.objects
.filter(category="AI")
.filter(views__gte=1000)
.search("neural networks")
.top_k(10)
.all()
)
# Exclude
results = await BlogPost.objects.exclude(author="Anonymous").search("LLMs").all()
# Hybrid search (dense + sparse)
results = await (
BlogPost.objects
.hybrid_search("BERT pretraining", alpha=0.7)
.top_k(10)
.all()
)
5. RAG Integration
question = "How do transformers handle long sequences?"
# Retrieve relevant context
context = await (
BlogPost.objects
.filter(category="AI")
.search(question)
.top_k(5)
.as_context()
)
# Inject into your LLM prompt
prompt = f"""Answer the question based on the context below.
Context:
{context}
Question: {question}
Answer:"""
Filter Operators
VectorAlchemy uses Django-style double-underscore lookup syntax:
.filter(year=2020) # exact match (implicit __eq)
.filter(year__eq=2020) # explicit equal
.filter(year__ne=2020) # not equal
.filter(year__gt=2020) # greater than
.filter(year__gte=2020) # greater than or equal
.filter(year__lt=2023) # less than
.filter(year__lte=2023) # less than or equal
.filter(author__in=["A", "B"]) # value in list
.filter(author__nin=["X"]) # value not in list
.filter(tags__contains="nlp") # list/string contains
.filter(title__startswith="Att")# string starts with
.filter(title__endswith=".pdf") # string ends with
.filter(abstract__exists=True) # field exists / not null
.filter(year__range=[2018,2023]) # between (inclusive)
Multiple filters are AND-ed by default:
.filter(year__gte=2020).filter(author="Vaswani")
# โ year >= 2020 AND author == "Vaswani"
Switching Backends
The only change needed is in your model's Config:
class Document(VectorModel):
class Config:
backend = "chroma" # โ change this line only
# ...rest stays the same
| Environment | Backend |
|---|---|
| Local development | chroma (no auth, in-memory option) |
| Staging | qdrant (self-hosted Docker) |
| Production | pinecone or weaviate (managed cloud) |
| Existing PostgreSQL stack | pgvector |
Architecture
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ VectorAlchemy ORM โ
โโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโค
โ Model Layer โ Query Layer โ Embedding Layer โ
โ VectorModel โ QuerySet โ OpenAI โ
โ VectorField โ FilterParser โ Cohere โ
โ TextField โ Filter AST โ HuggingFace โ
โ ModelRegistry โ QueryExecutor โ Ollama โ
โโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโค
โ Adapter Layer โ
โ BaseAdapter โ compile_filter() โ backend native format โ
โโโโโโโโโโฌโโโโโโโโโโโฌโโโโโโโโโฌโโโโโโโโโฌโโโโโโโโโฌโโโโโโโโโโโค
โ Qdrant โ Pinecone โWeaviateโ Milvus โ Chroma โ pgvector โ
โโโโโโโโโโดโโโโโโโโโโโดโโโโโโโโโดโโโโโโโโโดโโโโโโโโโดโโโโโโโโโโโ
Roadmap
- Phase 1 โ Core architecture (model, fields, filter AST, adapter interface)
- Phase 2 โ Qdrant adapter + OpenAI embeddings (full end-to-end MVP)
- Phase 3 โ Chroma, pgvector, Pinecone, Weaviate, Milvus adapters
- Phase 4 โ Hybrid search, migrations CLI, batch ops, embedding cache
- Phase 5 โ Docs site, PyPI release, community launch
Coming Soon
- SQLAlchemy-style declarative models
- Async QuerySet API
- Automatic embedding generation
- Hybrid dense + sparse retrieval
- Backend-agnostic filter compiler
- Multi-backend support
- CLI tools
- Migrations
- Comprehensive documentation
Contributing
We welcome contributions! See CONTRIBUTING.md for guidelines.
git clone https://github.com/tasmimul-huda/VectorAlchemy.git
cd vectoralchemy
pip install -e ".[dev]"
pytest
License
MIT โ see LICENSE.
Built for the LLM era. Inspired by SQLAlchemy. Powered by community.
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 vectoralchemy-0.0.1a2.tar.gz.
File metadata
- Download URL: vectoralchemy-0.0.1a2.tar.gz
- Upload date:
- Size: 67.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
babc86654f3af1b47c41db7f01ba4c286686a6665bd7dd311bbd1b7b48ed9417
|
|
| MD5 |
a27a5b3efa249dedb35bd554e129ef1e
|
|
| BLAKE2b-256 |
562f91cefad3a80077ff319b8dc36619e01e734b33319a81712caee9768f9e82
|
Provenance
The following attestation bundles were made for vectoralchemy-0.0.1a2.tar.gz:
Publisher:
publish.yml on tasmimul-huda/VectorAlchemy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
vectoralchemy-0.0.1a2.tar.gz -
Subject digest:
babc86654f3af1b47c41db7f01ba4c286686a6665bd7dd311bbd1b7b48ed9417 - Sigstore transparency entry: 2190580134
- Sigstore integration time:
-
Permalink:
tasmimul-huda/VectorAlchemy@5a6e86805a59151172d843673282cd28a0ec7b2a -
Branch / Tag:
refs/tags/v0.0.1a2 - Owner: https://github.com/tasmimul-huda
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5a6e86805a59151172d843673282cd28a0ec7b2a -
Trigger Event:
release
-
Statement type:
File details
Details for the file vectoralchemy-0.0.1a2-py3-none-any.whl.
File metadata
- Download URL: vectoralchemy-0.0.1a2-py3-none-any.whl
- Upload date:
- Size: 83.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
80d4c871e183e0d77d951cb840b4c50a8e9300bdd94a9488c3cd85f96dca126a
|
|
| MD5 |
b0640bcbff60c97d23b3f212bc23d88e
|
|
| BLAKE2b-256 |
239bbb9f2668c4b37389d65229e8ad64b17ebd5b86e43f81c703bda8529e8836
|
Provenance
The following attestation bundles were made for vectoralchemy-0.0.1a2-py3-none-any.whl:
Publisher:
publish.yml on tasmimul-huda/VectorAlchemy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
vectoralchemy-0.0.1a2-py3-none-any.whl -
Subject digest:
80d4c871e183e0d77d951cb840b4c50a8e9300bdd94a9488c3cd85f96dca126a - Sigstore transparency entry: 2190580168
- Sigstore integration time:
-
Permalink:
tasmimul-huda/VectorAlchemy@5a6e86805a59151172d843673282cd28a0ec7b2a -
Branch / Tag:
refs/tags/v0.0.1a2 - Owner: https://github.com/tasmimul-huda
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5a6e86805a59151172d843673282cd28a0ec7b2a -
Trigger Event:
release
-
Statement type: