arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~

作为一种数据类型的提示:数据库内的大语言模型提示管理与重写

Prompt as a Data Type: In-Database LLM Prompt Management and Rewriting

Denis Mayr Lima Martins, Gottfried Vossen

arXiv 2607.21756首次发表:更新:

发表机构

Department of Computing and Mathematics University of Sao Paulo; Department of Information Systems University of Münster(计算机与数学系 乌拉圭圣保罗大学; 信息系统系 梅茵斯特大学)

机构由 AI 辅助整理,请以论文原文为准。

AI 中文总结

研究如何在数据库中管理和重写大语言模型提示。核心方法是引入PromptDB系统,将提示视为元组级数据库值,利用数据库元数据重写提示。主要贡献是创造新优化空间,经实验验证数据库引导重写可提高输出有效性并权衡成本质量。

AI 中文摘要

大语言模型(LLMs)越来越多地用于数据库支持的应用程序中,但启动这些计算的提示通常以非结构化格式存储在数据库管理系统(DBMS)之外,这使得查询执行、元数据管理和优化无法看到它们。本文借鉴Stonebraker的QUEL作为一种数据类型和反射式编程原理,引入了PromptDB,一个将提示视为元组级数据库值的数据库系统。PromptDB提供了一个逻辑PROMPT数据类型,其值存储模板、与元组属性的绑定、模型元数据和任务元数据。关系可以在基表中直接包含PROMPT属性,或者通过连接元组的视图公开它们。用户通过生成的评估视图查询提示值属性,而系统内部通过EVAL操作符渲染、重写、优化和执行提示。使提示在数据库中可见创造了一个新的优化空间。关键思想是将查询优化器的思维应用于提示:就像查询优化器利用数据库元数据重写SQL计划一样,PromptDB利用数据库元数据重写提示。我们在不同任务的合成数据和真实世界数据工作负载上评估了PromptDB。结果表明,与静态的、手动编写的提示相比,数据库引导重写如何提高输出有效性并产生良好的成本-质量权衡。

英文摘要

Large Language Models (LLMs) are increasingly used in database-backed applications to classify tuples, filter records using semantic predicates, extract structured attributes, and enrich query results. Yet the prompt that start these computations are typically stored outside the DBMS in unstructured formats, making them invisible to query execution, metadata management, and optimization. Drawing on Stonebraker's QUEL as a Data Type and the principles of reflective programming, this paper introduces PromptDB, a database system that treats prompts as tuple-level database values. PromptDB provides a logical PROMPT datatype whose values store a template, bindings to tuple attributes, model metadata, and task metadata. Relations may contain PROMPT attributes directly in base tables, or expose them through views over joined tuples. Users query prompt-valued attributes through generated evaluation views, while the system internally renders, rewrites, optimizes, and executes prompts through an EVAL operator. Making prompts database-visible creates a new optimization space. The key idea is to bring query-optimizer thinking to prompts: just as query optimizers exploit database metadata to rewrite SQL plans, PromptDB exploits database metadata to rewrite prompts. We evaluate PromptDB on synthetic and real-world data workloads across different tasks. The results show how database-guided rewriting improves output validity and yields favorable cost-quality trade-offs compared with static, manually written prompts.

论文原文

arXiv 摘要页 · PDF 原文 · HTML 原文

↑