Skip to main content

Natural language structuring library

Project description

NLStruct

Natural language struturing library. Currently, it implements only a NER model, but other algorithms will follow.

Features

  • processes large documents seamlessly: it automatically handles tokenization and sentence splitting.
  • do not train twice: an automatic caching mechanism detects when an experiment has already been run
  • stop & resume with checkpoints
  • easy import and export of data
  • handles nested or overlapping entities
  • pretty logging with rich_logger
  • heavily customizable, without config files (see train_ner.py)
  • built on top of transformers and pytorch_lightning

How to train a NER model

from nlstruct.recipes import train_ner

model = train_ner(
    dataset={
        "train": "path to your train brat/standoff data",
        "val": 0.05,  # or path to your validation data
        # "test": # and optional path to your test data
    },
    finetune_bert=False,
    seed=42,
    bert_name="camembert/camembert-base",
    fasttext_file="",
    gpus=0,
    xp_name="my-xp",
)
model.save_pretrained("ner.pt")

How to use it

from nlstruct import load_pretrained
from nlstruct.datasets import load_from_brat, export_to_brat

ner = load_pretrained("ner.pt")
export_to_brat(ner.predict(load_from_brat("path/to/brat/test")), filename_prefix="path/to/exported_brat")

Status

This project is still under development and subject to changes.

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

nlstruct-0.0.3.post1.tar.gz (71.5 kB view details)

Uploaded Source

Built Distribution

nlstruct-0.0.3.post1-py3-none-any.whl (81.0 kB view details)

Uploaded Python 3

File details

Details for the file nlstruct-0.0.3.post1.tar.gz.

File metadata

  • Download URL: nlstruct-0.0.3.post1.tar.gz
  • Upload date:
  • Size: 71.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0.post20210125 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.4

File hashes

Hashes for nlstruct-0.0.3.post1.tar.gz
Algorithm Hash digest
SHA256 2da534daa68d13eedf7225b2af290c5e3c12c780e7955d2a5636600344f10e75
MD5 5470d2e37773a6a89a7345b192372114
BLAKE2b-256 bc52db974abbef9210f1ae2be2c6dda1fadc7570882c5b9c5d89efb70450780a

See more details on using hashes here.

Provenance

File details

Details for the file nlstruct-0.0.3.post1-py3-none-any.whl.

File metadata

  • Download URL: nlstruct-0.0.3.post1-py3-none-any.whl
  • Upload date:
  • Size: 81.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0.post20210125 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.4

File hashes

Hashes for nlstruct-0.0.3.post1-py3-none-any.whl
Algorithm Hash digest
SHA256 d30198ea1602d205588836b4cc66a1ff5e46f04a2dd3d675b07fba8281068ba1
MD5 46835ff806d7db4aeccb40e903e6d4c1
BLAKE2b-256 4120ed8449f0abfce1610fdfefaf65ee11a7dd434a53c34b72edae1cdbaf9cc8

See more details on using hashes here.

Provenance

Supported by

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