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 EmbedderEmbedder used to encode candidate n-grams. MUST be the same
provider + model that produced chunk_embed, otherwise cosine
similarity is meaningless.
top_k: usizeNumber 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: f32MMR diversity coefficient in [0.0, 1.0].
Implementations§
Source§impl<'a> KeyBertExtractor<'a>
impl<'a> KeyBertExtractor<'a>
Sourcepub fn new(embedder: &'a dyn Embedder) -> Self
pub fn new(embedder: &'a dyn Embedder) -> Self
Construct a KeyBERT extractor with default parameters.
Sourcepub const fn with_top_k(self, k: usize) -> Self
pub const fn with_top_k(self, k: usize) -> Self
Override top_k. Returns self for chaining.
Sourcepub const fn with_ngram_range(self, min: usize, max: usize) -> Self
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.
Sourcepub fn with_mmr_diversity(self, lambda: f32) -> Self
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<'_>
impl Debug for KeyBertExtractor<'_>
Source§impl Extractor for KeyBertExtractor<'_>
impl Extractor for KeyBertExtractor<'_>
Source§fn extract_entities(&self, text: &str, chunk_embed: &[f32]) -> Vec<Entity>
fn extract_entities(&self, text: &str, chunk_embed: &[f32]) -> Vec<Entity>
text. Read moreSource§fn extract_relations(&self, text: &str, entities: &[Entity]) -> Vec<Relation>
fn extract_relations(&self, text: &str, entities: &[Entity]) -> Vec<Relation>
Source§fn infer_typed_relations(
&self,
_text: &str,
_entities: &[Entity],
_budget: &InferenceBudget,
) -> Vec<TypedRelation>
fn infer_typed_relations( &self, _text: &str, _entities: &[Entity], _budget: &InferenceBudget, ) -> Vec<TypedRelation>
InferenceBudget]. Read more