Hypergraph is more powerful. Transform unstructured text into structured knowledge with LLMs. Graphs, hypergraphs, and spatio-temporal extractions — with one command.
docs: 更新中英文README文件以完善项目文档
yifanfeng9780293f94594f
diff --git a/README.md b/README.mdindex e49e732..e60996a 100644--- a/README.md+++ b/README.md@@ -1,15 +1,52 @@-# Hyper-Extract+# Hyper-Extract 🖥️[中文版](./README_ZH.md) · [English Version](#)---+## The CLI-First Knowledge Extraction Engine++> Transform any document into **searchable, queryable, reasoning-enabled** structured knowledge — with just one command.++**8 Knowledge Types** · **5 Extraction Methods** · **200+ Domain Templates** · **Bilingual**++---+<!-- Architecture Diagram -->----## "Chat solved. What's next is Knowledge."+## ⚡ One-Line Knowledge Extraction++```bash+# Install+uv pip install hyperextract++# Extract → Build → Query (one line at a time)+he parse report.md -o kb -t graph -l zh # Extract knowledge+he talk kb -i # Interactive Q&A+he search kb "revenue growth reasons" # Semantic search+he show kb # Visualize+```++### 💻 CLI Commands++| Command | Description |+|---------|-------------|+| `he parse` | Extract knowledge from text/file |+| `he talk` | Interactive Q&A with knowledge base |+| `he search` | Semantic search |+| `he show` | Visualize knowledge graph |+| `he list` | List available templates/methods |+| `he config` | Configure LLM/Embedder |+| `he info` | Show knowledge base info |+| `he feed` | Append knowledge to existing KB |+| `he build-index` | Build vector index |++---++## "Chat solved. What's next is CLI + Knowledge Structures."Transform LLM output from scattered text into **searchable, queryable, and reasoning-enabled** structured knowledge.@@ -22,15 +59,20 @@ Transform LLM output from scattered text into **searchable, queryable, and reaso| Before | After || :--- | :--- |-| LLM outputs a wall of text | Structured knowledge output |-| ❌ Answer disappears after chat | ✅ Persistent storage |-| ❌ Can't search precisely | ✅ Precise search |-| ❌ Can't trace the source | ✅ Traceable provenance |+| LLM outputs a wall of text | Structured knowledge (8 types) |+| ❌ Need Python to use | ✅ CLI-first (`he` command) |+| ❌ Only simple graph | ✅ Graph/Temporal/Spatial/Hypergraph... |+| ❌ Answer disappears | ✅ Persistent storage |+| ❌ Can't search precisely | ✅ Semantic search |+| ❌ Can't trace source | ✅ Traceable provenance |+| ❌ One language only | ✅ Bilingual (zh/en) || ❌ Fragmented, can't reuse | ✅ Knowledge accumulates |----## 🧩 8 AutoTypes+## 🧩 8 Knowledge Structures (Not Just Simple Graphs)++> Unlike other tools that only support basic graphs, Hyper-Extract handles **complex, multi-dimensional knowledge structures**.<!-- AutoTypes Diagram -->@@ -48,20 +90,26 @@ Transform LLM output from scattered text into **searchable, queryable, and reaso----## 🔬 Method Comparison+## 🔬 Extraction Methods Comparison++> Hyper-Extract implements **multiple** extraction methods, not just one.-| Method | Type | Model | List | Set | Graph | Temporal | Spatial | Spatiotemporal | Hypergraph |-| :--- | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: |-| **KG-Gen** | Graph | ❌ | ❌ | ❌ | ✅ | ❌ | ❌ | ❌ | ❌ |-| **ATOM** | Atomic | ❌ | ❌ | ❌ | ✅ | ✅ | ❌ | ❌ | ❌ |-| **Graphiti** | Temporal | ❌ | ❌ | ❌ | ❌ | ✅ | ❌ | ❌ | ❌ |-| **LightRAG** | Graph | ❌ | ❌ | ❌ | ✅ | ❌ | ❌ | ❌ | ❌ |-| **Hyper-RAG** | Hypergraph | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ✅ |-| **Hyper-Extract** | All-in-One | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |+| Method | Type | Graph | Temporal | Spatial | Spatiotemporal | Hypergraph |+| :--- | :--- | :---: | :---: | :---: | :---: | :---: |+| **KG-Gen** | Graph | ✅ | ❌ | ❌ | ❌ | ❌ |+| **ATOM** | Atomic | ✅ | ✅ | ❌ | ❌ | ❌ |+| **Graphiti** | Temporal | ❌ | ✅ | ❌ | ❌ | ❌ |+| **LightRAG** | Graph | ✅ | ❌ | ❌ | ❌ | ❌ |+| **Hyper-RAG** | Hypergraph | ❌ | ❌ | ❌ | ❌ | ✅ |+| **Hyper-Extract** | **All-in-One** | ✅ | ✅ | ✅ | ✅ | ✅ |++**Choose the method that fits your need, or let AutoTypes auto-select.**----## 🌍 12 Domains, 200+ Templates+## 🌍 12 Domains, 200+ Ready-to-Use Templates++> Pre-built templates for **different industries** — extract knowledge **right away** without designing schemas.| Domain | Templates | Domain | Templates || :--- | :---: | :--- | :---: |@@ -72,40 +120,39 @@ Transform LLM output from scattered text into **searchable, queryable, and reaso| 🔧 Industry | 18+ | 🌾 Agriculture | 8+ || 🍜 Food | 8+ | 🌐 General | 20+ |+**✅ Bilingual** — Templates available in both English and Chinese+---## 🚀 Quick Start-### Option 1: Using YAML Config (Recommended)--```python-from hyperextract.utils.template_engine import Gallery, TemplateFactory-from langchain_openai import ChatOpenAI, OpenAIEmbeddings+### Option 1: CLI (Recommended) ⚡-llm = ChatOpenAI(model="gpt-4o-mini")-embedder = OpenAIEmbeddings()+```bash+# Extract knowledge from document+he parse document.pdf -o my_kb -t knowledge_graph -l zh-# Get template (auto-loaded presets and customs)-config = Gallery.get("ResearchNoteSummary")+# Chat with your knowledge+he talk my_kb -i-# Create template-template = TemplateFactory.create(config, llm, embedder)-result = template.parse("Apple Q3 revenue reached $94.9 billion...")+# Search semantically+he search my_kb "公司营收增长原因"-answer = template.chat("What drove the revenue growth?")-print(answer.content)+# Visualize knowledge graph+he show my_kb```-### Option 2: Using Python Class (Deprecated)+### Option 2: Python API```python-from hyperextract.templates.legacy.en.finance import ResearchNoteSummary+from hyperextract.utils.template_engine import Gallery, TemplateFactoryfrom langchain_openai import ChatOpenAI, OpenAIEmbeddingsllm = ChatOpenAI(model="gpt-4o-mini")embedder = OpenAIEmbeddings()-template = ResearchNoteSummary(llm_client=llm, embedder=embedder)+config = Gallery.get("ResearchNoteSummary")+template = TemplateFactory.create(config, llm, embedder)result = template.parse("Apple Q3 revenue reached $94.9 billion...")answer = template.chat("What drove the revenue growth?")@@ -121,7 +168,11 @@ print(answer.content)```hyperextract/-├── types/ # 8 AutoTypes+├── cli/ # 💻 CLI Interface (he command)+│ ├── commands/ # parse, talk, search, show...+│ └── __main__.py # Entry point+│+├── types/ # 🧩 8 Knowledge Structures│ ├── model.py # AutoModel│ ├── list.py # AutoList│ ├── set.py # AutoSet@@ -131,20 +182,12 @@ hyperextract/│ ├── spatial_graph.py # AutoSpatialGraph│ └── spatio_temporal_graph.py # AutoSpatioTemporalGraph│-├── methods/ # Extraction Engines-│ ├── rag/ # RAG methods-│ │ ├── light_rag.py-│ │ ├── hyper_rag.py-│ │ └── cog_rag.py-│ └── typical/ # Reproduced methods-│ ├── kg_gen.py # KG-Gen-│ └── atom.py # ATOM+├── methods/ # 🔬 Extraction Engines+│ ├── rag/ # LightRAG, HyperRAG, CogRAG+│ └── typical/ # KG-Gen, ATOM (reproduced)│-└── templates/ # Domain Templates- ├── zh/ # Chinese templates- │ ├── finance/ # 25+ templates- │ ├── medicine/ # 20+ templates- │ └── ...+└── templates/ # 🌍 200+ Domain Templates+ ├── zh/ # Chinese templates (25+ domains)└── en/ # English templates```diff --git a/README_ZH.md b/README_ZH.mdindex df635ec..199b865 100644--- a/README_ZH.md+++ b/README_ZH.md@@ -1,15 +1,52 @@-# Hyper-Extract+# Hyper-Extract 🖥️[English Version](./README.md) · [中文版](#)---+## 首个 CLI 优先的知识提取引擎++> 只需一行命令,将任何文档转化为**可搜索、可查询、可推理**的结构化知识。++**8 种知识结构** · **5 种提取方法** · **200+ 领域模板** · **中英文支持**++---+<!-- 架构图 -->----## "Chat 已解决,下一步是知识"+## ⚡ 一行命令提取知识++```bash+# 安装+uv pip install hyperextract++# 提取 → 构建 → 问答 (逐行执行)+he parse report.md -o kb -t graph -l zh # 提取知识+he talk kb -i # 交互式问答+he search kb "营收增长原因" # 语义搜索+he show kb # 可视化+```++### 💻 CLI 命令++| 命令 | 说明 |+|---------|-------------|+| `he parse` | 从文本/文件提取知识 |+| `he talk` | 与知识库交互问答 |+| `he search` | 语义搜索 |+| `he show` | 可视化知识图谱 |+| `he list` | 列出可用模板/方法 |+| `he config` | 配置 LLM/Embedding |+| `he info` | 查看知识库信息 |+| `he feed` | 向现有知识库追加内容 |+| `he build-index` | 构建向量索引 |++---++## "Chat 已解决,下一步是 CLI + 知识结构"将 LLM 输出的文本转化为**可搜索、可查询、可推理**的结构化知识。@@ -22,15 +59,20 @@| 以前 | 现在 || :--- | :--- |-| LLM 输出一堆文本 | 输出结构化知识 |+| LLM 输出一堆文本 | 结构化知识(8种类型) |+| ❌ 需要写 Python 代码 | ✅ CLI 优先(`he` 命令) |+| ❌ 只支持简单图谱 | ✅ 图谱/时序/空间/超图... || ❌ 回答完就消失 | ✅ 可持久化存储 |-| ❌ 无法精准检索 | ✅ 可精准搜索 |+| ❌ 无法精准检索 | ✅ 语义搜索 || ❌ 难以追溯源头 | ✅ 可追溯来源 |+| ❌ 只有一种语言 | ✅ 中英文双语支持 || ❌ 碎片化无法复用 | ✅ 知识沉淀复用 |----## 🧩 8 种 AutoType+## 🧩 8 种知识结构(不只是简单图谱)++> 与其他只支持基础图谱的工具不同,Hyper-Extract 支持**复杂、多维的知识结构**。<!-- AutoTypes 图 -->@@ -41,27 +83,33 @@| **AutoList** | 📝 | 提取为列表 || **AutoSet** | 📦 | 提取并去重 || **AutoGraph** | 🔗 | 提取为知识图谱 |-| **AutoTemporalGraph** | ⏱️ | 提取为时序图 |-| **AutoSpatialGraph** | 📍 | 提取为空间图 |-| **AutoSpatioTemporalGraph** | 🌏 | 提取为时空图 |-| **AutoHypergraph** | 🌐 | 提取为超图 |+| **AutoTemporalGraph** | ⏱️ | 提取为时序图(时间线) |+| **AutoSpatialGraph** | 📍 | 提取为空间图(地理位置) |+| **AutoSpatioTemporalGraph** | 🌏 | 提取为时空图(时间+空间) |+| **AutoHypergraph** | 🌐 | 提取为超图(多方关系) |----## 🔬 方法对比+## 🔬 提取方法对比++> Hyper-Extract 实现了**多种**提取方法,而非只有一种。-| 方法 | 类型 | Model | List | Set | Graph | Temporal | Spatial | Spatiotemporal | Hypergraph |-| :--- | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: |-| **KG-Gen** | Graph | ❌ | ❌ | ❌ | ✅ | ❌ | ❌ | ❌ | ❌ |-| **ATOM** | Atomic | ❌ | ❌ | ❌ | ✅ | ✅ | ❌ | ❌ | ❌ |-| **Graphiti** | Temporal | ❌ | ❌ | ❌ | ❌ | ✅ | ❌ | ❌ | ❌ |-| **LightRAG** | Graph | ❌ | ❌ | ❌ | ✅ | ❌ | ❌ | ❌ | ❌ |-| **Hyper-RAG** | Hypergraph | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ✅ |-| **Hyper-Extract** | All-in-One | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |+| 方法 | 类型 | 图谱 | 时序 | 空间 | 时空 | 超图 |+| :--- | :--- | :---: | :---: | :---: | :---: | :---: |+| **KG-Gen** | 图谱 | ✅ | ❌ | ❌ | ❌ | ❌ |+| **ATOM** | 原子 | ✅ | ✅ | ❌ | ❌ | ❌ |+| **Graphiti** | 时序 | ❌ | ✅ | ❌ | ❌ | ❌ |+| **LightRAG** | 图谱 | ✅ | ❌ | ❌ | ❌ | ❌ |+| **Hyper-RAG** | 超图 | ❌ | ❌ | ❌ | ❌ | ✅ |+| **Hyper-Extract** | **全能型** | ✅ | ✅ | ✅ | ✅ | ✅ |++**选择适合你需求的方法,或让 AutoTypes 自动选择。**----## 🌍 12 个领域,200+ 模板+## 🌍 12 个领域,200+ 开箱即用模板++> 针对**不同行业**预置的模板 —— 无需设计schema,直接提取知识。| 领域 | 模板数 | 领域 | 模板数 || :--- | :---: | :--- | :---: |@@ -72,40 +120,39 @@| 🔧 工业 | 18+ | 🌾 农业 | 8+ || 🍜 美食 | 8+ | 🌐 通用 | 20+ |+**✅ 双语支持** — 模板同时支持中文和英文+---## 🚀 快速开始-### 方式一:使用 YAML 配置(推荐)--```python-from hyperextract.utils.template_engine import Gallery, TemplateFactory-from langchain_openai import ChatOpenAI, OpenAIEmbeddings+### 方式一:CLI(推荐)⚡-llm = ChatOpenAI(model="gpt-4o-mini")-embedder = OpenAIEmbeddings()+```bash+# 从文档提取知识+he parse document.pdf -o my_kb -t knowledge_graph -l zh-# 直接获取模板(自动加载 presets 和 customs)-config = Gallery.get("ResearchNoteSummary")+# 与知识库问答+he talk my_kb -i-# 创建模板-template = TemplateFactory.create(config, llm, embedder)-result = template.parse("苹果Q3营收达到949亿美元...")+# 语义搜索+he search my_kb "公司营收增长原因"-answer = template.chat("营收增长的原因是什么?")-print(answer.content)+# 可视化知识图谱+he show my_kb```-### 方式二:使用 Python 类(已废弃)+### 方式二:Python API```python-from hyperextract.templates.legacy.zh.finance import ResearchNoteSummary+from hyperextract.utils.template_engine import Gallery, TemplateFactoryfrom langchain_openai import ChatOpenAI, OpenAIEmbeddingsllm = ChatOpenAI(model="gpt-4o-mini")embedder = OpenAIEmbeddings()-template = ResearchNoteSummary(llm_client=llm, embedder=embedder)+config = Gallery.get("ResearchNoteSummary")+template = TemplateFactory.create(config, llm, embedder)result = template.parse("苹果Q3营收达到949亿美元...")answer = template.chat("营收增长的原因是什么?")@@ -121,7 +168,11 @@ print(answer.content)```hyperextract/-├── types/ # 8 种 AutoType+├── cli/ # 💻 CLI 接口(he 命令)+│ ├── commands/ # parse, talk, search, show...+│ └── __main__.py # 入口+│+├── types/ # 🧩 8 种知识结构│ ├── model.py # AutoModel│ ├── list.py # AutoList│ ├── set.py # AutoSet@@ -131,20 +182,12 @@ hyperextract/│ ├── spatial_graph.py # AutoSpatialGraph│ └── spatio_temporal_graph.py # AutoSpatioTemporalGraph│-├── methods/ # 提取引擎-│ ├── rag/ # RAG 方法-│ │ ├── light_rag.py-│ │ ├── hyper_rag.py-│ │ └── cog_rag.py-│ └── typical/ # 复现的方法-│ ├── kg_gen.py # KG-Gen-│ └── atom.py # ATOM+├── methods/ # 🔬 提取引擎+│ ├── rag/ # LightRAG, HyperRAG, CogRAG+│ └── typical/ # KG-Gen, ATOM(复现)│-└── templates/ # 领域模板- ├── zh/ # 中文模板- │ ├── finance/ # 25+ 模板- │ ├── medicine/ # 20+ 模板- │ └── ...+└── templates/ # 🌍 200+ 领域模板+ ├── zh/ # 中文模板(25+ 领域)└── en/ # 英文模板```