能力标签
Claude技能

知识图谱提取

基于 Python · 专为 Claude 深度优化,CLI 一键安装
英文名:mykg
⭐ 39 Stars 🍴 10 Forks 💻 Python 📄 MIT 🏷 AI 8.0分
8.0AI 综合评分
claude_skillai_agent知识图谱
✦ AI Skill Hub 推荐

知识图谱提取 是 AI Skill Hub 本期精选Claude技能之一。综合评分 8.0 分,整体质量较高。我们强烈推荐将其纳入你的 AI 工具库,帮助提升工作效率。

📚 深度解析

知识图谱提取 是一款基于 Python 的开源工具,在 GitHub 上收获 0k+ Star,是claude_skill、ai_agent、知识图谱领域中的优质开源项目。开源工具的最大优势在于代码完全透明,你可以审计每一行代码的安全性,也可以根据自身需求进行二次开发和定制。

**为什么要使用开源工具而非商业 SaaS?**
对于个人开发者和有隐私需求的用户,本地部署的开源工具意味着数据不离本机,不受第三方服务商的数据政策约束。同时,开源工具通常没有使用次数限制和月度费用,一次安装即可长期使用,对于高频使用场景的总拥有成本(TCO)远低于订阅制商业工具。

**安装与环境准备**
知识图谱提取 依赖 Python 运行环境。建议通过 pyenv(Python)或 nvm(Node.js)管理 Python 版本,避免全局环境污染。对于新手用户,推荐先创建虚拟环境(python -m venv venv && source venv/bin/activate),再安装依赖,这样即使出现问题也可以随时删除虚拟环境重新开始,不影响系统稳定性。

**社区与维护**
GitHub Issue 和 Discussion 是获取帮助的最快渠道。在提问前建议先检查 Closed Issues(已关闭的问题),大多数常见问题都已有解答。遇到 Bug 时,提供 pip list 的输出、完整错误堆栈和最小可复现示例,能显著提高开发者响应速度。AI Skill Hub 将持续追踪 知识图谱提取 的版本更新,及时通知重要功能变化。

📋 工具概览

知识图谱提取 是一款基于 Python 开发的开源工具,专注于 claude_skill、ai_agent、知识图谱 等核心功能。作为 GitHub 开源项目,它拥有活跃的社区支持和持续的版本迭代,代码完全透明可审计,支持本地部署以保护数据隐私。无论是个人使用还是集成到企业工作流,都能提供稳定可靠的解决方案。

GitHub Stars
⭐ 39
开发语言
Python
支持平台
Windows / macOS / Linux
维护状态
轻量级项目,按需更新
开源协议
MIT
AI 综合评分
8.0 分
工具类型
Claude技能
Forks
10

📖 中文文档

以下内容由 AI Skill Hub 根据项目信息自动整理,如需查看完整原始文档请访问底部「原始来源」。

知识图谱提取 是一款基于 Python 开发的开源工具,专注于 claude_skill、ai_agent、知识图谱 等核心功能。作为 GitHub 开源项目,它拥有活跃的社区支持和持续的版本迭代,代码完全透明可审计,支持本地部署以保护数据隐私。无论是个人使用还是集成到企业工作流,都能提供稳定可靠的解决方案。

📌 核心特色
  • 专为 Claude 系列模型深度优化的扩展技能
  • 通过 Claude Code CLI 一键安装,配置零门槛
  • 充分利用 Claude 的长上下文和推理能力
  • 支持与 MCP 工具组合使用,扩展能力边界
🎯 主要使用场景
  • 在 Claude 中快速解决特定专业领域的问题
  • 复杂任务的 AI 辅助分析、推理和报告生成
  • 构建个人专属的 AI 技能工具箱
以下安装命令基于项目开发语言和类型自动生成,实际以官方 README 为准。
安装命令
# 方式一: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('安装成功')"
📋 安装步骤说明
  1. 访问 GitHub 仓库页面
  2. 按照 README 文档完成依赖安装
  3. 根据系统环境完成初始化配置
  4. 参考官方示例或文档开始使用
  5. 遇到问题可在 GitHub Issues 中查找解答
以下用法示例由 AI Skill Hub 整理,涵盖最常见的使用场景。
常用命令 / 代码示例
# 命令行使用
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"
📑 README 深度解析 真实文档 完整度 82/100 查看 GitHub 原文 →
以下内容由系统直接从 GitHub README 解析整理,保留代码块、表格与列表结构。

简介

<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>

Features

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.

Requires OPENROUTER_API_KEY in environment or .env.mykg (see sample.env.mykg)

uv run pytest -m live -v

Install from PyPI

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 from source

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/

source installs: uv run mykg extract-graph <input_dir> [OPTIONS]

```

<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)
  • All extensions listed under 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.

Installation

git clone https://github.com/SenolIsci/mykg && cd mykg
uv sync

Ontology-Guided Extraction

- 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>

Quick Start

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.

Articles & Tutorials

Walkthroughs and case studies on Medium:

Examples

```bash

Example

mykg merge-graphs 2026-05-01T10-00-00 2026-05-15T14-30-00

Configuration

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:

  1. Profile — choose your LLM provider (OpenRouter, Anthropic, OpenAI, Ollama, Claude CLI, or Agent / Claude Code skill)
  2. Model — accept the default or type any model slug for that provider (skipped in agent mode — the host Claude Code session is the LLM)
  3. API key — paste your key (skipped for Ollama, Claude CLI, and agent mode)

