Skip to main content

Documentation Status Build PyPI version SWH License Downloads

DeLFT

DeLFT (Deep Learning Framework for Text) is a deep-learning framework for text processing, focusing on sequence labeling (e.g. named entity tagging, information extraction) and text classification (e.g. comment classification). This library re-implements standard state-of-the-art Deep Learning architectures relevant to text processing tasks.

DeLFT has three main purposes:

  1. Covering text and rich texts: most of the existing Deep Learning works in NLP only consider simple texts as input. In addition to simple texts, we also target rich text where tokens are associated to layout information (font. style, etc.), positions in structured documents, and possibly other lexical or symbolic contextual information. Text is usually coming from large documents like PDF or HTML, and not just from segments like sentences or paragraphs, and contextual features appear very useful. Rich text is the most common textual content used by humans to communicate and work.

  2. Reproducibility and benchmarking: by implementing several references/state-of-the-art models for both sequence labeling and text classification tasks, we want to offer the capacity to easily validate reported results and to benchmark several methods under the same conditions and criteria.

  3. Production level, by offering optimzed performance, robustness and integration possibilities, we aim at supporting better engineering decisions/trade-off and successful production-level applications.

Some contributions include:

  • A variety of modern NLP architectures and tasks to be used following the same API and input formats, including RNN and transformers.

  • Reduction of the size of RNN models, in particular by removing word embeddings from them. For instance, the model for the toxic comment classifier went down from a size of 230 MB with embeddings to 1.8 MB. In practice the size of all the models of DeLFT is less than 2 MB, except for Ontonotes 5.0 NER model which is 4.7 MB.

  • Implementation of a generic support of categorical features, available in various architectures.

  • Usage of dynamic data generator so that the training data do not need to stand completely in memory.

  • Efficient loading and management of an unlimited volume of static pre-trained embeddings.

  • A comprehensive evaluation framework with the standard metrics for sequence labeling and classification tasks, including n-fold cross validation.

  • Native integration of HuggingFace transformers (including recent models such as ModernBERT).

A native Java integration of the library has been realized in GROBID via JEP.

The DeLFT 1.0.x release line is built on PyTorch and has been tested successfully with Python 3.10/3.11 (see the PyPI badge above for the exact current version). As always, GPU(s) are required for decent training time. For example, a GeForce GTX 1050 Ti (4GB) is working very well for running RNN models and BERT or RoBERTa base models. Using BERT large model is no problem with a GeForce GTX 1080 Ti (11GB), including training with modest batch size. Using multiple GPUs (training and inference) is supported.

Migrating to PyTorch (0.4.x → 1.0.x)

The 1.0.x release line replaces the TensorFlow/Keras backend (used up to 0.4.x) with PyTorch. The public API, CLI entrypoints, architecture names and data formats are unchanged, but the runtime and saved weights are not. See the Upgrading section of the installation guide for the full step-by-step. Highlights:

  • PyTorch backend: torch 2.11, transformers 5.7 (native, no Keras-layer wrapping), and pytorch-crf replace TensorFlow / tf_keras / tensorflow-addons. Newer transformers such as ModernBERT are supported.
  • Retrain custom models: TensorFlow weights cannot be loaded into the PyTorch models and there is no automatic converter (the previous convert_model utility was removed). Bundled application models have been regenerated for PyTorch; custom models must be retrained with their original train / train_eval command.
  • GPU / CUDA 12.8: GPU builds target CUDA 12.8 via the [gpu] extra (see installation below). Reinstall into a fresh virtual environment to avoid leftover tensorflow packages.
  • ELMo support removed: the --use-ELMo flag and use_ELMo parameter are gone. Use transformer-based models (BERT, SciBERT, …) or static embeddings (GloVe, fastText) instead.
  • LMDB embedding caches built before 0.4.x use the legacy pickle format; convert them once with python -m delft.utilities.convert_lmdb_embeddings --input <old> --output <new> (or simply rebuild).

Other changes

  • Weights & Biases integration for experiment tracking, with resume support (--wandb flag) — see Experiment tracking (W&B)
  • Distributed / multi-GPU training support via SLURM scripts and accelerate — see Training on a cluster (SLURM)
  • ONNX export for BidLSTM_CRF / BidLSTM_CRF_FEATURES models (see below)
  • Additional checks for avoiding empty embeddings

DeLFT Documentation

Visit the DELFT documentation for detailed information on installation, usage and models.

Using DeLFT

PyPI packages are available for stable versions:

# macOS or Linux CPU
pip install delft

# Linux with CUDA 12.8 (adds PyTorch GPU support)
pip install "delft[gpu]" --extra-index-url https://download.pytorch.org/whl/cu128

