pub struct IntentClassifier { /* private fields */ }Expand description
Intent classifier using an ONNX model (all-MiniLM-L6-v2 or DistilBERT).
Implementations§
Source§impl IntentClassifier
impl IntentClassifier
Sourcepub fn load(
model_dir: &Path,
allow_unverified: bool,
trust_mode: TrustMode,
) -> Result<Self, ClassifierError>
pub fn load( model_dir: &Path, allow_unverified: bool, trust_mode: TrustMode, ) -> Result<Self, ClassifierError>
Load classifier from model directory.
Expected directory structure:
model_dir/
├── intent_classifier.onnx
├── tokenizer.json
├── config.json
├── calibration.json or temperature.json (optional)
├── checksums.json
└── version.txt§Arguments
model_dir— Resolved model directory (output of NL02 resolver chain).allow_unverified— Operator escape hatch. Whenfalse(NL04 default per FR-7), missingness is fatal. Whentrue, missingness downgrades totracing::warn!. Tampering on a present file ALWAYS errors regardless of this flag — see the inline contract documented at [verify_integrity].trust_mode— Output of [TrustMode::from(ResolverLevel)]. Trusted mode anchors integrity in the binary’s baked-in manifest; Custom mode trusts the user-suppliedmanifest.jsonshipped alongside the model directory.
§Errors
Returns ClassifierError if:
- Model files not found
- Checksum verification fails (AC-11.8 / NL04 integrity contract)
- ONNX Runtime initialization fails
Sourcepub fn classify(
&mut self,
input: &str,
) -> Result<ClassificationResult, ClassifierError>
pub fn classify( &mut self, input: &str, ) -> Result<ClassificationResult, ClassifierError>
Classify intent from natural language input.
§Critical: batch_size=1 enforcement (C1 mitigation)
ONNX Runtime may crash with batch_size > 1. This method
always processes exactly one input.
§Errors
Returns ClassifierError if tokenization or inference fails.
§Note
This method requires &mut self due to ort 2.0 API requirements.
Use a Mutex wrapper if concurrent access is needed.
Sourcepub fn model_version(&self) -> &str
pub fn model_version(&self) -> &str
Get the model version.
Auto Trait Implementations§
impl !Freeze for IntentClassifier
impl !RefUnwindSafe for IntentClassifier
impl Send for IntentClassifier
impl Sync for IntentClassifier
impl Unpin for IntentClassifier
impl UnsafeUnpin for IntentClassifier
impl !UnwindSafe for IntentClassifier
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more