Source-linked AI summary

Graph Neural Prompting with Large Language Models

Yijun Tian, Huan Song, Zichen Wang, Haozhu Wang, Ziqing Hu, Fang Wang, Nitesh V. Chawla, Panpan Xu

arXiv:2309.15427v2cs.CLcs.AIcs.LG

TL;DR

LLMs can have difficulty returning grounded knowledge, and incorporating KGs through joint training is challenging at LLM scale. GNP retrieves and encodes pertinent KG knowledge as a prompt for pre-trained LLMs. The reported experiments show improvements on commonsense and biomedical reasoning tasks in frozen and tuned settings.

  • Problem

    LLMs have limitations in precisely capturing and returning grounded knowledge, while joint KG–text training is challenging because of LLM parameter and computational costs.

    Source: Introduction · pp. 1–2
  • Method

    GNP retrieves pertinent KG knowledge and encodes it as a Graph Neural Prompt to guide pre-trained LLMs.

    Source: Introduction · p. 2
  • Results

    +13.5% when the LLM is frozen and +1.8% when the LLM is tuned; GNP is competitive or superior to full fine-tuning in 10 out of 12 evaluations.

    Source: Introduction · p. 2, Conclusion · p. 7
  • Takeaways & Limitations

    The reported evaluations support GNP as a way to encode intricate KG knowledge and improve performance on commonsense and biomedical reasoning tasks.

    Source: Conclusion · p. 7

Abstract

from arXiv · show

Large language models (LLMs) have shown remarkable generalization capability with exceptional performance in various language modeling tasks. However, they still exhibit inherent limitations in precisely capturing and returning grounded knowledge. While existing work has explored utilizing knowledge graphs (KGs) to enhance language modeling via joint training and customized model architectures, applying this to LLMs is problematic owing to their large number of parameters and high computational cost. Therefore, how to enhance pre-trained LLMs using grounded knowledge, e.g., retrieval-augmented generation, remains an open question. In this work, we propose Graph Neural Prompting (GNP), a novel plug-and-play method to assist pre-trained LLMs in learning beneficial knowledge from KGs. GNP encompasses various designs, including a standard graph neural network encoder, a cross-modality pooling module, a domain projector, and a self-supervised link prediction objective. Extensive experiments on multiple datasets demonstrate the superiority of GNP on both commonsense and biomedical reasoning tasks across different LLM sizes and settings. Code is available at https://github.com/meettyj/GNP.

Introduction

LLMs can struggle to return grounded knowledge, while joint KG–text training is challenging at LLM scale and directly supplying KG triples can introduce noise. GNP retrieves and encodes pertinent KG knowledge as a prompt for pre-trained LLMs, and the reported evaluations show gains across frozen and tuned settings.

Introduction

  • LLMs have limitations in returning grounded knowledge, while joint KG–text training is challenging because LLMs require substantial computation.Directly feeding KG triples into LLMs can introduce noise from extraneous contexts.Source: Introduction · pp. 1–2
  • GNP retrieves pertinent KG knowledge and encodes it as a Graph Neural Prompt that guides pre-trained LLMs.Its components include a GNN, cross-modality pooling, a domain projector, and a self-supervised link prediction objective.Source: Introduction · p. 2
  • +13.5% with the LLM frozen and +1.8% with LoRA tuning; GNP was competitive or superior to full fine-tuning in 10 of 12 evaluations.Figure 1 averages results across six datasets and two tasks for an 11B FLAN-T5 model.Source: Figure 1 · p. 1, Introduction · p. 2
  • The paper presents GNP as a plug-and-play approach for learning beneficial KG knowledge with pre-trained LLMs, without designing a specialized model and training it from scratch.The introduction describes this as the first attempt to study learning beneficial KG knowledge for pre-trained LLMs.Source: Introduction · p. 2

Related Work

Prior work has used KGs in language-model pretraining and question answering, while LLM adaptation methods address training costs. This paper frames GNP as a way to learn which KG knowledge to use and deliver it to an LLM as a prompt.

Related Work

  • Prompt Tuning conditions pre-trained LLMs with soft prompts, while parameter-efficient approaches address the training expense associated with large models.The passage also notes that LLMs can generate unfounded responses and have difficulty capturing accurate factual knowledge.Source: Related Work · p. 2
  • Earlier KG approaches tailored pretraining objectives or fusion frameworks to KG triples and text, while other work used graph structure to scaffold question-answering reasoning.Examples include ERNIE, JAKET, JointGT, DRAGON, GreaseLM, and QAGNN.Source: Related Work · p. 2
  • GNP retrieves question-relevant subgraphs, encodes their factual and structural knowledge into a Graph Neural Prompt, and sends it to the LLM with the input text embedding.The framework includes a GNN, cross-modality pooling, a domain projector, and self-supervised link prediction.Source: Figure 2 · p. 3

Preliminary

The preliminary section defines a knowledge graph and formulates multiple-choice question answering, with the KG available to assist the model.

