# `Sting.Similarity`
[🔗](https://github.com/dkuku/sting/blob/v0.1.0/lib/sting/similarity.ex#L1)

Vector similarity and distance functions mirroring `sentence_transformers.util`.

# `cos_sim`

Computes the cosine similarity matrix between two 1D or 2D tensors.

Returns a matrix of shape `{num_a, num_b}` where `result[i, j]` is the cosine
similarity between `a[i]` and `b[j]`.

# `dot_score`

Computes the dot product similarity matrix between two 1D or 2D tensors.

Returns a matrix of shape `{num_a, num_b}` where `result[i, j]` is the dot
product between `a[i]` and `b[j]`.

# `euclidean_sim`

Computes the Euclidean similarity matrix between two tensors.
Returns negative Euclidean distance `-dist(a[i], b[j])` so higher values indicate closer vectors.

# `manhattan_sim`

Computes the Manhattan (L1) similarity matrix between two tensors.
Returns negative Manhattan distance `-dist(a[i], b[j])` so higher values indicate closer vectors.

# `pairwise_angle_sim`

Computes the absolute normalized angle distance between pairs of tensors `x[i]` and `y[i]`.

Matches `sentence_transformers.util.pairwise_angle_sim`.

# `pairwise_cos_sim`

Computes the pairwise cosine similarity `cos_sim(a[i], b[i])`.

# `pairwise_dot_score`

Computes the pairwise dot product `dot_score(a[i], b[i])`.

# `pairwise_euclidean_sim`

Computes the pairwise Euclidean similarity `-dist(a[i], b[i])`.

# `pairwise_manhattan_sim`

Computes the pairwise Manhattan similarity `-dist(a[i], b[i])`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
