KG-Agent: An Efficient Autonomous Agent Framework for Complex Reasoning over Knowledge Graph
Jinhao Jiang1,3, Kun Zhou2,3, Wayne Xin Zhao1,3, Yang Song, Chen Zhu5, Hengshu Zhu5, Ji-Rong Wen1,2,3 1Gaoling School of Artificial Intelligence, Renmin University of China. 2School of Information, Renmin University of China. 3Beijing Key Laboratory of Big Data Management and Analysis Methods. 4NLP Center, BOSS Zhipin. 5Career Science Lab, BOSS Zhipin. Corresponding author.
Abstract
In this paper, we aim to improve the reasoning ability of large language models (LLMs) over knowledge graphs (KGs) to answer complex questions. Inspired by existing methods that design the interaction strategy between LLMs and KG, we propose an autonomous LLM-based agent framework, called KG-Agent, which enables a small LLM to actively make decisions until finishing the reasoning process over KGs. In KG-Agent, we integrate the LLM, multifunctional toolbox, KG-based executor, and knowledge memory, and develop an iteration mechanism that autonomously selects the tool then updates the memory for reasoning over KG. To guarantee the effectiveness, we leverage program language to formulate the multi-hop reasoning process over the KG, and synthesize a code-based instruction dataset to fine-tune the base LLM. Extensive experiments demonstrate that only using 10K samples for tuning LLaMA-7B can outperform state-of-the-art methods using larger LLMs or more data, on both in-domain and out-domain datasets. Our code and data will be publicly released.
中文速览
让LLM(大语言模型)在知识图谱(Knowledge Graph, KG)上做多跳复杂推理一直是个难题,现有方法要么依赖预先设计好的固定交互流程灵活性不足,要么离不开GPT-4这类大型闭源模型。这篇论文提出了KG-Agent框架:给一个7B的小模型配上一套多功能工具箱(负责从KG中提取、过滤、计算信息)、一个KG执行器和知识记忆模块,让它像自主Agent一样在推理过程中自己决定每一步调用哪个工具、更新哪些中间结果,直到得出答案;同时,他们把现有KGQA数据集的SQL查询转化为代码格式的推理程序,合成了一批指令微调数据来训练这个小模型,全程不依赖GPT-4蒸馏。实验表明,仅用1万条样本微调LLaMA-7B,KG-Agent在领域内数据集(CWQ、GrailQA)上就超过了使用更大模型或更多数据的现有最优方法,在零样本跨域测试上也优于有监督全量微调的基线。这项工作的意义在于,它证明了小开源模型也能通过自主规划和结构化工具调用完成复杂的知识图谱推理,打破了对闭源大模型的依赖。
原文 arXiv:2402.11163;中英对照 + 大白话阅读 https://aha.fim.ai/paper/2402.11163v1