EmbedderBuilder

Struct EmbedderBuilder 

Source
pub struct EmbedderBuilder<D = u32, T = DefaultTokenizer> { /* private fields */ }
Expand description

A consuming builder for Embedder.

Implementations§

Source§

impl<D, T> EmbedderBuilder<D, T>

Source

pub fn with_avgdl(avgdl: f32) -> EmbedderBuilder<D, T>
where T: Default,

Constructs a new EmbedderBuilder with the given average document length. Use this if you know the average document length in advance. If you don’t, but you have your full corpus ahead of time, use with_fit_to_corpus or with_tokenizer_and_fit_to_corpus instead.

If you have neither the full corpus nor a sample of it, you can configure the embedder to disregard document length by setting b to 0.0. In this case, it doesn’t matter what value you pass to with_avgdl.

The average document length is the average number of tokens in a document from your corpus; if you need access to this value, you can construct an Embedder and call avgdl on it.

Source

pub fn with_tokenizer_and_fit_to_corpus( tokenizer: T, corpus: &[&str], ) -> EmbedderBuilder<D, T>
where T: Tokenizer + Sync,

Constructs a new EmbedderBuilder with its average document length fit to the given corpus. Use this if you have the full corpus (or a sample of it) available in advance. The embedder will assume the given tokenizer. Use the parallelism feature to speed the fitting process up for large corpora.

Source

pub fn k1(self, k1: f32) -> EmbedderBuilder<D, T>

Sets the k1 parameter for the embedder. The default value is 1.2.

Source

pub fn b(self, b: f32) -> EmbedderBuilder<D, T>

Sets the b parameter for the embedder. The default value is 0.75.

Source

pub fn avgdl(self, avgdl: f32) -> EmbedderBuilder<D, T>

Overrides the average document length for the embedder.

Source

pub fn tokenizer(self, tokenizer: T) -> EmbedderBuilder<D, T>

Sets the tokenizer for the embedder.

Source

pub fn build(self) -> Embedder<D, T>

Builds the Embedder.

Source§

impl<D> EmbedderBuilder<D, DefaultTokenizer>

Source

pub fn with_fit_to_corpus( language_mode: impl Into<LanguageMode>, corpus: &[&str], ) -> EmbedderBuilder<D, DefaultTokenizer>

Constructs a new EmbedderBuilder with its average document length fit to the given corpus. Use this if you have the full corpus (or a sample of it) available in advance. This function uses the default tokenizer configured with the input language mode. The embedder will assume this tokenizer. Use the parallelism feature to speed the fitting process up for large corpora.

Source

pub fn language_mode( self, language_mode: impl Into<LanguageMode>, ) -> EmbedderBuilder<D, DefaultTokenizer>

Sets the language mode for the embedder tokenizer.

Auto Trait Implementations§

§

impl<D, T> Freeze for EmbedderBuilder<D, T>
where T: Freeze,

§

impl<D, T> RefUnwindSafe for EmbedderBuilder<D, T>

§

impl<D, T> Send for EmbedderBuilder<D, T>
where T: Send, D: Send,

§

impl<D, T> Sync for EmbedderBuilder<D, T>
where T: Sync, D: Sync,

§

impl<D, T> Unpin for EmbedderBuilder<D, T>
where T: Unpin, D: Unpin,

§

impl<D, T> UnwindSafe for EmbedderBuilder<D, T>
where T: UnwindSafe, D: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.