GRAD: Generative Retrieval-Aligned Demonstration Sampler for Efficient Few-Shot Reasoning

Oussama Gabouj, Kamel Charaf, Ivan Zakazov, Nicolas Baldwin, Robert West

TL;DR

GRAD (Generative Retrieval-Aligned Demonstrator) replaces static example retrieval with a dynamic LLM trained to generate custom, concise, task-specific demonstrations on the fly. By using Reinforcement Learning to optimize for both accuracy and token efficiency, GRAD significantly outperforms traditional Retrieval-Augmented Generation (RAG) on complex reasoning tasks, particularly when the questions fall outside the model's original training domain.

What Problem Does This Paper Address?

Few-shot prompting—providing an LLM with a few examples before asking a question—is the "secret sauce" for complex reasoning. Traditionally, we use Retrieval-Augmented Generation (RAG) to pull these examples from a static database.

However, RAG has two major "bottlenecks":

  1. Alignment Gap: A static database might not contain an example that perfectly mirrors the logic needed for a specific, novel query.
  2. Out-of-Distribution (OOD) Failure: When a model faces a topic it wasn't specifically indexed for (e.g., a math-heavy model facing a niche physics problem), retrieved examples are often irrelevant and can actually confuse the model, degrading performance.

The authors of GRAD ask: What if the model could just "imagine" the perfect, most helpful examples for itself?

Methods

The researchers introduced GRAD, a framework where a "demonstrator" model is trained to generate input-specific demonstrations.

The Secret Sauce: GRPO

Instead of standard supervised learning, they used Group Relative Policy Optimization (GRPO), a reinforcement learning algorithm. The training loop works like this:

  1. Generation: The demonstrator creates two concise examples based on the user's query.
  2. Execution: A "target" model uses these examples to solve the actual problem.
  3. Reward: The demonstrator receives a composite reward based on:
  4. Accuracy ($R_{acc}$): Did the target model get the right answer?
  5. Confidence ($R_p$): How high were the log probabilities for the correct tokens?
  6. Efficiency ($R_{demo}$): Did the model stay within a strict token budget (300 tokens for demos)?

They also tested GRADi, a variant that starts with a "warm-up" phase of Supervised Fine-Tuning (SFT) before moving to RL, helping the model stabilize its output format early on.

Datasets

  • Training: The models were trained on MRD3 (Math Reasoning Dataset with Diverse Difficulty), which aggregates GSM8K, MAWPS, and AQuA.
  • Evaluation:
    • In-Distribution (ID): GSM8K (math word problems).
  • Out-of-Distribution (OOD): A diverse battery including MMLU (College Physics, CS, Chemistry), MathQA, DeepMind basic_math, and the ARC Challenge.

Key Insights and Ideas

  • Structure over Content: Even though GRAD was trained only on math, it generalized remarkably well to Physics and Computer Science. This suggests the model learned the structure of reasoning (how to break down a problem) rather than just memorizing formulas.
  • The "Small Tutor" Effect: One of the most exciting findings is that a smaller, cheaper model (like a 3B or 7B parameter model) can be trained as a GRAD demonstrator to successfully guide a much larger 14B parameter model. This allows for high-performance reasoning without the cost of fine-tuning massive models.
  • Less is More: By enforcing a strict token budget, GRAD forces the demonstrator to be concise. The authors found that shorter, "punchier" demonstrations reduce noise and help the target model focus on the logic that matters.

Key Results

The researchers evaluated models from the Qwen2.5 and LLaMA 3.1 families.

  • Dominating the Baselines: On the Qwen2.5-14B model, GRAD achieved 90.92% accuracy on GSM8K, compared to 83.89% for traditional RAG.
  • OOD Superiority: The gap was even wider on OOD tasks. On the MMLU benchmark (STEM subjects), GRAD hit 65.31%, while RAG lagged behind at 48.52%*.
  • Efficiency: GRAD consistently produced shorter prompts and more concise final answers than RAG, which often suffered from "truncation" issues when retrieved examples were too wordy.

Limitations and Future Work

  • The "Small Model" Floor: The authors noted that very small models (3B parameters) struggled to act as effective demonstrators. They often generated "noisy" examples that actually hurt performance compared to zero-shot baselines.
  • Factuality Risks: Since the demonstrations are generated, there is a risk of "hallucinated" logic. While the RL reward for final accuracy mitigates this, there is no explicit check to ensure the demonstration itself is factually perfect.
  • H-GRAD: The authors propose a future "Hybrid" version that would dynamically choose between retrieving a factual example (for knowledge-heavy tasks) and generating one (for logic-heavy tasks).

Summary updated

BibTeX
@misc{gabouj2025grad,
  author = {Oussama Gabouj and Kamel Charaf and Ivan Zakazov and Nicolas Baldwin and Robert West},
  title = {{GRAD: Generative Retrieval-Aligned Demonstration Sampler for Efficient Few-Shot Reasoning}},
  year = {2025},
  eprint = {2510.01165},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2510.01165},
}
Figure