arXiv(opens in a new tab)cs.IRSep 2026Cited by 1 paper on PaperVantage

Manuscript Offprint

arXiv:2609.02324

Adaptive Test-Time Inference for Text2Cypher with Trace Budgeting and Selective Refinement

Makbule Gulcin Ozsoy

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Large language models have enabled natural language interfaces for structured databases, but generated queries may still contain syntactic errors, violate database schemas, or fail during execution. Test-time inference strategies improve generation reliability without additional training, but existing approaches often use fixed inference budgets and uniform refinement strategies, leading to unnecessary computation across questions with different complexity levels. In this work, we investigate adaptive test-time inference for Text2Cypher and introduce two strategies: adaptive trace budgeting, which dynamically adjusts the candidate generation budget based on question difficulty, and selective execution-guided refinement, which applies correction only when additional inference is expected to be beneficial. Experiments on Gemma-2-9B and Qwen-2.5-7B show that adaptive trace budgeting reduces the average generation budget by 30.7% and wall-clock inference time by 21-25% while maintaining comparable generation quality. Selective refinement preserves nearly all execution success gains of full refinement, reducing execution success by only 0.2–0.5% while avoiding unnecessary refinement for simpler questions. Experiments show that a single correction model (Gemma-4) effectively refines outputs from a different model family, suggesting refinement transfers across families.

1 Introduction

Large language models (LLMs) have improved natural language interfaces for structured databases, enabling direct generation of executable queries from natural language questions across tasks such as Text2SQL, Text2SPARQL, and Text2Cypher (Yu Zhu et al., 2025; D'Abramo et al., 2025; Ozsoy et al., 2025). However, generated queries may still contain syntactic errors, violate database schemas, or fail during execution, limiting their reliability in practical applications.

In order to improve generation reliability without retraining the underlying models, recent work has explored test-time inference strategies, including confidence-based candidate selection and inference-time grammar and schema filtering (Wang et al., 2023; Brown et al., 2024; Jivani et al., 2025; Tuccio et al., 2025). While these approaches improve robustness, they generally allocate the same amount of computation to every input question. In practice, question complexity varies considerably: simple questions often require fewer inference steps, whereas more complex questions may benefit from additional candidate generation or correction. Moreover, stricter filtering mechanisms may reject all generated candidates for some inputs, resulting in empty predictions that require additional recovery steps. Applying the same generation and refinement strategy uniformly therefore introduces unnecessary inference cost. These limitations motivate adaptive test-time strategies that allocate computation based on query complexity and apply additional processing only when needed.

In this work, we investigate adaptive test-time inference for Text2Cypher, the task of generating Cypher queries for property graph databases from natural language questions. Building on previous confidence-based, grammar- and schema-aware Text2Cypher inference frameworks (Dessí and Ozsoy, 2026; Ozsoy, 2026), we introduce two complementary strategies: (i) adaptive trace budgeting, which estimates question difficulty before generation and dynamically allocates the candidate generation budget, and (ii) selective execution-guided refinement, which applies iterative correction only to predictions likely to benefit from additional inference while avoiding unnecessary refinement for low-complexity queries.

We evaluate the proposed framework on a Text2Cypher benchmark using two LLMs from different model families, Gemma-2-9B and Qwen-2.5-7B. Adaptive trace budgeting reduces the av-

Figure

Figure 1: Overview of the proposed framework. Adaptive Trace Budgeting and Selective Refinement (red; this work) extend a confidence-based, grammar/schema-aware generation module (gray) from prior work (Dessí and Ozsoy, 2026; Ozsoy, 2026).

erage generation budget by 30.7% and wall-clock inference time by 21-25% while maintaining comparable generation quality. Execution-guided refinement improves execution success, and selective refinement preserves most of this improvement while reducing unnecessary refinement for low-complexity questions. Furthermore, our results suggest that a single refinement model can refine outputs from different generator families, indicating that the generator and correction models do not need to belong to the same model family.

Our main contributions are as follows:

  • We propose adaptive trace budgeting, allocating candidate generation budgets based on estimated question difficulty to reduce inference cost while maintaining generation quality.

  • We introduce selective execution-guided refinement, applying correction based on question difficulty and filtering outcomes.

  • We demonstrate the effectiveness of the proposed framework across two LLM families and show that a shared refinement model can generalize across evaluated generator models.

The remainder of the paper is organized as follows. Section 2 reviews related work, Section 3 presents the proposed method, Section 4 presents the experiments, and Section 5 concludes the paper.

References (15)