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
@@ -131,6 +131,21 @@ if "%LOG_CHOICE%"=="2" (
|
||||
set LOG_DESC=启用
|
||||
)
|
||||
|
||||
echo.
|
||||
echo 是否启用滚动更新(每完成一个问题就保存结果)?
|
||||
echo 1. 启用(推荐,防止数据丢失)
|
||||
echo 2. 禁用(默认)
|
||||
echo.
|
||||
set /p ROLLING_CHOICE=请输入选项 (1-2):
|
||||
|
||||
if "%ROLLING_CHOICE%"=="1" (
|
||||
set ROLLING_ENABLED=1
|
||||
set ROLLING_DESC=启用
|
||||
) else (
|
||||
set ROLLING_ENABLED=0
|
||||
set ROLLING_DESC=禁用
|
||||
)
|
||||
|
||||
echo.
|
||||
echo ========================================
|
||||
echo 时间预估(基于 15 个问题/系统)
|
||||
@@ -180,6 +195,18 @@ set START_TIME=%date% %time%
|
||||
echo 开始时间: %START_TIME%
|
||||
echo.
|
||||
|
||||
REM 如果启用滚动更新,创建结果目录并生成时间戳
|
||||
if %ROLLING_ENABLED%==1 (
|
||||
set TIMESTAMP=%date:~0,4%%date:~5,2%%date:~8,2%_%time:~0,2%%time:~3,2%%time:~6,2%
|
||||
set TIMESTAMP=!TIMESTAMP: =0!
|
||||
echo 滚动更新已启用
|
||||
echo 输出目录: data/results/rolling_!TIMESTAMP!
|
||||
echo.
|
||||
if not exist "data\results\rolling_!TIMESTAMP!" (
|
||||
mkdir "data\results\rolling_!TIMESTAMP!"
|
||||
)
|
||||
)
|
||||
|
||||
REM 初始化计数器和失败列表
|
||||
set CURRENT=0
|
||||
set FAILED_LIST=
|
||||
@@ -192,7 +219,11 @@ for %%s in (%SYSTEMS%) do (
|
||||
echo ========================================
|
||||
|
||||
REM 执行评估(使用新的可配置脚本)
|
||||
python scripts/evaluate_with_config.py --system %%s %MODE_FLAG% %PARALLEL_FLAG% %LOG_FLAG%
|
||||
if %ROLLING_ENABLED%==1 (
|
||||
python scripts/evaluate_with_config.py --system %%s %MODE_FLAG% %PARALLEL_FLAG% %LOG_FLAG% --output data/results/rolling_!TIMESTAMP!/%%s
|
||||
) else (
|
||||
python scripts/evaluate_with_config.py --system %%s %MODE_FLAG% %PARALLEL_FLAG% %LOG_FLAG%
|
||||
)
|
||||
|
||||
REM 检查执行结果
|
||||
if !errorlevel! neq 0 (
|
||||
@@ -218,6 +249,12 @@ echo.
|
||||
echo 开始时间: %START_TIME%
|
||||
echo 结束时间: %date% %time%
|
||||
echo.
|
||||
echo 评估配置:
|
||||
echo - 评估模式: %MODE_DESC%
|
||||
echo - 并行评估: %PARALLEL_DESC%
|
||||
echo - 日志记录: %LOG_DESC%
|
||||
echo - 滚动更新: %ROLLING_DESC%
|
||||
echo.
|
||||
|
||||
REM 显示失败的系统
|
||||
if not "%FAILED_LIST%"=="" (
|
||||
@@ -228,9 +265,18 @@ if not "%FAILED_LIST%"=="" (
|
||||
echo.
|
||||
)
|
||||
|
||||
REM 查看日志位置
|
||||
REM 查看日志和报告位置
|
||||
echo 日志文件位置: logs\
|
||||
echo 报告文件位置: data/results\
|
||||
if %ROLLING_ENABLED%==1 (
|
||||
echo 报告文件位置: data/results/rolling_!TIMESTAMP!\
|
||||
echo.
|
||||
echo 滚动更新文件说明:
|
||||
echo - 每个系统生成两个文件: *_positive.json 和 *_negative.json
|
||||
echo - 这些文件在评估过程中实时更新
|
||||
echo - 文件包含完整的评估状态和进度信息
|
||||
) else (
|
||||
echo 报告文件位置: data/results\
|
||||
)
|
||||
echo.
|
||||
|
||||
pause
|
||||
@@ -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