[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"doc-detail-83831-en":3,"doc-seo-83831-105":29,"detail-sidebar-cat-0-en-105":91},{"code":4,"msg":5,"data":6},0,"success",{"doc_id":7,"user_id":8,"nickname":9,"user_avatar":10,"doc_module":4,"category_id":11,"category_name":12,"doc_title":13,"doc_description":14,"doc_content":15,"file_id":16,"file_url":17,"file_type":18,"file_size":19,"view_count":20,"is_deleted":4,"is_public":20,"is_downloadable":20,"audit_status":20,"page_count":21,"language":22,"language_code":23,"site_id":24,"html_lang":23,"table_of_contents":25,"faqs":26,"seo_title":13,"seo_description":14,"update_tm":27,"read_time":28},83831,2336464648322,"Aria","https://ap-avatar.wpscdn.com/avatar/2200025388227c56fec?_k=1778556882303663488",8,"Research & Report","Finetuning Lightweight LLMs for Control Flow Graph Generation","Control Flow Graph (CFG) supports software analysis, code understanding, and maintenance, yet conventional CFG generation often requires complete, compilable, syntax-error-free code and relies on language-specific tooling, limiting coverage for real-world incomplete or erroneous programs. This paper explores fine-tuned lightweight LLMs for CFG generation, proposing a unified CFG output format and a task-specific fine-tuning prompt. A dataset is built via automatic CFG generation and error augmentation from an existing LeetCode source. Evaluations on six lightweight models show improved CFG generation, especially with incomplete or incorrect inputs, and cross-language generalization to languages outside the fine-tuning set.","Finetuning Lightweight LLMs for Control Flow  \nGraph Generation  \nHanyu Zhang  \nDept. of Industrial and Management Systems Engineering Waseda University  \nTokyo, Japan  \n[bankzhy@akane.waseda.jp](bankzhy@akane.waseda.jp)  \nTomoji Kishi  \nDept. of Industrial and Management Systems Engineering Waseda University  \nTokyo, Japan  \n[kishi@waseda.jp](kishi@waseda.jp)  \nAbstract—Control Flow Graph (CFG) is an important program representations for software analysis, code understanding, and software maintenance. Traditional CFG generation techniques mainly rely on bytecode or abstract syntax trees. However, these approaches usually require complete, compilable, and syntaxerror-free code, which limits their applicability to incomplete or erroneous code. Furthermore, they often depend on languagespecific tools, making it difficult to support multiple programming languages in a unified manner. To address these limitations, this paper investigates the use of fine-tuned lightweight large language models (LLMs) for CFG generation. We first design a unified CFG output format and a task-specific fine-tuning prompt for CFG generation. Then, we construct a dataset based on an existing LeetCode dataset through automatic CFG generation and error augmentation. We evaluate the proposed approach on six lightweight LLM models, including three code-specific LLMs: CodeLlama, QwenCoder, and DeepSeekCoder; and three generalpurpose LLMs: Llama3.2-3B, Qwen-4B, and Phi-4B. The experimental results show that, through fine-tuning, lightweight LLMs achieve promising results for CFG generation, particularly when the input code is incomplete or erroneous. It also demonstrates cross-language generalization capability on programming language not included in the fine-tuning data.  \nKeywords-controlflow graph; large language model; finetuning; code graph generation; lightweight LLMs  \nI. INTRODUCTION  \nA Control Flow Graph (CFG) is a graph-based representation of all possible execution paths in a program, where nodes denote basic statements and edges represent the transfer of control between them. Since its theory was pointed out by Allen [1], CFG has become one of the most fundamental intermediate representations in program analysis and software engineering (SE) . It serves as the structural foundation for a wide range of SE downstream tasks [2], including static analysis, compiler optimization, 32  \nOver the past decades, numerous approaches and tools have been proposed to automatically generate CFGs from source code. Existing approaches could generally be categorized into two main groups: bytecode-based approaches and Abstract Syntax Tree (AST)-based approaches. Bytecode-based approaches generate CFGs from compiled intermediate representations, leveraging precise low-level execution semantics. The representative example are Soot [4] and WALA [3], which  \nDOI reference number: 10. 18293/SEKE2026-036  \ngenerate CFGs from Java bytecode and both have been widely adopted in static program analysis. In contrast, AST-based approaches operate directly on source code syntax structures, enabling higher-level structural analysis before compilation. Representative examples include Spoon [5] for Java and Py2Cfg [24] for Python, both of which construct CFGs from parsed syntax trees. These tools have significantly advanced CFG construction by improving automation and supporting multiple programming languages.  \nHowever, existing CFG generation approaches still suffer from several practical limitations. For bytecode-based approaches, source code must be complete and compilable before the CFG construction. This strict requirement greatly limits their usefulness in realistic development scenarios, where code may be incomplete, partially written, or under active modification. AST-based approaches relax this requirement by operating on uncompiled code, but they still depend on successful syntax parsing. In the presence of syntax errors, malformed statements, or incomplete code fragmen","cbCaijDrJEk6F7K5","https://ap.wps.com/l/cbCaijDrJEk6F7K5","pdf",606139,1,6,"English","en",105,"# Introduction\n## Background on CFG and generation approaches\n## Practical limitations of existing methods\n## Motivation for language-agnostic LLM-based CFG generation","[{\"question\":\"Why do traditional CFG generation methods struggle with real-world code?\",\"answer\":\"They typically require complete, compilable, syntax-error-free code and may fail or produce incorrect CFGs when code is incomplete, erroneous, or contains syntax mistakes.\"},{\"question\":\"How does the paper adapt the LLM approach for CFG generation?\",\"answer\":\"It introduces a unified CFG output format and a task-specific fine-tuning prompt tailored to generating CFGs from source code.\"},{\"question\":\"What evidence supports the effectiveness of lightweight LLM fine-tuning?\",\"answer\":\"Experiments on six lightweight models show promising CFG generation results, particularly for incomplete or erroneous inputs, and demonstrate cross-language generalization to programming languages not present in the fine-tuning data.\"}]",1784190804,15,{"code":4,"msg":30,"data":31},"ok",{"site_id":24,"language":23,"slug":32,"title":13,"keywords":33,"description":14,"schema_data":34,"social_meta":86,"head_meta":88,"extra_data":90,"updated_unix":27},"finetuning-lightweight-llms-for-control-flow-graph-generation","",{"@graph":35,"@context":85},[36,53,68],{"@type":37,"itemListElement":38},"BreadcrumbList",[39,43,47,50],{"item":40,"name":41,"@type":42,"position":20},"https://docshare.wps.com","Home","ListItem",{"item":44,"name":45,"@type":42,"position":46},"https://docshare.wps.com/document/","Document",2,{"item":48,"name":12,"@type":42,"position":49},"https://docshare.wps.com/document/research-report/",3,{"item":51,"name":13,"@type":42,"position":52},"https://docshare.wps.com/document/finetuning-lightweight-llms-for-control-flow-graph-generation/83831/",4,{"url":51,"name":13,"@type":54,"author":55,"headline":13,"publisher":57,"fileFormat":60,"inLanguage":23,"description":14,"dateModified":61,"datePublished":62,"encodingFormat":60,"isAccessibleForFree":63,"interactionStatistic":64},"DigitalDocument",{"name":9,"@type":56},"Person",{"url":40,"name":58,"@type":59},"DocShare","Organization","application/pdf","2026-07-17","2026-07-16",true,{"@type":65,"interactionType":66,"userInteractionCount":20},"InteractionCounter",{"@type":67},"ViewAction",{"@type":69,"mainEntity":70},"FAQPage",[71,77,81],{"name":72,"@type":73,"acceptedAnswer":74},"Why do traditional CFG generation methods struggle with real-world code?","Question",{"text":75,"@type":76},"They typically require complete, compilable, syntax-error-free code and may fail or produce incorrect CFGs when code is incomplete, erroneous, or contains syntax mistakes.","Answer",{"name":78,"@type":73,"acceptedAnswer":79},"How does the paper adapt the LLM approach for CFG generation?",{"text":80,"@type":76},"It introduces a unified CFG output format and a task-specific fine-tuning prompt tailored to generating CFGs from source code.",{"name":82,"@type":73,"acceptedAnswer":83},"What evidence supports the effectiveness of lightweight LLM fine-tuning?",{"text":84,"@type":76},"Experiments on six lightweight models show promising CFG generation results, particularly for incomplete or erroneous inputs, and demonstrate cross-language generalization to programming languages not present in the fine-tuning data.","https://schema.org",{"og:url":51,"og:type":87,"og:title":13,"og:site_name":58,"og:description":14},"article",{"robots":89,"canonical":51},"index,follow",{"doc_id":7,"site_id":24},{"code":4,"msg":5,"data":92},[93,97,101,105,110,114,119,122,127,130,134],{"id":20,"doc_module":4,"doc_module_name":45,"category_name":94,"show_sort_weight":95,"slug":96},"Story & Novel",90,"story-novel",{"id":46,"doc_module":4,"doc_module_name":45,"category_name":98,"show_sort_weight":99,"slug":100},"Literature",80,"literature",{"id":52,"doc_module":4,"doc_module_name":45,"category_name":102,"show_sort_weight":103,"slug":104},"Exam",70,"exam",{"id":106,"doc_module":4,"doc_module_name":45,"category_name":107,"show_sort_weight":108,"slug":109},5,"Comic",60,"comic",{"id":21,"doc_module":4,"doc_module_name":45,"category_name":111,"show_sort_weight":112,"slug":113},"Technology",50,"technology",{"id":115,"doc_module":4,"doc_module_name":45,"category_name":116,"show_sort_weight":117,"slug":118},7,"Healthcare",40,"healthcare",{"id":11,"doc_module":4,"doc_module_name":45,"category_name":12,"show_sort_weight":120,"slug":121},30,"research-report",{"id":123,"doc_module":4,"doc_module_name":45,"category_name":124,"show_sort_weight":125,"slug":126},9,"Religion & Spirituality",20,"religion-spirituality",{"id":125,"doc_module":4,"doc_module_name":45,"category_name":128,"show_sort_weight":125,"slug":129},"World Cup","world-cup",{"id":131,"doc_module":4,"doc_module_name":45,"category_name":132,"show_sort_weight":131,"slug":133},10,"Lifestyle","lifestyle",{"id":135,"doc_module":4,"doc_module_name":45,"category_name":136,"show_sort_weight":106,"slug":137},19,"General","general"]