Introduction
While Large Language Models (LLMs) like GPT-4 and Claude 3 are incredibly powerful, they are prone to hallucinations—especially when asked domain-specific or highly technical questions not deeply covered in their training data. To ground their responses in hard facts, researchers often use Retrieval-Augmented Generation (RAG) or Knowledge Graphs (KGs).
However, most state-of-the-art LLMs are closed-source, meaning researchers can only interact with them via text prompts (APIs). Existing KG-prompting methods struggle in this "black-box" setting for three main reasons:
- Huge Search Spaces: Real-world KGs have millions of connections, making it hard to find the exact reasoning path needed.
- High API Costs: API calls charge by the token. Dumping a massive, unedited subgraph into a prompt is prohibitively expensive.
- Laborious Prompt Engineering: LLMs are highly sensitive to how data is formatted. Manually designing the "perfect" prompt to represent complex graph data is tedious and brittle.
To address these challenges, researchers introduce KnowGPT, a novel framework that uses Reinforcement Learning to extract concise, relevant facts from KGs, and a Multi-Armed Bandit algorithm to automatically format those facts into the optimal prompt for closed-source LLMs.
The KnowGPT Framework
KnowGPT is a two-part framework designed to efficiently inject KG data into black-box LLMs:
- Knowledge Extraction via Deep Reinforcement Learning (RL): Instead of pulling a massive, noisy subgraph, KnowGPT trains an RL agent to navigate the KG and extract a concise "reasoning chain." The agent is rewarded based on three criteria:
- Reachability: Does the path connect the question's core entity to a target answer?
- Context-relatedness: Are the nodes semantically relevant to the question?
- Conciseness: Is this the shortest possible path? (Crucial for saving API token costs).
- Context-Aware Prompt Construction via Multi-Armed Bandit (MAB): Because different questions require different prompt structures, KnowGPT uses an MAB algorithm to dynamically select the best combination of extraction strategy (RL vs. a fallback heuristic subgraph) and prompt template. The templates include raw Triples (e.g.,
(Apple, is_a, Fruit)), natural language Sentences, or a detailed Graph Description. The MAB learns from the LLM's feedback to balance exploring new formats and exploiting known successful ones.
Datasets and Evaluation
The framework was evaluated on three benchmark datasets spanning general and domain-specific knowledge:
- CommonsenseQA (CSQA): A multiple-choice dataset requiring everyday commonsense reasoning (paired with the ConceptNet KG).
- OpenBookQA (OBQA): Questions requiring fundamental scientific facts (paired with ConceptNet).
- MedQA-USMLE: A highly specialized medical dataset sourced from US medical licensing exams (paired with a biomedical KG combining UMLS and DrugBank).
Key Findings and Results
- Massive Accuracy Boost: KnowGPT (built on top of GPT-3.5) improved accuracy by an average of 23.7% over base GPT-3.5 across the three datasets.
- Beating the State-of-the-Art: Remarkably, KnowGPT + GPT-3.5 outperformed base GPT-4 by an average of 2.9%. It also achieved a 92.6% accuracy on the OpenBookQA leaderboard, outperforming traditional KG-enhanced models and approaching human-level performance (91.7%).
- Shorter is Better (and Cheaper): By using RL to prioritize concise reasoning paths, KnowGPT avoids overwhelming the LLM's context window. In a MedQA efficiency analysis, KnowGPT used significantly fewer tokens per prompt (348 vs. 1129 for the CoK baseline), resulting in an API cost that was roughly 3x cheaper while delivering better accuracy.
- Dynamic Prompting: The authors found that simple questions are best answered when the LLM is fed raw KG triples. However, complex, multi-hop reasoning questions benefit heavily from "Graph Description" prompts that explicitly explain the local structure of the entities. The MAB dynamically handles this routing.
- Black-Box > White-Box: KnowGPT outperformed white-box models that explicitly integrate KGs into their internal neural architecture, proving that smart, dynamic prompting can rival expensive structural integration.
Limitations and Future Work
The framework relies heavily on the quality of the underlying Knowledge Graph. Real-world KGs are often constructed automatically from online text, inevitably introducing noisy or incorrect triples. If the KG contains bad data, KnowGPT might extract it and actively mislead the LLM. Future work will focus on integrating off-the-shelf KG refinement and error-detection algorithms to clean the graphs before the extraction phase, ensuring the LLM is only prompted with high-fidelity facts.
Summary updated