feat: 实现实时进度跟踪和滚动更新功能
新增功能: - ✅ 实时进度跟踪:进度条、ETA、已用时间 - ✅ 滚动更新:每完成一个问题就保存结果 - ✅ 原子写入:防止文件损坏 新增文件: - src/utils/progress_tracker.py - 进度跟踪器 - 可视化进度条 - ETA 预估(基于实际耗时) - 各指标平均耗时统计 - docs/ROLLING_UPDATE_GUIDE.md - 滚动更新使用指南 - 功能说明和使用场景 - 文件格式详解 - 最佳实践 修改文件: - src/evaluators/configurable_evaluator.py - 集成 ProgressTracker - 实现 _init_output_file() 初始化输出文件 - 实现 _update_output_file() 滚动更新 - 支持原子写入(临时文件 + 重命名) - scripts/evaluate_with_config.py - 添加 --output 参数支持滚动更新 - 添加 show_progress 选项 - 更新帮助文档和示例 - scripts/evaluate_all_types_advanced.bat - 添加滚动更新选项 - 自动生成带时间戳的输出目录 - 更新总结信息显示配置 - docs/progress/TODO.md - 更新版本到 v2.1.1 - 记录用户体验优化功能 技术亮点: - 原子写入保证文件完整性 - 实时进度显示(进度条、ETA) - 滚动更新防止数据丢失 - 用户体验大幅提升 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
eb0897a31b
commit
cd1ab744c7
6 files changed
+913
-27
No files matched your search
@@ -28,7 +28,8 @@ async def evaluate_system(
|
||||
enable_parallel: bool = True,
|
||||
enable_logging: bool = True,
|
||||
disabled_metrics: list = None,
|
||||
enabled_metrics: list = None
|
||||
enabled_metrics: list = None,
|
||||
output_file: str = None
|
||||
):
|
||||
"""
|
||||
评估单个系统
|
||||
@@ -40,6 +41,7 @@ async def evaluate_system(
|
||||
enable_logging: 是否启用详细日志
|
||||
disabled_metrics: 要禁用的指标列表
|
||||
enabled_metrics: 要启用的指标列表(优先级更高)
|
||||
output_file: 输出文件路径(如果提供,将实现滚动更新)
|
||||
"""
|
||||
from src.transformers.data_converter import DataConverter
|
||||
from src.evaluators.configurable_evaluator import ConfigurableRAGAsEvaluator
|
||||
@@ -86,18 +88,33 @@ async def evaluate_system(
|
||||
logger=logger,
|
||||
enable_parallel=enable_parallel,
|
||||
disabled_metrics=disabled_set,
|
||||
enabled_metrics=enabled_set
|
||||
enabled_metrics=enabled_set,
|
||||
show_progress=True
|
||||
)
|
||||
print()
|
||||
|
||||
# 准备输出文件路径
|
||||
positive_output_file = None
|
||||
negative_output_file = None
|
||||
if output_file:
|
||||
output_path = Path(output_file)
|
||||
positive_output_file = str(output_path.parent / f"{output_path.stem}_positive{output_path.suffix}")
|
||||
negative_output_file = str(output_path.parent / f"{output_path.stem}_negative{output_path.suffix}")
|
||||
|
||||
# 评估正向用例
|
||||
print(f"[2/3] 评估正向用例...")
|
||||
positive_results = await evaluator.evaluate_batch(positive_cases)
|
||||
positive_results = await evaluator.evaluate_batch(
|
||||
positive_cases,
|
||||
output_file=positive_output_file
|
||||
)
|
||||
print()
|
||||
|
||||
# 评估负向用例
|
||||
print(f"[3/3] 评估负向用例...")
|
||||
negative_results = await evaluator.evaluate_batch(negative_cases)
|
||||
negative_results = await evaluator.evaluate_batch(
|
||||
negative_cases,
|
||||
output_file=negative_output_file
|
||||
)
|
||||
print()
|
||||
|
||||
end_time = datetime.now()
|
||||
@@ -193,14 +210,17 @@ def main():
|
||||
# 禁用最慢的指标 answer_correctness(推荐)
|
||||
python scripts/evaluate_with_config.py --system zht-excel --disable answer_correctness
|
||||
|
||||
# 启用滚动更新(每完成一个问题就保存结果)
|
||||
python scripts/evaluate_with_config.py --system zht-excel --disable answer_correctness --output data/results/rolling_update
|
||||
|
||||
# 只启用快速指标
|
||||
python scripts/evaluate_with_config.py --system zht-excel --enable context_precision context_recall faithfulness
|
||||
|
||||
# 禁用多个指标
|
||||
python scripts/evaluate_with_config.py --system zht-excel --disable answer_correctness faithfulness
|
||||
|
||||
# 组合使用:禁用慢速指标 + 禁用并行 + 禁用日志
|
||||
python scripts/evaluate_with_config.py --system zht-excel --disable answer_correctness --no-parallel --no-logging
|
||||
# 组合使用:禁用慢速指标 + 禁用并行 + 禁用日志 + 滚动更新
|
||||
python scripts/evaluate_with_config.py --system zht-excel --disable answer_correctness --no-parallel --no-logging --output data/results/test
|
||||
|
||||
可用指标:
|
||||
- context_precision: 上下文精确度(快速,~15秒)
|
||||
@@ -213,6 +233,7 @@ def main():
|
||||
- 快速测试: --disable answer_correctness
|
||||
- 质量优先: --enable context_precision faithfulness answer_relevance
|
||||
- 完整评估: (不使用 --disable 或 --enable)
|
||||
- 滚动更新: --output <path> (每完成一个问题就更新结果文件)
|
||||
"""
|
||||
)
|
||||
|
||||
@@ -258,6 +279,13 @@ def main():
|
||||
help='禁用详细日志记录(默认启用)'
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
'--output',
|
||||
type=str,
|
||||
dest='output_file',
|
||||
help='输出文件路径(将实现滚动更新:每完成一个问题就更新文件)'
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
# 检查是否同时指定了 --enable 和 --disable
|
||||
@@ -272,6 +300,7 @@ def main():
|
||||
print(f"系统: {args.system}")
|
||||
print(f"并行: {'启用' if not args.no_parallel else '禁用'}")
|
||||
print(f"日志: {'启用' if not args.no_logging else '禁用'}")
|
||||
print(f"滚动更新: {'启用' if args.output_file else '禁用'}")
|
||||
|
||||
if args.enabled_metrics:
|
||||
print(f"启用的指标: {', '.join(args.enabled_metrics)}")
|
||||
@@ -279,6 +308,12 @@ def main():
|
||||
print(f"禁用的指标: {', '.join(args.disabled_metrics)}")
|
||||
else:
|
||||
print("指标: 全部启用(默认)")
|
||||
|
||||
if args.output_file:
|
||||
print(f"输出文件: {args.output_file}")
|
||||
print(f" - 正向用例: {Path(args.output_file).parent / Path(args.output_file).stem}_positive.json")
|
||||
print(f" - 负向用例: {Path(args.output_file).parent / Path(args.output_file).stem}_negative.json")
|
||||
|
||||
print("=" * 80)
|
||||
|
||||
# 运行评估
|
||||
@@ -288,7 +323,8 @@ def main():
|
||||
enable_parallel=not args.no_parallel,
|
||||
enable_logging=not args.no_logging,
|
||||
disabled_metrics=args.disabled_metrics,
|
||||
enabled_metrics=args.enabled_metrics
|
||||
enabled_metrics=args.enabled_metrics,
|
||||
output_file=args.output_file
|
||||
))
|
||||
|
||||
return exit_code
|
||||
|
||||
Reference in new issue
Block a user