Skip to main content

In-memory vector store with cosine similarity search

Project description

philiprehberger-embedding-store

In-memory vector store with cosine similarity search.

Install

pip install philiprehberger-embedding-store

Usage

from philiprehberger_embedding_store import VectorStore

store = VectorStore(dimensions=1536)

# Add vectors with metadata
store.add("doc1", embedding=[0.1, 0.2, ...], metadata={"title": "First doc"})
store.add("doc2", embedding=[0.3, 0.1, ...], metadata={"title": "Second doc"})

# Search by similarity
results = store.search(query_embedding=[0.15, 0.18, ...], top_k=5)
for result in results:
    print(f"{result.id}: score={result.score:.3f}, {result.metadata}")

# Filter by metadata
results = store.search(query, top_k=10, filter=lambda m: m["category"] == "tech")

# Minimum score threshold
results = store.search(query, min_score=0.7)

# Persistence
store.save("vectors.json")
loaded = VectorStore.load("vectors.json")

# Batch operations
store.add_many([("id1", emb1, meta1), ("id2", emb2, meta2)])

API

Method Description
add(id, embedding, metadata?) Add a vector
add_many(items) Batch add
search(query, top_k?, metric?, filter?, min_score?) Similarity search
get(id) Get entry by ID
delete(id) Delete entry
update_metadata(id, metadata) Update metadata
save(path) Save to JSON
VectorStore.load(path) Load from JSON
clear() Remove all entries
ids() List all IDs

Distance Metrics

  • "cosine" (default) — cosine similarity
  • "dot" — dot product

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

philiprehberger_embedding_store-0.1.0.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file philiprehberger_embedding_store-0.1.0.tar.gz.

File metadata

File hashes

Hashes for philiprehberger_embedding_store-0.1.0.tar.gz
Algorithm Hash digest
SHA256 04022bb30742209e43b75f16a0cf783d05f66fda0e21c8140edce272cb221728
MD5 ff94d09906aaa0de7e03d107cf61ddf9
BLAKE2b-256 67b729c5cd223719e0566ea9525f587fa8bbe93c07832f444176a4798c85dfff

See more details on using hashes here.

File details

Details for the file philiprehberger_embedding_store-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for philiprehberger_embedding_store-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d85d186bd56a760d7d3ddb25b3c3034ef7dcd81789b233761472a0b5174456f6
MD5 d128baf1ca94651d0fab5d7623ab1cca
BLAKE2b-256 fdd61a33a6585b6773b061c7ce6a752a04279f46f62eb4fd5f58866bad6f40a8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page