Vettore.MultiVector (Vettore v0.3.2)

Copy Markdown View Source

Multi-vector scoring helpers.

Summary

Functions

Computes Chamfer/MaxSim similarity.

Computes a ColBERT-style late interaction score.

Types

metric()

@type metric() :: Vettore.Distance.metric() | atom()

vector()

@type vector() :: [number()]

Functions

chamfer(query_vectors, document_vectors, opts \\ [])

@spec chamfer([vector()], [vector()], keyword()) :: {:ok, float()} | {:error, term()}

Computes Chamfer/MaxSim similarity.

For each query vector, this finds the best matching document vector and sums those best scores.

Examples

iex> Vettore.MultiVector.chamfer(
...>   [[1.0, 0.0], [0.0, 1.0]],
...>   [[1.0, 0.0], [1.0, 1.0]],
...>   metric: :inner_product
...> )
{:ok, 2.0}

colbert_score(query_vectors, document_vectors, opts \\ [])

@spec colbert_score([vector()], [vector()], keyword()) ::
  {:ok, float()} | {:error, term()}

Computes a ColBERT-style late interaction score.

This is an explicit alias for Chamfer/MaxSim scoring: each query vector takes its best match from the document vectors, then the best-match scores are summed.

Examples

iex> Vettore.MultiVector.colbert_score(
...>   [[1.0, 0.0], [0.0, 1.0]],
...>   [[1.0, 0.0], [0.0, 1.0], [-1.0, 0.0]],
...>   metric: :inner_product
...> )
{:ok, 2.0}