Skip to main content

QUICK START

  1. Install Packge

pip install AlayaDB
  1. Import Dataset

from AlayaDataset import *
data = VECS(base_fname='/data/cohere-768-euclidean/cohere-768-euclidean_base.fvecs',
            query_fname='/data/cohere-768-euclidean/cohere-768-euclidean_query.fvecs',
            gt_fname='/data/cohere-768-euclidean/cohere-768-euclidean_gti.ivecs',
            metric='L2')

 data = HDF5(file_path='/data/cohere-768-euclidean.hdf5',
             metric='L2')

data = NPARRAY(database=database, query=query, gt=gt, metric='L2')
  1. Create Alaya Instance

from AlayaDB import Alaya
alaya = Alaya(data.database,        # dataset
            index_type=Alaya.HNSW   # index type
            )
  1. search

# normal search
alaya.search(query=data.query)

# search with trace
alaya.search(query=data.query, is_trace=True, save_json_dir='data/jsons')

API

alayapy.Alaya

STATIC VARIABLES

# graph type
MERGRAPH = "MERGRAPH"
HNSW = "HNSW"
NSG = "NSG"

# Methods for distance calculation
L2 = "L2"   # Euclidean distance
IP = "IP"   # Angle calculation
EUCLIDEAN = "L2"
ANGULAR = "IP"

Alaya.HNSW

__init__

def __init__(self,
            database: np.array,
            index_type: str=MERGRAPH,
            metric: str=L2,
            M: int=32,
            L: int=300,
            level: int=3,
            optimizer: int=os.cpu_count(),
            num_threads: int=os.cpu_count(),
            index_cache_dir: str="data/alaya_index",
            is_cache_index: bool=True,
            is_rebuild: bool=False
            ):

  """
  Args:
    database(np.array): 数据集, shape(n, dim)
    index_type(str): 索引类型, default=MERGRAPH
    metric(str): 距离度量, default=L2
    M(int): MERGRAPH的M参数, default=32
    L(int): MERGRAPH的L参数, default=300
    level(int): MERGRAPH的level参数, default=3
    optimizer(int): 调用优化器的线程数, default=os.cpu_count()
    num_threads(int): search时使用的线程数, default=os.cpu_count()
    index_cache_dir(str): 索引缓存目录, default="data/alaya_index"
    is_cache_index(bool): 是否缓存索引, default=True
    is_rebuild(bool): 是否重新构建索引, default=False

  Returns:
    None
  """
  1. call alaya = Alaya(dataset=dataset, index_type=index_type) will create graph and save in ./data/index_index/

  2. The name of the saved graph created isf'Alaya-{self.index_type}-{self.metric}-{self.M}-{self.__gene_md5()}', e.g. Alaya-HNSW-L2-32-55ee368c93392e849c40de551b62fdb2

  3. If you want to change the saved path, use index_cache_dir='/you/save/path'

  4. If you don’t want to save the graph, use is_cache_index=False

  5. If the graph is rebuilt regardless of whether it is cached or not, useis_rebuild=True

Release files for AlayaDB 1.4.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for AlayaDB 1.4.6
File Interpreter ABI Platform
AlayaDB-1.4.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.17+ x86-64 Details

Release files / AlayaDB-1.4.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL AlayaDB-1.4.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 3.2 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
cd7eb1e61cec0f4616f99e5cdd91a5511915244e890bf8c5803c510f2be5ef9e
BLAKE2b-256 checksum
How to use checksums
4e430f876e67c43b933afc55d59ce86ed31a993ea1d7398c6bd5e76d1973b6d8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.15

Release history Release notifications | RSS feed

This release

1.4.6 This release

1 release file

1.4.4

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page