create static method

Future<CommonEmbeddingModel> create({
  1. required ForwardPassDescriptor descriptor,
  2. required String tokenizerPath,
  3. VoidCallback? onClose,
})

Build an EmbeddingForwardPass from descriptor on a background isolate and prepare it for inference.

tokenizerPath points at the matching SentencePiece .model or exported .json for descriptor's model.

Caller owns the returned instance and must call close when done.

Implementation

static Future<CommonEmbeddingModel> create({
  required ForwardPassDescriptor descriptor,
  required String tokenizerPath,
  VoidCallback? onClose,
}) async {
  final worker = await EmbeddingWorker.spawn(
    descriptor: descriptor,
    tokenizerPath: tokenizerPath,
  );
  return CommonEmbeddingModel._(worker, onClose ?? () {});
}