Object Aligner: 一种可配置的图结构JSON模式相似度评分,应用于LLM提示优化
Object Aligner: A Configurable JSON Schema Similarity Score for Graphs, Applied to LLM Prompt Optimization
AI总结:
提出Object Aligner,一种基于递归树对齐和引用对齐的JSON相似度评分方法,通过Weisfeiler-Leman颜色细化近似图同构,用于LLM输出评估和提示优化。
摘要:
大型语言模型(LLM)常被要求生成符合固定模式的JSON,用于信息提取、工具调用、智能体规划和知识图谱构建。衡量输出与黄金参考的匹配程度至关重要但异常困难:精确匹配脆弱,文本相似度忽略结构,LLM评判昂贵、不透明且非确定性。我们通过Object Aligner(OA)解决这一问题,这是一个开源Python库,通过递归对齐两棵JSON对象的树(无序集合使用匈牙利算法,有序集合使用序列对齐)并在模式声明的粒度上给予部分分数,从而确定性评分两个JSON对象。Object Aligner完全通过一组JSON模式扩展配置,因此适应新任务只需注释模式而非编写代码。然而,复杂结构化数据很少是平坦树:记录可能形成由任意标识符键控的图或超图,打破了先前相似度度量的假设。我们的核心贡献——引用对齐——通过推断黄金和候选标识符之间的双射并据此评分每个引用来弥合这一差距,使得分数对重标号不变。由于精确恢复该双射是图同构问题,Object Aligner使用Weisfeiler-Leman颜色细化近似。顺序敏感的序列机制针对排序和规划。由于同一对齐定位每个不匹配,Object Aligner以零额外成本输出排序的修复建议。在GEPA提示优化器中作为奖励使用时,Object Aligner在所有数据集上均有帮助或保持中立。
英文摘要:
Large language models (LLMs) are often asked to produce JSON conforming to a fixed schema, powering information extraction, tool calling, agentic planning, and knowledge-graph construction. Measuring how closely an output matches a gold reference is essential yet surprisingly hard: exact match is brittle, text similarity ignores structure, and an LLM judge is expensive, opaque, and non-deterministic. We address this with Object Aligner (OA), an open-source Python library that scores two JSON objects deterministically by recursively aligning their trees (the Hungarian algorithm for unordered collections, sequence alignment for ordered ones) and awarding partial credit at the granularity the schema declares. The Object Aligner is configured entirely through a set of JSON Schema extensions, so adapting it to a new task involves annotating a schema rather than writing code. Complex structured data, however, are rarely flat trees: records may form graphs or hypergraphs keyed by arbitrary identifiers, breaking the assumptions of prior similarity metrics. Our central contribution, referential alignment, closes this gap by inferring a bijection between gold and candidate identifiers and scoring every reference through it, so the score is invariant to relabeling. Since recovering this bijection exactly is graph isomorphism, the Object Aligner approximates it with Weisfeiler-Leman color refinement. An order-sensitive sequence regime targets ranking and planning. Since the same alignment localizes every mismatch, the Object Aligner emits ranked repair suggestions at no extra cost. Used as a reward inside the GEPA prompt optimizer, Object Aligner helps or stays neutral across all datasets.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。