pub trait NlpModel: ModelInfo {
// Required methods
fn analyze<'life0, 'life1, 'async_trait>(
&'life0 self,
requests: Vec<NlpRequest<'life1>>,
) -> Pin<Box<dyn Future<Output = Result<Vec<NlpResult>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn supported_tasks(&self) -> NlpTasks;
// Provided methods
fn label_maps(&self) -> Option<&NlpLabelMaps> { ... }
fn warmup<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: Sync + 'async_trait,
'life0: 'async_trait { ... }
}Expand description
A multi-head structured-NLP model.
§Canonical default model
The reference implementation is
dragonscale-ai/kniv-deberta-nlp-base-en-xsmall:
a DeBERTa-v3-xsmall multi-head cascade producing POS / NER / DEP / SRL / CLS
in a single forward pass. It will ship as the canonical nlp/default
catalog alias once the local/onnx provider gains an NlpModel
implementation in a follow-up release.
Tagsets used by the reference model:
- POS: Universal Dependencies English EWT (17 classes)
- NER: OntoNotes (18 entity types)
- DEP: Universal Dependencies English EWT
- SRL: PropBank (42 classes)
- CLS: 8 dialog acts (internal dataset)
Language: English only. Maximum input: 128 tokens — provider-side chunking is the implementation’s responsibility; the trait contract keeps token offsets stable in whole-document UTF-8 byte coordinates regardless of internal chunking.
Required Methods§
Sourcefn analyze<'life0, 'life1, 'async_trait>(
&'life0 self,
requests: Vec<NlpRequest<'life1>>,
) -> Pin<Box<dyn Future<Output = Result<Vec<NlpResult>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn analyze<'life0, 'life1, 'async_trait>(
&'life0 self,
requests: Vec<NlpRequest<'life1>>,
) -> Pin<Box<dyn Future<Output = Result<Vec<NlpResult>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Analyze a batch of texts, returning one NlpResult per request.
§Errors
Returns an error if a requested task is not in
supported_tasks, or if the provider
fails internally.
Sourcefn supported_tasks(&self) -> NlpTasks
fn supported_tasks(&self) -> NlpTasks
Heads this model can populate. Callers may request a subset via
NlpRequest::tasks.
Provided Methods§
Sourcefn label_maps(&self) -> Option<&NlpLabelMaps>
fn label_maps(&self) -> Option<&NlpLabelMaps>
The label vocabularies this model decodes against, if it exposes them.
Returns Some for models with a fixed, introspectable label set (e.g.
the ONNX cascade), letting callers map labels to class ids and read
SpeechAct::scores against NlpLabelMaps::cls. The default is
None for models that do not expose vocabularies (e.g. remote or mock).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".