TWT: Table with Written Text for Controlled Data-to-Text Generation

Tongliang Li, Lei Fang, Jian-Guang Lou, Zhoujun Li

Introduction

Traditional data-to-text (D2T) generation systems aim to transform structured data, such as tables, into natural language descriptions. However, these systems often struggle with two core challenges: content planning (deciding which parts of a large table to describe) and faithfulness (ensuring the generated text is factually accurate). While previous benchmarks like ToTTo utilized manual cell highlighting to guide models, this approach does not reflect how humans typically interact with writing assistants.

The Table with Written Text (TWT) task proposes a more intuitive mechanism for content planning: using a user-provided text prefix (e.g., "The governor took office in...") as the control signal. This allows the model to act as a sophisticated "auto-complete" tool that understands the context of the table.

Examples of the TWT task where a written prefix guides the generation of a factual completion based on a table.

Methodology: The TWT Model Architecture

To address the TWT task, the authors developed a transformer-based encoder-decoder model with several architectural enhancements designed to improve table understanding and factual grounding.

The TWT model architecture featuring table-aware embeddings, specialized attention visibility masks, and a copy mechanism.

1. Table-aware Additional Embeddings

Rather than flattening the table into a simple string, the model incorporates structural information through specialized embeddings. These include row and column indices and type embeddings (distinguishing between cell values and metadata), allowing the transformer to maintain the spatial relationships inherent in tabular data.

2. Attention Visibility Masking

The "secret sauce" of the TWT approach is the use of visibility matrices. In the encoder-decoder attention, the model restricts its focus to specific rows or columns relevant to the user's prefix. This "blinding" mechanism prevents the model from attending to irrelevant data, which significantly reduces hallucinations. Additionally, the decoder uses a prefix mask that allows bidirectional attention among prefix tokens while maintaining standard unidirectional (causal) attention for the generated target tokens.

3. Copy Mechanism

To ensure high factual accuracy, the model employs a "soft switch" copy mechanism. At each generation step, the model calculates a probability of either generating a word from its fixed vocabulary or copying a specific value directly from the input table.

Datasets and Experimental Setup

The researchers constructed the TWT dataset by repurposing two existing benchmarks: ToTTo (focused on descriptive facts) and TabFact (focused on logical inferences). By applying rule-based breakpoints to existing sentences, they generated over 40,000 prefix-target pairs. This allows the model to be evaluated on both simple data retrieval and more complex reasoning (e.g., "only two players had...").

Key Results and Insights

The TWT model demonstrated superior performance over standard pre-trained baselines like T5 across several dimensions:

  • Performance Metrics: On the ToTTo-derived test set, the model achieved a BLEU score of 37.38, compared to 30.51 for the T5 baseline.
  • Faithfulness: The model's Fact Coverage reached 46.68%, a significant improvement over the baseline's 33.48%, indicating that the attention masking and copy mechanism effectively grounded the model in the provided data.
  • User Utility: In terms of "Characters Saved"—a metric measuring the reduction in typing effort—the TWT model consistently provided more useful completions than general-purpose language models.

Human evaluations further confirmed these findings, with judges rating the TWT outputs as more faithful and logically consistent. However, the authors noted that logical and numerical reasoning remains a challenge; models still struggle with completions requiring algebraic operations (e.g., calculating differences between values).

Conclusion

The TWT framework represents a significant step toward practical, data-driven writing assistants. By leveraging text prefixes as a natural constraint for content planning, the model achieves higher faithfulness and utility than traditional D2T systems. Future work will likely focus on integrating explicit symbolic reasoning to handle complex mathematical operations within tabular data.

Summary updated

BibTeX
@inproceedings{li2021twt,
  author = {Tongliang Li and Lei Fang and Jian-Guang Lou and Zhoujun Li},
  title = {{TWT: Table with Written Text for Controlled Data-to-Text Generation}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2021},
  doi = {10.18653/v1/2021.findings-emnlp.107},
}
Figure