[][src]Module rust_bert::pipelines::ner

Named Entity Recognition pipeline

Extracts entities (Person, Location, Organization, Miscellaneous) from text. BERT cased large model finetuned on CoNNL03, contributed by the MDZ Digital Library team at the Bavarian State Library All resources for this model can be downloaded using the Python utility script included in this repository.

  1. Set-up a Python virtual environment and install dependencies (in ./requirements.txt)
  2. Run the conversion script python /utils/download-dependencies_bert_ner.py. The dependencies will be downloaded to the user's home directory, under ~/rustbert/bert-ner
use rust_bert::pipelines::ner::NERModel;
let ner_model = NERModel::new(Default::default())?;

let input = [
    "My name is Amy. I live in Paris.",
    "Paris is a city in France."
];
let output = ner_model.predict(&input);

Output:

[
   Entity { word: String::from("Amy"), score: 0.9986, label: String::from("I-PER") },
   Entity { word: String::from("Paris"), score: 0.9985, label: String::from("I-LOC") },
   Entity { word: String::from("Paris"), score: 0.9988, label: String::from("I-LOC") },
   Entity { word: String::from("France"), score: 0.9993, label: String::from("I-LOC") },
]

Structs

Entity

Entity generated by a NERModel

NERConfig

Configuration for NER

NERModel

NERModel to extract named entities