[{"data":1,"prerenderedAt":1395},["ShallowReactive",2],{"content-/ai/prompt-optimization":3,"related-ai":1365},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"keywords":10,"author":11,"date":12,"category":13,"image":14,"body":15,"_type":1359,"_id":1360,"_source":1361,"_file":1362,"_stem":1363,"_extension":1364},"/ai/prompt-optimization","ai",false,"","自动化提示词优化体系","构建基于数据驱动与自动评估的提示词迭代优化系统","提示词优化, A/B测试, 自动评估, DSPy, 软提示, HTMLPAGE","HTMLPAGE","2025-11-27","AI 技术","/content-images/ai/ai.jpg",{"type":16,"children":17,"toc":1337},"root",[18,26,33,39,44,130,135,144,780,786,791,797,802,827,833,838,859,865,870,891,897,902,907,940,948,1181,1187,1192,1197,1230,1236,1242,1247,1270,1276,1281,1287,1318,1322,1331],{"type":19,"tag":20,"props":21,"children":22},"element","p",{},[23],{"type":24,"value":25},"text","在 HTMLPAGE，我们不依赖\"提示词工程师\"的直觉来编写 Prompt，而是建立了一套科学的、数据驱动的自动化优化体系。通过引入 A/B 测试、自动评估指标和进化算法，我们将 Prompt Optimization 从一门玄学变成了一门精确的工程学科。",{"type":19,"tag":27,"props":28,"children":30},"h2",{"id":29},"自动化优化架构-apo",[31],{"type":24,"value":32},"🧬 自动化优化架构 (APO)",{"type":19,"tag":34,"props":35,"children":37},"h3",{"id":36},"基于梯度的离散优化",[38],{"type":24,"value":36},{"type":19,"tag":20,"props":40,"children":41},{},[42],{"type":24,"value":43},"我们采用了类似 DSPy (Declarative Self-improving Language Programs) 的架构，将 Prompt 视为模型参数的一部分，通过优化算法自动搜索最佳的 Prompt 组合。",{"type":19,"tag":45,"props":46,"children":50},"pre",{"className":47,"code":48,"language":49,"meta":7,"style":7},"language-mermaid shiki shiki-themes github-dark github-dark","graph TD\n    A[初始 Prompt] --> B{优化器 (Optimizer)}\n    B --> C[生成变体 (Variants)]\n    C --> D[评估集 (Dev Set)]\n    D --> E{评分模型 (Scorer)}\n    E --> F[计算指标]\n    F --> B\n    F --> G[最佳 Prompt]\n","mermaid",[51],{"type":19,"tag":52,"props":53,"children":54},"code",{"__ignoreMap":7},[55,67,76,85,94,103,112,121],{"type":19,"tag":56,"props":57,"children":60},"span",{"class":58,"line":59},"line",1,[61],{"type":19,"tag":56,"props":62,"children":64},{"style":63},"--shiki-default:#E1E4E8;--shiki-dark:#E1E4E8",[65],{"type":24,"value":66},"graph TD\n",{"type":19,"tag":56,"props":68,"children":70},{"class":58,"line":69},2,[71],{"type":19,"tag":56,"props":72,"children":73},{"style":63},[74],{"type":24,"value":75},"    A[初始 Prompt] --> B{优化器 (Optimizer)}\n",{"type":19,"tag":56,"props":77,"children":79},{"class":58,"line":78},3,[80],{"type":19,"tag":56,"props":81,"children":82},{"style":63},[83],{"type":24,"value":84},"    B --> C[生成变体 (Variants)]\n",{"type":19,"tag":56,"props":86,"children":88},{"class":58,"line":87},4,[89],{"type":19,"tag":56,"props":90,"children":91},{"style":63},[92],{"type":24,"value":93},"    C --> D[评估集 (Dev Set)]\n",{"type":19,"tag":56,"props":95,"children":97},{"class":58,"line":96},5,[98],{"type":19,"tag":56,"props":99,"children":100},{"style":63},[101],{"type":24,"value":102},"    D --> E{评分模型 (Scorer)}\n",{"type":19,"tag":56,"props":104,"children":106},{"class":58,"line":105},6,[107],{"type":19,"tag":56,"props":108,"children":109},{"style":63},[110],{"type":24,"value":111},"    E --> F[计算指标]\n",{"type":19,"tag":56,"props":113,"children":115},{"class":58,"line":114},7,[116],{"type":19,"tag":56,"props":117,"children":118},{"style":63},[119],{"type":24,"value":120},"    F --> B\n",{"type":19,"tag":56,"props":122,"children":124},{"class":58,"line":123},8,[125],{"type":19,"tag":56,"props":126,"children":127},{"style":63},[128],{"type":24,"value":129},"    F --> G[最佳 Prompt]\n",{"type":19,"tag":34,"props":131,"children":133},{"id":132},"优化算法实现",[134],{"type":24,"value":132},{"type":19,"tag":20,"props":136,"children":137},{},[138],{"type":19,"tag":139,"props":140,"children":141},"strong",{},[142],{"type":24,"value":143},"基于 LLM 的进化策略",{"type":19,"tag":45,"props":145,"children":149},{"className":146,"code":147,"language":148,"meta":7,"style":7},"language-python shiki shiki-themes github-dark github-dark","class PromptOptimizer:\n    def __init__(self):\n        self.mutator = PromptMutator()\n        self.evaluator = CodeQualityEvaluator()\n    \n    def optimize(self, base_prompt, dataset, generations=5):\n        population = [base_prompt]\n        \n        for gen in range(generations):\n            # 1. 变异：生成新的 Prompt 候选者\n            candidates = []\n            for p in population:\n                candidates.extend(self.mutator.mutate(p, strategy='rewrite_instructions'))\n                candidates.extend(self.mutator.mutate(p, strategy='add_few_shot'))\n            \n            # 2. 评估：在验证集上测试每个候选者\n            scores = []\n            for cand in candidates:\n                score = self.evaluate_prompt(cand, dataset)\n                scores.append((cand, score))\n            \n            # 3. 选择：保留表现最好的 Top-K\n            population = [p for p, s in sorted(scores, key=lambda x: x[1], reverse=True)[:3]]\n            \n            print(f\"Generation {gen}: Best Score = {scores[0][1]}\")\n            \n        return population[0]\n","python",[150],{"type":19,"tag":52,"props":151,"children":152},{"__ignoreMap":7},[153,173,192,215,236,244,275,292,300,329,339,357,380,420,453,462,471,488,510,533,542,550,559,655,663,749,757],{"type":19,"tag":56,"props":154,"children":155},{"class":58,"line":59},[156,162,168],{"type":19,"tag":56,"props":157,"children":159},{"style":158},"--shiki-default:#F97583;--shiki-dark:#F97583",[160],{"type":24,"value":161},"class",{"type":19,"tag":56,"props":163,"children":165},{"style":164},"--shiki-default:#B392F0;--shiki-dark:#B392F0",[166],{"type":24,"value":167}," PromptOptimizer",{"type":19,"tag":56,"props":169,"children":170},{"style":63},[171],{"type":24,"value":172},":\n",{"type":19,"tag":56,"props":174,"children":175},{"class":58,"line":69},[176,181,187],{"type":19,"tag":56,"props":177,"children":178},{"style":158},[179],{"type":24,"value":180},"    def",{"type":19,"tag":56,"props":182,"children":184},{"style":183},"--shiki-default:#79B8FF;--shiki-dark:#79B8FF",[185],{"type":24,"value":186}," __init__",{"type":19,"tag":56,"props":188,"children":189},{"style":63},[190],{"type":24,"value":191},"(self):\n",{"type":19,"tag":56,"props":193,"children":194},{"class":58,"line":78},[195,200,205,210],{"type":19,"tag":56,"props":196,"children":197},{"style":183},[198],{"type":24,"value":199},"        self",{"type":19,"tag":56,"props":201,"children":202},{"style":63},[203],{"type":24,"value":204},".mutator ",{"type":19,"tag":56,"props":206,"children":207},{"style":158},[208],{"type":24,"value":209},"=",{"type":19,"tag":56,"props":211,"children":212},{"style":63},[213],{"type":24,"value":214}," PromptMutator()\n",{"type":19,"tag":56,"props":216,"children":217},{"class":58,"line":87},[218,222,227,231],{"type":19,"tag":56,"props":219,"children":220},{"style":183},[221],{"type":24,"value":199},{"type":19,"tag":56,"props":223,"children":224},{"style":63},[225],{"type":24,"value":226},".evaluator ",{"type":19,"tag":56,"props":228,"children":229},{"style":158},[230],{"type":24,"value":209},{"type":19,"tag":56,"props":232,"children":233},{"style":63},[234],{"type":24,"value":235}," CodeQualityEvaluator()\n",{"type":19,"tag":56,"props":237,"children":238},{"class":58,"line":96},[239],{"type":19,"tag":56,"props":240,"children":241},{"style":63},[242],{"type":24,"value":243},"    \n",{"type":19,"tag":56,"props":245,"children":246},{"class":58,"line":105},[247,251,256,261,265,270],{"type":19,"tag":56,"props":248,"children":249},{"style":158},[250],{"type":24,"value":180},{"type":19,"tag":56,"props":252,"children":253},{"style":164},[254],{"type":24,"value":255}," optimize",{"type":19,"tag":56,"props":257,"children":258},{"style":63},[259],{"type":24,"value":260},"(self, base_prompt, dataset, generations",{"type":19,"tag":56,"props":262,"children":263},{"style":158},[264],{"type":24,"value":209},{"type":19,"tag":56,"props":266,"children":267},{"style":183},[268],{"type":24,"value":269},"5",{"type":19,"tag":56,"props":271,"children":272},{"style":63},[273],{"type":24,"value":274},"):\n",{"type":19,"tag":56,"props":276,"children":277},{"class":58,"line":114},[278,283,287],{"type":19,"tag":56,"props":279,"children":280},{"style":63},[281],{"type":24,"value":282},"        population ",{"type":19,"tag":56,"props":284,"children":285},{"style":158},[286],{"type":24,"value":209},{"type":19,"tag":56,"props":288,"children":289},{"style":63},[290],{"type":24,"value":291}," [base_prompt]\n",{"type":19,"tag":56,"props":293,"children":294},{"class":58,"line":123},[295],{"type":19,"tag":56,"props":296,"children":297},{"style":63},[298],{"type":24,"value":299},"        \n",{"type":19,"tag":56,"props":301,"children":303},{"class":58,"line":302},9,[304,309,314,319,324],{"type":19,"tag":56,"props":305,"children":306},{"style":158},[307],{"type":24,"value":308},"        for",{"type":19,"tag":56,"props":310,"children":311},{"style":63},[312],{"type":24,"value":313}," gen ",{"type":19,"tag":56,"props":315,"children":316},{"style":158},[317],{"type":24,"value":318},"in",{"type":19,"tag":56,"props":320,"children":321},{"style":183},[322],{"type":24,"value":323}," range",{"type":19,"tag":56,"props":325,"children":326},{"style":63},[327],{"type":24,"value":328},"(generations):\n",{"type":19,"tag":56,"props":330,"children":332},{"class":58,"line":331},10,[333],{"type":19,"tag":56,"props":334,"children":336},{"style":335},"--shiki-default:#6A737D;--shiki-dark:#6A737D",[337],{"type":24,"value":338},"            # 1. 变异：生成新的 Prompt 候选者\n",{"type":19,"tag":56,"props":340,"children":342},{"class":58,"line":341},11,[343,348,352],{"type":19,"tag":56,"props":344,"children":345},{"style":63},[346],{"type":24,"value":347},"            candidates ",{"type":19,"tag":56,"props":349,"children":350},{"style":158},[351],{"type":24,"value":209},{"type":19,"tag":56,"props":353,"children":354},{"style":63},[355],{"type":24,"value":356}," []\n",{"type":19,"tag":56,"props":358,"children":360},{"class":58,"line":359},12,[361,366,371,375],{"type":19,"tag":56,"props":362,"children":363},{"style":158},[364],{"type":24,"value":365},"            for",{"type":19,"tag":56,"props":367,"children":368},{"style":63},[369],{"type":24,"value":370}," p ",{"type":19,"tag":56,"props":372,"children":373},{"style":158},[374],{"type":24,"value":318},{"type":19,"tag":56,"props":376,"children":377},{"style":63},[378],{"type":24,"value":379}," population:\n",{"type":19,"tag":56,"props":381,"children":383},{"class":58,"line":382},13,[384,389,394,399,405,409,415],{"type":19,"tag":56,"props":385,"children":386},{"style":63},[387],{"type":24,"value":388},"                candidates.extend(",{"type":19,"tag":56,"props":390,"children":391},{"style":183},[392],{"type":24,"value":393},"self",{"type":19,"tag":56,"props":395,"children":396},{"style":63},[397],{"type":24,"value":398},".mutator.mutate(p, ",{"type":19,"tag":56,"props":400,"children":402},{"style":401},"--shiki-default:#FFAB70;--shiki-dark:#FFAB70",[403],{"type":24,"value":404},"strategy",{"type":19,"tag":56,"props":406,"children":407},{"style":158},[408],{"type":24,"value":209},{"type":19,"tag":56,"props":410,"children":412},{"style":411},"--shiki-default:#9ECBFF;--shiki-dark:#9ECBFF",[413],{"type":24,"value":414},"'rewrite_instructions'",{"type":19,"tag":56,"props":416,"children":417},{"style":63},[418],{"type":24,"value":419},"))\n",{"type":19,"tag":56,"props":421,"children":423},{"class":58,"line":422},14,[424,428,432,436,440,444,449],{"type":19,"tag":56,"props":425,"children":426},{"style":63},[427],{"type":24,"value":388},{"type":19,"tag":56,"props":429,"children":430},{"style":183},[431],{"type":24,"value":393},{"type":19,"tag":56,"props":433,"children":434},{"style":63},[435],{"type":24,"value":398},{"type":19,"tag":56,"props":437,"children":438},{"style":401},[439],{"type":24,"value":404},{"type":19,"tag":56,"props":441,"children":442},{"style":158},[443],{"type":24,"value":209},{"type":19,"tag":56,"props":445,"children":446},{"style":411},[447],{"type":24,"value":448},"'add_few_shot'",{"type":19,"tag":56,"props":450,"children":451},{"style":63},[452],{"type":24,"value":419},{"type":19,"tag":56,"props":454,"children":456},{"class":58,"line":455},15,[457],{"type":19,"tag":56,"props":458,"children":459},{"style":63},[460],{"type":24,"value":461},"            \n",{"type":19,"tag":56,"props":463,"children":465},{"class":58,"line":464},16,[466],{"type":19,"tag":56,"props":467,"children":468},{"style":335},[469],{"type":24,"value":470},"            # 2. 评估：在验证集上测试每个候选者\n",{"type":19,"tag":56,"props":472,"children":474},{"class":58,"line":473},17,[475,480,484],{"type":19,"tag":56,"props":476,"children":477},{"style":63},[478],{"type":24,"value":479},"            scores ",{"type":19,"tag":56,"props":481,"children":482},{"style":158},[483],{"type":24,"value":209},{"type":19,"tag":56,"props":485,"children":486},{"style":63},[487],{"type":24,"value":356},{"type":19,"tag":56,"props":489,"children":491},{"class":58,"line":490},18,[492,496,501,505],{"type":19,"tag":56,"props":493,"children":494},{"style":158},[495],{"type":24,"value":365},{"type":19,"tag":56,"props":497,"children":498},{"style":63},[499],{"type":24,"value":500}," cand ",{"type":19,"tag":56,"props":502,"children":503},{"style":158},[504],{"type":24,"value":318},{"type":19,"tag":56,"props":506,"children":507},{"style":63},[508],{"type":24,"value":509}," candidates:\n",{"type":19,"tag":56,"props":511,"children":513},{"class":58,"line":512},19,[514,519,523,528],{"type":19,"tag":56,"props":515,"children":516},{"style":63},[517],{"type":24,"value":518},"                score ",{"type":19,"tag":56,"props":520,"children":521},{"style":158},[522],{"type":24,"value":209},{"type":19,"tag":56,"props":524,"children":525},{"style":183},[526],{"type":24,"value":527}," self",{"type":19,"tag":56,"props":529,"children":530},{"style":63},[531],{"type":24,"value":532},".evaluate_prompt(cand, dataset)\n",{"type":19,"tag":56,"props":534,"children":536},{"class":58,"line":535},20,[537],{"type":19,"tag":56,"props":538,"children":539},{"style":63},[540],{"type":24,"value":541},"                scores.append((cand, score))\n",{"type":19,"tag":56,"props":543,"children":545},{"class":58,"line":544},21,[546],{"type":19,"tag":56,"props":547,"children":548},{"style":63},[549],{"type":24,"value":461},{"type":19,"tag":56,"props":551,"children":553},{"class":58,"line":552},22,[554],{"type":19,"tag":56,"props":555,"children":556},{"style":335},[557],{"type":24,"value":558},"            # 3. 选择：保留表现最好的 Top-K\n",{"type":19,"tag":56,"props":560,"children":562},{"class":58,"line":561},23,[563,568,572,577,582,587,591,596,601,606,611,616,621,626,631,635,640,645,650],{"type":19,"tag":56,"props":564,"children":565},{"style":63},[566],{"type":24,"value":567},"            population ",{"type":19,"tag":56,"props":569,"children":570},{"style":158},[571],{"type":24,"value":209},{"type":19,"tag":56,"props":573,"children":574},{"style":63},[575],{"type":24,"value":576}," [p ",{"type":19,"tag":56,"props":578,"children":579},{"style":158},[580],{"type":24,"value":581},"for",{"type":19,"tag":56,"props":583,"children":584},{"style":63},[585],{"type":24,"value":586}," p, s ",{"type":19,"tag":56,"props":588,"children":589},{"style":158},[590],{"type":24,"value":318},{"type":19,"tag":56,"props":592,"children":593},{"style":183},[594],{"type":24,"value":595}," sorted",{"type":19,"tag":56,"props":597,"children":598},{"style":63},[599],{"type":24,"value":600},"(scores, ",{"type":19,"tag":56,"props":602,"children":603},{"style":401},[604],{"type":24,"value":605},"key",{"type":19,"tag":56,"props":607,"children":608},{"style":158},[609],{"type":24,"value":610},"=lambda",{"type":19,"tag":56,"props":612,"children":613},{"style":63},[614],{"type":24,"value":615}," x: x[",{"type":19,"tag":56,"props":617,"children":618},{"style":183},[619],{"type":24,"value":620},"1",{"type":19,"tag":56,"props":622,"children":623},{"style":63},[624],{"type":24,"value":625},"], ",{"type":19,"tag":56,"props":627,"children":628},{"style":401},[629],{"type":24,"value":630},"reverse",{"type":19,"tag":56,"props":632,"children":633},{"style":158},[634],{"type":24,"value":209},{"type":19,"tag":56,"props":636,"children":637},{"style":183},[638],{"type":24,"value":639},"True",{"type":19,"tag":56,"props":641,"children":642},{"style":63},[643],{"type":24,"value":644},")[:",{"type":19,"tag":56,"props":646,"children":647},{"style":183},[648],{"type":24,"value":649},"3",{"type":19,"tag":56,"props":651,"children":652},{"style":63},[653],{"type":24,"value":654},"]]\n",{"type":19,"tag":56,"props":656,"children":658},{"class":58,"line":657},24,[659],{"type":19,"tag":56,"props":660,"children":661},{"style":63},[662],{"type":24,"value":461},{"type":19,"tag":56,"props":664,"children":666},{"class":58,"line":665},25,[667,672,677,682,687,692,697,702,707,711,716,721,726,730,735,739,744],{"type":19,"tag":56,"props":668,"children":669},{"style":183},[670],{"type":24,"value":671},"            print",{"type":19,"tag":56,"props":673,"children":674},{"style":63},[675],{"type":24,"value":676},"(",{"type":19,"tag":56,"props":678,"children":679},{"style":158},[680],{"type":24,"value":681},"f",{"type":19,"tag":56,"props":683,"children":684},{"style":411},[685],{"type":24,"value":686},"\"Generation ",{"type":19,"tag":56,"props":688,"children":689},{"style":183},[690],{"type":24,"value":691},"{",{"type":19,"tag":56,"props":693,"children":694},{"style":63},[695],{"type":24,"value":696},"gen",{"type":19,"tag":56,"props":698,"children":699},{"style":183},[700],{"type":24,"value":701},"}",{"type":19,"tag":56,"props":703,"children":704},{"style":411},[705],{"type":24,"value":706},": Best Score = ",{"type":19,"tag":56,"props":708,"children":709},{"style":183},[710],{"type":24,"value":691},{"type":19,"tag":56,"props":712,"children":713},{"style":63},[714],{"type":24,"value":715},"scores[",{"type":19,"tag":56,"props":717,"children":718},{"style":183},[719],{"type":24,"value":720},"0",{"type":19,"tag":56,"props":722,"children":723},{"style":63},[724],{"type":24,"value":725},"][",{"type":19,"tag":56,"props":727,"children":728},{"style":183},[729],{"type":24,"value":620},{"type":19,"tag":56,"props":731,"children":732},{"style":63},[733],{"type":24,"value":734},"]",{"type":19,"tag":56,"props":736,"children":737},{"style":183},[738],{"type":24,"value":701},{"type":19,"tag":56,"props":740,"children":741},{"style":411},[742],{"type":24,"value":743},"\"",{"type":19,"tag":56,"props":745,"children":746},{"style":63},[747],{"type":24,"value":748},")\n",{"type":19,"tag":56,"props":750,"children":752},{"class":58,"line":751},26,[753],{"type":19,"tag":56,"props":754,"children":755},{"style":63},[756],{"type":24,"value":461},{"type":19,"tag":56,"props":758,"children":760},{"class":58,"line":759},27,[761,766,771,775],{"type":19,"tag":56,"props":762,"children":763},{"style":158},[764],{"type":24,"value":765},"        return",{"type":19,"tag":56,"props":767,"children":768},{"style":63},[769],{"type":24,"value":770}," population[",{"type":19,"tag":56,"props":772,"children":773},{"style":183},[774],{"type":24,"value":720},{"type":19,"tag":56,"props":776,"children":777},{"style":63},[778],{"type":24,"value":779},"]\n",{"type":19,"tag":27,"props":781,"children":783},{"id":782},"评估指标体系",[784],{"type":24,"value":785},"📊 评估指标体系",{"type":19,"tag":20,"props":787,"children":788},{},[789],{"type":24,"value":790},"为了量化 Prompt 的质量，我们定义了三个核心维度的评估指标。",{"type":19,"tag":34,"props":792,"children":794},{"id":793},"_1-鲁棒性-robustness",[795],{"type":24,"value":796},"1. 鲁棒性 (Robustness)",{"type":19,"tag":20,"props":798,"children":799},{},[800],{"type":24,"value":801},"测试 Prompt 在不同输入扰动下的稳定性。",{"type":19,"tag":803,"props":804,"children":805},"ul",{},[806,817],{"type":19,"tag":807,"props":808,"children":809},"li",{},[810,815],{"type":19,"tag":139,"props":811,"children":812},{},[813],{"type":24,"value":814},"指标",{"type":24,"value":816},"：Pass Rate Variance (通过率方差)",{"type":19,"tag":807,"props":818,"children":819},{},[820,825],{"type":19,"tag":139,"props":821,"children":822},{},[823],{"type":24,"value":824},"测试方法",{"type":24,"value":826},"：对输入需求进行同义词替换、语序调整，观察生成代码的一致性。",{"type":19,"tag":34,"props":828,"children":830},{"id":829},"_2-忠实度-faithfulness",[831],{"type":24,"value":832},"2. 忠实度 (Faithfulness)",{"type":19,"tag":20,"props":834,"children":835},{},[836],{"type":24,"value":837},"测试生成代码是否严格遵循了 Prompt 中的所有约束条件。",{"type":19,"tag":803,"props":839,"children":840},{},[841,850],{"type":19,"tag":807,"props":842,"children":843},{},[844,848],{"type":19,"tag":139,"props":845,"children":846},{},[847],{"type":24,"value":814},{"type":24,"value":849},"：Constraint Satisfaction Rate (约束满足率)",{"type":19,"tag":807,"props":851,"children":852},{},[853,857],{"type":19,"tag":139,"props":854,"children":855},{},[856],{"type":24,"value":824},{"type":24,"value":858},"：使用静态分析工具检查代码是否包含指定的 CSS 类名、是否使用了指定的组件库。",{"type":19,"tag":34,"props":860,"children":862},{"id":861},"_3-效率-efficiency",[863],{"type":24,"value":864},"3. 效率 (Efficiency)",{"type":19,"tag":20,"props":866,"children":867},{},[868],{"type":24,"value":869},"测试 Prompt 是否以最少的 Token 消耗达到了预期效果。",{"type":19,"tag":803,"props":871,"children":872},{},[873,882],{"type":19,"tag":807,"props":874,"children":875},{},[876,880],{"type":19,"tag":139,"props":877,"children":878},{},[879],{"type":24,"value":814},{"type":24,"value":881},"：Token Efficiency Ratio (代码行数 / 输入 Token 数)",{"type":19,"tag":807,"props":883,"children":884},{},[885,889],{"type":19,"tag":139,"props":886,"children":887},{},[888],{"type":24,"value":824},{"type":24,"value":890},"：对比不同 Prompt 生成相同功能代码所需的 Token 数量。",{"type":19,"tag":27,"props":892,"children":894},{"id":893},"ab-测试框架",[895],{"type":24,"value":896},"🧪 A/B 测试框架",{"type":19,"tag":34,"props":898,"children":900},{"id":899},"在线实验平台",[901],{"type":24,"value":899},{"type":19,"tag":20,"props":903,"children":904},{},[905],{"type":24,"value":906},"我们在生产环境中部署了 Prompt A/B 测试系统，实时比较不同 Prompt 的表现。",{"type":19,"tag":803,"props":908,"children":909},{},[910,920,930],{"type":19,"tag":807,"props":911,"children":912},{},[913,918],{"type":19,"tag":139,"props":914,"children":915},{},[916],{"type":24,"value":917},"流量分桶",{"type":24,"value":919},"：将 5% 的流量分配给实验组 Prompt B，95% 流量保持对照组 Prompt A。",{"type":19,"tag":807,"props":921,"children":922},{},[923,928],{"type":19,"tag":139,"props":924,"children":925},{},[926],{"type":24,"value":927},"指标追踪",{"type":24,"value":929},"：实时监控两组的用户修改率（Edit Rate）、代码报错率（Error Rate）和用户留存率。",{"type":19,"tag":807,"props":931,"children":932},{},[933,938],{"type":19,"tag":139,"props":934,"children":935},{},[936],{"type":24,"value":937},"显著性检验",{"type":24,"value":939},"：自动计算 p-value，当结果具有统计显著性时自动全量发布胜出者。",{"type":19,"tag":20,"props":941,"children":942},{},[943],{"type":19,"tag":139,"props":944,"children":945},{},[946],{"type":24,"value":947},"实验配置示例",{"type":19,"tag":45,"props":949,"children":953},{"className":950,"code":951,"language":952,"meta":7,"style":7},"language-yaml shiki shiki-themes github-dark github-dark","experiment_id: \"prompt_exp_v2_css_framework\"\ndescription: \"Compare Tailwind vs UnoCSS instruction efficiency\"\nvariants:\n  control:\n    prompt_id: \"prompt_v1.2\"\n    weight: 90\n  treatment:\n    prompt_id: \"prompt_v1.3_unocss_optimized\"\n    weight: 10\nmetrics:\n  - name: \"build_success_rate\"\n    type: \"binomial\"\n  - name: \"user_acceptance_rate\"\n    type: \"binomial\"\n","yaml",[954],{"type":19,"tag":52,"props":955,"children":956},{"__ignoreMap":7},[957,976,993,1005,1017,1034,1051,1063,1079,1095,1107,1129,1146,1166],{"type":19,"tag":56,"props":958,"children":959},{"class":58,"line":59},[960,966,971],{"type":19,"tag":56,"props":961,"children":963},{"style":962},"--shiki-default:#85E89D;--shiki-dark:#85E89D",[964],{"type":24,"value":965},"experiment_id",{"type":19,"tag":56,"props":967,"children":968},{"style":63},[969],{"type":24,"value":970},": ",{"type":19,"tag":56,"props":972,"children":973},{"style":411},[974],{"type":24,"value":975},"\"prompt_exp_v2_css_framework\"\n",{"type":19,"tag":56,"props":977,"children":978},{"class":58,"line":69},[979,984,988],{"type":19,"tag":56,"props":980,"children":981},{"style":962},[982],{"type":24,"value":983},"description",{"type":19,"tag":56,"props":985,"children":986},{"style":63},[987],{"type":24,"value":970},{"type":19,"tag":56,"props":989,"children":990},{"style":411},[991],{"type":24,"value":992},"\"Compare Tailwind vs UnoCSS instruction efficiency\"\n",{"type":19,"tag":56,"props":994,"children":995},{"class":58,"line":78},[996,1001],{"type":19,"tag":56,"props":997,"children":998},{"style":962},[999],{"type":24,"value":1000},"variants",{"type":19,"tag":56,"props":1002,"children":1003},{"style":63},[1004],{"type":24,"value":172},{"type":19,"tag":56,"props":1006,"children":1007},{"class":58,"line":87},[1008,1013],{"type":19,"tag":56,"props":1009,"children":1010},{"style":962},[1011],{"type":24,"value":1012},"  control",{"type":19,"tag":56,"props":1014,"children":1015},{"style":63},[1016],{"type":24,"value":172},{"type":19,"tag":56,"props":1018,"children":1019},{"class":58,"line":96},[1020,1025,1029],{"type":19,"tag":56,"props":1021,"children":1022},{"style":962},[1023],{"type":24,"value":1024},"    prompt_id",{"type":19,"tag":56,"props":1026,"children":1027},{"style":63},[1028],{"type":24,"value":970},{"type":19,"tag":56,"props":1030,"children":1031},{"style":411},[1032],{"type":24,"value":1033},"\"prompt_v1.2\"\n",{"type":19,"tag":56,"props":1035,"children":1036},{"class":58,"line":105},[1037,1042,1046],{"type":19,"tag":56,"props":1038,"children":1039},{"style":962},[1040],{"type":24,"value":1041},"    weight",{"type":19,"tag":56,"props":1043,"children":1044},{"style":63},[1045],{"type":24,"value":970},{"type":19,"tag":56,"props":1047,"children":1048},{"style":183},[1049],{"type":24,"value":1050},"90\n",{"type":19,"tag":56,"props":1052,"children":1053},{"class":58,"line":114},[1054,1059],{"type":19,"tag":56,"props":1055,"children":1056},{"style":962},[1057],{"type":24,"value":1058},"  treatment",{"type":19,"tag":56,"props":1060,"children":1061},{"style":63},[1062],{"type":24,"value":172},{"type":19,"tag":56,"props":1064,"children":1065},{"class":58,"line":123},[1066,1070,1074],{"type":19,"tag":56,"props":1067,"children":1068},{"style":962},[1069],{"type":24,"value":1024},{"type":19,"tag":56,"props":1071,"children":1072},{"style":63},[1073],{"type":24,"value":970},{"type":19,"tag":56,"props":1075,"children":1076},{"style":411},[1077],{"type":24,"value":1078},"\"prompt_v1.3_unocss_optimized\"\n",{"type":19,"tag":56,"props":1080,"children":1081},{"class":58,"line":302},[1082,1086,1090],{"type":19,"tag":56,"props":1083,"children":1084},{"style":962},[1085],{"type":24,"value":1041},{"type":19,"tag":56,"props":1087,"children":1088},{"style":63},[1089],{"type":24,"value":970},{"type":19,"tag":56,"props":1091,"children":1092},{"style":183},[1093],{"type":24,"value":1094},"10\n",{"type":19,"tag":56,"props":1096,"children":1097},{"class":58,"line":331},[1098,1103],{"type":19,"tag":56,"props":1099,"children":1100},{"style":962},[1101],{"type":24,"value":1102},"metrics",{"type":19,"tag":56,"props":1104,"children":1105},{"style":63},[1106],{"type":24,"value":172},{"type":19,"tag":56,"props":1108,"children":1109},{"class":58,"line":341},[1110,1115,1120,1124],{"type":19,"tag":56,"props":1111,"children":1112},{"style":63},[1113],{"type":24,"value":1114},"  - ",{"type":19,"tag":56,"props":1116,"children":1117},{"style":962},[1118],{"type":24,"value":1119},"name",{"type":19,"tag":56,"props":1121,"children":1122},{"style":63},[1123],{"type":24,"value":970},{"type":19,"tag":56,"props":1125,"children":1126},{"style":411},[1127],{"type":24,"value":1128},"\"build_success_rate\"\n",{"type":19,"tag":56,"props":1130,"children":1131},{"class":58,"line":359},[1132,1137,1141],{"type":19,"tag":56,"props":1133,"children":1134},{"style":962},[1135],{"type":24,"value":1136},"    type",{"type":19,"tag":56,"props":1138,"children":1139},{"style":63},[1140],{"type":24,"value":970},{"type":19,"tag":56,"props":1142,"children":1143},{"style":411},[1144],{"type":24,"value":1145},"\"binomial\"\n",{"type":19,"tag":56,"props":1147,"children":1148},{"class":58,"line":382},[1149,1153,1157,1161],{"type":19,"tag":56,"props":1150,"children":1151},{"style":63},[1152],{"type":24,"value":1114},{"type":19,"tag":56,"props":1154,"children":1155},{"style":962},[1156],{"type":24,"value":1119},{"type":19,"tag":56,"props":1158,"children":1159},{"style":63},[1160],{"type":24,"value":970},{"type":19,"tag":56,"props":1162,"children":1163},{"style":411},[1164],{"type":24,"value":1165},"\"user_acceptance_rate\"\n",{"type":19,"tag":56,"props":1167,"children":1168},{"class":58,"line":422},[1169,1173,1177],{"type":19,"tag":56,"props":1170,"children":1171},{"style":962},[1172],{"type":24,"value":1136},{"type":19,"tag":56,"props":1174,"children":1175},{"style":63},[1176],{"type":24,"value":970},{"type":19,"tag":56,"props":1178,"children":1179},{"style":411},[1180],{"type":24,"value":1145},{"type":19,"tag":27,"props":1182,"children":1184},{"id":1183},"️-安全红队测试-red-teaming",[1185],{"type":24,"value":1186},"🛡️ 安全红队测试 (Red Teaming)",{"type":19,"tag":34,"props":1188,"children":1190},{"id":1189},"自动化攻击测试",[1191],{"type":24,"value":1189},{"type":19,"tag":20,"props":1193,"children":1194},{},[1195],{"type":24,"value":1196},"在 Prompt 上线前，必须通过自动化的红队测试，确保没有安全漏洞。",{"type":19,"tag":803,"props":1198,"children":1199},{},[1200,1210,1220],{"type":19,"tag":807,"props":1201,"children":1202},{},[1203,1208],{"type":19,"tag":139,"props":1204,"children":1205},{},[1206],{"type":24,"value":1207},"Jailbreak 测试",{"type":24,"value":1209},"：尝试使用 \"DAN\" (Do Anything Now) 等模式绕过安全限制。",{"type":19,"tag":807,"props":1211,"children":1212},{},[1213,1218],{"type":19,"tag":139,"props":1214,"children":1215},{},[1216],{"type":24,"value":1217},"Prompt Injection",{"type":24,"value":1219},"：尝试注入恶意指令（如 \"Ignore previous instructions\"）。",{"type":19,"tag":807,"props":1221,"children":1222},{},[1223,1228],{"type":19,"tag":139,"props":1224,"children":1225},{},[1226],{"type":24,"value":1227},"敏感信息泄露",{"type":24,"value":1229},"：测试 Prompt 是否会诱导模型输出训练数据中的敏感信息。",{"type":19,"tag":27,"props":1231,"children":1233},{"id":1232},"高级微调技术",[1234],{"type":24,"value":1235},"🔧 高级微调技术",{"type":19,"tag":34,"props":1237,"children":1239},{"id":1238},"soft-prompts-软提示",[1240],{"type":24,"value":1241},"Soft Prompts (软提示)",{"type":19,"tag":20,"props":1243,"children":1244},{},[1245],{"type":24,"value":1246},"对于特定行业的生成任务，我们使用 Soft Prompts 技术。不同于人类可读的文本 Prompt，Soft Prompts 是一组可学习的连续向量，直接拼接到模型输入的 Embedding 层。",{"type":19,"tag":803,"props":1248,"children":1249},{},[1250,1260],{"type":19,"tag":807,"props":1251,"children":1252},{},[1253,1258],{"type":19,"tag":139,"props":1254,"children":1255},{},[1256],{"type":24,"value":1257},"优势",{"type":24,"value":1259},"：比微调整个模型更高效，比离散文本 Prompt 效果更好。",{"type":19,"tag":807,"props":1261,"children":1262},{},[1263,1268],{"type":19,"tag":139,"props":1264,"children":1265},{},[1266],{"type":24,"value":1267},"应用",{"type":24,"value":1269},"：为 \"医疗行业\"、\"法律行业\" 训练专属的 Soft Prompt 向量。",{"type":19,"tag":34,"props":1271,"children":1273},{"id":1272},"prefix-tuning",[1274],{"type":24,"value":1275},"Prefix Tuning",{"type":19,"tag":20,"props":1277,"children":1278},{},[1279],{"type":24,"value":1280},"在每一层 Transformer 的 Key/Value 矩阵前添加可学习的前缀（Prefix），引导模型生成特定风格的代码。",{"type":19,"tag":27,"props":1282,"children":1284},{"id":1283},"相关技术文档",[1285],{"type":24,"value":1286},"🔗 相关技术文档",{"type":19,"tag":803,"props":1288,"children":1289},{},[1290,1300,1309],{"type":19,"tag":807,"props":1291,"children":1292},{},[1293],{"type":19,"tag":1294,"props":1295,"children":1297},"a",{"href":1296},"/ai/prompt-elements.md",[1298],{"type":24,"value":1299},"提示词要素",{"type":19,"tag":807,"props":1301,"children":1302},{},[1303],{"type":19,"tag":1294,"props":1304,"children":1306},{"href":1305},"/ai/training-optimization.md",[1307],{"type":24,"value":1308},"训练优化",{"type":19,"tag":807,"props":1310,"children":1311},{},[1312],{"type":19,"tag":1294,"props":1313,"children":1315},{"href":1314},"/ai/quality-assurance.md",[1316],{"type":24,"value":1317},"质量保证体系",{"type":19,"tag":1319,"props":1320,"children":1321},"hr",{},[],{"type":19,"tag":20,"props":1323,"children":1324},{},[1325],{"type":19,"tag":1326,"props":1327,"children":1328},"em",{},[1329],{"type":24,"value":1330},"优秀的 Prompt 不是写出来的，而是算出来的。HTMLPAGE 通过自动化的优化体系，持续挖掘 LLM 的潜能。",{"type":19,"tag":1332,"props":1333,"children":1334},"style",{},[1335],{"type":24,"value":1336},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":7,"searchDepth":78,"depth":78,"links":1338},[1339,1343,1348,1351,1354,1358],{"id":29,"depth":69,"text":32,"children":1340},[1341,1342],{"id":36,"depth":78,"text":36},{"id":132,"depth":78,"text":132},{"id":782,"depth":69,"text":785,"children":1344},[1345,1346,1347],{"id":793,"depth":78,"text":796},{"id":829,"depth":78,"text":832},{"id":861,"depth":78,"text":864},{"id":893,"depth":69,"text":896,"children":1349},[1350],{"id":899,"depth":78,"text":899},{"id":1183,"depth":69,"text":1186,"children":1352},[1353],{"id":1189,"depth":78,"text":1189},{"id":1232,"depth":69,"text":1235,"children":1355},[1356,1357],{"id":1238,"depth":78,"text":1241},{"id":1272,"depth":78,"text":1275},{"id":1283,"depth":69,"text":1286},"markdown","content:ai:prompt-optimization.md","content","ai/prompt-optimization.md","ai/prompt-optimization","md",[1366,1377,1386],{"_path":1367,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":1368,"description":1369,"keywords":1370,"schemaType":1371,"author":11,"date":1372,"image":1373,"_type":1359,"_id":1374,"_source":1361,"_file":1375,"_stem":1376,"_extension":1364},"/ai/architecture-overview","AI架构概述 - HTMLPAGE智能网页生成系统","HTMLPAGE AI系统架构深度解析，了解多智能体协作、实时流式生成、模块化组装等核心技术，探索AI如何革新网页设计流程。","AI网页生成, 多智能体系统, 实时流式AI, 智能网页设计, AI架构, 机器学习","TechArticle","2025-11-24","/content-images/ai/architecture-overview.jpg","content:ai:architecture-overview.md","ai/architecture-overview.md","ai/architecture-overview",{"_path":1378,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":1379,"description":1380,"keywords":1381,"author":11,"date":12,"category":1382,"image":14,"_type":1359,"_id":1383,"_source":1361,"_file":1384,"_stem":1385,"_extension":1364},"/ai/batch-creation","批量页面创建","模板 + 提示词模式组合进行多页面高效率生成","批量页面创建, 批量生成, 提示词模板, HTMLPAGE","应用场景","content:ai:batch-creation.md","ai/batch-creation.md","ai/batch-creation",{"_path":1387,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":1388,"description":1389,"keywords":1390,"author":11,"date":12,"category":1391,"image":14,"_type":1359,"_id":1392,"_source":1361,"_file":1393,"_stem":1394,"_extension":1364},"/ai/case-studies","AI 案例研究","HTMLPAGE AI 在不同行业和场景中的成功应用案例","AI 案例研究, 成功案例, 页面生成, HTMLPAGE","案例研究","content:ai:case-studies.md","ai/case-studies.md","ai/case-studies",1774945280498]