Large Language Models (LLMs) excel at code generation but struggle with complex problems. Retrieval-Augmented Generation (RAG) mitigates this issue by integrating external knowledge, yet retrieval models often miss relevant context, and generation models hallucinate with irrelevant data. We propose Programming Knowledge Graph (PKG) for semantic representation and fine-grained retrieval of code and text. Our approach enhances retrieval precision through tree pruning and mitigates hallucinations via a re-ranking mechanism that integrates non-RAG solutions. Structuring external data into finer-grained nodes improves retrieval granularity. Evaluations on HumanEval and MBPP show up to 20% pass@1 accuracy gains and a 34% improvement over baselines on MBPP. Our findings demonstrate that our proposed PKG approach along with re-ranker effectively address complex problems while maintaining minimal negative impact on solutions that are already correct without RAG. The replication package is published at https://github.com/iamshahd/ProgrammingKnowledgeGraph


翻译:大型语言模型(LLM)在代码生成方面表现出色,但在处理复杂问题时仍面临挑战。检索增强生成(RAG)通过整合外部知识缓解了这一问题,然而检索模型常常遗漏相关上下文,而生成模型则可能因无关数据产生幻觉。我们提出了编程知识图谱(PKG),用于代码和文本的语义表示与细粒度检索。我们的方法通过树剪枝提高了检索精度,并通过集成非RAG解决方案的重新排序机制减轻了幻觉效应。将外部数据结构化为更细粒度的节点提升了检索的粒度。在HumanEval和MBPP上的评估显示,pass@1准确率最高提升20%,在MBPP上较基线提升34%。我们的研究结果表明,所提出的PKG方法结合重新排序器能有效处理复杂问题,同时对无需RAG已正确的解决方案保持最小的负面影响。复现包已发布于https://github.com/iamshahd/ProgrammingKnowledgeGraph

0
下载
关闭预览

相关内容

大语言模型中的检索与结构化增强生成综述
专知会员服务
32+阅读 · 2025年9月17日
【新书】Essential GraphRAG: 知识图谱增强的RAG
专知会员服务
32+阅读 · 2025年7月17日
【SIGIR2025教程】动态与参数化检索增强生成
专知会员服务
16+阅读 · 2025年7月14日
定制化大型语言模型的图检索增强生成综述
专知会员服务
37+阅读 · 2025年1月28日
图增强生成(GraphRAG)
专知会员服务
34+阅读 · 2025年1月4日
通过强化学习增强代码生成中的代码大语言模型:综述
专知会员服务
29+阅读 · 2025年1月1日
图检索增强生成研究进展
专知会员服务
36+阅读 · 2024年11月5日
【Code】GraphSAGE 源码解析
AINLP
31+阅读 · 2020年6月22日
高效的文本生成方法 — LaserTagger 现已开源
TensorFlow
30+阅读 · 2020年2月27日
AmpliGraph:知识图谱表示学习工具包
专知
40+阅读 · 2019年4月6日
强化学习与文本生成
微信AI
41+阅读 · 2019年4月4日
基于深度学习的文本生成【附217页PPT下载】
专知
35+阅读 · 2018年11月24日
深度学习文本分类方法综述(代码)
中国人工智能学会
28+阅读 · 2018年6月16日
国家自然科学基金
18+阅读 · 2017年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
4+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
5+阅读 · 2014年12月31日
国家自然科学基金
18+阅读 · 2014年12月31日
VIP会员
相关VIP内容
大语言模型中的检索与结构化增强生成综述
专知会员服务
32+阅读 · 2025年9月17日
【新书】Essential GraphRAG: 知识图谱增强的RAG
专知会员服务
32+阅读 · 2025年7月17日
【SIGIR2025教程】动态与参数化检索增强生成
专知会员服务
16+阅读 · 2025年7月14日
定制化大型语言模型的图检索增强生成综述
专知会员服务
37+阅读 · 2025年1月28日
图增强生成(GraphRAG)
专知会员服务
34+阅读 · 2025年1月4日
通过强化学习增强代码生成中的代码大语言模型:综述
专知会员服务
29+阅读 · 2025年1月1日
图检索增强生成研究进展
专知会员服务
36+阅读 · 2024年11月5日
相关基金
国家自然科学基金
18+阅读 · 2017年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
4+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
5+阅读 · 2014年12月31日
国家自然科学基金
18+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员