Semi-Structured Object Sequence Encoders

Rudra Murthy V, Riyaz Bhat, Chulaka Gunasekara, Siva Sankalp Patel, Hui Wan, Tejas Indulal Dhamecha, Danish Contractor, Marina Danilevsky

TL;DR

This paper introduces TVM-KA, a modular hierarchical encoder designed for long sequences of semi-structured objects (like JSON logs or user activity). By decomposing sequences into independent key-centric streams and using a novel interleaved training schedule with shared attention heads, the model effectively bypasses the memory bottlenecks of standard sequence flattening while outperforming record-centric baselines.

What Problem Does This Paper Address?

Modern digital systems generate vast amounts of semi-structured data—sequences of objects containing various key-value pairs (e.g., machine logs, clickstreams). Modeling these sequences is challenging for two main reasons:

  1. Extreme Sequence Length: A "trivial" approach is to flatten each object into a string of tokens. However, for real-world data, this can result in sequences tens of thousands of tokens long, far exceeding the memory limits of standard Transformers like BERT.
  2. Structural Complexity: Standard models often struggle to capture how specific attributes (keys) evolve over time. Existing "record-centric" methods, which compress an entire object into a single vector at each time step, often create information bottlenecks that hurt downstream task performance.

Methods

The authors propose a two-part hierarchical architecture called TVM-KA:

  1. Temporal Value Modeling (TVM): Instead of looking at whole objects, this module processes the sequence of values for each key independently over time. For example, it tracks how the status field changes across 100 log entries. This allows the model to handle much longer temporal contexts.
  2. Key Aggregation (KA): This module takes the final representations of each key from the TVM and performs self-attention across them to build a global representation of the entire sequence for a specific task (e.g., classification).
Figure 2: The TVM-KA network architecture consisting of a set of shared attention heads (weights) between the Temporal Value Modeler and the Key Aggregator. Each key is encoded independently to create a corresponding key representation.

Novel Training Strategy: To ensure the TVM learns representations useful for the final task, the authors introduce shared attention heads between the two modules. They use an interleaved training schedule:

  • Train TVM using a Masked Language Modeling (MLM) objective.
  • Train KA for the downstream task.
  • Repeat, allowing task-specific gradients from the KA to influence the TVM's shared attention weights.

Datasets

The model was evaluated on three distinct types of semi-structured data:

  • Cloud Service Logs: An internal dataset of user interaction traces from a large cloud provider, used for "milestone prediction" (e.g., predicting if a user will upgrade their plan).
  • LogHub (HDFS-1): A public dataset of Hadoop distributed file system logs, used for anomaly detection.
  • Instacart eCommerce: A public dataset of grocery purchase histories, used for next-product prediction.

Key Insights and Ideas

  • Key-Centricity is Scalable: By decoupling keys, the model can support an arbitrary number of fields and much longer time horizons than flattening. It essentially turns a 2D problem (time x keys) into multiple 1D problems (time) followed by a shallow 1D aggregation (keys).
  • Interleaving Prevents Forgetting: Standard sequential training (pre-train then fine-tune) can lead to "catastrophic forgetting." The interleaved approach keeps the TVM's general understanding of the data aligned with the KA's specific task requirements.
  • The "Goldilocks" Zone for Sharing: Sharing too few attention heads doesn't inject enough task bias, while sharing too many restricts the model's capacity. The authors found that sharing 4 to 6 heads (out of 12 in a BERT-base architecture) provided the best results.
Figure 1: Semi-Structured Object Sequences: (a) Generic representation of a sequence of semi-structured objects, consisting of multiple key-value pairs at time steps t1 . . . tN. (b) Example object: a sequence of events triggered by the use of a graphical user interface. (c) Viewing a text paragraph as a sequence of sentences. (d) Encoding the example object in (a) by flattening. (e) Encoding (a) by encoding a representation of the values for each key (to be followed by a key aggregation step, not shown). (f) Encoding (a) using a record-centric representation for each time step.

Key Results

  • Superior Performance: TVM-KA consistently outperformed flattened BERT and record-centric baselines. On the Cloud Service Logs, it achieved a 3.9% to 58.5% increase in Macro F1 score compared to flattened encodings.
  • Handling Long Sequences: On the Instacart dataset, where sequences are particularly long, TVM-KA achieved a Recall@10 of 22.54, significantly higher than the best flattened BERT baseline (19.11).
  • Efficiency: The model performs better than bert-large (which has 3x the parameters) while using a bert-base backbone, proving that architectural structure is more important than raw size for this data type.

Limitations and Future Work

  • Global View: The key-centric approach might miss complex patterns that occur across different fields at the same time step, as it only aggregates them at the very end.
  • Task Constraints: The current architecture is not designed for sequence tagging (labeling each object in the sequence), as the aggregation step produces a single global vector.
  • Future Directions: The authors suggest exploring more complex aggregation methods and testing the architecture on even more diverse semi-structured formats beyond JSON-like logs.

Summary updated

BibTeX
@misc{v2023semi,
  author = {Rudra Murthy V and Riyaz Bhat and Chulaka Gunasekara and Siva Sankalp Patel and Hui Wan and Tejas Indulal Dhamecha and Danish Contractor and Marina Danilevsky},
  title = {{Semi-Structured Object Sequence Encoders}},
  year = {2023},
  eprint = {2301.01015},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2301.01015},
}
Figure