HW-TSC at TextGraphs-17 Shared Task: Enhancing Inference Capabilities of LLMs with Knowledge Graphs

Wei Tang, Xiaosong Qiao, Xiaofeng Zhao, Min Zhang, Chang Su, Yuang Li, Yinglu Li, Yilun Liu, Feiyu Yao, Shimin Tao, Hao Yang, He XianghuiACL 2024

TL;DR

This paper presents a novel prompt engineering strategy for Large Language Models (LLMs) to improve their performance on Knowledge Graph Question Answering (KGQA) tasks. By incorporating "self-ranking" and "emotional prompts," the authors significantly boost LLM accuracy in selecting the correct entity from a set of candidates, achieving second place in the TextGraphs-17 shared task.

What Problem Does This Paper Address?

The paper tackles a critical challenge in the era of advanced LLMs: their struggle with factual accuracy and logical reasoning, especially when dealing with complex questions that require external knowledge. While LLMs like GPT-4 show impressive capabilities, they can sometimes produce plausible-sounding but incorrect answers, or be uncertain about their own outputs. This is particularly true for Knowledge Graph Question Answering (KGQA), where grounding answers in structured knowledge is crucial. The TextGraphs-17 shared task specifically aims to address this by requiring participants to select the most relevant entity from a candidate list, using provided knowledge graph subgraphs to aid the LLM. The core problem is how to effectively integrate external knowledge (via KGs) with LLM reasoning to ensure factual correctness and confidence.

Methods

The authors propose a two-pronged prompt engineering strategy to enhance LLM performance:

  • Self-Ranking Prompt: This encourages the LLM to assign a confidence score (on a scale of 0-5) to its chosen answer. This forces the model to reflect on its certainty and provides a quantifiable measure of its confidence.
  • Emotional Prompt: This involves adding phrases that evoke a sense of importance or urgency, framing the task as critical for the LLM's "career" or emphasizing the need for careful consideration. The hypothesis is that this emotional framing can lead to more cautious and thorough inference.

These prompts are integrated into a base prompt that clearly defines the task: a question, candidate answers, and reasoning paths derived from a knowledge graph. The LLM is instructed to select the single correct answer based on the provided reasoning paths, and if no correct answer is found, to provide the most plausible one based on its own knowledge. The authors also implement a post-processing step to handle potential output inconsistencies from the LLM, using regular expressions to extract the desired answer format.

Datasets

The primary dataset used is from the TextGraphs-17 Shared Task. This task involves:

  • A textual question.
  • A set of candidate entities.
  • A Wikidata subgraph representing shortest paths between entities in the question and candidate entities.

The paper mentions that answers are provided in the training set but not in the testing set, which is a standard setup for evaluation.

Key Insights and Ideas

  • Emotional Framing Enhances LLM Caution: The "emotional prompt" strategy, which imbues the task with a sense of importance, surprisingly leads to more careful and accurate responses from LLMs. This suggests that even artificial agents can be nudged towards better performance through carefully crafted linguistic cues.
  • Self-Ranking Boosts Confidence and Accuracy: Requiring LLMs to self-rank their answers not only provides a confidence score but also seems to improve the accuracy of the selected answer. This implies that the act of self-assessment can lead to better decision-making.
  • Prompt Engineering is a Powerful Tool: The paper demonstrates that sophisticated prompt design can significantly improve LLM performance on complex reasoning tasks without requiring additional model training or fine-tuning. This highlights the growing importance of prompt engineering as a key skill in leveraging LLMs.
  • KG Integration is Crucial for Factual Accuracy: Despite the advancements in LLMs, they still struggle with factual questions without external knowledge. The integration of knowledge graphs, even in a limited subgraph form, is essential for grounding their answers and improving reliability.

Key Results

The authors report significant improvements using their combined prompt strategy:

  • Mistral 7B: The open-source Mistral 7B model, when equipped with both prompt-rank and prompt-emotion strategies, saw its F1 score increase from 0.3776 (base model) to 0.5226, a substantial improvement.
  • Claude 3: The more powerful Claude 3 model, using the prompt-rank and prompt-emotion strategy, achieved an F1 score of 0.8321, securing second place in the TextGraphs-17 shared task. This demonstrates the transferability and effectiveness of the proposed prompts on state-of-the-art LLMs.
  • The prompt-rank strategy alone improved the F1 score by 3.57%, and prompt-emotion by 3.34% on Mistral 7B. Combining them yielded a 4.09% improvement.

Limitations and Future Work

The authors acknowledge several limitations:

  • Output Inconsistencies: LLMs can still produce outputs that deviate from the desired format, requiring robust post-processing (like regular expressions) to extract correct answers. This points to ongoing challenges in controlling LLM output precisely.
  • Outdated External Knowledge: In some cases, the knowledge embedded within LLMs might be outdated, necessitating mechanisms for accessing real-time or more current information.
  • Ablation Study on Mistral 7B: Due to cost constraints, a full ablation study was conducted on the Mistral 7B model rather than the primary Claude 3 model.

Future work directions include:

  • Investigating methods for LLMs to independently access APIs to retrieve up-to-date external knowledge.
  • Further research into reducing output errors, such as inconsistencies, unreasonability, and ambiguity.
  • Exploring more sophisticated ways to emotionally influence LLMs for improved inference.

Summary updated

BibTeX
@inproceedings{tang2024hw,
  author = {Wei Tang and Xiaosong Qiao and Xiaofeng Zhao and Min Zhang and Chang Su and Yuang Li and Yinglu Li and Yilun Liu and Feiyu Yao and Shimin Tao and Hao Yang and He Xianghui},
  title = {{HW-TSC at TextGraphs-17 Shared Task: Enhancing Inference Capabilities of LLMs with Knowledge Graphs}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2024},
}
Figure