[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-dylanhogg--llmgraph":3,"tool-dylanhogg--llmgraph":61},[4,18,26,36,44,53],{"id":5,"name":6,"github_repo":7,"description_zh":8,"stars":9,"difficulty_score":10,"last_commit_at":11,"category_tags":12,"status":17},4358,"openclaw","openclaw\u002Fopenclaw","OpenClaw 是一款专为个人打造的本地化 AI 助手，旨在让你在自己的设备上拥有完全可控的智能伙伴。它打破了传统 AI 助手局限于特定网页或应用的束缚，能够直接接入你日常使用的各类通讯渠道，包括微信、WhatsApp、Telegram、Discord、iMessage 等数十种平台。无论你在哪个聊天软件中发送消息，OpenClaw 都能即时响应，甚至支持在 macOS、iOS 和 Android 设备上进行语音交互，并提供实时的画布渲染功能供你操控。\n\n这款工具主要解决了用户对数据隐私、响应速度以及“始终在线”体验的需求。通过将 AI 部署在本地，用户无需依赖云端服务即可享受快速、私密的智能辅助，真正实现了“你的数据，你做主”。其独特的技术亮点在于强大的网关架构，将控制平面与核心助手分离，确保跨平台通信的流畅性与扩展性。\n\nOpenClaw 非常适合希望构建个性化工作流的技术爱好者、开发者，以及注重隐私保护且不愿被单一生态绑定的普通用户。只要具备基础的终端操作能力（支持 macOS、Linux 及 Windows WSL2），即可通过简单的命令行引导完成部署。如果你渴望拥有一个懂你",349277,3,"2026-04-06T06:32:30",[13,14,15,16],"Agent","开发框架","图像","数据工具","ready",{"id":19,"name":20,"github_repo":21,"description_zh":22,"stars":23,"difficulty_score":10,"last_commit_at":24,"category_tags":25,"status":17},3808,"stable-diffusion-webui","AUTOMATIC1111\u002Fstable-diffusion-webui","stable-diffusion-webui 是一个基于 Gradio 构建的网页版操作界面，旨在让用户能够轻松地在本地运行和使用强大的 Stable Diffusion 图像生成模型。它解决了原始模型依赖命令行、操作门槛高且功能分散的痛点，将复杂的 AI 绘图流程整合进一个直观易用的图形化平台。\n\n无论是希望快速上手的普通创作者、需要精细控制画面细节的设计师，还是想要深入探索模型潜力的开发者与研究人员，都能从中获益。其核心亮点在于极高的功能丰富度：不仅支持文生图、图生图、局部重绘（Inpainting）和外绘（Outpainting）等基础模式，还独创了注意力机制调整、提示词矩阵、负向提示词以及“高清修复”等高级功能。此外，它内置了 GFPGAN 和 CodeFormer 等人脸修复工具，支持多种神经网络放大算法，并允许用户通过插件系统无限扩展能力。即使是显存有限的设备，stable-diffusion-webui 也提供了相应的优化选项，让高质量的 AI 艺术创作变得触手可及。",162132,"2026-04-05T11:01:52",[14,15,13],{"id":27,"name":28,"github_repo":29,"description_zh":30,"stars":31,"difficulty_score":32,"last_commit_at":33,"category_tags":34,"status":17},1381,"everything-claude-code","affaan-m\u002Feverything-claude-code","everything-claude-code 是一套专为 AI 编程助手（如 Claude Code、Codex、Cursor 等）打造的高性能优化系统。它不仅仅是一组配置文件，而是一个经过长期实战打磨的完整框架，旨在解决 AI 代理在实际开发中面临的效率低下、记忆丢失、安全隐患及缺乏持续学习能力等核心痛点。\n\n通过引入技能模块化、直觉增强、记忆持久化机制以及内置的安全扫描功能，everything-claude-code 能显著提升 AI 在复杂任务中的表现，帮助开发者构建更稳定、更智能的生产级 AI 代理。其独特的“研究优先”开发理念和针对 Token 消耗的优化策略，使得模型响应更快、成本更低，同时有效防御潜在的攻击向量。\n\n这套工具特别适合软件开发者、AI 研究人员以及希望深度定制 AI 工作流的技术团队使用。无论您是在构建大型代码库，还是需要 AI 协助进行安全审计与自动化测试，everything-claude-code 都能提供强大的底层支持。作为一个曾荣获 Anthropic 黑客大奖的开源项目，它融合了多语言支持与丰富的实战钩子（hooks），让 AI 真正成长为懂上",156033,2,"2026-04-14T23:32:00",[14,13,35],"语言模型",{"id":37,"name":38,"github_repo":39,"description_zh":40,"stars":41,"difficulty_score":32,"last_commit_at":42,"category_tags":43,"status":17},2271,"ComfyUI","Comfy-Org\u002FComfyUI","ComfyUI 是一款功能强大且高度模块化的视觉 AI 引擎，专为设计和执行复杂的 Stable Diffusion 图像生成流程而打造。它摒弃了传统的代码编写模式，采用直观的节点式流程图界面，让用户通过连接不同的功能模块即可构建个性化的生成管线。\n\n这一设计巧妙解决了高级 AI 绘图工作流配置复杂、灵活性不足的痛点。用户无需具备编程背景，也能自由组合模型、调整参数并实时预览效果，轻松实现从基础文生图到多步骤高清修复等各类复杂任务。ComfyUI 拥有极佳的兼容性，不仅支持 Windows、macOS 和 Linux 全平台，还广泛适配 NVIDIA、AMD、Intel 及苹果 Silicon 等多种硬件架构，并率先支持 SDXL、Flux、SD3 等前沿模型。\n\n无论是希望深入探索算法潜力的研究人员和开发者，还是追求极致创作自由度的设计师与资深 AI 绘画爱好者，ComfyUI 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",108322,"2026-04-10T11:39:34",[14,15,13],{"id":45,"name":46,"github_repo":47,"description_zh":48,"stars":49,"difficulty_score":32,"last_commit_at":50,"category_tags":51,"status":17},6121,"gemini-cli","google-gemini\u002Fgemini-cli","gemini-cli 是一款由谷歌推出的开源 AI 命令行工具，它将强大的 Gemini 大模型能力直接集成到用户的终端环境中。对于习惯在命令行工作的开发者而言，它提供了一条从输入提示词到获取模型响应的最短路径，无需切换窗口即可享受智能辅助。\n\n这款工具主要解决了开发过程中频繁上下文切换的痛点，让用户能在熟悉的终端界面内直接完成代码理解、生成、调试以及自动化运维任务。无论是查询大型代码库、根据草图生成应用，还是执行复杂的 Git 操作，gemini-cli 都能通过自然语言指令高效处理。\n\n它特别适合广大软件工程师、DevOps 人员及技术研究人员使用。其核心亮点包括支持高达 100 万 token 的超长上下文窗口，具备出色的逻辑推理能力；内置 Google 搜索、文件操作及 Shell 命令执行等实用工具；更独特的是，它支持 MCP（模型上下文协议），允许用户灵活扩展自定义集成，连接如图像生成等外部能力。此外，个人谷歌账号即可享受免费的额度支持，且项目基于 Apache 2.0 协议完全开源，是提升终端工作效率的理想助手。",100752,"2026-04-10T01:20:03",[52,13,15,14],"插件",{"id":54,"name":55,"github_repo":56,"description_zh":57,"stars":58,"difficulty_score":32,"last_commit_at":59,"category_tags":60,"status":17},4721,"markitdown","microsoft\u002Fmarkitdown","MarkItDown 是一款由微软 AutoGen 团队打造的轻量级 Python 工具，专为将各类文件高效转换为 Markdown 格式而设计。它支持 PDF、Word、Excel、PPT、图片（含 OCR）、音频（含语音转录）、HTML 乃至 YouTube 链接等多种格式的解析，能够精准提取文档中的标题、列表、表格和链接等关键结构信息。\n\n在人工智能应用日益普及的今天，大语言模型（LLM）虽擅长处理文本，却难以直接读取复杂的二进制办公文档。MarkItDown 恰好解决了这一痛点，它将非结构化或半结构化的文件转化为模型“原生理解”且 Token 效率极高的 Markdown 格式，成为连接本地文件与 AI 分析 pipeline 的理想桥梁。此外，它还提供了 MCP（模型上下文协议）服务器，可无缝集成到 Claude Desktop 等 LLM 应用中。\n\n这款工具特别适合开发者、数据科学家及 AI 研究人员使用，尤其是那些需要构建文档检索增强生成（RAG）系统、进行批量文本分析或希望让 AI 助手直接“阅读”本地文件的用户。虽然生成的内容也具备一定可读性，但其核心优势在于为机器",93400,"2026-04-06T19:52:38",[52,14],{"id":62,"github_repo":63,"name":64,"description_en":65,"description_zh":66,"ai_summary_zh":66,"readme_en":67,"readme_zh":68,"quickstart_zh":69,"use_case_zh":70,"hero_image_url":71,"owner_login":72,"owner_name":73,"owner_avatar_url":74,"owner_bio":75,"owner_company":76,"owner_location":77,"owner_email":78,"owner_twitter":72,"owner_website":79,"owner_url":80,"languages":81,"stars":94,"forks":95,"last_commit_at":96,"license":97,"difficulty_score":32,"env_os":98,"env_gpu":99,"env_ram":100,"env_deps":101,"category_tags":108,"github_topics":109,"view_count":32,"oss_zip_url":119,"oss_zip_packed_at":119,"status":17,"created_at":120,"updated_at":121,"faqs":122,"releases":152},7597,"dylanhogg\u002Fllmgraph","llmgraph","Create knowledge graphs with LLMs","llmgraph 是一款利用大语言模型（LLM）自动构建知识图谱的开源工具。它只需提供一个维基百科页面链接作为起点，就能调用 ChatGPT 或其他兼容模型，智能提取实体间的关联信息，并生成结构化的知识网络。\n\n这一工具有效解决了传统知识图谱构建过程中依赖人工梳理、耗时费力且难以扩展的痛点，让从非结构化文本中快速获取系统化世界知识变得简单高效。生成的图谱支持 GraphML、GEXF 以及可交互的 HTML 格式，用户可以直接在浏览器中查看节点间的动态关系。\n\nllmgraph 特别适合开发者、数据科学家及研究人员使用，尤其是那些希望快速验证概念、探索领域知识关联或需要可视化数据关系的团队。普通用户若对特定主题的知识脉络感兴趣，也可通过简单的命令行操作轻松上手。\n\n其技术亮点在于集成了 LiteLLM 库，允许用户灵活切换不同的后端大模型；同时具备缓存机制，支持迭代式地扩展图谱深度而无需重复消耗算力。此外，它还能统计 Token 用量，帮助用户清晰掌控运行成本。无论是用于学术调研还是工程原型开发，llmgraph 都能以极低的门槛提供强大的知识挖掘能力。","# llmgraph\n\n[![License: MIT](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Flicense-MIT-green.svg)](https:\u002F\u002Fopensource.org\u002Flicenses\u002FMIT)\n[![PyPI version](https:\u002F\u002Fbadge.fury.io\u002Fpy\u002Fllmgraph.svg?1)](https:\u002F\u002Fbadge.fury.io\u002Fpy\u002Fllmgraph)\n[![build](https:\u002F\u002Fgithub.com\u002Fdylanhogg\u002Fllmgraph\u002Factions\u002Fworkflows\u002Fpython-poetry-app.yml\u002Fbadge.svg)](https:\u002F\u002Fgithub.com\u002Fdylanhogg\u002Fllmgraph\u002Factions\u002Fworkflows\u002Fpython-poetry-app.yml)\n[![Latest Tag](https:\u002F\u002Fimg.shields.io\u002Fgithub\u002Fv\u002Ftag\u002Fdylanhogg\u002Fllmgraph)](https:\u002F\u002Fgithub.com\u002Fdylanhogg\u002Fllmgraph\u002Ftags)\n[![Downloads](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fdylanhogg_llmgraph_readme_e47afd5f2578.png)](https:\u002F\u002Fpepy.tech\u002Fproject\u002Fllmgraph)\n[![Colab](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002Fdylanhogg\u002Fllmgraph\u002Fblob\u002Fmaster\u002Fnotebooks\u002Fllmgraph_example.ipynb)\n\n\u003C!-- [![Dependencies](https:\u002F\u002Fimg.shields.io\u002Flibrariesio\u002Fgithub\u002Fdylanhogg\u002Fllmgraph)](https:\u002F\u002Flibraries.io\u002Fgithub\u002Fdylanhogg\u002Fllmgraph) -->\n\nCreate knowledge graphs with LLMs.\n\n![example machine learning output](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fdylanhogg_llmgraph_readme_eccee44d5f13.jpg)\n\nllmgraph enables you to create knowledge graphs in [GraphML](http:\u002F\u002Fgraphml.graphdrawing.org\u002F), [GEXF](https:\u002F\u002Fgexf.net\u002F), and HTML formats (generated via [pyvis](https:\u002F\u002Fgithub.com\u002FWestHealth\u002Fpyvis)) from a given source entity Wikipedia page. The knowledge graphs are generated by extracting world knowledge from ChatGPT or other large language models (LLMs) as supported by [LiteLLM](https:\u002F\u002Fgithub.com\u002FBerriAI\u002Flitellm).\n\nFor a background on knowledge graphs see a [youtube overview by Computerphile](https:\u002F\u002Fwww.youtube.com\u002Fwatch?v=PZBm7M0HGzw)\n\n## Features\n\n- Create knowledge graphs, given a source entity.\n- Uses ChatGPT (or another specified LLM) to extract world knowledge.\n- Generate knowledge graphs in HTML, GraphML, and GEXF formats.\n- Many entity types and relationships supported by [customised prompts](https:\u002F\u002Fgithub.com\u002Fdylanhogg\u002Fllmgraph\u002Fblob\u002Fmain\u002Fllmgraph\u002Fprompts.yaml).\n- Cache support to iteratively grow a knowledge graph, efficiently.\n- Outputs `total tokens` used to understand LLM costs (even though a default run is only about 1 cent).\n- Customisable model (default is OpenAI `gpt-5-mini` for speed and cost).\n\n## Installation\n\nYou can install llmgraph using pip, ideally into a Python [virtual environment](https:\u002F\u002Frealpython.com\u002Fpython-virtual-environments-a-primer\u002F#create-it):\n\n```bash\npip install llmgraph\n```\n\nAlternatively, checkout [an example notebook](https:\u002F\u002Fgithub.com\u002Fdylanhogg\u002Fllmgraph\u002Fblob\u002Fmain\u002Fnotebooks\u002Fllmgraph_example.ipynb) that uses llmgraph and you can run directly in Google Colab.\n\n[![Colab](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002Fdylanhogg\u002Fllmgraph\u002Fblob\u002Fmaster\u002Fnotebooks\u002Fllmgraph_example.ipynb)\n\n## Example Output\n\nIn addition to GraphML and GEXF formats, an HTML [pyvis](https:\u002F\u002Fgithub.com\u002FWestHealth\u002Fpyvis) physics enabled graph can be viewed:\n\n### Artificial Intelligence example\n\n![example machine-learning output](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fdylanhogg_llmgraph_readme_d909824b9f48.png)\n\u003Csub>Generate above machine-learning graph:\u003Cbr \u002F>`llmgraph machine-learning \"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FArtificial_intelligence\" --levels 4`\n\u003Cbr \u002F>View entire graph: \u003Ca target=\"_blank\" href=\"https:\u002F\u002Fblog.infocruncher.com\u002Fhtml\u002Fllmgraph\u002Fmachine-learning_artificial-intelligence_v1.0.0_level4_fully_connected.html\">machine-learning_artificial-intelligence_v1.0.0_level4_fully_connected.html\u003C\u002Fa>\u003C\u002Fsub>\n\n## llmgraph Usage\n\n### Example Usage\n\nThe example above was generated with the following command, which requires an `entity_type` and a quoted `entity_wikipedia` souce url:\n\n```bash\nllmgraph machine-learning \"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FArtificial_intelligence\" --levels 3\n```\n\nThis example creates a 3 level graph, based on the given start node `Artificial Intelligence`.\n\nBy default OpenAI is used and you will need to set an environment variable '`OPENAI_API_KEY`' prior to running. See the [OpenAI docs](https:\u002F\u002Fplatform.openai.com\u002Fdocs\u002Fquickstart\u002Fstep-2-setup-your-api-key) for more info. The `total tokens used` is output as the run progresses. For reference this 3 level example used a total of 7,650 gpt-5-mini tokens, which is less than 2 cents as of Oct 2025.\n\nYou can also specify a different LLM provider, including running with a local [ollama](https:\u002F\u002Fgithub.com\u002Fjmorganca\u002Follama) model. You should be able to specify anything supported by [LiteLLM](https:\u002F\u002Fgithub.com\u002FBerriAI\u002Flitellm) as described here: https:\u002F\u002Fdocs.litellm.ai\u002Fdocs\u002Fproviders. Note that the prompts to extract related entities were tested with OpenAI and may not work as well with other models.\n\nLocal [ollama\u002Fllama2](https:\u002F\u002Follama.ai\u002Flibrary\u002Fllama2) model example:\n\n```bash\nllmgraph machine-learning \"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FArtificial_intelligence\" --levels 3 --llm-model ollama\u002Fllama2 --llm-base-url http:\u002F\u002Flocalhost:\u003Cyour_port>\n```\n\nThe `entity_type` sets the LLM prompt used to find related entities to include in the graph. The full list can be seen in [prompts.yaml](https:\u002F\u002Fgithub.com\u002Fdylanhogg\u002Fllmgraph\u002Fblob\u002Fmain\u002Fllmgraph\u002Fprompts.yaml) and include the following entity types:\n\n- `automobile`\n- `book`\n- `computer-game`\n- `concepts-general`\n- `concepts-science`\n- `creative-general`\n- `documentary`\n- `food`\n- `machine-learning`\n- `movie`\n- `music`\n- `people-historical`\n- `podcast`\n- `software-engineering`\n- `tv`\n\n### Required Arguments\n\n- `entity_type` (TEXT): Entity type (e.g. movie)\n- `entity_wikipedia` (TEXT): Full Wikipedia link to the root entity\n\n### Optional Arguments\n\n- `--entity-root` (TEXT): Optional root entity name override if different from the Wikipedia page title [default: None]\n- `--levels` (INTEGER): Number of levels deep to construct from the central root entity [default: 2]\n- `--max-sum-total-tokens` (INTEGER): Maximum sum of tokens for graph generation [default: 200000]\n- `--output-folder` (TEXT): Folder location to write outputs [default: .\u002F_output\u002F]\n- `--llm-model` (TEXT): The model name [default: gpt-5-mini]\n- `--llm-temp` (FLOAT): LLM temperature value [default: 1.0]\n- `--llm-base-url` (TEXT): LLM will use custom base URL instead of the automatic one [default: None]\n- `--version`: Display llmgraph version and exit.\n- `--help`: Show this message and exit.\n\nNote: For gpt-5 models only temperature=1 is supported.\n\n## More Examples of HTML Output\n\nHere are some more examples of the HTML graph output for different entity types and root entities (with commands to generate and links to view full interactive graphs).\n\nInstall llmgraph to create your own knowledge graphs! Feel free to share interesting results in the [issue section](https:\u002F\u002Fgithub.com\u002Fdylanhogg\u002Fllmgraph\u002Fissues\u002Fnew) above with a documentation label :)\n\n### Knowledge graph concept example\n\n![example concepts-general output](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fdylanhogg_llmgraph_readme_3f6c88606b91.png)\n\u003Csub>Command to generate above concepts-general graph:\u003Cbr \u002F>`llmgraph concepts-general \"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FKnowledge_graph\" --levels 4`\n\u003Cbr \u002F>View entire graph: \u003Ca target=\"_blank\" href=\"https:\u002F\u002Fblog.infocruncher.com\u002Fhtml\u002Fllmgraph\u002Fconcepts-general_knowledge-graph_v1.0.0_level4_fully_connected.html\">concepts-general_knowledge-graph_v1.0.0_level4_fully_connected.html\u003C\u002Fa>\u003C\u002Fsub>\n\n### Inception movie example\n\n![example movie output](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fdylanhogg_llmgraph_readme_e4b7b4e8a192.png)\n\u003Csub>Command to generate above movie graph:\u003Cbr \u002F>`llmgraph movie \"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FInception\" --levels 4`\n\u003Cbr \u002F>View entire graph: \u003Ca target=\"_blank\" href=\"https:\u002F\u002Fblog.infocruncher.com\u002Fhtml\u002Fllmgraph\u002Fmovie_inception_v1.0.0_level4_fully_connected.html\">movie_inception_v1.0.0_level4_fully_connected.html\u003C\u002Fa>\u003C\u002Fsub>\n\n### OpenAI company example\n\n![example company output](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fdylanhogg_llmgraph_readme_75ca57b085a4.png)\n\u003Csub>Command to generate above company graph:\u003Cbr \u002F>`llmgraph company \"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FOpenAI\" --levels 4`\n\u003Cbr \u002F>View entire graph: \u003Ca target=\"_blank\" href=\"https:\u002F\u002Fblog.infocruncher.com\u002Fhtml\u002Fllmgraph\u002Fcompany_openai_v1.0.0_level4_fully_connected.html\">company_openai_v1.0.0_level4_fully_connected.html\u003C\u002Fa>\u003C\u002Fsub>\n\n### John von Neumann people example\n\n![example people-historical output](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fdylanhogg_llmgraph_readme_030dcca13163.png)\n\u003Csub>Command to generate above people-historical graph:\u003Cbr \u002F>`llmgraph people-historical \"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FJohn_von_Neumann\" --levels 4`\n\u003Cbr \u002F>View entire graph: \u003Ca target=\"_blank\" href=\"https:\u002F\u002Fblog.infocruncher.com\u002Fhtml\u002Fllmgraph\u002Fpeople-historical_john-von-neumann_v1.0.0_level4_fully_connected.html\">people-historical_john-von-neumann_v1.0.0_level4_fully_connected.html\u003C\u002Fa>\u003C\u002Fsub>\n\n## Example of Prompt Used to Generate Graph\n\nHere is an example of the prompt template, with place holders, used to generate related entities from a given source entity. This is applied recursively to create a knowledge graph, merging duplicated nodes as required.\n\n```\nYou are knowledgeable about {knowledgeable_about}.\nList, in json array format, the top {top_n} {entities} most like '{{entity_root}}'\nwith Wikipedia link, reasons for similarity, similarity on scale of 0 to 1.\nFormat your response in json array format as an array with column names: 'name', 'wikipedia_link', 'reason_for_similarity', and 'similarity'.\nExample response: {{{{\"name\": \"Example {entity}\",\"wikipedia_link\": \"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FExample_{entity_underscored}\",\"reason_for_similarity\": \"Reason for similarity\",\"similarity\": 0.5}}}}\n```\n\nIt works well on the primary tested LLM, being OpenAI gpt-5-mini. Results are ok, but not as good using Llama2. The prompt source of truth and additional details can be see in [prompts.yaml](https:\u002F\u002Fgithub.com\u002Fdylanhogg\u002Fllmgraph\u002Fblob\u002Fmain\u002Fllmgraph\u002Fprompts.yaml).\n\nEach entity type has custom placeholders, for example `concepts-general` and `documentary`:\n\n```\nconcepts-general:\n    system: You are a highly knowledgeable ontologist and creator of knowledge graphs.\n    knowledgeable_about: many concepts and ontologies.\n    entities: concepts\n    entity: concept name\n    top_n: 5\n\ndocumentary:\n    system: You are knowledgeable about documentaries of all types, and genres.\n    knowledgeable_about: documentaries of all types, and genres\n    entities: Documentaries\n    entity: Documentary\n    top_n: 5\n```\n\n## Cached LLM API calls\n\nEach call to the LLM API (and Wikipedia) is cached locally in a `.joblib_cache` folder. This allows an interrupted run to be resumed without duplicating identical calls. It also allows a re-run with a higher `--level` option to re-use results from the lower level run (assuming the same entity type and source).\n\n## Future Improvements\n\n- Contrast graph output from different LLM models (e.g. [Llama2](https:\u002F\u002Fhuggingface.co\u002Fdocs\u002Ftransformers\u002Fmodel_doc\u002Fllama2) vs [Mistral](https:\u002F\u002Fhuggingface.co\u002Fdocs\u002Ftransformers\u002Fmodel_doc\u002Fmistral) vs [ChatGPT-4](https:\u002F\u002Fopenai.com\u002Fchatgpt))\n- Investigate the hypothosis that this approach provides insight into how an LLM views the world.\n- Include more examples in this documentation and make examples available for easy browsing.\n- Instructions for running locally and adding a custom `entity_type` prompt.\n- Better pyviz html output, in particular including reasons for entity relationship in UI and arguments for pixel size etc.\n- Parallelise API calls and result processing.\n- Remove dependency on Wikipedia entities as a source.\n- Contrast results from llmgraphg with other non-LLM graph construction e.g. using wikipedia page links, or [direct article embeddings](https:\u002F\u002Ftxt.cohere.com\u002Fembedding-archives-wikipedia\u002F).\n\n## Contributing\n\nContributions to llmgraph are welcome. Please follow these steps:\n\n1. Fork the repository.\n2. Create a new branch for your feature or bug fix.\n3. Make your changes and commit them.\n4. Create a pull request with a description of your changes.\n\n## Thanks 🙏\n\nThanks to @breitburg for implementing the LiteLLM updates.\n\n## References\n\n- https:\u002F\u002Farxiv.org\u002Fabs\u002F2211.10511 - Knowledge Graph Generation From Text\n- https:\u002F\u002Farxiv.org\u002Fabs\u002F2310.04562 - Towards Foundation Models for Knowledge Graph Reasoning\n- https:\u002F\u002Farxiv.org\u002Fabs\u002F2206.14268 - BertNet: Harvesting Knowledge Graphs with Arbitrary Relations from Pretrained Language Models\n- https:\u002F\u002Farxiv.org\u002Fabs\u002F2312.02783 - Large Language Models on Graphs: A Comprehensive Survey\n- https:\u002F\u002Fgithub.com\u002Faws\u002Fgraph-notebook - Graph Notebook: easily query and visualize graphs\n- https:\u002F\u002Fgithub.com\u002FKiddoZhu\u002FNBFNet-PyG - PyG re-implementation of Neural Bellman-Ford Networks\n- https:\u002F\u002Fcaminao.blog\u002Fknowledge-management-booklet\u002Fa-hitchhikers-guide-to-knowledge-galaxies\u002F - A Hitchhiker’s Guide to Knowledge Galaxies\n- https:\u002F\u002Fgithub.com\u002FPeterGriffinJin\u002FAwesome-Language-Model-on-Graphs - A curated list of papers and resources based on \"Large Language Models on Graphs: A Comprehensive Survey\".\n","# llmgraph\n\n[![许可证：MIT](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Flicense-MIT-green.svg)](https:\u002F\u002Fopensource.org\u002Flicenses\u002FMIT)\n[![PyPI版本](https:\u002F\u002Fbadge.fury.io\u002Fpy\u002Fllmgraph.svg?1)](https:\u002F\u002Fbadge.fury.io\u002Fpy\u002Fllmgraph)\n[![构建](https:\u002F\u002Fgithub.com\u002Fdylanhogg\u002Fllmgraph\u002Factions\u002Fworkflows\u002Fpython-poetry-app.yml\u002Fbadge.svg)](https:\u002F\u002Fgithub.com\u002Fdylanhogg\u002Fllmgraph\u002Factions\u002Fworkflows\u002Fpython-poetry-app.yml)\n[![最新标签](https:\u002F\u002Fimg.shields.io\u002Fgithub\u002Fv\u002Ftag\u002Fdylanhogg\u002Fllmgraph)](https:\u002F\u002Fgithub.com\u002Fdylanhogg\u002Fllmgraph\u002Ftags)\n[![下载量](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fdylanhogg_llmgraph_readme_e47afd5f2578.png)](https:\u002F\u002Fpepy.tech\u002Fproject\u002Fllmgraph)\n[![Colab](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002Fdylanhogg\u002Fllmgraph\u002Fblob\u002Fmaster\u002Fnotebooks\u002Fllmgraph_example.ipynb)\n\n\u003C!-- [![依赖](https:\u002F\u002Fimg.shields.io\u002Flibrariesio\u002Fgithub\u002Fdylanhogg\u002Fllmgraph)](https:\u002F\u002Flibraries.io\u002Fgithub\u002Fdylanhogg\u002Fllmgraph) -->\n\n使用大语言模型创建知识图谱。\n\n![示例机器学习输出](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fdylanhogg_llmgraph_readme_eccee44d5f13.jpg)\n\nllmgraph 允许您根据给定的维基百科源实体页面，以 GraphML、GEXF 和 HTML 格式（通过 pyvis 生成）创建知识图谱。这些知识图谱是通过从 ChatGPT 或其他大型语言模型（LLM）中提取世界知识而生成的，这些模型由 LiteLLM 支持。\n\n有关知识图谱的背景知识，请参阅 Computerphile 的 YouTube 概述：[观看视频](https:\u002F\u002Fwww.youtube.com\u002Fwatch?v=PZBm7M0HGzw)\n\n## 功能\n\n- 根据源实体创建知识图谱。\n- 使用 ChatGPT（或指定的其他 LLM）提取世界知识。\n- 生成 HTML、GraphML 和 GEXF 格式的知识图谱。\n- 支持多种实体类型和关系，可通过[自定义提示词](https:\u002F\u002Fgithub.com\u002Fdylanhogg\u002Fllmgraph\u002Fblob\u002Fmain\u002Fllmgraph\u002Fprompts.yaml)实现。\n- 支持缓存，可高效地迭代扩展知识图谱。\n- 输出“总 token 数”，以便了解 LLM 的成本（尽管默认运行仅需约 1 美分）。\n- 可自定义模型（默认为 OpenAI 的 gpt-5-mini，以兼顾速度和成本）。\n\n## 安装\n\n您可以使用 pip 安装 llmgraph，最好是在 Python [虚拟环境](https:\u002F\u002Frealpython.com\u002Fpython-virtual-environments-a-primer\u002F#create-it) 中：\n\n```bash\npip install llmgraph\n```\n\n或者，您可以查看一个[示例笔记本](https:\u002F\u002Fgithub.com\u002Fdylanhogg\u002Fllmgraph\u002Fblob\u002Fmain\u002Fnotebooks\u002Fllmgraph_example.ipynb)，其中使用了 llmgraph，并且可以直接在 Google Colab 中运行。\n[![Colab](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002Fdylanhogg\u002Fllmgraph\u002Fblob\u002Fmaster\u002Fnotebooks\u002Fllmgraph_example.ipynb)\n\n## 示例输出\n\n除了 GraphML 和 GEXF 格式外，还可以查看一个启用物理引擎的 HTML [pyvis](https:\u002F\u002Fgithub.com\u002FWestHealth\u002Fpyvis) 图：\n\n### 人工智能示例\n\n![示例机器学习输出](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fdylanhogg_llmgraph_readme_d909824b9f48.png)\n\u003Csub>生成上述机器学习图：\u003Cbr \u002F>`llmgraph machine-learning \"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FArtificial_intelligence\" --levels 4`\n\u003Cbr \u002F>查看完整图：[machine-learning_artificial-intelligence_v1.0.0_level4_fully_connected.html](https:\u002F\u002Fblog.infocruncher.com\u002Fhtml\u002Fllmgraph\u002Fmachine-learning_artificial-intelligence_v1.0.0_level4_fully_connected.html)\u003C\u002Fsub>\n\n## llmgraph 使用方法\n\n### 示例用法\n\n上面的示例是通过以下命令生成的，该命令需要一个 `entity_type` 和一个带引号的 `entity_wikipedia` 源 URL：\n\n```bash\nllmgraph machine-learning \"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FArtificial_intelligence\" --levels 3\n```\n\n此示例基于给定的起始节点“人工智能”创建了一个 3 层知识图谱。\n\n默认情况下使用 OpenAI，您需要在运行前设置环境变量 `OPENAI_API_KEY`。更多信息请参阅 [OpenAI 文档](https:\u002F\u002Fplatform.openai.com\u002Fdocs\u002Fquickstart\u002Fstep-2-setup-your-api-key)。运行过程中会输出“使用的总 token 数”。作为参考，这个 3 层示例总共使用了 7,650 个 gpt-5-mini token，截至 2025 年 10 月，费用不到 2 美分。\n\n您也可以指定不同的 LLM 提供商，包括使用本地的 [ollama](https:\u002F\u002Fgithub.com\u002Fjmorganca\u002Follama) 模型。只要支持 [LiteLLM](https:\u002F\u002Fgithub.com\u002FBerriAI\u002Flitellm) 的模型，都可以在这里指定：https:\u002F\u002Fdocs.litellm.ai\u002Fdocs\u002Fproviders。请注意，用于提取相关实体的提示词是针对 OpenAI 测试过的，可能在其他模型上效果不佳。\n\n本地 [ollama\u002Fllama2](https:\u002F\u002Follama.ai\u002Flibrary\u002Fllama2) 模型示例：\n\n```bash\nllmgraph machine-learning \"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FArtificial_intelligence\" --levels 3 --llm-model ollama\u002Fllama2 --llm-base-url http:\u002F\u002Flocalhost:\u003Cyour_port>\n```\n\n`entity_type` 设置了用于查找要包含在图中的相关实体的 LLM 提示词。完整的列表可以在 [prompts.yaml](https:\u002F\u002Fgithub.com\u002Fdylanhogg\u002Fllmgraph\u002Fblob\u002Fmain\u002Fllmgraph\u002Fprompts.yaml) 中查看，包括以下实体类型：\n\n- `automobile`\n- `book`\n- `computer-game`\n- `concepts-general`\n- `concepts-science`\n- `creative-general`\n- `documentary`\n- `food`\n- `machine-learning`\n- `movie`\n- `music`\n- `people-historical`\n- `podcast`\n- `software-engineering`\n- `tv`\n\n### 必需参数\n\n- `entity_type`（文本）：实体类型（例如 movie）\n- `entity_wikipedia`（文本）：根实体的完整维基百科链接\n\n### 可选参数\n\n- `--entity-root`（文本）：如果与维基百科页面标题不同，可覆盖根实体名称 [默认：无]\n- `--levels`（整数）：从中心根实体向外构建的层数 [默认：2]\n- `--max-sum-total-tokens`（整数）：生成图的最大 token 总数 [默认：200000]\n- `--output-folder`（文本）：输出文件的保存路径 [默认：.\u002F_output\u002F]\n- `--llm-model`（文本）：模型名称 [默认：gpt-5-mini]\n- `--llm-temp`（浮点数）：LLM 温度值 [默认：1.0]\n- `--llm-base-url`（文本）：LLM 将使用自定义基础 URL 而不是自动获取的 URL [默认：无]\n- `--version`：显示 llmgraph 版本并退出。\n- `--help`：显示此消息并退出。\n\n注意：对于 gpt-5 模型，仅支持温度=1。\n\n## 更多 HTML 输出示例\n\n以下是不同实体类型和根实体的 HTML 图形输出示例（附有生成命令和查看完整交互式图的链接）。\n\n安装 llmgraph，创建您自己的知识图谱吧！欢迎在上方的 [问题专区](https:\u002F\u002Fgithub.com\u002Fdylanhogg\u002Fllmgraph\u002Fissues\u002Fnew) 分享有趣的成果，并添加文档标签 :)\n\n### 知识图谱概念示例\n\n![概念通用输出示例](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fdylanhogg_llmgraph_readme_3f6c88606b91.png)\n\u003Csub>生成上述概念通用图的命令：\u003Cbr \u002F>`llmgraph concepts-general \"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FKnowledge_graph\" --levels 4`\n\u003Cbr \u002F>查看完整图： \u003Ca target=\"_blank\" href=\"https:\u002F\u002Fblog.infocruncher.com\u002Fhtml\u002Fllmgraph\u002Fconcepts-general_knowledge-graph_v1.0.0_level4_fully_connected.html\">concepts-general_knowledge-graph_v1.0.0_level4_fully_connected.html\u003C\u002Fa>\u003C\u002Fsub>\n\n### 《盗梦空间》电影示例\n\n![电影输出示例](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fdylanhogg_llmgraph_readme_e4b7b4e8a192.png)\n\u003Csub>生成上述电影图的命令：\u003Cbr \u002F>`llmgraph movie \"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FInception\" --levels 4`\n\u003Cbr \u002F>查看完整图： \u003Ca target=\"_blank\" href=\"https:\u002F\u002Fblog.infocruncher.com\u002Fhtml\u002Fllmgraph\u002Fmovie_inception_v1.0.0_level4_fully_connected.html\">movie_inception_v1.0.0_level4_fully_connected.html\u003C\u002Fa>\u003C\u002Fsub>\n\n### OpenAI 公司示例\n\n![公司输出示例](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fdylanhogg_llmgraph_readme_75ca57b085a4.png)\n\u003Csub>生成上述公司图的命令：\u003Cbr \u002F>`llmgraph company \"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FOpenAI\" --levels 4`\n\u003Cbr \u002F>查看完整图： \u003Ca target=\"_blank\" href=\"https:\u002F\u002Fblog.infocruncher.com\u002Fhtml\u002Fllmgraph\u002Fcompany_openai_v1.0.0_level4_fully_connected.html\">company_openai_v1.0.0_level4_fully_connected.html\u003C\u002Fa>\u003C\u002Fsub>\n\n### 约翰·冯·诺依曼人物示例\n\n![历史人物输出示例](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fdylanhogg_llmgraph_readme_030dcca13163.png)\n\u003Csub>生成上述历史人物图的命令：\u003Cbr \u002F>`llmgraph people-historical \"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FJohn_von_Neumann\" --levels 4`\n\u003Cbr \u002F>查看完整图： \u003Ca target=\"_blank\" href=\"https:\u002F\u002Fblog.infocruncher.com\u002Fhtml\u002Fllmgraph\u002Fpeople-historical_john-von-neumann_v1.0.0_level4_fully_connected.html\">people-historical_john-von-neumann_v1.0.0_level4_fully_connected.html\u003C\u002Fa>\u003C\u002Fsub>\n\n## 用于生成图谱的提示示例\n\n以下是用于从给定源实体中提取相关实体的提示模板示例，其中包含占位符。该模板会递归应用以创建知识图谱，并在必要时合并重复节点。\n\n```\n你对{knowledgeable_about}非常熟悉。\n请以 JSON 数组格式列出与 '{{entity_root}}' 最相似的前 {top_n} 个 {entities}，\n并附上维基百科链接、相似原因以及 0 到 1 的相似度评分。\n请将你的回复格式化为包含以下列名的 JSON 数组：'name'、'wikipedia_link'、'reason_for_similarity' 和 'similarity'。\n示例回复：{{{{\"name\": \"示例 {entity}\",\"wikipedia_link\": \"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002F示例_{entity_underscored}\",\"reason_for_similarity\": \"相似原因\",\"similarity\": 0.5}}}}\n```\n\n此提示在主要测试的 LLM（OpenAI gpt-5-mini）上表现良好。使用 Llama2 时效果尚可，但不如前者。该提示的权威来源及更多详细信息可在 [prompts.yaml](https:\u002F\u002Fgithub.com\u002Fdylanhogg\u002Fllmgraph\u002Fblob\u002Fmain\u002Fllmgraph\u002Fprompts.yaml) 中查看。\n\n每种实体类型都有自定义占位符，例如 `concepts-general` 和 `documentary`：\n\n```\nconcepts-general:\n    system: 你是一位博学的本体论专家和知识图谱创建者。\n    knowledgeable_about: 许多概念和本体论。\n    entities: 概念\n    entity: 概念名称\n    top_n: 5\n\ndocumentary:\n    system: 你精通各类纪录片及其流派。\n    knowledgeable_about: 各类纪录片及其流派。\n    entities: 纪录片\n    entity: 纪录片\n    top_n: 5\n```\n\n## 缓存的 LLM API 调用\n\n每次调用 LLM API（以及维基百科）都会被本地缓存在 `.joblib_cache` 文件夹中。这使得中断的运行可以在不重复相同调用的情况下继续进行。同时，这也允许在使用更高 `--level` 选项重新运行时，复用较低级别运行的结果（前提是实体类型和来源相同）。\n\n## 未来改进方向\n\n- 对比不同 LLM 模型生成的图谱输出（例如 [Llama2](https:\u002F\u002Fhuggingface.co\u002Fdocs\u002Ftransformers\u002Fmodel_doc\u002Fllama2)、[Mistral](https:\u002F\u002Fhuggingface.co\u002Fdocs\u002Ftransformers\u002Fmodel_doc\u002Fmistral) 和 [ChatGPT-4](https:\u002F\u002Fopenai.com\u002Fchatgpt)）。\n- 探讨这一方法是否能揭示 LLM 如何理解世界。\n- 在文档中增加更多示例，并提供易于浏览的示例。\n- 提供本地运行说明以及添加自定义 `entity_type` 提示的方法。\n- 改进 pyviz HTML 输出，特别是将实体关系的原因纳入用户界面，并优化像素大小等参数。\n- 并行化 API 调用和结果处理。\n- 移除对维基百科实体作为来源的依赖。\n- 将 llmgraphg 的结果与其他非 LLM 图谱构建方法进行对比，例如利用维基百科页面链接或 [直接文章嵌入](https:\u002F\u002Ftxt.cohere.com\u002Fembedding-archives-wikipedia\u002F)。\n\n## 贡献说明\n\n欢迎为 llmgraph 做出贡献。请按照以下步骤操作：\n\n1. 分支该项目。\n2. 为您的功能或错误修复创建一个新分支。\n3. 进行更改并提交。\n4. 创建包含您更改描述的拉取请求。\n\n## 感谢 🙏\n\n感谢 @breitburg 实现 LiteLLM 更新。\n\n## 参考文献\n\n- https:\u002F\u002Farxiv.org\u002Fabs\u002F2211.10511 - 从文本生成知识图谱\n- https:\u002F\u002Farxiv.org\u002Fabs\u002F2310.04562 - 面向知识图谱推理的基础模型\n- https:\u002F\u002Farxiv.org\u002Fabs\u002F2206.14268 - BertNet：从预训练语言模型中挖掘具有任意关系的知识图谱\n- https:\u002F\u002Farxiv.org\u002Fabs\u002F2312.02783 - 大型语言模型与图：全面综述\n- https:\u002F\u002Fgithub.com\u002Faws\u002Fgraph-notebook - Graph Notebook：轻松查询和可视化图\n- https:\u002F\u002Fgithub.com\u002FKiddoZhu\u002FNBFNet-PyG - PyG 版本的神经贝尔曼-福特网络重实现\n- https:\u002F\u002Fcaminao.blog\u002Fknowledge-management-booklet\u002Fa-hitchhikers-guide-to-knowledge-galaxies\u002F - 知识星系漫游指南\n- https:\u002F\u002Fgithub.com\u002FPeterGriffinJin\u002FAwesome-Language-Model-on-Graphs - 基于“大型语言模型与图：全面综述”整理的论文和资源列表。","# llmgraph 快速上手指南\n\n`llmgraph` 是一个利用大语言模型（LLM）从维基百科页面提取世界知识并生成知识图谱的开源工具。支持输出 GraphML、GEXF 以及可交互的 HTML 格式图谱。\n\n## 环境准备\n\n在开始之前，请确保满足以下要求：\n\n*   **操作系统**：Linux, macOS 或 Windows\n*   **Python 版本**：建议 Python 3.8+\n*   **API Key**：\n    *   默认使用 OpenAI 模型，需设置环境变量 `OPENAI_API_KEY`。\n    *   若使用本地模型（如 Ollama）或其他提供商，需配置相应的服务地址。\n*   **虚拟环境**（推荐）：建议使用 `venv` 或 `conda` 创建独立的 Python 环境以避免依赖冲突。\n\n## 安装步骤\n\n可以通过 pip 直接安装最新稳定版：\n\n```bash\npip install llmgraph\n```\n\n或者，如果您希望直接在浏览器中体验，可以使用 Google Colab 运行官方示例 Notebook：\n[在 Colab 中打开示例](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002Fdylanhogg\u002Fllmgraph\u002Fblob\u002Fmaster\u002Fnotebooks\u002Fllmgraph_example.ipynb)\n\n## 基本使用\n\n### 1. 配置 API Key\n\n在使用默认模型前，请在终端导出您的 OpenAI API Key：\n\n**Linux\u002FmacOS:**\n```bash\nexport OPENAI_API_KEY=\"your-api-key-here\"\n```\n\n**Windows (PowerShell):**\n```powershell\n$env:OPENAI_API_KEY=\"your-api-key-here\"\n```\n\n### 2. 生成知识图谱\n\n运行以下命令即可基于维基百科页面生成图谱。命令需要两个核心参数：**实体类型** 和 **维基百科链接**。\n\n**示例：生成关于“人工智能”的 3 层深度知识图谱**\n\n```bash\nllmgraph machine-learning \"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FArtificial_intelligence\" --levels 3\n```\n\n*   `machine-learning`: 实体类型（告诉 LLM 如何提取相关概念）。\n*   `\"https:\u002F\u002F...\"`: 起始实体的维基百科 URL。\n*   `--levels 3`: 图谱扩展的深度层级（默认为 2）。\n\n执行完成后，工具会在当前目录下的 `_output\u002F` 文件夹中生成文件，包括：\n*   `.html`: 可交互的可视化图谱（推荐使用浏览器打开查看）。\n*   `.graphml` \u002F `.gexf`: 标准图谱数据格式，可用于 Gephi 等专业工具。\n*   控制台会输出消耗的 Token 总数及预估成本。\n\n### 3. 常用参数说明\n\n| 参数 | 说明 | 默认值 |\n| :--- | :--- | :--- |\n| `entity_type` | 实体类型，决定提示词策略 (如: `movie`, `book`, `people-historical`) | 必填 |\n| `entity_wikipedia` | 根节点的维基百科完整链接 | 必填 |\n| `--levels` | 图谱递归生成的层数 | 2 |\n| `--llm-model` | 指定使用的模型 (如: `ollama\u002Fllama2`) | `gpt-5-mini` |\n| `--llm-base-url` | 自定义 LLM 服务地址 (用于本地模型或代理) | None |\n| `--output-folder` | 输出文件保存路径 | `.\u002F_output\u002F` |\n\n### 4. 使用本地模型 (可选)\n\n如果您使用本地部署的 Ollama 模型，可以这样运行：\n\n```bash\nllmgraph machine-learning \"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FArtificial_intelligence\" --levels 3 --llm-model ollama\u002Fllama2 --llm-base-url http:\u002F\u002Flocalhost:11434\n```\n\n> **注意**：自定义提示词主要针对 OpenAI 模型优化，使用其他模型时效果可能略有差异。工具会自动缓存 API 调用结果，中断后可重新运行以续传进度。","某科技公司的知识图谱工程师需要快速构建“量子计算”领域的关联网络，以支持内部研发问答系统的数据底层搭建。\n\n### 没有 llmgraph 时\n- **人工梳理耗时极长**：工程师需手动阅读数十篇维基百科及论文，逐条提取实体与关系，耗时数天才能完成基础骨架。\n- **数据结构难以统一**：不同来源的信息格式杂乱，人工定义节点属性时容易出现标准不一，导致后续图数据库导入频繁报错。\n- **关联深度受限**：受限于精力，通常只能构建 1-2 层浅层关系，难以发现跨领域的深层隐性知识连接。\n- **可视化门槛高**：将整理好的数据转换为可交互的 HTML 或 GraphML 格式，需要额外编写复杂的绘图代码和配置环境。\n\n### 使用 llmgraph 后\n- **自动化极速构建**：只需输入\"quantum-computing\"和维基链接，llmgraph 调用大模型在几分钟内自动提取并生成包含多层级关系的图谱。\n- **标准化输出格式**：直接生成标准的 GraphML、GEXF 及带物理引擎的 HTML 交互文件，无需任何格式转换即可导入 Neo4j 或直接展示。\n- **深度知识挖掘**：通过设置 `--levels` 参数，llmgraph 能轻松扩展至 3-4 层深度，自动发现算法与硬件之间原本被忽略的隐性关联。\n- **成本透明可控**：内置 Token 统计功能，让团队清晰掌握每次构建的 LLM 调用成本（通常仅需几分钱），便于预算管控。\n\nllmgraph 将原本需要数天的人工知识工程工作压缩至分钟级，让开发者能专注于图谱应用而非数据清洗。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fdylanhogg_llmgraph_eccee44d.jpg","dylanhogg","Dylan Hogg","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Fdylanhogg_326e781e.png","Interested in AI, Machine Learning, Data Engineering, Analytics, Statistics, NLP, Distributed computing, Open Source and Futurology.","Infocruncher","Sydney, Australia","dylanhogg@gmail.com","https:\u002F\u002Fwww.awesomepython.org\u002F","https:\u002F\u002Fgithub.com\u002Fdylanhogg",[82,86,90],{"name":83,"color":84,"percentage":85},"Jupyter Notebook","#DA5B0B",73.8,{"name":87,"color":88,"percentage":89},"Python","#3572A5",24.4,{"name":91,"color":92,"percentage":93},"Makefile","#427819",1.9,505,33,"2026-03-30T19:38:53","MIT","Linux, macOS, Windows","非必需。默认使用云端 API (OpenAI\u002FLiteLLM)；若配置本地模型 (如 Ollama)，需根据具体模型决定，文中未指定具体显卡要求。","未说明",{"notes":102,"python":103,"dependencies":104},"该工具主要通过调用 LLM API (如 OpenAI, Ollama) 运行，无需本地部署大型模型。必须设置 'OPENAI_API_KEY' 环境变量或使用 '--llm-base-url' 连接本地服务。支持通过 pip 安装或在 Google Colab 中运行。生成的知识图谱可输出为 GraphML, GEXF 和 HTML 格式。","3.8+",[105,106,107],"litellm","pyvis","joblib",[16,35,14],[110,111,112,113,114,115,116,117,118],"chatgpt","gephi","knowledge-graph","llama2","llm","large-language-model","gexf","graph","graphml",null,"2026-03-27T02:49:30.150509","2026-04-15T08:09:43.701857",[123,128,133,138,143,147],{"id":124,"question_zh":125,"answer_zh":126,"source_url":127},34034,"为什么无法使用 pyvis 直接查看生成的 HTML 文件中的图谱？","生成的 HTML 文件仅用于在浏览器中静态查看，不能作为序列化格式加载到 pyvis 对象中。正确的做法是：首先从同目录下输出的 graphml 或 gexf 文件中加载数据到 networkx 对象，然后再将其加载到 pyvis 中进行显示。\n示例代码逻辑：\n1. 使用 networkx 读取 graphml\u002Fgexf 文件：https:\u002F\u002Fnetworkx.org\u002Fdocumentation\u002Fstable\u002Freference\u002Freadwrite\u002Fgraphml.html\n2. 使用 pyvis 的 from_nx 方法加载：https:\u002F\u002Fpyvis.readthedocs.io\u002Fen\u002Flatest\u002Fdocumentation.html#pyvis.network.Network.from_nx","https:\u002F\u002Fgithub.com\u002Fdylanhogg\u002Fllmgraph\u002Fissues\u002F4",{"id":129,"question_zh":130,"answer_zh":131,"source_url":132},34035,"如何自定义实体类型和提示词（Prompts）？","无需修改 Python 代码，只需编辑 `llmgraph\u002Fprompts.yaml` 文件即可添加自定义实体。例如，添加以下内容：\n```yaml\nkaomitas-new-concept:\n  system: You are highly knowledgeable about things that kaomita likes\n  knowledgeable_about: things that kaomita likes\n  entities: things\n  entity: thing\n  top_n: 5\n```\n然后通过命令行运行：`llmgraph kaomitas-new-concept \"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002F\u003C你的根实体>\"`。\n注意：如果使用 pip 安装版本，可能需要克隆仓库本地运行以确保加载修改后的 yaml 文件，或者找到 pip 安装目录下的 prompts.yaml 进行编辑。","https:\u002F\u002Fgithub.com\u002Fdylanhogg\u002Fllmgraph\u002Fissues\u002F7",{"id":134,"question_zh":135,"answer_zh":136,"source_url":137},34036,"是否支持本地模型（如 Llama.cpp, LM Studio, Ollama）？","支持。该项目通过 LiteLLM 集成，可以指定任何 LiteLLM 支持的 LLM 提供商，包括本地运行的 Ollama 模型。\n配置方法参考：https:\u002F\u002Fdocs.litellm.ai\u002Fdocs\u002Fproviders\n注意：提取相关实体的提示词是针对 OpenAI 模型测试优化的，使用其他模型时效果可能有所不同。","https:\u002F\u002Fgithub.com\u002Fdylanhogg\u002Fllmgraph\u002Fissues\u002F8",{"id":139,"question_zh":140,"answer_zh":141,"source_url":142},34037,"如何在 Windows 系统上运行该项目？有详细教程吗？","项目提供了本地安装说明（见 README Installation 部分）。对于初学者或希望快速体验的用户，推荐使用免费的 Google Colab 笔记本直接运行，无需本地配置环境。\nColab 示例地址：https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002Fdylanhogg\u002Fllmgraph\u002Fblob\u002Fmaster\u002Fnotebooks\u002Fllmgraph_example.ipynb\n如果本地运行遇到困难，建议借助 ChatGPT 或 Claude 等 AI 助手辅助排查环境配置问题。","https:\u002F\u002Fgithub.com\u002Fdylanhogg\u002Fllmgraph\u002Fissues\u002F15",{"id":144,"question_zh":145,"answer_zh":146,"source_url":127},34038,"如何过滤图谱以仅显示特定实体？","虽然 Issue 中未提供直接的代码片段，但维护者指出可以通过加载 graphml\u002Fgexf 文件到 networkx 对象后，利用 networkx 的功能对节点进行过滤，然后再传递给 pyvis 进行渲染。此外，自定义 `prompts.yaml` 中的 `entities` 字段也可以控制提取哪些类型的实体，从而从源头控制图谱内容。",{"id":148,"question_zh":149,"answer_zh":150,"source_url":151},34039,"项目是否支持俄语或其他非英语语言？","目前官方尚未内置俄语支持。维护者欢迎社区贡献，用户可以通过 Fork 仓库并提交 Pull Request (PR) 来添加多语言支持功能。","https:\u002F\u002Fgithub.com\u002Fdylanhogg\u002Fllmgraph\u002Fissues\u002F5",[]]