Package genlayer_embeddings#

class genlayer_embeddings.Model[source]#

Bases: object

__call__(inputs: dict[str, ndarray], outputs: list[str] | None = None) dict[str, ndarray][source]#

Call self as a function.

Return type:

dict[str, ndarray]

__init__(model: str, inputs: dict[str, dtype[Any] | None | type[Any] | _SupportsDType[dtype[Any]] | str | tuple[Any, int] | tuple[Any, SupportsIndex | Sequence[SupportsIndex]] | list[Any] | _DTypeDict | tuple[Any, Any]], *, models_db=_ALL_MODELS)[source]#
genlayer_embeddings.SentenceTransformer(model: str) Callable[[str], ndarray][source]#
Return type:

Callable[[str], ndarray]

class genlayer_embeddings.VecDB[source]#

Bases: Generic

Data structure that supports storing and querying vector data

There are two entities that can act as a key:

  1. vector (can have duplicates)

  2. id (int alias, can’t have duplicates)

Warning

import numpy before from genlayer import * if you wish to use VecDB!

Element = Element#
Id = Id#
__gl_allow_storage__ = True#
__iter__()[source]#
__len__() int[source]#
Return type:

int

get_by_id(id: Id) VecDBElement[T, S, V, None][source]#
Return type:

VecDBElement[T, S, V, None]

get_by_id_or_none(id: Id) VecDBElement[T, S, V, None] | None[source]#
Return type:

VecDBElement[T, S, V, None] | None

insert(key: np.ndarray[tuple[S], np.dtype[T]], val: V) Id[source]#
Return type:

Id

knn(v: np.ndarray[tuple[S], np.dtype[T]], k: int) Iterator[VecDBElement[T, S, V, T]][source]#
Return type:

Iterator[VecDBElement[T, S, V, T]]