Hypergraph is more powerful. Transform unstructured text into structured knowledge with LLMs. Graphs, hypergraphs, and spatio-temporal extractions — with one command.
docs(templates): 统一规范所有模板的提示词结构,添加核心概念定义
yifanfeng97499fb5c237b9
diff --git a/hyperextract/templates/en/INSTRUCTION.md b/hyperextract/templates/en/INSTRUCTION.mdindex baf436e..7d76d1f 100644--- a/hyperextract/templates/en/INSTRUCTION.md+++ b/hyperextract/templates/en/INSTRUCTION.md@@ -1,4 +1,4 @@-# Hyper-Extract Knowledge Template Definition Manual+# Hyper-Extract Knowledge Template Definition ManualThis document defines the standard-specific knowledge extraction templates workflow for implementing domain in the `Hyper-Extract` framework.@@ -179,6 +179,71 @@ Current Observation Location: {observation_location}| `_NODE_PROMPT` | two_stage step 1: extract nodes only || `_EDGE_PROMPT` | two_stage step 2: extract edges based on known nodes |+### 4.3 Prompt Pre-Structure Specifications (Mandatory)++**All Prompts MUST follow the following pre-structure, no exceptions**:++```+## Role and Task+You are a professional xxx expert, please extract xxx from the text...++## Core Concept Definitions (varies by AutoType)+- **Concept 1**: xxx+- **Concept 2**: xxx++## Extraction Rules+...+```++**Why concept definitions are needed?**+- Let the LLM understand "what" to extract first, before telling it "how" to extract+- Different AutoTypes have different core concepts that must be clearly defined+- Concept definitions must be placed at the beginning of the Prompt++### 4.4 Core Concept Definition Templates for Each AutoType++#### AutoModel+```+## Core Concept Definitions+- **Object**: A single structured object extracted from the text, containing multiple fields+```++#### AutoList+```+## Core Concept Definitions+- **Item**: Repeating pattern instances extracted from the text+```++#### AutoSet+```+## Core Concept Definitions+- **Element**: Knowledge units with unique keys, used for accumulating information+```++#### AutoGraph+```+## Core Concept Definitions+- **Node**: Entities in the graph+- **Edge**: Binary relationships between nodes+```++#### AutoHypergraph+```+## Core Concept Definitions+- **Node**: Basic elements that make up hyperedges (edges), serving as participants in hyperedges+- **Edge**: Connects multiple nodes and expresses complex relationships among multiple entities+```++#### AutoTemporalGraph / AutoSpatialGraph / AutoSpatioTemporalGraph+In addition to node and edge definitions, time/location definitions must also be added:+```+## Core Concept Definitions+- **Node**: Entities in the graph+- **Edge**: Binary relationships between nodes+- **Time**: xxx (define according to actual needs)+- **Location**: xxx (define according to actual needs)+```+---## 5. Parameter Management Specifications@@ -272,10 +337,14 @@ class FinancialRelation(BaseModel):# 2. Predefined Prompts (All in English)# ==============================================================================-_NODE_PROMPT = """-You are a professional financial analyst. Extract all key entities as nodes.+_NODE_PROMPT = """## Role and Task+You are a professional financial analyst, extract all key entities as nodes from the text.-### Extraction Rules+## Core Concept Definitions+- **Node**: Entities in the graph+- **Edge**: Binary relationships between nodes++## Extraction Rules1. Extract all entities such as companies, products, departments2. Assign type for each entity: company, product, department3. Keep entity names consistent with the source text@@ -284,9 +353,15 @@ You are a professional financial analyst. Extract all key entities as nodes.### Source Text:"""-_EDGE_PROMPT = """-You are a professional financial analyst. Extract relationships between given entities.+_EDGE_PROMPT = """## Role and Task+You are a professional financial analyst, extract relationships between given entities.++## Core Concept Definitions+- **Node**: Entities in the graph+- **Edge**: Binary relationships between nodes+- **Time**: Records time information when relationships occur+## Extraction Rules### Time Format RequirementsAll time information must be unified to "YYYY-MM-DD" format (e.g., 2023-06-15).@@ -304,12 +379,19 @@ Current Observation Date: {observation_time}### Constraints1. Only extract edges from the known entity list below2. Do NOT create entities not listed+3. Each edge must contain source, target, relationType"""-_PROMPT = """-You are a professional financial analyst. Extract entities and their relationships from text.+_PROMPT = """## Role and Task+You are a professional financial analyst, extract entities and their relationships from text.++## Core Concept Definitions+- **Node**: Entities in the graph+- **Edge**: Binary relationships between nodes+- **Time**: Records time information when relationships occur+## Extraction Rules### Node Extraction Rules1. Extract all entities such as companies, products, departments2. **NEVER extract time or location as independent nodes**diff --git a/hyperextract/templates/en/general/clause_list.py b/hyperextract/templates/en/general/clause_list.pyindex 6178318..832ea4a 100644--- a/hyperextract/templates/en/general/clause_list.py+++ b/hyperextract/templates/en/general/clause_list.py@@ -18,9 +18,13 @@ class Clause(BaseModel):category: str = Field(description="Clause category: GeneralProvisions, RightsAndObligations, Procedures, Penalties, SupplementaryProvisions, Other", default="Other")-_PROMPT = """You are a professional regulation clause breakdown expert. Please break down the text into atomic clauses.+_PROMPT = """## Role and Task+You are a professional regulation clause breakdown expert. Please break down the text into atomic clauses.-### Extraction Rules+## Core Concept Definitions+- **Item**: In this template, "Item" refers to a single regulation clause, an atomic rule unit that includes fields such as clause ID, title, content, and category.++## Extraction Rules1. Break down the regulation into independent clauses according to its natural structure2. Assign an ID to each clause (e.g., Article 1, Section 2.1, etc.)3. Extract the content of each clausediff --git a/hyperextract/templates/en/general/compliance_logic.py b/hyperextract/templates/en/general/compliance_logic.pyindex 057cb6d..4d034c0 100644--- a/hyperextract/templates/en/general/compliance_logic.py+++ b/hyperextract/templates/en/general/compliance_logic.py@@ -12,65 +12,84 @@ from hyperextract.types import AutoHypergraphclass ComplianceElement(BaseModel):"""Compliance Element - Node"""- name: str = Field(description="Element name")- type: str = Field(description="Element type: Subject, Action, Condition, Other")+ name: str = Field(description="Element name, exact name from text")+ category: str = Field(description="Element category: Subject, Action, Condition, Other")description: str = Field(description="Brief description", default="")class ComplianceRule(BaseModel):"""Compliance Rule - Hyperedge"""- rule_type: str = Field(description="Rule type: Must, MustNot, May, Other")+ ruleType: str = Field(description="Rule type: Must, MustNot, May, Other")+ participants: List[str] = Field(description="List of participating element names, must use names from extracted nodes")action: str = Field(description="Required or prohibited action content")condition: str = Field(description="Applicable conditions/prerequisites", default="")- penalty: str = Field(description="Violation consequences/penalties", default="")- source_clause: str = Field(description="Source clause of the rule", default="")- notes: str = Field(description="Additional notes", default="")- participants: List[str] = Field(description="List of participating element names")+ consequence: str = Field(description="Violation consequences/incentives", default="")+ sourceClause: str = Field(description="Source clause of the rule", default="")-_PROMPT = """You are a professional compliance analysis expert. Please extract compliance elements and rules from the text, modeling the logic of "under what conditions, which subjects must/may not perform which actions" to build a compliance behavior hypergraph.+_PROMPT = """## Role and Task+You are a professional compliance assessor, skilled in extracting compliance elements and analyzing rule logic from documents. Please extract compliance elements and rules from the text to build a compliance behavior hypergraph.-### Node Extraction Rules+## Core Concept Definitions+- **Node**: In this template, "Node" refers to basic elements that make up rules, divided into four categories:+ - **Subject**: Entities that perform actions (individuals, departments, organizations, roles, etc.)+ - **Action**: Specific actions or behaviors (submit, approve, execute, prohibit, etc.)+ - **Condition**: Prerequisites or scenarios where the rule applies (time, location, status, quantity, etc.)+ - **Other**: Elements that don't fall into the above categories (documents, files, status, results, etc.)+- **Hyperedge(Edge)**: In this template, "Hyperedge" is also known as "rule", connects multiple nodes and expresses the logic of "under what conditions, which subjects must/may not perform which actions".++## Extraction Rules+### Node Extraction1. Extract elements involved in rules as nodes-2. Assign type to each element: Subject, Action, Condition, Other+2. Assign category to each element: Subject, Action, Condition, Other3. Add brief description for each element-### Hyperedge Extraction Rules-1. Only create compliance rule hyperedges from extracted elements-2. Assign rule type: Must, MustNot, May, Other-3. Fill in required or prohibited action content (required)-4. Extract applicable conditions/prerequisites (if available)-5. Extract violation consequences/penalties (if available)-6. Extract source clause (if available)-7. Add additional notes (if available)-8. List all participating element names (required)--### Constraints-- Ensure rule logic accuracy-- Maintain objectivity and accuracy, do not add information not in the text-- Each hyperedge must contain rule_type, action, and participants-- Try to fill other fields, use empty string for missing fields+### Hyperedge Extraction+1. Only create rules from extracted nodes+2. Rule type: Must, MustNot, May, Other+3. Must contain ruleType, participants, and action+4. participants must strictly use names from extracted nodes+5. Try to fill other fields, use empty string for missing fields### Source text:"""-_NODE_PROMPT = """You are a professional compliance element recognition expert. Please extract all compliance-related elements as nodes from the text.+_NODE_PROMPT = """## Role and Task+You are a professional compliance element recognition expert, skilled in accurately identifying core compliance-related elements from documents. Please extract all compliance-related elements as nodes from the text.-### Extraction Rules-1. Extract elements involved in rules-2. Assign type to each element: Subject, Action, Condition, Other-3. Add brief description for each element+## Core Concept Definitions+- **Node**: In this template, "Node" refers to basic elements that make up rules, divided into four categories:+ - **Subject**: Entities that perform actions (individuals, departments, organizations, roles, etc.)+ - **Action**: Specific actions or behaviors (submit, approve, execute, prohibit, etc.)+ - **Condition**: Prerequisites or scenarios where the rule applies (time, location, status, quantity, etc.)+ - **Other**: Elements that don't fall into the above categories (documents, files, status, results, etc.)++## Extraction Rules+1. Extract concrete, atomic elements, not abstract "processes" or "comparison tables"+2. Use exact nouns or verbs from the text as element names+3. Assign correct category to each element+4. Add brief description (1-2 sentences) for each element### Source text:"""-_EDGE_PROMPT = """You are a professional compliance rule extraction expert. Please extract compliance rule hyperedges from the given node (element) list.+_EDGE_PROMPT = """## Role and Task+You are a professional compliance rule analyst, skilled in building clear compliance rule relationships from given elements. Please extract compliance rule hyperedges from the given node list.++## Core Concept Definitions+- **Node**: In this template, "Node" refers to basic elements that make up rules, serving as participants in hyperedges.+- **Hyperedge(Edge)**: In this template, "Hyperedge" is also known as "rule", connects multiple nodes and expresses the logic of "under what conditions, which subjects must/may not perform which actions".++## Extraction Rules+1. **participants must strictly use names from the "Known Elements List" below**, do not create new names+2. Rules must contain ruleType, participants, and action+3. participants should include: involved subjects, executed actions, and related other elements-### Constraints-1. Only extract rules (hyperedges) from the known element list below-2. Do not create unlisted elements-3. Each rule must contain rule_type, action, and participants-4. Try to fill other fields, use empty string for missing fields+### Rule Types+- **Must**: Mandatory actions to perform+- **MustNot**: Prohibited actions+- **May**: Permissible actions+- **Other**: Rules that don't fall into the above categories"""@@ -84,7 +103,7 @@ class ComplianceLogic(AutoHypergraph[ComplianceElement, ComplianceRule]):Example:>>> template = ComplianceLogic(llm_client=llm, embedder=embedder)- >>> template.feed_text("Universe First Slacker Company Compliance Manual...")+ >>> template.feed_text("Company Compliance Manual...")>>> template.show()"""@@ -114,7 +133,7 @@ class ComplianceLogic(AutoHypergraph[ComplianceElement, ComplianceRule]):node_schema=ComplianceElement,edge_schema=ComplianceRule,node_key_extractor=lambda x: x.name,- edge_key_extractor=lambda x: f"{sorted(x.participants)}_{x.rule_type}_{x.action}",+ edge_key_extractor=lambda x: f"{sorted(x.participants)}_{x.ruleType}_{x.action}",nodes_in_edge_extractor=lambda x: tuple(x.participants),llm_client=llm_client,embedder=embedder,@@ -141,10 +160,10 @@ class ComplianceLogic(AutoHypergraph[ComplianceElement, ComplianceRule]):top_k_for_chat: Number of nodes/edges to use for chat, default: 3"""def node_label_extractor(node: ComplianceElement) -> str:- return f"{node.name} ({node.type})"+ return f"{node.name} ({node.category})"def edge_label_extractor(edge: ComplianceRule) -> str:- return f"[{edge.rule_type}] {edge.action}"+ return f"[{edge.ruleType}] {edge.action}"super().show(node_label_extractor=node_label_extractor,diff --git a/hyperextract/templates/en/general/concept_hierarchy.py b/hyperextract/templates/en/general/concept_hierarchy.pyindex dfefacc..d020118 100644--- a/hyperextract/templates/en/general/concept_hierarchy.py+++ b/hyperextract/templates/en/general/concept_hierarchy.py@@ -25,8 +25,14 @@ class HierarchyRelation(BaseModel):details: str = Field(description="Detailed relationship explanation", default="")-_PROMPT = """You are a professional concept structure analysis expert. Please extract concepts and their hierarchical relationships from the text to build a concept hierarchy graph.+_PROMPT = """## Role and Task+You are a professional concept structure analysis expert. Please extract concepts and their hierarchical relationships from the text to build a concept hierarchy graph.+## Core Concept Definitions+- **Node**: In this template, "Node" refers to a concept unit, categorized into types such as CoreConcept, Subconcept, Attribute, and Instance, used to represent basic concepts in a knowledge system.+- **Edge**: In this template, "Edge" refers to a hierarchical relationship between concepts, including binary relationships such as Subclass-Of (taxonomy), Part-Of (composition), and Instance-Of (instance).++## Extraction Rules### Node Extraction Rules1. Extract all concepts: CoreConcept, Subconcept, Attribute, Instance, etc.2. Assign a type to each concept: CoreConcept, Subconcept, Attribute, Instance, Other@@ -49,9 +55,13 @@ _PROMPT = """You are a professional concept structure analysis expert. Please ex### Source text:"""-_NODE_PROMPT = """You are a professional concept recognition expert. Please extract all concepts as nodes from the text.+_NODE_PROMPT = """## Role and Task+You are a professional concept recognition expert. Please extract all concepts as nodes from the text.++## Core Concept Definitions+- **Node**: In this template, "Node" refers to a concept unit, categorized into types such as CoreConcept, Subconcept, Attribute, and Instance, used to represent basic concepts in a knowledge system.-### Extraction Rules+## Extraction Rules1. Extract all concepts: CoreConcept, Subconcept, Attribute, Instance, etc.2. Assign a type to each concept: CoreConcept, Subconcept, Attribute, Instance, Other3. Add a brief description for each concept@@ -59,8 +69,14 @@ _NODE_PROMPT = """You are a professional concept recognition expert. Please extr### Source text:"""-_EDGE_PROMPT = """You are a professional hierarchical relationship extraction expert. Please extract hierarchical relationships between concepts (nodes) from the given concept list.+_EDGE_PROMPT = """## Role and Task+You are a professional hierarchical relationship extraction expert. Please extract hierarchical relationships between concepts (nodes) from the given concept list.++## Core Concept Definitions+- **Node**: In this template, "Node" refers to a concept unit, as participants in hierarchical relationships.+- **Edge**: In this template, "Edge" refers to a hierarchical relationship between concepts, including binary relationships such as Subclass-Of (taxonomy), Part-Of (composition), and Instance-Of (instance).+## Extraction Rules### Relationship Type Explanation- Subclass-Of: Taxonomy relationship (subclass and superclass)- Part-Of: Composition relationship (part and whole)diff --git a/hyperextract/templates/en/general/cross_reference_net.py b/hyperextract/templates/en/general/cross_reference_net.pyindex 8986a3c..c491781 100644--- a/hyperextract/templates/en/general/cross_reference_net.py+++ b/hyperextract/templates/en/general/cross_reference_net.py@@ -25,8 +25,14 @@ class ReferenceRelation(BaseModel):context: str = Field(description="Reference context description", default="")-_PROMPT = """You are a professional knowledge network analysis expert. Please extract concepts/entries and their mutual reference relationships from the text to build a cross-reference network.+_PROMPT = """## Role and Task+You are a professional knowledge network analysis expert. Please extract concepts/entries and their mutual reference relationships from the text to build a cross-reference network.+## Core Concept Definitions+- **Node**: In this template, "Node" refers to a concept or entry unit, including types such as Entry, Section, Concept, Person, Location, etc., used to represent entities in a knowledge network.+- **Edge**: In this template, "Edge" refers to a reference relationship between concepts/entries, including binary relationships such as Hyperlink, Reference, SeeAlso, and Related.++## Extraction Rules### Node Extraction Rules1. Extract all mentioned concepts or entries2. Assign a type to each node: Entry, Section, Concept, Person, Location, Other@@ -50,9 +56,13 @@ _PROMPT = """You are a professional knowledge network analysis expert. Please ex### Source text:"""-_NODE_PROMPT = """You are a professional entry recognition expert. Please extract all concepts or entries as nodes from the text.+_NODE_PROMPT = """## Role and Task+You are a professional entry recognition expert. Please extract all concepts or entries as nodes from the text.++## Core Concept Definitions+- **Node**: In this template, "Node" refers to a concept or entry unit, including types such as Entry, Section, Concept, Person, Location, etc., used to represent entities in a knowledge network.-### Extraction Rules+## Extraction Rules1. Extract all mentioned concepts or entries2. Assign a type to each node: Entry, Section, Concept, Person, Location, Other3. Add a brief description for each node@@ -60,8 +70,14 @@ _NODE_PROMPT = """You are a professional entry recognition expert. Please extrac### Source text:"""-_EDGE_PROMPT = """You are a professional reference relationship extraction expert. Please extract mutual reference relationships between nodes from the given node list.+_EDGE_PROMPT = """## Role and Task+You are a professional reference relationship extraction expert. Please extract mutual reference relationships between nodes from the given node list.++## Core Concept Definitions+- **Node**: In this template, "Node" refers to a concept or entry unit, as participants in reference relationships.+- **Edge**: In this template, "Edge" refers to a reference relationship between concepts/entries, including binary relationships such as Hyperlink, Reference, SeeAlso, and Related.+## Extraction Rules### Relationship Type Explanation- Hyperlink: Hyperlink relationship- Reference: Reference relationshipdiff --git a/hyperextract/templates/en/general/encyclopedia_item.py b/hyperextract/templates/en/general/encyclopedia_item.pyindex ff684ee..119cf6c 100644--- a/hyperextract/templates/en/general/encyclopedia_item.py+++ b/hyperextract/templates/en/general/encyclopedia_item.py@@ -22,9 +22,13 @@ class EncyclopediaInfo(BaseModel):relatedConcepts: List[str] = Field(description="Related concepts/entries", default_factory=list)-_PROMPT = """You are a professional encyclopedia editor. Please extract structured attribute information for a single subject from the text to build an encyclopedia item infobox.+_PROMPT = """## Role and Task+You are a professional encyclopedia editor. Please extract structured attribute information for a single subject from the text to build an encyclopedia item infobox.-### Extraction Rules+## Core Concept Definitions+- **Object**: In this template, "Object" refers to a single encyclopedia entry subject, which is a structured information unit containing multiple fields such as title, entity type, aliases, categories, summary, attributes, important events, related concepts, etc.++## Extraction Rules1. Identify the core subject of the text (Person, Location, Organization, Event, Concept, etc.)2. Assign a type to the subject: Person, Location, Organization, Event, Concept, Item, Other3. Extract all aliases, common names, or foreign namesdiff --git a/hyperextract/templates/en/general/entity_registry.py b/hyperextract/templates/en/general/entity_registry.pyindex 3efad83..581b83d 100644--- a/hyperextract/templates/en/general/entity_registry.py+++ b/hyperextract/templates/en/general/entity_registry.py@@ -17,9 +17,13 @@ class RegistryEntry(BaseModel):description: str = Field(description="Brief description", default="")-_PROMPT = """You are a professional entity recognition expert. Please extract all unique entities from the text to form an entity registry.+_PROMPT = """## Role and Task+You are a professional entity recognition expert. Please extract all unique entities from the text to form an entity registry.-### Extraction Rules+## Core Concept Definitions+- **Element**: In this template, "Element" refers to a single entity registry entry, a unique knowledge unit that includes fields such as entity name, type, and description, and is deduplicated by name.++## Extraction Rules1. Extract all entities: Person, Organization, Location, Product, Concept, etc.2. Assign a type to each entity: Person, Organization, Location, Product, Concept, Other3. Keep entity names consistent with the original textdiff --git a/hyperextract/templates/en/general/keyword_list.py b/hyperextract/templates/en/general/keyword_list.pyindex 71f712f..182e39b 100644--- a/hyperextract/templates/en/general/keyword_list.py+++ b/hyperextract/templates/en/general/keyword_list.py@@ -17,9 +17,13 @@ class Keyword(BaseModel):description: str = Field(description="Brief description or context explanation of the keyword", default="")-_PROMPT = """You are a professional keyword extraction expert. Please extract all keywords from the text with category and description information.+_PROMPT = """## Role and Task+You are a professional keyword extraction expert. Please extract all keywords from the text with category and description information.-### Extraction Rules+## Core Concept Definitions+- **Item**: In this template, "Item" refers to a single keyword entry, a semantic tag unit that includes fields such as keyword term, category, and description.++## Extraction Rules1. Extract all keywords and core phrases from the text2. Assign a category to each keyword: CoreConcept, Term, PersonName, OrganizationName, Other3. Add a brief description for each keyword, explaining its meaning or context in the textdiff --git a/hyperextract/templates/en/general/knowledge_graph.py b/hyperextract/templates/en/general/knowledge_graph.pyindex b4ea04d..8548058 100644--- a/hyperextract/templates/en/general/knowledge_graph.py+++ b/hyperextract/templates/en/general/knowledge_graph.py@@ -25,8 +25,14 @@ class GeneralRelation(BaseModel):details: str = Field(description="Detailed description", default="")-_PROMPT = """You are a professional knowledge graph extraction expert. Please extract all entities (nodes) and their relationships (edges) from the text.+_PROMPT = """## Role and Task+You are a professional knowledge graph extraction expert. Please extract all entities (nodes) and their relationships (edges) from the text.+## Core Concept Definitions+- **Node**: In this template, "Node" refers to a general entity, including types such as Person, Organization, Location, Product, Concept, etc., used to represent basic entities in a knowledge graph.+- **Edge**: In this template, "Edge" refers to a binary relationship between entities, including relationship types such as BelongsTo, LocatedIn, CollaboratesWith, CompetesWith, InventedBy, CreatedBy, and RelatedTo.++## Extraction Rules### Node Extraction Rules1. Extract all entities: Person, Organization, Location, Product, Concept, etc.2. Assign a type to each entity: Person, Organization, Location, Product, Concept, Other@@ -45,9 +51,13 @@ _PROMPT = """You are a professional knowledge graph extraction expert. Please ex### Source text:"""-_NODE_PROMPT = """You are a professional entity recognition expert. Please extract all key entities as nodes from the text.+_NODE_PROMPT = """## Role and Task+You are a professional entity recognition expert. Please extract all key entities as nodes from the text.++## Core Concept Definitions+- **Node**: In this template, "Node" refers to a general entity, including types such as Person, Organization, Location, Product, Concept, etc., used to represent basic entities in a knowledge graph.-### Extraction Rules+## Extraction Rules1. Extract all entities: Person, Organization, Location, Product, Concept, etc.2. Assign a type to each entity: Person, Organization, Location, Product, Concept, Other3. Keep entity names consistent with the original text@@ -56,8 +66,14 @@ _NODE_PROMPT = """You are a professional entity recognition expert. Please extra### Source text:"""-_EDGE_PROMPT = """You are a professional relationship extraction expert. Please extract relationships between entities from the given entity list.+_EDGE_PROMPT = """## Role and Task+You are a professional relationship extraction expert. Please extract relationships between entities from the given entity list.++## Core Concept Definitions+- **Node**: In this template, "Node" refers to a general entity, as participants in relationships.+- **Edge**: In this template, "Edge" refers to a binary relationship between entities, including relationship types such as BelongsTo, LocatedIn, CollaboratesWith, CompetesWith, InventedBy, CreatedBy, and RelatedTo.+## Extraction Rules### Constraints1. Only extract edges from the known entity list below2. Do not create unlisted entitiesdiff --git a/hyperextract/templates/en/general/life_event_timeline.py b/hyperextract/templates/en/general/life_event_timeline.pyindex 04729dc..f6b06e7 100644--- a/hyperextract/templates/en/general/life_event_timeline.py+++ b/hyperextract/templates/en/general/life_event_timeline.py@@ -26,8 +26,15 @@ class LifeEvent(BaseModel):details: str = Field(description="Detailed event description", default="")-_PROMPT = """You are a professional biography chronology expert. Please extract entities such as people, locations, organizations, etc., and life events from the text to build a life event timeline.+_PROMPT = """## Role and Task+You are a professional biography chronology expert. Please extract entities such as people, locations, organizations, etc., and life events from the text to build a life event timeline.+## Core Concept Definitions+- **Node**: In this template, "Node" refers to a life entity, including types such as Person, Location, Organization, Item, and Concept, used to represent entities in a life timeline.+- **Edge**: In this template, "Edge" refers to a life event, connecting multiple entities to record binary relationships of life experiences such as birth, education, work, and achievements.+- **Time**: In this template, "Time" refers to the temporal information of when events occur, used to arrange life events in chronological order, supporting relative time parsing.++## Extraction Rules### Node Extraction Rules1. Extract all related entities: Person, Location, Organization, Item, Concept, etc.2. Assign a type to each entity: Person, Location, Organization, Item, Concept, Other@@ -82,9 +89,13 @@ Current observation date: {observation_time}### Source text:"""-_NODE_PROMPT = """You are a professional entity recognition expert. Please extract all related entities as nodes from the text.+_NODE_PROMPT = """## Role and Task+You are a professional entity recognition expert. Please extract all related entities as nodes from the text.++## Core Concept Definitions+- **Node**: In this template, "Node" refers to a life entity, including types such as Person, Location, Organization, Item, and Concept, used to represent entities in a life timeline.-### Extraction Rules+## Extraction Rules1. Extract all related entities: Person, Location, Organization, Item, Concept, etc.2. Assign a type to each entity: Person, Location, Organization, Item, Concept, Other3. Add a brief description for each entity@@ -92,8 +103,15 @@ _NODE_PROMPT = """You are a professional entity recognition expert. Please extra### Source text:"""-_EDGE_PROMPT = """You are a professional life event extraction expert. Please extract life events from the given entity list.+_EDGE_PROMPT = """## Role and Task+You are a professional life event extraction expert. Please extract life events from the given entity list.++## Core Concept Definitions+- **Node**: In this template, "Node" refers to a life entity, as participants in life events.+- **Edge**: In this template, "Edge" refers to a life event, connecting multiple entities to record binary relationships of life experiences such as birth, education, work, and achievements.+- **Time**: In this template, "Time" refers to the temporal information of when events occur, used to arrange life events in chronological order, supporting relative time parsing.+## Extraction Rules### Event Type Explanation- Birth: Birth events- Death: Death eventsdiff --git a/hyperextract/templates/en/general/operational_procedure.py b/hyperextract/templates/en/general/operational_procedure.pyindex d88f004..a6082a8 100644--- a/hyperextract/templates/en/general/operational_procedure.py+++ b/hyperextract/templates/en/general/operational_procedure.py@@ -28,8 +28,14 @@ class ProcedureTransition(BaseModel):details: str = Field(description="Detailed explanation", default="")-_PROMPT = """You are a professional process analysis expert. Please extract the specific sequential steps for declaration, approval, or operations specified in regulations from the text to build an operational procedure flowchart.+_PROMPT = """## Role and Task+You are a professional process analysis expert. Please extract the specific sequential steps for declaration, approval, or operations specified in regulations from the text to build an operational procedure flowchart.+## Core Concept Definitions+- **Node**: In this template, "Node" refers to a process step unit, an operational unit that includes fields such as step ID, name, description, executor role, inputs, and outputs.+- **Edge**: In this template, "Edge" refers to a transition relationship between process steps, a binary relationship that records the sequential order and transition conditions between steps.++## Extraction Rules### Node Extraction Rules1. Extract all process steps2. Assign an ID to each step (e.g., Step 1, Step 2)@@ -51,9 +57,13 @@ _PROMPT = """You are a professional process analysis expert. Please extract the### Source text:"""-_NODE_PROMPT = """You are a professional process step recognition expert. Please extract all process steps as nodes from the text.+_NODE_PROMPT = """## Role and Task+You are a professional process step recognition expert. Please extract all process steps as nodes from the text.++## Core Concept Definitions+- **Node**: In this template, "Node" refers to a process step unit, an operational unit that includes fields such as step ID, name, description, executor role, inputs, and outputs.-### Extraction Rules+## Extraction Rules1. Extract all process steps2. Assign an ID to each step (e.g., Step 1, Step 2)3. Add a name and detailed description to each step@@ -64,8 +74,14 @@ _NODE_PROMPT = """You are a professional process step recognition expert. Please### Source text:"""-_EDGE_PROMPT = """You are a professional process transition recognition expert. Please extract the sequential relationship between steps from the given step list.+_EDGE_PROMPT = """## Role and Task+You are a professional process transition recognition expert. Please extract the sequential relationship between steps from the given step list.++## Core Concept Definitions+- **Node**: In this template, "Node" refers to a process step unit, as participants in process transitions.+- **Edge**: In this template, "Edge" refers to a transition relationship between process steps, a binary relationship that records the sequential order and transition conditions between steps.+## Extraction Rules### Constraints1. Only extract edges from the known step list below2. Do not create unlisted stepsdiff --git a/hyperextract/templates/en/general/penalty_mapping.py b/hyperextract/templates/en/general/penalty_mapping.pyindex a641b86..4f15194 100644--- a/hyperextract/templates/en/general/penalty_mapping.py+++ b/hyperextract/templates/en/general/penalty_mapping.py@@ -25,8 +25,14 @@ class PenaltyPath(BaseModel):details: str = Field(description="Detailed explanation", default="")-_PROMPT = """You are a professional penalty logic analysis expert. Please extract the evolution path from "violation behavior" to "handling procedure" to "final result" from the text to build a penalty mapping.+_PROMPT = """## Role and Task+You are a professional penalty logic analysis expert. Please extract the evolution path from "violation behavior" to "handling procedure" to "final result" from the text to build a penalty mapping.+## Core Concept Definitions+- **Node**: In this template, "Node" refers to a key unit in the penalty causal chain, including types such as Violation, HandlingProcedure, and PenaltyResult, used to represent key links in the penalty process.+- **Edge**: In this template, "Edge" refers to a causal relationship between nodes, including binary relationships such as Causes, Triggers, Executes, and Produces, used to represent the evolution path from violation to penalty.++## Extraction Rules### Node Extraction Rules1. Extract all key nodes: Violation, HandlingProcedure, PenaltyResult, etc.2. Assign a type to each node: Violation, HandlingProcedure, PenaltyResult, Other@@ -45,9 +51,13 @@ _PROMPT = """You are a professional penalty logic analysis expert. Please extrac### Source text:"""-_NODE_PROMPT = """You are a professional penalty node recognition expert. Please extract all key nodes from the text.+_NODE_PROMPT = """## Role and Task+You are a professional penalty node recognition expert. Please extract all key nodes from the text.++## Core Concept Definitions+- **Node**: In this template, "Node" refers to a key unit in the penalty causal chain, including types such as Violation, HandlingProcedure, and PenaltyResult, used to represent key links in the penalty process.-### Extraction Rules+## Extraction Rules1. Extract all key nodes: Violation, HandlingProcedure, PenaltyResult, etc.2. Assign a type to each node: Violation, HandlingProcedure, PenaltyResult, Other3. Add a detailed description to each node@@ -55,8 +65,14 @@ _NODE_PROMPT = """You are a professional penalty node recognition expert. Please### Source text:"""-_EDGE_PROMPT = """You are a professional penalty causal relationship recognition expert. Please extract the causal relationship between nodes from the given node list.+_EDGE_PROMPT = """## Role and Task+You are a professional penalty causal relationship recognition expert. Please extract the causal relationship between nodes from the given node list.++## Core Concept Definitions+- **Node**: In this template, "Node" refers to a key unit in the penalty causal chain, as participants in causal relationships.+- **Edge**: In this template, "Edge" refers to a causal relationship between nodes, including binary relationships such as Causes, Triggers, Executes, and Produces, used to represent the evolution path from violation to penalty.+## Extraction Rules### Constraints1. Only extract edges from the known node list below2. Do not create unlisted nodesdiff --git a/hyperextract/templates/en/general/penalty_registry.py b/hyperextract/templates/en/general/penalty_registry.pyindex 1fb73f4..f0771a7 100644--- a/hyperextract/templates/en/general/penalty_registry.py+++ b/hyperextract/templates/en/general/penalty_registry.py@@ -19,9 +19,13 @@ class PenaltyEntry(BaseModel):notes: str = Field(description="Notes", default="")-_PROMPT = """You are a professional compliance analysis expert. Please extract all violations and their corresponding penalty measures from the text to form a violation penalty registry.+_PROMPT = """## Role and Task+You are a professional compliance analysis expert. Please extract all violations and their corresponding penalty measures from the text to form a violation penalty registry.-### Extraction Rules+## Core Concept Definitions+- **Element**: In this template, "Element" refers to a single violation penalty entry, a unique knowledge unit that includes fields such as violation description, severity, penalty measure, applicable clause, and notes, and is deduplicated by the combination of violation and penalty measure.++## Extraction Rules1. Extract all violations and their corresponding penalty measures2. Assign a severity level to each violation: Minor, Moderate, Serious, VerySerious3. Maintain the accuracy of violations and penalty measuresdiff --git a/hyperextract/templates/en/general/personal_profile.py b/hyperextract/templates/en/general/personal_profile.pyindex 417bcd0..4f66765 100644--- a/hyperextract/templates/en/general/personal_profile.py+++ b/hyperextract/templates/en/general/personal_profile.py@@ -26,9 +26,13 @@ class PersonalInfo(BaseModel):summary: str = Field(description="Personal introduction", default="")-_PROMPT = """You are a professional personal profile editor. Please extract static attribute information of this person from the text to build a personal profile.+_PROMPT = """## Role and Task+You are a professional personal profile editor. Please extract static attribute information of this person from the text to build a personal profile.-### Extraction Rules+## Core Concept Definitions+- **Object**: In this template, "Object" refers to personal profile information, which is a structured person information unit containing multiple fields such as name, gender, birth/death dates, nationality, education background, occupations, core identity, major achievements, affiliations, summary, etc.++## Extraction Rules1. Extract basic information: name, gender, date of birth, date of death, nationality, place of birth, etc.2. Extract education background3. Extract occupation or identity informationdiff --git a/hyperextract/templates/en/general/regulation_profile.py b/hyperextract/templates/en/general/regulation_profile.pyindex 487d89c..978b4ff 100644--- a/hyperextract/templates/en/general/regulation_profile.py+++ b/hyperextract/templates/en/general/regulation_profile.py@@ -25,9 +25,13 @@ class RegulationInfo(BaseModel):relatedRegulations: List[str] = Field(description="Related regulations", default_factory=list)-_PROMPT = """You are a professional regulation analysis expert. Please extract metadata information of this regulation from the text to build a regulation profile.+_PROMPT = """## Role and Task+You are a professional regulation analysis expert. Please extract metadata information of this regulation from the text to build a regulation profile.-### Extraction Rules+## Core Concept Definitions+- **Object**: In this template, "Object" refers to regulation metadata information, structured institutional information that includes multiple fields: title, version, issuing authority, issue/effective/expiry dates, applicable scope, target audience, core purpose, keywords, and related regulations.++## Extraction Rules1. Extract the full name of the regulation2. Extract version number (if available)3. Extract issuing authoritydiff --git a/hyperextract/templates/en/general/social_network.py b/hyperextract/templates/en/general/social_network.pyindex 47eeed2..8a1e308 100644--- a/hyperextract/templates/en/general/social_network.py+++ b/hyperextract/templates/en/general/social_network.py@@ -26,8 +26,14 @@ class SocialRelation(BaseModel):details: str = Field(description="Detailed relationship explanation", default="")-_PROMPT = """You are a professional social relationship analysis expert. Please extract people, organizations, and their mutual relationships from the text to build a social network graph.+_PROMPT = """## Role and Task+You are a professional social relationship analysis expert. Please extract people, organizations, and their mutual relationships from the text to build a social network graph.+## Core Concept Definitions+- **Node**: In this template, "Node" refers to a person or organization unit, including types such as Person, Organization, Institution, etc., used to represent entities in a social network.+- **Edge**: In this template, "Edge" refers to a social relationship between people/organizations, including binary relationships such as Family, Friend, Colleague, TeacherStudent, SupervisorSubordinate, Collaboration, Competition, and Affiliation.++## Extraction Rules### Node Extraction Rules1. Extract all people, organizations, institutions, etc.2. Assign a type to each node: Person, Organization, Institution, Other@@ -55,9 +61,13 @@ _PROMPT = """You are a professional social relationship analysis expert. Please### Source text:"""-_NODE_PROMPT = """You are a professional person and organization recognition expert. Please extract all people and organizations as nodes from the text.+_NODE_PROMPT = """## Role and Task+You are a professional person and organization recognition expert. Please extract all people and organizations as nodes from the text.++## Core Concept Definitions+- **Node**: In this template, "Node" refers to a person or organization unit, including types such as Person, Organization, Institution, etc., used to represent entities in a social network.-### Extraction Rules+## Extraction Rules1. Extract all people, organizations, institutions, etc.2. Assign a type to each node: Person, Organization, Institution, Other3. Add a brief description for each node@@ -66,8 +76,14 @@ _NODE_PROMPT = """You are a professional person and organization recognition exp### Source text:"""-_EDGE_PROMPT = """You are a professional social relationship extraction expert. Please extract mutual relationships between nodes from the given node list.+_EDGE_PROMPT = """## Role and Task+You are a professional social relationship extraction expert. Please extract mutual relationships between nodes from the given node list.++## Core Concept Definitions+- **Node**: In this template, "Node" refers to a person or organization unit, as participants in social relationships.+- **Edge**: In this template, "Edge" refers to a social relationship between people/organizations, including binary relationships such as Family, Friend, Colleague, TeacherStudent, SupervisorSubordinate, Collaboration, Competition, and Affiliation.+## Extraction Rules### Relationship Type Explanation- Family: Family relationships (parents, children, spouse, siblings, etc.)- Friend: Friend relationshipsdiff --git a/hyperextract/templates/zh/INSTRUCTION.md b/hyperextract/templates/zh/INSTRUCTION.mdindex dc0831c..da802e5 100644--- a/hyperextract/templates/zh/INSTRUCTION.md+++ b/hyperextract/templates/zh/INSTRUCTION.md@@ -177,6 +177,71 @@ class FinancialRelation(BaseModel):| `_NODE_PROMPT` | two_stage 第一步:仅提取节点 || `_EDGE_PROMPT` | two_stage 第二步:基于已知节点提取边 |+### 4.3 Prompt 前置结构规范(强制要求)++**所有 Prompt 必须遵循以下前置结构,缺一不可**:++```+## 角色与任务+你是一位专业的 xxx 专家,请从文本中提取 xxx...++## 核心概念定义(根据 AutoType 不同而变化)+- **概念1**:xxx+- **概念2**:xxx++## 提取规则+...+```++**为什么需要概念定义?**+- 让大模型先理解要提取的"是什么",再告诉它"怎么提取"+- 不同的 AutoType 有不同的核心概念,必须明确定义+- 概念定义必须放在 Prompt 的开头部分++### 4.4 各 AutoType 的核心概念定义模板++#### AutoModel+```+## 核心概念定义+- **对象 (Object)**:从文本中提取的单一结构化对象,包含多个字段+```++#### AutoList+```+## 核心概念定义+- **条目 (Item)**:从文本中提取的重复模式实例+```++#### AutoSet+```+## 核心概念定义+- **元素 (Element)**:具有唯一键的知识单元,用于累积信息+```++#### AutoGraph+```+## 核心概念定义+- **节点 (Node)**:图谱中的实体+- **边 (Edge)**:节点之间的二元关系+```++#### AutoHypergraph+```+## 核心概念定义+- **节点 (Node)**:构成超边(边)的基本要素,作为超边的参与者+- **边 (Edge)**:连接多个节点,表达多个实体间的复杂关联关系+```++#### AutoTemporalGraph / AutoSpatialGraph / AutoSpatioTemporalGraph+除了节点和边的定义,还需要添加时间/位置的定义:+```+## 核心概念定义+- **节点 (Node)**:图谱中的实体+- **边 (Edge)**:节点之间的二元关系+- **时间**:xxx(根据实际需求定义)+- **位置**:xxx(根据实际需求定义)+```+---## 5. 参数管理规范@@ -270,10 +335,14 @@ class FinancialRelation(BaseModel):# 2. 预定义 Prompt(全中文)# ==============================================================================-_NODE_PROMPT = """-你是一位专业的财报分析专家。请从文本中提取所有关键实体作为节点。+_NODE_PROMPT = """## 角色与任务+你是一位专业的财报分析专家,请从文本中提取所有关键实体作为节点。-### 提取规则+## 核心概念定义+- **节点 (Node)**:图谱中的实体+- **边 (Edge)**:节点之间的二元关系++## 提取规则1. 提取所有公司、产品、部门等实体2. 为每个实体指定类型:公司、产品、部门3. 保持实体名称与原文一致@@ -282,9 +351,15 @@ _NODE_PROMPT = """### 源文本:"""-_EDGE_PROMPT = """-你是一位专业的财报分析专家。请从给定实体列表中提取实体之间的关系。+_EDGE_PROMPT = """## 角色与任务+你是一位专业的财报分析专家,请从给定实体列表中提取实体之间的关系。++## 核心概念定义+- **节点 (Node)**:图谱中的实体+- **边 (Edge)**:节点之间的二元关系+- **时间**:记录关系发生的时间信息+## 提取规则### 时间格式要求所有时间信息必须统一转换为「年-月-日」格式(如 2023-06-15)。@@ -302,12 +377,19 @@ _EDGE_PROMPT = """### 约束条件1. 仅从下方已知实体列表中提取边2. 不要创建未列出的实体+3. 每条边必须包含 source、target、relationType"""-_PROMPT = """-你是一位专业的财报分析专家。请从文本中提取实体和它们之间的关系。+_PROMPT = """## 角色与任务+你是一位专业的财报分析专家,请从文本中提取实体和它们之间的关系。++## 核心概念定义+- **节点 (Node)**:图谱中的实体+- **边 (Edge)**:节点之间的二元关系+- **时间**:记录关系发生的时间信息+## 提取规则### 节点提取规则1. 提取所有公司、产品、部门等实体2. **禁止将时间或地点作为独立节点提取**diff --git a/hyperextract/templates/zh/general/clause_list.py b/hyperextract/templates/zh/general/clause_list.pyindex 1be84b7..2ec8590 100644--- a/hyperextract/templates/zh/general/clause_list.py+++ b/hyperextract/templates/zh/general/clause_list.py@@ -18,9 +18,13 @@ class Clause(BaseModel):category: str = Field(description="条文分类:总则、权利义务、程序、处罚、附则、其他", default="其他")-_PROMPT = """你是一位专业的规章制度条文拆解专家。请将文本拆解为逐条的原子化条文。+_PROMPT = """## 角色与任务+你是一位专业的规章制度条文拆解专家,请将文本拆解为逐条的原子化条文。-### 提取规则+## 核心概念定义+- **条目 (Item)**:本模板中的"条目"指单条规章制度条文,包含条文编号、标题、内容、分类等字段的原子化规则单元。++## 提取规则1. 将规章制度按其自然结构拆解为独立的条文2. 为每条条文分配编号(如第1条、第2.1款等)3. 提取条文的内容diff --git a/hyperextract/templates/zh/general/compliance_logic.py b/hyperextract/templates/zh/general/compliance_logic.pyindex 571ae9f..3349218 100644--- a/hyperextract/templates/zh/general/compliance_logic.py+++ b/hyperextract/templates/zh/general/compliance_logic.py@@ -12,65 +12,94 @@ from hyperextract.types import AutoHypergraphclass ComplianceElement(BaseModel):"""合规要素 - 节点"""- name: str = Field(description="要素名称")- type: str = Field(description="要素类型:主体、操作、条件、其他")+ name: str = Field(description="要素名称,文本中出现的精确名称")+ category: str = Field(description="要素类型:主体、操作、条件、其他")description: str = Field(description="简要描述", default="")class ComplianceRule(BaseModel):"""合规规则 - 超边"""- rule_type: str = Field(description="规则类型:必须、禁止、允许、其他")+ ruleType: str = Field(description="规则类型:必须、禁止、允许、其他")+ participants: List[str] = Field(description="参与要素名称列表,必须使用已提取节点的 name")action: str = Field(description="要求执行或禁止的操作内容")condition: str = Field(description="适用条件/前置要求", default="")- penalty: str = Field(description="违规后果/处罚措施", default="")- source_clause: str = Field(description="规则来源条款", default="")- notes: str = Field(description="补充说明", default="")- participants: List[str] = Field(description="参与要素名称列表")+ consequence: str = Field(description="违规后果/奖励措施", default="")+ sourceClause: str = Field(description="规则来源条款", default="")-_PROMPT = """你是一位专业的合规分析专家。请从文本中提取合规要素和规则,建模"在何种条件下,何种主体,必须/禁止执行何种操作"的复杂逻辑,构建合规行为超图。+_PROMPT = """+你是一位专业的合规评估员,擅长从文档中提取合规要素并分析规则逻辑。-### 节点提取规则+## 任务+请从文本中提取合规要素和规则,构建合规行为超图。++## 概念定义+- **节点(Node)**:构成规则的基本要素,分为四类:+ - **主体**:执行动作的实体(个人、部门、组织、角色等)+ - **操作**:具体的动作或行为(提交、审批、执行、禁止等)+ - **条件**:规则适用的前提或场景(时间、地点、状态、数量等)+ - **其他**:不属于上述三类的要素(凭证、文件、状态、结果等)+- **超边(Hyperedge/Edge)**:即"规则",连接多个节点,表达"在何种条件下,何种主体,必须/禁止执行何种操作"的逻辑。++## 提取规则++### 节点提取1. 提取规则中涉及的要素作为节点2. 为每个要素指定类型:主体、操作、条件、其他3. 为每个要素添加简要描述-### 超边提取规则-1. 仅从提取的要素中创建合规规则(超边)-2. 指定规则类型:必须、禁止、允许、其他-3. 填写要求执行或禁止的操作内容(必须)-4. 提取适用条件/前置要求(如有)-5. 提取违规后果/处罚措施(如有)-6. 提取规则来源条款(如有)-7. 添加补充说明(如有)-8. 列出所有参与要素名称(必须)--### 约束条件-- 确保规则逻辑准确-- 保持客观准确,不添加文本中没有的信息-- 每条超边必须包含 rule_type、action 和 participants-- 其他字段尽量填充,缺失的使用空字符串+### 超边提取+1. 仅从已提取节点创建规则+2. 规则类型:必须、禁止、允许、其他+3. 必须包含 ruleType、participants、action+4. participants 严格使用已提取节点的 name+5. 其他字段尽量填充,缺失用空字符串### 源文本:"""-_NODE_PROMPT = """你是一位专业的合规要素识别专家。请从文本中提取所有合规相关要素作为节点。+_NODE_PROMPT = """+你是一位专业的合规要素识别专家,擅长从文档中精准识别合规相关的核心要素。-### 提取规则-1. 提取规则中涉及的要素-2. 为每个要素指定类型:主体、操作、条件、其他-3. 为每个要素添加简要描述+## 任务+请从文本中提取所有合规相关要素作为节点。++## 概念定义+- **节点(Node)**:构成规则的基本要素,分为四类:+ - **主体**:执行动作的实体(个人、部门、组织、角色等)+ - **操作**:具体的动作或行为(提交、审批、执行、禁止等)+ - **条件**:规则适用的前提或场景(时间、地点、状态、数量等)+ - **其他**:不属于上述三类的要素(凭证、文件、状态、结果等)++## 提取规则+1. 提取具体、原子化的要素,不要抽象的"流程"或"对照表"+2. 要素名称直接使用文本中出现的名词或动词+3. 为每个要素指定正确的类型+4. 为每个要素添加简要描述(1-2句话)### 源文本:"""-_EDGE_PROMPT = """你是一位专业的合规规则提取专家。请从给定节点(要素)列表中提取合规规则超边。+_EDGE_PROMPT = """+你是一位专业的合规规则分析师,擅长从给定要素中构建清晰的合规规则关系。++## 任务+请从给定节点列表中提取合规规则超边。++## 概念定义+- **节点(Node)**:构成规则的基本要素,作为超边(Hyperedge/Edge)的参与者+- **超边(Hyperedge/Edge)**:即"规则",连接多个节点,表达"在何种条件下,何种主体,必须/禁止执行何种操作"的逻辑。++## 提取规则+1. **participants 必须严格使用下方中的名称,不要创建任何新的要素名称**+2. 规则必须包含 ruleType、participants、action+3. participants 应包含:涉及的主体、执行的操作、相关的其他要素-### 约束条件-1. 仅从下方已知要素列表中提取规则(超边)-2. 不要创建未列出的要素-3. 每条规则必须包含 rule_type、action 和 participants-4. 其他字段尽量填充,缺失的使用空字符串+### 规则类型+- **必须**:强制要求执行的行为+- **禁止**:不允许执行的行为+- **允许**:可以执行的行为+- **其他**:不属于上述三类的规则"""@@ -84,7 +113,7 @@ class ComplianceLogic(AutoHypergraph[ComplianceElement, ComplianceRule]):Example:>>> template = ComplianceLogic(llm_client=llm, embedder=embedder)- >>> template.feed_text("宇宙第一摸鱼公司合规手册...")+ >>> template.feed_text("公司合规手册...")>>> template.show()"""@@ -114,7 +143,7 @@ class ComplianceLogic(AutoHypergraph[ComplianceElement, ComplianceRule]):node_schema=ComplianceElement,edge_schema=ComplianceRule,node_key_extractor=lambda x: x.name,- edge_key_extractor=lambda x: f"{sorted(x.participants)}_{x.rule_type}_{x.action}",+ edge_key_extractor=lambda x: f"{sorted(x.participants)}_{x.ruleType}_{x.action}",nodes_in_edge_extractor=lambda x: tuple(x.participants),llm_client=llm_client,embedder=embedder,@@ -141,10 +170,10 @@ class ComplianceLogic(AutoHypergraph[ComplianceElement, ComplianceRule]):top_k_for_chat: 问答使用的节点/边数量,默认为 3"""def node_label_extractor(node: ComplianceElement) -> str:- return f"{node.name} ({node.type})"+ return f"{node.name} ({node.category})"def edge_label_extractor(edge: ComplianceRule) -> str:- return f"[{edge.rule_type}] {edge.action}"+ return f"[{edge.ruleType}] {edge.action}"super().show(node_label_extractor=node_label_extractor,diff --git a/hyperextract/templates/zh/general/concept_hierarchy.py b/hyperextract/templates/zh/general/concept_hierarchy.pyindex a1c9aec..fc50605 100644--- a/hyperextract/templates/zh/general/concept_hierarchy.py+++ b/hyperextract/templates/zh/general/concept_hierarchy.py@@ -25,8 +25,14 @@ class HierarchyRelation(BaseModel):details: str = Field(description="关系详细说明", default="")-_PROMPT = """你是一位专业的概念结构分析专家。请从文本中提取概念及其层级关系,构建概念层级图。+_PROMPT = """## 角色与任务+你是一位专业的概念结构分析专家,请从文本中提取概念及其层级关系,构建概念层级图。+## 核心概念定义+- **节点 (Node)**:本模板中的"节点"指概念单元,分为核心概念、子概念、属性、实例等类型,用于表示知识体系中的基本概念。+- **边 (Edge)**:本模板中的"边"指概念之间的层级关系,包括 Subclass-Of(上下位)、Part-Of(组成)、Instance-Of(实例)等二元关系。++## 提取规则### 节点提取规则1. 提取所有概念:核心概念、子概念、属性、实例等2. 为每个概念指定类型:核心概念、子概念、属性、实例、其他@@ -49,9 +55,13 @@ _PROMPT = """你是一位专业的概念结构分析专家。请从文本中提### 源文本:"""-_NODE_PROMPT = """你是一位专业的概念识别专家。请从文本中提取所有概念作为节点。+_NODE_PROMPT = """## 角色与任务+你是一位专业的概念识别专家,请从文本中提取所有概念作为节点。++## 核心概念定义+- **节点 (Node)**:本模板中的"节点"指概念单元,分为核心概念、子概念、属性、实例等类型,用于表示知识体系中的基本概念。-### 提取规则+## 提取规则1. 提取所有概念:核心概念、子概念、属性、实例等2. 为每个概念指定类型:核心概念、子概念、属性、实例、其他3. 为每个概念添加简要描述@@ -59,8 +69,14 @@ _NODE_PROMPT = """你是一位专业的概念识别专家。请从文本中提### 源文本:"""-_EDGE_PROMPT = """你是一位专业的层级关系提取专家。请从给定概念列表中提取概念(节点)之间的层级关系。+_EDGE_PROMPT = """## 角色与任务+你是一位专业的层级关系提取专家,请从给定概念列表中提取概念(节点)之间的层级关系。++## 核心概念定义+- **节点 (Node)**:本模板中的"节点"指概念单元,作为层级关系的参与者。+- **边 (Edge)**:本模板中的"边"指概念之间的层级关系,包括 Subclass-Of(上下位)、Part-Of(组成)、Instance-Of(实例)等二元关系。+## 提取规则### 关系类型说明- Subclass-Of:上下位关系(子类与父类)- Part-Of:组成关系(部分与整体)diff --git a/hyperextract/templates/zh/general/cross_reference_net.py b/hyperextract/templates/zh/general/cross_reference_net.pyindex e449688..960e0aa 100644--- a/hyperextract/templates/zh/general/cross_reference_net.py+++ b/hyperextract/templates/zh/general/cross_reference_net.py@@ -25,8 +25,14 @@ class ReferenceRelation(BaseModel):context: str = Field(description="引用上下文描述", default="")-_PROMPT = """你是一位专业的知识网络分析专家。请从文本中提取概念/条目及其相互引用关系,构建交叉引用网络。+_PROMPT = """## 角色与任务+你是一位专业的知识网络分析专家,请从文本中提取概念/条目及其相互引用关系,构建交叉引用网络。+## 核心概念定义+- **节点 (Node)**:本模板中的"节点"指概念或条目单元,包括条目、章节、概念、人物、地点等类型,用于表示知识网络中的实体。+- **边 (Edge)**:本模板中的"边"指概念/条目之间的引用关系,包括 Hyperlink(超链接)、Reference(引用)、SeeAlso(参见)、Related(相关)等二元关系。++## 提取规则### 节点提取规则1. 提取所有被提及的概念或条目2. 为每个节点指定类型:条目、章节、概念、人物、地点、其他@@ -50,9 +56,13 @@ _PROMPT = """你是一位专业的知识网络分析专家。请从文本中提### 源文本:"""-_NODE_PROMPT = """你是一位专业的条目识别专家。请从文本中提取所有概念或条目作为节点。+_NODE_PROMPT = """## 角色与任务+你是一位专业的条目识别专家,请从文本中提取所有概念或条目作为节点。++## 核心概念定义+- **节点 (Node)**:本模板中的"节点"指概念或条目单元,包括条目、章节、概念、人物、地点等类型,用于表示知识网络中的实体。-### 提取规则+## 提取规则1. 提取所有被提及的概念或条目2. 为每个节点指定类型:条目、章节、概念、人物、地点、其他3. 为每个节点添加简要描述@@ -60,8 +70,14 @@ _NODE_PROMPT = """你是一位专业的条目识别专家。请从文本中提### 源文本:"""-_EDGE_PROMPT = """你是一位专业的引用关系提取专家。请从给定节点列表中提取节点之间的相互引用关系。+_EDGE_PROMPT = """## 角色与任务+你是一位专业的引用关系提取专家,请从给定节点列表中提取节点之间的相互引用关系。++## 核心概念定义+- **节点 (Node)**:本模板中的"节点"指概念或条目单元,作为引用关系的参与者。+- **边 (Edge)**:本模板中的"边"指概念/条目之间的引用关系,包括 Hyperlink(超链接)、Reference(引用)、SeeAlso(参见)、Related(相关)等二元关系。+## 提取规则### 关系类型说明- Hyperlink:超链接关系- Reference:引用关系diff --git a/hyperextract/templates/zh/general/encyclopedia_item.py b/hyperextract/templates/zh/general/encyclopedia_item.pyindex 0b4495a..195e39f 100644--- a/hyperextract/templates/zh/general/encyclopedia_item.py+++ b/hyperextract/templates/zh/general/encyclopedia_item.py@@ -22,9 +22,13 @@ class EncyclopediaInfo(BaseModel):relatedConcepts: List[str] = Field(description="相关概念/条目", default_factory=list)-_PROMPT = """你是一位专业的百科全书编辑。请从文本中提取单一主体的结构化属性信息,构建百科条目信息框。+_PROMPT = """## 角色与任务+你是一位专业的百科全书编辑,请从文本中提取单一主体的结构化属性信息,构建百科条目信息框。-### 提取规则+## 核心概念定义+- **对象 (Object)**:本模板中的"对象"指单一百科条目主体,包含标题、实体类型、别名、分类、摘要、属性、重要事件等多个字段的结构化信息。++## 提取规则1. 识别文本的核心主体(人物、地点、组织、事件、概念等)2. 为主体指定类型:人物、地点、组织、事件、概念、物品、其他3. 提取所有别名、俗称或外文名称diff --git a/hyperextract/templates/zh/general/entity_registry.py b/hyperextract/templates/zh/general/entity_registry.pyindex 2eb2846..6cb013a 100644--- a/hyperextract/templates/zh/general/entity_registry.py+++ b/hyperextract/templates/zh/general/entity_registry.py@@ -17,9 +17,13 @@ class RegistryEntry(BaseModel):description: str = Field(description="简要描述", default="")-_PROMPT = """你是一位专业的实体识别专家。请从文本中提取所有唯一实体,形成实体注册表。+_PROMPT = """## 角色与任务+你是一位专业的实体识别专家,请从文本中提取所有唯一实体,形成实体注册表。-### 提取规则+## 核心概念定义+- **元素 (Element)**:本模板中的"元素"指单个实体注册表条目,包含实体名称、类型、描述等字段,通过名称进行去重的唯一知识单元。++## 提取规则1. 提取所有实体:人物、机构、地点、产品、概念等2. 为每个实体指定类型:人物、机构、地点、产品、概念、其他3. 保持实体名称与原文一致diff --git a/hyperextract/templates/zh/general/keyword_list.py b/hyperextract/templates/zh/general/keyword_list.pyindex 43be42d..fe48333 100644--- a/hyperextract/templates/zh/general/keyword_list.py+++ b/hyperextract/templates/zh/general/keyword_list.py@@ -17,9 +17,13 @@ class Keyword(BaseModel):description: str = Field(description="关键词简要描述或上下文说明", default="")-_PROMPT = """你是一位专业的关键词提取专家。请从文本中提取所有关键词并附带分类和描述信息。+_PROMPT = """## 角色与任务+你是一位专业的关键词提取专家,请从文本中提取所有关键词并附带分类和描述信息。-### 提取规则+## 核心概念定义+- **条目 (Item)**:本模板中的"条目"指单个关键词项,包含关键词、分类、描述等字段的语义标签单元。++## 提取规则1. 提取文本中的所有关键词和核心短语2. 为每个关键词指定分类:核心概念、术语、人名、机构名、其他3. 为每个关键词添加简要描述,说明其在文本中的含义或上下文diff --git a/hyperextract/templates/zh/general/knowledge_graph.py b/hyperextract/templates/zh/general/knowledge_graph.pyindex 5b9b617..cc37be9 100644--- a/hyperextract/templates/zh/general/knowledge_graph.py+++ b/hyperextract/templates/zh/general/knowledge_graph.py@@ -3,7 +3,7 @@适用于任意文本、网页抓取内容等非结构化文档,提取通用实体及其关系。"""-from typing import Any, Optional, Tuple+from typing import Anyfrom pydantic import BaseModel, Fieldfrom langchain_core.language_models import BaseChatModelfrom langchain_core.embeddings import Embeddings@@ -25,8 +25,14 @@ class GeneralRelation(BaseModel):details: str = Field(description="详细描述", default="")-_PROMPT = """你是一位专业的知识图谱提取专家。请从文本中提取所有实体(节点)和它们之间的关系(边)。+_PROMPT = """## 角色与任务+你是一位专业的知识图谱提取专家,请从文本中提取所有实体(节点)和它们之间的关系(边)。+## 核心概念定义+- **节点 (Node)**:本模板中的"节点"指通用实体,包括人物、机构、地点、产品、概念等类型,用于表示知识图谱中的基本实体。+- **边 (Edge)**:本模板中的"边"指实体之间的二元关系,包括属于、位于、合作、竞争、发明、创建、相关等关系类型。++## 提取规则### 节点提取规则1. 提取所有实体:人物、机构、地点、产品、概念等2. 为每个实体指定类型:人物、机构、地点、产品、概念、其他@@ -45,9 +51,13 @@ _PROMPT = """你是一位专业的知识图谱提取专家。请从文本中提### 源文本:"""-_NODE_PROMPT = """你是一位专业的实体识别专家。请从文本中提取所有关键实体作为节点。+_NODE_PROMPT = """## 角色与任务+你是一位专业的实体识别专家,请从文本中提取所有关键实体作为节点。++## 核心概念定义+- **节点 (Node)**:本模板中的"节点"指通用实体,包括人物、机构、地点、产品、概念等类型,用于表示知识图谱中的基本实体。-### 提取规则+## 提取规则1. 提取所有实体:人物、机构、地点、产品、概念等2. 为每个实体指定类型:人物、机构、地点、产品、概念、其他3. 保持实体名称与原文一致@@ -56,8 +66,14 @@ _NODE_PROMPT = """你是一位专业的实体识别专家。请从文本中提### 源文本:"""-_EDGE_PROMPT = """你是一位专业的关系提取专家。请从给定实体列表中提取实体之间的关系。+_EDGE_PROMPT = """## 角色与任务+你是一位专业的关系提取专家,请从给定实体列表中提取实体之间的关系。++## 核心概念定义+- **节点 (Node)**:本模板中的"节点"指通用实体,作为关系的参与者。+- **边 (Edge)**:本模板中的"边"指实体之间的二元关系,包括属于、位于、合作、竞争、发明、创建、相关等关系类型。+## 提取规则### 约束条件1. 仅从下方已知实体列表中提取边2. 不要创建未列出的实体diff --git a/hyperextract/templates/zh/general/life_event_timeline.py b/hyperextract/templates/zh/general/life_event_timeline.pyindex baf740d..7011eb5 100644--- a/hyperextract/templates/zh/general/life_event_timeline.py+++ b/hyperextract/templates/zh/general/life_event_timeline.py@@ -26,8 +26,15 @@ class LifeEvent(BaseModel):details: str = Field(description="事件详细描述", default="")-_PROMPT = """你是一位专业的传记年表专家。请从文本中提取人物、地点、组织等实体以及生活事件,构建生平时序图。+_PROMPT = """## 角色与任务+你是一位专业的传记年表专家,请从文本中提取人物、地点、组织等实体以及生活事件,构建生平时序图。+## 核心概念定义+- **节点 (Node)**:本模板中的"节点"指生活实体,包括人物、地点、组织、物品、概念等类型,用于表示生平时序中的实体。+- **边 (Edge)**:本模板中的"边"指生活事件,连接多个实体,记录出生、教育、工作、成就等人生经历的二元关系。+- **时间**:本模板中的"时间"指事件发生的时间信息,用于按时间顺序排列生活事件,支持相对时间解析。++## 提取规则### 节点提取规则1. 提取所有相关实体:人物、地点、组织、物品、概念等2. 为每个实体指定类型:人物、地点、组织、物品、概念、其他@@ -84,9 +91,13 @@ _PROMPT = """你是一位专业的传记年表专家。请从文本中提取人### 源文本:"""-_NODE_PROMPT = """你是一位专业的实体识别专家。请从文本中提取所有相关实体作为节点。+_NODE_PROMPT = """## 角色与任务+你是一位专业的实体识别专家,请从文本中提取所有相关实体作为节点。++## 核心概念定义+- **节点 (Node)**:本模板中的"节点"指生活实体,包括人物、地点、组织、物品、概念等类型,用于表示生平时序中的实体。-### 提取规则+## 提取规则1. 提取所有相关实体:人物、地点、组织、物品、概念等2. 为每个实体指定类型:人物、地点、组织、物品、概念、其他3. 为每个实体添加简要描述@@ -94,8 +105,15 @@ _NODE_PROMPT = """你是一位专业的实体识别专家。请从文本中提### 源文本:"""-_EDGE_PROMPT = """你是一位专业的生活事件提取专家。请从给定实体列表中提取生活事件。+_EDGE_PROMPT = """## 角色与任务+你是一位专业的生活事件提取专家,请从给定实体列表中提取生活事件。++## 核心概念定义+- **节点 (Node)**:本模板中的"节点"指生活实体,作为生活事件的参与者。+- **边 (Edge)**:本模板中的"边"指生活事件,连接多个实体,记录出生、教育、工作、成就等人生经历的二元关系。+- **时间**:本模板中的"时间"指事件发生的时间信息,用于按时间顺序排列生活事件,支持相对时间解析。+## 提取规则### 事件类型说明- 出生:出生事件- 逝世:逝世事件diff --git a/hyperextract/templates/zh/general/operational_procedure.py b/hyperextract/templates/zh/general/operational_procedure.pyindex 2571bff..8c60aff 100644--- a/hyperextract/templates/zh/general/operational_procedure.py+++ b/hyperextract/templates/zh/general/operational_procedure.py@@ -28,8 +28,14 @@ class ProcedureTransition(BaseModel):details: str = Field(description="详细说明", default="")-_PROMPT = """你是一位专业的流程分析专家。请从文本中提取规章中规定的申报、审批或操作的具体先后步骤,构建执行程序流程图。+_PROMPT = """## 角色与任务+你是一位专业的流程分析专家,请从文本中提取规章中规定的申报、审批或操作的具体先后步骤,构建执行程序流程图。+## 核心概念定义+- **节点 (Node)**:本模板中的"节点"指流程步骤单元,包含步骤编号、名称、描述、执行角色、输入、输出等字段的操作单元。+- **边 (Edge)**:本模板中的"边"指流程步骤之间的转换关系,记录步骤之间的先后顺序、转换条件等二元关系。++## 提取规则### 节点提取规则1. 提取所有流程步骤2. 为每个步骤分配编号(如步骤1、步骤2)@@ -51,9 +57,13 @@ _PROMPT = """你是一位专业的流程分析专家。请从文本中提取规### 源文本:"""-_NODE_PROMPT = """你是一位专业的流程步骤识别专家。请从文本中提取所有流程步骤作为节点。+_NODE_PROMPT = """## 角色与任务+你是一位专业的流程步骤识别专家,请从文本中提取所有流程步骤作为节点。++## 核心概念定义+- **节点 (Node)**:本模板中的"节点"指流程步骤单元,包含步骤编号、名称、描述、执行角色、输入、输出等字段的操作单元。-### 提取规则+## 提取规则1. 提取所有流程步骤2. 为每个步骤分配编号(如步骤1、步骤2)3. 为每个步骤添加名称和详细描述@@ -64,8 +74,14 @@ _NODE_PROMPT = """你是一位专业的流程步骤识别专家。请从文本### 源文本:"""-_EDGE_PROMPT = """你是一位专业的流程转换识别专家。请从给定步骤列表中提取步骤之间的先后关系。+_EDGE_PROMPT = """## 角色与任务+你是一位专业的流程转换识别专家,请从给定步骤列表中提取步骤之间的先后关系。++## 核心概念定义+- **节点 (Node)**:本模板中的"节点"指流程步骤单元,作为流程转换的参与者。+- **边 (Edge)**:本模板中的"边"指流程步骤之间的转换关系,记录步骤之间的先后顺序、转换条件等二元关系。+## 提取规则### 约束条件1. 仅从下方已知步骤列表中提取边2. 不要创建未列出的步骤diff --git a/hyperextract/templates/zh/general/penalty_mapping.py b/hyperextract/templates/zh/general/penalty_mapping.pyindex ded94f7..deade40 100644--- a/hyperextract/templates/zh/general/penalty_mapping.py+++ b/hyperextract/templates/zh/general/penalty_mapping.py@@ -25,8 +25,14 @@ class PenaltyPath(BaseModel):details: str = Field(description="详细说明", default="")-_PROMPT = """你是一位专业的处罚逻辑分析专家。请从文本中提取从“违规行为”到“处理程序”再到“最终结果”的演变路径,构建违规处罚因果链。+_PROMPT = """## 角色与任务+你是一位专业的处罚逻辑分析专家,请从文本中提取从“违规行为”到“处理程序”再到“最终结果”的演变路径,构建违规处罚因果链。+## 核心概念定义+- **节点 (Node)**:本模板中的"节点"指处罚因果链中的关键单元,包括违规行为、处理程序、处罚结果等类型,用于表示处罚流程中的关键环节。+- **边 (Edge)**:本模板中的"边"指节点之间的因果关系,包括导致、触发、执行、产生等二元关系,用于表示从违规到处罚的演变路径。++## 提取规则### 节点提取规则1. 提取所有关键节点:违规行为、处理程序、处罚结果等2. 为每个节点指定类型:违规行为、处理程序、处罚结果、其他@@ -45,9 +51,13 @@ _PROMPT = """你是一位专业的处罚逻辑分析专家。请从文本中提### 源文本:"""-_NODE_PROMPT = """你是一位专业的处罚节点识别专家。请从文本中提取所有关键节点。+_NODE_PROMPT = """## 角色与任务+你是一位专业的处罚节点识别专家,请从文本中提取所有关键节点。++## 核心概念定义+- **节点 (Node)**:本模板中的"节点"指处罚因果链中的关键单元,包括违规行为、处理程序、处罚结果等类型,用于表示处罚流程中的关键环节。-### 提取规则+## 提取规则1. 提取所有关键节点:违规行为、处理程序、处罚结果等2. 为每个节点指定类型:违规行为、处理程序、处罚结果、其他3. 为每个节点添加详细描述@@ -55,8 +65,14 @@ _NODE_PROMPT = """你是一位专业的处罚节点识别专家。请从文本### 源文本:"""-_EDGE_PROMPT = """你是一位专业的处罚因果关系识别专家。请从给定节点列表中提取节点之间的因果关系。+_EDGE_PROMPT = """## 角色与任务+你是一位专业的处罚因果关系识别专家,请从给定节点列表中提取节点之间的因果关系。++## 核心概念定义+- **节点 (Node)**:本模板中的"节点"指处罚因果链中的关键单元,作为因果关系的参与者。+- **边 (Edge)**:本模板中的"边"指节点之间的因果关系,包括导致、触发、执行、产生等二元关系,用于表示从违规到处罚的演变路径。+## 提取规则### 约束条件1. 仅从下方已知节点列表中提取边2. 不要创建未列出的节点diff --git a/hyperextract/templates/zh/general/penalty_registry.py b/hyperextract/templates/zh/general/penalty_registry.pyindex d6c88bf..197edf7 100644--- a/hyperextract/templates/zh/general/penalty_registry.py+++ b/hyperextract/templates/zh/general/penalty_registry.py@@ -19,9 +19,13 @@ class PenaltyEntry(BaseModel):notes: str = Field(description="备注说明", default="")-_PROMPT = """你是一位专业的合规分析专家。请从文本中提取所有违规行为及其对应的处罚措施,形成违规处罚对照表。+_PROMPT = """## 角色与任务+你是一位专业的合规分析专家,请从文本中提取所有违规行为及其对应的处罚措施,形成违规处罚对照表。-### 提取规则+## 核心概念定义+- **元素 (Element)**:本模板中的"元素"指单条违规处罚条目,包含违规行为、严重程度、处罚措施、适用条款、备注等字段,通过违规行为+处罚措施组合进行去重的唯一知识单元。++## 提取规则1. 提取所有违规行为及其对应的处罚措施2. 为每条违规行为指定严重程度:轻微、一般、严重、特别严重3. 保持违规行为和处罚措施的准确性diff --git a/hyperextract/templates/zh/general/personal_profile.py b/hyperextract/templates/zh/general/personal_profile.pyindex f10a3f8..e6c97f8 100644--- a/hyperextract/templates/zh/general/personal_profile.py+++ b/hyperextract/templates/zh/general/personal_profile.py@@ -26,9 +26,13 @@ class PersonalInfo(BaseModel):summary: str = Field(description="个人简介", default="")-_PROMPT = """你是一位专业的人物档案编辑。请从文本中提取该人物的静态属性信息,构建个人档案。+_PROMPT = """## 角色与任务+你是一位专业的人物档案编辑,请从文本中提取该人物的静态属性信息,构建个人档案。-### 提取规则+## 核心概念定义+- **对象 (Object)**:本模板中的"对象"指个人档案信息,包含姓名、性别、生卒年、国籍、教育经历、职业、核心身份、主要成就等多个字段的结构化人物信息。++## 提取规则1. 提取姓名、性别、出生日期、逝世日期、国籍、出生地等基本信息2. 提取教育经历3. 提取职业或身份信息diff --git a/hyperextract/templates/zh/general/regulation_profile.py b/hyperextract/templates/zh/general/regulation_profile.pyindex 0a81aa8..a4c65c7 100644--- a/hyperextract/templates/zh/general/regulation_profile.py+++ b/hyperextract/templates/zh/general/regulation_profile.py@@ -25,9 +25,13 @@ class RegulationInfo(BaseModel):relatedRegulations: List[str] = Field(description="关联规章", default_factory=list)-_PROMPT = """你是一位专业的规章制度分析专家。请从文本中提取该规章制度的元数据信息,构建规章元数据快照。+_PROMPT = """## 角色与任务+你是一位专业的规章制度分析专家,请从文本中提取该规章制度的元数据信息,构建规章元数据快照。-### 提取规则+## 核心概念定义+- **对象 (Object)**:本模板中的"对象"指规章元数据信息,包含标题、版本、发布机构、发布/生效/失效日期、适用范围、适用对象、核心宗旨、关键词、关联规章等多个字段的结构化制度信息。++## 提取规则1. 提取规章的完整名称2. 提取版本号(如有)3. 提取发布机构diff --git a/hyperextract/templates/zh/general/social_network.py b/hyperextract/templates/zh/general/social_network.pyindex 107cc4d..c87a7ec 100644--- a/hyperextract/templates/zh/general/social_network.py+++ b/hyperextract/templates/zh/general/social_network.py@@ -26,8 +26,14 @@ class SocialRelation(BaseModel):details: str = Field(description="关系详细说明", default="")-_PROMPT = """你是一位专业的社会关系分析专家。请从文本中提取人物、组织及其相互关系,构建社交网络图。+_PROMPT = """## 角色与任务+你是一位专业的社会关系分析专家,请从文本中提取人物、组织及其相互关系,构建社交网络图。+## 核心概念定义+- **节点 (Node)**:本模板中的"节点"指人物或组织单元,包括人物、组织、机构等类型,用于表示社交网络中的实体。+- **边 (Edge)**:本模板中的"边"指人物/组织之间的社会关系,包括亲属、朋友、同事、师生、上下级、合作、竞争、隶属等二元关系。++## 提取规则### 节点提取规则1. 提取所有人物、组织、机构等2. 为每个节点指定类型:人物、组织、机构、其他@@ -55,9 +61,13 @@ _PROMPT = """你是一位专业的社会关系分析专家。请从文本中提### 源文本:"""-_NODE_PROMPT = """你是一位专业的人物和组织识别专家。请从文本中提取所有人物、组织作为节点。+_NODE_PROMPT = """## 角色与任务+你是一位专业的人物和组织识别专家,请从文本中提取所有人物、组织作为节点。++## 核心概念定义+- **节点 (Node)**:本模板中的"节点"指人物或组织单元,包括人物、组织、机构等类型,用于表示社交网络中的实体。-### 提取规则+## 提取规则1. 提取所有人物、组织、机构等2. 为每个节点指定类型:人物、组织、机构、其他3. 为每个节点添加简要描述@@ -66,8 +76,14 @@ _NODE_PROMPT = """你是一位专业的人物和组织识别专家。请从文### 源文本:"""-_EDGE_PROMPT = """你是一位专业的社会关系提取专家。请从给定节点列表中提取节点之间的相互关系。+_EDGE_PROMPT = """## 角色与任务+你是一位专业的社会关系提取专家,请从给定节点列表中提取节点之间的相互关系。++## 核心概念定义+- **节点 (Node)**:本模板中的"节点"指人物或组织单元,作为社会关系的参与者。+- **边 (Edge)**:本模板中的"边"指人物/组织之间的社会关系,包括亲属、朋友、同事、师生、上下级、合作、竞争、隶属等二元关系。+## 提取规则### 关系类型说明- 亲属:家庭关系(父母、子女、配偶、兄弟姐妹等)- 朋友:朋友关系