cos_sim: Cosine similarity of two vectors

View source: R/helper.R

cos_simR Documentation

Cosine similarity of two vectors

Description

Used by the distributed-memory models (minerva2(), todam()): ⁠a . b / (||a|| ||b||)⁠. Returns 0 (rather than NaN) when either vector has zero norm, since that just means "no signal yet" for these models (e.g. an empty memory trace before any training).

Usage

cos_sim(a, b)

Arguments

a, b

Numeric vectors of the same length


XSLmodels documentation built on Oct. 18, 2026, 5:08 p.m.