Skip to main content

Similarity engine utils

Project description

similarity-engine-utils

Utility tools for easier management of feature-vector database and similar vector comparison

Installation


Use the package manager pip to install library.

pip install similarity-engine-utils

Setup backend connection (milvus)


from se_utils.backend.milvus.core import setup_connection
milvus_credentials = {
    "alias": "default",
    "host": "localhost",
    "port": "19530"
}
collection_name = 'test_collection'

c = setup_connection(milvus_credentials)

Create collection


from se_utils.backend.milvus.core import create_milvus_collection, generate_schema, read_schema_json

collection_name = 'test_collection'

schema_path = "/path/to/schema.json"
tag = "some_tag"

# existing tag
collection1 = create_milvus_collection(collection_name, tag=tag)

# parse json schema
collection_schema, index_params = generate_schema(tag=tag, 
                                                  schema=read_schema_json(schema_path))
collection2 = create_milvus_collection(collection_name, 
                                       schema=collection_schema, 
                                       indices=index_params)

Insert data to collection


from se_utils.backend.milvus.core import insert2milvus

collection_name = 'test_collection'
kwargs = {
    "id": 1,
    "name": "name",
    "emb": [1,1,1,1]
}

insert2milvus(data=[kwargs], 
              collection_name=collection_name)

Find the closest cluster id


import numpy as np
from se_utils.backend.milvus.core import get_cluster_id, get_increment_cluster_id

collection_name = 'test_collection'
emb_label = 'emb'
emb = [np.random.uniform(low=-1, high=1, size=(1024,)).tolist() 
       for _ in range(1)][0]
cluster_label = 'group_id'

cluster_id = get_cluster_id(collection_name=collection_name, 
                            emb=emb, 
                            emb_label=emb_label, 
                            cluster_label=cluster_label)

if cluster_id is None:
    cluster_id = get_increment_cluster_id(collection_name=collection_name, 
                                          cluster_label=cluster_label)

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

similarity-engine-utils-0.1.1.tar.gz (9.5 kB view details)

Uploaded Source

Built Distribution

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

similarity_engine_utils-0.1.1-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file similarity-engine-utils-0.1.1.tar.gz.

File metadata

  • Download URL: similarity-engine-utils-0.1.1.tar.gz
  • Upload date:
  • Size: 9.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for similarity-engine-utils-0.1.1.tar.gz
Algorithm Hash digest
SHA256 da87809b3c53039744fb6e9cce5b110c21b46e69adc64cf52c60fb1d7c09032d
MD5 274566c42220a0aceefba925cad9565e
BLAKE2b-256 358135df59baad226c9094dab687c696370d179c68a55b0420ebad4f287d2355

See more details on using hashes here.

File details

Details for the file similarity_engine_utils-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for similarity_engine_utils-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 de4a7d948740d6cd74bb3f54dabbec1c5772fb13b4fa9a5caff38ea433e2bff1
MD5 86aebc2541e29e09357f1f3c1b0b3b22
BLAKE2b-256 5ebf1d4219c5064850f58583d03317a5f75252f1f4d07083d732ed2a73c98090

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