Context-Augmented Code Generation Using Programming Knowledge Graphs

Fuente: arXiv
Salvato in:
Dettagli Bibliografici
Autori principali: Seddik, Shahd, Seddik, Fahd, Saberi, Iman, Fard, Fatemeh, Huynh, Minh Hieu, Thongtanunam, Patanamon
Natura: Preprint
Pubblicazione: 2026
Soggetti:
Accesso online:
Tags: Aggiungi Tag
Nessun Tag, puoi essere il primo ad aggiungerne!!
_version_ 1866915759851044864
author Seddik, Shahd
Seddik, Fahd
Saberi, Iman
Fard, Fatemeh
Huynh, Minh Hieu
Thongtanunam, Patanamon
author_facet Seddik, Shahd
Seddik, Fahd
Saberi, Iman
Fard, Fatemeh
Huynh, Minh Hieu
Thongtanunam, Patanamon
contents 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
format Preprint
id arxiv_https___arxiv_org_abs_2601_20810
institution arXiv
publishDate 2026
record_format arxiv
spellingShingle Context-Augmented Code Generation Using Programming Knowledge Graphs
Seddik, Shahd
Seddik, Fahd
Saberi, Iman
Fard, Fatemeh
Huynh, Minh Hieu
Thongtanunam, Patanamon
Software Engineering
Machine Learning
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
title Context-Augmented Code Generation Using Programming Knowledge Graphs
topic Software Engineering
Machine Learning
url https://arxiv.org/abs/2601.20810