推理评测:同一个分数,可能藏着不同错误
Evaluating reasoning
使用明确的规则基线,按变体切片和模板评估原创算术题。
reasoning-evaluation都是十二题对九题
两个程序回答十二道算术题,都对了九道。一个记住熟悉措辞对应的答案,数量一变就错;另一个会计算,却把无关的货架编号也加进结果。总分相同,掩盖了不同的修复方向。
这是原创受控实验,不是语言模型比赛。透明的规则程序用作非AI基线。目标是设计一种评测,把熟悉例子上的成功与处理有效任务变体的能力区分开。自然语言解释有助于检查答案,但出现了解释,并不能证明写出的步骤导致了模型的答案。
GSM8K提供人工编写的小学数学题和自然语言解答。报告结果时要固定版本与划分;首版论文的取整数据量,并不定义所有后续下载副本。GSM8K论文
变换题目,也要说明答案如何变
令x为问题,g(x)为参考答案。变换T可以保持答案,例如改人名;也可以按已知方式改变答案,例如改数量。判断模型前,先写清这种关系:
第二种形式允许使用原题数量,因为旧答案本身未必包含计算新答案所需的信息。还要检查有效性约束:送出的瓷片比已有的多,就离开了本文非负计数练习的定义域。改写读起来通顺,不代表测试有效。
GSM-Symbolic构造带约束的数学模板变体,检查数量变化与无关条件的影响。其失败结果针对所测模型、提示和预算,不能证明所有语言模型都无法推理。GSM-Symbolic
对n道题,记录是否正确,以及是否返回答案。本文评分把拒答算作总体准确率中的错误,并单独报告覆盖率:
每个模板t有一组变体V_t,可统计有多少模板在全部指定变化下都成功。这是有意严格的鲁棒性指标,其数值取决于选入哪些变体:
两个系统准确率相同,错误位置却可能完全不同。应在同一组题上做配对计数,其中c_i为是否正确的指示量:
HELM把评估组织为场景与多种指标的覆盖,包括指定扰动下的鲁棒性。局部不变性测试只检查某一行为切片,不是通用推理能力的完整度量。HELM
做一套答案能审计的小测试
三个模板各有四版:原题、换人名、换数量、添加无关货架标签。原数量为4和3,新数量为5和3;加、减、乘的答案分别由7、1、12变成8、2、15。货架标签7不改变任何答案。名字与瓷片故事均为虚构。
使用Python 3.12运行,不需外部包。语法基线识别三种精确句型并计算相应运算;记忆基线按关键词返回原题答案;扫数基线先做运算,再加上前两个数字之后出现的所有数字。这是三个明确机制,不是对语言模型内部过程的描述。
"""Metamorphic evaluation of three rule programs on original arithmetic templates."""
import json,re
OPS=('add','subtract','multiply')
def make(op,a,b,name='Rin',extra=None):
if op not in OPS or any(type(x) is not int or not 1<=x<=20 for x in [a,b]) or (op=='subtract' and b>a):raise ValueError('valid bounded arithmetic instance required')
if name not in ['Rin','Sol']:raise ValueError('choose an authored fictional name')
if extra is not None and (type(extra) is not int or not 1<=extra<=20):raise ValueError('bounded shelf label required')
if op=='add':text=f'{name} has {a} red tiles and {b} blue tiles. How many tiles altogether?';answer=a+b
elif op=='subtract':text=f'{name} has {a} tiles and gives away {b} tiles. How many remain?';answer=a-b
else:text=f'{name} packs {a} boxes with {b} tiles each. How many tiles are packed?';answer=a*b
if extra is not None:text+=f' The shelf label is {extra}.'
return dict(template=op,text=text,answer=answer)
def grammar_solver(text):
if not isinstance(text,str) or len(text)>500:raise ValueError('bounded text required')
patterns=[(r'^(?:Rin|Sol) has (\d+) red tiles and (\d+) blue tiles\.',lambda a,b:a+b),(r'^(?:Rin|Sol) has (\d+) tiles and gives away (\d+) tiles\.',lambda a,b:a-b),(r'^(?:Rin|Sol) packs (\d+) boxes with (\d+) tiles each\.',lambda a,b:a*b)]
for pattern,fn in patterns:
match=re.match(pattern,text)
if match:return fn(*map(int,match.groups()))
return None
def sweeper(text):
result=grammar_solver(text)
if result is None:return None
values=list(map(int,re.findall(r'\d+',text)))
return result+sum(values[2:])
def lookup(text):
if 'red tiles' in text:return 7
if 'gives away' in text:return 1
if 'boxes with' in text:return 12
return None
def evaluate(rows,solver):
if not rows:raise ValueError('nonempty evaluation rows required')
outputs=[solver(r['text']) for r in rows];correct=[p==r['answer'] for p,r in zip(outputs,rows)]
variants=sorted({r['variant'] for r in rows});templates=sorted({r['template'] for r in rows})
by_variant={v:sum(c for c,r in zip(correct,rows) if r['variant']==v)/sum(r['variant']==v for r in rows) for v in variants}
all_variants=[all(c for c,r in zip(correct,rows) if r['template']==t) for t in templates]
return dict(accuracy=sum(correct)/len(rows),coverage=sum(p is not None for p in outputs)/len(rows),by_variant=by_variant,all_variants_per_template=sum(all_variants)/len(templates),outputs=outputs,correct=correct,templates=len(templates),rows=len(rows))
def demo():
rows=[]
for op in OPS:
for variant,args in [('base',dict(a=4,b=3)),('rename',dict(a=4,b=3,name='Sol')),('numbers',dict(a=5,b=3)),('irrelevant',dict(a=4,b=3,extra=7))]:
rows.append(dict(variant=variant,**make(op,**args)))
result={name:evaluate(rows,fn) for name,fn in [('grammar',grammar_solver),('memorized',lookup),('sweeper',sweeper)]}
paired={}
for a,b in [('grammar','memorized'),('memorized','sweeper')]:
x=result[a]['correct'];y=result[b]['correct'];paired[a+'_vs_'+b]=dict(first_only=sum(i and not j for i,j in zip(x,y)),second_only=sum(j and not i for i,j in zip(x,y)),both=sum(i and j for i,j in zip(x,y)))
return dict(rows=rows,results=result,paired=paired,unrecognized=grammar_solver('Rin owns four boxes containing three tiles each.'),scope='Twelve authored variants from three templates; programs are transparent baselines, not language models or independent random test draws.')
if __name__=='__main__':print(json.dumps(demo(),indent=2,allow_nan=False))
语法程序得12/12。两个脆弱程序都得9/12:记忆程序错在三道数量变化题,扫数程序错在三道无关标签题。两者各有三题单独获胜,六题共同成功。它们的模板全变体鲁棒性均为零,语法程序则为一。
语法基线拒绝一条关于“四盒、每盒三片”的未识别改写。它在自己语法上的满分,不能证明广泛的语言理解。解析器也只识别指定前缀,并不验证任意追加内容。评估输入应遵守声明的生成规则,扩展范围需要另测。
n条长度L的有界字符串,经固定的简单扫描需O(nL)工作;报告存储O(n)个输出。虽然有十二个案例,却只有三个来源模板。它们是人为编写、相互相关的变体,不是十二个独立随机任务。程序只给精确描述性计数,不作统计置信声明。
别让评测只考自己教过的题
真实模型研究应在提示筛选前留出模板和样本,记录模型版本、解码方式、示例、工具权限、尝试次数及token预算。独立核对参考解答,并区分格式错误、算术错误、无效变换与判分歧义。评分器的错误不自动等于求解器推理失败。
按变换、模板及相关子群报告分数,再检查配对案例。如果要为抽样模板估计不确定性,应保留其变体之间的依赖;例如在恰当的抽样设计下,以整组模板为单位重采样。同一模板增加更多变体,不能提供与新增独立模板相同的证据。
隐藏测试能减少直接针对答案调参,但本身无法证明训练数据没有污染。比较新生成且有效的变体,并记录已知的数据来源。精确匹配算术题只是在一种预算下的一项能力;解释、迁移和真实应用约束需分别评估,不能把孤立失败扩大成所有可能系统的结论。相关的检查器与任务目标之别,可见可验证奖励。
看看总分背后
- 为什么两个9/12程序需要不同修复?
答案:一个忽略变化后的数量,另一个使用了无关数字。总分相同,但错误切片揭示不同机制。
- 四盒改为五盒,每盒仍三片,不变性测试应该期待答案12吗?
答案:不应该。这是答案变化型变换,新答案是15;若当作答案不变,就会惩罚正确推理。
- 语法程序得12/12,能证明理解任意同义改写吗?
答案:不能。给定的改写例子就没有返回答案。满分覆盖的是十二条生成字符串,不包括解析模式之外的语言。
- 置信区间可以把同模板的全部变体当独立任务吗?
答案:没有合理的独立性模型就不可以。共享结构会产生依赖。应定义抽样单位,在适用时按整个模板组分析或重采样。
从数学题到评估覆盖
GSM8K提供题目与解答的基准设计,GSM-Symbolic检查受控变化,HELM明确评估覆盖范围。本文十二个例子全为新写,没有复制基准题目。它们的数字用于解释测量选择,不是LLM性能估计。
先判断,再看解释
两个系统都是9/12,是否一定错在相同题目?
学习目标
- 构造有效的答案变化与答案不变变换,如实报告相关样本。
- 运行原创有限实验,解释其中的反例与适用范围。
先修与延伸
查看知识关联图 →参考文献
- Training Verifiers to Solve Math Word Problems — v1
Karl Cobbe; Vineet Kosaraju; Mohammad Bavarian; Jacob Hilton; Reiichiro Nakano; Christopher Hesse; John Schulman · 2021 - GSM-Symbolic: Understanding the Limitations of Mathematical Reasoning in Large Language Models — v1
Iman Mirzadeh; Keivan Alizadeh; Hooman Shahrokhi; Oncel Tuzel; Samy Bengio; Mehrdad Farajtabar · 2024 - Holistic Evaluation of Language Models — v1
Percy Liang; Rishi Bommasani; Tony Lee and coauthors · 2022
版本1 · 编写状态: 已完成记录中的技术复核
查看技术检查记录(AI)
Codex · 2026-09-20 · Single AI author. Viewed PDF3: human-written math tasks and natural-language solutions; first-version rounded split counts. Viewed PDF5/10: constrained template variants and irrelevant clauses; results do not prove universal inability to reason. Viewed PDF5/29/31: scenario/metric coverage, calibration, local invariance and robustness; title/authors also read from page1 text. 4 paired equations and four explained exercises. All small arithmetic combinations, answer-changing variants, equal totals/different slices, paired outcomes and correlated-template scope checked. Rule programs are not LLMs.
- 核全部小算术组合、答案变化、同分异错、配对结果及相关模板范围;规则程序不冒充LLM。
- 每题四张计算SVG,11数值/几何与36响应式组合通过;实看12张最终图,完整页面验收另记。
核对的来源位置:
- Training Verifiers to Solve Math Word Problems — v1 · Viewed PDF3: human-written math tasks and natural-language solutions; first-version rounded split counts.
- GSM-Symbolic: Understanding the Limitations of Mathematical Reasoning in Large Language Models — v1 · Viewed PDF5/10: constrained template variants and irrelevant clauses; results do not prove universal inability to reason.
- Holistic Evaluation of Language Models — v1 · Viewed PDF5/29/31: scenario/metric coverage, calibration, local invariance and robustness; title/authors also read from page1 text.
相关主题