SpreadsheetLLM: Encoding Spreadsheets for Large Language Models

Yuzhang Tian,Jianbo Zhao,Haoyu Dong,Junyu Xiong,Shiyu Xia,Mengyu Zhou,Yun Lin,José Cambronero,Yeye He,Shi Han,Dongmei Zhang
2024-07-12
Abstract:Spreadsheets, with their extensive two-dimensional grids, various layouts, and diverse formatting options, present notable challenges for large language models (LLMs). In response, we introduce SpreadsheetLLM, pioneering an efficient encoding method designed to unleash and optimize LLMs' powerful understanding and reasoning capability on spreadsheets. Initially, we propose a vanilla serialization approach that incorporates cell addresses, values, and formats. However, this approach was limited by LLMs' token constraints, making it impractical for most applications. To tackle this challenge, we develop SheetCompressor, an innovative encoding framework that compresses spreadsheets effectively for LLMs. It comprises three modules: structural-anchor-based compression, inverse index translation, and data-format-aware aggregation. It significantly improves performance in spreadsheet table detection task, outperforming the vanilla approach by 25.6% in GPT4's in-context learning setting. Moreover, fine-tuned LLM with SheetCompressor has an average compression ratio of 25 times, but achieves a state-of-the-art 78.9% F1 score, surpassing the best existing models by 12.3%. Finally, we propose Chain of Spreadsheet for downstream tasks of spreadsheet understanding and validate in a new and demanding spreadsheet QA task. We methodically leverage the inherent layout and structure of spreadsheets, demonstrating that SpreadsheetLLM is highly effective across a variety of spreadsheet tasks.
Artificial Intelligence
What problem does this paper attempt to address?
The paper mainly addresses the challenges that large language models (LLMs) face when handling spreadsheets. The extensive two-dimensional grid, flexible layout, and diverse formatting options of spreadsheets make it difficult for LLMs to understand and reason with them. To solve this problem, the paper proposes the SPREADSHEET LLM framework, which innovatively designs an encoding method aimed at unlocking and optimizing the potential of LLMs in understanding and reasoning with spreadsheets. The paper first introduces a simple serialization method that includes the cell address, value, and format. However, this method is limited by the token constraints of LLMs and is not suitable for most applications. Therefore, they developed SHEET COMPRESSOR, an innovative encoding framework consisting of three modules: structure-anchor-based compression, inverse-index translation, and data-format-aware aggregation. These modules effectively compress spreadsheets and improve performance in spreadsheet detection tasks, surpassing simple methods by 25.6%. SHEET COMPRESSOR achieves an average compression ratio of 25x and still achieves an F1 score of 78.9% on fine-tuned LLMs, outperforming the best existing models by 12.3%. In addition, the paper introduces the concept of Chain of Spreadsheet for downstream spreadsheet understanding tasks, demonstrating the efficiency of SPREADSHEET LLM in various spreadsheet tasks. Overall, the paper attempts to address how to better understand and handle complex spreadsheets with LLMs by proposing effective encoding strategies and methods, significantly improving processing efficiency and accuracy.