DeepZensols: Deep Natural Language Processing Framework

Paul Landes, Barbara Di Eugenio, Cornelia CarageaarXiv 2021

Abstract

DeepZensols is a Python-based deep learning framework built on top of PyTorch, specifically engineered to address the "replication crisis" in Natural Language Processing (NLP) research. By providing strict management of random states and batch ordering alongside a zero-code configuration system, it enables researchers to rapidly experiment with diverse linguistic features and word embeddings while ensuring scientific reproducibility.

Introduction

The machine learning community, particularly in NLP, faces significant challenges in reproducing published results. This variance often arises from unmanaged random seeds, inconsistent data splitting, and brittle, ad-hoc preprocessing scripts. While low-level libraries like PyTorch offer flexibility, they lack the high-level abstractions necessary for consistent reproducibility. Conversely, more rigid frameworks can hinder the rapid experimentation required in research. DeepZensols bridges this gap by offering a highly configurable wrapper around PyTorch that prioritizes strict scientific standards and flexible feature engineering.

System Architecture

DeepZensols is designed as a layered system that integrates core NLP libraries and deep learning tools into a unified framework.

The DeepZensols architecture stack, showing the relationship between Zensols libraries, third-party Python libraries (spaCy, HuggingFace, PyTorch), and the underlying system hardware.

Methodology

The framework's core design relies on several key innovations:

Strict Reproducibility

DeepZensols automatically saves and restores all random states across Python, PyTorch, and GPU environments. It further ensures reproducibility by serializing dataset splits and the exact mini-batch orderings used during training. This allows a model's state to be perfectly recreated for testing or further experimentation.

Decoupled Vectorization and Zero-Code Architecture

The framework utilizes a Spring-like inversion of control (IoC) configuration system. Users define "vectorizers" that transform raw text and linguistic features—such as POS tags, NER, and dependency trees generated by spaCy—into tensors. This approach eliminates the need for custom PyTorch data loading code, allowing researchers to concatenate linguistic features to contextual (e.g., BERT) or non-contextual (e.g., GloVe) embeddings entirely through configuration files.

Efficient Batch Encoding

To optimize training performance, DeepZensols treats mini-batches as independent units of work. It segments datasets into chunks, vectorizes them in parallel sub-processes, and caches the resulting tensors to the file system. This drastically reduces data loading times and memory overhead, particularly when working with large, frozen transformer embeddings.

The DeepZensols batching and feature concatenation process, illustrating how word embeddings and token features are vectorized, cached, and combined into batches for model input.

Key Insights

  • Bridging Classical and Deep NLP: DeepZensols simplifies the process of injecting explicit linguistic knowledge (like POS tags or document-level features) into modern deep learning models, facilitating research into hybrid architectures.
  • Configuration over Code: By relying on a dependency injection system, the framework ensures that every experiment's state—including hyperparameters and feature sets—is fully serialized and shareable.

Conclusion and Future Work

DeepZensols provides a robust platform for reproducible NLP research, validated through extensive unit and integration testing. It supports complex architectures like BiLSTM-CRFs and various Transformer-based classifiers out-of-the-box. Future developments will focus on expanding support for pre-training tasks, such as masked language modeling, and integrating real-time visualization tools like TensorBoard to enhance the researcher's workflow.

Summary updated

BibTeX
@misc{landes2021deepzensols,
  author = {Paul Landes and Barbara Di Eugenio and Cornelia Caragea},
  title = {{DeepZensols: Deep Natural Language Processing Framework}},
  year = {2021},
  eprint = {2109.03383},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2109.03383},
}
Figure