67 lines
2.9 KiB
Markdown
67 lines
2.9 KiB
Markdown
# Output Consistency for Multi-Campus Batch Processing
|
|
|
|
**Lesson learned**: 2026-06-30 — 跃龙路 vs 解放中路/星月等7校区
|
|
|
|
## Root Cause: LLM Context Anchoring
|
|
|
|
LLM output style is heavily influenced by what's in the context window:
|
|
- **Consecutive processing** (same session, same time window): previous campus outputs are still in context → LLM naturally "copies the style" → consistent output
|
|
- **Separated processing** (different session, different time): previous outputs are gone → LLM generates with its own default style → drift
|
|
|
|
This is NOT a workflow bug or a rules problem. The rules were the same. The output format specification was the same. But the LLM produced different styles because the **contextual anchor** was different.
|
|
|
|
Maggie's concern (verbatim): "金额,风险,模版对比各列内容的审查和修改意见表达都不一样了...第一批里从解放中路到星月的审查逻辑和表达都是一致的,为什么到跃龙路又变掉了?"
|
|
|
|
## Three-Layer Defense
|
|
|
|
### Layer 1: Fixed Templates in Workflow Prompt (hardest constraint)
|
|
|
|
Embed complete output examples + "禁止" (prohibited) rules directly in the data-extractor role's procedure section. Example structure:
|
|
|
|
```yaml
|
|
H列格式规范:
|
|
风格: 段落式叙述
|
|
结构: 【租金】→【付款推算】→【押金】→【物业费】→【违约金】
|
|
禁止:
|
|
- bullet符号(•、-、*)
|
|
- "【大类·条款号】"合并标题
|
|
- 过度拆分为逐行小条目
|
|
|
|
K列格式规范:
|
|
风格: 先【整体评价】段落,再❗【需客户核实】编号列表
|
|
禁止:
|
|
- "10项风险(3高/5中/2低):"统计式开头
|
|
- "1.【高·第十条】"标签格式
|
|
- markdown表格列风险
|
|
|
|
L列格式规范:
|
|
风格: 一句话说明+编号列表
|
|
禁止:
|
|
- "34处差异(16缺失/15修改/3新增)vs 07模版:"统计式开头
|
|
- "【核心缺失】"分类小标题
|
|
- "vs"分隔模版和合同
|
|
```
|
|
|
|
Updated in nantong-lease-audit.yaml v2 (hash: `C77579MQ9QPKE`).
|
|
|
|
### Layer 2: Load Previous Campus Output as Reference
|
|
|
|
Before generating data for a new campus, read the most recent completed campus xlsx and extract H/K/L column content as style reference:
|
|
|
|
```bash
|
|
REF_XLSX=$(ls -t /path/to/campuses/*/*梳理*.xlsx 2>/dev/null | head -1)
|
|
```
|
|
|
|
Use openpyxl to read H/K/L values from the first data row, inject into the data-extractor prompt context.
|
|
|
|
### Layer 3: Post-Processing Validation Script
|
|
|
|
Run `scripts/output-style-check.py <row-data.json>` after data extraction:
|
|
- Checks 8 rules across H/K/L/J columns
|
|
- Exit 0 = pass, exit 1 = fail (lists specific issues)
|
|
- If fail → fix the specific issues before proceeding to xlsx generation
|
|
|
|
## Key Insight
|
|
|
|
Rules alone are insufficient to prevent style drift. The LLM needs **concrete examples in context** at the moment of generation. Three layers provide redundancy: if Layer 1 is imperfectly followed, Layer 2 gives a fresh anchor, and Layer 3 catches what slips through.
|