MarkLogic 12 EA 1 Product Documentation
vec:vector

vec:vector(
   $values as xs:anyAtomicType
) as vec:vector

Summary

Returns a vector value.

Parameters
$values The value(s) to create the vector from. Can be a sequence or json:array of integer or floating-point numbers. Also accepts a string that has the format of a JSON array of Numbers. Also accepts a string that was created by vec:base64-encode().

Example

  xquery version "1.0-ml";

  vec:vector((3.14, 1.59, 2.65))

  => (A vector value representing the constructed vector)
  [ 3.14, 1.59, 2.65 ]

Example

  xquery version "1.0-ml";
  (: string representation :)
  vec:vector('[3.14, 1.59, 2.65]')

  => (A vector value representing the constructed vector)
  [ 3.14, 1.59, 2.65 ]

Example


  (: There exists a JSON document 'pronethalol.json' in the database
     that contains a vector generated by a classifier model.
     'pronethalol.json' looks like this:
     {
        "object": "list",
        "data": [
        {
          "object": "embedding",
          "index": 0,
          "embedding": [
            -0.03508576,
            -0.011583557,
            ...,
            -0.009329922,
            0.0031751299,
            -0.03169545
            ]
        }]
      }
  :)
  xquery version "1.0-ml";

  vec:vector(fn:doc('pronethalol.json')//array-node('embedding'));

  => (A vector value representing the vector constructed by a JSON array node)
  [ -0.0350858, -0.0115836, 0.0111236, -0.0191592, ..., -0.0121749, -0.00932992, 0.00317513, -0.0316955 ]
Powered by MarkLogic Server | Terms of Use | Privacy Policy