1.0.1 • Published 5 years ago

qxencoder v1.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
5 years ago

qxencoder

Wrapper around tensorflowjs universal sentence encoder.

Installation

npm i qxencoder

Usage

const { encode, Encoder } = require('qxencoder');

(async () => {

  const sentences = ['Hello', 'Bye'];

  // Simple encoding
  var embeddings = await encode(sentences);
  console.log(embeddings.map(e => e.length));
  // [ 512, 512 ]

  // Encoder usage
  // Works the same as above, but only load model once so slightly faster
  var encoder = new Encoder();
  await encoder.load();
  embeddings = encoder.encode(sentences);

})();