@metreeca/llms
    Preparing search index...

    Function cosine

    • Computes the cosine distance between two vectors.

      Cosine distance is defined as 1 - cosine similarity, where cosine similarity measures the cosine of the angle between two vectors in n-dimensional space: values range from 0 to 2, with 0 for identical direction, 1 for orthogonality and 2 for opposite directions.

      Only vectors of the same length are comparable, as components are matched by position: vectors of different length, as produced by different sources, are rejected rather than reconciled.

      Parameters

      Returns number

      The cosine distance between x and y

      RangeError If x and y have different lengths, if either carries a non-finite component, or if either has a zero norm, that is if it is empty or all its components are 0