Skip to content

Commit

Permalink
Use Markdown for README
Browse files Browse the repository at this point in the history
  • Loading branch information
jbenjoseph committed Apr 10, 2024
1 parent 04b0489 commit 3ee86f9
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 100 deletions.
94 changes: 94 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# VectorizeDB

## Overview

VectorizeDB is a Python package designed for the efficient storage and retrieval of high-dimensional vectors. It's particularly useful in applications like machine learning and information retrieval. The package utilizes hnswlib for fast approximate nearest neighbor searches and LMDB for scalable and reliable storage.

## Installation

To install VectorizeDB, ensure you have Python 3.10 or higher. It can be installed via pip:

```bash
pip install vectorizedb
```

## Usage

**Initialization**

```python
from vectorizedb import Database

# Initialize a new database
db = Database(path="path/to/db", dim=128, readonly=False, similarity="cosine")
```

**Adding Data**

```python
import numpy as np

# Add a vector with an associated key
db.add(key="sample_key", vector=np.random.rand(128))

# Add a vector with metadata
db.add(key="another_key", vector=np.random.rand(128), metadata={"info": "sample metadata"})

# Another way to add data
db["yet_another_key"] = (np.random.rand(128), {"info": "sample metadata"})
```

**Retrieving Data**

```python
# Retrieve vector and metadata by key
vector, metadata = db["sample_key"]

# Check if a key exists in the database
exists = "sample_key" in db
```

**Searching**

```python
# Search for nearest neighbors of a vector
results = db.search(vector=np.random.rand(128), k=5)
for key, vector, distance, metadata in results:
print(key, distance, metadata)
```

**Iterating Through Data**

```python
# Iterate through all keys, vectors and metadata in the database
for key, vector, metadata in db:
print(key, metadata)
```

**Updating Data**

```python
# Update a vector in the database
db.update_vector("sample_key", np.random.rand(128))

# Update metadata
db.update_metadata("sample_key", {"info": "updated metadata"})
```

**Deleting Data**

```python
# Delete a vector from the database by key
del db["sample_key"]
```

**Database Length**

```python
# Get the number of entries in the database
length = len(db)
```

## License

VectorizeDB is released under the Apache License. For more details, see the LICENSE file included in the package.
99 changes: 0 additions & 99 deletions README.rst

This file was deleted.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "1.0.0"
description = "VectorizeDB is a database for vectorized data and metadata, allowing for fast similarity search and retrieval."
authors = ["JJ Ben-Joseph <[email protected]>", "Yair Benita <[email protected]>"]
license = "Apache"
readme = "README.rst"
readme = "README.md"
homepage = "https://github.com/aion-labs/vectorizedb"
classifiers = [
"Programming Language :: Python :: 3",
Expand Down

0 comments on commit 3ee86f9

Please sign in to comment.