
vec.base64Encode( vector1 as vec.vector ) as String
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. |
const vec1 = vec.vector([3.14,1.59,2.65]) vec.base64Encode(vec1) => kuF6JKCPwuUfzcwUIAAAAA==
const vec1 = vec.vector(xdmp.toJSON(fn.doc('pronethalol.json')).xpath('/data/array-node{embedding}'))
String(vec.base64Encode(vec1).length).concat(" VS ").concat(String(vec1).length);
=> 8220 VS 18231
// This function compressed the string representation of the 1536 dimensional float vector
// in 'pronethalol.json' at array node 'embedding'
// from 18231 characters to 8220 characters.
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.