create static method
Future<FutoSwipeEngine>
create({
- required FutoSwipeOnnxBackend backend,
- required List<
String> vocabulary, - required Map<
String, dynamic> scoring, - required List<
FutoSwipeWord> lexicon, - required bool includeModelVocabulary,
- required int beamWidth,
Implementation
static Future<FutoSwipeEngine> create({
required FutoSwipeOnnxBackend backend,
required List<String> vocabulary,
required Map<String, dynamic> scoring,
required List<FutoSwipeWord> lexicon,
required bool includeModelVocabulary,
required int beamWidth,
}) async {
if (vocabulary.length != futoContextVocabularySize) {
throw FormatException(
'FUTO vocabulary has ${vocabulary.length} words; '
'expected $futoContextVocabularySize',
);
}
final engine = FutoSwipeEngine._(
backend: backend,
vocabulary: List<String>.unmodifiable(vocabulary),
decoderWeights: FutoScoringWeights.fromJson(scoring, _decoderScoringKey),
contextWeights: FutoScoringWeights.fromJson(scoring, _contextScoringKey),
embeddings: await backend.loadEmbeddings(),
beamWidth: beamWidth,
);
engine.setLexicon(lexicon, includeModelVocabulary: includeModelVocabulary);
return engine;
}