Skip to main content
QUICK REVIEW

[Paper Review] Can Language Models Solve Graph Problems in Natural Language?

Heng Wang, Shangbin Feng|arXiv (Cornell University)|May 17, 2023
Topic ModelingComputer Science10 citations
TL;DR

The paper introduces NLGraph, a large natural-language graph reasoning benchmark, shows LLMs have preliminary graph reasoning abilities, and proposes Build-a-Graph and Algorithmic prompting to improve performance on simpler tasks. Results indicate gains but complex graph reasoning remains challenging.

ABSTRACT

Large language models (LLMs) are increasingly adopted for a variety of tasks with implicit graphical structures, such as planning in robotics, multi-hop question answering or knowledge probing, structured commonsense reasoning, and more. While LLMs have advanced the state-of-the-art on these tasks with structure implications, whether LLMs could explicitly process textual descriptions of graphs and structures, map them to grounded conceptual spaces, and perform structured operations remains underexplored. To this end, we propose NLGraph (Natural Language Graph), a comprehensive benchmark of graph-based problem solving designed in natural language. NLGraph contains 29,370 problems, covering eight graph reasoning tasks with varying complexity from simple tasks such as connectivity and shortest path up to complex problems such as maximum flow and simulating graph neural networks. We evaluate LLMs (GPT-3/4) with various prompting approaches on the NLGraph benchmark and find that 1) language models do demonstrate preliminary graph reasoning abilities, 2) the benefit of advanced prompting and in-context learning diminishes on more complex graph problems, while 3) LLMs are also (un)surprisingly brittle in the face of spurious correlations in graph and problem settings. We then propose Build-a-Graph Prompting and Algorithmic Prompting, two instruction-based approaches to enhance LLMs in solving natural language graph problems. Build-a-Graph and Algorithmic prompting improve the performance of LLMs on NLGraph by 3.07% to 16.85% across multiple tasks and settings, while how to solve the most complicated graph reasoning tasks in our setup with language models remains an open research question. The NLGraph benchmark and evaluation code are available at https://github.com/Arthur-Heng/NLGraph.

Motivation & Objective

  • Evaluate whether large language models can reason about graphs when described in natural language.
  • Quantify the impact of prompting strategies on graph-based tasks of varying difficulty.
  • Identify limitations of LLMs, including brittleness to spurious correlations and diminished gains on complex tasks.
  • Propose instruction-based prompting methods to enhance graph reasoning capabilities.

Proposed method

  • Develop NLGraph with 29,370 problems across eight graph tasks of easy to hard difficulty.
  • Use random graph generators to create problem instances and natural-language prompts per task.
  • Evaluate LLMs (GPT-3/4 family) with zero-shot, few-shot, chain-of-thought, zero-shot-CoT, least-to-most, and self-consistency prompting.
  • Introduce partial-credit metrics for several tasks to capture near-correct reasoning.
  • Propose Build-a-Graph prompting to ground graph descriptions in conceptual spaces before solving, and Algorithmic prompting to recall problem-specific algorithms.
Figure 1: Overview of the NLGraph Benchmark, featuring eight tasks with varying complexity. We show an intuitive figure representing each task along with the example natural language prompts being passed to the LLMs.
Figure 1: Overview of the NLGraph Benchmark, featuring eight tasks with varying complexity. We show an intuitive figure representing each task along with the example natural language prompts being passed to the LLMs.

Experimental results

Research questions

  • RQ1Can LLMs perform explicit graph algorithm reasoning when problems are described in natural language?
  • RQ2How do prompting strategies affect LLM performance across simple vs. complex graph tasks?
  • RQ3Do in-context exemplars and advanced prompting help on harder graph reasoning problems?
  • RQ4Can instruction-based prompting mitigate reliance on spurious correlations in graph problems?

Key findings

  • LLMs show preliminary graph reasoning abilities, outperforming random baselines by 37.33% to 57.82% on simple tasks with chain-of-thought prompting.
  • Advanced prompting benefits diminish on more complex graph problems, with CoT/LtM/SC often underperforming few-shot prompting on tasks like topological sort and Hamilton path.
  • In-context learning can be counterproductive for complex graph reasoning, with zero-shot sometimes outperforming few-shot on certain tasks.
  • LLMs exhibit brittleness to spurious correlations (e.g., chain and clique cases in connectivity) that can dramatically lower performance.
  • Build-a-Graph prompting and Algorithmic prompting yield 3.07% to 16.85% gains on several tasks, though the most complex problems remain open research questions.
Figure 2: (left) Model performance on the topological sort task. CoT , LtM , and self-consistency are mostly ineffective on this problem. (right) Model performance on the maximum flow task. few-shot prompting outperforms CoT+SC prompting on both easy and hard subsets, suggesting that LLMs fall short
Figure 2: (left) Model performance on the topological sort task. CoT , LtM , and self-consistency are mostly ineffective on this problem. (right) Model performance on the maximum flow task. few-shot prompting outperforms CoT+SC prompting on both easy and hard subsets, suggesting that LLMs fall short

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.