Skip to content

Hypergraph is more powerful. Transform unstructured text into structured knowledge with LLMs. Graphs, hypergraphs, and spatio-temporal extractions — with one command.

refactor(templates): 重构通用模板并更新文档

yifanfeng973b49146b2483
diff --git a/README.md b/README.md
index f1c2872..0f4257a 100644
--- a/README.md
+++ b/README.md
@@ -65,8 +65,6 @@ he search kb "key insights"
![Domain](docs/assets/domain.png)
-![Domain Templates](docs/assets/domain-templates.jpeg)
-
Pre-built templates for common domains:
| Domain | Templates |
diff --git a/README_ZH.md b/README_ZH.md
index af1590e..34d89a5 100644
--- a/README_ZH.md
+++ b/README_ZH.md
@@ -65,8 +65,6 @@ he search kb "关键信息"
![Domain](docs/assets/domain.png)
-![领域模板](docs/assets/domain-templates.jpeg)
-
开箱即用的领域模板:
| 领域 | 模板 |
diff --git a/hyperextract/templates/legacy/IMPLEMENTATION_PLAN.md b/hyperextract/templates/legacy/IMPLEMENTATION_PLAN.md
new file mode 100644
index 0000000..04806e2
--- /dev/null
+++ b/hyperextract/templates/legacy/IMPLEMENTATION_PLAN.md
@@ -0,0 +1,551 @@
+# Hyper-Extract 知识模板重新设计实施计划
+
+## 📋 概述
+
+本文档详细规划了 Hyper-Extract 知识模板库的重新设计方案。核心目标是通过精简过度设计的模板、增加顺应热点的新模板、提高每个模板的实际使用价值,打造一个更实用、更精简、更有吸引力的模板库。
+
+---
+
+## 🎯 设计原则
+
+### 1. 真实性检验
+- ✅ 有真实文档需求:能否举出3个以上具体文档类型?
+- ✅ 有明确使用场景:谁来用?解决什么问题?
+- ✅ 有可视化价值:提取结果能否直观展示?
+
+### 2. 精简高效
+- ✅ 删除自我创造需求的模板
+- ✅ 合并功能重叠的模板
+- ✅ 控制每个类别模板数量在 6-10 个
+
+### 3. 跟进热点
+- 重点关注:AI Agents、MCP、Skill RAG、知识图谱等热点领域
+
+---
+
+## 📊 模板数量规划
+
+| 类别 | Legacy数量 | 建议数量 | 精简比例 | 优先级 |
+|------|----------|---------|---------|--------|
+| **General** | ~15 | 8 | 47% | 🔴 高 |
+| **Finance** | ~20 | 9 | 55% | 🔴 高 |
+| **Legal** | ~12 | 8 | 33% | 🟡 中 |
+| **Industry** | ~14 | 8 | 43% | 🟡 中 |
+| **Medicine** | ~16 | 9 | 44% | 🟡 中 |
+| **TCM** | ~10 | 8 | 20% | 🟢 低 |
+| **总计** | ~87 | ~50 | 43% | - |
+
+---
+
+## 🗂️ 各类别详细设计
+
+---
+
+### 1️⃣ General(通用领域)
+
+#### 🔍 需求分析
+
+| 模板名称 | 保留/新增 | 理由 | 实际场景 |
+|---------|----------|------|---------|
+| KnowledgeGraph | ✅ 保留 | 通用图谱提取,适用性最广 | 任何文本 |
+| EntityRegistry | ✅ 保留 | 实体集合提取,NER任务 | 新闻、简历 |
+| KeywordList | ✅ 保留 | 关键词提取,索引构建 | 内容打标 |
+| EncyclopediaItem | ✅ 保留 | 百科词条,结构化信息 | 词典词条 |
+| ConceptHierarchy | ✅ 保留 | 概念层级,教材知识 | 教材、论文 |
+| LifeEventTimeline | ✅ 保留 | 生平时序,传记分析 | 传记、年表 |
+| SocialNetwork | ✅ 保留 | 人物关系,社交分析 | 人物分析 |
+| ComplianceLogic | ✅ 保留 | 合规超图,制度分析 | 公司制度 |
+
+#### 🆕 新增模板
+
+##### 1. SkillFlowGraph(AI Agent 技能流程图)
+
+**类型**: `graph`
+
+**需求验证**:
+- ✅ 真实场景:分析 Cursor Rules、refly skills、MCP workflows
+- ✅ 使用者:AI开发者、Agent设计者
+- ✅ 痛点:Skill文档缺乏可视化工具
+
+**设计思路**:
+- 将 Skill 的触发条件、执行步骤、工具调用、条件分支等建模为图的节点和边
+- 不同于超图,因为每个节点之间有明确的流向关系
+
+**示例输入**:
+```
+## Skill: code_review
+trigger: "/review"
+steps:
+ 1. 分析代码变更
+ 2. 调用 linter 工具
+ 3. 生成审查意见
+ 4. 如果有严重问题,标记需要修复
+tools: [git, linter, openai]
+```
+
+##### 2. TechStackGraph(技术栈依赖图)
+
+**类型**: `graph`
+
+**需求验证**:
+- ✅ 真实场景:理解项目架构、依赖关系
+- ✅ 使用者:开发者、技术管理者
+- ✅ 痛点:README太长,难以快速理解技术栈
+
+**设计思路**:
+- 从 README、技术文档中提取技术之间的依赖关系
+- 支持不同粒度:语言→框架→库→服务
+
+---
+
+#### ❌ 删除/合并的模板
+
+| 删除模板 | 原因 |
+|---------|------|
+| CrossReferenceNet | 与 ConceptHierarchy 功能重叠 |
+| RegulationProfile | 过于简单,可并入 ComplianceLogic |
+| ClauseList | 与 ComplianceLogic 部分重叠 |
+| PenaltyRegistry | 与 PenaltyMapping 功能重叠 |
+| PenaltyMapping | 与 ComplianceLogic 功能重叠 |
+| OperationalProcedure | 可并入现有模板 |
+
+---
+
+### 2️⃣ Finance(金融投资)
+
+#### 🔍 需求分析
+
+| 模板名称 | 保留/新增 | 理由 | 实际场景 |
+|---------|----------|------|---------|
+| FilingFinancialSnapshot | ✅ 保留 | 财报关键数据 | 投资分析 |
+| MDANarrativeGraph | ✅ 保留 | 管理层讨论因果 | 趋势分析 |
+| RiskFactorSet | ✅ 保留 | 风险因子清单 | 风险监控 |
+| MaterialEventTimeline | ✅ 保留 | 重大事件时间轴 | 事件驱动 |
+| SegmentPerformanceList | ✅ 保留 | 分部业绩 | 分部估值 |
+| FinancialDataTemporalGraph | ✅ 保留 | 跨期财务指标 | 趋势分析 |
+
+#### 🆕 新增模板
+
+##### 1. EarningsCallQA(财报问答抽取)
+
+**类型**: `hypergraph`
+
+**需求验证**:
+- ✅ 真实场景:分析财报电话会议QA环节
+- ✅ 使用者:分析师、投资者
+- ✅ 痛点:会议记录太长,难以快速定位关键Q&A
+
+##### 2. ResearchKeyPoints(研报要点)
+
+**类型**: `list`
+
+**需求验证**:
+- ✅ 真实场景:快速提炼研报核心观点
+- ✅ 使用者:研究员、投资者
+- ✅ 痛点:研报太长,需要快速提取结论
+
+##### 3. GuidanceTracker(管理层指引跟踪)
+
+**类型**: `temporal_graph`
+
+**需求验证**:
+- ✅ 真实场景:跟踪管理层指引兑现情况
+- ✅ 使用者:分析师、投资者
+- ✅ 痛点:需要跨期对比指引与实际
+
+---
+
+#### ❌ 删除/合并的模板
+
+| 删除模板 | 原因 |
+|---------|------|
+| ManagementGuidanceList | 并入 GuidanceTracker |
+| ValuationLogicMap | 过于抽象,实际使用率低 |
+| FactorInfluenceHypergraph | 过度设计,用户难以使用 |
+| MultiSourceSentimentHypergraph | 合并到 MarketSentimentModel |
+| SupplyChain | 与核心金融场景关联弱 |
+| DiscussionGraph | 与 EarningsCallQA 功能重叠 |
+| CompanyHistoryTimeline | 与 MaterialEventTimeline 重叠 |
+| ProceedsUsage | 使用场景有限 |
+| ShareholderStructure | 已有类似模板,可简化 |
+| CallSentimentHypergraph | 过度设计 |
+| MarketSentimentModel | 可简化为 ResearchKeyPoints |
+
+---
+
+### 3️⃣ Legal(法律合规)
+
+#### 🔍 需求分析
+
+| 模板名称 | 保留/新增 | 理由 | 实际场景 |
+|---------|----------|------|---------|
+| ContractObligationHypergraph | ✅ 保留 | 合同权利义务 | 合同审查 |
+| DefinedTermRegistry | ✅ 保留 | 术语定义 | 合同理解 |
+| LiabilityClauseList | ✅ 保留 | 违约责任 | 风险评估 |
+| AdjudicationLogic | ✅ 保留 | 判决推理 | 案件分析 |
+| CaseFactTimeline | ✅ 保留 | 事实时间线 | 案情分析 |
+| LitigationParticipantMap | ✅ 保留 | 当事人关系 | 利益分析 |
+| ComplianceRequirementList | ✅ 保留 | 合规要求 | 合规审查 |
+| BeneficialOwnershipGraph | ✅ 保留 | 股权穿透 | AML/KYC |
+
+#### 🆕 新增模板
+
+##### 1. ClauseRegistry(条款清单)
+
+**类型**: `list`
+
+**需求验证**:
+- ✅ 真实场景:提取合同所有条款并分类
+- ✅ 使用者:律师、法务
+- ✅ 痛点:条款太多,难以快速定位
+
+##### 2. CaseLawCitation(判例引用)
+
+**类型**: `graph`
+
+**需求验证**:
+- ✅ 真实场景:研究判例之间的引用关系
+- ✅ 使用者:律师、研究人员
+- ✅ 痛点:判例引用关系复杂,难以追溯
+
+---
+
+#### ❌ 删除/合并的模板
+
+| 删除模板 | 原因 |
+|---------|------|
+| CaseLawCitationNet | 简化为 CaseLawCitation |
+| LegalConceptOntology | 与通用 ConceptHierarchy 重叠 |
+
+---
+
+### 4️⃣ Industry(工业制造)
+
+#### 🔍 需求分析
+
+| 模板名称 | 保留/新增 | 理由 | 实际场景 |
+|---------|----------|------|---------|
+| SystemTopologyGraph | ✅ 保留 | 系统拓扑 | 架构理解 |
+| EquipmentTopologyGraph | ✅ 保留 | 设备拓扑 | 设备管理 |
+| SpecParameterTable | ✅ 保留 | 技术参数 | 设备台账 |
+| SafetyControlGraph | ✅ 保留 | 安全规程 | 安全管理 |
+| EmergencyResponseGraph | ✅ 保留 | 应急预案 | 应急响应 |
+| OperationFlowGraph | ✅ 保留 | 操作流程 | 运维规程 |
+| OperatingModeGraph | ✅ 保留 | 工况切换 | 运行管理 |
+| FailureCaseGraph | ✅ 保留 | 故障案例 | 故障分析 |
+
+#### 🆕 新增模板
+
+##### 1. MaintenanceLog(维保日志)
+
+**类型**: `temporal_graph`
+
+**需求验证**:
+- ✅ 真实场景:提取维保记录的时间序列
+- ✅ 使用者:运维工程师
+- ✅ 痛点:日志难以结构化分析
+
+##### 2. IncidentChain(事故因果链)
+
+**类型**: `hypergraph`
+
+**需求验证**:
+- ✅ 真实场景:分析事故发生的因果关系
+- ✅ 使用者:安全工程师
+- ✅ 痛点:事故分析需要完整因果链
+
+---
+
+#### ❌ 删除/合并的模板
+
+| 删除模板 | 原因 |
+|---------|------|
+| SystemCompatibilityGraph | 过度设计 |
+| PartReplacementList | 可并入 MaintenanceLog |
+| InspectionRecordGraph | 与 MaintenanceLog 功能重叠 |
+| MaintenaceOperationMap | 与 OperationFlowGraph 重叠 |
+| IncidentCausalityMap | 简化为 IncidentChain |
+| SafetyTimeline | 与 MaintenanceLog 功能重叠 |
+| FailureKnowledgeHypergraph | 简化为 FailureCaseGraph |
+
+---
+
+### 5️⃣ Medicine(医疗健康)
+
+#### 🔍 需求分析
+
+| 模板名称 | 保留/新增 | 理由 | 实际场景 |
+|---------|----------|------|---------|
+| PharmacologyGraph | ✅ 保留 | 药理关系 | 药理分析 |
+| AnatomyHierarchy | ✅ 保留 | 解剖层级 | 手术导航 |
+| TreatmentRegimenMap | ✅ 保留 | 治疗方案 | 临床决策 |
+| ClinicalPathway | ✅ 保留 | 临床路径 | 诊疗规范 |
+| HospitalCourseTimeline | ✅ 保留 | 病程时间线 | 病历分析 |
+| DischargeInstruction | ✅ 保留 | 出院指导 | 患者教育 |
+| ComplexInteractionNet | ✅ 保留 | 药物相互作用 | 用药安全 |
+| ContraindicationList | ✅ 保留 | 禁忌症 | 处方审核 |
+
+#### 🆕 新增模板
+
+##### 1. DiagnosisChain(诊断推理链)
+
+**类型**: `hypergraph`
+
+**需求验证**:
+- ✅ 真实场景:提取鉴别诊断的推理过程
+- ✅ 使用者:医生、医学生
+- ✅ 痛点:病历中的诊断推理难以结构化
+
+##### 2. LabResult(检验报告)
+
+**类型**: `model`
+
+**需求验证**:
+- ✅ 真实场景:结构化提取检验报告数据
+- ✅ 使用者:医生、数据分析
+- ✅ 痛点:检验报告难以自动提取
+
+##### 3. AdverseEventReport(不良事件报告)
+
+**类型**: `hypergraph`
+
+**需求验证**:
+- ✅ 真实场景:提取不良事件的详细信息
+- ✅ 使用者:药物警戒
+- ✅ 痛点:需要完整的因果关系
+
+---
+
+#### ❌ 删除/合并的模板
+
+| 删除模板 | 原因 |
+|---------|------|
+| PathologyHypergraph | 与 DiagnosisChain 功能重叠 |
+| MedicalConceptNet | 与通用模板重叠 |
+| LevelOfEvidence | 使用场景有限 |
+| SurgicalEventGraph | 可并入 HospitalCourseTimeline |
+| TumorStagingItem | 可并入 DiagnosisChain |
+| MicroscopicFeatureSet | 可并入 LabResult |
+| AdverseReactionStats | 简化为 AdverseEventReport |
+
+---
+
+### 6️⃣ TCM(中医中药)
+
+#### 🔍 需求分析
+
+| 模板名称 | 保留/新增 | 理由 | 实际场景 |
+|---------|----------|------|---------|
+| HerbPropertyModel | ✅ 保留 | 中药属性 | 中药数据库 |
+| FormulaComposition | ✅ 保留 | 君臣佐使 | 方剂分析 |
+| SyndromeReasoningGraph | ✅ 保留 | 证候推理 | 临床推理 |
+| CompatibilityNet | ✅ 保留 | 药对配伍 | 配伍禁忌 |
+| MeridianFlowGraph | ✅ 保留 | 经络循行 | 经络理论 |
+| AcupointLocationMap | ✅ 保留 | 穴位定位 | 针灸教学 |
+| ProcessingMethod | ✅ 保留 | 炮制方法 | 炮制规范 |
+
+#### 🆕 新增模板
+
+##### 1. CaseRecord(医案记录)
+
+**类型**: `hypergraph`
+
+**需求验证**:
+- ✅ 真实场景:提取名医医案的完整信息
+- ✅ 使用者:中医师、研究人员
+- ✅ 痛点:医案难以结构化分析
+
+##### 2. PrescriptionModification(处方加减)
+
+**类型**: `graph`
+
+**需求验证**:
+- ✅ 真实场景:分析处方加减规律
+- ✅ 使用者:中医师、方剂研究
+- ✅ 痛点:处方演变难以追溯
+
+---
+
+#### ❌ 删除/合并的模板
+
+| 删除模板 | 原因 |
+|---------|------|
+| FunctionIndicationMap | 可并入 FormulaComposition |
+| PrescriptionModification | 已有同名模板,保留 |
+
+---
+
+## 📝 实施流程
+
+### 每个模板的实现流程
+
+```
+┌─────────────────────────────────────────┐
+│ 1️⃣ Brainstorm(头脑风暴) │
+│ - 讨论模板的实际需求场景 │
+│ - 验证是否是真需求 │
+│ - 确定合适的原语类型 │
+└─────────────────┬───────────────────────┘
+ │
+ ▼
+┌─────────────────────────────────────────┐
+│ 2️⃣ Designer(设计) │
+│ - 根据 brainstorm 结果设计 YAML │
+│ - record-designer: model/list/set │
+│ - graph-designer: graph/hypergraph │
+└─────────────────┬───────────────────────┘
+ │
+ ▼
+┌─────────────────────────────────────────┐
+│ 3️⃣ Validator(验证) │
+│ - 验证 YAML 语法正确性 │
+│ - 检查字段定义是否合理 │
+│ - 验证与原语类型的匹配度 │
+└─────────────────────────────────────────┘
+```
+
+---
+
+## 📅 实施时间表
+
+### Phase 1: General + Finance(高优先级)
+
+| 步骤 | 任务 | 状态 |
+|------|------|------|
+| 1.1 | Brainstorm: SkillFlowGraph | ⏳ 待开始 |
+| 1.2 | Design: SkillFlowGraph | ⏳ 待开始 |
+| 1.3 | Validate: SkillFlowGraph | ⏳ 待开始 |
+| 1.4 | Brainstorm: TechStackGraph | ⏳ 待开始 |
+| 1.5 | Design: TechStackGraph | ⏳ 待开始 |
+| 1.6 | Validate: TechStackGraph | ⏳ 待开始 |
+| 1.7 | Brainstorm: Finance 新模板 | ⏳ 待开始 |
+| 1.8 | Design: Finance 新模板 | ⏳ 待开始 |
+| 1.9 | Validate: Finance 新模板 | ⏳ 待开始 |
+
+### Phase 2: Legal + Industry
+
+| 步骤 | 任务 | 状态 |
+|------|------|------|
+| 2.1 | Brainstorm: Legal 新模板 | ⏳ 待开始 |
+| 2.2 | Design: Legal 新模板 | ⏳ 待开始 |
+| 2.3 | Validate: Legal 新模板 | ⏳ 待开始 |
+| 2.4 | Brainstorm: Industry 新模板 | ⏳ 待开始 |
+| 2.5 | Design: Industry 新模板 | ⏳ 待开始 |
+| 2.6 | Validate: Industry 新模板 | ⏳ 待开始 |
+
+### Phase 3: Medicine + TCM
+
+| 步骤 | 任务 | 状态 |
+|------|------|------|
+| 3.1 | Brainstorm: Medicine 新模板 | ⏳ 待开始 |
+| 3.2 | Design: Medicine 新模板 | ⏳ 待开始 |
+| 3.3 | Validate: Medicine 新模板 | ⏳ 待开始 |
+| 3.4 | Brainstorm: TCM 新模板 | ⏳ 待开始 |
+| 3.5 | Design: TCM 新模板 | ⏳ 待开始 |
+| 3.6 | Validate: TCM 新模板 | ⏳ 待开始 |
+
+---
+
+## 📂 输出文件结构
+
+```
+hyperextract/templates/
+├── presets/
+│ ├── general/
+│ │ ├── base_graph.yaml # 基础图(已存在)
+│ │ ├── base_hypergraph.yaml # 基础超图(已存在)
+│ │ ├── knowledge_graph.yaml # 知识图谱
+│ │ ├── entity_registry.yaml # 实体集合
+│ │ ├── keyword_list.yaml # 关键词列表
+│ │ ├── encyclopedia_item.yaml # 百科条目
+│ │ ├── concept_hierarchy.yaml # 概念层级
+│ │ ├── life_event_timeline.yaml # 生平时序
+│ │ ├── social_network.yaml # 社交网络
+│ │ ├── compliance_logic.yaml # 合规逻辑(已存在)
+│ │ ├── skill_flow_graph.yaml # 🆕 AI技能流程图
+│ │ └── tech_stack_graph.yaml # 🆕 技术栈依赖图
+│ │
+│ ├── finance/
+│ │ ├── filing_snapshot.yaml # 🆕 财报快照
+│ │ ├── mda_graph.yaml # 🆕 MD&A因果图
+│ │ ├── risk_factor_set.yaml # 🆕 风险因子集
+│ │ ├── event_timeline.yaml # 🆕 重大事件时序
+│ │ ├── segment_performance.yaml # 🆕 分部业绩
+│ │ ├── earnings_call_qa.yaml # 🆕 财报问答
+│ │ ├── research_keypoints.yaml # 🆕 研报要点
+│ │ └── guidance_tracker.yaml # 🆕 指引跟踪
+│ │
+│ ├── legal/
+│ │ ├── contract_obligations.yaml # 🆕 合同义务
+│ │ ├── defined_terms.yaml # 🆕 术语定义
+│ │ ├── liability_clauses.yaml # 🆕 责任条款
+│ │ ├── clause_registry.yaml # 🆕 条款清单
+│ │ ├── case_fact_timeline.yaml # 🆕 案件事实时序
+│ │ ├── adjudication_logic.yaml # 🆕 裁判逻辑(已存在)
+│ │ ├── litigation_participants.yaml # 🆕 诉讼参与人
+│ │ └── case_citation.yaml # 🆕 判例引用
+│ │
+│ ├── industry/
+│ │ ├── system_topology.yaml # 🆕 系统拓扑
+│ │ ├── equipment_spec.yaml # 🆕 设备规格
+│ │ ├── safety_control.yaml # 🆕 安全控制
+│ │ ├── operation_procedure.yaml # 🆕 操作规程
+│ │ ├── failure_case.yaml # 🆕 故障案例
+│ │ ├── maintenance_log.yaml # 🆕 维保日志
+│ │ ├── incident_chain.yaml # 🆕 事故因果链
+│ │ └── emergency_response.yaml # 🆕 应急响应
+│ │
+│ ├── medicine/
+│ │ ├── drug_info.yaml # 🆕 药品信息
+│ │ ├── drug_interaction.yaml # 🆕 药物相互作用
+│ │ ├── treatment_plan.yaml # 🆕 治疗方案
+│ │ ├── clinical_pathway.yaml # 🆕 临床路径
+│ │ ├── hospital_course.yaml # 🆕 住院病程
+│ │ ├── lab_result.yaml # 🆕 检验结果
+│ │ ├── discharge_summary.yaml # 🆕 出院小结
+│ │ ├── diagnosis_chain.yaml # 🆕 诊断推理链
+│ │ └── adverse_event.yaml # 🆕 不良事件
+│ │
+│ └── tcm/
+│ ├── herb_property.yaml # 🆕 中药属性
+│ ├── formula_composition.yaml # 🆕 方剂组成
+│ ├── syndrome_reasoning.yaml # 🆕 证候推理
+│ ├── herb_compatibility.yaml # 🆕 药对配伍
+│ ├── meridian_flow.yaml # 🆕 经络循行
+│ ├── acupoint_info.yaml # 🆕 穴位信息
+│ ├── case_record.yaml # 🆕 医案记录
+│ └── processing_method.yaml # 🆕 炮制方法
+│
+└── IMPLEMENTATION_PLAN.md # 本文档
+```
+
+---
+
+## ✅ 检查清单
+
+### 设计检查
+- [ ] 是否有真实文档场景?
+- [ ] 是否有明确的使用者?
+- [ ] 是否有可视化的价值?
+- [ ] 是否与现有模板功能重叠?
+
+### YAML 检查
+- [ ] 字段定义完整
+- [ ] 描述清晰准确
+- [ ] 语言支持(中/英)
+- [ ] 符合原语类型规范
+- [ ] 示例具有代表性
+
+### 文档检查
+- [ ] README 已更新
+- [ ] 示例代码可用
+- [ ] 测试用例覆盖
+
+---
+
+## 📌 备注
+
+本计划将根据实施过程中的反馈持续迭代优化。
+
+**最后更新**: 2026-03-27
+**版本**: v1.0
diff --git a/hyperextract/templates/presets/general/base_set.yaml b/hyperextract/templates/presets/general/base_set.yaml
index f5a37f8..6642956 100644
--- a/hyperextract/templates/presets/general/base_set.yaml
+++ b/hyperextract/templates/presets/general/base_set.yaml
@@ -2,7 +2,7 @@ language: [zh, en]
name: base_set
type: set
-tags: [general]
+tags: [general, set]
description:
zh: '通用实体集合结构知识模板 - 从任意文本中识别并去重关键实体,汇总为可复用的实体清单。'
diff --git a/hyperextract/templates/presets/general/base_spatial_graph.yaml b/hyperextract/templates/presets/general/base_spatial_graph.yaml
index 775314c..3b558d4 100644
--- a/hyperextract/templates/presets/general/base_spatial_graph.yaml
+++ b/hyperextract/templates/presets/general/base_spatial_graph.yaml
@@ -48,7 +48,7 @@ output:
description:
zh: '关系终点实体,必须对应已提取实体的 name。'
en: 'Target entity of the relation, must correspond to the name of an extracted entity.'
- - name: relation_type
+ - name: type
type: str
description:
zh: '关系类型,用简洁词语概括两个实体之间的连接方式。'
@@ -98,7 +98,7 @@ guideline:
identifiers:
entity_id: name
- relation_id: '{source}|{relation_type}|{target}'
+ relation_id: '{source}|{type}|{target}|{location}'
relation_members:
source: source
target: target
@@ -109,4 +109,4 @@ options:
display:
entity_label: '{name} ({type})'
- relation_label: '{relation_type}'
+ relation_label: '{type}@{location}'
diff --git a/hyperextract/templates/presets/general/base_spatio_temporal_graph.yaml b/hyperextract/templates/presets/general/base_spatio_temporal_graph.yaml
index 7b960b8..68268b3 100644
--- a/hyperextract/templates/presets/general/base_spatio_temporal_graph.yaml
+++ b/hyperextract/templates/presets/general/base_spatio_temporal_graph.yaml
@@ -48,12 +48,12 @@ output:
description:
zh: '关系终点实体,必须对应已提取实体的 name。'
en: 'Target entity of the relation, must correspond to the name of an extracted entity.'
- - name: event_type
+ - name: type
type: str
description:
zh: '关系类型,用简洁词语概括两个实体之间的连接方式。'
en: 'Relation type, concisely describing the connection between two entities.'
- - name: event_date
+ - name: time
type: str
description:
zh: '关系对应的时间;无明确时间时可留空。'
@@ -91,12 +91,12 @@ guideline:
rules_for_time:
zh:
- '当前观察日期:{observation_time}'
- - 'event_date 是可选字段;仅在文本明确提供时间,或可依据相对时间可靠换算时填写。'
+ - 'time 是可选字段;仅在文本明确提供时间,或可依据相对时间可靠换算时填写。'
- '若文本给出明确年份,则写为 YYYY;若给出完整日期,则写为 YYYY-MM-DD。'
- '无法可靠确定时间时留空。'
en:
- 'Current observation date: {observation_time}'
- - 'event_date is optional; fill in only when the text explicitly provides time or when relative time can be reliably converted.'
+ - 'time is optional; fill in only when the text explicitly provides time or when relative time can be reliably converted.'
- 'Write years as YYYY; write full dates as YYYY-MM-DD.'
- 'Leave empty when time cannot be reliably determined.'
rules_for_location:
@@ -113,11 +113,11 @@ guideline:
identifiers:
entity_id: name
- relation_id: '{source}|{event_type}|{target}'
+ relation_id: '{source}|{type}|{target}|{time}|{location}'
relation_members:
source: source
target: target
- time_field: event_date
+ time_field: time
location_field: location
options:
@@ -125,4 +125,4 @@ options:
display:
entity_label: '{name} ({type})'
- relation_label: '{event_type}'
+ relation_label: '{type}@{location}({time})'
diff --git a/hyperextract/templates/presets/general/base_temporal_graph.yaml b/hyperextract/templates/presets/general/base_temporal_graph.yaml
index b47dbd2..43826a1 100644
--- a/hyperextract/templates/presets/general/base_temporal_graph.yaml
+++ b/hyperextract/templates/presets/general/base_temporal_graph.yaml
@@ -48,12 +48,12 @@ output:
description:
zh: '关系终点实体,必须对应已提取实体的 name。'
en: 'Target entity of the relation, must correspond to the name of an extracted entity.'
- - name: event_type
+ - name: type
type: str
description:
zh: '关系类型,用简洁词语概括两个实体之间的连接方式。'
en: 'Relation type, concisely describing the connection between two entities.'
- - name: event_date
+ - name: time
type: str
description:
zh: '关系对应的时间;无明确时间时可留空。'
@@ -85,14 +85,14 @@ guideline:
rules_for_time:
zh:
- '当前观察日期:{observation_time}'
- - 'event_date 是可选字段;仅在文本明确提供时间,或可依据相对时间可靠换算时填写。'
+ - 'time 是可选字段;仅在文本明确提供时间,或可依据相对时间可靠换算时填写。'
- '相对时间以 observation_time 为基准解析,如"去年/今年/明年""昨天/今天/明天""十年前/五年后"。'
- '若文本给出明确年份,则写为 YYYY;若给出完整日期,则写为 YYYY-MM-DD;保留文本可确定的最细粒度。'
- '若时间只对应关系成立、变化或终止中的某一时点,则记录最直接相关的那个时间。'
- '无法可靠确定时间时留空,不要根据常识补写。'
en:
- 'Current observation date: {observation_time}'
- - 'event_date is optional; fill in only when the text explicitly provides time or when relative time can be reliably converted.'
+ - 'time is optional; fill in only when the text explicitly provides time or when relative time can be reliably converted.'
- 'Parse relative time based on observation_time.'
- 'Write years as YYYY; write full dates as YYYY-MM-DD; preserve the finest granularity determinable from the text.'
- 'If time corresponds to only one point among establishment, change, or termination, record the most directly relevant time.'
@@ -100,15 +100,15 @@ guideline:
identifiers:
entity_id: name
- relation_id: '{source}|{event_type}|{target}'
+ relation_id: '{source}|{type}|{target}|{time}'
relation_members:
source: source
target: target
- time_field: event_date
+ time_field: time
options:
extraction_mode: two_stage
display:
entity_label: '{name} ({type})'
- relation_label: '{event_type}'
+ relation_label: '{type}@{time}'
diff --git a/hyperextract/templates/presets/general/entity_registry.yaml b/hyperextract/templates/presets/general/entity_registry.yaml
deleted file mode 100644
index bbca877..0000000
--- a/hyperextract/templates/presets/general/entity_registry.yaml
+++ /dev/null
@@ -1,43 +0,0 @@
-language: zh
-name: entity_registry
-type: set
-tags: [general]
-description:
- zh: '实体注册表模板 - 从任意文本中识别并去重关键实体,汇总为可复用的实体清单。'
-
-output:
- description:
- zh: '去重后的实体列表结果,用于形成基础实体台账。'
- fields:
- - name: name
- type: str
- description:
- zh: '实体名称,优先使用文本中最稳定、最清晰的称呼。'
- - name: category
- type: str
- description:
- zh: '实体类型,如人物、机构、地点、产品、概念、事件、制度、其他。'
- - name: description
- type: str
- description:
- zh: '对实体身份、含义或在文本中作用的简要说明。'
- required: false
- default: ''
-
-guideline:
- target:
- zh: '你是一位实体识别专家。请从文本中识别具有独立意义的实体,并将重复出现的同一实体合并为一条记录。'
- rules:
- zh:
- - '提取对理解文本内容有意义的实体,如人物、机构、地点、产品、概念、事件、制度等。'
- - '同一实体若有简称或别称,应统一为一个名称。'
- - '对同一实体进行去重,不要因表述差异重复输出多条。'
- - '不要把纯代词、泛称、临时描述短语或无独立指代意义的词语当作实体。'
-
-identifiers:
- item_id: name
-
-options: {}
-
-display:
- label: name
diff --git a/hyperextract/templates/presets/general/graph.yaml b/hyperextract/templates/presets/general/graph.yaml
deleted file mode 100644
index 150ff0b..0000000
--- a/hyperextract/templates/presets/general/graph.yaml
+++ /dev/null
@@ -1,68 +0,0 @@
-language: zh
-name: knowledge_graph
-type: graph
-tags: [general]
-description: '通用知识图谱模板 - 从非结构化文本中提取关键实体、实体类型及实体之间的显式关系,适用于新闻、百科、制度和说明类文本的基础结构化建模。'
-
-output:
- description: '由实体节点和关系边组成的通用知识图谱结果,用于表达文本中的核心对象及其语义连接。'
- entities:
- description: '文本中可独立识别、可作为关系端点的实体节点。'
- fields:
- - name: name
- type: str
- description: '实体在文本中的标准称呼或最稳定名称。'
- - name: type
- type: str
- description: '实体类别,如人物、地点、组织、物品、概念、事件、制度、技术等。'
- - name: description
- type: str
- description: '对实体身份、含义或在当前文本中作用的简要说明。'
- required: false
- relations:
- description: '实体之间的显式语义关系边。'
- fields:
- - name: source
- type: str
- description: '关系起点实体,必须对应已提取实体的 name。'
- - name: target
- type: str
- description: '关系终点实体,必须对应已提取实体的 name。'
- - name: type
- type: str
- description: '关系类型,应使用简洁明确的语义词,如包含、属于、合作、影响、导致、相关等。'
- - name: description
- type: str
- description: '对关系依据、方向或上下文含义的简要说明。'
- required: false
-
-guideline:
- target:
- zh: '你是一位知识抽取与知识图谱构建专家。请基于给定文本识别关键实体,并构建仅由这些实体组成的二元关系图。'
- rules_for_entities:
- zh:
- - '提取对理解文本事实、结构或逻辑有价值的实体,避免无意义的泛称和临时短语。'
- - 'name 使用原文中最明确、最稳定的称呼;同一实体在全文中保持命名一致。'
- - 'type 需概括实体类别,可使用人物、地点、组织、物品、概念、事件、制度、技术等标签。'
- - 'description 用 1 句话概括实体的身份、属性或在文本中的作用;若信息不足可留空。'
- rules_for_relations:
- zh:
- - '仅在文本明确表达两个实体之间存在语义联系时创建关系,不要凭常识补充隐含关系。'
- - 'source 和 target 必须直接引用已提取实体的 name,不能新造实体名称。'
- - 'type 使用简洁、方向清晰的关系词,如包含、属于、相关、影响、合作、竞争、导致、位于、使用等。'
- - 'description 简要说明关系依据、作用方式或上下文;若文本没有额外信息可留空。'
- - '避免重复关系;若同一对实体存在多种不同关系,可分别记录。'
-
-identifiers:
- entity_id: name
- relation_id: '{source}|{target}'
- relation_members:
- source: source
- target: target
-
-options:
- extraction_mode: two_stage
-
-display:
- entity_label: '{name} ({type})'
- relation_label: '{type}'
diff --git a/hyperextract/templates/presets/legal/.gitkeep b/hyperextract/templates/presets/legal/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/hyperextract/templates/presets/legal/adjudication_logic.yaml b/hyperextract/templates/presets/legal/adjudication_logic.yaml
deleted file mode 100644
index 684bbdf..0000000
--- a/hyperextract/templates/presets/legal/adjudication_logic.yaml
+++ /dev/null
@@ -1,97 +0,0 @@
-language: zh
-name: adjudication_logic
-type: hypergraph
-tags: [legal]
-description:
- zh: '裁判逻辑超图 - 建模法官的推理过程'
-
-output:
- description:
- zh: '包含裁判要素和推理逻辑的超图结构'
- entities:
- description:
- zh: '提取的裁判要素列表'
- fields:
- - name: name
- type: str
- description:
- zh: '要素名称'
- required: true
- default: ''
- - name: category
- type: str
- description:
- zh: '要素类型:事实认定、法律依据、裁判结论、主旨、证据、其他'
- required: true
- default: ''
- - name: description
- type: str
- description:
- zh: '简要描述'
- required: false
- default: ''
- relations:
- description:
- zh: '提取的推理逻辑关系列表'
- fields:
- - name: logic_type
- type: str
- description:
- zh: '推理类型:事实认定、法律适用、因果认定、责任认定、金额计算、其他'
- required: true
- default: ''
- - name: participants
- type: list
- description:
- zh: '参与要素名称列表,必须使用已提取节点的 name'
- required: true
- default: ''
- - name: reasoning
- type: str
- description:
- zh: '推理过程描述,从事实到结论的逻辑推导'
- required: true
- default: ''
- - name: conclusion
- type: str
- description:
- zh: '推理结论'
- required: false
- default: ''
- - name: source_clause
- type: str
- description:
- zh: '裁判文书的章节位置'
- required: false
- default: ''
-
-guideline:
- target:
- zh: '你是一位专业的法律工作者,请从裁判文书中提取裁判要素和裁判逻辑。'
- rules_for_entities:
- zh:
- - '每个节点只能对应一个独立的要素,禁止将多个要素合并为一个节点'
- - '要素名称与原文保持一致'
- - '提取裁判文书中涉及的要素作为节点'
- - '为每个要素指定类型'
- - '为每个要素添加简要描述(1-2句话)'
- rules_for_relations:
- zh:
- - '仅从已提取节点中提取边,不要创建新名称'
- - '超边必须包含 logic_type, participants, reasoning'
- - 'participants 应包含涉及的事实认定、法律依据、裁判结论等要素'
- - 'reasoning 描述从事实到结论的逻辑推导过程'
- - '要素类型:事实认定(法院认定的案件事实)、法律依据(适用的法律条文、司法解释等)、裁判结论(判决结果或裁定结果)、主旨(裁判的核心观点或要旨)、证据(用于证明事实的证据材料)、其他(不属于上述类别的要素)'
- - '推理类型:事实认定(从证据推导出事实)、法律适用(将法律适用于事实)、因果认定(认定行为与结果之间的因果关系)、责任认定(认定责任主体和责任大小)、金额计算(计算赔偿金额或标的金额)、其他(不属于上述类别的推理)'
-
-identifiers:
- entity_id: name
- relation_id: '{logic_type}_{participants}'
- relation_members: participants
-
-options:
- extraction_mode: two_stage
-
-display:
- entity_label: '{name} ({category})'
- relation_label: '[{logic_type}] {conclusion}'