NeurIPS 2026QuestionsPapersAreasAboutMarkdown

Reward Shaping to Improve Language Model Query Generation

Shicheng Liu, Zeyu Zhang, LEI LU, Kexuan Sun, Thuy Vu

NeurIPS page · OpenReview · Open on the map

Category: LLM Post-Training: RL & Distillation › Reward Shaping for LLM Reasoning · Type: new method · Keywords: reward shaping, language model query generation, reinforcement learning, token-level reward, bilevel optimization

Areas: RL for LLMs & Agents › LLM Reasoning Reinforcement Learning › Reinforcement Learning for Reasoning

Summary

We propose a reward shaping method that learns a token-level reward function via bilevel optimization to improve language model query generation.

Explained to a 5-year-old

A computer program tries to turn a sentence into a special code that asks a computer for information. Right now it only gets a big reward when it's completely right, which makes learning hard. We give it many small rewards for each small step, like a teacher cheering for each correct word. This helps the program learn faster and make better codes. The new idea uses a clever math plan to teach the program these small rewards.

Explained to a 5-year-old, longer

A language model is a computer program that can write sentences. One job for it is to turn a normal sentence into a special query that a database can understand. When the query is correct, the program gets a big reward, but when it's wrong it gets nothing. This big reward only comes at the end, so the program doesn't know which part it got wrong. To help it learn, we give it many small rewards for each small step it takes. These small rewards tell the program if a word or a part of the query is good. The new idea teaches the program to give itself these small rewards automatically. It does this by using a special planning method that balances two goals. First, it learns what the correct answer should be from examples. Second, it uses that knowledge to improve its own guesses. Because of this, the program can practice more often and get better at making queries. In the end, it produces more accurate queries for databases and knowledge graphs.

For a technical reader

The paper addresses the challenge of training language models to generate formal queries for databases by providing richer feedback than the usual sequence-level reward. It introduces a reward-shaping scheme that learns a dense, token-level reward from ground-truth outcomes and uses this reward to fine-tune the model. The learning process is cast as a bilevel optimization problem, where an outer loop learns the shaping reward and an inner loop updates the language model. Theoretical analysis shows the algorithm converges at a rate of O(1/√K)+O(log K/√K), and experiments confirm substantial gains over baseline methods. The result is a practical recipe for improving query generation accuracy without requiring extensive manual reward engineering.

Problem

Language model query generation often suffers from sparse, sequence-level rewards that provide limited feedback for training, making it difficult for models to learn to produce correct formal queries.

Method

The approach formulates the problem as a bilevel optimization where a token-level shaping reward is learned from ground truth sequence-level rewards, and the language model is optimized using this dense shaping reward.

Results

The approach achieves superior performance over baseline methods on query generation tasks.

Contributions

It introduces a token-level reward shaping framework learned via bilevel optimization to provide dense supervision for language model query generation.

Research questions this paper is counted under

This page was written by language models from the title and abstract of each paper, and the answers were checked by two other models. It can be wrong: check the paper itself. Suggest a correction