.env.mykg

ANTHROPIC_API_KEY=sk-ant-... ``` For source installs you can also copy sample.env.mykg to .env.mykg as a starting template.

Options

OptionDescription
--session NAMEResume an existing session by folder name
--from-step NAMEDelete a step's outputs and re-run from that point
--reviewPause after Pass 1 for manual schema review
--appendSkip Pass 1; re-run only on new/modified files
--append-with-grow-schemaLike --append, but runs a locked Pass 1 over changed files to expand the schema
--workers NParallel workers for Pass 2
--confidence-agg mean\|maxConfidence aggregation when deduplicating
--base-schema PATHLocked TBox TTL file (locked classes/properties cannot be changed by the LLM)
--thesaurus PATHSKOS TTL thesaurus for synonym resolution in schema merge
--obsidian-vaultForce Obsidian vault export for this run (overrides config)
--neo4j-csvForce Neo4j LOAD CSV bundle export for this run (overrides config)
--log-file PATHWrite logs here (relative paths placed inside the session folder)
--verbose / -vEnable DEBUG-level logging

Advanced Options

Shallow-clone a GitHub repo (git clone --depth 1, no Crawlee/venv)

mykg fetch-web https://github.com/SenolIsci/mykg mykg extract-graph ./mykg_web_fetch/github.com_SenolIsci_mykg/input/

Hitting API Rate Limits (HTTP 429)

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 calls
  • pass2.max_workers — concurrent per-file extraction calls
  • orphan_pass.max_workers — concurrent orphan-connection calls

Lower these (e.g. from 8 down to 24) 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).

API Keys

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

claude-cli profile

myKG ships with a claude-cli profile that runs extractions through the locally-installed claude CLI.

Setup

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/

How it works

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

Using myKG from inside Claude Code Session

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

Then reference the output in your session:

All non-live tests (fast, no API key needed)

uv run pytest -m "not live" -v

All tests including live API integration tests

Extract Pipeline

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.

Pipeline Steps

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.

#StepLLMKey outputs
1preprocesspreprocess.done, preprocess_manifest.json, files under input/_preprocessed/ *(routes non-md inputs to MinerU, markdownify, or rename; no-op for pure Markdown corpora)*
2ingestfile_manifest.json
3pass1✓ (3 calls)schema.json, schema.ttl, schema_history/
4schema_validateschema_validate.done
5human_reviewschema_approved.flag *(only with --review)*
6schema_flattenflattened_schema.json
7pass2raw_extractions.json, chunk_node_index.json
8normalize_namesname_normalization.json
9assembleedge_metadata.json, nodes.json, merge_log.json
10orphan_scoreorphan_candidates.json
11orphan_connectorphan_connections.json, orphan_log.json
12validate_graphnodes.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.

→ pipeline halts; edit mykg_sessions/<name>/intermediate/schema.json

mykg approve-schema --session <name> mykg extract-graph my_notes/ --session <name> --review # resumes from Pass 2 ```

🎯 aiskill88 AI 点评 A 级 2026-06-28

高质量的知识图谱提取工具

⚡ 核心功能

👥 适合人群

Claude 重度用户AI 研究者和开发者需要专业领域 AI 增强的专家

🎯 使用场景

  • 在 Claude 中快速解决特定专业领域的问题
  • 复杂任务的 AI 辅助分析、推理和报告生成
  • 构建个人专属的 AI 技能工具箱

⚖️ 优点与不足

✅ 优点
  • +MIT 协议,可免费商用
  • +深度优化 Claude 使用体验
  • +CLI 一键安装,极度便捷
  • +官方支持,稳定可靠
⚠️ 不足
  • 仅限 Claude 用户使用,受平台限制
  • 功能边界受当前 Claude 模型能力约束
⚠️ 使用须知

AI Skill Hub 为第三方内容聚合平台,本页面信息基于公开数据整理,不对工具功能和质量作任何法律背书。

建议在沙箱或测试环境中充分验证后,再部署至生产环境,并做好必要的安全评估。

📄 License 说明

✅ MIT 协议 — 最宽松的开源协议之一,可自由商用、修改、分发,仅需保留版权声明。

🔗 相关工具推荐

🧩 你可能还需要
基于当前 Skill 的能力图谱,自动补全的工具组合

❓ 常见问题 FAQ

参考项目README文档
💡 AI Skill Hub 点评

经综合评估,知识图谱提取 在Claude技能赛道中表现稳健,质量优秀。如果你已有明确的使用需求,可以直接上手体验;如果还在评估阶段,建议对比同类工具后再做决策。

⬇️ 获取与下载
⬇ 下载源码 ZIP

✅ MIT 协议 · 可免费商用 · 直接从 aiskill88 服务器下载,无需跳转 GitHub

📚 深入学习 知识图谱提取
查看分步骤安装教程和完整使用指南,快速上手这款工具
🌐 原始信息
原始名称 mykg
Topics claude_skillai_agent知识图谱
GitHub https://github.com/SenolIsci/mykg
License MIT
语言 Python
🔗 原始来源
🐙 GitHub 仓库  https://github.com/SenolIsci/mykg

收录时间:2026-06-28 · 更新时间:2026-06-28 · License:MIT · AI Skill Hub 不对第三方内容的准确性作法律背书。

📺 订阅 AI Skill Hub Daily Telegram 频道
每天 8 条精选 AI Skill、MCP、Agent 与自动化工具推送
加入频道 →