知识图谱提取 是 AI Skill Hub 本期精选Claude技能之一。综合评分 8.0 分,整体质量较高。我们强烈推荐将其纳入你的 AI 工具库,帮助提升工作效率。
知识图谱提取 是一款基于 Python 开发的开源工具,专注于 claude_skill、ai_agent、知识图谱 等核心功能。作为 GitHub 开源项目,它拥有活跃的社区支持和持续的版本迭代,代码完全透明可审计,支持本地部署以保护数据隐私。无论是个人使用还是集成到企业工作流,都能提供稳定可靠的解决方案。
知识图谱提取 是一款基于 Python 开发的开源工具,专注于 claude_skill、ai_agent、知识图谱 等核心功能。作为 GitHub 开源项目,它拥有活跃的社区支持和持续的版本迭代,代码完全透明可审计,支持本地部署以保护数据隐私。无论是个人使用还是集成到企业工作流,都能提供稳定可靠的解决方案。
# 方式一:pip 安装(推荐)
pip install mykg
# 方式二:虚拟环境安装(推荐生产环境)
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install mykg
# 方式三:从源码安装(获取最新功能)
git clone https://github.com/SenolIsci/mykg
cd mykg
pip install -e .
# 验证安装
python -c "import mykg; print('安装成功')"
# 命令行使用
mykg --help
# 基本用法
mykg input_file -o output_file
# Python 代码中调用
import mykg
# 示例
result = mykg.process("input")
print(result)
# mykg 配置文件示例(config.yml) app: name: "mykg" debug: false log_level: "INFO" # 运行时指定配置文件 mykg --config config.yml # 或通过环境变量配置 export MYKG_API_KEY="your-key" export MYKG_OUTPUT_DIR="./output"
<p align="center"> <img src="https://gcore.jsdelivr.net/gh/SenolIsci/mykg@main/docs/mykg-logo-text.svg" width="400px" style="vertical-align:middle;"> </p>
MyKG builds trustworthy knowledge graphs through a self-evolving ontology that continuously adapts, maintains consistency, and assigns confidence scores to knowledge, keeping information grounded and reliable as it grows.
uv run pytest -m live -v
Install mykg, then run the interactive setup wizard — it asks for your provider, model, and API key and writes mykg_config.yaml and .env.mykg in one step.
pip install mykg
mykg init
Then extract a knowledge graph from your notes:
mykg extract-graph my_notes/
Open mykg_sessions/<timestamp>/output/knowledge_graph.html in your browser to explore the result.
Install uv, clone the repo, sync dependencies, run the setup wizard, then extract.
git clone https://github.com/SenolIsci/mykg && cd mykg
uv sync && uv run mykg init --force
Then extract a knowledge graph from your notes:
uv run mykg extract-graph my_notes/
For Ollama (local inference, no API key needed), pull a model and select the ollama-local profile when mykg init prompts you.
ollama pull llama3.3
mykg init
mykg extract-graph my_notes/
```
<input_dir> is any directory containing your source files. Subdirectories are included recursively. Only files matching the configured extensions are copied into the session:
.md — always included (the pipeline's native format)preprocess.extensions in mykg_config.yaml (.pdf, .docx, .doc, .pptx, .xlsx, .png, .jpg, .jpeg, .html, .htm, .txt by default)Everything else (.py, .json, .yaml, lock files, etc.) is ignored. Hidden directories (.venv, .git, etc.) and the sessions folder are also excluded automatically, so you can safely point extract-graph at the project root or any parent directory.
git clone https://github.com/SenolIsci/mykg && cd mykg
uv sync
- Schema-guided knowledge graph generation — the extracted graph is always grounded in a formal RDFS/OWL schema: concept types, property names, domain/range constraints, and the is-a hierarchy are explicit and inspectable before any entity is extracted - Bring your own ontology — supply a --base-schema TTL file to lock in classes and properties from an existing formal ontology; the LLM expands it with domain-specific concepts but cannot rename, remove, or contradict your authoritative vocabulary - SKOS thesaurus support — pass --thesaurus to load a SKOS vocabulary; skos:exactMatch terms are collapsed silently, skos:closeMatch terms trigger a warning — giving the schema merger richer synonym awareness than string matching alone - Verifiable TTL ontology — after Pass 1, the induced schema is exported as a valid RDFS/OWL Turtle file (intermediate/schema.ttl) that can be opened directly in ontology editors such as Protégé. The TTL is validated by rdflib (syntax + semantic checks: domain/range refer to declared classes, no conflicting ranges) before any extraction begins - Human-in-the-loop ontology design — run with --review to pause after schema induction; inspect and edit schema.json (or load schema.ttl in Protégé, modify, and save back) before a single entity is extracted; resume with mykg approve-schema - Incremental updates — append new files to an existing session, extracting only what changed. Optionally grow the schema from new documents while preserving existing concepts and properties - AI coding assistant friendly — designed for smooth use alongside AI coding assistants such as Claude Code; run extractions, inspect outputs, and iterate on your knowledge graph without leaving your coding environment; see Using mykg with Claude Code - Second brain for AI coding assistants — the Obsidian vault output turns your extracted knowledge graph into a directory of wikilinked Markdown notes that any AI coding assistant can read as project context; point Claude Code, Cursor, or Copilot at output/obsidian_vault/ and ask questions, trace relationships, and get answers grounded in your own documents - MCP server for desktop AI apps — run mykg mcp-serve to expose your knowledge graph via the Model Context Protocol; integrates with Claude Desktop, Cherry Studio, and any MCP-compatible client — 13 query tools let LLMs search entities, explore relationships, find paths, traverse the graph, and read wiki notes directly from your extracted knowledge; see MCP Server <p align="center"> <img src="https://gcore.jsdelivr.net/gh/SenolIsci/mykg@main/docs/diagrams/architecture-sketch.png" width="95%" style="vertical-align:middle;"> </p>
Requires Python 3.11+ (developed on macOS; automated CI runs the test suite on Linux/Ubuntu — Windows is not actively tested), and one of: an Anthropic/OpenAI/OpenRouter API key, Ollama running locally, or the claude CLI.
Walkthroughs and case studies on Medium:
```bash
mykg merge-graphs 2026-05-01T10-00-00 2026-05-15T14-30-00
All configuration lives in a single mykg_config.yaml file discovered automatically from the working directory (or any parent). There are no hardcoded defaults in the code — the YAML is the sole source of truth.
mykg init # interactive: choose provider, model, paste API key
# writes mykg_config.yaml and .env.mykg in one step
mykg init --force # overwrite an existing config
mykg init --profile openrouter-free --model google/llama-4-maverick --api-key sk-or-... # non-interactive
The wizard walks you through three prompts:
ANTHROPIC_API_KEY=sk-ant-... ``` For source installs you can also copy sample.env.mykg to .env.mykg as a starting template.
| Option | Description |
|---|---|
--session NAME | Resume an existing session by folder name |
--from-step NAME | Delete a step's outputs and re-run from that point |
--review | Pause after Pass 1 for manual schema review |
--append | Skip Pass 1; re-run only on new/modified files |
--append-with-grow-schema | Like --append, but runs a locked Pass 1 over changed files to expand the schema |
--workers N | Parallel workers for Pass 2 |
--confidence-agg mean\|max | Confidence aggregation when deduplicating |
--base-schema PATH | Locked TBox TTL file (locked classes/properties cannot be changed by the LLM) |
--thesaurus PATH | SKOS TTL thesaurus for synonym resolution in schema merge |
--obsidian-vault | Force Obsidian vault export for this run (overrides config) |
--neo4j-csv | Force Neo4j LOAD CSV bundle export for this run (overrides config) |
--log-file PATH | Write logs here (relative paths placed inside the session folder) |
--verbose / -v | Enable DEBUG-level logging |
mykg fetch-web https://github.com/SenolIsci/mykg mykg extract-graph ./mykg_web_fetch/github.com_SenolIsci_mykg/input/
If you see repeated 429 errors during pass1, pass2, or the orphan-connection pass, your account's requests-per-minute limit is lower than the number of concurrent calls mykg is making. Each profile sets these independently under pipeline::
pass1.max_workers — concurrent schema-induction batch callspass2.max_workers — concurrent per-file extraction callsorphan_pass.max_workers — concurrent orphan-connection callsLower these (e.g. from 8 down to 2–4) in the active profile to reduce concurrent requests. This is especially likely on openrouter-free (free-tier models have very low per-minute caps) and on lower-tier anthropic-claude/openai accounts. llm.retry_429_max / llm.retry_429_base_delay control automatic backoff on a 429, but per Invariant 13 a persistent 429 is a signal to reduce max_workers, not just retry harder. claude-cli and agent-claude-code are unaffected — both are serial by design (max_workers: 1).
myKG reads API keys from environment variables. Set them by exporting directly or by creating a .env.mykg file in your project directory (loaded automatically on startup).
Option A — export in your shell:
export ANTHROPIC_API_KEY=sk-ant-...
Option B — create a .env.mykg file:
```bash
myKG ships with a claude-cli profile that runs extractions through the locally-installed claude CLI.
Install the claude CLI, then install mykg and run the setup wizard — select [5] Claude CLI when prompted.
npm install -g @anthropic-ai/claude-code
pip install mykg && mykg init
mykg extract-graph my_notes/
The claude-cli provider calls claude -p as a subprocess for every LLM step (Pass 1 schema induction, Pass 2 extraction, orphan connection, name normalization). All pipeline features — session isolation, resumability, orphan recovery, cross-session merge — work identically to API-based providers.
Key constraints of the claude-cli profile: - max_workers must be 1 — the claude CLI is serial by design; parallel workers will queue - The effort and model fields in mykg_config.yaml map directly to --effort and --model flags passed to claude -p
You can run myKG extractions as a tool call from within a Claude Code session. This is useful for building knowledge graphs from notes or documentation while you work:
```bash
uv run pytest -m "not live" -v
Reads a directory of mixed format files and produces a typed knowledge graph in three output formats. The pipeline runs 12 sequential steps; all intermediate state is persisted so any step can be re-entered without repeating upstream work.
The pipeline runs 12 steps in sequence. All intermediate state is written to disk so any step can be re-entered without repeating upstream work.
| # | Step | LLM | Key outputs |
|---|---|---|---|
| 1 | preprocess | — | preprocess.done, preprocess_manifest.json, files under input/_preprocessed/ *(routes non-md inputs to MinerU, markdownify, or rename; no-op for pure Markdown corpora)* |
| 2 | ingest | — | file_manifest.json |
| 3 | pass1 | ✓ (3 calls) | schema.json, schema.ttl, schema_history/ |
| 4 | schema_validate | — | schema_validate.done |
| 5 | human_review | — | schema_approved.flag *(only with --review)* |
| 6 | schema_flatten | — | flattened_schema.json |
| 7 | pass2 | ✓ | raw_extractions.json, chunk_node_index.json |
| 8 | normalize_names | ✓ | name_normalization.json |
| 9 | assemble | — | edge_metadata.json, nodes.json, merge_log.json |
| 10 | orphan_score | — | orphan_candidates.json |
| 11 | orphan_connect | ✓ | orphan_connections.json, orphan_log.json |
| 12 | validate_graph | — | nodes.jsonl, edges.jsonl, knowledge_graph.ttl, knowledge_graph.html, networkx_output/, obsidian_vault/, neo4j_csv/ *(optional)* |
Pass 1 internally runs four sequential stages: parallel batch induction → algorithmic merge → harmonization LLM call → quality review LLM call.
mykg approve-schema --session <name> mykg extract-graph my_notes/ --session <name> --review # resumes from Pass 2 ```
高质量的知识图谱提取工具
AI Skill Hub 为第三方内容聚合平台,本页面信息基于公开数据整理,不对工具功能和质量作任何法律背书。
建议在沙箱或测试环境中充分验证后,再部署至生产环境,并做好必要的安全评估。
✅ MIT 协议 — 最宽松的开源协议之一,可自由商用、修改、分发,仅需保留版权声明。
经综合评估,知识图谱提取 在Claude技能赛道中表现稳健,质量优秀。如果你已有明确的使用需求,可以直接上手体验;如果还在评估阶段,建议对比同类工具后再做决策。
| 原始名称 | mykg |
| Topics | claude_skillai_agent知识图谱 |
| GitHub | https://github.com/SenolIsci/mykg |
| License | MIT |
| 语言 | Python |
收录时间:2026-06-28 · 更新时间:2026-06-28 · License:MIT · AI Skill Hub 不对第三方内容的准确性作法律背书。
选择 Agent 类型,复制安装指令后粘贴到对应客户端