bert base N E R

dslim

Introduction

bert-base-NER is a fine-tuned BERT model designed for Named Entity Recognition (NER). It identifies four types of entities: location (LOC), organization (ORG), person (PER), and miscellaneous (MISC). The model is based on the bert-base-cased architecture and is fine-tuned on the CoNLL-2003 dataset, achieving state-of-the-art performance.

Architecture

The model is built on the bert-base-cased architecture and fine-tuned for NER tasks. It supports multiple frameworks, including PyTorch, TensorFlow, JAX, and ONNX. Additionally, a larger bert-large-NER model and a smaller distilbert-NER version are available for different performance and size requirements.

Training

Training was performed on the CoNLL-2003 English dataset using an NVIDIA V100 GPU. The dataset contains entity-annotated news articles, distinguishing entity beginnings and continuations to handle consecutive entities of the same type. The model was trained with hyperparameters recommended in the original BERT paper. Evaluation metrics on the test set include an F1 score of 91.3, precision of 90.7, and recall of 91.9.

Guide: Running Locally

  1. Install Dependencies: Ensure you have Python and transformers library installed.

    pip install transformers
    
  2. Load the Model and Tokenizer:

    from transformers import AutoTokenizer, AutoModelForTokenClassification, pipeline
    
    tokenizer = AutoTokenizer.from_pretrained("dslim/bert-base-NER")
    model = AutoModelForTokenClassification.from_pretrained("dslim/bert-base-NER")
    
  3. Create a Pipeline and Perform Inference:

    nlp = pipeline("ner", model=model, tokenizer=tokenizer)
    example = "My name is Wolfgang and I live in Berlin"
    ner_results = nlp(example)
    print(ner_results)
    
  4. Hardware Suggestions: For optimal performance, consider using cloud GPUs like those available on AWS, Google Cloud, or Azure.

License

The bert-base-NER model is licensed under the MIT License, allowing for broad use and modification.

More Related APIs in Token Classification