Skip to main content

KeyBertExtractor

Struct KeyBertExtractor 

Source
pub struct KeyBertExtractor<'a> {
    pub embedder: &'a dyn Embedder,
    pub top_k: usize,
    pub ngram_range: (usize, usize),
    pub mmr_diversity: f32,
}
Expand description

KeyBERT-style extractor.

Holds a borrowed Embedder reference; the caller owns the concrete provider (Ollama / OpenAI / ONNX / mock) and threads it in for the duration of an ingest run.

Fields§

§embedder: &'a dyn Embedder

Embedder used to encode candidate n-grams. MUST be the same provider + model that produced chunk_embed, otherwise cosine similarity is meaningless.

§top_k: usize

Number of entities to return per call. See DEFAULT_TOP_K.

§ngram_range: (usize, usize)

Inclusive (min_n, max_n) n-gram length range.

§mmr_diversity: f32

MMR diversity coefficient in [0.0, 1.0].

Implementations§

Source§

impl<'a> KeyBertExtractor<'a>

Source

pub fn new(embedder: &'a dyn Embedder) -> Self

Construct a KeyBERT extractor with default parameters.

Source

pub const fn with_top_k(self, k: usize) -> Self

Override top_k. Returns self for chaining.

Source

pub const fn with_ngram_range(self, min: usize, max: usize) -> Self

Override n-gram range. min must be >= 1; callers that pass 0 are clamped to 1. Returns self for chaining.

Source

pub fn with_mmr_diversity(self, lambda: f32) -> Self

Override MMR diversity coefficient. Returns self for chaining. Callers passing values outside [0.0, 1.0] get them clamped.

Trait Implementations§

Source§

impl Debug for KeyBertExtractor<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Extractor for KeyBertExtractor<'_>

Source§

fn extract_entities(&self, text: &str, chunk_embed: &[f32]) -> Vec<Entity>

Extract entity mentions from text. Read more
Source§

fn extract_relations(&self, text: &str, entities: &[Entity]) -> Vec<Relation>

Mine candidate relations over an already-extracted entity set. Read more
Source§

fn infer_typed_relations( &self, _text: &str, _entities: &[Entity], _budget: &InferenceBudget, ) -> Vec<TypedRelation>

Optionally infer typed relations between already-extracted entities, subject to the supplied [InferenceBudget]. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for KeyBertExtractor<'a>

§

impl<'a> !RefUnwindSafe for KeyBertExtractor<'a>

§

impl<'a> Send for KeyBertExtractor<'a>

§

impl<'a> Sync for KeyBertExtractor<'a>

§

impl<'a> Unpin for KeyBertExtractor<'a>

§

impl<'a> UnsafeUnpin for KeyBertExtractor<'a>

§

impl<'a> !UnwindSafe for KeyBertExtractor<'a>

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more