Spaces:
Sleeping
Sleeping
Update examples with real evaluation dataset questions
Browse files56 unmodified lines5758596061626364656667686946 unmodified lines11611711811912012112212312456 unmodified lines# 解码输出generated_text = tokenizer.decode(outputs[0], skip_special_tokens=True)# 提取答案部分if "答案:" in generated_text:answer = generated_text.split("答案:", 1)[1].strip()else:answer = generated_textreturn answer# 创建 Gradio 界面46 unmodified lines- 模型作者:zhman""",examples=[["2+2等于多少?", 256, 0.7, 0.9],["一个长方形的长是8厘米,宽是5厘米,它的周长是多少?", 256, 0.7, 0.9],["小明有5个苹果,小红给了他3个,小明现在有多少个苹果?", 256, 0.7, 0.9]],cache_examples=False, # 禁用示例缓存,避免启动时卡住theme=gr.themes.Soft()56 unmodified lines5758596061626364656667686970717273747576777879808182838485868788899091929394959697989910046 unmodified lines14714814915015115215315415556 unmodified lines# 解码输出generated_text = tokenizer.decode(outputs[0], skip_special_tokens=True)# 清理和提取答案# 1. 移除输入的问题部分if "答案:" in generated_text:answer = generated_text.split("答案:", 1)[1].strip()else:answer = generated_text.replace(prompt, "").strip()# 2. 清理训练格式文本# 移除包含这些关键词的行(训练数据格式)cleanup_keywords = ["运算符", "运算方法", "运算公式", "运算步骤","左值", "右值", "中值", "结果值","Step", "步骤编号",]# 分行处理lines = answer.split('\n')cleaned_lines = []for line in lines:line = line.strip()# 跳过空行if not line:continue# 跳过包含训练格式关键词的行if any(keyword in line for keyword in cleanup_keywords):continue# 保留这一行cleaned_lines.append(line)# 合并清理后的行,最多保留前 3 行if cleaned_lines:final_answer = '\n'.join(cleaned_lines[:3])else:# 如果全部被清理,返回原始答案的前 200 字符final_answer = answer[:200]return final_answer# 创建 Gradio 界面46 unmodified lines- 模型作者:zhman""",examples=[["Find the positive integer $n$ such that $10^n$ cubic centimeters is the same as 1 cubic kilometer.", 256, 0.7, 0.9],["Define an operation $\\Diamond$ as $ a \\Diamond b = 12a - 10b.$ Compute the value of $((((20 \\Diamond 22) \\Diamond 22) \\Diamond 22) \\Diamond22).$", 256, 0.7, 0.9],["S1.1 Let $a, b, c$ and $d$ be the distinct roots of the equation $x^{4}-15 x^{2}+56=0$. If $R=a^{2}+b^{2}+c^{2}+d^{2}$, find the value of $R$.", 256, 0.7, 0.9]],cache_examples=False, # 禁用示例缓存,避免启动时卡住theme=gr.themes.Soft()
app.py+37-6