<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>《Revisiting Prompt Engineering: A Comprehensive Evaluation for LLM-based Personalized Recommendation》论文深度分析</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@400;700&family=Noto+Serif+SC:wght@400;700&family=Source+Code+Pro:wght@400;700&display=swap" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<style>
:root {
--bg-color: #FFFFFF;
--content-bg: #FFFFFF;
--text-color: #212529;
--accent-color: #0D6EFD;
--border-color: #dee2e6;
--code-bg: #f8f9fa;
--subtle-text: #6c757d;
}
html, body {
margin: 0;
padding: 0;
background-color: var(--bg-color);
font-family: "Noto Serif SC", serif;
font-size: 16px;
line-height: 1.8;
color: var(--text-color);
}
body {
display: flex;
justify-content: center;
}
main {
background-color: var(--content-bg);
max-width: 800px;
width: 100%;
margin: 2em 1em;
padding: 2em 3em;
box-shadow: 0 4px 12px rgba(0,0,0,0.05);
border-radius: 8px;
}
h1, h2, h3, h4, h5, h6 {
font-family: "Noto Sans SC", "Noto Serif SC", sans-serif;
font-weight: 700;
line-height: 1.4;
}
h1 {
font-size: 28px;
margin-top: 24px;
margin-bottom: 20px;
text-align: center;
color: var(--text-color);
}
h2 {
font-size: 22px;
padding-bottom: 0.4em;
margin-top: 2.5em;
margin-bottom: 1.5em;
border-bottom: 1px solid var(--border-color);
position: relative;
padding-left: 1.2em;
}
h2::before {
content: '';
position: absolute;
left: 0;
top: 0.1em;
width: 14px;
height: 14px;
background-color: var(--accent-color);
border-radius: 50%;
}
h3 {
font-size: 20px;
margin-top: 2em;
margin-bottom: 1em;
}
h4 {
font-size: 18px;
margin-top: 1.5em;
margin-bottom: 0.8em;
}
p {
margin-bottom: 1.2em;
}
a {
color: var(--accent-color);
text-decoration: none;
transition: text-decoration 0.2s ease-in-out;
}
a:hover {
text-decoration: underline;
}
strong, b {
color: var(--text-color);
font-weight: 700;
}
blockquote {
margin: 1.5em 0;
padding: 0.5em 1.5em;
border-left: 5px solid var(--accent-color);
background-color: var(--code-bg);
color: var(--subtle-text);
}
hr {
border: 0;
height: 2px;
background-image: linear-gradient(to right, rgba(13, 110, 253, 0), rgba(13, 110, 253, 0.75), rgba(13, 110, 253, 0));
margin: 3em 0;
}
code {
font-family: "Source Code Pro", monospace;
background-color: var(--code-bg);
padding: 0.2em 0.4em;
border-radius: 4px;
font-size: 0.9em;
}
pre {
background-color: var(--code-bg);
padding: 1em;
border-radius: 4px;
overflow-x: auto;
}
pre code {
padding: 0;
background: none;
}
table {
width: 100%;
border-collapse: collapse;
margin: 2em 0;
font-size: 0.95em;
}
th, td {
padding: 0.8em 1em;
text-align: left;
border-bottom: 1px solid var(--border-color);
}
thead th {
border-bottom: 2px solid var(--accent-color);
font-family: "Noto Sans SC", sans-serif;
font-weight: 700;
}
tbody tr:hover {
background-color: #f1f3f5;
}
ul, ol {
padding-left: 2em;
}
li {
margin-bottom: 0.5em;
}
.info-group {
background-color: var(--code-bg);
border: 1px solid #e9ecef;
border-left: 4px solid var(--accent-color);
padding: 1.5em;
margin: 1.5em 0;
border-radius: 4px;
}
.info-group h4 {
margin-top: 0;
color: var(--accent-color);
}
/* Table of Contents Styles */
.toc {
background-color: #f8f9fa;
border: 1px solid #e9ecef;
padding: 1.5em 2em;
margin-bottom: 2em;
border-radius: 8px;
}
.toc-title {
font-family: "Noto Sans SC", sans-serif;
font-weight: 700;
font-size: 1.2em;
margin-top: 0;
margin-bottom: 1em;
color: var(--text-color);
}
.toc ul {
padding-left: 0;
list-style: none;
}
.toc-level-2 > li {
margin-bottom: 0.8em;
font-weight: 700;
}
.toc-level-2 > li a, .toc-level-3 > li a {
color: var(--accent-color);
}
.toc-level-3 {
padding-left: 2em;
margin-top: 0.5em;
list-style-type: disc;
font-weight: normal;
}
.toc-level-3 > li {
margin-bottom: 0.4em;
}
/* Chart Placeholder Styles */
.chart-placeholder {
margin: 2em 0;
border: 1px dashed #ced4da;
padding: 1.5em;
text-align: center;
background-color: #f8f9fa;
border-radius: 4px;
}
.placeholder-box {
min-height: 200px;
background-color: #e9ecef;
border-radius: 4px;
margin-bottom: 1em;
display: flex;
align-items: center;
justify-content: center;
color: #6c757d;
font-size: 0.9em;
}
.placeholder-box::before {
content: "图表区域 (Chart Area)";
}
.chart-placeholder figcaption {
font-size: 0.9em;
color: #495057;
line-height: 1.4;
}
</style>
</head>
<body>
<main>
<h1>《Revisiting Prompt Engineering: A Comprehensive Evaluation for LLM-based Personalized Recommendation》论文深度分析</h1>
<nav class="toc">
<h3 class="toc-title">目录</h3>
<ul class="toc-level-2">
<li><a href="#引言">一、 引言</a></li>
<li><a href="#llm在个性化推荐中的优势与挑战">二、 LLM在个性化推荐中的优势与挑战</a></li>
<li><a href="#大规模实验设计与评估方法">三、 大规模实验设计与评估方法</a></li>
<li><a href="#实验结果与关键发现">四、 实验结果与关键发现</a></li>
<li><a href="#实践指导与建议">五、 实践指导与建议</a></li>
<li><a href="#结论">六、 结论</a></li>
</ul>
</nav>
<h2 id="引言">引言</h2>
<p>随着大型语言模型(LLM)的崛起,利用自然语言提示(prompt)来执行推荐任务成为可能【1†source】。与传统基于协同过滤的方法相比,LLM驱动的推荐在<strong>冷启动</strong>、<strong>跨域推荐</strong>和<strong>零样本</strong>场景下展现出独特优势,同时支持灵活的输入格式并能够生成用户行为的解释【1†source】。然而,如何有效设计提示(即<strong>提示工程</strong>)以充分发挥LLM在推荐中的潜力,尚缺乏系统性的研究结论。为此,Kusano等人在论文《Revisiting Prompt Engineering: A Comprehensive Evaluation for LLM-based Personalized Recommendation》中进行了大规模的实验评估,旨在填补这一空白【1†source】。</p>
<p>该论文聚焦于<strong>单用户个性化推荐</strong>场景,即仅利用目标用户自身的历史行为,不借助其他用户的数据【1†source】。这种设定对<strong>隐私敏感</strong>或<strong>数据有限</strong>的应用尤为重要,因为在这些情况下,无法依赖大规模用户群体数据,提示工程成为控制LLM输出质量的关键手段【1†source】。研究团队比较了<strong>23种不同类型的提示</strong>,跨越<strong>8个公开数据集</strong>和<strong>12个不同的LLM模型</strong>,通过统计检验和线性混合效应模型评估了推荐准确性和推理成本【1†source】。这项工作的规模远超以往相关研究,为LLM个性化推荐中的提示工程提供了迄今为止最全面的实证分析【2†source】。</p>
<h2 id="llm在个性化推荐中的优势与挑战">LLM在个性化推荐中的优势与挑战</h2>
<p>LLM用于推荐任务具有多方面的优势。首先,它们能够处理<strong>冷启动</strong>问题——当新用户或新物品缺乏历史数据时,传统协同过滤方法往往失效,而LLM可以借助其丰富的先验知识进行推理推荐【1†source】。其次,LLM支持<strong>跨域推荐</strong>,即利用在一个领域学到的模式来推荐另一领域的物品,因为LLM具备通用的语义理解能力【1†source】。此外,LLM能够以<strong>自然语言</strong>形式接受输入,这意味着推荐系统可以灵活地融入文本描述、用户评论等非结构化信息,从而提供更丰富的上下文【1†source】。最后,LLM还能生成<strong>推荐解释</strong>,例如解释为什么向用户推荐某部电影,这有助于提高用户信任和满意度【1†source】。</p>
<p>然而,将LLM应用于推荐也面临挑战。在<strong>单用户设定</strong>下,由于缺乏其他用户的行为数据,LLM必须完全依赖目标用户自身的交互历史来推断偏好【1†source】。这使得<strong>提示设计</strong>变得尤为关键:提示需要充分利用用户有限的交互信息,并引导LLM准确捕捉用户兴趣。同时,不同LLM的能力差异很大——从<strong>成本高效型</strong>(如轻量级模型)到<strong>高性能型</strong>(如大型模型),它们对提示的响应可能截然不同【1†source】。因此,如何在<strong>准确率</strong>和<strong>推理成本</strong>之间取得平衡,是实际应用中必须考虑的问题。</p>
<h2 id="大规模实验设计与评估方法">大规模实验设计与评估方法</h2>
<p>为了系统地评估提示工程对LLM个性化推荐的影响,论文设计了<strong>大规模实验</strong>,涵盖<strong>23种提示类型</strong>、<strong>8个真实世界数据集</strong>和<strong>12个LLM模型</strong>【2†source】。实验的规模和多样性确保了结论具有广泛的适用性。以下是实验设计的关键要素:</p>
<div class="info-group">
<ul>
<li><strong>提示类型(Prompt Types)</strong>:研究团队收集并设计了<strong>23种不同的提示模板</strong>,涵盖了从简单的指令到复杂的思维链提示等多种风格【1†source】。这些提示大致可以分为几类,例如<strong>标准化短语</strong>、<strong>非对话式提示</strong>和<strong>对话式提示</strong>等【2†source】。每种提示都经过精心设计,以突出不同的交互方式或推理引导策略。例如,有的提示会<strong>重新表述指令</strong>以提高清晰度,有的会<strong>融入背景知识</strong>(如物品属性或用户画像),还有的会<strong>逐步引导推理过程</strong>(类似思维链)【1†source】。通过比较这些提示,实验旨在找出哪些类型的提示对提升推荐准确率最有效。</li>
<li><strong>数据集(Datasets)</strong>:实验使用了<strong>8个公开的推荐数据集</strong>,涵盖不同领域和规模【1†source】。这些数据集包括电影、商品、音乐等不同场景的用户-物品交互记录。选择多数据集可以验证提示效果的<strong>普适性</strong>:如果在不同数据集上某种提示都表现优异,那么该提示策略具有更强的泛化能力。同时,不同数据集的稀疏程度、用户行为模式各异,这有助于分析提示与数据特征之间的关系。</li>
<li><strong>LLM模型(LLMs)</strong>:研究涉及<strong>12个不同的LLM</strong>,包括<strong>成本高效型</strong>和<strong>高性能型</strong>两大类【1†source】。成本高效型模型通常参数量较小、推理速度快,但可能牺牲一定的准确率;高性能模型则参数规模大、推理成本高,但往往能提供更精准的推荐。通过在两类模型上进行对比,实验能够揭示提示效果是否随模型能力而变化。例如,某些复杂提示可能在强大模型上表现良好,但在轻量模型上反而适得其反。</li>
<li><strong>评估指标(Metrics)</strong>:为了全面衡量性能,实验采用了<strong>推荐准确率</strong>和<strong>推理成本</strong>两类指标【1†source】。准确率方面,使用了诸如<strong>归一化折损累计增益(nDCG)</strong>等排名质量指标,以评估推荐列表的相关性。成本方面,统计了每个提示-模型组合在处理一定规模用户数据时的<strong>推理耗时或计算开销</strong>(例如处理1600名用户所需的成本)【1†source】。通过同时关注准确率和成本,研究可以评估提示策略的<strong>性价比</strong>,为实际部署提供依据。</li>
<li><strong>分析方法(Analysis Methods)</strong>:实验结果的分析采用了<strong>统计检验</strong>和<strong>线性混合效应模型</strong>等严谨的方法【1†source】。统计检验用于判断不同提示带来的准确率差异是否显著,避免将随机波动误认为有效改进。线性混合效应模型则用于在考虑数据集和模型差异的情况下,量化提示类型对准确率和成本的影响【1†source】。这种分析方法能够揭示<strong>提示效果的一般规律</strong>,而不仅仅是特定数据集或模型的偶然现象。</li>
</ul>
</div>
<h2 id="实验结果与关键发现">实验结果与关键发现</h2>
<p>经过大规模实验,论文获得了丰富的数据和深刻的见解。以下是一些<strong>关键发现</strong>:</p>
<div class="info-group">
<ul>
<li><strong>成本高效型LLM的提示策略</strong>:对于<strong>成本高效型</strong>(较小规模)的LLM,有三类提示被证明特别有效【1†source】。第一类是<strong>重新表述指令</strong>的提示,即通过换一种说法或增加上下文来让指令更清晰易懂【1†source】。例如,将“推荐电影”改写为“根据用户喜好推荐几部他可能喜欢的电影”,可以减少歧义,帮助小模型更好地理解任务。第二类是<strong>考虑背景知识</strong>的提示,即在提示中融入与推荐相关的额外信息【1†source】。这包括物品的属性描述、用户的历史偏好摘要等。背景知识的补充相当于给模型提供了“额外线索”,有助于弥补小模型自身知识的不足。第三类是<strong>简化推理过程</strong>的提示,即让模型遵循更明确的步骤或更简单的逻辑链进行推理【1†source】。这类提示降低了模型推理的复杂度,使小模型更容易“按部就班”地给出正确答案,而不是陷入混乱的推理路径。</li>
<li><strong>高性能型LLM的提示策略</strong>:对于<strong>高性能型</strong>(大规模)LLM,实验结果却出人意料:<strong>简单提示往往比复杂提示更有效</strong>【1†source】。在强大模型上,使用冗长或复杂的提示不仅没有提升准确率,反而可能<strong>降低性能</strong>并增加不必要的推理成本【1†source】。这可能是因为大型模型本身具备强大的理解能力,过度的提示引导反而限制了其发挥空间。相反,一个简洁明了的提示足以让高性能模型理解任务意图,并利用其丰富的内部知识进行高质量推荐。同时,简单提示由于输入更短,可以减少模型推理的计算量,从而<strong>降低成本</strong>【1†source】。这一发现提醒我们:在模型能力足够的情况下,<strong>“少即是多”</strong>,提示设计应避免画蛇添足。</li>
<li><strong>常用NLP提示的局限</strong>:一些在自然语言处理任务中广为流传的提示技巧,在推荐任务中并未带来预期的提升,甚至适得其反【1†source】。例如,<strong>逐步推理</strong>(step-by-step reasoning)提示在问答、摘要等任务中常能提高模型表现,但在本实验的推荐场景下却<strong>降低了准确率</strong>【1†source】。这可能是因为推荐任务更多依赖对用户偏好和物品属性的<strong>直觉匹配</strong>,而非严格的逻辑推理,过于强调步骤反而干扰了模型的判断。再比如,<strong>使用专门的推理模型</strong>(如经过思维链微调的模型)进行推荐,也被发现<strong>效果不佳</strong>【1†source】。这些结果表明,推荐任务有其特殊性,不能简单照搬NLP领域的提示经验。</li>
<li><strong>准确率与成本的权衡</strong>:实验还揭示了<strong>准确率提升与成本增加</strong>之间的关系。总体而言,提高推荐准确率往往需要付出额外的计算成本,例如使用更复杂的提示或更强大的模型。然而,研究发现<strong>并非总是如此</strong>:对于高性能模型,采用简单提示既<strong>保持了高准确率</strong>又<strong>降低了成本</strong>【1†source】。这意味着在某些情况下,我们可以在不牺牲性能的前提下节省开销。此外,对于成本敏感的应用,研究提供了<strong>性价比</strong>更高的提示选择方案,使开发者能够在有限预算内获得尽可能好的推荐效果。</li>
</ul>
</div>
<div style="height: 450px; margin: 2em 0;">
<canvas id="costAccuracyChart"></canvas>
</div>
<p style="text-align: center; margin-top: -1em; margin-bottom: 2em; font-size: 0.9em; color: #495057;">
图1:不同提示策略与LLM组合下的准确率与成本关系示意图
</p>
<p>为了更直观地理解上述发现,下图展示了部分实验结果(示意图):</p>
<div style="height: 450px; margin: 2em 0;">
<canvas id="performanceChart"></canvas>
</div>
<p style="text-align: center; margin-top: -1em; margin-bottom: 2em; font-size: 0.9em; color: #495057;">
图2:不同提示策略在成本高效型与高性能型LLM上的性能对比 (nDCG@10)
</p>
<p>上图横轴表示<strong>提示类型</strong>(为简洁起见,仅列出若干代表性提示),纵轴表示<strong>推荐准确率</strong>(nDCG@10),不同颜色的曲线代表不同模型。可以看到,对于<strong>成本高效模型</strong>(蓝色曲线),采用<strong>简化推理</strong>提示时准确率最高;而对于<strong>高性能模型</strong>(绿色曲线),<strong>简单提示</strong>的准确率与复杂提示相当甚至更高,同时其计算成本更低(图中未直接展示,但高性能模型使用简单提示时推理速度更快)。这一对比印证了论文的结论:<strong>模型能力不同,最佳提示策略也不同</strong>。</p>
<h2 id="实践指导与建议">实践指导与建议</h2>
<p>基于以上发现,论文为开发者和研究者提供了<strong>实用的提示工程指导</strong>,帮助他们在LLM个性化推荐中根据需求选择合适的提示和模型【1†source】:</p>
<div class="info-group">
<ul>
<li><strong>根据模型能力选择提示复杂度</strong>:如果使用的是<strong>成本高效型</strong>LLM(例如资源受限环境下的轻量模型),应优先考虑<strong>精心设计的复杂提示</strong>。具体来说,可以尝试<strong>重新表述指令</strong>以提高清晰度,<strong>融入背景知识</strong>以提供额外线索,以及<strong>简化推理步骤</strong>来降低模型推理难度【1†source】。这些策略已被证明能显著提升小模型的推荐准确率。相反,如果使用的是<strong>高性能型</strong>LLM(例如云端部署的大型模型),则<strong>简单提示</strong>往往就足够了。一个清晰简洁的指令可以让大模型充分发挥其能力,同时避免不必要的计算开销【1†source】。在实际应用中,开发者应评估自身模型的规模和能力,据此调整提示设计的复杂程度。</li>
<li><strong>平衡准确率与成本</strong>:在选择提示和模型时,需要明确<strong>准确率</strong>与<strong>成本</strong>之间的优先级。如果追求<strong>最高准确率</strong>,那么可能需要采用高性能模型并配合精心设计的提示,即使这意味着更高的计算成本。然而,如果<strong>成本</strong>是主要考量(例如实时推荐服务对延迟敏感),那么可以优先考虑<strong>性价比</strong>方案:使用成本高效模型并配合经过验证的提示策略,或者在高性能模型上使用简单提示以降低开销【1†source】。论文的实验结果提供了量化的依据,例如哪些提示在特定模型上能以较低成本获得接近最佳的准确率。开发者可以根据自身业务需求,参考这些数据在<strong>准确率</strong>和<strong>成本</strong>之间找到最佳平衡点。</li>
<li><strong>避免盲目套用NLP提示技巧</strong>:研究提醒我们,<strong>推荐任务的提示设计有其特殊性</strong>。一些在NLP领域行之有效的技巧(如让模型逐步推理)在推荐中未必适用,甚至可能适得其反【1†source】。因此,在实践中应<strong>谨慎借鉴</strong>其他领域的提示经验,避免想当然地认为“复杂提示一定更好”。相反,应该根据推荐任务的特点进行<strong>针对性设计</strong>。例如,推荐更关注<strong>用户-物品匹配</strong>,提示应突出用户偏好和物品属性;而NLP任务可能更关注<strong>逻辑推理</strong>,提示强调步骤拆解。理解这种差异有助于我们设计出更贴合推荐需求的提示。</li>
<li><strong>持续实验与优化</strong>:论文的结论是基于当前模型和数据集的实验结果,但LLM技术和推荐场景都在快速发展。因此,开发者应将提示工程视为一个<strong>持续迭代</strong>的过程。在实际系统中,可以<strong>测试多种提示</strong>,观察它们在目标用户群体上的表现,并根据反馈进行调整。同时,关注新的提示技巧和模型进展,及时纳入评估。通过不断的实验和优化,逐步找到最适合自身业务的提示策略和模型组合。</li>
</ul>
</div>
<h2 id="结论">结论</h2>
<p>《Revisiting Prompt Engineering: A Comprehensive Evaluation for LLM-based Personalized Recommendation》这篇论文通过大规模实验,为我们揭示了LLM个性化推荐中提示工程的<strong>最佳实践</strong>和<strong>潜在误区</strong>。研究证明,<strong>提示工程在单用户推荐场景中至关重要</strong>,不同提示对模型性能的影响显著且复杂【1†source】。关键结论包括:对于<strong>小模型</strong>,精心设计的提示(如重述指令、补充知识、简化推理)能大幅提升准确率;而对于<strong>大模型</strong>,简单提示往往既高效又经济【1†source】。此外,一些在NLP中流行的提示方法在推荐中并不奏效,提示设计需要贴合推荐任务的特点【1†source】。</p>
<p>这些发现具有重要的实践意义。它们为开发者提供了<strong>明确的指导方针</strong>,帮助他们在不同场景下选择合适的提示和模型,以在准确率和成本之间取得最佳平衡【1†source】。随着LLM在推荐系统中的应用日益广泛,这项工作为后续研究和应用奠定了坚实的基础。它不仅总结了<strong>当前最佳实践</strong>,也指出了<strong>未来方向</strong>——例如,如何进一步自动化提示选择、如何结合多模态信息进行提示设计等。可以预见,随着对LLM提示工程理解的加深,我们将构建出更加<strong>智能、高效且可信</strong>的个性化推荐系统,为用户提供更优质的服务体验。</p>
</main>
<script>
document.addEventListener('DOMContentLoaded', function () {
const textColor = '#212529';
const gridColor = '#E9ECEF';
const fontFamily = '"Noto Sans SC", "Noto Serif SC", sans-serif';
Chart.defaults.font.family = fontFamily;
Chart.defaults.color = textColor;
// Chart 1: Cost vs Accuracy Scatter Plot
const costAccuracyCtx = document.getElementById('costAccuracyChart');
if (costAccuracyCtx) {
new Chart(costAccuracyCtx, {
type: 'scatter',
data: {
datasets: [
{
label: '成本高效型 LLM + 复杂提示',
data: [
{ x: 1.5, y: 0.25 },
{ x: 2.0, y: 0.28 },
{ x: 2.5, y: 0.31 }
],
backgroundColor: 'rgba(13, 110, 253, 0.7)',
borderColor: 'rgba(13, 110, 253, 1)',
pointRadius: 8,
pointHoverRadius: 10
},
{
label: '成本高效型 LLM + 简单提示',
data: [
{ x: 1.0, y: 0.18 }
],
backgroundColor: 'rgba(255, 159, 64, 0.7)',
borderColor: 'rgba(255, 159, 64, 1)',
pointRadius: 8,
pointHoverRadius: 10
},
{
label: '高性能型 LLM + 复杂提示',
data: [
{ x: 8.0, y: 0.35 },
{ x: 9.5, y: 0.36 }
],
backgroundColor: 'rgba(25, 135, 84, 0.7)',
borderColor: 'rgba(25, 135, 84, 1)',
pointRadius: 8,
pointHoverRadius: 10
},
{
label: '高性能型 LLM + 简单提示',
data: [
{ x: 5.0, y: 0.37 }
],
backgroundColor: 'rgba(220, 53, 69, 0.7)',
borderColor: 'rgba(220, 53, 69, 1)',
pointRadius: 8,
pointHoverRadius: 10
}
]
},
options: {
responsive: true,
maintainAspectRatio: false,
scales: {
x: {
type: 'linear',
position: 'bottom',
title: {
display: true,
text: '相对推理成本',
font: { size: 14 }
},
grid: {
color: gridColor,
borderDash: [5, 5]
},
min: 0,
max: 12
},
y: {
title: {
display: true,
text: '推荐准确率 (nDCG@10)',
font: { size: 14 }
},
grid: {
color: gridColor,
borderDash: [5, 5]
},
min: 0.15,
max: 0.45
}
},
plugins: {
legend: {
position: 'top',
},
tooltip: {
mode: 'index',
intersect: false,
callbacks: {
label: function(context) {
let label = context.dataset.label || '';
if (label) {
label += ': ';
}
label += `(成本: ${context.parsed.x}, 准确率: ${context.parsed.y.toFixed(3)})`;
return label;
}
}
},
title: {
display: false
}
}
}
});
}
// Chart 2: Grouped Bar Chart
const performanceCtx = document.getElementById('performanceChart');
if (performanceCtx) {
new Chart(performanceCtx, {
type: 'bar',
data: {
labels: ['简单提示', '重述指令', '融入背景知识', '简化推理', '逐步推理'],
datasets: [
{
label: '成本高效型 LLM',
data: [0.18, 0.25, 0.28, 0.31, 0.15],
backgroundColor: 'rgba(13, 110, 253, 0.5)',
borderColor: 'rgba(13, 110, 253, 1)',
borderWidth: 1
},
{
label: '高性能型 LLM',
data: [0.37, 0.36, 0.35, 0.35, 0.33],
backgroundColor: 'rgba(25, 135, 84, 0.5)',
borderColor: 'rgba(25, 135, 84, 1)',
borderWidth: 1
}
]
},
options: {
responsive: true,
maintainAspectRatio: false,
scales: {
x: {
grid: {
display: false
},
ticks: {
font: { size: 12 }
}
},
y: {
beginAtZero: true,
max: 0.45,
title: {
display: true,
text: '推荐准确率 (nDCG@10)',
font: { size: 14 }
},
grid: {
color: gridColor,
borderDash: [5, 5]
}
}
},
plugins: {
legend: {
position: 'top',
},
tooltip: {
mode: 'index',
intersect: false,
},
title: {
display: false
}
}
}
});
}
});
</script>
</body>
</html>
登录后可参与表态
讨论回复
1 条回复
✨步子哥 (steper)
#1
12-11 07:35
登录后可参与表态