基於高效圖檢索增強生成的程式碼自動補全方法
Code Auto-Completion via Highly Efficient Graph-Based Retrieval Augmented Generation
摘要
隨著軟體工程規模與複雜度日益提升,開發人員面臨多語言、多領域程式碼檢索與自動補全的挑戰。現有方法在語言支援、檢索效率及專業領域適應性上仍有諸多限制。為此,本論文提出一套高效圖檢索增強生成(Graph-basedRetrieval-Augmented Generation, RAG)之程式碼自動補全系統,擴展GraphCoder 架構,支援 Python、C++、Verilog 及 PLC 指令表等多種語言。系統設計包含語法樹解析、語意圖建構、子圖切片、索引加速與多子圖檢索,並結合MinHash-LSH與加權子圖編輯距離重排序,有效提升檢索速度與準確率。實驗結果顯示,本方法在多語言程式碼自動補全任務上,於準確率、識別率及檢索效率均優於現有基準方法,並能無縫整合於主流程式碼補全前端。未來將進一步探討跨語言檢索與專業領域微調技術,以提升系統泛化能力與實用性。
As software engineering grows in scale and complexity, developers face increasing challenges in code retrieval and auto-completion across multiple languages. Existing methods are limited in language support, efficiency, and adaptability. This thesis proposes an efficient graph-based retrieval-augmented generation (RAG) system for code auto-completion, extending GraphCoder to support Python, C++, Verilog, and PLC instruction list languages. The system integrates syntax and semantic graph analysis, accelerated indexing, and multi-subgraph retrieval, enhanced by MinHash-LSH filtering and weighted subgraph edit distance reranking. Experiments show the proposed method outperforms baselines in accuracy and efficiency, and can be integrated into mainstream code completion tools. Future work will explore cross-lingual retrieval and domain-specific fine-tuning to further improve generalizability.