Note: The base install pulls the standard PyTorch wheel from PyPI — that's a CPU build on Linux, and a native build on macOS arm64 that includes MPS (Apple Silicon GPU) support automatically. The [gpu] extra is for NVIDIA CUDA 12.8 on Linux.

DeLFT Installation

To work from source (current master), clone the repo, set up a virtual environment, and install in editable mode:

git clone https://github.com/kermitt2/delft
cd delft
uv venv --python=3.11
source .venv/bin/activate
uv pip install pip
uv pip install -e .          # macOS or Linux CPU (torch is included automatically)

For NVIDIA GPU (CUDA) wheels, older pre-Turing GPUs (V100/P100), the [dev] extras required for training, and upgrading from a TensorFlow-based build, follow the full Install DeLFT guide. See the DeLFT documentation for usage.

Experiment tracking and distributed training

  • Weights & Biases — pass --wandb to any train / train_eval / eval command to log the run. Setup (WANDB_API_KEY, project selection, resuming a run for evaluation) is in Experiment tracking (W&B).
  • SLURM clusters — multi-GPU training and the cluster submitter scripts are documented in Training on a cluster (SLURM).

ONNX Export

DeLFT supports exporting trained sequence labeling models (BidLSTM_CRF and BidLSTM_CRF_FEATURES) to ONNX format for inference in Java or other runtimes.

Export a model:

python -m delft.applications.onnx_export \
    --model grobid-date-BidLSTM_CRF_FEATURES \
    --output exported_models/date-features

This creates:

  • encoder.onnx - BiLSTM encoder model
  • crf_params.json - CRF transition matrices
  • vocab.json - Character and label vocabularies
  • config.json - Model configuration

Java inference:

A Java inference library is available in java/delft-onnx/. Build and run:

cd java/delft-onnx
./gradlew build
./gradlew run --args="--model ../../exported_models/date-features \
    --embeddings ../../data/db/glove-840B-raw \
    --input 'December 25, 2024'"

Note: For feature models, sample features are auto-generated for demo purposes.

License and contact

Distributed under Apache 2.0 license. The dependencies used in the project are either themselves also distributed under Apache 2.0 license or distributed under a compatible license.

If you contribute to DeLFT, you agree to share your contribution following these licenses.

Contact: Patrice Lopez (patrice.lopez@science-miner.com) and Luca Foppiano (@lfoppiano).

How to cite

If you want to this work, please refer to the present GitHub project, together with the Software Heritage project-level permanent identifier. For example, with BibTeX:

@misc{DeLFT,
    title = {DeLFT},
    howpublished = {\url{https://github.com/kermitt2/delft}},
    publisher = {GitHub},
    year = {2018--2026},
    archivePrefix = {swh},
    eprint = {1:dir:54eb292e1c0af764e27dd179596f64679e44d06e}
}

Download files

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

Source Distribution

delft-1.0.0.tar.gz (142.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

delft-1.0.0-py3-none-any.whl (172.5 kB view details)

Uploaded Python 3

File details

Details for the file delft-1.0.0.tar.gz.

File metadata

  • Download URL: delft-1.0.0.tar.gz
  • Upload date:
  • Size: 142.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for delft-1.0.0.tar.gz
Algorithm Hash digest
SHA256 9d6f5b51ff9184ae77e03942b6a71f49c009d36b69c241f5dd8b7f272cf2889b
MD5 0636c6022f378fe5f65ea8d7164595b5
BLAKE2b-256 a0b1c8704f1bb5a3ae0a2d3e99375a2f36fa325c6e40eee5726a1a721552d75b

See more details on using hashes here.

Provenance

The following attestation bundles were made for delft-1.0.0.tar.gz:

Publisher: ci-release.yml on kermitt2/delft

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file delft-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: delft-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 172.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for delft-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 aca49a7e1c4c2f591bf2e0fbc89ba71630ff3f9e8d2a67c6f9ece4f9b651fd5f
MD5 4dd68514cca6dcb732e89c2db158222c
BLAKE2b-256 717d62957445a4dc516522b8a0c43103c17b1eef6fb074ae3eba3416f6599002

See more details on using hashes here.

Provenance

The following attestation bundles were made for delft-1.0.0-py3-none-any.whl:

Publisher: ci-release.yml on kermitt2/delft

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

1.0.1

2 files

This release

1.0.0 This release

2 files

0.4.6

2 files

0.4.5

2 files

0.4.4

2 files

0.4.3

2 files

0.4.2

2 files

0.4.1

2 files

0.4.0

2 files

0.3.5

2 files

0.3.4

2 files

0.3.3

2 files

0.3.2

1 file

0.3.1

1 file

0.3.0

1 file

0.2.8

2 files

0.2.7

2 files

0.2.6

1 file

0.2.5

2 files

0.2.4

2 files

0.2.3

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page