getEmbeddingAsVector method
Implementation
@override
Future<Vector> getEmbeddingAsVector(List<int> tokens) async {
await loadFonnxWebModule('minish_lab_init.js');
final jsObject = await sbertJs(
modelPath.toJS,
Int16List.fromList(tokens).toJS,
).toDart;
if (jsObject == null) {
throw Exception('Embeddings returned from JS code are null');
}
final jsList = jsObject as JSFloat32Array;
final vector = Vector.fromList(
jsList.toDart,
dtype: DType.float32,
).normalize();
return vector;
}