[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"detail-sidebar-cat-0-en-105":3,"doc-seo-510244-105":59,"doc-detail-510244-en":130},{"code":4,"msg":5,"data":6},0,"success",[7,13,18,23,28,33,38,43,48,51,55],{"id":8,"doc_module":4,"doc_module_name":9,"category_name":10,"show_sort_weight":11,"slug":12},1,"Document","Story & Novel",90,"story-novel",{"id":14,"doc_module":4,"doc_module_name":9,"category_name":15,"show_sort_weight":16,"slug":17},2,"Literature",80,"literature",{"id":19,"doc_module":4,"doc_module_name":9,"category_name":20,"show_sort_weight":21,"slug":22},4,"Exam",70,"exam",{"id":24,"doc_module":4,"doc_module_name":9,"category_name":25,"show_sort_weight":26,"slug":27},5,"Comic",60,"comic",{"id":29,"doc_module":4,"doc_module_name":9,"category_name":30,"show_sort_weight":31,"slug":32},6,"Technology",50,"technology",{"id":34,"doc_module":4,"doc_module_name":9,"category_name":35,"show_sort_weight":36,"slug":37},7,"Healthcare",40,"healthcare",{"id":39,"doc_module":4,"doc_module_name":9,"category_name":40,"show_sort_weight":41,"slug":42},8,"Research & Report",30,"research-report",{"id":44,"doc_module":4,"doc_module_name":9,"category_name":45,"show_sort_weight":46,"slug":47},9,"Religion & Spirituality",20,"religion-spirituality",{"id":46,"doc_module":4,"doc_module_name":9,"category_name":49,"show_sort_weight":46,"slug":50},"World Cup","world-cup",{"id":52,"doc_module":4,"doc_module_name":9,"category_name":53,"show_sort_weight":52,"slug":54},10,"Lifestyle","lifestyle",{"id":56,"doc_module":4,"doc_module_name":9,"category_name":57,"show_sort_weight":24,"slug":58},19,"General","general",{"code":4,"msg":60,"data":61},"ok",{"site_id":62,"language":63,"slug":64,"title":65,"keywords":66,"description":67,"schema_data":68,"social_meta":123,"head_meta":125,"extra_data":127,"updated_unix":129},105,"en","compact-constraint-encoding-for-llm-code-generation-an-empirical-study-of-token-economics-and-constraint-compliance","Compact Constraint Encoding for LLM Code Generation - An Empirical Study of Token Economics and Constraint Compliance","","Large language models used for code generation rely on engineering constraints expressed in verbose natural language. This study tests whether compact, structured constraint headers can reduce prompt token consumption without lowering constraint compliance. Across six rounds covering 11 models, 16 benchmark tasks, and 830+ invocations, compact headers cut constraint-portion tokens by ~71% and full-prompt tokens by 25–30%, while constraint satisfaction rate remains statistically unchanged across encoding forms and propagation modes.",{"@graph":69,"@context":122},[70,84,105],{"@type":71,"itemListElement":72},"BreadcrumbList",[73,77,79,82],{"item":74,"name":75,"@type":76,"position":8},"https://docshare.wps.com","Home","ListItem",{"item":78,"name":9,"@type":76,"position":14},"https://docshare.wps.com/document/",{"item":80,"name":40,"@type":76,"position":81},"https://docshare.wps.com/document/research-report/",3,{"item":83,"name":65,"@type":76,"position":19},"https://docshare.wps.com/document/compact-constraint-encoding-for-llm-code-generation-an-empirical-study-of-token-economics-and-constraint-compliance/510244/",{"url":83,"name":65,"@type":85,"image":86,"author":91,"headline":65,"publisher":94,"fileFormat":97,"inLanguage":63,"description":67,"dateModified":98,"datePublished":99,"encodingFormat":97,"isAccessibleForFree":100,"interactionStatistic":101},"DigitalDocument",{"url":87,"@type":88,"width":89,"height":90},"https://docshare.wps.com/thumbnails/compact-constraint-encoding-for-llm-code-generation-an-empirical-study-of-token-economics-and-constraint-compliance/510244.png","ImageObject",300,407,{"name":92,"@type":93},"Dipper","Person",{"url":74,"name":95,"@type":96},"DocShare","Organization","application/pdf","2026-11-07","2026-10-05",true,{"@type":102,"interactionType":103,"userInteractionCount":44},"InteractionCounter",{"@type":104},"ViewAction",{"@type":106,"mainEntity":107},"FAQPage",[108,114,118],{"name":109,"@type":110,"acceptedAnswer":111},"What is the main problem addressed by the study?","Question",{"text":112,"@type":113},"The study asks whether verbose natural-language engineering constraints in LLM code generation can be replaced by compact, structured constraint headers without reducing compliance.","Answer",{"name":115,"@type":110,"acceptedAnswer":116},"How do compact constraint headers affect token usage?",{"text":117,"@type":113},"They reduce constraint-portion tokens by about 71% and full-prompt tokens by roughly 25–30%, with savings replicated across independent experimental rounds.",{"name":119,"@type":110,"acceptedAnswer":120},"Do compact headers improve constraint compliance?",{"text":121,"@type":113},"No. Under the tested task and model settings, constraint satisfaction rate is statistically invariant across encoding forms and propagation modes, with negligible observed effect sizes.","https://schema.org",{"og:url":83,"og:type":124,"og:title":65,"og:site_name":95,"og:description":67},"article",{"robots":126,"canonical":83},"index,follow",{"doc_id":128,"site_id":62},510244,1791398263,{"code":4,"msg":5,"data":131},{"doc_id":128,"user_id":132,"nickname":92,"user_avatar":133,"doc_module":4,"category_id":39,"category_name":40,"doc_title":65,"doc_description":67,"doc_content":134,"file_id":135,"file_url":136,"file_type":137,"file_size":138,"view_count":44,"is_deleted":4,"is_public":8,"is_downloadable":8,"audit_status":8,"page_count":139,"language":140,"language_code":63,"site_id":62,"html_lang":63,"table_of_contents":141,"faqs":142,"seo_title":143,"seo_description":67,"update_tm":144,"read_time":145,"preview_page_count":19,"preview_urls":146},1374404997633,"https://ap-avatar.wpscdn.com/davatar_a8503ba1806abce46bf441b54a3ca4cd","Compact Constraint Encoding for LLM Code Generation: An Empirical Study of Token Economics and Constraint  \nCompliance  \nHanzhang Tang  \nTencent · April 2026  \n\n| Abstract |\n| --- |\n| Large language models ( LLMs) used for code generation are typically guided by engineering constraints—technology choices, dependency restrictions, and architectural patterns—expressed in verbose natural language. We investigate whether compact, structured constraint headers can reduce prompt token consumption without degrading constraint compliance.\u003Cbr>Across six experimental rounds spanning 11 models, 16 benchmark tasks, and over 830 LLM invocations, we report three principal findings under the tested task and model settings. First, compact headers reduce constraint-portion tokens by approximately 71% and full-prompt tokens by 25–30%, a saving replicated across three independent rounds in both single-agent and multi-stage configurations. Second, we do not detect statistically significant differences in constraint satisfaction rate (CSR) across three encoding forms (n = 81–84 per group) or, in smaller-scale mechanism probes (n = 11–12 per condition), across four propagation modes; observed encoding effect sizes are negligible (Cliff 's δ \u003C 0.01 , difference 95% CI spanning ±2.6 percentage points), and this null pattern holds for both a frontier model (CSR = 0.944) and a second model verified across three independent execution rounds (CSR = 0.967) . A supplementary experiment ( EXP-D) with four non-CSS tasks and eight additional counterintuitive constraints provides additional non-CSS support for the encoding null result. Third, under our task suite, the largest observed sources of compliance variance are constraint type (Δ = 9 percentage points between normal and counter-intuitive constraints) and task domain: counter-intuitive constraints opposing model defaults fail at rates of 10–100%(dominated by CSSrelated styling constraints in the frontend domain, with non-CSS failures at 8.3% concentrated in urllib prohibition), while conventional constraints achieve 99%+ compliance regardless of encoding. Under our tested task and model settings, the primary observable benefit of compact constraint encoding is token reduction rather than measurable compliance improvement.\u003Cbr>We additionally report that model self-assessments systematically overestimate constraint compliance relative to rule-based scoring, revealing a gap between constraint understanding and constraint execution. These findings suggest that, under the tested conditions, engineering effort toward constraint compliance is better directed at model selection and constraint design than at prompt formatting.\u003Cbr>Keywords: LLM code generation, prompt engineering, constraint compliance, token economics, multi-agent pipeline, empirical study, null result |\n| 1. Introduction |\n\n1.1 Problem Statement  \nModern LLM-assisted code generation relies on engineering constraints communicated through natural-language prompts. Atypical constraint block—specifying framework choices, dependency restrictions, styling requirements, and output format—can span hundreds of tokens. In multi-agent architectures where constraints are injected at each pipeline stage, these costs multiply linearly with pipeline depth.  \nThis raises a practical question: can verbose constraint descriptions be replaced by a compact, structured encoding without sacrificing the model 's ability to follow them?  \n1.2 The Constraint Header Approach  \nWe define a constraint header as a single-line, tag-based encoding of engineering constraints. For example:  \nNL-full (587 chars) :  \n> 1 . Use TypeScript with React framework. 2. Use CSS Modules for all styling. Do not use Tailwind CSS... 3. Implement drag-anddrop using the native HTML5 API only. Do not use react-dnd...  \nHeader (129 chars) :  \n> [L]TS [F]React [Y]CSS_MODULES [!Y]NO_TW [!D]NO_DND_LIB [DRAG]HTML5  \nThis encoding reduces constraint character count by ~ 78% and estimated token count","cbCaimqD3sYnyCqv","https://ap.wps.com/l/cbCaimqD3sYnyCqv","pdf",780888,18,"English","# 1. Introduction\n## 1.1 Problem Statement\n## 1.2 The Constraint Header Approach\n## 1.3 What We Expected vs. What We Found\n## 1.4 Contributions","[{\"question\":\"What is the main problem addressed by the study?\",\"answer\":\"The study asks whether verbose natural-language engineering constraints in LLM code generation can be replaced by compact, structured constraint headers without reducing compliance.\"},{\"question\":\"How do compact constraint headers affect token usage?\",\"answer\":\"They reduce constraint-portion tokens by about 71% and full-prompt tokens by roughly 25–30%, with savings replicated across independent experimental rounds.\"},{\"question\":\"Do compact headers improve constraint compliance?\",\"answer\":\"No. Under the tested task and model settings, constraint satisfaction rate is statistically invariant across encoding forms and propagation modes, with negligible observed effect sizes.\"}]","Compact Constraint Encoding for LLM Code Generation - An Empirical Study of Token Economics and Constraint Compliance | PDF",1791239870,45,[147,151,155,159],{"page_no":8,"url":148,"width":149,"height":150},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-17/362839585871e7702cf343ef0d872d0f.webp",983,1391,{"page_no":14,"url":152,"width":153,"height":154},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-17/c78662840f658f2648ccb089b4fd7648.webp",982,1389,{"page_no":81,"url":156,"width":157,"height":158},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-17/04fb74b11b0cccd410b1ee705570282c.webp",981,1388,{"page_no":19,"url":160,"width":161,"height":162},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-17/09e6a8bf4a37f92761e8eaa6c31de553.webp",980,1387]