Table layout affects how language models remember data relationships

Table Serialization Determines Which Relations Language Models Preserve

Computation and Language

Summary

This paper looks at how the way tables are written out as text affects how language models find information in them. The authors tested models with tables arranged by rows or by columns and found that the best arrangement depends on the shape of the table. For tall tables, writing by rows worked better; for wide tables, writing by columns was more accurate. The study shows that models tend to keep part of the data relationship well but struggle with the other depending on the order the table is presented.

What this means in practice

  • For software engineers: Improve data extraction accuracy by choosing table text formats suited for model queries based on table shape.
  • For ai system integrators: Design prompt formats that optimize relational data recall when using instruction-tuned language models for tabular data tasks.

Authors

Junwei Ma, Arun Kumar Chithanar, Palash Goyal, Chul Lee

Abstract

We study how text serialization affects table lookup in instruction-tuned language models. Our diagnostic asks the model to find the row containing a specified value under one named column, then return the value under another named column in that same row. We render the same synthetic 256-cell tables in row-major form and in column-major form with each header placed beside its values, while varying the table aspect ratio across five shapes. Across three models, the better format changes with table shape: row-major performs better on tall tables, whereas column-major performs better on wide tables. At 64 x 4, row-major leads by 42.3-54.0 percentage points; at 4 x 64, column-major leads by 35.0-59.0 points. Mapping wrong answers back to their source cells reveals a complementary error pattern: row-major tends to preserve the correct row but lose the target column, while column-major tends to preserve the correct column but lose the row. We use the term relational locality to describe this pattern: serialization keeps one relation locally available while making the other depend on positional alignment. A separate non-tabular ordering experiment supports this interpretation. Thus, apparent width-related failures in text-serialized tables depend on linearization, not table shape alone.