Skip to content

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

general 模版修改

rizrockd35cec55a308
diff --git a/hyperextract/templates/presets/general/base_temporal_graph.yaml b/hyperextract/templates/presets/general/base_temporal_graph.yaml
new file mode 100644
index 0000000..dac0752
--- /dev/null
+++ b/hyperextract/templates/presets/general/base_temporal_graph.yaml
@@ -0,0 +1,98 @@
+language: zh
+name: base_temporal_graph
+type: temporal_graph
+tags: [general]
+description:
+ zh: '基础时序图谱模板 - 从文本中提取实体之间的关系,并在文本提供时间信息时为关系补充时间属性,用于表达事实、事件或状态的连接及其时间上下文。'
+
+output:
+ description:
+ zh: '包含实体节点、关系边及可选时间信息的时序图谱结构。'
+ entities:
+ description:
+ zh: '文本中可独立识别、可参与关系连接的实体节点。'
+ fields:
+ - name: name
+ type: str
+ description:
+ zh: '实体名称,使用文本中最明确、最稳定的称呼。'
+ - name: type
+ type: str
+ description:
+ zh: '实体类型,如人物、地点、组织、物品、概念、事件、制度、其他。'
+ - name: description
+ type: str
+ description:
+ zh: '对实体身份、含义或其在当前文本中作用的简要说明。'
+ required: false
+ relations:
+ description:
+ zh: '实体之间的关系边;若文本提供时间,可在关系上补充时间属性。'
+ fields:
+ - name: source
+ type: str
+ description:
+ zh: '关系起点实体,必须对应已提取实体的 name。'
+ - name: target
+ type: str
+ description:
+ zh: '关系终点实体,必须对应已提取实体的 name。'
+ - name: eventType
+ type: str
+ description:
+ zh: '关系类型,用简洁词语概括两个实体之间的连接方式。'
+ - name: eventDate
+ type: str
+ description:
+ zh: '关系对应的时间;无明确时间时可留空。'
+ required: false
+ - name: details
+ type: str
+ description:
+ zh: '对关系的简要补充说明;无额外信息时可留空。'
+ required: false
+
+guideline:
+ target:
+ zh: '你是一位时序知识图谱构建专家。请从文本中提取关键实体,以及这些实体之间的关系;如果文本提供了明确时间,再为关系补充时间属性。'
+ rules_for_entities:
+ zh:
+ - '提取对理解文本事实、事件过程和时间演变有价值,且能够参与关系连接的实体。'
+ - '为每个实体指定合适类型,如人物、地点、组织、物品、概念、事件、制度、其他。'
+ - 'name 使用原文中最稳定、最清晰的称呼;同一实体在全文中保持命名一致。'
+ - 'description 用 1 句话概括实体身份、含义或其在文本中的作用;信息不足时可留空。'
+ - '优先保留在文本中与其他实体存在明确联系的实体;对既不关键也没有明确关系支撑的边缘实体,可不提取。'
+ rules_for_relations:
+ zh:
+ - '仅在文本明确表达两个实体之间存在关系、事件或状态变化时创建关系边。'
+ - 'source 和 target 必须直接引用已提取实体的 name,不要新增未提取实体。'
+ - '只要文本能支持关系成立,就应提取该关系边。'
+ - 'eventType 使用简洁关系词概括,如属于、位于、任职、合作、参与、影响、发布、签署、相关等。'
+ - 'eventDate 是可选字段;没有明确时间时也要保留关系边,并将 eventDate 留空。'
+ - 'details 只补充必要背景或结果,没有额外信息时可留空。'
+ - '无法确定具体关系对象时,不要强行构造边。'
+ rules_for_time:
+ zh:
+ - '当前观察日期:{observation_time}'
+ - 'eventDate 是可选字段;仅在文本明确提供时间,或可依据相对时间可靠换算时填写。'
+ - '没有明确时间时,仍应保留关系边,并将 eventDate 留空。'
+ - '相对时间以 observation_time 为基准解析,如“去年/今年/明年”“昨天/今天/明天”“十年前/五年后”。'
+ - '若文本给出明确年份,则写为 YYYY;若给出完整日期,则写为 YYYY-MM-DD;保留文本可确定的最细粒度。'
+ - '“年初/年末”可解析为当年 1 月 1 日或 12 月 31 日;朝代、时期名称或模糊历史时间可按原文保留。'
+ - '若时间只对应关系成立、变化或终止中的某一时点,则记录最直接相关的那个时间。'
+ - '无法可靠确定时间时留空,不要根据常识补写。'
+
+identifiers:
+ entity_id: name
+ relation_id: '{source}|{eventType}|{details}'
+ relation_members:
+ source: source
+ target: target
+ time_field: 'eventDate'
+
+options:
+ extraction_mode: two_stage
+
+display:
+ entity_label: '{name} ({type})'
+ relation_label: '{eventType} ({eventDate})'
diff --git a/hyperextract/templates/presets/general/clause_list.yaml b/hyperextract/templates/presets/general/clause_list.yaml
new file mode 100644
index 0000000..d78f9bb
--- /dev/null
+++ b/hyperextract/templates/presets/general/clause_list.yaml
@@ -0,0 +1,50 @@
+language: zh
+name: clause_list
+type: list
+tags: [general]
+description:
+ zh: '规章条文清单 - 将规章制度、操作手册或合规文本拆解为逐条的原子化条文,便于索引、检索、比对与问答。'
+
+output:
+ description:
+ zh: '由逐条拆解后的规章条文组成的列表结果。'
+ fields:
+ - name: clauseId
+ type: str
+ description:
+ zh: '条文编号,如第1条、第2条、第2.1款、第3项等。'
+ - name: title
+ type: str
+ description:
+ zh: '条文标题、主题或该条的简短概括;原文未明确给出时可留空。'
+ required: false
+ default: ''
+ - name: content
+ type: str
+ description:
+ zh: '条文正文内容,尽量保持与原文一致,避免改写。'
+ - name: category
+ type: str
+ description:
+ zh: '条文分类,如总则、权利义务、程序、处罚、附则、其他。'
+ required: false
+ default: '其他'
+
+guideline:
+ target:
+ zh: '你是一位专业的规章制度条文拆解专家。请将输入文本按其自然结构拆解为可独立引用、可检索的逐条条文。'
+ rules:
+ zh:
+ - '按原文的自然层级和编号结构拆解条文,如第X条、第X款、第X项等。'
+ - '每一项输出都应对应一个独立、可单独引用的条文单元。'
+ - 'clauseId 必须尽量使用原文中的编号;若原文无明确编号,可使用稳定且简洁的顺序标识。'
+ - 'content 应保留该条的核心正文,尽量与原文一致,不要总结式改写。'
+ - 'title 仅在原文明确存在标题、主题或能够从该条主旨中直接提炼时填写;否则留空。'
+ - 'category 需尽量归入总则、权利义务、程序、处罚、附则、其他之一。'
+ - '不要遗漏任何实质性条文,也不要把多个独立条文合并成一条。'
+ - '目录、页眉页脚、签章、编号噪音、纯格式性重复内容通常不作为条文输出。'
+
+options: {}
+
+display:
+ label: '{clauseId}({title})'
diff --git a/hyperextract/templates/presets/general/compliance_logic.yaml b/hyperextract/templates/presets/general/compliance_logic.yaml
new file mode 100644
index 0000000..5585069
--- /dev/null
+++ b/hyperextract/templates/presets/general/compliance_logic.yaml
@@ -0,0 +1,81 @@
+language: zh
+name: compliance_logic
+type: hypergraph
+tags: [general]
+description:
+ zh: '规定条文超图 - 面向制度、细则、办法、规范、指引、规程等规定类文本,提取条文中涉及的基本主体及其行为。'
+
+output:
+ description:
+ zh: '由主体/行为节点和规定超边组成的结构化结果。节点只保留条文中的基本主体与行为;超边表示一条独立规定,并概括该规定在要求什么。'
+ entities:
+ description:
+ zh: '规定涉及的基础节点。只提取主体和行为两类节点,不提取条件、结果、章节标题或整句规定。'
+ fields:
+ - name: name
+ type: str
+ description:
+ zh: '实体名称,尽量直接使用原文中的稳定称呼;同一对象若同时出现全称、简称或缩写,应统一为一个名称。'
+ - name: category
+ type: str
+ description:
+ zh: '实体类型,只能是“主体、行为”两种。主体是人、部门、组织或角色;行为是主体执行、被要求执行或被禁止执行的动作短语。'
+ - name: description
+ type: str
+ description:
+ zh: '用一句话说明该主体或行为在条文中的含义。'
+ required: false
+ default: ''
+ relations:
+ description:
+ zh: '表达规定条文的超边。每条超边对应一条独立规定,由相关主体和行为构成。'
+ fields:
+ - name: ruleType
+ type: str
+ description:
+ zh: '规定类型,用于概括该条规定在规定什么。优先使用:职责分工、行为要求、流程程序、其他。'
+ - name: participants
+ type: list[str]
+ description:
+ zh: '构成该条规定基本内容的节点名称列表,必须直接使用已提取节点的 name。通常只包含主体和行为。'
+ - name: action
+ type: str
+ description:
+ zh: '该条规定涉及的核心行为概括,用 1 句话说明主体要做什么。'
+ - name: sourceClause
+ type: str
+ description:
+ zh: '规定来源的条款编号、标题或出处标识,尽量写最近的编号或小节定位。'
+ required: false
+ default: ''
+
+guideline:
+ target:
+ zh: '你是一位规定条文结构化分析专家。请从规定类文本中提取每条规定涉及的基本主体,以及这些主体对应的行为。'
+ rules_for_entities:
+ zh:
+ - '只提取两类节点:主体和行为。不要提取条件、结果、时间、范围、标题或概括性栏目名。'
+ - '主体是人、部门、组织或角色;行为是主体执行、被要求执行或被禁止执行的动作短语。'
+ - 'name 尽量保持原文中的稳定称呼;同一对象不要重复命名。'
+ - '例1:原文“访客进入样品库前须登记”,可提取“访客(主体)”和“登记(行为)”。'
+ - '例2:原文“值班工程师负责核对设备状态并填写交接记录”,可提取“值班工程师(主体)”和“核对设备状态并填写交接记录(行为)”。'
+ rules_for_relations:
+ zh:
+ - '每条超边只表达一条独立规定,并连接相关主体和行为。'
+ - 'ruleType 优先使用:职责分工、行为要求、流程程序、其他。'
+ - 'participants 必须直接引用已提取节点的 name,通常只保留主体和行为。'
+ - 'action 用 1 句话概括这条规定中主体要做的行为。'
+ - '例1:原文“访客进入样品库前须登记”,可抽为 ruleType=流程程序,participants=[访客, 登记],action=规定访客进入样品库前须登记。'
+ - '例2:原文“值班工程师负责核对设备状态并填写交接记录”,可抽为 ruleType=职责分工,participants=[值班工程师, 核对设备状态并填写交接记录],action=规定值班工程师负责核对设备状态并填写交接记录。'
+
+identifiers:
+ entity_id: name
+ relation_id: '{sourceClause}|{ruleType}|{action}'
+ relation_members: participants
+
+options:
+ extraction_mode: one_stage
+
+display:
+ entity_label: '{name} ({category})'
+ relation_label: '[{ruleType}] {action}'
diff --git a/hyperextract/templates/presets/general/concept_hierarchy.yaml b/hyperextract/templates/presets/general/concept_hierarchy.yaml
new file mode 100644
index 0000000..3892f07
--- /dev/null
+++ b/hyperextract/templates/presets/general/concept_hierarchy.yaml
@@ -0,0 +1,81 @@
+language: zh
+name: concept_hierarchy
+type: graph
+tags: [general]
+description:
+ zh: '概念层级图谱模板 - 从教材、百科、定义说明等文本中提取概念及其层次结果的组成或实例化关系,用于构建稳定的概念结构。'
+
+output:
+ description:
+ zh: '由概念节点和层级关系边组成的结构化结果,用于表达概念体系中的分类、组成与实例关系。'
+ entities:
+ description:
+ zh: '文本中出现并可进入概念结构的节点。'
+ fields:
+ - name: name
+ type: str
+ description:
+ zh: '概念名称、术语名称或实例名称,优先使用原文中的稳定叫法。'
+ - name: category
+ type: str
+ description:
+ zh: '概念所属专业类别,需要通过文中内容归纳并结合你的常识进行判断'
+ - name: description
+ type: str
+ description:
+ zh: '对该概念的简要说明,可概括其定义、范围或在当前结构中的作用。'
+ required: false
+ default: ''
+ relations:
+ description:
+ zh: '概念之间的层级或结构关系边。'
+ fields:
+ - name: source
+ type: str
+ description:
+ zh: '关系起点,通常为上位概念、整体概念或被实例化的概念。'
+ - name: target
+ type: str
+ description:
+ zh: '关系终点,通常为下位概念、组成部分或实例。'
+ - name: relation_type
+ type: str
+ description:
+ zh: '层次关系类型,使用具体层级关系词'
+ - name: details
+ type: str
+ description:
+ zh: '对关系方向、限定条件或上下文的简要补充。'
+ required: false
+ default: ''
+
+guideline:
+ target:
+ zh: '你是一位概念层级抽取专家。请只提取能够组成层级结构的概念,并同时给出这些概念之间明确成立的层次结构组成或实例关系。'
+ rules_for_entities:
+ zh:
+ - 'name 必须使用原文中的完整稳定名称;不要把“推理/预测”缩写成“推理”这类更短名字。'
+ - 'category 表明专业所属类别,需要通过文中内容归纳并结合你的常识进行判断;如果无法归类太过于泛化或不重要可留空。'
+ - 'description 用 1 句话简述该概念在当前层级中的含义;若无必要可留空。'
+ rules_for_relations:
+ zh:
+ - '只在文本明确表达层级结构时建立边。'
+ - 'source 和 target 必须逐字对应已提取节点的 name,不能改写、缩写或新造名称。'
+ - '组成用于“X 包含 Y 作为部分/模块/组成项”;实例用于“Y 是 X 的具体实例/代表;你还可以使用一些其他的表示层次关系的词语”。'
+ - '如果某个节点在全文中找不到任何可靠关系,不要为了保留它而强行构造边。'
+ - '优先保证图谱连通性和关系准确性,而不是追求节点数量。'
+ - '若关系依赖特定限定语、范围或角度,可写入 details;没有则留空。'
+
+identifiers:
+ entity_id: name
+ relation_id: '{source}|{relation_type}|{target}'
+ relation_members:
+ source: source
+ target: target
+
+options:
+ extraction_mode: one_stage
+
+display:
+ entity_label: '{name} ({category})'
+ relation_label: '{relation_type}'
diff --git a/hyperextract/templates/presets/general/cross_reference_net.yaml b/hyperextract/templates/presets/general/cross_reference_net.yaml
new file mode 100644
index 0000000..42b9da1
--- /dev/null
+++ b/hyperextract/templates/presets/general/cross_reference_net.yaml
@@ -0,0 +1,81 @@
+language: zh
+name: cross_reference_net
+type: graph
+tags: [general]
+description:
+ zh: '交叉引用网络模板 - 从百科、文档、规章或知识说明类文本中提取条目之间的引用、参见、链接或相关关系。'
+
+output:
+ description:
+ zh: '由条目节点和交叉引用关系组成的网络结构,用于表达文本中的引用路径和知识跳转关系。'
+ entities:
+ description:
+ zh: '可作为引用发起方或引用目标的条目、概念或章节节点。'
+ fields:
+ - name: name
+ type: str
+ description:
+ zh: '条目、概念、章节或被引用对象的名称。'
+ - name: type
+ type: str
+ description:
+ zh: '节点类型,如条目、章节、概念、人物、地点、其他。'
+ - name: description
+ type: str
+ description:
+ zh: '对节点含义或其在当前引用网络中角色的简要说明。'
+ required: false
+ default: ''
+ relations:
+ description:
+ zh: '节点之间的交叉引用关系边。'
+ fields:
+ - name: source
+ type: str
+ description:
+ zh: '引用发起方,即当前条目、章节或概念。'
+ - name: target
+ type: str
+ description:
+ zh: '被引用、被链接、被参见或被关联的目标节点。'
+ - name: relation_type
+ type: str
+ description:
+ zh: '关系类型,优先使用超链接、引用、参见、相关、其他。'
+ - name: context
+ type: str
+ description:
+ zh: '对引用语境、引用目的或上下文位置的简要补充。'
+ required: false
+ default: ''
+
+guideline:
+ target:
+ zh: '你是一位知识网络分析专家。请从文本中提取可独立识别的条目或概念,并建立它们之间明确存在的引用、参见或相关连接。'
+ rules_for_entities:
+ zh:
+ - '优先提取在文本中被明确提及、并能够作为引用源或引用目标的条目、概念、章节、人物或地点。'
+ - 'name 使用原文中最清晰、最稳定的称呼;同一对象保持统一命名。'
+ - 'type 需概括节点身份,如条目、章节、概念、人物、地点、其他。'
+ - 'description 可用于说明该节点为何会进入当前引用网络;信息不足时可留空。'
+ rules_for_relations:
+ zh:
+ - '仅在文本明确存在引用、超链接、参见、相关提示或互指关系时建立边。'
+ - 'source 和 target 必须直接引用已提取节点的 name。'
+ - 'relation_type 优先使用超链接、引用、参见、相关、其他,并尽量与文本表达保持一致。'
+ - '若引用关系带有特定上下文、说明语或引用目的,可写入 context;否则留空。'
+ - '不要把仅仅共同出现、主题相近但没有显式互指的节点误判为交叉引用关系。'
+
+identifiers:
+ entity_id: name
+ relation_id: '{source}|{relation_type}|{target}'
+ relation_members:
+ source: source
+ target: target
+
+options:
+ extraction_mode: two_stage
+
+display:
+ entity_label: '{name} ({type})'
+ relation_label: '{relation_type}'
diff --git a/hyperextract/templates/presets/general/entity_registry.yaml b/hyperextract/templates/presets/general/entity_registry.yaml
new file mode 100644
index 0000000..2abb4e4
--- /dev/null
+++ b/hyperextract/templates/presets/general/entity_registry.yaml
@@ -0,0 +1,45 @@
+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:
+ - '提取对理解文本内容有意义的实体,如人物、机构、地点、产品、概念、事件、制度等。'
+ - 'name 使用文本中最清晰、最稳定的称呼;同一实体若有简称或别称,应统一为一个名称。'
+ - 'category 用于概括实体类型,尽量准确且可复用。'
+ - 'description 用 1 句话说明实体是谁、是什么或在文本中的作用;信息不足时可留空。'
+ - '对同一实体进行去重,不要因表述差异重复输出多条。'
+ - '不要把纯代词、泛称、临时描述短语或无独立指代意义的词语当作实体。'
+
+identifiers:
+ item_id: name
+
+options: {}
+
+display:
+ label: name
diff --git a/hyperextract/templates/presets/general/graph.yaml b/hyperextract/templates/presets/general/graph.yaml
index 6f808b0..150ff0b 100644
--- a/hyperextract/templates/presets/general/graph.yaml
+++ b/hyperextract/templates/presets/general/graph.yaml
@@ -2,53 +2,56 @@ language: zh
name: knowledge_graph
type: graph
tags: [general]
-description: '通用知识图谱 - 提取实体和它们之间的关系'
+description: '通用知识图谱模板 - 从非结构化文本中提取关键实体、实体类型及实体之间的显式关系,适用于新闻、百科、制度和说明类文本的基础结构化建模。'
output:
- description: '通用知识图谱结构'
+ description: '由实体节点和关系边组成的通用知识图谱结果,用于表达文本中的核心对象及其语义连接。'
entities:
- description: '提取的实体'
+ description: '文本中可独立识别、可作为关系端点的实体节点。'
fields:
- name: name
type: str
- description: '实体名称'
+ description: '实体在文本中的标准称呼或最稳定名称。'
- name: type
type: str
- description: '实体类型'
+ description: '实体类别,如人物、地点、组织、物品、概念、事件、制度、技术等。'
- name: description
type: str
- description: '实体描述'
+ description: '对实体身份、含义或在当前文本中作用的简要说明。'
required: false
relations:
- description: '实体之间的关系'
+ description: '实体之间的显式语义关系边。'
fields:
- name: source
type: str
- description: '源实体'
+ description: '关系起点实体,必须对应已提取实体的 name。'
- name: target
type: str
- description: '目标实体'
+ description: '关系终点实体,必须对应已提取实体的 name。'
- name: type
type: str
- description: '关系类型'
+ description: '关系类型,应使用简洁明确的语义词,如包含、属于、合作、影响、导致、相关等。'
- name: description
type: str
- description: '关系描述'
+ description: '对关系依据、方向或上下文含义的简要说明。'
required: false
guideline:
target:
- zh: '你是一位知识图谱专家,请从文本中提取实体和它们之间的关系。'
+ zh: '你是一位知识抽取与知识图谱构建专家。请基于给定文本识别关键实体,并构建仅由这些实体组成的二元关系图。'
rules_for_entities:
zh:
- - '提取所有相关实体'
- - '为每个实体指定类型'
- - '实体类型包括:人物、地点、组织、物品、概念、事件等'
+ - '提取对理解文本事实、结构或逻辑有价值的实体,避免无意义的泛称和临时短语。'
+ - 'name 使用原文中最明确、最稳定的称呼;同一实体在全文中保持命名一致。'
+ - 'type 需概括实体类别,可使用人物、地点、组织、物品、概念、事件、制度、技术等标签。'
+ - 'description 用 1 句话概括实体的身份、属性或在文本中的作用;若信息不足可留空。'
rules_for_relations:
zh:
- - '仅从提取的实体中创建关系边'
- - '关系类型包括:包含、属于、相关、影响、合作、竞争等'
- - 'source 和 target 都必须是已提取的实体'
+ - '仅在文本明确表达两个实体之间存在语义联系时创建关系,不要凭常识补充隐含关系。'
+ - 'source 和 target 必须直接引用已提取实体的 name,不能新造实体名称。'
+ - 'type 使用简洁、方向清晰的关系词,如包含、属于、相关、影响、合作、竞争、导致、位于、使用等。'
+ - 'description 简要说明关系依据、作用方式或上下文;若文本没有额外信息可留空。'
+ - '避免重复关系;若同一对实体存在多种不同关系,可分别记录。'
identifiers:
entity_id: name
diff --git a/hyperextract/templates/presets/general/life_event_timeline.yaml b/hyperextract/templates/presets/general/life_event_timeline.yaml
index 77264a0..ccc5902 100644
--- a/hyperextract/templates/presets/general/life_event_timeline.yaml
+++ b/hyperextract/templates/presets/general/life_event_timeline.yaml
@@ -1,70 +1,76 @@
language: zh
-name: life_event_timeline
+name: biographical_timeline
type: temporal_graph
tags: [general]
description:
- zh: '生活事件时间线 - 提取带时间戳的事件,并按时间顺序排列'
+ zh: '人物生平时间线 - 从传记、自传、回忆录等人物叙事文本中提取带时间的生平事件,并组织为时间线。'
output:
description:
- zh: '包含实体和事件关系的时间线'
+ zh: '由人物相关实体和生平事件关系组成的时间线结果,用于还原人物经历、角色变化与关键转折。'
entities:
description:
- zh: '提取的实体'
+ zh: '文本中与人物生平相关、可作为事件端点的实体。'
fields:
- name: name
type: str
description:
- zh: '实体名称'
+ zh: '实体在文本中的稳定名称或常用称呼。'
- name: type
type: str
description:
- zh: '实体类型:人物、地点、组织、物品、概念、其他'
+ zh: '实体类型,如人物、地点、组织、作品、奖项、身份、物品、概念、其他。'
- name: description
type: str
description:
- zh: '简要描述'
+ zh: '对实体身份、角色或在当前文本中作用的简要说明。'
required: false
relations:
description:
- zh: '提取的事件关系'
+ zh: '围绕人物经历构建的事件关系边。'
fields:
- name: source
type: str
description:
- zh: '事件主体/相关实体'
+ zh: '事件发起者或经历者,通常为人物主体或触发事件的相关实体。'
- name: target
type: str
description:
- zh: '事件对象/相关实体'
+ zh: '与该事件直接相关的对象实体,如地点、学校、组织、人物、作品、奖项等。'
- name: eventType
type: str
description:
- zh: '事件类型:出生、逝世、教育、工作、成就、交往、旅行、其他'
+ zh: '事件类型。使用能够概括事件本身的简洁词语或短语,优先具体、直观、可区分;通常可用动词,如出生、入学、任职、结婚、出版、获奖。可参考示例,但不必局限于示例,也可以根据文本语义自行创造更贴切的标签。'
- name: eventDate
type: str
description:
- zh: '事件日期,格式为年-月-日或年份'
+ zh: '事件时间。优先保留文本中最精确的时间表达;可为年份、年月、年月日,必要时可保留时间段。'
required: false
- name: details
type: str
description:
- zh: '事件详细描述'
+ zh: '事件补充说明,可记录身份、地点、机构、结果或上下文。'
required: false
guideline:
target:
- zh: '你是一位专业的传记年表专家,请从文本中提取人物、地点、组织等实体以及生活事件。'
+ zh: '你是一位专业的人物传记事件抽取专家。请围绕人物主体,从文本中提取与其生平经历直接相关的实体和事件,并构建可信的时间线。'
rules_for_entities:
zh:
- - '提取所有相关实体'
- - '为每个实体指定类型'
- - '人物、地点、组织、物品、概念等实体'
+ - '优先提取与人物主体生平经历直接相关的实体,如人物、地点、组织、作品、奖项、身份称谓等。'
+ - '为每个实体指定尽量准确的类型,并优先使用文本中的稳定称呼。'
+ - '不必为纯背景概念、空泛评价或无法成为事件端点的内容单独建实体。'
rules_for_relations:
zh:
- - '仅从提取的实体中创建事件边'
- - '事件类型:出生、逝世、教育、工作、成就、交往、旅行、其他'
- - '时间信息为可选,仅在文本中明确提及时才提取'
+ - '仅从已提取实体中创建事件边,source 和 target 都必须对应实体 name。'
+ - '事件应代表可放入人物时间线的经历、转折、公开活动或身份变化,不要把纯评价、性格描述或静态背景知识当作事件。'
+ - '若一句话包含多个独立事件,应拆分为多条关系;若同一事件同时涉及时间、地点、组织、身份,可在 details 中补充。'
+ - 'eventType 应使用能够概括事件本身的简洁词语或短语,优先具体、直观、可区分;通常可用动词或动宾结构。'
+ - '优先写贴近原文语义的具体标签,不要过度抽象。例如优先写“入学、毕业、留学”而不是“教育”,优先写“任职、升迁、离任”而不是“工作”,优先写“出版、获奖、发明”而不是“成就”。'
+ - '可参考但不限于以下示例:出生、逝世、迁居、入学、毕业、任职、结婚、合作、出版、获奖、参战、归国、隐居。'
+ - '允许根据文本语义自行创造更贴切的标签,例如拜师、出道、登基、封侯、退赛、复出等;不要求必须使用示例中的词。'
+ - '仅在确实无法提炼出更具体的事件标签时,才使用较泛的词。'
+ - '时间信息为可选,仅在文本明确给出或能根据明确相对时间可靠换算时才填写。'
rules_for_time:
zh:
- '当前观察日期:{observation_time}'
@@ -76,14 +82,15 @@ guideline:
- '- "十年前/五年后" → {observation_time} 前/后相应年数'
- '- "年初/年末" → 当年 1月1日/12月31日'
- '- "朝代" → 保留朝代名称'
- - '明确日期:保持原格式'
+ - '明确时间:优先保留文本中最精确的原始格式'
- '- 年份(如 429年、2023年)→ 429、2023'
- - '- 年-月-日 → 保持原格式'
+ - '- 年-月、年-月-日、时间段(如 1937-1945)→ 保持原格式'
+ - '若只有模糊阶段性表达且无法可靠换算,不要强行补时间'
- '缺失时间:留空'
identifiers:
entity_id: name
- relation_id: '{source}|{eventType}|{details}'
+ relation_id: '{source}|{target}'
relation_members:
source: source
target: target
@@ -94,4 +101,4 @@ options:
display:
entity_label: '{name} ({type})'
- relation_label: '{eventType}'
+ relation_label: '{eventType}({eventDate})'
diff --git a/hyperextract/templates/presets/general/social_network.yaml b/hyperextract/templates/presets/general/social_network.yaml
new file mode 100644
index 0000000..cfdc3b5
--- /dev/null
+++ b/hyperextract/templates/presets/general/social_network.yaml
@@ -0,0 +1,87 @@
+language: zh
+name: social_network
+type: graph
+tags: [general]
+description:
+ zh: '社会关系网络模板 - 从人物叙事、组织介绍、历史材料或新闻文本中提取人物与组织之间的人际和隶属关系。'
+
+output:
+ description:
+ zh: '由人物、组织等节点及其关系边组成的社会关系网络结构。'
+ entities:
+ description:
+ zh: '人际关系网络中的人物、组织或机构节点。'
+ fields:
+ - name: name
+ type: str
+ description:
+ zh: '人物、组织或机构的名称。'
+ - name: type
+ type: str
+ description:
+ zh: '节点类型,如人物、组织、机构、团体、其他。'
+ - name: description
+ type: str
+ description:
+ zh: '对节点身份或其在网络中作用的简要说明。'
+ required: false
+ default: ''
+ - name: role
+ type: str
+ description:
+ zh: '该节点在当前文本中的角色、身份或职位。'
+ required: false
+ default: ''
+ relations:
+ description:
+ zh: '人物与人物、人物与组织、组织与组织之间的社会关系边。'
+ fields:
+ - name: source
+ type: str
+ description:
+ zh: '关系起点节点。'
+ - name: target
+ type: str
+ description:
+ zh: '关系终点节点。'
+ - name: relation_type
+ type: str
+ description:
+ zh: '关系类型,如亲属、朋友、同事、师生、上下级、合作、竞争、隶属、其他。'
+ - name: details
+ type: str
+ description:
+ zh: '对关系依据、互动方式或上下文的简要补充。'
+ required: false
+ default: ''
+
+guideline:
+ target:
+ zh: '你是一位社会关系分析专家。请从文本中提取人物、组织及其明确存在的人际关系或组织隶属关系。'
+ rules_for_entities:
+ zh:
+ - '优先提取对关系网络有意义的人物、组织、机构或团体节点。'
+ - 'name 使用文本中最稳定、最清晰的称呼;同一对象保持统一命名。'
+ - 'type 概括节点类别,role 用于补充其在当前文本中的身份或职位;没有则留空。'
+ - 'description 可说明该节点为何重要或其在关系网络中的作用;信息不足时留空。'
+ rules_for_relations:
+ zh:
+ - '仅在文本明确表达两节点之间存在社会关系、合作关系、竞争关系或组织隶属时建立边。'
+ - 'source 和 target 必须直接引用已提取节点的 name。'
+ - 'relation_type 优先使用亲属、朋友、同事、师生、上下级、合作、竞争、隶属、其他。'
+ - 'details 可用于补充关系背景、时间段或互动情境;没有额外信息时留空。'
+ - '不要把共同出现、共同被提及但无明确互动的对象误判为存在关系。'
+
+identifiers:
+ entity_id: name
+ relation_id: '{source}|{relation_type}|{target}'
+ relation_members:
+ source: source
+ target: target
+
+options:
+ extraction_mode: two_stage
+
+display:
+ entity_label: '{name} ({role})'
+ relation_label: '{relation_type}'