OptionScoringModel mixin base

Mixed into an InferenceModel whose engine can score options, which is what InferenceModel.createDecider needs. Exported for engines (package:flutter_edge_ai/engine.dart); an app never calls it.

A base mixin, so that a member added in a later release can arrive with a default body instead of breaking every engine.

Experimental: may change in a minor release while the API settles.

Superclass constraints
  1. @experimental

Properties

activeAudioBackend → PreferredBackend?
Backend the audio encoder runs on, or null when the model was created without audio or the engine does not say; see activeVisionBackend.
no setterinherited
activeBackend → PreferredBackend?
Backend that the runtime initialized for this model, when known.
no setterinherited
activeVisionBackend → PreferredBackend?
Backend the vision encoder runs on, or null when the model was created without vision, has no vision encoder, or the engine does not say. The native LiteRT-LM engine reports it, including what it chose for an unset preferredVisionBackend (from the model file: a declared backend_constraint, the NPU for an encoder compiled for one, else the CPU).
no setterinherited
chat ↔ InferenceChat?
getter/setter pairinherited
fileType → ModelFileType
no setterinherited
hashCode → int
The hash code for this object.
no setterinherited
isClosed → bool
Whether close has been called — true from the moment it starts, not when its teardown ends.
no setterinherited
maxTokens → int
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
session → InferenceModelSession?
The single session created via createSession. Singleton lane — each createSession call overwrites this field with a new session and closes the previous one.
no setterinherited
sessions → List<InferenceModelSession>
Live sessions owned by this model — union of the legacy session (if any) and every active openSession result. Returns an unmodifiable view; mutate via openSession, session.close(), or close.
no setterinherited

Methods

addCloseListener(void listener()) → void
Register a callback fired once when this model is closed. The lifecycle OWNER (core) uses this to reset its singleton bookkeeping for models built by an engine package. Concrete models satisfy this via CloseNotifier.
inherited
close() → Future<void>
inherited
createChat({double? temperature, int? randomSeed, int? topK, double? topP, int tokenBuffer = 256, String? loraPath, bool? supportImage, bool? supportAudio, List<Tool> tools = const [], bool? supportsFunctionCalls, bool enableThinking = false, ModelType? modelType, ToolChoice toolChoice = ToolChoice.auto, int? maxFunctionBufferLength, String? systemInstruction, int? maxOutputTokens}) → Future<InferenceChat>
inherited
createDecider({required String question, required List<DeciderOption> options, required InferenceDeciderCalibration calibration, CancelToken? cancelToken}) → Future<Decider>
A decider that answers question by scoring each of options as this model's reply (DeciderMethod.optionScoring). It is meant for a model TRAINED on exactly this question and these options; calibration carries the values fitted with that training (a softmax temperature, an abstain threshold, the "none of these" option). Its answers have the shape of an embedding decider's, so an app reads them the same way: ScoreKind.logprob scores, AbstainSignalKind.topProbability as the abstain signal.
inherited
createSession({double? temperature, int? randomSeed, int? topK, double? topP, String? loraPath, bool? enableVisionModality, bool? enableAudioModality, String? systemInstruction, bool enableThinking = false, List<Tool> tools = const [], int? maxOutputTokens}) → Future<InferenceModelSession>
Creates a new InferenceModelSession for generation.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
openChat({double? temperature, int? randomSeed, int? topK, double? topP, int tokenBuffer = 256, String? loraPath, bool? supportImage, bool? supportAudio, List<Tool> tools = const [], bool? supportsFunctionCalls, bool enableThinking = false, ModelType? modelType, ToolChoice toolChoice = ToolChoice.auto, int? maxFunctionBufferLength, String? systemInstruction, int? maxOutputTokens}) → Future<InferenceChat>
Same as createChat, but uses openSession internally so the resulting chat owns an independent session that does not touch the legacy session field or other open chats. Use this when you need concurrent chats on a single loaded model.
inherited
openOptionScorer() → Future<OptionScorer>
The engine's scoring calls, for one decider. Fails with DeciderUnsupportedException when this model cannot score here — a backend option scoring is not measured on, for one — and with StateError when the model is closed.
openSession({double? temperature, int? randomSeed, int? topK, double? topP, String? loraPath, bool? enableVisionModality, bool? enableAudioModality, String? systemInstruction, bool enableThinking = false, List<Tool> tools = const [], int? maxOutputTokens}) → Future<InferenceModelSession>
Opens a new session detached from session. Each call returns a fresh independent session sharing the loaded model weights but with isolated context (history / KV cache). Use this for concurrent dialogues on a single loaded model.
inherited
readDecisionSection() → Future<String?>
The decision the model file was trained for: the UTF-8 JSON payload litetune writes into it (decision contract version 1), however the engine's container carries it — a litetune.decision section in a .litertlm. Null when the file carries none: it is an ordinary chat model, and createDecider refuses it.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited