MarkLogic 12 EA 1 Product Documentation
vec:base64-encode

vec:base64-encode(
   $vector1 as vec:vector
) as xs:string

Summary

Returns the base64 encoding of the vector. Useful for compressing a high-dimensional float vector represented as a string into fewer characters.

Parameters
vector1 The vector to base64 encode.

See Also

Example

  xquery version "1.0-ml";
  let $vec1 := vec:vector((3.14,1.59,2.65))
  return vec:base64-encode($vec1)

  => FYT6NiFJhGw=AwAAAA==AAAAAA==w/VIQB+Fyz+amSlA

Example

  xquery version "1.0-ml";
  let $vec1 := vec:vector(xdmp:to-json(fn:doc('pronethalol.json'))/data/array-node{embedding})
  return fn:string-length(vec:base64-encode($vec1)) || " VS " || fn:string-length(fn:string($vec1))

  => 8220 VS 18229
  (: This function compressed the string representation of the 1536 dimensional float vector
     in 'pronethalol.json' at array node 'embedding'
     from 18229 characters to 8220 characters.
  :)
Powered by MarkLogic Server | Terms of Use | Privacy Policy