pub struct LinearChainCRF {
pub n_labels: usize,
pub n_features: usize,
pub max_iter: usize,
pub learning_rate: f32,
pub l2_penalty: f32,
pub tol: f32,
/* private fields */
}Expand description
Linear-chain Conditional Random Field
Used for sequence labeling tasks like:
- Named Entity Recognition (NER)
- Part-of-Speech (POS) tagging
- Chunking
- Segmentation
Fields§
§n_labels: usize§n_features: usize§max_iter: usize§learning_rate: f32§l2_penalty: f32§tol: f32Implementations§
Source§impl LinearChainCRF
impl LinearChainCRF
pub fn new(n_labels: usize, n_features: usize) -> Self
pub fn max_iter(self, iter: usize) -> Self
pub fn learning_rate(self, lr: f32) -> Self
pub fn l2_penalty(self, penalty: f32) -> Self
Sourcepub fn fit(&mut self, sequences: &[Tensor], labels: &[Tensor])
pub fn fit(&mut self, sequences: &[Tensor], labels: &[Tensor])
Fit the CRF using stochastic gradient descent
Sourcepub fn predict(&self, sequence: &Tensor) -> Tensor
pub fn predict(&self, sequence: &Tensor) -> Tensor
Predict label sequence using Viterbi algorithm
Sourcepub fn predict_marginals(&self, sequence: &Tensor) -> Tensor
pub fn predict_marginals(&self, sequence: &Tensor) -> Tensor
Predict marginal probabilities for each position
Auto Trait Implementations§
impl Freeze for LinearChainCRF
impl RefUnwindSafe for LinearChainCRF
impl Send for LinearChainCRF
impl Sync for LinearChainCRF
impl Unpin for LinearChainCRF
impl UnwindSafe for LinearChainCRF
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> 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