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.2.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.2-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: similarity-engine-utils-0.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 b3954c36c4c9762478847ce441af6e834243373286aec10573ec23bb4ab26703
MD5 54bc38b32c3d93e3b01b1d7c0532b843
BLAKE2b-256 aaafaad49d03ce1893103bfca13abe1e80c81a4b79294b23bde4d532eff155a0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for similarity_engine_utils-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3a6aaa4f88841560f66e9b52f7fe7296709f2a05a3ac5eee4ae925e833e655d0
MD5 a9a3d7bf8c077442249f82e07f56ff53
BLAKE2b-256 bac61c6fbbd378ab6359f47b47e9084b838f5f42888e59c18bcb47fbb6973f6b

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