Skip to main content

fine-tune transformer-based language models for named entity recognition

Project description

A python package to fine-tune transformer-based language models for named entity recognition (NER).

PyPI PyPI - Python Version CI PyPI - License



pip install nerblackbox


Fine-tune a language model for named entity recognition in a few simple steps:

  1. Define a fine-tuning experiment by choosing a pretrained model and a dataset

experiment = Experiment("my_experiment", model="bert-base-cased", dataset="conll2003")
  1. Run the experiment and get the performance of the fine-tuned model
experiment.get_result(metric="f1", level="entity", phase="test")
# 0.9045
  1. Use the fine-tuned model for inference

model = Model.from_experiment("my_experiment")
model.predict("The United Nations has never recognised Jakarta's move.")
# [[
#  {'char_start': '4', 'char_end': '18', 'token': 'United Nations', 'tag': 'ORG'},
#  {'char_start': '40', 'char_end': '47', 'token': 'Jakarta', 'tag': 'LOC'}
# ]]

There is much more to it than that! See the documentation to get started.



  • Support for Different Data Formats

  • Support for Different Annotation Schemes

  • Integration of HuggingFace Datasets

  • Text Encoding


  • Adaptive Fine-tuning

  • Hyperparameter Search

  • Multiple Runs with Different Random Seeds

  • Detailed Analysis of Training Results


  • Evaluation of a Model on a Dataset


  • Versatile Model Inference


  • Compatibility with HuggingFace

  • GPU Support

  • Language Agnosticism

See the documentation for more details.


  author = {Stollenwerk, Felix},
  title  = {nerblackbox: a python package to fine-tune transformer-based language models for named entity recognition},
  year   = {2021},
  url    = {},

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nerblackbox-0.0.14.tar.gz (116.9 kB view hashes)

Uploaded source

Built Distribution

nerblackbox-0.0.14-py3-none-any.whl (162.2 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page