Shortcuts

qdrant_client.local.distances module

class ContextPair(positive: List[float], negative: List[float])[source]

Bases: object

class ContextQuery(context_pairs: List[ContextPair])[source]

Bases: object

class DiscoveryQuery(target: List[float], context: List[ContextPair])[source]

Bases: object

class DistanceOrder(value)[source]

Bases: str, Enum

An enumeration.

BIGGER_IS_BETTER = 'bigger_is_better'
SMALLER_IS_BETTER = 'smaller_is_better'
class RecoQuery(positive: Optional[List[List[float]]] = None, negative: Optional[List[List[float]]] = None)[source]

Bases: object

calculate_context_scores(query: ContextQuery, vectors: ndarray[Any, dtype[Union[bool_, int8, int16, int32, int64, uint8, uint16, uint32, uint64, float16, float32, float64, float128]]], distance_type: Distance) ndarray[Any, dtype[Union[bool_, int8, int16, int32, int64, uint8, uint16, uint32, uint64, float16, float32, float64, float128]]][source]
calculate_discovery_ranks(context: List[ContextPair], vectors: ndarray[Any, dtype[Union[bool_, int8, int16, int32, int64, uint8, uint16, uint32, uint64, float16, float32, float64, float128]]], distance_type: Distance) ndarray[Any, dtype[Union[bool_, int8, int16, int32, int64, uint8, uint16, uint32, uint64, float16, float32, float64, float128]]][source]
calculate_discovery_scores(query: DiscoveryQuery, vectors: ndarray[Any, dtype[Union[bool_, int8, int16, int32, int64, uint8, uint16, uint32, uint64, float16, float32, float64, float128]]], distance_type: Distance) ndarray[Any, dtype[Union[bool_, int8, int16, int32, int64, uint8, uint16, uint32, uint64, float16, float32, float64, float128]]][source]
calculate_distance(query: ndarray[Any, dtype[Union[bool_, int8, int16, int32, int64, uint8, uint16, uint32, uint64, float16, float32, float64, float128]]], vectors: ndarray[Any, dtype[Union[bool_, int8, int16, int32, int64, uint8, uint16, uint32, uint64, float16, float32, float64, float128]]], distance_type: Distance) ndarray[Any, dtype[Union[bool_, int8, int16, int32, int64, uint8, uint16, uint32, uint64, float16, float32, float64, float128]]][source]
calculate_distance_core(query: ndarray[Any, dtype[Union[bool_, int8, int16, int32, int64, uint8, uint16, uint32, uint64, float16, float32, float64, float128]]], vectors: ndarray[Any, dtype[Union[bool_, int8, int16, int32, int64, uint8, uint16, uint32, uint64, float16, float32, float64, float128]]], distance_type: Distance) ndarray[Any, dtype[Union[bool_, int8, int16, int32, int64, uint8, uint16, uint32, uint64, float16, float32, float64, float128]]][source]

Calculate same internal distances as in core, rather than the final displayed distance

calculate_recommend_best_scores(query: RecoQuery, vectors: ndarray[Any, dtype[Union[bool_, int8, int16, int32, int64, uint8, uint16, uint32, uint64, float16, float32, float64, float128]]], distance_type: Distance) ndarray[Any, dtype[Union[bool_, int8, int16, int32, int64, uint8, uint16, uint32, uint64, float16, float32, float64, float128]]][source]
cosine_similarity(query: ndarray[Any, dtype[Union[bool_, int8, int16, int32, int64, uint8, uint16, uint32, uint64, float16, float32, float64, float128]]], vectors: ndarray[Any, dtype[Union[bool_, int8, int16, int32, int64, uint8, uint16, uint32, uint64, float16, float32, float64, float128]]]) ndarray[Any, dtype[Union[bool_, int8, int16, int32, int64, uint8, uint16, uint32, uint64, float16, float32, float64, float128]]][source]

Calculate cosine distance between query and vectors :param query: query vector :param vectors: vectors to calculate distance with

Returns

distances

distance_to_order(distance: Distance) DistanceOrder[source]

Convert distance to order :param distance: distance to convert

Returns

order

dot_product(query: ndarray[Any, dtype[Union[bool_, int8, int16, int32, int64, uint8, uint16, uint32, uint64, float16, float32, float64, float128]]], vectors: ndarray[Any, dtype[Union[bool_, int8, int16, int32, int64, uint8, uint16, uint32, uint64, float16, float32, float64, float128]]]) ndarray[Any, dtype[Union[bool_, int8, int16, int32, int64, uint8, uint16, uint32, uint64, float16, float32, float64, float128]]][source]

Calculate dot product between query and vectors :param query: query vector. :param vectors: vectors to calculate distance with

Returns

distances

euclidean_distance(query: ndarray[Any, dtype[Union[bool_, int8, int16, int32, int64, uint8, uint16, uint32, uint64, float16, float32, float64, float128]]], vectors: ndarray[Any, dtype[Union[bool_, int8, int16, int32, int64, uint8, uint16, uint32, uint64, float16, float32, float64, float128]]]) ndarray[Any, dtype[Union[bool_, int8, int16, int32, int64, uint8, uint16, uint32, uint64, float16, float32, float64, float128]]][source]

Calculate euclidean distance between query and vectors :param query: query vector. :param vectors: vectors to calculate distance with

Returns

distances

fast_sigmoid(x: float32) float32[source]
manhattan_distance(query: ndarray[Any, dtype[Union[bool_, int8, int16, int32, int64, uint8, uint16, uint32, uint64, float16, float32, float64, float128]]], vectors: ndarray[Any, dtype[Union[bool_, int8, int16, int32, int64, uint8, uint16, uint32, uint64, float16, float32, float64, float128]]]) ndarray[Any, dtype[Union[bool_, int8, int16, int32, int64, uint8, uint16, uint32, uint64, float16, float32, float64, float128]]][source]

Calculate manhattan distance between query and vectors :param query: query vector. :param vectors: vectors to calculate distance with

Returns

distances

scaled_fast_sigmoid(x: float32) float32[source]

Qdrant

Learn more about Qdrant vector search project and ecosystem

Discover Qdrant

Similarity Learning

Explore practical problem solving with Similarity Learning

Learn Similarity Learning

Community

Find people dealing with similar problems and get answers to your questions

Join Community