Skip to content

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

feat: 为历史和中医学模板添加分块参数配置

yifanfeng97c841d426a422
diff --git a/examples/template_history_demo.py b/examples/template_history_demo.py
index 71b78bc..1274404 100644
--- a/examples/template_history_demo.py
+++ b/examples/template_history_demo.py
@@ -68,12 +68,12 @@ TEMPLATE_TO_INPUT = {
# ==========================================
# 历史专著
-TEMPLATE = HistoricalKnowledgeGraph
+# TEMPLATE = HistoricalKnowledgeGraph
# TEMPLATE = MultiParticipantEventMap
# 编年史
# TEMPLATE = ChronologicalEventChain
-# TEMPLATE = HistoricalContextGraph
+TEMPLATE = HistoricalContextGraph
# TEMPLATE = PoliticalStruggleHypergraph
# 口述历史
@@ -135,7 +135,6 @@ def main():
llm_client=llm,
embedder=embedder,
verbose=True,
- chunk_size=512,
)
# 喂入文本
diff --git a/hyperextract/templates/zh/history/chronological_event_chain.py b/hyperextract/templates/zh/history/chronological_event_chain.py
index 3b4e32d..2a85d1c 100644
--- a/hyperextract/templates/zh/history/chronological_event_chain.py
+++ b/hyperextract/templates/zh/history/chronological_event_chain.py
@@ -128,6 +128,8 @@ class ChronologicalEventChain(AutoTemporalGraph[EventNode, TemporalEventEdge]):
*,
extraction_mode: str = "two_stage",
observation_time: str | None = None,
+ chunk_size: int = 512,
+ chunk_overlap: int = 64,
max_workers: int = 10,
verbose: bool = False,
**kwargs: Any,
@@ -142,6 +144,8 @@ class ChronologicalEventChain(AutoTemporalGraph[EventNode, TemporalEventEdge]):
或 "two_stage"(先提取节点,再提取边),默认为 "two_stage"
observation_time: 观察时间,用于解析相对时间表达,
如未指定则使用当前日期
+ chunk_size: 每个分块的最大字符数,默认为 512(历史文本信息量大,需较小分块)
+ chunk_overlap: 分块之间的重叠字符数,默认为 64
max_workers: 最大工作线程数,默认为 10
verbose: 是否输出详细日志,默认为 False
**kwargs: 其他技术参数,传递给基类
@@ -162,6 +166,8 @@ class ChronologicalEventChain(AutoTemporalGraph[EventNode, TemporalEventEdge]):
prompt=_PROMPT,
prompt_for_node_extraction=_NODE_PROMPT,
prompt_for_edge_extraction=_EDGE_PROMPT,
+ chunk_size=chunk_size,
+ chunk_overlap=chunk_overlap,
**kwargs,
)
diff --git a/hyperextract/templates/zh/history/epistolary_knowledge_graph.py b/hyperextract/templates/zh/history/epistolary_knowledge_graph.py
index 49f28d4..b0c101c 100644
--- a/hyperextract/templates/zh/history/epistolary_knowledge_graph.py
+++ b/hyperextract/templates/zh/history/epistolary_knowledge_graph.py
@@ -117,6 +117,8 @@ class EpistolaryKnowledgeGraph(AutoGraph[CorrespondentNode, LetterContentEdge]):
embedder: Embeddings,
*,
extraction_mode: str = "two_stage",
+ chunk_size: int = 512,
+ chunk_overlap: int = 64,
max_workers: int = 10,
verbose: bool = False,
**kwargs: Any,
@@ -129,6 +131,8 @@ class EpistolaryKnowledgeGraph(AutoGraph[CorrespondentNode, LetterContentEdge]):
embedder: 嵌入模型,用于语义检索
extraction_mode: 提取模式,可选 "one_stage"(同时提取节点和边)
或 "two_stage"(先提取节点,再提取边),默认为 "two_stage"
+ chunk_size: 每个分块的最大字符数,默认为 512(历史文本信息量大,需较小分块)
+ chunk_overlap: 分块之间的重叠字符数,默认为 64
max_workers: 最大工作线程数,默认为 10
verbose: 是否输出详细日志,默认为 False
**kwargs: 其他技术参数,传递给基类
@@ -147,6 +151,8 @@ class EpistolaryKnowledgeGraph(AutoGraph[CorrespondentNode, LetterContentEdge]):
prompt=_PROMPT,
prompt_for_node_extraction=_NODE_PROMPT,
prompt_for_edge_extraction=_EDGE_PROMPT,
+ chunk_size=chunk_size,
+ chunk_overlap=chunk_overlap,
**kwargs,
)
diff --git a/hyperextract/templates/zh/history/historical_context_graph.py b/hyperextract/templates/zh/history/historical_context_graph.py
index c3b0081..c624e67 100644
--- a/hyperextract/templates/zh/history/historical_context_graph.py
+++ b/hyperextract/templates/zh/history/historical_context_graph.py
@@ -106,6 +106,8 @@ class HistoricalContextGraph(AutoGraph[ContextEntityNode, ContextRelationEdge]):
embedder: Embeddings,
*,
extraction_mode: str = "two_stage",
+ chunk_size: int = 512,
+ chunk_overlap: int = 64,
max_workers: int = 10,
verbose: bool = False,
**kwargs: Any,
@@ -118,6 +120,8 @@ class HistoricalContextGraph(AutoGraph[ContextEntityNode, ContextRelationEdge]):
embedder: 嵌入模型,用于语义检索
extraction_mode: 提取模式,可选 "one_stage"(同时提取节点和边)
或 "two_stage"(先提取节点,再提取边),默认为 "two_stage"
+ chunk_size: 每个分块的最大字符数,默认为 512(历史文本信息量大,需较小分块)
+ chunk_overlap: 分块之间的重叠字符数,默认为 64
max_workers: 最大工作线程数,默认为 10
verbose: 是否输出详细日志,默认为 False
**kwargs: 其他技术参数,传递给基类
@@ -136,6 +140,8 @@ class HistoricalContextGraph(AutoGraph[ContextEntityNode, ContextRelationEdge]):
prompt=_PROMPT,
prompt_for_node_extraction=_NODE_PROMPT,
prompt_for_edge_extraction=_EDGE_PROMPT,
+ chunk_size=chunk_size,
+ chunk_overlap=chunk_overlap,
**kwargs,
)
diff --git a/hyperextract/templates/zh/history/historical_knowledge_graph.py b/hyperextract/templates/zh/history/historical_knowledge_graph.py
index 5579a87..a3d615d 100644
--- a/hyperextract/templates/zh/history/historical_knowledge_graph.py
+++ b/hyperextract/templates/zh/history/historical_knowledge_graph.py
@@ -108,6 +108,8 @@ class HistoricalKnowledgeGraph(AutoGraph[HistoricalPersonNode, PersonRelationEdg
embedder: Embeddings,
*,
extraction_mode: str = "two_stage",
+ chunk_size: int = 512,
+ chunk_overlap: int = 64,
max_workers: int = 10,
verbose: bool = False,
**kwargs: Any,
@@ -120,6 +122,8 @@ class HistoricalKnowledgeGraph(AutoGraph[HistoricalPersonNode, PersonRelationEdg
embedder: 嵌入模型,用于语义检索
extraction_mode: 提取模式,可选 "one_stage"(同时提取节点和边)
或 "two_stage"(先提取节点,再提取边),默认为 "two_stage"
+ chunk_size: 每个分块的最大字符数,默认为 512(历史文本信息量大,需较小分块)
+ chunk_overlap: 分块之间的重叠字符数,默认为 64
max_workers: 最大工作线程数,默认为 10
verbose: 是否输出详细日志,默认为 False
**kwargs: 其他技术参数,传递给基类
@@ -138,6 +142,8 @@ class HistoricalKnowledgeGraph(AutoGraph[HistoricalPersonNode, PersonRelationEdg
prompt=_PROMPT,
prompt_for_node_extraction=_NODE_PROMPT,
prompt_for_edge_extraction=_EDGE_PROMPT,
+ chunk_size=chunk_size,
+ chunk_overlap=chunk_overlap,
**kwargs,
)
diff --git a/hyperextract/templates/zh/history/memory_flashback_list.py b/hyperextract/templates/zh/history/memory_flashback_list.py
index d3538b1..2b0586a 100644
--- a/hyperextract/templates/zh/history/memory_flashback_list.py
+++ b/hyperextract/templates/zh/history/memory_flashback_list.py
@@ -58,6 +58,8 @@ class MemoryFlashbackList(AutoList[MemoryFragment]):
llm_client: BaseChatModel,
embedder: Embeddings,
*,
+ chunk_size: int = 512,
+ chunk_overlap: int = 64,
max_workers: int = 10,
verbose: bool = False,
**kwargs: Any,
@@ -68,6 +70,8 @@ class MemoryFlashbackList(AutoList[MemoryFragment]):
Args:
llm_client: LLM 客户端,用于知识提取
embedder: 嵌入模型,用于语义检索
+ chunk_size: 每个分块的最大字符数,默认为 512(历史文本信息量大,需较小分块)
+ chunk_overlap: 分块之间的重叠字符数,默认为 64
max_workers: 最大工作线程数,默认为 10
verbose: 是否输出详细日志,默认为 False
**kwargs: 其他技术参数,传递给基类
@@ -79,6 +83,8 @@ class MemoryFlashbackList(AutoList[MemoryFragment]):
max_workers=max_workers,
verbose=verbose,
prompt=_PROMPT,
+ chunk_size=chunk_size,
+ chunk_overlap=chunk_overlap,
**kwargs,
)
diff --git a/hyperextract/templates/zh/history/multi_participant_event_map.py b/hyperextract/templates/zh/history/multi_participant_event_map.py
index 9c3d920..73ac64f 100644
--- a/hyperextract/templates/zh/history/multi_participant_event_map.py
+++ b/hyperextract/templates/zh/history/multi_participant_event_map.py
@@ -113,6 +113,8 @@ class MultiParticipantEventMap(AutoHypergraph[EventParticipantNode, EventHypered
embedder: Embeddings,
*,
extraction_mode: str = "two_stage",
+ chunk_size: int = 512,
+ chunk_overlap: int = 64,
max_workers: int = 10,
verbose: bool = False,
**kwargs: Any,
@@ -125,6 +127,8 @@ class MultiParticipantEventMap(AutoHypergraph[EventParticipantNode, EventHypered
embedder: 嵌入模型,用于语义检索
extraction_mode: 提取模式,可选 "one_stage"(同时提取节点和边)
或 "two_stage"(先提取节点,再提取边),默认为 "two_stage"
+ chunk_size: 每个分块的最大字符数,默认为 512(历史文本信息量大,需较小分块)
+ chunk_overlap: 分块之间的重叠字符数,默认为 64
max_workers: 最大工作线程数,默认为 10
verbose: 是否输出详细日志,默认为 False
**kwargs: 其他技术参数,传递给基类
@@ -146,6 +150,8 @@ class MultiParticipantEventMap(AutoHypergraph[EventParticipantNode, EventHypered
prompt=_PROMPT,
prompt_for_node_extraction=_NODE_PROMPT,
prompt_for_edge_extraction=_EDGE_PROMPT,
+ chunk_size=chunk_size,
+ chunk_overlap=chunk_overlap,
**kwargs,
)
diff --git a/hyperextract/templates/zh/history/narrative_relation_graph.py b/hyperextract/templates/zh/history/narrative_relation_graph.py
index 726e223..bb10f9e 100644
--- a/hyperextract/templates/zh/history/narrative_relation_graph.py
+++ b/hyperextract/templates/zh/history/narrative_relation_graph.py
@@ -109,6 +109,8 @@ class NarrativeRelationGraph(AutoGraph[NarrativeCharacterNode, NarrativeInteract
embedder: Embeddings,
*,
extraction_mode: str = "two_stage",
+ chunk_size: int = 512,
+ chunk_overlap: int = 64,
max_workers: int = 10,
verbose: bool = False,
**kwargs: Any,
@@ -121,6 +123,8 @@ class NarrativeRelationGraph(AutoGraph[NarrativeCharacterNode, NarrativeInteract
embedder: 嵌入模型,用于语义检索
extraction_mode: 提取模式,可选 "one_stage"(同时提取节点和边)
或 "two_stage"(先提取节点,再提取边),默认为 "two_stage"
+ chunk_size: 每个分块的最大字符数,默认为 512(历史文本信息量大,需较小分块)
+ chunk_overlap: 分块之间的重叠字符数,默认为 64
max_workers: 最大工作线程数,默认为 10
verbose: 是否输出详细日志,默认为 False
**kwargs: 其他技术参数,传递给基类
@@ -139,6 +143,8 @@ class NarrativeRelationGraph(AutoGraph[NarrativeCharacterNode, NarrativeInteract
prompt=_PROMPT,
prompt_for_node_extraction=_NODE_PROMPT,
prompt_for_edge_extraction=_EDGE_PROMPT,
+ chunk_size=chunk_size,
+ chunk_overlap=chunk_overlap,
**kwargs,
)
diff --git a/hyperextract/templates/zh/history/personal_trajectory_hypergraph.py b/hyperextract/templates/zh/history/personal_trajectory_hypergraph.py
index ac5a1ba..0f0b591 100644
--- a/hyperextract/templates/zh/history/personal_trajectory_hypergraph.py
+++ b/hyperextract/templates/zh/history/personal_trajectory_hypergraph.py
@@ -113,6 +113,8 @@ class PersonalTrajectoryHypergraph(AutoHypergraph[PersonNode, LifePhaseHyperedge
embedder: Embeddings,
*,
extraction_mode: str = "two_stage",
+ chunk_size: int = 512,
+ chunk_overlap: int = 64,
max_workers: int = 10,
verbose: bool = False,
**kwargs: Any,
@@ -125,6 +127,8 @@ class PersonalTrajectoryHypergraph(AutoHypergraph[PersonNode, LifePhaseHyperedge
embedder: 嵌入模型,用于语义检索
extraction_mode: 提取模式,可选 "one_stage"(同时提取节点和边)
或 "two_stage"(先提取节点,再提取边),默认为 "two_stage"
+ chunk_size: 每个分块的最大字符数,默认为 512(历史文本信息量大,需较小分块)
+ chunk_overlap: 分块之间的重叠字符数,默认为 64
max_workers: 最大工作线程数,默认为 10
verbose: 是否输出详细日志,默认为 False
**kwargs: 其他技术参数,传递给基类
@@ -146,6 +150,8 @@ class PersonalTrajectoryHypergraph(AutoHypergraph[PersonNode, LifePhaseHyperedge
prompt=_PROMPT,
prompt_for_node_extraction=_NODE_PROMPT,
prompt_for_edge_extraction=_EDGE_PROMPT,
+ chunk_size=chunk_size,
+ chunk_overlap=chunk_overlap,
**kwargs,
)
diff --git a/hyperextract/templates/zh/history/political_struggle_hypergraph.py b/hyperextract/templates/zh/history/political_struggle_hypergraph.py
index 35113e2..c2d6aeb 100644
--- a/hyperextract/templates/zh/history/political_struggle_hypergraph.py
+++ b/hyperextract/templates/zh/history/political_struggle_hypergraph.py
@@ -120,6 +120,8 @@ class PoliticalStruggleHypergraph(AutoHypergraph[PoliticalActorNode, StruggleHyp
embedder: Embeddings,
*,
extraction_mode: str = "two_stage",
+ chunk_size: int = 512,
+ chunk_overlap: int = 64,
max_workers: int = 10,
verbose: bool = False,
**kwargs: Any,
@@ -132,6 +134,8 @@ class PoliticalStruggleHypergraph(AutoHypergraph[PoliticalActorNode, StruggleHyp
embedder: 嵌入模型,用于语义检索
extraction_mode: 提取模式,可选 "one_stage"(同时提取节点和边)
或 "two_stage"(先提取节点,再提取边),默认为 "two_stage"
+ chunk_size: 每个分块的最大字符数,默认为 512(历史文本信息量大,需较小分块)
+ chunk_overlap: 分块之间的重叠字符数,默认为 64
max_workers: 最大工作线程数,默认为 10
verbose: 是否输出详细日志,默认为 False
**kwargs: 其他技术参数,传递给基类
@@ -158,6 +162,8 @@ class PoliticalStruggleHypergraph(AutoHypergraph[PoliticalActorNode, StruggleHyp
prompt=_PROMPT,
prompt_for_node_extraction=_NODE_PROMPT,
prompt_for_edge_extraction=_EDGE_PROMPT,
+ chunk_size=chunk_size,
+ chunk_overlap=chunk_overlap,
**kwargs,
)
diff --git a/hyperextract/templates/zh/tcm/acupoint_location_map.py b/hyperextract/templates/zh/tcm/acupoint_location_map.py
index 7885905..62c5141 100644
--- a/hyperextract/templates/zh/tcm/acupoint_location_map.py
+++ b/hyperextract/templates/zh/tcm/acupoint_location_map.py
@@ -99,6 +99,8 @@ class AcupointLocationMap(AutoGraph[AcupointNode, LocationRelation]):
embedder: Embeddings,
*,
extraction_mode: str = "two_stage",
+ chunk_size: int = 512,
+ chunk_overlap: int = 64,
max_workers: int = 10,
verbose: bool = False,
**kwargs: Any,
@@ -111,6 +113,8 @@ class AcupointLocationMap(AutoGraph[AcupointNode, LocationRelation]):
embedder: 嵌入模型,用于语义检索
extraction_mode: 提取模式,可选 "one_stage"(同时提取节点和边)
或 "two_stage"(先提取节点,再提取边),默认为 "two_stage"
+ chunk_size: 每个分块的最大字符数,默认为 512(中医文本信息量大,需较小分块)
+ chunk_overlap: 分块之间的重叠字符数,默认为 64
max_workers: 最大工作线程数,默认为 10
verbose: 是否输出详细日志,默认为 False
**kwargs: 其他技术参数,传递给基类
@@ -124,6 +128,8 @@ class AcupointLocationMap(AutoGraph[AcupointNode, LocationRelation]):
llm_client=llm_client,
embedder=embedder,
extraction_mode=extraction_mode,
+ chunk_size=chunk_size,
+ chunk_overlap=chunk_overlap,
max_workers=max_workers,
verbose=verbose,
prompt=_PROMPT,
diff --git a/hyperextract/templates/zh/tcm/compatibility_net.py b/hyperextract/templates/zh/tcm/compatibility_net.py
index 2456b0a..1ee91dc 100644
--- a/hyperextract/templates/zh/tcm/compatibility_net.py
+++ b/hyperextract/templates/zh/tcm/compatibility_net.py
@@ -94,6 +94,8 @@ class CompatibilityNet(AutoGraph[HerbEntity, CompatibilityRelation]):
embedder: Embeddings,
*,
extraction_mode: str = "two_stage",
+ chunk_size: int = 512,
+ chunk_overlap: int = 64,
max_workers: int = 10,
verbose: bool = False,
**kwargs: Any,
@@ -106,6 +108,8 @@ class CompatibilityNet(AutoGraph[HerbEntity, CompatibilityRelation]):
embedder: 嵌入模型,用于语义检索
extraction_mode: 提取模式,可选 "one_stage"(同时提取节点和边)
或 "two_stage"(先提取节点,再提取边),默认为 "two_stage"
+ chunk_size: 每个分块的最大字符数,默认为 512(中医文本信息量大,需较小分块)
+ chunk_overlap: 分块之间的重叠字符数,默认为 64
max_workers: 最大工作线程数,默认为 10
verbose: 是否输出详细日志,默认为 False
**kwargs: 其他技术参数,传递给基类
@@ -119,6 +123,8 @@ class CompatibilityNet(AutoGraph[HerbEntity, CompatibilityRelation]):
llm_client=llm_client,
embedder=embedder,
extraction_mode=extraction_mode,
+ chunk_size=chunk_size,
+ chunk_overlap=chunk_overlap,
max_workers=max_workers,
verbose=verbose,
prompt=_PROMPT,
diff --git a/hyperextract/templates/zh/tcm/formula_composition.py b/hyperextract/templates/zh/tcm/formula_composition.py
index df7a456..4e6f262 100644
--- a/hyperextract/templates/zh/tcm/formula_composition.py
+++ b/hyperextract/templates/zh/tcm/formula_composition.py
@@ -122,6 +122,8 @@ class FormulaComposition(AutoHypergraph[HerbNode, FormulaHyperedge]):
embedder: Embeddings,
*,
extraction_mode: str = "two_stage",
+ chunk_size: int = 512,
+ chunk_overlap: int = 64,
max_workers: int = 10,
verbose: bool = False,
**kwargs: Any,
@@ -134,6 +136,8 @@ class FormulaComposition(AutoHypergraph[HerbNode, FormulaHyperedge]):
embedder: 嵌入模型,用于语义检索
extraction_mode: 提取模式,可选 "one_stage"(同时提取节点和边)
或 "two_stage"(先提取节点,再提取边),默认为 "two_stage"
+ chunk_size: 每个分块的最大字符数,默认为 512(中医文本信息量大,需较小分块)
+ chunk_overlap: 分块之间的重叠字符数,默认为 64
max_workers: 最大工作线程数,默认为 10
verbose: 是否输出详细日志,默认为 False
**kwargs: 其他技术参数,传递给基类
@@ -160,6 +164,8 @@ class FormulaComposition(AutoHypergraph[HerbNode, FormulaHyperedge]):
llm_client=llm_client,
embedder=embedder,
extraction_mode=extraction_mode,
+ chunk_size=chunk_size,
+ chunk_overlap=chunk_overlap,
max_workers=max_workers,
verbose=verbose,
prompt=_PROMPT,
diff --git a/hyperextract/templates/zh/tcm/function_indication_map.py b/hyperextract/templates/zh/tcm/function_indication_map.py
index 29bf69b..857207b 100644
--- a/hyperextract/templates/zh/tcm/function_indication_map.py
+++ b/hyperextract/templates/zh/tcm/function_indication_map.py
@@ -100,6 +100,8 @@ class FunctionIndicationMap(AutoGraph[GeneralEntity, GeneralRelation]):
embedder: Embeddings,
*,
extraction_mode: str = "two_stage",
+ chunk_size: int = 512,
+ chunk_overlap: int = 64,
max_workers: int = 10,
verbose: bool = False,
**kwargs: Any,
@@ -112,6 +114,8 @@ class FunctionIndicationMap(AutoGraph[GeneralEntity, GeneralRelation]):
embedder: 嵌入模型,用于语义检索
extraction_mode: 提取模式,可选 "one_stage"(同时提取节点和边)
或 "two_stage"(先提取节点,再提取边),默认为 "two_stage"
+ chunk_size: 每个分块的最大字符数,默认为 512(中医文本信息量大,需较小分块)
+ chunk_overlap: 分块之间的重叠字符数,默认为 64
max_workers: 最大工作线程数,默认为 10
verbose: 是否输出详细日志,默认为 False
**kwargs: 其他技术参数,传递给基类
@@ -125,6 +129,8 @@ class FunctionIndicationMap(AutoGraph[GeneralEntity, GeneralRelation]):
llm_client=llm_client,
embedder=embedder,
extraction_mode=extraction_mode,
+ chunk_size=chunk_size,
+ chunk_overlap=chunk_overlap,
max_workers=max_workers,
verbose=verbose,
prompt=_PROMPT,
diff --git a/hyperextract/templates/zh/tcm/herb_property_model.py b/hyperextract/templates/zh/tcm/herb_property_model.py
index 4963f12..ecce677 100644
--- a/hyperextract/templates/zh/tcm/herb_property_model.py
+++ b/hyperextract/templates/zh/tcm/herb_property_model.py
@@ -28,9 +28,6 @@ class HerbProperty(BaseModel):
_PROMPT = """## 角色与任务
你是一位专业的中药学家,请从文本中提取单味药的性味归经、毒性及推荐剂量等信息。
-## 核心概念定义
-- **对象 (Object)**:从文本中提取的单一结构化对象,包含药物的性味归经信息
-
## 提取规则
### 核心约束
1. 识别文本的核心药物主体
@@ -72,6 +69,8 @@ class HerbPropertyModel(AutoModel[HerbProperty]):
llm_client: BaseChatModel,
embedder: Embeddings,
*,
+ chunk_size: int = 512,
+ chunk_overlap: int = 64,
max_workers: int = 10,
verbose: bool = False,
**kwargs: Any,
@@ -82,6 +81,8 @@ class HerbPropertyModel(AutoModel[HerbProperty]):
Args:
llm_client: LLM 客户端,用于知识提取
embedder: 嵌入模型,用于语义检索
+ chunk_size: 每个分块的最大字符数,默认为 512(中医文本信息量大,需较小分块)
+ chunk_overlap: 分块之间的重叠字符数,默认为 64
max_workers: 最大工作线程数,默认为 10
verbose: 是否输出详细日志,默认为 False
**kwargs: 其他技术参数,传递给基类
@@ -91,6 +92,8 @@ class HerbPropertyModel(AutoModel[HerbProperty]):
llm_client=llm_client,
embedder=embedder,
prompt=_PROMPT,
+ chunk_size=chunk_size,
+ chunk_overlap=chunk_overlap,
max_workers=max_workers,
verbose=verbose,
**kwargs,
diff --git a/hyperextract/templates/zh/tcm/meridian_flow_graph.py b/hyperextract/templates/zh/tcm/meridian_flow_graph.py
index d661b2a..3ab446f 100644
--- a/hyperextract/templates/zh/tcm/meridian_flow_graph.py
+++ b/hyperextract/templates/zh/tcm/meridian_flow_graph.py
@@ -100,6 +100,8 @@ class MeridianFlowGraph(AutoGraph[MeridianNode, MeridianFlowRelation]):
embedder: Embeddings,
*,
extraction_mode: str = "two_stage",
+ chunk_size: int = 512,
+ chunk_overlap: int = 64,
max_workers: int = 10,
verbose: bool = False,
**kwargs: Any,
@@ -112,6 +114,8 @@ class MeridianFlowGraph(AutoGraph[MeridianNode, MeridianFlowRelation]):
embedder: 嵌入模型,用于语义检索
extraction_mode: 提取模式,可选 "one_stage"(同时提取节点和边)
或 "two_stage"(先提取节点,再提取边),默认为 "two_stage"
+ chunk_size: 每个分块的最大字符数,默认为 512(中医文本信息量大,需较小分块)
+ chunk_overlap: 分块之间的重叠字符数,默认为 64
max_workers: 最大工作线程数,默认为 10
verbose: 是否输出详细日志,默认为 False
**kwargs: 其他技术参数,传递给基类
@@ -125,6 +129,8 @@ class MeridianFlowGraph(AutoGraph[MeridianNode, MeridianFlowRelation]):
llm_client=llm_client,
embedder=embedder,
extraction_mode=extraction_mode,
+ chunk_size=chunk_size,
+ chunk_overlap=chunk_overlap,
max_workers=max_workers,
verbose=verbose,
prompt=_PROMPT,
diff --git a/hyperextract/templates/zh/tcm/prescription_modification.py b/hyperextract/templates/zh/tcm/prescription_modification.py
index 73aa36a..b12ec77 100644
--- a/hyperextract/templates/zh/tcm/prescription_modification.py
+++ b/hyperextract/templates/zh/tcm/prescription_modification.py
@@ -112,6 +112,8 @@ class PrescriptionModification(AutoHypergraph[PrescriptionNode, ModificationHype
embedder: Embeddings,
*,
extraction_mode: str = "two_stage",
+ chunk_size: int = 512,
+ chunk_overlap: int = 64,
max_workers: int = 10,
verbose: bool = False,
**kwargs: Any,
@@ -124,6 +126,8 @@ class PrescriptionModification(AutoHypergraph[PrescriptionNode, ModificationHype
embedder: 嵌入模型,用于语义检索
extraction_mode: 提取模式,可选 "one_stage"(同时提取节点和边)
或 "two_stage"(先提取节点,再提取边),默认为 "two_stage"
+ chunk_size: 每个分块的最大字符数,默认为 512(中医文本信息量大,需较小分块)
+ chunk_overlap: 分块之间的重叠字符数,默认为 64
max_workers: 最大工作线程数,默认为 10
verbose: 是否输出详细日志,默认为 False
**kwargs: 其他技术参数,传递给基类
@@ -147,6 +151,8 @@ class PrescriptionModification(AutoHypergraph[PrescriptionNode, ModificationHype
llm_client=llm_client,
embedder=embedder,
extraction_mode=extraction_mode,
+ chunk_size=chunk_size,
+ chunk_overlap=chunk_overlap,
max_workers=max_workers,
verbose=verbose,
prompt=_PROMPT,
diff --git a/hyperextract/templates/zh/tcm/processing_method.py b/hyperextract/templates/zh/tcm/processing_method.py
index efef896..65ca9ec 100644
--- a/hyperextract/templates/zh/tcm/processing_method.py
+++ b/hyperextract/templates/zh/tcm/processing_method.py
@@ -59,6 +59,8 @@ class ProcessingMethod(AutoList[ProcessingMethodItem]):
llm_client: BaseChatModel,
embedder: Embeddings,
*,
+ chunk_size: int = 512,
+ chunk_overlap: int = 64,
max_workers: int = 10,
verbose: bool = False,
**kwargs: Any,
@@ -69,6 +71,8 @@ class ProcessingMethod(AutoList[ProcessingMethodItem]):
Args:
llm_client: LLM 客户端,用于知识提取
embedder: 嵌入模型,用于语义检索
+ chunk_size: 每个分块的最大字符数,默认为 512(中医文本信息量大,需较小分块)
+ chunk_overlap: 分块之间的重叠字符数,默认为 64
max_workers: 最大工作线程数,默认为 10
verbose: 是否输出详细日志,默认为 False
**kwargs: 其他技术参数,传递给基类
@@ -78,6 +82,8 @@ class ProcessingMethod(AutoList[ProcessingMethodItem]):
llm_client=llm_client,
embedder=embedder,
prompt=_PROMPT,
+ chunk_size=chunk_size,
+ chunk_overlap=chunk_overlap,
max_workers=max_workers,
verbose=verbose,
**kwargs,
diff --git a/hyperextract/templates/zh/tcm/pulse_tongue_record.py b/hyperextract/templates/zh/tcm/pulse_tongue_record.py
index 5a8a9f0..4e847f2 100644
--- a/hyperextract/templates/zh/tcm/pulse_tongue_record.py
+++ b/hyperextract/templates/zh/tcm/pulse_tongue_record.py
@@ -61,6 +61,8 @@ class PulseTongueRecord(AutoList[PulseTongueItem]):
llm_client: BaseChatModel,
embedder: Embeddings,
*,
+ chunk_size: int = 512,
+ chunk_overlap: int = 64,
max_workers: int = 10,
verbose: bool = False,
**kwargs: Any,
@@ -71,6 +73,8 @@ class PulseTongueRecord(AutoList[PulseTongueItem]):
Args:
llm_client: LLM 客户端,用于知识提取
embedder: 嵌入模型,用于语义检索
+ chunk_size: 每个分块的最大字符数,默认为 512(中医文本信息量大,需较小分块)
+ chunk_overlap: 分块之间的重叠字符数,默认为 64
max_workers: 最大工作线程数,默认为 10
verbose: 是否输出详细日志,默认为 False
**kwargs: 其他技术参数,传递给基类
@@ -79,6 +83,8 @@ class PulseTongueRecord(AutoList[PulseTongueItem]):
item_schema=PulseTongueItem,
llm_client=llm_client,
embedder=embedder,
+ chunk_size=chunk_size,
+ chunk_overlap=chunk_overlap,
max_workers=max_workers,
verbose=verbose,
prompt=_PROMPT,
diff --git a/hyperextract/templates/zh/tcm/syndrome_reasoning_graph.py b/hyperextract/templates/zh/tcm/syndrome_reasoning_graph.py
index bde886a..90780d3 100644
--- a/hyperextract/templates/zh/tcm/syndrome_reasoning_graph.py
+++ b/hyperextract/templates/zh/tcm/syndrome_reasoning_graph.py
@@ -114,6 +114,8 @@ class SyndromeReasoningGraph(AutoHypergraph[TCMEntity, SyndromeReasoningEdge]):
embedder: Embeddings,
*,
extraction_mode: str = "two_stage",
+ chunk_size: int = 512,
+ chunk_overlap: int = 64,
max_workers: int = 10,
verbose: bool = False,
**kwargs: Any,
@@ -126,6 +128,8 @@ class SyndromeReasoningGraph(AutoHypergraph[TCMEntity, SyndromeReasoningEdge]):
embedder: 嵌入模型,用于语义检索
extraction_mode: 提取模式,可选 "one_stage"(同时提取节点和边)
或 "two_stage"(先提取节点,再提取边),默认为 "two_stage"
+ chunk_size: 每个分块的最大字符数,默认为 512(中医文本信息量大,需较小分块)
+ chunk_overlap: 分块之间的重叠字符数,默认为 64
max_workers: 最大工作线程数,默认为 10
verbose: 是否输出详细日志,默认为 False
**kwargs: 其他技术参数,传递给基类
@@ -139,6 +143,8 @@ class SyndromeReasoningGraph(AutoHypergraph[TCMEntity, SyndromeReasoningEdge]):
llm_client=llm_client,
embedder=embedder,
extraction_mode=extraction_mode,
+ chunk_size=chunk_size,
+ chunk_overlap=chunk_overlap,
max_workers=max_workers,
verbose=verbose,
prompt=_PROMPT,