Enhancing Logical Reasoning in Large Language Models through Graph-based Synthetic Data

Jiaming Zhou, Abbas Ghaddar, Ge Zhang, Liheng Ma, Yaochen Hu, Soumyasundar Pal, Bin Wang, Jianye Hao, Mark Coates, Yingxue Zhang

TL;DR

Large language models frequently stumble on multi-hop logical reasoning involving long deduction chains. This paper introduces a framework to boost reasoning in open-source LLMs by generating high-quality, synthetic training data via random-walk sampling over relational graphs, paired with an "Extract-Then-Answer" (ETA-P) prompting format. Supervised fine-tuning with this graph-derived data allows moderate-sized 7B models to match or exceed few-shot GPT-4o on complex multi-hop benchmarks without suffering from catastrophic forgetting.

What Problem Does This Paper Address?

While modern LLMs excel at fluent text generation and short-horizon problem solving, they remain brittle on multi-hop logical reasoning. They struggle to maintain coherence across lengthy reasoning steps and are easily derailed by small perturbations in context.

Generating synthetic data using powerful proprietary models is a common workaround, but LLM-generated reasoning traces often hallucinate or produce incorrect intermediate labels. To bypass the unreliability and cost of LLM-based synthetic generation, this paper explores whether rigorous, graph-based programmatic data generation can supply deterministic, correct training signals that teach models structured, multi-step deduction.

Methods

The authors propose an end-to-end pipeline combining graph algorithms with structured prompting:

  1. Relational Graph Construction: Starting from a root node, the relational graph $G = (V, E, R)$ is grown iteratively. If a relation between nodes is missing, candidate nodes are added, and an external deductive engine (e.g., an Answer Set Programming solver for kinship logic, or relative coordinate math for spatial logic) deduces valid connecting edges.
  2. Sub-Graph Sampling via Random Walks: To extract non-trivial, non-circular reasoning paths, an isotropic random-walk algorithm samples paths of varying lengths (2 to 10 hops). The paths are augmented via triple permutations, edge-direction flips, and distracting "edge noise" (irrelevant triples).
  3. Verbalization: A deterministic, rule-based verbalizer translates sampled relation triples into natural language stories, avoiding the expense and potential hallucinations of LLM-based verbalizers.
  4. Extract-Then-Answer (ETA-P) Prompting: Rather than asking the model to jump straight from story to answer (standard prompting), ETA-P forces the model to first parse the narrative into explicit, ordered relational triples before deriving the final answer.
Narrative Context ──► [Extract Ordered Triples] ──► [Infer Target Relation]

Datasets

The authors evaluated models across two canonical multi-hop reasoning tasks:

  • CLUTRR: Inductive kinship reasoning requiring models to infer family relationships (e.g., niece, grandfather) from short narratives. The authors generated ~10k synthetic reasoning chains spanning 2 to 10 hops.
  • StepGame: Spatial reasoning requiring models to track relative agent positions (e.g., upper-left, below). GPT-4o was used to convert original structured data into textual stories, and ~5k synthetic chains were generated.
  • General Evaluation Benchmarks: MMLU, GPQA, and GSM8K were used to verify whether task-specific fine-tuning caused catastrophic forgetting.

Key Insights and Ideas

  • Prompting alone is not enough: In zero-/few-shot settings, ETA-P prompting actually decreased model performance compared to standard prompting. Without fine-tuning, models failed to extract triples accurately, creating cascading errors.
  • Prompt engineering and SFT are complementary: When trained via SFT on structured targets, models learn to extract intermediate graphs reliably. ETA-P combined with SFT dramatically outperformed standard direct-answer tuning.
  • Synthetic graphs bridge the low-resource gap: The performance boost from synthetic graph data was especially stark on harder, low-resource tasks (StepGame) and at high hop counts (hops 6–10), where base models typically collapse.
  • Zero catastrophic forgetting: Adapting models with purely synthetic, graph-derived data did not erode their broad capabilities; scores on MMLU, GPQA, and GSM8K remained essentially unchanged (and occasionally improved).

Key Results

Experiments centered on Mistral-7B-Instruct (with parallel validations on Qwen2.5-7B and Llama3-8B):

  • Surpassing GPT-4o on StepGame: On 10-hop spatial reasoning in StepGame, few-shot GPT-4o achieved 43.0% accuracy, and Mistral-7B with story-only fine-tuning (SFT-S) reached 37.0%. Adding 5,000 synthetic graph chains (SFT-S+5k) propelled Mistral-7B to 76.0%.
  • CLUTRR Gains: At 6 hops, Mistral-7B accuracy rose from 23.7% (Few-Shot) and 83.2% (SFT-S) to 91.0% (SFT-S+10k), outperforming few-shot GPT-4o (87.6%).
  • Benchmark Stability: Mistral-7B fine-tuned on CLUTRR retained its general capabilities: MMLU shifted from 57.54% to 58.46%, GPQA from 29.46% to 29.02%, and GSM8K from 38.82% to 38.36%.

Limitations and Future Work

  • Domain Scope: The study focuses on domains that map cleanly to formal first-order logic or coordinates (kinship and 2D grid spatial tasks). Extending this to fuzzier, non-deterministic reasoning domains remains an open challenge.
  • High-Hop Degradation: While synthetic tuning significantly mitigates performance drop-offs, accuracy still gradually degrades as hops approach 10.
  • Heuristic Verbalization: The authors relied on simple template verbalizers to isolate the impact of graph structures; integrating richer, diverse language while guaranteeing factual precision is left for future exploration.

Summary updated

BibTeX
@inproceedings{zhou2025enhancing,
  author = {Jiaming Zhou and Abbas Ghaddar and Ge Zhang and Liheng Ma and Yaochen Hu and Soumyasundar Pal and Bin Wang and Jianye HAO and Mark Coates and Yingxue Zhang},
  title = {{Enhancing Logical Reasoning in Large Language Models through Graph-based Synthetic Data}},
  booktitle = {XLLM-Reason-Plan @ COLM},
  year = {2025},
  url = {https://openreview.net/forum?id=Kqp4325eXm},
}
Figure