docs: Scene VLM summary fix documentation
- Document root cause: using reasoning_content instead of content - Explain Gemma4 response structure - Provide data repair options - Add monitoring and verification steps Related: M5Max48 deep scan VLM summary issue
This commit is contained in:
@@ -0,0 +1,218 @@
|
||||
# Scene VLM Summary Fix - 2026-10-08
|
||||
|
||||
## 问题
|
||||
|
||||
M5Max48 deep scan 的 VLM summary 没有产出。
|
||||
|
||||
### 现象
|
||||
|
||||
```sql
|
||||
SELECT
|
||||
COUNT(*) as total_traces,
|
||||
COUNT(vlm_description) as has_vlm,
|
||||
COUNT(CASE WHEN vlm_description IS NOT NULL AND vlm_description != '' THEN 1 END) as non_empty_vlm
|
||||
FROM public.trace_profiles;
|
||||
|
||||
-- 结果:
|
||||
-- total_traces | has_vlm | non_empty_vlm
|
||||
-- --------------+---------+---------------
|
||||
-- 10780 | 1 | 1
|
||||
```
|
||||
|
||||
- 10,780 个 trace_profiles,只有 1 个有 vlm_description
|
||||
- Worker 日志: `[Scene VLM] ✅ Generated 0 descriptions, 3 failed`
|
||||
|
||||
## 根因
|
||||
|
||||
**代码问题**: `src/core/processor/scene_vlm.rs:574-579`
|
||||
|
||||
**原始代码**:
|
||||
```rust
|
||||
// Try reasoning_content first (Gemma4), fall back to content
|
||||
let content = message
|
||||
.get("reasoning_content")
|
||||
.and_then(|c| c.as_str())
|
||||
.or_else(|| message.get("content").and_then(|c| c.as_str()))
|
||||
.unwrap_or("")
|
||||
.to_string();
|
||||
```
|
||||
|
||||
**问题分析**:
|
||||
1. Gemma4 返回两种内容:
|
||||
- `reasoning_content`: 思考过程(The user wants... I need to...)
|
||||
- `content`: 最终答案(A man wearing...)
|
||||
2. 代码优先使用 `reasoning_content`,导致使用了思考过程而非答案
|
||||
3. 思考过程通常很长,不符合场景描述格式
|
||||
|
||||
**测试验证**:
|
||||
```bash
|
||||
curl -X POST "http://localhost:8080/v1/chat/completions" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"model": "gemma-4-12b-it", "messages": [...]}'
|
||||
|
||||
# 返回:
|
||||
{
|
||||
"content": "A man wearing a red vest...", # 正确答案
|
||||
"reasoning_content": "Here's a thinking process..." # 思考过程
|
||||
}
|
||||
```
|
||||
|
||||
## 修复
|
||||
|
||||
**修改**: `src/core/processor/scene_vlm.rs:574-585`
|
||||
|
||||
**新代码**:
|
||||
```rust
|
||||
// Try content first (final answer), fall back to reasoning_content if content is empty
|
||||
let content = match message
|
||||
.get("content")
|
||||
.and_then(|c| c.as_str())
|
||||
.filter(|s| !s.is_empty())
|
||||
{
|
||||
Some(s) => s.to_string(),
|
||||
None => message
|
||||
.get("reasoning_content")
|
||||
.and_then(|c| c.as_str())
|
||||
.unwrap_or("")
|
||||
.to_string(),
|
||||
};
|
||||
|
||||
if content.is_empty() {
|
||||
anyhow::bail!("VLM returned empty response");
|
||||
}
|
||||
```
|
||||
|
||||
**改进**:
|
||||
1. 优先使用 `content`(最终答案)
|
||||
2. 只有当 `content` 为空时,才 fallback 到 `reasoning_content`
|
||||
3. 如果两者都为空,返回错误
|
||||
|
||||
### 提交
|
||||
|
||||
- **Commit**: `2ec0bc67`
|
||||
- **Date**: 2026-10-08
|
||||
- **Status**: ✅ 已部署
|
||||
|
||||
## 验证
|
||||
|
||||
### 测试 VLM API
|
||||
|
||||
```bash
|
||||
# 测试图片描述生成
|
||||
curl -X POST "http://localhost:8080/v1/chat/completions" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"model": "gemma-4-12b-it",
|
||||
"messages": [{
|
||||
"role": "user",
|
||||
"content": [
|
||||
{"type": "text", "text": "Describe this scene..."},
|
||||
{"type": "image_url", "image_url": {"url": "data:image/jpeg;base64,..."}}
|
||||
]
|
||||
}],
|
||||
"max_tokens": 800
|
||||
}' | jq '.choices[0].message | {content, reasoning_content}'
|
||||
|
||||
# 结果:
|
||||
{
|
||||
"content": "A man wearing a red vest and glasses is practicing his golf swing...",
|
||||
"reasoning_content": "Here's a thinking process that leads to the description..."
|
||||
}
|
||||
```
|
||||
|
||||
✅ 验证通过:`content` 包含正确的场景描述
|
||||
|
||||
### Worker 验证
|
||||
|
||||
```bash
|
||||
# 重启 worker
|
||||
pkill -9 -f "momentry worker"
|
||||
./target/release/momentry worker > logs/worker_3002.log 2>&1 &
|
||||
|
||||
# 观察日志
|
||||
tail -f logs/worker_3002.log | grep "Scene VLM"
|
||||
```
|
||||
|
||||
## 数据修复方案
|
||||
|
||||
### 现有数据状态
|
||||
|
||||
| 统计项 | 数量 |
|
||||
|--------|------|
|
||||
| 总 trace_profiles | 10,780 |
|
||||
| 有 vlm_description | 1 |
|
||||
| 缺少 vlm_description | 10,779 |
|
||||
|
||||
### 方案 1: 等待新文件(推荐)
|
||||
|
||||
- 新注册的文件会自动使用修复后的代码
|
||||
- 无需手动干预
|
||||
- 适合: 新项目或数据不重要
|
||||
|
||||
### 方案 2: 重新处理历史文件
|
||||
|
||||
**步骤**:
|
||||
1. 清空 vlm_description:
|
||||
```sql
|
||||
UPDATE public.trace_profiles
|
||||
SET vlm_description = NULL
|
||||
WHERE vlm_description IS NULL OR vlm_description = '';
|
||||
```
|
||||
|
||||
2. 触发重新生成:
|
||||
- 选项 A: 重新注册文件
|
||||
- 选项 B: 手动调用 Scene VLM API
|
||||
- 选项 C: 编写批量处理脚本
|
||||
|
||||
**时间估算**:
|
||||
- 每个 trace: ~5-10 秒
|
||||
- 总计: 10,779 × 8秒 ≈ 23.9 小时(串行)
|
||||
- 可并行处理,缩短至 2-4 小时
|
||||
|
||||
### 方案 3: 混合方案
|
||||
|
||||
- 重要文件: 手动重新处理
|
||||
- 不重要文件: 等待自然更新
|
||||
|
||||
## 监控
|
||||
|
||||
### 日志监控
|
||||
|
||||
```bash
|
||||
# 查看 Scene VLM 生成进度
|
||||
grep "Scene VLM" logs/worker_3002.log | grep -E "Generated|Completed|Failed"
|
||||
|
||||
# 查看 VLM description 数量变化
|
||||
watch -n 10 'psql -t -A -c "SELECT COUNT(*) FROM trace_profiles WHERE vlm_description IS NOT NULL"'
|
||||
```
|
||||
|
||||
### 关键指标
|
||||
|
||||
- **VLM 成功率**: `vlm_description != NULL` 的比例
|
||||
- **平均生成时间**: 每个文件的处理耗时
|
||||
- **错误率**: `Failed` 记录 vs `Completed` 记录
|
||||
|
||||
## 相关文档
|
||||
|
||||
- `/Users/accusys/momentry_core/src/core/processor/scene_vlm.rs` - Scene VLM 实现
|
||||
- `/Users/accusys/momentry_core/logs/worker_3002.log` - Worker 日志
|
||||
- `docs_v1.0/M4_workspace/2026-10-07_visual_search_fault_analysis.md` - VLM Search 故障分析
|
||||
|
||||
## 下一步行动
|
||||
|
||||
**立即**:
|
||||
1. ✅ 代码已修复
|
||||
2. ✅ Worker 已重启
|
||||
3. ⏳ 验证新文件是否正确生成 VLM description
|
||||
|
||||
**后续**:
|
||||
1. 决定是否重新生成历史数据
|
||||
2. 编写批量处理脚本(如需要)
|
||||
3. 监控 VLM 服务稳定性
|
||||
|
||||
---
|
||||
|
||||
**修复者**: Core Team
|
||||
**修复日期**: 2026-10-08
|
||||
**影响范围**: Scene VLM, trace_profiles
|
||||
**状态**: ✅ 代码已修复,Worker 已重启
|
||||
Reference in New Issue
Block a user