Seed demo LLM analysis reports by UI language.
Browse filesImport zh/en markdown into llm_analysis_cache on first startup and load cached analysis by lang in the annotation analysis tab.
Files changed (9)
7 unmodified lines89101112137 unmodified linesCOPY qa_annotate/ qa_annotate/COPY scripts/ scripts/COPY seed/demo.sql seed/demo.sqlRUN pip install --no-cache-dir .7 unmodified lines891011121314157 unmodified linesCOPY qa_annotate/ qa_annotate/COPY scripts/ scripts/COPY seed/demo.sql seed/demo.sqlCOPY seed/llm-analysis-2026-06-15_zh.md seed/llm-analysis-2026-06-15_zh.mdCOPY seed/llm-analysis-2026-06-15_en.md seed/llm-analysis-2026-06-15_en.mdRUN pip install --no-cache-dir .
158 unmodified lines159160161162163164165166167168169170158 unmodified linesproject_id: int,db: Session = Depends(get_db),current_user: User = Depends(get_current_superuser),):"""获取项目缓存的 LLM 分析报告需要 superuser 权限。"""cached = LlmAnalysisCacheCRUD.get_by_project(db, project_id)if not cached:raise HTTPException(status_code=404, detail="暂无缓存的分析报告")158 unmodified lines159160161162163164165166167168169170171172173174158 unmodified linesproject_id: int,db: Session = Depends(get_db),current_user: User = Depends(get_current_superuser),lang: str = Query("zh", description="Report language: zh or en"),):"""获取项目缓存的 LLM 分析报告需要 superuser 权限。"""language = "en" if lang.lower().startswith("en") else "zh"cached = LlmAnalysisCacheCRUD.get_by_project(db, project_id=project_id, language=language)if not cached:raise HTTPException(status_code=404, detail="暂无缓存的分析报告")
123456789101112131416 unmodified lines313233"""应用启动时的数据库初始化辅助函数"""from qa_annotate.config import settingsfrom qa_annotate.database.base import SessionLocalfrom qa_annotate.database.crud import SystemConfigCRUD_LLM_CONFIG_SPECS = (("llm_base_url", "LLM_BASE_URL", "LLM API Base URL"),("llm_model_name", "LLM_MODEL_NAME", "LLM Model Name"),)def ensure_llm_config() -> None:"""写入 LLM 默认配置;API Key 优先从环境变量同步。"""16 unmodified linesprint("已从环境变量同步 LLM API Key")finally:db.close()12345678910111213141516171819202122232416 unmodified lines41424344454647484950515253545556575859606162636465666768697071727374"""应用启动时的数据库初始化辅助函数"""from pathlib import Pathfrom qa_annotate.config import settingsfrom qa_annotate.database.base import SessionLocalfrom qa_annotate.database.crud import LlmAnalysisCacheCRUD, SystemConfigCRUDfrom qa_annotate.database.models import ProjectModel_LLM_CONFIG_SPECS = (("llm_base_url", "LLM_BASE_URL", "LLM API Base URL"),("llm_model_name", "LLM_MODEL_NAME", "LLM Model Name"),)_SEED_DIR = Path(__file__).resolve().parent.parent / "seed"_DEMO_ANALYSIS_FILES = {"zh": _SEED_DIR / "llm-analysis-2026-06-15_zh.md","en": _SEED_DIR / "llm-analysis-2026-06-15_en.md",}_DEMO_ANALYSIS_NOTES_COUNT = 4def ensure_llm_config() -> None:"""写入 LLM 默认配置;API Key 优先从环境变量同步。"""16 unmodified linesprint("已从环境变量同步 LLM API Key")finally:db.close()def seed_demo_llm_analysis() -> None:"""从 seed 目录下的示例 Markdown 预置中英文 LLM 分析报告。"""db = SessionLocal()try:project = db.query(ProjectModel).order_by(ProjectModel.id).first()if not project:print("无项目数据,跳过 Demo LLM 分析报告导入")returnfor language, path in _DEMO_ANALYSIS_FILES.items():if not path.exists():print(f"未找到 {path.name},跳过")continueif LlmAnalysisCacheCRUD.get_by_project(db, project_id=project.id, language=language):continueLlmAnalysisCacheCRUD.save(db=db,project_id=project.id,analysis_text=path.read_text(encoding="utf-8"),model_name=settings.LLM_MODEL_NAME,notes_count=_DEMO_ANALYSIS_NOTES_COUNT,language=language,)print(f"已导入 Demo LLM 分析报告: project={project.id} lang={language}")finally:db.close()
2223 unmodified lines222422252226222722282229223022312232223322342235223622372238223922402241224217 unmodified lines22602261226222632264226522662223 unmodified lines"""LLM 分析报告缓存 CRUD 操作"""@staticmethoddef get_by_project(db: Session, project_id: int) -> Optional[dict]:"""获取项目最新的分析报告缓存Returns:包含 analysis_text, model_name, notes_count, language, created_at, updated_at 的字典,如果没有缓存则返回 None"""db_model = (db.query(LlmAnalysisCacheModel).filter(LlmAnalysisCacheModel.project_id == project_id).order_by(LlmAnalysisCacheModel.updated_at.desc()).first())if not db_model:return Nonereturn {17 unmodified lines"""保存分析报告缓存(如果已有则更新,否则创建)"""db_model = (db.query(LlmAnalysisCacheModel).filter(LlmAnalysisCacheModel.project_id == project_id).first())if db_model:2223 unmodified lines222422252226222722282229223022312232223322342235223622372238223917 unmodified lines22572258225922602261226222632264226522662223 unmodified lines"""LLM 分析报告缓存 CRUD 操作"""@staticmethoddef get_by_project(db: Session, project_id: int, language: str | None = None) -> Optional[dict]:"""获取项目分析报告缓存(可按语言筛选)"""query = db.query(LlmAnalysisCacheModel).filter(LlmAnalysisCacheModel.project_id == project_id)if language:query = query.filter(LlmAnalysisCacheModel.language == language)db_model = query.order_by(LlmAnalysisCacheModel.updated_at.desc()).first()if not db_model:return Nonereturn {17 unmodified lines"""保存分析报告缓存(如果已有则更新,否则创建)"""db_model = (db.query(LlmAnalysisCacheModel).filter(LlmAnalysisCacheModel.project_id == project_id,LlmAnalysisCacheModel.language == language,).first())if db_model:
18 unmodified lines1920212223242521 unmodified lines47484950515218 unmodified linesfrom qa_annotate.api.system_config import router as system_config_routerfrom qa_annotate.api.user import router as user_routerfrom qa_annotate.config import settingsfrom qa_annotate.bootstrap import ensure_llm_configfrom qa_annotate.database.base import init_db21 unmodified lines# 启动时执行init_db()ensure_llm_config()yield# 关闭时执行(如果需要清理资源,可以在这里添加)18 unmodified lines1920212223242521 unmodified lines4748495051525318 unmodified linesfrom qa_annotate.api.system_config import router as system_config_routerfrom qa_annotate.api.user import router as user_routerfrom qa_annotate.config import settingsfrom qa_annotate.bootstrap import ensure_llm_config, seed_demo_llm_analysisfrom qa_annotate.database.base import init_db21 unmodified lines# 启动时执行init_db()ensure_llm_config()seed_demo_llm_analysis()yield# 关闭时执行(如果需要清理资源,可以在这里添加)
36 unmodified lines3738394041424336 unmodified lines*/loadCachedAnalysis: async function() {try {const response = await apiGet(`/analysis/projects/${this.currentProjectId}/cached-analysis`);if (response) {this.renderLlmAnalysisResult(response);const btn = document.getElementById('generateLlmAnalysisBtn');36 unmodified lines373839404142434445464736 unmodified lines*/loadCachedAnalysis: async function() {try {const currentLang = (window.i18next && window.i18next.language) || 'zh';const lang = currentLang.startsWith('zh') ? 'zh' : 'en';const response = await apiGet(`/analysis/projects/${this.currentProjectId}/cached-analysis?lang=${lang}`);if (response) {this.renderLlmAnalysisResult(response);const btn = document.getElementById('generateLlmAnalysisBtn');
10 unmodified lines1112131415161782 unmodified lines10010110210310410510 unmodified linesproject_root = Path(__file__).parent.parentsys.path.insert(0, str(project_root))from qa_annotate.bootstrap import ensure_llm_config # noqa: E402from qa_annotate.config import settings # noqa: E402from qa_annotate.database.base import SessionLocal, init_db # noqa: E402from qa_annotate.database.crud import UserCRUD # noqa: E40282 unmodified linesinit_db()ensure_superuser()ensure_llm_config()if __name__ == "__main__":10 unmodified lines1112131415161782 unmodified lines10010110210310410510610 unmodified linesproject_root = Path(__file__).parent.parentsys.path.insert(0, str(project_root))from qa_annotate.bootstrap import ensure_llm_config, seed_demo_llm_analysis # noqa: E402from qa_annotate.config import settings # noqa: E402from qa_annotate.database.base import SessionLocal, init_db # noqa: E402from qa_annotate.database.crud import UserCRUD # noqa: E40282 unmodified linesinit_db()ensure_superuser()ensure_llm_config()seed_demo_llm_analysis()if __name__ == "__main__":
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271## Overview
The current project is in an early stage with a small dataset (50 QA pairs) and low full-coverage annotation (20%). One scoring config (“test1111”) has full coverage and shows a mid–low average score (2.66/5), suggesting overall quality is mediocre with few very good items. The domain relevance config has low coverage (20%) but indicates most items are at best moderately useful. Annotation notes are sparse and low-content, which limits diagnostic detail. The pipeline likely needs substantial quality improvements and better-designed annotation guidance.
---
## Annotation Results Analysis
### 1. Overall annotation coverage
- Total QA pairs: 50 - At least one config annotated: 50 (100%) - Fully annotated (all configs): 10 (20%)
Implications:- Most QA pairs only have partial evaluation. - Any conclusions about “领域相关性与价值” are based on a small subset (10 items), so domain-related findings are indicative but not robust. - For pipeline iteration, the test1111 score data is more reliable than the domain relevance labels.
### 2. Config: `test1111` (score 1–5)
- Coverage: 50/50 (100%) - Average score: 2.66 - Distribution: - 1: 6 - 2: 16 - 3: 18 - 4: 9 - 5: 1
Observations:- Scores cluster in the mid range (2–3): 34/50 (68%). - Very high quality (score 5) is almost absent (1/50 = 2%). - Very low quality (score 1) exists but is not dominant (12%). - The long “tail” of 2–3 indicates many “acceptable but flawed” QAs rather than clearly good or clearly bad.
Potential interpretations:- The generation pipeline produces content that is rarely excellent and often requires improvement to reach high-quality standards. - Scoring rubric may be applied conservatively; annotators might be hesitant to give 4–5 unless an item is near-perfect. - There might be limited diversity in quality: mostly similar “average” level outputs, potentially due to conservative generation settings or prompt patterns.
### 3. Config: `领域相关性与价值` (single_choice)
- Coverage: 10/50 (20%) - Labels: - 相关性强,有实用价值但需结合具体场景: 2 - 部分相关,价值有限: 4 - 相关但价值平庸: 4
Observations:- No items are marked as “完全无关 / 无价值” (if such a category exists) in this small sample. - Only 2/10 items are both strongly relevant and practically valuable. - 8/10 items are either partially relevant with limited value or just mediocre in value.
Implications:- Within the small subset, “truly valuable” QAs are a minority. - The data may be somewhat on-topic but often lacks strong practical utility. - There might be a tendency to avoid extreme negative labels, similar to the test1111 scoring distribution.
---
## Annotation Notes Analysis
Notes are very sparse and mostly low information:
### `test1111` notes (3)
1. “可以的” (“OK / acceptable”) 2. “发发” (likely filler, typo, or non-meaningful content) 3. “答复” (“reply”, essentially restating the concept)
### `领域相关性与价值` notes (1)
1. “不太确定” (“not quite sure / uncertain”)
Key observations:- Almost no detailed, diagnostic feedback (e.g., no mention of specific issues like hallucinations, ambiguity, missing context, etc.).- At least one annotator expresses uncertainty about how to label domain relevance/value (“不太确定”). - Some notes (“发发”) suggest that annotators may not be using the remark field strictly for substantive comments, or the system did not clearly explain the purpose of the notes.
Implications:- The current annotation guideline may be insufficiently clear or detailed, especially for “领域相关性与价值”. - Lack of structured error tags or required fields leads to low-quality notes, making it hard to trace back specific failure modes in the QA generation. - Annotators may not see strong incentives or instructions to provide detailed notes.
---
## QA Generation Pipeline Improvement Suggestions
Below are concrete, pipeline-oriented suggestions grouped by theme.
### 1. Data Quality Issues to Address
Based on the mid–low scores and “mediocre but relevant” domain labels, common likely issues include:
1. **Shallow or generic answers** - Many items appear “OK” but not excellent (scores 2–3; “价值平庸”). - Likely issues: - Answers too generic or high-level. - Lack of concrete examples or actionable detail. - Not sufficiently adapted to the specific scenario implied by the question.
2. **Limited practical value** - Only 2/10 in the domain config are “相关性强,有实用价值”. - Likely issues: - Answers may restate obvious information without deeper insights. - Missing domain-specific constraints (e.g., industry standards, real-world constraints).
3. **Unclear relevance / annotator uncertainty** - “不太确定” indicates: - QA context may be ambiguous (unclear domain or target use case). - Label definitions for “相关性 / 价值” are not clear enough. Given the lack of explicit error notes, you should explicitly check for:- Hallucinations or factual inaccuracies.- Misinterpretation of the question (answering a different question).- Incomplete answers (missing key parts).- Overly verbose but low-information answers.
### 2. Generation Strategy Adjustments
To move more items from score 2–3 into 4–5 and increase “strongly relevant and valuable” items, consider the following:
#### 2.1 Prompt design
1. **Explicit quality criteria in the prompt** - Add clear instructions such as: - “Answer concisely but with sufficient detail to be practically useful.” - “If the question is ambiguous, state your assumptions explicitly.” - “Provide domain-specific examples or scenarios where relevant.” - Include negative instructions: - “Avoid generic, vague statements.” - “Do not repeat the question; focus on providing new information.”
2. **Domain anchoring** - If the dataset targets a specific domain, explicitly include: - Domain description. - Target user persona (e.g., junior engineer vs. manager). - Usage scenario. - Example: - “You are answering questions for [domain] practitioners. Focus on practical steps, tools, and best practices used in real projects.”
3. **Structured answer templates** - For certain question types (how-to, comparison, definition), impose soft templates: - Definition → Key points → Example → Short summary. - Steps → Warnings/pitfalls → Practical tips. - This improves consistency and usefulness, making 4–5 scores more likely.
4. **Encourage self-checking** - Add meta instructions: - “Before finalizing the answer, verify that all parts of the question are addressed and that no unsupported claims are made.”
#### 2.2 Model selection and parameters
1. **Model choice** - If using smaller or older models for generation, consider: - Upgrading to a stronger model for complex or domain-heavy content. - Using a two-stage pipeline: initial generation by a fast model, refinement by a stronger one.
2. **Decoding parameters** - If current outputs are too safe and generic: - Slightly increase temperature/top-p to allow more diverse, richer content. - If outputs are verbose but not better: - Lower maximum tokens and instruct for concise but rich answers. - Use a constraint like “limit to X words, but ensure all key aspects are covered.”
3. **Two-pass generation** - Pass 1: Generate a structured outline (key points to cover). - Pass 2: Generate the final answer based on the outline. - This often improves completeness and coherence, especially for multi-part questions.
### 3. Quality Control and Screening
Given the mid-range scores, adding QA-specific quality checks before finalizing items is essential.
#### 3.1 Automatic filters
1. **Consistency & completeness check (LLM-as-judge)** - Use a separate model to evaluate each generated QA pair, with a rubric aligned with `test1111` and “领域相关性与价值”: - Does the answer directly address the question? - Is it factually plausible? (flag potential hallucinations) - Is it practically useful in the stated domain? - Discard or send for manual review any items judged as: - Very low quality (equivalent to 1–2). - Low relevance / value.
2. **Length and redundancy checks** - Use simple rules: - Discard answers that are too short (likely superficial) or excessively long with low information density (based on simple heuristics like type-token ratio or repeated phrases).
3. **Duplicate or near-duplicate detection** - Use embeddings to detect near-duplicate questions or answers. - Remove or down-sample highly similar QA pairs to increase diversity and avoid many similar mid-quality items.
#### 3.2 Human-in-the-loop review
1. **Double annotation for a sample** - For a subset of items, obtain test1111 scores from two annotators. - Measure agreement: - If agreement is low, refine guidelines and rubric. - If agreement is reasonable, use consensus scores to tune automatic filters.
2. **Structured error tags** - Update annotation interface to include checkboxes/tags like: - [ ] Factual error - [ ] Irrelevant answer - [ ] Too generic - [ ] Incomplete - [ ] Poor clarity/structure - [ ] Domain mismatch - Make at least one error tag mandatory when giving low scores (1–2). - This will immediately increase the diagnostic value of annotations.
3. **Guided free-text notes** - Change the “note” field label to something like: - “Briefly describe what is wrong or could be improved (e.g., missing details, unclear, off-topic).” - Provide examples of good notes: - “Missed addressing part B of the question.” - “Answer is correct but too high-level; lacks domain-specific examples.”
### 4. Data Distribution and Coverage Optimization
Even with a small dataset, you can start improving diversity and domain coverage.
#### 4.1 Balanced question types
- Review the 50 questions (internally) to identify underrepresented types: - Definitions/Concepts - How-to/Procedures - Comparisons/Trade-offs - Scenario-based questions - Error analysis/debugging type questions (if relevant to domain)- For any underrepresented type, generate additional QAs with prompts targeting those structures.
#### 4.2 Domain-specific coverage
- If “领域相关性与价值” is important, define: - Core subtopics in the domain. - Realistic user roles (e.g., beginner, intermediate, expert).- Ensure questions are sampled to cover: - Different subtopics uniformly. - Different difficulty levels (basic vs advanced).- Use prompt variations: - “Generate beginner-level questions about X.” - “Generate advanced troubleshooting questions about Y.”
#### 4.3 Difficulty and depth control
- Explicitly generate: - Simple questions for basic concepts (but ensure answers are clear and correct). - Complex, multi-step scenario questions for deeper analysis, using more powerful models and more rigorous validation.
#### 4.4 Active learning loop
- Use existing annotations: - Focus improvement on patterns common in low-scoring items (when more notes become available). - For borderline items (score 2–3), adjust prompts and re-generate, then re-evaluate to see whether scores shift upward.
---
## Summary
- Current QA quality is mostly mediocre: the average score is 2.66/5, with almost no top-quality (score 5) items and only 2/10 QAs rated as strongly relevant and practically valuable.- Annotation coverage is incomplete (20% full coverage), and notes are sparse and largely non-diagnostic, indicating a need for clearer annotation guidelines and structured error tagging.- To improve the QA generation pipeline, prioritize: 1) Better prompts: explicit quality criteria, domain anchoring, structured answer templates, and self-check instructions. 2) Stronger and more controlled generation: model upgrades where needed, tuned decoding, and possibly two-pass generation (outline + final answer). 3) Robust quality control: LLM-as-judge filters, heuristic checks, mandatory error tags, and improved annotator guidance. 4) Data distribution optimization: balance question types and domain subtopics, and systematically cover different difficulty levels.
Implementing these pipeline improvements should shift the score distribution toward 4–5, increase the proportion of “strongly relevant, practically valuable” QAs, and make future annotation data far more useful for iterative refinement.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241## 总体概述
从当前 50 条 QA 样本的标注情况看:
- 主评分配置(test1111)已全量覆盖,平均分 2.66,整体质量偏中下。- 评分分布集中在 2–3 分区间,高分(4–5 分)比例较低,仅有 1 条 5 分样本,说明现阶段生成的 QA 对整体“可用但不够好”,优质样本稀缺。- 领域相关性与价值的标注覆盖率仅 20%,且标注结果多为“部分相关/价值有限/平庸”,表明从已观察的样本看,真正“强相关且价值高”的 QA 较少。- 标注备注极少且内容空泛,标注反馈信号弱,无法有效支持细粒度问题诊断。
整体来看,这批 QA 数据处于“初步可用、但质量和价值都偏弱”的阶段,且当前标注体系对问题定位的支持不足,需要在生成端和标注端同时优化。
---
## 标注结果分析
### 1. 评分配置:test1111
- 覆盖率:100%(50/50)- 平均分:2.66- 分布情况: - 1 分:6 条(12%) - 2 分:16 条(32%) - 3 分:18 条(36%) - 4 分:9 条(18%) - 5 分:1 条(2%)
#### 发现与解读
1. **中间档(2–3 分)占比高(68%)** - 说明大多数 QA 对不存在严重问题,但也明显达不到高质量标准。 - 模型生成的答案大概率是“基本回答了,但不够精准/不够深入/不够贴合场景”。
2. **高分稀缺(4–5 分仅 20%,其中 5 分只有 1 条)** - 说明当前生成策略在“稳定产出高质量答案”方面表现不足,要么 prompt 不够明确,要么模型能力/温度设置导致答案不够可靠或不够丰富。
3. **低分样本(1–2 分)比例也不算低(44%)** - 存在较多“明显不佳”样本(答偏、质量差、无实质内容),说明生成管线缺乏有效的质量过滤机制。
### 2. 配置:领域相关性与价值
- 覆盖率:20%(10/50),说明此配置刚开始试用或标注还未完成。- 选项分布: - 相关性强,有实用价值但需结合具体场景: 2 - 部分相关,价值有限: 4 - 相关但价值平庸: 4 - 0 条“强相关且高度有价值”的样本(从现有选项看,目前没有非常高价值的标注记录)
#### 发现与解读
1. 已标注样本中,**“强相关且有明显价值”的比例很低**,多数只是“部分相关/价值有限/价值平庸”。这与 test1111 的平均分偏低相互印证:不仅质量一般,而且在任务/领域层面的实用性也一般。2. 仅 10 条样本参与了该维度标注,统计可靠性有限,但可作为早期信号:生成的 QA 对在“业务/领域实际使用价值”方面有明显提升空间。
---
## 标注备注分析
### 备注内容概览
- test1111(3 条): 1. “可以的” 2. “发发” 3. “答复”- 领域相关性与价值(1 条): 1. “不太确定”
### 问题与信号
1. **备注质量极低、缺乏问题指向性** - “可以的”“答复”基本不能提供任何可操作信息。 - “发发”近似无意义。 - 唯一有信息含量的“ 不太确定 ”表明:标注者在判断“领域相关性与价值”时存在理解或判断困难,说明: - 要么任务定义不清楚; - 要么问题/答案本身就模糊,难以判断价值。
2. **目前标注规范明显不完善** - 备注没有采用结构化方式(如选原因标签:事实错误/逻辑混乱/不符合领域/过于泛泛等),导致后续分析无法知道 1、2 分样本到底是哪里出了问题。
3. **无法从备注中抽取典型错误模式** - 现状:评分数据提示“质量不佳”,但备注无法告诉我们具体问题是:事实错误、风格不符合、无关内容、答非所问,还是缺乏深度。
---
## QA 生成管线改进建议
下面从四个方面给出可落地的改进建议。
### 一、数据质量问题归纳(基于统计推断 + 现有信号)
在没有详细文本的前提下,可结合评分分布和“领域价值偏低”这两个信号,推断生成端可能存在的常见问题类型:
1. **回答质量中庸,缺乏深度或结构** - 大量 2–3 分说明:回答通常能抓住主题,但不够系统或详尽,缺乏步骤、例子、清晰结构等,使得“可用但不优秀”。
2. **领域价值不高、泛泛而谈** - “部分相关/价值平庸”比例高:问题可能较宽泛、答案为通用解释而非针对具体场景,导致对实际业务/领域帮助有限。
3. **部分样本可能存在明显错误或偏题** - 1 分与 2 分样本占 44%,可以推测其中一部分存在明显的: - 事实性错误; - 完全答非所问; - 纯空话或废话。 - 但由于没有细致标签,目前无法精确定位哪种错误更常见。
因此,生成管线需要同时提升:**正确性、相关性、信息密度** 和 **场景贴合度**。
---
### 二、生成策略调整(Prompt、模型与参数)
在缺少具体内容的情况下,可以提出一套与统计现象匹配的通用调整方案:
#### 1. Prompt 设计优化
1. **明确回答质量标准** - 在系统 prompt 中显式要求: - 回答要围绕用户问题,避免无关扩展; - 优先提供结构化信息(分点、步骤、示例); - 回答必须具体、可执行,避免空泛表述。 - 示例策略(抽象表述): - 要求模型在回答结尾补充“简要总结”和“可操作建议”; - 对技术/业务问题,要求给出具体步骤或案例,而不仅是定义解释。
2. **强化领域/任务上下文** - 在生成时给模型提供: - 目标领域背景(如电商、金融、教育等); - 明确使用场景(客服、教学、业务咨询等)。 - Prompt 中增加: - “针对【领域/场景】下的用户问题给出回答”; - “优先考虑该领域用户的实际需求和常见约束”。
3. **约束回答风格,减少“泛泛而谈”** - 要求回答必须包含: - 具体数字、条件、前提; - 必要时说明“不确定/需要更多信息”的情况,避免瞎编。 - 通过 few-shot 示例展示:什么是 4–5 分的优质回答、什么是 2–3 分的回答,引导模型靠近高分示例。
#### 2. 模型与参数配置
1. **温度(temperature)适度降低** - 当前质量偏不稳定、高分少,可能与生成多样性过高、稳定性不足有关。 - 建议:在事实性/任务型 QA 中降低 temperature(如控制在 0–0.5 范围),提升一致性和严谨性。
2. **分场景使用不同模型/模式** - 对要求高事实正确性的 QA(知识问答、业务规则解释),优先选择更强的基础模型或加入检索增强(RAG); - 对开放式/创意类问题,则允许略高温度以保持多样性,但同时对事实相关部分加校验。
3. **增加对“回答长度与结构”的软约束** - 通过 prompt 规定大致长度区间和段落结构, - 避免过短(信息不足)或冗长(堆砌无效内容)导致被标低分。
---
### 三、质量把控:增加筛选与验证步骤
当前 44% 样本在低分区间,说明**生成后几乎没有有效过滤**。建议在管线中增加以下质量控制环节:
#### 1. 自动质量评估(模型自评 + 规则过滤)
1. **自评打分模型** - 使用一个单独的评估 prompt 或小模型,对生成答案进行: - 相关性评分; - 准确性/合理性评分; - 结构/可读性评分。 - 仅保留综合评分高于某一阈值的 QA 对,或优先送高分样本给人工做深度标注。
2. **规则/正则过滤** - 过滤明显无效回答,比如: - 过多重复句; - 明显不完整的句子(截断); - 出现“我不知道”“无法回答”但仍被当作正式答案输出的场景。 - 对包含敏感/不当内容的回答进行剔除或重新生成。
#### 2. 人工标注与反馈闭环优化
1. **改造标注体系为“结构化错误标签 + 简短备注”** - 在 test1111 的基础上,增加错误/问题维度选择,比如: - 事实错误; - 答非所问; - 过于泛泛,缺乏细节; - 结构混乱、难以理解; - 领域不匹配; - 语气/风格不合适。 - 要求标注者至少勾选 1 个主要问题标签,备注可选写补充说明。
2. **提升备注质量的标注规范** - 制定简单规范(1–2 句): - 备注需说明“为什么不给高分”,例如:“只给出定义,没有实操建议”,“答偏到其他领域”等。 - 对标注员做快速培训或提供示范例子,避免出现“可以的”“发发”这类无信息备注。
3. **重点样本二次审核** - 对 1 分和 5 分样本进行二次审核,确保: - 低分样本的确存在明显问题,便于后续用作“负例”; - 高分样本质量可靠,可作为“优质示例库”用于 prompt few-shot 和训练/蒸馏。
---
### 四、数据分布优化与覆盖面提升
目前仅有 50 条样本,且高质量样本极少,数据分布与多样性明显不足。建议:
#### 1. 增加“高价值场景”的问题设计
1. 从业务/产品需求倒推问题模板: - 例如:用户常见咨询、关键操作流程、常见错误场景、决策类问题。 - 由业务同学或产品经理先设计高价值问题,再交给模型生成答案。
2. 控制问题难度与粒度: - 避免过于宽泛(导致泛泛回答),如“介绍一下 AI”,改为“在电商客服场景中,AI 可以如何减少人工成本?请分步骤说明”。
#### 2. 分层采样生成 QA
1. 按领域/主题维度控制样本比例: - 确保各主要业务模块都有足够样本,而不是集中在少数话题��
2. 按问题类型分类: - 说明性、操作性、诊断性、对比性、建议类等; - 对每种类型都生成一定数量 QA,保证训练或评估时的覆盖全面。
#### 3. 强化“高质量样本”的比例
1. 对当前管线输出进行多轮生成 + 筛选: - 对同一问题生成多候选答案; - 使用评估模型筛选评分最高的 1–2 个答案加入数据集。
2. 将高分样本沉淀为“参考模板”: - 将 4–5 分样本总结出格式和风格特征; - 在 prompt 中引用这些特征,引导后续生成靠近优质范式。
---
## 总结
- 当前 QA 数据整体质量偏中下,平均分 2.66,高质量(4–5 分)样本比例不高,领域相关性与实际价值也不理想。- 标注备注基本无法提供有用的错误信息,暴露出标注方案和标注规范的不足,使问题定位和迭代优化受限。- 最优先的改进方向: 1. **在生成端**:优化 prompt,增强领域/场景约束,降低温度并引入结构化输出要求,必要时引入检索增强与自评打分。 2. **在质量控制端**:建立自动评估 + 规则过滤机制,将最差和最好的样本区分开,并对高低分样本进行重点人工复核。 3. **在标注端**:增加结构化错误标签和备注规范,显著提升标注信号质量,为后续迭代提供可操作的反馈。 4. **在数据分布端**:按领域和问题类型设计高价值问题,提升高质量样本比例,构建可复用的“优质 QA 模板”。
优先落地上述四点,将有助于快速提升后续 QA 数据的整体质量和实用价值。Dockerfile+2
qa_annotate/api/analysis.py+5-1
qa_annotate/bootstrap.py+42-1
qa_annotate/database/crud.py+13-13
qa_annotate/main.py+2-1
qa_annotate/static/js/annotation-analysis.js+5-1
scripts/space_init.py+2-1
seed/llm-analysis-2026-06-15_en.mdAdded+271
seed/llm-analysis-2026-06-15_zh.mdAdded+241