arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2406.10442cs.CL
收藏

基于上下文无关文法的领域特定速记生成方法

Domain-Specific Shorthand for Generation Based on Context-Free Grammar

Andriy Kanyuka, Elias Mahfoud

AI总结:

针对JSON等结构化格式token冗余问题,本文提出基于CFG的DSS速记格式及解析方法,实现与标准格式无歧义互转,并在LLM可视化任务中将token减少3至5倍。

摘要:

JSON、YAML和XML等格式的结构化数据生成是生成式人工智能(GenAI)应用中的一项关键任务。这些格式虽被广泛使用,却包含大量冗余结构,导致token用量膨胀。在使用GPT-4等大型语言模型(LLM)时,这种低效尤为明显:生成大量结构化数据会增加延迟和运营成本。我们提出一种以上下文无关文法(CFG)为基础的领域特定速记(DSS)格式,并展示如何用它减少结构化数据生成所需的token数量。该方法创建一种速记表示,以更少的token捕获输出模式的核心元素,并确保其能够与冗长的原始形式进行无歧义的相互转换。它利用CFG促使LLM高效生成速记,并构建解析器将速记翻译回标准结构化格式。将本方法应用于LLM数据可视化任务的结果表明,生成token数量显著减少(3倍至5倍),从而显著降低延迟和成本。本文概述了DSS及配套CFG的开发过程,以及该方法对GenAI应用的意义,为结构化数据生成中的token低效问题提供了一种可扩展的解决方案。

英文摘要:

The generation of structured data in formats such as JSON, YAML and XML is a critical task in Generative AI (GenAI) applications. These formats, while widely used, contain many redundant constructs that lead to inflated token usage. This inefficiency is particularly evident when employing large language models (LLMs) like GPT-4, where generating extensive structured data incurs increased latency and operational costs. We introduce a domain-specific shorthand (DSS) format, underpinned by a context-free grammar (CFG), and demonstrate its usage to reduce the number of tokens required for structured data generation. The method involves creating a shorthand notation that captures essential elements of the output schema with fewer tokens, ensuring it can be unambiguously converted to and from its verbose form. It employs a CFG to facilitate efficient shorthand generation by the LLM, and to create parsers to translate the shorthand back into standard structured formats. The application of our approach to data visualization with LLMs demonstrates a significant (3x to 5x) reduction in generated tokens, leading to significantly lower latency and cost. This paper outlines the development of the DSS and the accompanying CFG, and the implications of this approach for GenAI applications, presenting a scalable solution to the token inefficiency problem in structured data generation.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