Mill.jl and JsonGrinder.jl: automated differentiable feature extraction for learning from raw JSON data

Simon Mandlík, Matej Racinsky, Viliam Lisý, Tomás PevnýarXiv 2021

Introduction

Manual feature engineering for hierarchical data like JSON is a tedious, error-prone bottleneck in machine learning. Most algorithms require inputs to be fixed-size vectors or tensors, yet a massive amount of real-world data—especially in cybersecurity and enterprise services—is stored in hierarchical formats like JSON, XML, or Protocol Buffers. These structures are often "messy," containing variable-length lists, missing fields, and deeply nested dictionaries.

Traditionally, researchers handle this by manually "flattening" the data, deciding which fields to keep and how to aggregate lists. This process is laborious, lossy, and biased by human intuition. This paper introduces a tandem of Julia libraries—Mill.jl and JsonGrinder.jl—that automate the creation of end-to-end differentiable models directly from raw, nested data structures using Hierarchical Multiple Instance Learning (HMIL).

Methods: Hierarchical Multiple Instance Learning

The core innovation of the framework is to mirror the data's hierarchy with a hierarchy of neural network modules. The process involves two primary components:

  1. JsonGrinder.jl: This pre-processing engine scans JSON samples to deduce a schema, identifying types, key-value pairs, and list structures. It then suggests extractors that convert raw values into initial embeddings.
  2. Mill.jl: This modeling engine provides three building blocks corresponding to JSON structures:
  3. ArrayNode: Handles atomic data (numbers, strings) via standard feed-forward layers.
  4. BagNode: Handles lists or sets using permutation-invariant aggregation functions (like mean and maximum) to map variable-length lists to fixed-size vectors.
  5. ProductNode: Handles dictionaries by embedding each key-value pair separately and concatenating them.
Hierarchical mapping of JSON fields to neural network modules.

The framework utilizes a function called reflectinmodel to automatically build the neural network architecture based on the deduced schema. Furthermore, it employs trainable imputation parameters to handle missing data, ensuring the entire pipeline—from leaf nodes to final output—is fully differentiable.

Experimental Evaluation

The authors evaluated the framework on three distinct datasets to demonstrate its generality:

  • Device ID Challenge: Network scan data containing MAC addresses, IP addresses, and services.
  • EMBER: A large-scale dataset for static malware detection based on binary file features.
  • Mutagenesis: A dataset of molecules trialed for mutagenicity, represented as complex relational structures.

Key Results

The framework demonstrated that "out-of-the-box" performance with default settings is remarkably competitive, often outperforming hand-tuned models from specific competitions. In all cases, the "Tuned" version of the Mill/JsonGrinder pipeline exceeded the performance of baseline models that relied on significant manual feature engineering.

Performance comparison across three benchmark datasets showing accuracy for default, tuned, and baseline models.

Discussion and Limitations

The paper argues that the hierarchy itself is a feature. By using HMIL, the model learns to extract features from the relationships between data points, providing a solid mathematical foundation for the software. However, some limitations remain. By default, BagNodes treat lists as unordered sets; while RNNs or Transformers could be used for ordered sequences, the authors found the added computational cost often outweighed the performance gains in their test cases. Additionally, the approach assumes a relatively consistent schema across the dataset, and processing massive JSON files ($10^8$ samples) still requires significant memory and parsing time compared to pre-flattened binary formats.

Summary updated

BibTeX
@misc{mandlik2021mill,
  author = {Simon Mandlík and Matej Racinsky and Viliam Lisý and Tomás Pevný},
  title = {{Mill.jl and JsonGrinder.jl: automated differentiable feature extraction for learning from raw JSON data}},
  year = {2021},
  eprint = {2105.09107},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2105.09107},
}
Figure