pub struct KeywordExtractionModel<'a> {
    pub sentence_embeddings_model: SentenceEmbeddingsModel,
    pub tokenizer: StopWordsTokenizer<'a>,
    /* private fields */
}
Expand description

KeywordExtractionModel to extract keywords from input texts

It contains a sentence embeddings model to compute word-document similarities, a tokenizer to define a keyword candidates list and a scorer to rank these keywords.

  • sentence_embeddings_model: Sentence embeddings model
  • tokenizer: tokenizer used to generate the list of candidates (differs from the transformer tokenizer)

Fields§

§sentence_embeddings_model: SentenceEmbeddingsModel§tokenizer: StopWordsTokenizer<'a>

Implementations§

Build a new KeywordExtractionModel

Arguments
  • config - KeywordExtractionConfig object containing a sentence embeddings configuration and tokenizer-specific options
Example
use rust_bert::pipelines::keywords_extraction::KeywordExtractionModel;

let keyword_extraction_model = KeywordExtractionModel::new(Default::default())?;

Extract keywords from a list of input texts.

Arguments
  • inputs - slice of string-like input texts to extract keywords from
Returns
  • Result<Vec<Vec<Keyword>>, RustBertError> containing a list of keyword for each input text
Example
use rust_bert::pipelines::keywords_extraction::KeywordExtractionModel;

let keyword_extraction_model = KeywordExtractionModel::new(Default::default())?;
let input = [
    "This is a first sentence to extract keywords from.",
    "Some keywords will be extracted from this text too.",
];
let output = keyword_extraction_model.predict(&input);

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

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

Calls U::from(self).

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

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
Should always be Self
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more