meeting_summury/README.md

83 lines
3.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# Meeting Summary Lab
这是从 Meetily 提取出的纯 Python 长会议总结测试项目。输入是**已经得到的会议文字稿**;不含 ASR、音频、数据库、录音或界面。
它严格复现原项目的核心路线:
```text
完整文字稿
-> 估算 token 数
-> 超过阈值则按窗口切块(相邻块重叠 100 tokens
-> 每个块提取关键点、决策、行动项、人员
-> 一次性合并各块摘要
-> 按 Markdown 模板生成最终会议纪要
```
默认采用与原项目一致的粗略估算:`字符数 * 0.35`。块切分优先在句末(`. `)或空格处断开。
## 安装
项目依赖 PyYAML用于加载可编辑的 YAML 提示词配置。可直接用源码运行:
```powershell
cd meeting-summary-lab
$env:PYTHONPATH = "src"
python -m meeting_summary_lab chunk --input .\examples\meeting.txt --context-tokens 4096
python -m meeting_summary_lab summarize --input .\examples\meeting.txt --fake --output .\report.md
```
也可以安装为本地命令:
```powershell
python -m pip install -e .
meeting-summary-lab summarize --input .\examples\meeting.txt --fake
```
## 可独立测试的功能单元
| 单元 | 命令 / API | 用途 |
| --- | --- | --- |
| Token 估算 | `rough_token_count(text)` | 验证触发分块的阈值 |
| 切块 | `chunk_text(text, size, overlap)``chunk` | 验证块尺寸、重叠与边界 |
| 单块摘要 | `SummarizationPipeline.summarize_chunk()` | 验证 map prompt |
| 摘要合并 | `combine_chunk_summaries()` | 验证 reduce prompt |
| 模板报告 | `render_final_report()` | 验证 Markdown 模板化 |
| 全链路 | `summarize` | 验证单次/分块两种路径 |
## 调整提示词
默认中文提示词位于 `prompt/zh/base.yaml`。其中 `system` 管理各阶段系统提示词,`prompts` 管理 map、reduce 和最终报告的用户提示词模板,`templates.final_output` 管理默认 Markdown 结构。修改 YAML 后,下次启动程序即可生效,无需改动 Python 代码。
## 使用真实本地模型Ollama
先启动 Ollama 并准备模型,例如:
```powershell
ollama pull qwen3:4b
$env:PYTHONPATH = "src"
python -m meeting_summary_lab summarize `
--input .\examples\meeting.txt `
--endpoint http://localhost:11434/v1 `
--model qwen3:4b `
--context-tokens 8192 `
--output .\report.md
```
客户端使用 OpenAI 兼容的 `/chat/completions` 协议,因此也可以指向 vLLM、LM Studio 或企业内部兼容网关。`--api-key` 是可选的;默认从 `OPENAI_API_KEY` 读取。
## 离线全流程测试
加入 `--fake` 可使用确定性测试模型:它不会调用任何网络,而是记录每一步 prompt 并生成可检查的占位结果。这适合验证切块、调用次数和模板结构;不代表真实模型质量。
```powershell
$env:PYTHONPATH = "src"
python -m unittest discover -s tests -v
python -m meeting_summary_lab summarize --input .\examples\meeting.txt --fake --context-tokens 500
```
## 与 Meetily 原实现一致的限制
这是**单层 Map-Reduce**:块摘要会在一次请求中统一合并,随后再执行一次模板化请求。极端长会议可能使“摘要合并”或“最终模板化”仍超出上下文;该项目刻意保留这一行为,方便复现和测试。若你要消除该限制,可在 `combine_chunk_summaries()` 外再套递归分组归并。