Skip to main content

Named_Entity_Recognition_BERT_Multilingual_Library_LUX

Downloads

Overview

Named_Entity_Recognition_BERT_Multilingual_Library_LUX is a powerful and flexible library for Named Entity Recognition (NER) tasks using BERT models. This library supports multilingual NER and is suitable for key information extraction tasks across various domains such as biomedical, environmental, and technological.

The library simplifies NER tasks by providing an easy-to-use pipeline for loading data, training models, and making predictions. It is designed for developers, researchers, and data scientists looking for a robust NER solution. You can find an example of employing the library at this Kaggle notebook.

Features

  • Multilingual Support: Leverage the power of BERT for NER tasks in multiple languages.
  • Flexible Input Format: Works with CoNLL format data.
  • Easy Integration: Provides a simple NERPipeline class for seamless integration into your projects.
  • Comprehensive Metrics: Evaluate your models with precision, recall, F1-score, and accuracy.
  • Pretrained Models: Supports any BERT-based pretrained models.

Installation

Install the library using pip:

pip install named-entity-recognition-bert-multilingual-library-lux

Usage

Example Usage

Here is a complete example of how to use the library for training and predicting:

# Clone the dataset
!git clone https://github.com/spyysalo/bc2gm-corpus.git
from Named_Entity_Recognition_BERT_Multilingual_Library_LUX import NERPipeline

# Initialize pipeline
pipeline = NERPipeline(pretrained_model="bert-base-multilingual-cased")

# Prepare data
train_dataset, val_dataset, test_dataset = pipeline.prepare_data(
    "./bc2gm-corpus/conll/train.tsv", 
    "./bc2gm-corpus/conll/devel.tsv", 
    "./bc2gm-corpus/conll/test.tsv"
)


# Initialize model
pipeline.initialize_model(num_labels=len(pipeline.label_list))

# Train the model
pipeline.train(train_dataset, val_dataset,output_dir="/kaggle/temp/bio_ner_results/")

# Load the model after training
pipeline.load_model(model_dir="/kaggle/temp/bio_ner_results/best_model/")

# Test the model
test_metrics = pipeline.test(test_dataset)
print(test_metrics)

# Predict on a new sentence
predictions = pipeline.predict("BRCA1 is a gene associated with breast cancer.")
print("\nPredictions on New Sentence:")
for token, label in predictions:
    print(f"{token} | {label}")

CoNLL Data Format

The input data should be in CoNLL format:

Token1    Label1
Token2    Label2
Token3    Label3
Token4    Label4

Example:

BRCA1       B-GENE
is          O
a           O
gene        O
associated  O
with        O
breast      B-DISEASE
cancer      I-DISEASE
.           O

Key Components

1. NERPipeline

The main class providing methods for:

  • Data Preparation: Converts CoNLL format to a dataset suitable for BERT.
  • Model Initialization: Loads a pretrained BERT model for NER.
  • Training: Fine-tunes the model on your data.
  • Prediction: Predicts labels for new sentences.
  • Evaluation: Computes evaluation metrics (precision, recall, F1, etc.).

2. Helper Functions

The library also includes utility functions for advanced users:

  • load_data: Load and parse CoNLL format data.
  • convert_to_hf_format: Convert data to Hugging Face dataset format.
  • compute_metrics: Evaluate predictions using seqeval.

Evaluation Metrics

The library uses the seqeval library to compute the following metrics:

  • Precision
  • Recall
  • F1-Score
  • Accuracy

Dependencies

  • torch
  • transformers
  • datasets
  • evaluate
  • numpy
  • seqeval

Contributing

We welcome contributions! Please feel free to open issues or submit pull requests.

Metadata

Release files for Named-Entity-Recognition-BERT-Multilingual-Library-LUX 0.1.14

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for Named-Entity-Recognition-BERT-Multilingual-Library-LUX 0.1.14
File Size Uploaded Provenance
named_entity_recognition_bert_multilingual_library_lux-0.1.14.tar.gz 6.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for Named-Entity-Recognition-BERT-Multilingual-Library-LUX 0.1.14
File Interpreter ABI Platform
Named_Entity_Recognition_BERT_Multilingual_Library_LUX-0.1.14-py3-none-any.whl Python 3 none any Details

Total release size: 14.6 kB

Release files / named_entity_recognition_bert_multilingual_library_lux-0.1.14.tar.gz

Download URL named_entity_recognition_bert_multilingual_library_lux-0.1.14.tar.gz
Size 6.9 kB
Tags Source
SHA-256 checksum
How to use checksums
8544d97f0d9f0395deb5fb4afddd0c815afa842da9cdbe6ac4b1fb8588adbf09
BLAKE2b-256 checksum
How to use checksums
cf2f2fd621490950ef8814f42ace6b553ec0097b9ea06699907c3a92b1434fb9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.9.13

Release files / Named_Entity_Recognition_BERT_Multilingual_Library_LUX-0.1.14-py3-none-any.whl

Download URL Named_Entity_Recognition_BERT_Multilingual_Library_LUX-0.1.14-py3-none-any.whl
Size 7.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
18fadb4744bfce74925764eebe923987b82a4e514f85213fc3b32fd6b0f59616
BLAKE2b-256 checksum
How to use checksums
83aece207955b12adc919237516bbb9ca616ed4ad9138cbc2112cb9fa171d73b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.9.13

Security for Named-Entity-Recognition-BERT-Multilingual-Library-LUX 0.1.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.14 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page