Preliminary

  • A knowledge graph is G = (E, R, T), where E is the entity set, R the relation set, and T the collection of head–relation–tail fact triples.Each triple is drawn from E × R × E.Source: Preliminary · p. 3
  • Multiple-choice question answering takes a question, answer options, and optional context, and requires selecting the best option.The context may depend on whether the task is open-book or closed-book.Source: Preliminary · p. 3
  • The formulation includes a knowledge graph as a source of rich knowledge to assist the model in answering the question.Source: Preliminary · p. 3

Methodology

GNP retrieves relevant knowledge-graph subgraphs and encodes their information into a soft prompt for an LLM. Its pipeline uses graph encoding, cross-modal pooling, a domain projector, and a self-supervised link-prediction objective.

Prompting LLMs for Question Answering

  • GNP encodes retrieved graph structure and facts into trainable soft-prompt vectors concatenated with the input text embeddings.The prompt is intended to provide structural knowledge and task instructions for each instance.Source: Prompting LLMs for Question Answering · p. 3

Subgraph Retrieval

  • Entity linking matches input tokens to graph entities, then retrieval collects their two-hop neighbors and connecting relations.The retrieved subgraph is intended to contain knowledge relevant to answering the question.Source: Subgraph Retrieval · pp. 3–4

Graph Neural Prompting

  • A graph attention network encodes retrieved subgraphs into node embeddings, avoiding direct use of every triple that could add noise.The encoder initializes nodes with pretrained entity embeddings.Source: Graph Neural Prompting · p. 4
  • Cross-modality pooling identifies question-relevant nodes and combines their embeddings into a graph-level representation.Self-attention captures graph-internal node significance; cross-attention uses node embeddings as queries and transformed text embeddings as keys and values.Source: Graph Neural Prompting · p. 4
  • A domain projector maps graph-level embeddings into the LLM’s text dimension to bridge the graph and text domains.Its output is the Graph Neural Prompt, the final GNP output.Source: Graph Neural Prompting · p. 4
  • Self-supervised link prediction trains the model to recover masked graph edges, with the final objective combining link-prediction and LLM losses.The method scores masked triples as positives against random negative triples.Source: Graph Neural Prompting · p. 4

Experiments

Across commonsense and biomedical reasoning tasks, GNP improves performance in frozen and tuned LLM settings. The experiments also examine component contributions, design alternatives, parameter sensitivity, and examples of retrieved knowledge.

Experiment setup

  • Experiments cover commonsense and biomedical reasoning, comparing frozen LLMs with prompt adaptation against tuned LLMs using LoRA or full fine-tuning.The frozen-setting baselines include prompt designs, KG-injection approaches, and Prompt Tuning; the tuned setting compares with LoRA and full fine-tuning.Source: Experiment setup · p. 5

Performance Comparison

  • GNP improves frozen-LLM performance across datasets and achieves +12.76% and +13.54% overall improvement for 3B and 11B LLMs, respectively; tuned results match or surpass full fine-tuning in 10 of 12 evaluations.In the tuned setting, GNP is combined with LoRA; the comparison uses full fine-tuning as a reference.Source: Performance Comparison · p. 6

Ablation Study

  • Removing DP significantly affects performance, while removing CMP or SLP lowers it; SLP matters more in most cases, but CMP matters more on BioASQ.GNP achieves the best results in all ablation cases.Source: Ablation Study · p. 6, Table 2 · p. 6

Model Design Comparison

  • Adding dataset-level prompts does not further boost performance and can diminish it, while using a relational GNN also reduces performance relative to the standard GNN.The authors report that instance-level prompts provide adequate guidance and that a standard GNN is sufficient to capture graph information.Source: Model Design Comparison · p. 6, Table 3 · p. 6

Parameter Sensitivity

  • Optimal GNN and pooling-layer counts vary by dataset and LLM size, and changing layer counts can have weak or substantial effects on performance.For example, 11B LLM performance on ARC falls from 78.1 to 74.3 when increasing GNN layers from 3 to 5; OBQA and BioASQ respond differently to pooling-layer changes by model size.Source: Parameter Sensitivity · pp. 6–7, Figure 3 · p. 7, Figure 4 · p. 7

Case Study and Visualization

  • In two OBQA examples, retrieved subgraphs contain answer-related entities and connecting edges, while also including irrelevant entities that could confuse the model.The examples include a babies-to-genealogy path associated with the correct option and a historical relation connecting humans, evolution, and fossil fuels.Source: Case Study and Visualization · p. 7, Figure 5 · p. 7

Conclusion

GNP is a plug-and-play approach to help pre-trained LLMs learn beneficial knowledge from KGs, addressing limitations in grounded knowledge. Experiments on commonsense and biomedical reasoning report performance gains when LLMs are frozen or tuned.

  • GNP improves performance by +13.5% when LLM is frozen and +1.8% when LLM is tuned.Source: Conclusion · p. 7
  • Graph Neural Prompting is a plug-and-play method that assists pre-trained LLMs in learning beneficial knowledge from KGs.Source: Conclusion · p. 7
  • Ablation studies, model design comparisons, parameter sensitivity analyses, case studies, and visualizations are used to validate the method.Source: Conclusion · p. 7
Loading 2309.15427v2…