[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"doc-detail-81492-en":3,"doc-seo-81492-105":30,"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":21,"is_downloadable":21,"audit_status":21,"page_count":22,"language":23,"language_code":24,"site_id":25,"html_lang":24,"table_of_contents":26,"faqs":27,"seo_title":13,"seo_description":14,"update_tm":28,"read_time":29},81492,1099513958607,"Jiven","https://ap-avatar.wpscdn.com/avatar/100002390cf8733938c?x-image-process=image/resize,m_fixed,w_180,h_180&k=1778829742770036399",8,"Research & Report","Efficient and Universal Watermarking for LLM-Generated Code Detection","Large language models (LLMs) significantly improve the usability of AI-generated code, but they also introduce accountability risks such as academic dishonesty and malicious code creation. Detecting whether code is AI-generated is therefore essential. Watermarking can provide implicit provenance, yet prior code approaches suffer from weak universality and high time/memory overhead. This work proposes ACW, a training-free plug-and-play watermarking method using semantic-preserving, idempotent code transformations for efficient and robust detection across different LLMs.","Efficient and Universal Watermarking for LLM-Generated Code Detection  \nBoquan Li, Zirui Fu, Mengdi Zhang, Peixin Zhang, Jun Sun and Xingmei Wang  \narXiv :2402 .075 18v 5 [ cs .CR] 10 Jul 2026  \nAbstract—Large language models (LLMs) have significantly enhanced the usability of AI-generated code, providing effective assistance to programmers. This advancement also raises ethical and legal concerns, such as academic dishonesty and the generation of malicious code. For accountability, it is imperative to detect whether a piece of code is AI-generated. Watermarking is broadly considered a promising solution and has been successfully applied to identify LLM-generated text. However, existing efforts on code are far from ideal, suffering from limited universality and excessive time and memory consumption. In this work, we propose a plugand-play watermarking approach for AI-generated code detection, named ACW (AI Code Watermarking). ACW is training-free and works by selectively applying a set of carefully-designed, semanticpreserving and idempotent code transformations to LLM code outputs. The presence or absence of the transformations serves as implicit watermarks, enabling the detection of AI-generated code. Our experimental results show that ACW effectively and efficiently detects AI-generated code, preserves code utility, and is resilient against potential code disruptions. Especially, ACWis universal across different LLMs, addressing the limitations of existing approaches.  \nIndex Terms—Large language model, code generation, watermarking, code transformation.  \nI. INTRODUCTION  \nLARGE language models (LLMs) [1] mark a milestone in  \nthe progress of artificial intelligence (AI) and prompt a variety of applications [2], one of which is code generation. Multiple LLMs, such as ChatGPT [3] and Qwen2.5-Coder [4], are widely adopted for code generation. While LLMs improve programmers’ productivity significantly, they can be misused as well. For instance, Langton [5] showed how an attacker could use ChatGPT to construct ransomware. In addition, students may dishonestly leverage LLMs to generate programming assignments. For accountability, it is an urgent need to detect whether a piece of code is AI-generated.  \nExisting efforts on detecting AI-generated content mostly focus on text [6] and are broadly categorized into two groups. The first group includes passive detectors [7, 8, 9, 10] which build binary classifiers to distinguish between AI-generated and human-written text. The second group focuses on watermarking [11, 12, 13, 14, 15, 16, 17], which actively embeds hidden ‘patterns’ (a.k.a. watermarks) into AI-generated text, and determines whether given text is generated based on the presence of the pattern. As the state-of-the-art approaches,  \nBoquan Li, Zirui Fu, Xingmei Wang are with College of Computer Science and Technology, Harbin Engineering University. Mengdi Zhang, Peixin Zhang, Jun Sun are with School of Computing and Information Systems, Singapore Management University.  \nCorresponding to Peixin Zhang [at pxzhang@smu.edu.sg](at pxzhang@smu.edu.sg) and Xingmei Wang [at wangxingmei@hrbeu.edu.cn](at wangxingmei@hrbeu.edu.cn).  \nKirchenbauer et al. [11] propose WLLM (Watermarking LLMs), which splits a vocabulary into ‘green’ and ‘red’ tokens and softly promotes the ‘green’ ones during text generation, thereby a given piece of text can be concluded AI-generated if abundant‘green’ tokens are present. Giboulot and Furon [12] propose WaterMax, which embeds watermarks by generating multiple candidate text chunks from an LLM and selecting the candidates that maximize a predefined test statistic, and then detects the watermark by evaluating the same statistic on given text.  \nIn comparison to text, detecting AI-generated code based on watermarking remains an emerging task, with state-of-the-art approaches extending from WLLM. Lee et al. [18] propose a selective watermarking technique via entropy thresholding named SWEET, which prompts","cbCailQZfDle0DjY","https://ap.wps.com/l/cbCailQZfDle0DjY","pdf",1246527,3,1,16,"English","en",105,"# Introduction\n## Background on LLM code generation and misuse\n## Related work: text watermarking and code watermarking\n## Limitations of existing approaches\n# Method: ACW\n## Design of semantic-preserving, idempotent transformations\n## Watermark embedding and identification","[{\"question\":\"What problem does ACW address?\",\"answer\":\"ACW targets the challenge of detecting whether code was generated by an LLM, while avoiding limitations of prior watermarking methods such as poor universality and excessive time/memory use.\"},{\"question\":\"How does ACW embed a watermark in AI-generated code?\",\"answer\":\"ACW post-processes LLM outputs by selectively applying a set of designed, semantic-preserving and idempotent code transformations. The set of applied transformations acts as implicit watermarks.\"},{\"question\":\"Why is the proposed approach efficient and robust?\",\"answer\":\"ACW is training-free and uses transformations that enable straightforward watermark identification by checking whether repeatedly applying a transformation changes the code, and the method is reported to be resilient against code disruptions and universal across different LLMs.\"}]",1784173793,40,{"code":4,"msg":31,"data":32},"ok",{"site_id":25,"language":24,"slug":33,"title":13,"keywords":34,"description":14,"schema_data":35,"social_meta":86,"head_meta":88,"extra_data":90,"updated_unix":28},"efficient-and-universal-watermarking-for-llm-generated-code-detection","",{"@graph":36,"@context":85},[37,53,68],{"@type":38,"itemListElement":39},"BreadcrumbList",[40,44,48,50],{"item":41,"name":42,"@type":43,"position":21},"https://docshare.wps.com","Home","ListItem",{"item":45,"name":46,"@type":43,"position":47},"https://docshare.wps.com/document/","Document",2,{"item":49,"name":12,"@type":43,"position":20},"https://docshare.wps.com/document/research-report/",{"item":51,"name":13,"@type":43,"position":52},"https://docshare.wps.com/document/efficient-and-universal-watermarking-for-llm-generated-code-detection/81492/",4,{"url":51,"name":13,"@type":54,"author":55,"headline":13,"publisher":57,"fileFormat":60,"inLanguage":24,"description":14,"dateModified":61,"datePublished":62,"encodingFormat":60,"isAccessibleForFree":63,"interactionStatistic":64},"DigitalDocument",{"name":9,"@type":56},"Person",{"url":41,"name":58,"@type":59},"DocShare","Organization","application/pdf","2026-07-24","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},"What problem does ACW address?","Question",{"text":75,"@type":76},"ACW targets the challenge of detecting whether code was generated by an LLM, while avoiding limitations of prior watermarking methods such as poor universality and excessive time/memory use.","Answer",{"name":78,"@type":73,"acceptedAnswer":79},"How does ACW embed a watermark in AI-generated code?",{"text":80,"@type":76},"ACW post-processes LLM outputs by selectively applying a set of designed, semantic-preserving and idempotent code transformations. The set of applied transformations acts as implicit watermarks.",{"name":82,"@type":73,"acceptedAnswer":83},"Why is the proposed approach efficient and robust?",{"text":84,"@type":76},"ACW is training-free and uses transformations that enable straightforward watermark identification by checking whether repeatedly applying a transformation changes the code, and the method is reported to be resilient against code disruptions and universal across different LLMs.","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":25},{"code":4,"msg":5,"data":92},[93,97,101,105,110,115,119,122,127,130,134],{"id":21,"doc_module":4,"doc_module_name":46,"category_name":94,"show_sort_weight":95,"slug":96},"Story & Novel",90,"story-novel",{"id":47,"doc_module":4,"doc_module_name":46,"category_name":98,"show_sort_weight":99,"slug":100},"Literature",80,"literature",{"id":52,"doc_module":4,"doc_module_name":46,"category_name":102,"show_sort_weight":103,"slug":104},"Exam",70,"exam",{"id":106,"doc_module":4,"doc_module_name":46,"category_name":107,"show_sort_weight":108,"slug":109},5,"Comic",60,"comic",{"id":111,"doc_module":4,"doc_module_name":46,"category_name":112,"show_sort_weight":113,"slug":114},6,"Technology",50,"technology",{"id":116,"doc_module":4,"doc_module_name":46,"category_name":117,"show_sort_weight":29,"slug":118},7,"Healthcare","healthcare",{"id":11,"doc_module":4,"doc_module_name":46,"category_name":12,"show_sort_weight":120,"slug":121},30,"research-report",{"id":123,"doc_module":4,"doc_module_name":46,"category_name":124,"show_sort_weight":125,"slug":126},9,"Religion & Spirituality",20,"religion-spirituality",{"id":125,"doc_module":4,"doc_module_name":46,"category_name":128,"show_sort_weight":125,"slug":129},"World Cup","world-cup",{"id":131,"doc_module":4,"doc_module_name":46,"category_name":132,"show_sort_weight":131,"slug":133},10,"Lifestyle","lifestyle",{"id":135,"doc_module":4,"doc_module_name":46,"category_name":136,"show_sort_weight":106,"slug":137},19,"General","general"]