#[non_exhaustive]pub struct NlpRequest<'a> {
pub text: &'a str,
pub tasks: NlpTasks,
pub turns: Option<&'a [Turn<'a>]>,
pub schema: Option<&'a ExtractionSchema>,
pub calibration: Option<&'a NlpCalibrationOverrides>,
}Expand description
One NLP analysis request: an input plus the heads to populate.
#[non_exhaustive]: build one with NlpRequest::new (or
NlpRequest::from_turns) and chain the with_* setters, so later
releases can add inputs without breaking callers.
use uni_xervo::traits::{NlpRequest, NlpTasks};
let req = NlpRequest::new("Ada Lovelace was born in London.", NlpTasks::NER);
assert_eq!(req.tasks, NlpTasks::NER);Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.text: &'a strInput prose. Borrowed so batch callers don’t have to clone.
kniv v7 splits it into paragraphs at blank lines ("\n\n"). Ignored
when turns is set.
tasks: NlpTasksWhich heads to populate. Unset flags result in empty fields on the
corresponding NlpResult entries.
turns: Option<&'a [Turn<'a>]>A conversation to analyse instead of text: one
(speaker, text) Turn per message, oldest first.
Each turn is its own unit — sentences never cross a turn — and its
speaker becomes a "speaker" entity, so relations can be anchored on
who said what. Models that do not support conversations ignore it.
schema: Option<&'a ExtractionSchema>The relations and entity types to extract, for
NlpTasks::ENTITIES / NlpTasks::FACTS.
Zero-shot: the schema is supplied per request and scored against the
whole window. None leaves facts empty and falls back to the model’s
own coarse entity types.
calibration: Option<&'a NlpCalibrationOverrides>Per-request overrides of the model’s shipped decoding thresholds.
None uses the model’s calibration.json as published, which is
what the reported quality figures were measured with.
Implementations§
Source§impl<'a> NlpRequest<'a>
impl<'a> NlpRequest<'a>
Sourcepub fn from_turns(turns: &'a [Turn<'a>], tasks: NlpTasks) -> Self
pub fn from_turns(turns: &'a [Turn<'a>], tasks: NlpTasks) -> Self
A request over conversation turns.
Sourcepub fn with_turns(self, turns: &'a [Turn<'a>]) -> Self
pub fn with_turns(self, turns: &'a [Turn<'a>]) -> Self
Attach conversation turns, which take precedence over
text.
Sourcepub fn with_schema(self, schema: &'a ExtractionSchema) -> Self
pub fn with_schema(self, schema: &'a ExtractionSchema) -> Self
Attach the extraction schema.
Sourcepub fn with_calibration(self, calibration: &'a NlpCalibrationOverrides) -> Self
pub fn with_calibration(self, calibration: &'a NlpCalibrationOverrides) -> Self
Attach calibration overrides.
Trait Implementations§
Source§impl<'a> Clone for NlpRequest<'a>
impl<'a> Clone for NlpRequest<'a>
Source§fn clone(&self) -> NlpRequest<'a>
fn clone(&self) -> NlpRequest<'a>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl<'a> Freeze for NlpRequest<'a>
impl<'a> RefUnwindSafe for NlpRequest<'a>
impl<'a> Send for NlpRequest<'a>
impl<'a> Sync for NlpRequest<'a>
impl<'a> Unpin for NlpRequest<'a>
impl<'a> UnsafeUnpin for NlpRequest<'a>
impl<'a> UnwindSafe for NlpRequest<'a>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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> ⓘ
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> ⓘ
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