Skip to content

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

docs: mention removal feature across README/FAQ/Python API; guard non-graph KAs in he remove

yifanfeng9763ebf2538658
diff --git a/README.md b/README.md
index 0701fde..32480df 100644
--- a/README.md
+++ b/README.md
@@ -88,7 +88,7 @@ Hyper-Extract is an intelligent, LLM-powered knowledge extraction and evolution
| 🔷 **8 Knowledge Structures** | From simple Lists to advanced Graphs, Hypergraphs, and Spatio-Temporal Graphs |
| 🧠 **10+ Extraction Engines** | GraphRAG, LightRAG, Hyper-RAG, KG-Gen, and more — ready to use |
| 📝 **80+ YAML Templates** | Zero-code extraction across Finance, Legal, Medical, TCM, Industry, and General domains |
-| 🔄 **Incremental Evolution** | Feed new documents anytime to expand and refine your knowledge base |
+| 🔄 **Incremental Evolution** | Feed new documents anytime, and remove or refine knowledge (`he remove`) as your sources change |
| 📤 **Obsidian Export** | Turn any extracted graph into an Obsidian vault — Markdown notes linked by `[[wikilinks]]` |
## 🎯 What Can You Do With It?
diff --git a/README_ZH.md b/README_ZH.md
index 7b748cc..9796add 100644
--- a/README_ZH.md
+++ b/README_ZH.md
@@ -88,7 +88,7 @@ Hyper-Extract 是一个智能的、由大语言模型(LLM)驱动的知识提
| 🔷 **8 种知识结构** | 从简单的列表到复杂的图谱、超图、时空图谱 |
| 🧠 **10+ 提取引擎** | GraphRAG、LightRAG、Hyper-RAG、KG-Gen 等开箱即用 |
| 📝 **80+ YAML 模板** | 零代码提取,覆盖金融、法律、医疗、中医、工业、通用 6 大领域 |
-| 🔄 **增量演进** | 随时喂入新文档,自动扩展和精炼知识库 |
+| 🔄 **增量演进** | 随时喂入新文档扩展知识库,也支持删除或修正已有知识(`he remove`) |
| 📤 **Obsidian 导出** | 将提取的图谱导出为 Obsidian 知识库——以 `[[双向链接]]` 关联的 Markdown 笔记 |
## 🎯 它能做什么?
diff --git a/docs/en/python/index.md b/docs/en/python/index.md
index fe71bd7..8b7dadb 100644
--- a/docs/en/python/index.md
+++ b/docs/en/python/index.md
@@ -95,6 +95,10 @@ ka = Template.create(template_path, language="en")
result = ka.parse(text) # New extraction
result.feed_text(text) # Add to existing
+# Delete (graph-family KAs)
+result.remove_nodes("Apple") # Hard-delete a node + its orphan edges
+report = result.edit_node("Apple", remove_fact="...", dry_run=True) # Soft-remove one fact
+
# Query
result.build_index() # Build search index
results = result.search(query) # Semantic search
diff --git a/docs/en/resources/faq.md b/docs/en/resources/faq.md
index dba125a..386da1d 100644
--- a/docs/en/resources/faq.md
+++ b/docs/en/resources/faq.md
@@ -151,6 +151,19 @@ he parse ./docs/ -t general/graph -o ./ka/ -l en
he parse doc.md -t general/biography_graph -l zh
```
+### How do I delete knowledge from an existing KA?
+
+```bash
+# Hard-delete a node (edges anchored by it are removed too)
+he remove ./ka/ --node Apple
+
+# Soft-remove one wrong/obsolete fact, keeping the rest of the node
+he remove ./ka/ --edit-node Apple --fact "founded by Steve Jobs" --dry-run
+he remove ./ka/ --edit-node Apple --fact "founded by Steve Jobs" -y
+```
+
+Soft delete uses the LLM to rewrite the item under the same schema, with a key-invariance check and an automatic `data.json` backup. To delete **everything a specific document contributed**, rebuild the KA without that document — per-document provenance tracking is not implemented yet. See [`he remove`](../cli/commands/remove.md).
+
---
## Performance
diff --git a/docs/zh/python/index.md b/docs/zh/python/index.md
index d3a6340..ad7834d 100644
--- a/docs/zh/python/index.md
+++ b/docs/zh/python/index.md
@@ -95,6 +95,10 @@ ka = Template.create(template_path, language="zh")
result = ka.parse(text) # 新提取
result.feed_text(text) # 添加到现有
+# 删除(图谱类 KA)
+result.remove_nodes("Apple") # 硬删除节点及其孤儿边
+report = result.edit_node("Apple", remove_fact="...", dry_run=True) # 软删除单条事实
+
# 查询
result.build_index() # 构建搜索索引
results = result.search(query) # 语义搜索
diff --git a/docs/zh/resources/faq.md b/docs/zh/resources/faq.md
index edb9a19..feb711e 100644
--- a/docs/zh/resources/faq.md
+++ b/docs/zh/resources/faq.md
@@ -151,6 +151,19 @@ he parse ./docs/ -t general/graph -o ./ka/ -l zh
he parse doc.md -t general/biography_graph -l zh
```
+### 如何从已有知识摘要中删除知识?
+
+```bash
+# 硬删除节点(以其为端点的边会一并删除)
+he remove ./ka/ --node Apple
+
+# 软删除节点中一条错误/过时的事实,其余内容保留
+he remove ./ka/ --edit-node Apple --fact "founded by Steve Jobs" --dry-run
+he remove ./ka/ --edit-node Apple --fact "founded by Steve Jobs" -y
+```
+
+软删除由大模型在相同 schema 下重写条目,带 key 不变性校验和自动 `data.json` 备份。若要删除**某份文档贡献的全部知识**,请去掉该文档后重建 KA——按文档溯源删除尚未实现。详见 [`he remove`](../cli/commands/remove.md)。
+
---
## 性能问题
diff --git a/hyperextract/cli/cli.py b/hyperextract/cli/cli.py
index 8849eb5..ced2123 100644
--- a/hyperextract/cli/cli.py
+++ b/hyperextract/cli/cli.py
@@ -1014,6 +1014,16 @@ def remove_items(
ka = Template.create(template, lang)
ka.load(path)
+ if not hasattr(ka, "remove_nodes"):
+ console.print(
+ f"[red]Error:[/red] `he remove` supports graph-family knowledge "
+ f"abstracts (graph / hypergraph / temporal / spatial). "
+ f"'{template}' produced a {type(ka).__name__}, which does not "
+ "support keyed deletion. For lists/sets, use the Python API "
+ "`ka.remove(item)`; or rebuild the KA with `he clean --all`."
+ )
+ raise typer.Exit(1)
+
try:
if hard_targets:
report = {}
diff --git a/tests/cli/test_remove.py b/tests/cli/test_remove.py
index 97774d4..b91291c 100644
--- a/tests/cli/test_remove.py
+++ b/tests/cli/test_remove.py
@@ -201,3 +201,29 @@ class TestArgumentValidation:
result = runner.invoke(app, ["remove", str(ka)])
assert result.exit_code == 0
assert "Nothing to do" in result.output
+
+
+class TestNonGraphKa:
+ def test_list_ka_gets_friendly_error(self, tmp_path, monkeypatch):
+ """List/set/model KAs don't support keyed deletion — say so clearly."""
+ from hyperextract.types import AutoList
+
+ class Item(BaseModel):
+ name: str
+
+ g = AutoList(
+ item_schema=Item,
+ llm_client=MockChatModel(),
+ embedder=MockEmbeddings(),
+ )
+ g.metadata["template"] = "general/list"
+ g.metadata["lang"] = "en"
+ ka = tmp_path / "ka"
+ g.dump(ka)
+ monkeypatch.setattr(climod.Template, "create", staticmethod(lambda *a, **k: g))
+
+ result = runner.invoke(app, ["remove", str(ka), "--node", "Apple", "-y"])
+
+ assert result.exit_code == 1
+ assert "graph-family" in result.output
+ assert "AutoList" in result.output