@metreeca/llms
    Preparing search index...

    Function compress

    • Compresses a vector to a compact textual form.

      Trades precision for size, quantising components to 16-bit integers and encoding them as base64 text: storage shrinks by roughly 75% compared to a JSON array, at a loss negligible for similarity ranking. Components must lie in the [-1, 1] range, as they do in a normalised vector: values outside it are rejected rather than silently wrapped around by the conversion.

      Parameters

      • vector: Vector

        The vector to compress

      Returns string

      The compact textual form of vector, to be restored by decompress

      RangeError If vector carries a non-finite component or a component outside the [-1, 1] range