MCPcopy Index your code
hub / github.com/tensorflow/tfjs-examples / classify

Function classify

intent-classifier/app/index.js:51–68  ·  view source on GitHub ↗
(sentences)

Source from the content-addressed store, hash-verified

49}
50
51async function classify(sentences) {
52 const [use, intent, metadata] = await Promise.all(
53 [loadUSE(), loadIntentClassifer(DENSE_MODEL_URL), loadMetadata()]);
54
55 const {labels} = metadata;
56 const activations = await use.embed(sentences);
57
58 const prediction = intent.predict(activations);
59
60 const predsArr = await prediction.array();
61 const preview = [predsArr[0].slice()];
62 preview.unshift(labels);
63 console.table(preview);
64
65 tf.dispose([activations, prediction]);
66
67 return predsArr[0];
68}
69
70const THRESHOLD = 0.90;
71async function getClassificationMessage(softmaxArr) {

Callers 2

onSendMessageFunction · 0.85
warmupFunction · 0.85

Calls 4

loadIntentClassiferFunction · 0.85
loadUSEFunction · 0.70
loadMetadataFunction · 0.70
predictMethod · 0.45

Tested by

no test coverage detected