知识图谱从0到1:AI应用开发的核心技术
你是否遇到过这些问题?
- 听过知识图谱,但不知道具体是什么?
- 不清楚知识图谱在AI开发中有什么用?
- 想学习知识图谱,但不知道从哪里开始?
- 面试时被问到知识图谱,只能泛泛而谈?
别担心!这篇文章带你从0到1彻底搞懂知识图谱,掌握其在AI应用开发中的核心价值!
📚 目录
- 一、什么是知识图谱?
- 二、知识图谱的核心组成
- 三、知识图谱 vs 其他数据结构
- 四、知识图谱的构建方法
- 五、知识图谱在AI应用中的意义
- 六、知识图谱的实战实现
- 七、最新技术与发展趋势
- 八、面试问答全解析
一、什么是知识图谱?
1.1 从生活场景理解知识图谱
想象你在搜索引擎中输入"李白的诗":
#mermaid-svg-tDa0GOxQbVtt4WIQ{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-tDa0GOxQbVtt4WIQ .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-tDa0GOxQbVtt4WIQ .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-tDa0GOxQbVtt4WIQ .error-icon{fill:#552222;}#mermaid-svg-tDa0GOxQbVtt4WIQ .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-tDa0GOxQbVtt4WIQ .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-tDa0GOxQbVtt4WIQ .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-tDa0GOxQbVtt4WIQ .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-tDa0GOxQbVtt4WIQ .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-tDa0GOxQbVtt4WIQ .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-tDa0GOxQbVtt4WIQ .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-tDa0GOxQbVtt4WIQ .marker{fill:#333333;stroke:#333333;}#mermaid-svg-tDa0GOxQbVtt4WIQ .marker.cross{stroke:#333333;}#mermaid-svg-tDa0GOxQbVtt4WIQ svg{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-tDa0GOxQbVtt4WIQ p{margin:0;}#mermaid-svg-tDa0GOxQbVtt4WIQ .label{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;color:#333;}#mermaid-svg-tDa0GOxQbVtt4WIQ .cluster-label text{fill:#333;}#mermaid-svg-tDa0GOxQbVtt4WIQ .cluster-label span{color:#333;}#mermaid-svg-tDa0GOxQbVtt4WIQ .cluster-label span p{background-color:transparent;}#mermaid-svg-tDa0GOxQbVtt4WIQ .label text,#mermaid-svg-tDa0GOxQbVtt4WIQ span{fill:#333;color:#333;}#mermaid-svg-tDa0GOxQbVtt4WIQ .node rect,#mermaid-svg-tDa0GOxQbVtt4WIQ .node circle,#mermaid-svg-tDa0GOxQbVtt4WIQ .node ellipse,#mermaid-svg-tDa0GOxQbVtt4WIQ .node polygon,#mermaid-svg-tDa0GOxQbVtt4WIQ .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-tDa0GOxQbVtt4WIQ .rough-node .label text,#mermaid-svg-tDa0GOxQbVtt4WIQ .node .label text,#mermaid-svg-tDa0GOxQbVtt4WIQ .image-shape .label,#mermaid-svg-tDa0GOxQbVtt4WIQ .icon-shape .label{text-anchor:middle;}#mermaid-svg-tDa0GOxQbVtt4WIQ .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-tDa0GOxQbVtt4WIQ .rough-node .label,#mermaid-svg-tDa0GOxQbVtt4WIQ .node .label,#mermaid-svg-tDa0GOxQbVtt4WIQ .image-shape .label,#mermaid-svg-tDa0GOxQbVtt4WIQ .icon-shape .label{text-align:center;}#mermaid-svg-tDa0GOxQbVtt4WIQ .node.clickable{cursor:pointer;}#mermaid-svg-tDa0GOxQbVtt4WIQ .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-tDa0GOxQbVtt4WIQ .arrowheadPath{fill:#333333;}#mermaid-svg-tDa0GOxQbVtt4WIQ .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-tDa0GOxQbVtt4WIQ .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-tDa0GOxQbVtt4WIQ .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-tDa0GOxQbVtt4WIQ .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-tDa0GOxQbVtt4WIQ .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-tDa0GOxQbVtt4WIQ .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-tDa0GOxQbVtt4WIQ .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-tDa0GOxQbVtt4WIQ .cluster text{fill:#333;}#mermaid-svg-tDa0GOxQbVtt4WIQ .cluster span{color:#333;}#mermaid-svg-tDa0GOxQbVtt4WIQ div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-tDa0GOxQbVtt4WIQ .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-tDa0GOxQbVtt4WIQ rect.text{fill:none;stroke-width:0;}#mermaid-svg-tDa0GOxQbVtt4WIQ .icon-shape,#mermaid-svg-tDa0GOxQbVtt4WIQ .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-tDa0GOxQbVtt4WIQ .icon-shape p,#mermaid-svg-tDa0GOxQbVtt4WIQ .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-tDa0GOxQbVtt4WIQ .icon-shape rect,#mermaid-svg-tDa0GOxQbVtt4WIQ .image-shape rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-tDa0GOxQbVtt4WIQ .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-tDa0GOxQbVtt4WIQ .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-tDa0GOxQbVtt4WIQ :root{–mermaid-font-family:\”trebuchet ms\”,verdana,arial,sans-serif;}
李白
诗人
唐朝
静夜思
将进酒
床前明月光
君不见黄河之水
公元701-762年
搜索引擎之所以能理解你的意图,是因为它背后有一个知识图谱,记录了:
- 李白是诗人
- 李白生活在唐朝
- 静夜思、将进酒是李白的作品
1.2 知识图谱的正式定义
#mermaid-svg-sAdJqZKVlGPyaDoN{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-sAdJqZKVlGPyaDoN .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-sAdJqZKVlGPyaDoN .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-sAdJqZKVlGPyaDoN .error-icon{fill:#552222;}#mermaid-svg-sAdJqZKVlGPyaDoN .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-sAdJqZKVlGPyaDoN .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-sAdJqZKVlGPyaDoN .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-sAdJqZKVlGPyaDoN .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-sAdJqZKVlGPyaDoN .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-sAdJqZKVlGPyaDoN .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-sAdJqZKVlGPyaDoN .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-sAdJqZKVlGPyaDoN .marker{fill:#333333;stroke:#333333;}#mermaid-svg-sAdJqZKVlGPyaDoN .marker.cross{stroke:#333333;}#mermaid-svg-sAdJqZKVlGPyaDoN svg{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-sAdJqZKVlGPyaDoN p{margin:0;}#mermaid-svg-sAdJqZKVlGPyaDoN .label{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;color:#333;}#mermaid-svg-sAdJqZKVlGPyaDoN .cluster-label text{fill:#333;}#mermaid-svg-sAdJqZKVlGPyaDoN .cluster-label span{color:#333;}#mermaid-svg-sAdJqZKVlGPyaDoN .cluster-label span p{background-color:transparent;}#mermaid-svg-sAdJqZKVlGPyaDoN .label text,#mermaid-svg-sAdJqZKVlGPyaDoN span{fill:#333;color:#333;}#mermaid-svg-sAdJqZKVlGPyaDoN .node rect,#mermaid-svg-sAdJqZKVlGPyaDoN .node circle,#mermaid-svg-sAdJqZKVlGPyaDoN .node ellipse,#mermaid-svg-sAdJqZKVlGPyaDoN .node polygon,#mermaid-svg-sAdJqZKVlGPyaDoN .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-sAdJqZKVlGPyaDoN .rough-node .label text,#mermaid-svg-sAdJqZKVlGPyaDoN .node .label text,#mermaid-svg-sAdJqZKVlGPyaDoN .image-shape .label,#mermaid-svg-sAdJqZKVlGPyaDoN .icon-shape .label{text-anchor:middle;}#mermaid-svg-sAdJqZKVlGPyaDoN .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-sAdJqZKVlGPyaDoN .rough-node .label,#mermaid-svg-sAdJqZKVlGPyaDoN .node .label,#mermaid-svg-sAdJqZKVlGPyaDoN .image-shape .label,#mermaid-svg-sAdJqZKVlGPyaDoN .icon-shape .label{text-align:center;}#mermaid-svg-sAdJqZKVlGPyaDoN .node.clickable{cursor:pointer;}#mermaid-svg-sAdJqZKVlGPyaDoN .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-sAdJqZKVlGPyaDoN .arrowheadPath{fill:#333333;}#mermaid-svg-sAdJqZKVlGPyaDoN .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-sAdJqZKVlGPyaDoN .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-sAdJqZKVlGPyaDoN .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-sAdJqZKVlGPyaDoN .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-sAdJqZKVlGPyaDoN .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-sAdJqZKVlGPyaDoN .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-sAdJqZKVlGPyaDoN .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-sAdJqZKVlGPyaDoN .cluster text{fill:#333;}#mermaid-svg-sAdJqZKVlGPyaDoN .cluster span{color:#333;}#mermaid-svg-sAdJqZKVlGPyaDoN div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-sAdJqZKVlGPyaDoN .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-sAdJqZKVlGPyaDoN rect.text{fill:none;stroke-width:0;}#mermaid-svg-sAdJqZKVlGPyaDoN .icon-shape,#mermaid-svg-sAdJqZKVlGPyaDoN .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-sAdJqZKVlGPyaDoN .icon-shape p,#mermaid-svg-sAdJqZKVlGPyaDoN .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-sAdJqZKVlGPyaDoN .icon-shape rect,#mermaid-svg-sAdJqZKVlGPyaDoN .image-shape rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-sAdJqZKVlGPyaDoN .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-sAdJqZKVlGPyaDoN .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-sAdJqZKVlGPyaDoN :root{–mermaid-font-family:\”trebuchet ms\”,verdana,arial,sans-serif;}
知识图谱
知识表示
图结构
语义网络
结构化知识
机器可理解
节点: 实体/概念
边: 关系
语义关联
推理能力
核心定义:
知识图谱(Knowledge Graph) 是一种用图结构来表示知识和建模世界中实体间关系的技术。它由节点(实体/概念)和边(关系)组成,通过三元组(主语-谓语-宾语)的形式描述知识。
1.3 知识图谱的发展历程
#mermaid-svg-5NmDREcz9mxdHdTD{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-5NmDREcz9mxdHdTD .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-5NmDREcz9mxdHdTD .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-5NmDREcz9mxdHdTD .error-icon{fill:#552222;}#mermaid-svg-5NmDREcz9mxdHdTD .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-5NmDREcz9mxdHdTD .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-5NmDREcz9mxdHdTD .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-5NmDREcz9mxdHdTD .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-5NmDREcz9mxdHdTD .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-5NmDREcz9mxdHdTD .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-5NmDREcz9mxdHdTD .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-5NmDREcz9mxdHdTD .marker{fill:#333333;stroke:#333333;}#mermaid-svg-5NmDREcz9mxdHdTD .marker.cross{stroke:#333333;}#mermaid-svg-5NmDREcz9mxdHdTD svg{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-5NmDREcz9mxdHdTD p{margin:0;}#mermaid-svg-5NmDREcz9mxdHdTD .edge{stroke-width:3;}#mermaid-svg-5NmDREcz9mxdHdTD .section–1 rect,#mermaid-svg-5NmDREcz9mxdHdTD .section–1 path,#mermaid-svg-5NmDREcz9mxdHdTD .section–1 circle,#mermaid-svg-5NmDREcz9mxdHdTD .section–1 path{fill:hsl(240, 100%, 76.2745098039%);}#mermaid-svg-5NmDREcz9mxdHdTD .section–1 text{fill:#ffffff;}#mermaid-svg-5NmDREcz9mxdHdTD .node-icon–1{font-size:40px;color:#ffffff;}#mermaid-svg-5NmDREcz9mxdHdTD .section-edge–1{stroke:hsl(240, 100%, 76.2745098039%);}#mermaid-svg-5NmDREcz9mxdHdTD .edge-depth–1{stroke-width:17;}#mermaid-svg-5NmDREcz9mxdHdTD .section–1 line{stroke:hsl(60, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-5NmDREcz9mxdHdTD .lineWrapper line{stroke:#ffffff;}#mermaid-svg-5NmDREcz9mxdHdTD .disabled,#mermaid-svg-5NmDREcz9mxdHdTD .disabled circle,#mermaid-svg-5NmDREcz9mxdHdTD .disabled text{fill:lightgray;}#mermaid-svg-5NmDREcz9mxdHdTD .disabled text{fill:#efefef;}#mermaid-svg-5NmDREcz9mxdHdTD .section-0 rect,#mermaid-svg-5NmDREcz9mxdHdTD .section-0 path,#mermaid-svg-5NmDREcz9mxdHdTD .section-0 circle,#mermaid-svg-5NmDREcz9mxdHdTD .section-0 path{fill:hsl(60, 100%, 73.5294117647%);}#mermaid-svg-5NmDREcz9mxdHdTD .section-0 text{fill:black;}#mermaid-svg-5NmDREcz9mxdHdTD .node-icon-0{font-size:40px;color:black;}#mermaid-svg-5NmDREcz9mxdHdTD .section-edge-0{stroke:hsl(60, 100%, 73.5294117647%);}#mermaid-svg-5NmDREcz9mxdHdTD .edge-depth-0{stroke-width:14;}#mermaid-svg-5NmDREcz9mxdHdTD .section-0 line{stroke:hsl(240, 100%, 83.5294117647%);stroke-width:3;}#mermaid-svg-5NmDREcz9mxdHdTD .lineWrapper line{stroke:black;}#mermaid-svg-5NmDREcz9mxdHdTD .disabled,#mermaid-svg-5NmDREcz9mxdHdTD .disabled circle,#mermaid-svg-5NmDREcz9mxdHdTD .disabled text{fill:lightgray;}#mermaid-svg-5NmDREcz9mxdHdTD .disabled text{fill:#efefef;}#mermaid-svg-5NmDREcz9mxdHdTD .section-1 rect,#mermaid-svg-5NmDREcz9mxdHdTD .section-1 path,#mermaid-svg-5NmDREcz9mxdHdTD .section-1 circle,#mermaid-svg-5NmDREcz9mxdHdTD .section-1 path{fill:hsl(80, 100%, 76.2745098039%);}#mermaid-svg-5NmDREcz9mxdHdTD .section-1 text{fill:black;}#mermaid-svg-5NmDREcz9mxdHdTD .node-icon-1{font-size:40px;color:black;}#mermaid-svg-5NmDREcz9mxdHdTD .section-edge-1{stroke:hsl(80, 100%, 76.2745098039%);}#mermaid-svg-5NmDREcz9mxdHdTD .edge-depth-1{stroke-width:11;}#mermaid-svg-5NmDREcz9mxdHdTD .section-1 line{stroke:hsl(260, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-5NmDREcz9mxdHdTD .lineWrapper line{stroke:black;}#mermaid-svg-5NmDREcz9mxdHdTD .disabled,#mermaid-svg-5NmDREcz9mxdHdTD .disabled circle,#mermaid-svg-5NmDREcz9mxdHdTD .disabled text{fill:lightgray;}#mermaid-svg-5NmDREcz9mxdHdTD .disabled text{fill:#efefef;}#mermaid-svg-5NmDREcz9mxdHdTD .section-2 rect,#mermaid-svg-5NmDREcz9mxdHdTD .section-2 path,#mermaid-svg-5NmDREcz9mxdHdTD .section-2 circle,#mermaid-svg-5NmDREcz9mxdHdTD .section-2 path{fill:hsl(270, 100%, 76.2745098039%);}#mermaid-svg-5NmDREcz9mxdHdTD .section-2 text{fill:#ffffff;}#mermaid-svg-5NmDREcz9mxdHdTD .node-icon-2{font-size:40px;color:#ffffff;}#mermaid-svg-5NmDREcz9mxdHdTD .section-edge-2{stroke:hsl(270, 100%, 76.2745098039%);}#mermaid-svg-5NmDREcz9mxdHdTD .edge-depth-2{stroke-width:8;}#mermaid-svg-5NmDREcz9mxdHdTD .section-2 line{stroke:hsl(90, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-5NmDREcz9mxdHdTD .lineWrapper line{stroke:#ffffff;}#mermaid-svg-5NmDREcz9mxdHdTD .disabled,#mermaid-svg-5NmDREcz9mxdHdTD .disabled circle,#mermaid-svg-5NmDREcz9mxdHdTD .disabled text{fill:lightgray;}#mermaid-svg-5NmDREcz9mxdHdTD .disabled text{fill:#efefef;}#mermaid-svg-5NmDREcz9mxdHdTD .section-3 rect,#mermaid-svg-5NmDREcz9mxdHdTD .section-3 path,#mermaid-svg-5NmDREcz9mxdHdTD .section-3 circle,#mermaid-svg-5NmDREcz9mxdHdTD .section-3 path{fill:hsl(300, 100%, 76.2745098039%);}#mermaid-svg-5NmDREcz9mxdHdTD .section-3 text{fill:black;}#mermaid-svg-5NmDREcz9mxdHdTD .node-icon-3{font-size:40px;color:black;}#mermaid-svg-5NmDREcz9mxdHdTD .section-edge-3{stroke:hsl(300, 100%, 76.2745098039%);}#mermaid-svg-5NmDREcz9mxdHdTD .edge-depth-3{stroke-width:5;}#mermaid-svg-5NmDREcz9mxdHdTD .section-3 line{stroke:hsl(120, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-5NmDREcz9mxdHdTD .lineWrapper line{stroke:black;}#mermaid-svg-5NmDREcz9mxdHdTD .disabled,#mermaid-svg-5NmDREcz9mxdHdTD .disabled circle,#mermaid-svg-5NmDREcz9mxdHdTD .disabled text{fill:lightgray;}#mermaid-svg-5NmDREcz9mxdHdTD .disabled text{fill:#efefef;}#mermaid-svg-5NmDREcz9mxdHdTD .section-4 rect,#mermaid-svg-5NmDREcz9mxdHdTD .section-4 path,#mermaid-svg-5NmDREcz9mxdHdTD .section-4 circle,#mermaid-svg-5NmDREcz9mxdHdTD .section-4 path{fill:hsl(330, 100%, 76.2745098039%);}#mermaid-svg-5NmDREcz9mxdHdTD .section-4 text{fill:black;}#mermaid-svg-5NmDREcz9mxdHdTD .node-icon-4{font-size:40px;color:black;}#mermaid-svg-5NmDREcz9mxdHdTD .section-edge-4{stroke:hsl(330, 100%, 76.2745098039%);}#mermaid-svg-5NmDREcz9mxdHdTD .edge-depth-4{stroke-width:2;}#mermaid-svg-5NmDREcz9mxdHdTD .section-4 line{stroke:hsl(150, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-5NmDREcz9mxdHdTD .lineWrapper line{stroke:black;}#mermaid-svg-5NmDREcz9mxdHdTD .disabled,#mermaid-svg-5NmDREcz9mxdHdTD .disabled circle,#mermaid-svg-5NmDREcz9mxdHdTD .disabled text{fill:lightgray;}#mermaid-svg-5NmDREcz9mxdHdTD .disabled text{fill:#efefef;}#mermaid-svg-5NmDREcz9mxdHdTD .section-5 rect,#mermaid-svg-5NmDREcz9mxdHdTD .section-5 path,#mermaid-svg-5NmDREcz9mxdHdTD .section-5 circle,#mermaid-svg-5NmDREcz9mxdHdTD .section-5 path{fill:hsl(0, 100%, 76.2745098039%);}#mermaid-svg-5NmDREcz9mxdHdTD .section-5 text{fill:black;}#mermaid-svg-5NmDREcz9mxdHdTD .node-icon-5{font-size:40px;color:black;}#mermaid-svg-5NmDREcz9mxdHdTD .section-edge-5{stroke:hsl(0, 100%, 76.2745098039%);}#mermaid-svg-5NmDREcz9mxdHdTD .edge-depth-5{stroke-width:-1;}#mermaid-svg-5NmDREcz9mxdHdTD .section-5 line{stroke:hsl(180, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-5NmDREcz9mxdHdTD .lineWrapper line{stroke:black;}#mermaid-svg-5NmDREcz9mxdHdTD .disabled,#mermaid-svg-5NmDREcz9mxdHdTD .disabled circle,#mermaid-svg-5NmDREcz9mxdHdTD .disabled text{fill:lightgray;}#mermaid-svg-5NmDREcz9mxdHdTD .disabled text{fill:#efefef;}#mermaid-svg-5NmDREcz9mxdHdTD .section-6 rect,#mermaid-svg-5NmDREcz9mxdHdTD .section-6 path,#mermaid-svg-5NmDREcz9mxdHdTD .section-6 circle,#mermaid-svg-5NmDREcz9mxdHdTD .section-6 path{fill:hsl(30, 100%, 76.2745098039%);}#mermaid-svg-5NmDREcz9mxdHdTD .section-6 text{fill:black;}#mermaid-svg-5NmDREcz9mxdHdTD .node-icon-6{font-size:40px;color:black;}#mermaid-svg-5NmDREcz9mxdHdTD .section-edge-6{stroke:hsl(30, 100%, 76.2745098039%);}#mermaid-svg-5NmDREcz9mxdHdTD .edge-depth-6{stroke-width:-4;}#mermaid-svg-5NmDREcz9mxdHdTD .section-6 line{stroke:hsl(210, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-5NmDREcz9mxdHdTD .lineWrapper line{stroke:black;}#mermaid-svg-5NmDREcz9mxdHdTD .disabled,#mermaid-svg-5NmDREcz9mxdHdTD .disabled circle,#mermaid-svg-5NmDREcz9mxdHdTD .disabled text{fill:lightgray;}#mermaid-svg-5NmDREcz9mxdHdTD .disabled text{fill:#efefef;}#mermaid-svg-5NmDREcz9mxdHdTD .section-7 rect,#mermaid-svg-5NmDREcz9mxdHdTD .section-7 path,#mermaid-svg-5NmDREcz9mxdHdTD .section-7 circle,#mermaid-svg-5NmDREcz9mxdHdTD .section-7 path{fill:hsl(90, 100%, 76.2745098039%);}#mermaid-svg-5NmDREcz9mxdHdTD .section-7 text{fill:black;}#mermaid-svg-5NmDREcz9mxdHdTD .node-icon-7{font-size:40px;color:black;}#mermaid-svg-5NmDREcz9mxdHdTD .section-edge-7{stroke:hsl(90, 100%, 76.2745098039%);}#mermaid-svg-5NmDREcz9mxdHdTD .edge-depth-7{stroke-width:-7;}#mermaid-svg-5NmDREcz9mxdHdTD .section-7 line{stroke:hsl(270, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-5NmDREcz9mxdHdTD .lineWrapper line{stroke:black;}#mermaid-svg-5NmDREcz9mxdHdTD .disabled,#mermaid-svg-5NmDREcz9mxdHdTD .disabled circle,#mermaid-svg-5NmDREcz9mxdHdTD .disabled text{fill:lightgray;}#mermaid-svg-5NmDREcz9mxdHdTD .disabled text{fill:#efefef;}#mermaid-svg-5NmDREcz9mxdHdTD .section-8 rect,#mermaid-svg-5NmDREcz9mxdHdTD .section-8 path,#mermaid-svg-5NmDREcz9mxdHdTD .section-8 circle,#mermaid-svg-5NmDREcz9mxdHdTD .section-8 path{fill:hsl(150, 100%, 76.2745098039%);}#mermaid-svg-5NmDREcz9mxdHdTD .section-8 text{fill:black;}#mermaid-svg-5NmDREcz9mxdHdTD .node-icon-8{font-size:40px;color:black;}#mermaid-svg-5NmDREcz9mxdHdTD .section-edge-8{stroke:hsl(150, 100%, 76.2745098039%);}#mermaid-svg-5NmDREcz9mxdHdTD .edge-depth-8{stroke-width:-10;}#mermaid-svg-5NmDREcz9mxdHdTD .section-8 line{stroke:hsl(330, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-5NmDREcz9mxdHdTD .lineWrapper line{stroke:black;}#mermaid-svg-5NmDREcz9mxdHdTD .disabled,#mermaid-svg-5NmDREcz9mxdHdTD .disabled circle,#mermaid-svg-5NmDREcz9mxdHdTD .disabled text{fill:lightgray;}#mermaid-svg-5NmDREcz9mxdHdTD .disabled text{fill:#efefef;}#mermaid-svg-5NmDREcz9mxdHdTD .section-9 rect,#mermaid-svg-5NmDREcz9mxdHdTD .section-9 path,#mermaid-svg-5NmDREcz9mxdHdTD .section-9 circle,#mermaid-svg-5NmDREcz9mxdHdTD .section-9 path{fill:hsl(180, 100%, 76.2745098039%);}#mermaid-svg-5NmDREcz9mxdHdTD .section-9 text{fill:black;}#mermaid-svg-5NmDREcz9mxdHdTD .node-icon-9{font-size:40px;color:black;}#mermaid-svg-5NmDREcz9mxdHdTD .section-edge-9{stroke:hsl(180, 100%, 76.2745098039%);}#mermaid-svg-5NmDREcz9mxdHdTD .edge-depth-9{stroke-width:-13;}#mermaid-svg-5NmDREcz9mxdHdTD .section-9 line{stroke:hsl(0, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-5NmDREcz9mxdHdTD .lineWrapper line{stroke:black;}#mermaid-svg-5NmDREcz9mxdHdTD .disabled,#mermaid-svg-5NmDREcz9mxdHdTD .disabled circle,#mermaid-svg-5NmDREcz9mxdHdTD .disabled text{fill:lightgray;}#mermaid-svg-5NmDREcz9mxdHdTD .disabled text{fill:#efefef;}#mermaid-svg-5NmDREcz9mxdHdTD .section-10 rect,#mermaid-svg-5NmDREcz9mxdHdTD .section-10 path,#mermaid-svg-5NmDREcz9mxdHdTD .section-10 circle,#mermaid-svg-5NmDREcz9mxdHdTD .section-10 path{fill:hsl(210, 100%, 76.2745098039%);}#mermaid-svg-5NmDREcz9mxdHdTD .section-10 text{fill:black;}#mermaid-svg-5NmDREcz9mxdHdTD .node-icon-10{font-size:40px;color:black;}#mermaid-svg-5NmDREcz9mxdHdTD .section-edge-10{stroke:hsl(210, 100%, 76.2745098039%);}#mermaid-svg-5NmDREcz9mxdHdTD .edge-depth-10{stroke-width:-16;}#mermaid-svg-5NmDREcz9mxdHdTD .section-10 line{stroke:hsl(30, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-5NmDREcz9mxdHdTD .lineWrapper line{stroke:black;}#mermaid-svg-5NmDREcz9mxdHdTD .disabled,#mermaid-svg-5NmDREcz9mxdHdTD .disabled circle,#mermaid-svg-5NmDREcz9mxdHdTD .disabled text{fill:lightgray;}#mermaid-svg-5NmDREcz9mxdHdTD .disabled text{fill:#efefef;}#mermaid-svg-5NmDREcz9mxdHdTD .section-root rect,#mermaid-svg-5NmDREcz9mxdHdTD .section-root path,#mermaid-svg-5NmDREcz9mxdHdTD .section-root circle{fill:hsl(240, 100%, 46.2745098039%);}#mermaid-svg-5NmDREcz9mxdHdTD .section-root text{fill:#ffffff;}#mermaid-svg-5NmDREcz9mxdHdTD .icon-container{height:100%;display:flex;justify-content:center;align-items:center;}#mermaid-svg-5NmDREcz9mxdHdTD .edge{fill:none;}#mermaid-svg-5NmDREcz9mxdHdTD .eventWrapper{filter:brightness(120%);}#mermaid-svg-5NmDREcz9mxdHdTD :root{–mermaid-font-family:\”trebuchet ms\”,verdana,arial,sans-serif;}
2001
语义网概念
Berners-Lee提出
2012
Google知识图谱
商业化应用开端
2016
知识图谱+深度学习
TransE等表示学习
2019
知识增强预训练
ERNIE, K-BERT
2023
大模型+知识图谱
ChatKBQA, ToG
2024
GraphRAG
微软图谱增强检索
知识图谱发展历程
二、知识图谱的核心组成
2.1 三元组:知识的基本单元
#mermaid-svg-DyEVJ1Lg52OFo2XD{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-DyEVJ1Lg52OFo2XD .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-DyEVJ1Lg52OFo2XD .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-DyEVJ1Lg52OFo2XD .error-icon{fill:#552222;}#mermaid-svg-DyEVJ1Lg52OFo2XD .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-DyEVJ1Lg52OFo2XD .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-DyEVJ1Lg52OFo2XD .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-DyEVJ1Lg52OFo2XD .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-DyEVJ1Lg52OFo2XD .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-DyEVJ1Lg52OFo2XD .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-DyEVJ1Lg52OFo2XD .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-DyEVJ1Lg52OFo2XD .marker{fill:#333333;stroke:#333333;}#mermaid-svg-DyEVJ1Lg52OFo2XD .marker.cross{stroke:#333333;}#mermaid-svg-DyEVJ1Lg52OFo2XD svg{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-DyEVJ1Lg52OFo2XD p{margin:0;}#mermaid-svg-DyEVJ1Lg52OFo2XD .label{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;color:#333;}#mermaid-svg-DyEVJ1Lg52OFo2XD .cluster-label text{fill:#333;}#mermaid-svg-DyEVJ1Lg52OFo2XD .cluster-label span{color:#333;}#mermaid-svg-DyEVJ1Lg52OFo2XD .cluster-label span p{background-color:transparent;}#mermaid-svg-DyEVJ1Lg52OFo2XD .label text,#mermaid-svg-DyEVJ1Lg52OFo2XD span{fill:#333;color:#333;}#mermaid-svg-DyEVJ1Lg52OFo2XD .node rect,#mermaid-svg-DyEVJ1Lg52OFo2XD .node circle,#mermaid-svg-DyEVJ1Lg52OFo2XD .node ellipse,#mermaid-svg-DyEVJ1Lg52OFo2XD .node polygon,#mermaid-svg-DyEVJ1Lg52OFo2XD .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-DyEVJ1Lg52OFo2XD .rough-node .label text,#mermaid-svg-DyEVJ1Lg52OFo2XD .node .label text,#mermaid-svg-DyEVJ1Lg52OFo2XD .image-shape .label,#mermaid-svg-DyEVJ1Lg52OFo2XD .icon-shape .label{text-anchor:middle;}#mermaid-svg-DyEVJ1Lg52OFo2XD .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-DyEVJ1Lg52OFo2XD .rough-node .label,#mermaid-svg-DyEVJ1Lg52OFo2XD .node .label,#mermaid-svg-DyEVJ1Lg52OFo2XD .image-shape .label,#mermaid-svg-DyEVJ1Lg52OFo2XD .icon-shape .label{text-align:center;}#mermaid-svg-DyEVJ1Lg52OFo2XD .node.clickable{cursor:pointer;}#mermaid-svg-DyEVJ1Lg52OFo2XD .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-DyEVJ1Lg52OFo2XD .arrowheadPath{fill:#333333;}#mermaid-svg-DyEVJ1Lg52OFo2XD .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-DyEVJ1Lg52OFo2XD .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-DyEVJ1Lg52OFo2XD .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-DyEVJ1Lg52OFo2XD .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-DyEVJ1Lg52OFo2XD .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-DyEVJ1Lg52OFo2XD .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-DyEVJ1Lg52OFo2XD .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-DyEVJ1Lg52OFo2XD .cluster text{fill:#333;}#mermaid-svg-DyEVJ1Lg52OFo2XD .cluster span{color:#333;}#mermaid-svg-DyEVJ1Lg52OFo2XD div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-DyEVJ1Lg52OFo2XD .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-DyEVJ1Lg52OFo2XD rect.text{fill:none;stroke-width:0;}#mermaid-svg-DyEVJ1Lg52OFo2XD .icon-shape,#mermaid-svg-DyEVJ1Lg52OFo2XD .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-DyEVJ1Lg52OFo2XD .icon-shape p,#mermaid-svg-DyEVJ1Lg52OFo2XD .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-DyEVJ1Lg52OFo2XD .icon-shape rect,#mermaid-svg-DyEVJ1Lg52OFo2XD .image-shape rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-DyEVJ1Lg52OFo2XD .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-DyEVJ1Lg52OFo2XD .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-DyEVJ1Lg52OFo2XD :root{–mermaid-font-family:\”trebuchet ms\”,verdana,arial,sans-serif;}
三元组示例
职业
工作于
掌握
属于
语言
张三
Python开发者
阿里巴巴
FastAPI
Web框架
Python
三元组结构:
| 主语 | Subject | 张三 | 实体 |
| 谓语 | Predicate | 职业 | 关系 |
| 宾语 | Object | Python开发者 | 实体或值 |
三元组示例:
(张三, 职业, Python开发者)
(张三, 工作于, 阿里巴巴)
(FastAPI, 属于, Web框架)
(FastAPI, 语言, Python)
2.2 实体(Entity)
#mermaid-svg-6BgZDE4YSgQ0lAQ5{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-6BgZDE4YSgQ0lAQ5 .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-6BgZDE4YSgQ0lAQ5 .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-6BgZDE4YSgQ0lAQ5 .error-icon{fill:#552222;}#mermaid-svg-6BgZDE4YSgQ0lAQ5 .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-6BgZDE4YSgQ0lAQ5 .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-6BgZDE4YSgQ0lAQ5 .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-6BgZDE4YSgQ0lAQ5 .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-6BgZDE4YSgQ0lAQ5 .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-6BgZDE4YSgQ0lAQ5 .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-6BgZDE4YSgQ0lAQ5 .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-6BgZDE4YSgQ0lAQ5 .marker{fill:#333333;stroke:#333333;}#mermaid-svg-6BgZDE4YSgQ0lAQ5 .marker.cross{stroke:#333333;}#mermaid-svg-6BgZDE4YSgQ0lAQ5 svg{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-6BgZDE4YSgQ0lAQ5 p{margin:0;}#mermaid-svg-6BgZDE4YSgQ0lAQ5 .label{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;color:#333;}#mermaid-svg-6BgZDE4YSgQ0lAQ5 .cluster-label text{fill:#333;}#mermaid-svg-6BgZDE4YSgQ0lAQ5 .cluster-label span{color:#333;}#mermaid-svg-6BgZDE4YSgQ0lAQ5 .cluster-label span p{background-color:transparent;}#mermaid-svg-6BgZDE4YSgQ0lAQ5 .label text,#mermaid-svg-6BgZDE4YSgQ0lAQ5 span{fill:#333;color:#333;}#mermaid-svg-6BgZDE4YSgQ0lAQ5 .node rect,#mermaid-svg-6BgZDE4YSgQ0lAQ5 .node circle,#mermaid-svg-6BgZDE4YSgQ0lAQ5 .node ellipse,#mermaid-svg-6BgZDE4YSgQ0lAQ5 .node polygon,#mermaid-svg-6BgZDE4YSgQ0lAQ5 .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-6BgZDE4YSgQ0lAQ5 .rough-node .label text,#mermaid-svg-6BgZDE4YSgQ0lAQ5 .node .label text,#mermaid-svg-6BgZDE4YSgQ0lAQ5 .image-shape .label,#mermaid-svg-6BgZDE4YSgQ0lAQ5 .icon-shape .label{text-anchor:middle;}#mermaid-svg-6BgZDE4YSgQ0lAQ5 .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-6BgZDE4YSgQ0lAQ5 .rough-node .label,#mermaid-svg-6BgZDE4YSgQ0lAQ5 .node .label,#mermaid-svg-6BgZDE4YSgQ0lAQ5 .image-shape .label,#mermaid-svg-6BgZDE4YSgQ0lAQ5 .icon-shape .label{text-align:center;}#mermaid-svg-6BgZDE4YSgQ0lAQ5 .node.clickable{cursor:pointer;}#mermaid-svg-6BgZDE4YSgQ0lAQ5 .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-6BgZDE4YSgQ0lAQ5 .arrowheadPath{fill:#333333;}#mermaid-svg-6BgZDE4YSgQ0lAQ5 .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-6BgZDE4YSgQ0lAQ5 .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-6BgZDE4YSgQ0lAQ5 .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-6BgZDE4YSgQ0lAQ5 .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-6BgZDE4YSgQ0lAQ5 .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-6BgZDE4YSgQ0lAQ5 .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-6BgZDE4YSgQ0lAQ5 .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-6BgZDE4YSgQ0lAQ5 .cluster text{fill:#333;}#mermaid-svg-6BgZDE4YSgQ0lAQ5 .cluster span{color:#333;}#mermaid-svg-6BgZDE4YSgQ0lAQ5 div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-6BgZDE4YSgQ0lAQ5 .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-6BgZDE4YSgQ0lAQ5 rect.text{fill:none;stroke-width:0;}#mermaid-svg-6BgZDE4YSgQ0lAQ5 .icon-shape,#mermaid-svg-6BgZDE4YSgQ0lAQ5 .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-6BgZDE4YSgQ0lAQ5 .icon-shape p,#mermaid-svg-6BgZDE4YSgQ0lAQ5 .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-6BgZDE4YSgQ0lAQ5 .icon-shape rect,#mermaid-svg-6BgZDE4YSgQ0lAQ5 .image-shape rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-6BgZDE4YSgQ0lAQ5 .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-6BgZDE4YSgQ0lAQ5 .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-6BgZDE4YSgQ0lAQ5 :root{–mermaid-font-family:\”trebuchet ms\”,verdana,arial,sans-serif;}
实体类型
人物
组织
地点
概念
事件
张三, 李四
阿里巴巴, 腾讯
北京, 上海
Python, FastAPI
项目启动, 版本发布
实体定义:
实体是知识图谱中的节点,代表现实世界中的具体对象或抽象概念。每个实体通常有唯一的标识符和若干属性。
2.3 关系(Relation)
#mermaid-svg-Fh0V3ifFiKGViqPV{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-Fh0V3ifFiKGViqPV .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-Fh0V3ifFiKGViqPV .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-Fh0V3ifFiKGViqPV .error-icon{fill:#552222;}#mermaid-svg-Fh0V3ifFiKGViqPV .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-Fh0V3ifFiKGViqPV .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-Fh0V3ifFiKGViqPV .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-Fh0V3ifFiKGViqPV .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-Fh0V3ifFiKGViqPV .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-Fh0V3ifFiKGViqPV .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-Fh0V3ifFiKGViqPV .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-Fh0V3ifFiKGViqPV .marker{fill:#333333;stroke:#333333;}#mermaid-svg-Fh0V3ifFiKGViqPV .marker.cross{stroke:#333333;}#mermaid-svg-Fh0V3ifFiKGViqPV svg{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-Fh0V3ifFiKGViqPV p{margin:0;}#mermaid-svg-Fh0V3ifFiKGViqPV .label{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;color:#333;}#mermaid-svg-Fh0V3ifFiKGViqPV .cluster-label text{fill:#333;}#mermaid-svg-Fh0V3ifFiKGViqPV .cluster-label span{color:#333;}#mermaid-svg-Fh0V3ifFiKGViqPV .cluster-label span p{background-color:transparent;}#mermaid-svg-Fh0V3ifFiKGViqPV .label text,#mermaid-svg-Fh0V3ifFiKGViqPV span{fill:#333;color:#333;}#mermaid-svg-Fh0V3ifFiKGViqPV .node rect,#mermaid-svg-Fh0V3ifFiKGViqPV .node circle,#mermaid-svg-Fh0V3ifFiKGViqPV .node ellipse,#mermaid-svg-Fh0V3ifFiKGViqPV .node polygon,#mermaid-svg-Fh0V3ifFiKGViqPV .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-Fh0V3ifFiKGViqPV .rough-node .label text,#mermaid-svg-Fh0V3ifFiKGViqPV .node .label text,#mermaid-svg-Fh0V3ifFiKGViqPV .image-shape .label,#mermaid-svg-Fh0V3ifFiKGViqPV .icon-shape .label{text-anchor:middle;}#mermaid-svg-Fh0V3ifFiKGViqPV .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-Fh0V3ifFiKGViqPV .rough-node .label,#mermaid-svg-Fh0V3ifFiKGViqPV .node .label,#mermaid-svg-Fh0V3ifFiKGViqPV .image-shape .label,#mermaid-svg-Fh0V3ifFiKGViqPV .icon-shape .label{text-align:center;}#mermaid-svg-Fh0V3ifFiKGViqPV .node.clickable{cursor:pointer;}#mermaid-svg-Fh0V3ifFiKGViqPV .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-Fh0V3ifFiKGViqPV .arrowheadPath{fill:#333333;}#mermaid-svg-Fh0V3ifFiKGViqPV .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-Fh0V3ifFiKGViqPV .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-Fh0V3ifFiKGViqPV .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-Fh0V3ifFiKGViqPV .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-Fh0V3ifFiKGViqPV .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-Fh0V3ifFiKGViqPV .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-Fh0V3ifFiKGViqPV .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-Fh0V3ifFiKGViqPV .cluster text{fill:#333;}#mermaid-svg-Fh0V3ifFiKGViqPV .cluster span{color:#333;}#mermaid-svg-Fh0V3ifFiKGViqPV div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-Fh0V3ifFiKGViqPV .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-Fh0V3ifFiKGViqPV rect.text{fill:none;stroke-width:0;}#mermaid-svg-Fh0V3ifFiKGViqPV .icon-shape,#mermaid-svg-Fh0V3ifFiKGViqPV .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-Fh0V3ifFiKGViqPV .icon-shape p,#mermaid-svg-Fh0V3ifFiKGViqPV .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-Fh0V3ifFiKGViqPV .icon-shape rect,#mermaid-svg-Fh0V3ifFiKGViqPV .image-shape rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-Fh0V3ifFiKGViqPV .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-Fh0V3ifFiKGViqPV .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-Fh0V3ifFiKGViqPV :root{–mermaid-font-family:\”trebuchet ms\”,verdana,arial,sans-serif;}
关系类型
属性关系
层级关系
关联关系
时序关系
姓名, 年龄, 职业
属于, 包含, 父类
工作于, 合作, 依赖
发生于, 先于, 后于
关系示例:
| 属性关系 | (张三, 年龄, 25) | 描述实体属性 |
| 层级关系 | (FastAPI, 属于, Web框架) | 分类/包含关系 |
| 关联关系 | (张三, 工作于, 阿里巴巴) | 实体间关联 |
| 时序关系 | (项目启动, 先于, 版本发布) | 时间顺序 |
2.4 属性(Property)
#mermaid-svg-h9EeJ6sqGlsxzpYs{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-h9EeJ6sqGlsxzpYs .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-h9EeJ6sqGlsxzpYs .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-h9EeJ6sqGlsxzpYs .error-icon{fill:#552222;}#mermaid-svg-h9EeJ6sqGlsxzpYs .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-h9EeJ6sqGlsxzpYs .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-h9EeJ6sqGlsxzpYs .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-h9EeJ6sqGlsxzpYs .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-h9EeJ6sqGlsxzpYs .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-h9EeJ6sqGlsxzpYs .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-h9EeJ6sqGlsxzpYs .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-h9EeJ6sqGlsxzpYs .marker{fill:#333333;stroke:#333333;}#mermaid-svg-h9EeJ6sqGlsxzpYs .marker.cross{stroke:#333333;}#mermaid-svg-h9EeJ6sqGlsxzpYs svg{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-h9EeJ6sqGlsxzpYs p{margin:0;}#mermaid-svg-h9EeJ6sqGlsxzpYs .label{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;color:#333;}#mermaid-svg-h9EeJ6sqGlsxzpYs .cluster-label text{fill:#333;}#mermaid-svg-h9EeJ6sqGlsxzpYs .cluster-label span{color:#333;}#mermaid-svg-h9EeJ6sqGlsxzpYs .cluster-label span p{background-color:transparent;}#mermaid-svg-h9EeJ6sqGlsxzpYs .label text,#mermaid-svg-h9EeJ6sqGlsxzpYs span{fill:#333;color:#333;}#mermaid-svg-h9EeJ6sqGlsxzpYs .node rect,#mermaid-svg-h9EeJ6sqGlsxzpYs .node circle,#mermaid-svg-h9EeJ6sqGlsxzpYs .node ellipse,#mermaid-svg-h9EeJ6sqGlsxzpYs .node polygon,#mermaid-svg-h9EeJ6sqGlsxzpYs .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-h9EeJ6sqGlsxzpYs .rough-node .label text,#mermaid-svg-h9EeJ6sqGlsxzpYs .node .label text,#mermaid-svg-h9EeJ6sqGlsxzpYs .image-shape .label,#mermaid-svg-h9EeJ6sqGlsxzpYs .icon-shape .label{text-anchor:middle;}#mermaid-svg-h9EeJ6sqGlsxzpYs .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-h9EeJ6sqGlsxzpYs .rough-node .label,#mermaid-svg-h9EeJ6sqGlsxzpYs .node .label,#mermaid-svg-h9EeJ6sqGlsxzpYs .image-shape .label,#mermaid-svg-h9EeJ6sqGlsxzpYs .icon-shape .label{text-align:center;}#mermaid-svg-h9EeJ6sqGlsxzpYs .node.clickable{cursor:pointer;}#mermaid-svg-h9EeJ6sqGlsxzpYs .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-h9EeJ6sqGlsxzpYs .arrowheadPath{fill:#333333;}#mermaid-svg-h9EeJ6sqGlsxzpYs .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-h9EeJ6sqGlsxzpYs .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-h9EeJ6sqGlsxzpYs .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-h9EeJ6sqGlsxzpYs .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-h9EeJ6sqGlsxzpYs .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-h9EeJ6sqGlsxzpYs .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-h9EeJ6sqGlsxzpYs .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-h9EeJ6sqGlsxzpYs .cluster text{fill:#333;}#mermaid-svg-h9EeJ6sqGlsxzpYs .cluster span{color:#333;}#mermaid-svg-h9EeJ6sqGlsxzpYs div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-h9EeJ6sqGlsxzpYs .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-h9EeJ6sqGlsxzpYs rect.text{fill:none;stroke-width:0;}#mermaid-svg-h9EeJ6sqGlsxzpYs .icon-shape,#mermaid-svg-h9EeJ6sqGlsxzpYs .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-h9EeJ6sqGlsxzpYs .icon-shape p,#mermaid-svg-h9EeJ6sqGlsxzpYs .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-h9EeJ6sqGlsxzpYs .icon-shape rect,#mermaid-svg-h9EeJ6sqGlsxzpYs .image-shape rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-h9EeJ6sqGlsxzpYs .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-h9EeJ6sqGlsxzpYs .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-h9EeJ6sqGlsxzpYs :root{–mermaid-font-family:\”trebuchet ms\”,verdana,arial,sans-serif;}
张三
属性
姓名: 张三
年龄: 25
邮箱: zhangsan@example.com
技能: Python, FastAPI
属性定义:
属性是实体的特征描述,通常以键值对的形式存储。属性可以是基本类型(字符串、数字)或复杂类型(列表、嵌套对象)。
三、知识图谱 vs 其他数据结构
3.1 知识图谱 vs 关系数据库
#mermaid-svg-TZhWEGjo8TrCdR5N{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-TZhWEGjo8TrCdR5N .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-TZhWEGjo8TrCdR5N .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-TZhWEGjo8TrCdR5N .error-icon{fill:#552222;}#mermaid-svg-TZhWEGjo8TrCdR5N .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-TZhWEGjo8TrCdR5N .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-TZhWEGjo8TrCdR5N .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-TZhWEGjo8TrCdR5N .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-TZhWEGjo8TrCdR5N .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-TZhWEGjo8TrCdR5N .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-TZhWEGjo8TrCdR5N .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-TZhWEGjo8TrCdR5N .marker{fill:#333333;stroke:#333333;}#mermaid-svg-TZhWEGjo8TrCdR5N .marker.cross{stroke:#333333;}#mermaid-svg-TZhWEGjo8TrCdR5N svg{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-TZhWEGjo8TrCdR5N p{margin:0;}#mermaid-svg-TZhWEGjo8TrCdR5N .label{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;color:#333;}#mermaid-svg-TZhWEGjo8TrCdR5N .cluster-label text{fill:#333;}#mermaid-svg-TZhWEGjo8TrCdR5N .cluster-label span{color:#333;}#mermaid-svg-TZhWEGjo8TrCdR5N .cluster-label span p{background-color:transparent;}#mermaid-svg-TZhWEGjo8TrCdR5N .label text,#mermaid-svg-TZhWEGjo8TrCdR5N span{fill:#333;color:#333;}#mermaid-svg-TZhWEGjo8TrCdR5N .node rect,#mermaid-svg-TZhWEGjo8TrCdR5N .node circle,#mermaid-svg-TZhWEGjo8TrCdR5N .node ellipse,#mermaid-svg-TZhWEGjo8TrCdR5N .node polygon,#mermaid-svg-TZhWEGjo8TrCdR5N .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-TZhWEGjo8TrCdR5N .rough-node .label text,#mermaid-svg-TZhWEGjo8TrCdR5N .node .label text,#mermaid-svg-TZhWEGjo8TrCdR5N .image-shape .label,#mermaid-svg-TZhWEGjo8TrCdR5N .icon-shape .label{text-anchor:middle;}#mermaid-svg-TZhWEGjo8TrCdR5N .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-TZhWEGjo8TrCdR5N .rough-node .label,#mermaid-svg-TZhWEGjo8TrCdR5N .node .label,#mermaid-svg-TZhWEGjo8TrCdR5N .image-shape .label,#mermaid-svg-TZhWEGjo8TrCdR5N .icon-shape .label{text-align:center;}#mermaid-svg-TZhWEGjo8TrCdR5N .node.clickable{cursor:pointer;}#mermaid-svg-TZhWEGjo8TrCdR5N .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-TZhWEGjo8TrCdR5N .arrowheadPath{fill:#333333;}#mermaid-svg-TZhWEGjo8TrCdR5N .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-TZhWEGjo8TrCdR5N .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-TZhWEGjo8TrCdR5N .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-TZhWEGjo8TrCdR5N .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-TZhWEGjo8TrCdR5N .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-TZhWEGjo8TrCdR5N .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-TZhWEGjo8TrCdR5N .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-TZhWEGjo8TrCdR5N .cluster text{fill:#333;}#mermaid-svg-TZhWEGjo8TrCdR5N .cluster span{color:#333;}#mermaid-svg-TZhWEGjo8TrCdR5N div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-TZhWEGjo8TrCdR5N .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-TZhWEGjo8TrCdR5N rect.text{fill:none;stroke-width:0;}#mermaid-svg-TZhWEGjo8TrCdR5N .icon-shape,#mermaid-svg-TZhWEGjo8TrCdR5N .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-TZhWEGjo8TrCdR5N .icon-shape p,#mermaid-svg-TZhWEGjo8TrCdR5N .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-TZhWEGjo8TrCdR5N .icon-shape rect,#mermaid-svg-TZhWEGjo8TrCdR5N .image-shape rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-TZhWEGjo8TrCdR5N .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-TZhWEGjo8TrCdR5N .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-TZhWEGjo8TrCdR5N :root{–mermaid-font-family:\”trebuchet ms\”,verdana,arial,sans-serif;}
知识图谱
图结构
节点
关系
直接连接
关系数据库
表结构
行记录
字段
外键关联
详细对比:
| 数据模型 | 表格(行+列) | 图(节点+边) |
| 查询语言 | SQL | Cypher/SPARQL |
| 关系表示 | 外键关联(隐式) | 直接边连接(显式) |
| 灵活性 | 需预定义Schema | Schema-less |
| 扩展性 | 修改Schema困难 | 易于添加新节点/关系 |
| 推理能力 | 无 | 支持图推理 |
| 适用场景 | 结构化数据 | 关系密集型数据 |
3.2 知识图谱 vs 向量数据库
#mermaid-svg-KUNyYcultOkAKpMU{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-KUNyYcultOkAKpMU .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-KUNyYcultOkAKpMU .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-KUNyYcultOkAKpMU .error-icon{fill:#552222;}#mermaid-svg-KUNyYcultOkAKpMU .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-KUNyYcultOkAKpMU .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-KUNyYcultOkAKpMU .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-KUNyYcultOkAKpMU .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-KUNyYcultOkAKpMU .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-KUNyYcultOkAKpMU .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-KUNyYcultOkAKpMU .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-KUNyYcultOkAKpMU .marker{fill:#333333;stroke:#333333;}#mermaid-svg-KUNyYcultOkAKpMU .marker.cross{stroke:#333333;}#mermaid-svg-KUNyYcultOkAKpMU svg{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-KUNyYcultOkAKpMU p{margin:0;}#mermaid-svg-KUNyYcultOkAKpMU .label{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;color:#333;}#mermaid-svg-KUNyYcultOkAKpMU .cluster-label text{fill:#333;}#mermaid-svg-KUNyYcultOkAKpMU .cluster-label span{color:#333;}#mermaid-svg-KUNyYcultOkAKpMU .cluster-label span p{background-color:transparent;}#mermaid-svg-KUNyYcultOkAKpMU .label text,#mermaid-svg-KUNyYcultOkAKpMU span{fill:#333;color:#333;}#mermaid-svg-KUNyYcultOkAKpMU .node rect,#mermaid-svg-KUNyYcultOkAKpMU .node circle,#mermaid-svg-KUNyYcultOkAKpMU .node ellipse,#mermaid-svg-KUNyYcultOkAKpMU .node polygon,#mermaid-svg-KUNyYcultOkAKpMU .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-KUNyYcultOkAKpMU .rough-node .label text,#mermaid-svg-KUNyYcultOkAKpMU .node .label text,#mermaid-svg-KUNyYcultOkAKpMU .image-shape .label,#mermaid-svg-KUNyYcultOkAKpMU .icon-shape .label{text-anchor:middle;}#mermaid-svg-KUNyYcultOkAKpMU .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-KUNyYcultOkAKpMU .rough-node .label,#mermaid-svg-KUNyYcultOkAKpMU .node .label,#mermaid-svg-KUNyYcultOkAKpMU .image-shape .label,#mermaid-svg-KUNyYcultOkAKpMU .icon-shape .label{text-align:center;}#mermaid-svg-KUNyYcultOkAKpMU .node.clickable{cursor:pointer;}#mermaid-svg-KUNyYcultOkAKpMU .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-KUNyYcultOkAKpMU .arrowheadPath{fill:#333333;}#mermaid-svg-KUNyYcultOkAKpMU .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-KUNyYcultOkAKpMU .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-KUNyYcultOkAKpMU .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-KUNyYcultOkAKpMU .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-KUNyYcultOkAKpMU .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-KUNyYcultOkAKpMU .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-KUNyYcultOkAKpMU .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-KUNyYcultOkAKpMU .cluster text{fill:#333;}#mermaid-svg-KUNyYcultOkAKpMU .cluster span{color:#333;}#mermaid-svg-KUNyYcultOkAKpMU div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-KUNyYcultOkAKpMU .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-KUNyYcultOkAKpMU rect.text{fill:none;stroke-width:0;}#mermaid-svg-KUNyYcultOkAKpMU .icon-shape,#mermaid-svg-KUNyYcultOkAKpMU .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-KUNyYcultOkAKpMU .icon-shape p,#mermaid-svg-KUNyYcultOkAKpMU .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-KUNyYcultOkAKpMU .icon-shape rect,#mermaid-svg-KUNyYcultOkAKpMU .image-shape rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-KUNyYcultOkAKpMU .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-KUNyYcultOkAKpMU .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-KUNyYcultOkAKpMU :root{–mermaid-font-family:\”trebuchet ms\”,verdana,arial,sans-serif;}
知识图谱
实体
三元组
图结构
图遍历
关系推理
向量数据库
文档
Embedding
向量
相似度检索
语义相似
详细对比:
| 数据结构 | 高维向量 | 图结构 |
| 检索方式 | 相似度计算 | 图遍历/模式匹配 |
| 知识表示 | 隐式(分布式) | 显式(符号化) |
| 推理能力 | 弱(基于相似) | 强(基于关系) |
| 可解释性 | 低 | 高 |
| 更新方式 | 重新索引 | 增量更新 |
| 适用场景 | 语义检索 | 关系推理、知识问答 |
3.3 三种数据结构的融合
#mermaid-svg-SfIuP5yOVSP4iueT{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-SfIuP5yOVSP4iueT .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-SfIuP5yOVSP4iueT .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-SfIuP5yOVSP4iueT .error-icon{fill:#552222;}#mermaid-svg-SfIuP5yOVSP4iueT .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-SfIuP5yOVSP4iueT .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-SfIuP5yOVSP4iueT .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-SfIuP5yOVSP4iueT .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-SfIuP5yOVSP4iueT .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-SfIuP5yOVSP4iueT .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-SfIuP5yOVSP4iueT .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-SfIuP5yOVSP4iueT .marker{fill:#333333;stroke:#333333;}#mermaid-svg-SfIuP5yOVSP4iueT .marker.cross{stroke:#333333;}#mermaid-svg-SfIuP5yOVSP4iueT svg{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-SfIuP5yOVSP4iueT p{margin:0;}#mermaid-svg-SfIuP5yOVSP4iueT .label{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;color:#333;}#mermaid-svg-SfIuP5yOVSP4iueT .cluster-label text{fill:#333;}#mermaid-svg-SfIuP5yOVSP4iueT .cluster-label span{color:#333;}#mermaid-svg-SfIuP5yOVSP4iueT .cluster-label span p{background-color:transparent;}#mermaid-svg-SfIuP5yOVSP4iueT .label text,#mermaid-svg-SfIuP5yOVSP4iueT span{fill:#333;color:#333;}#mermaid-svg-SfIuP5yOVSP4iueT .node rect,#mermaid-svg-SfIuP5yOVSP4iueT .node circle,#mermaid-svg-SfIuP5yOVSP4iueT .node ellipse,#mermaid-svg-SfIuP5yOVSP4iueT .node polygon,#mermaid-svg-SfIuP5yOVSP4iueT .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-SfIuP5yOVSP4iueT .rough-node .label text,#mermaid-svg-SfIuP5yOVSP4iueT .node .label text,#mermaid-svg-SfIuP5yOVSP4iueT .image-shape .label,#mermaid-svg-SfIuP5yOVSP4iueT .icon-shape .label{text-anchor:middle;}#mermaid-svg-SfIuP5yOVSP4iueT .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-SfIuP5yOVSP4iueT .rough-node .label,#mermaid-svg-SfIuP5yOVSP4iueT .node .label,#mermaid-svg-SfIuP5yOVSP4iueT .image-shape .label,#mermaid-svg-SfIuP5yOVSP4iueT .icon-shape .label{text-align:center;}#mermaid-svg-SfIuP5yOVSP4iueT .node.clickable{cursor:pointer;}#mermaid-svg-SfIuP5yOVSP4iueT .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-SfIuP5yOVSP4iueT .arrowheadPath{fill:#333333;}#mermaid-svg-SfIuP5yOVSP4iueT .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-SfIuP5yOVSP4iueT .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-SfIuP5yOVSP4iueT .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-SfIuP5yOVSP4iueT .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-SfIuP5yOVSP4iueT .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-SfIuP5yOVSP4iueT .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-SfIuP5yOVSP4iueT .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-SfIuP5yOVSP4iueT .cluster text{fill:#333;}#mermaid-svg-SfIuP5yOVSP4iueT .cluster span{color:#333;}#mermaid-svg-SfIuP5yOVSP4iueT div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-SfIuP5yOVSP4iueT .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-SfIuP5yOVSP4iueT rect.text{fill:none;stroke-width:0;}#mermaid-svg-SfIuP5yOVSP4iueT .icon-shape,#mermaid-svg-SfIuP5yOVSP4iueT .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-SfIuP5yOVSP4iueT .icon-shape p,#mermaid-svg-SfIuP5yOVSP4iueT .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-SfIuP5yOVSP4iueT .icon-shape rect,#mermaid-svg-SfIuP5yOVSP4iueT .image-shape rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-SfIuP5yOVSP4iueT .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-SfIuP5yOVSP4iueT .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-SfIuP5yOVSP4iueT :root{–mermaid-font-family:\”trebuchet ms\”,verdana,arial,sans-serif;}
融合架构
用户Query
向量检索
图谱检索
关键词检索
语义召回
关系召回
精确召回
结果融合
最终结果
融合优势:
| 向量检索 | 语义理解强 | 缺乏精确性 | 语义相似问题 |
| 图谱检索 | 关系推理强 | 构建成本高 | 关系查询、多跳推理 |
| 关键词检索 | 精确匹配 | 缺乏语义 | 精确查询、专业术语 |
四、知识图谱的构建方法
4.1 构建流程总览
#mermaid-svg-Q3flxdZZwHdOpI0v{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-Q3flxdZZwHdOpI0v .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-Q3flxdZZwHdOpI0v .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-Q3flxdZZwHdOpI0v .error-icon{fill:#552222;}#mermaid-svg-Q3flxdZZwHdOpI0v .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-Q3flxdZZwHdOpI0v .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-Q3flxdZZwHdOpI0v .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-Q3flxdZZwHdOpI0v .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-Q3flxdZZwHdOpI0v .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-Q3flxdZZwHdOpI0v .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-Q3flxdZZwHdOpI0v .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-Q3flxdZZwHdOpI0v .marker{fill:#333333;stroke:#333333;}#mermaid-svg-Q3flxdZZwHdOpI0v .marker.cross{stroke:#333333;}#mermaid-svg-Q3flxdZZwHdOpI0v svg{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-Q3flxdZZwHdOpI0v p{margin:0;}#mermaid-svg-Q3flxdZZwHdOpI0v .label{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;color:#333;}#mermaid-svg-Q3flxdZZwHdOpI0v .cluster-label text{fill:#333;}#mermaid-svg-Q3flxdZZwHdOpI0v .cluster-label span{color:#333;}#mermaid-svg-Q3flxdZZwHdOpI0v .cluster-label span p{background-color:transparent;}#mermaid-svg-Q3flxdZZwHdOpI0v .label text,#mermaid-svg-Q3flxdZZwHdOpI0v span{fill:#333;color:#333;}#mermaid-svg-Q3flxdZZwHdOpI0v .node rect,#mermaid-svg-Q3flxdZZwHdOpI0v .node circle,#mermaid-svg-Q3flxdZZwHdOpI0v .node ellipse,#mermaid-svg-Q3flxdZZwHdOpI0v .node polygon,#mermaid-svg-Q3flxdZZwHdOpI0v .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-Q3flxdZZwHdOpI0v .rough-node .label text,#mermaid-svg-Q3flxdZZwHdOpI0v .node .label text,#mermaid-svg-Q3flxdZZwHdOpI0v .image-shape .label,#mermaid-svg-Q3flxdZZwHdOpI0v .icon-shape .label{text-anchor:middle;}#mermaid-svg-Q3flxdZZwHdOpI0v .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-Q3flxdZZwHdOpI0v .rough-node .label,#mermaid-svg-Q3flxdZZwHdOpI0v .node .label,#mermaid-svg-Q3flxdZZwHdOpI0v .image-shape .label,#mermaid-svg-Q3flxdZZwHdOpI0v .icon-shape .label{text-align:center;}#mermaid-svg-Q3flxdZZwHdOpI0v .node.clickable{cursor:pointer;}#mermaid-svg-Q3flxdZZwHdOpI0v .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-Q3flxdZZwHdOpI0v .arrowheadPath{fill:#333333;}#mermaid-svg-Q3flxdZZwHdOpI0v .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-Q3flxdZZwHdOpI0v .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-Q3flxdZZwHdOpI0v .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-Q3flxdZZwHdOpI0v .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-Q3flxdZZwHdOpI0v .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-Q3flxdZZwHdOpI0v .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-Q3flxdZZwHdOpI0v .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-Q3flxdZZwHdOpI0v .cluster text{fill:#333;}#mermaid-svg-Q3flxdZZwHdOpI0v .cluster span{color:#333;}#mermaid-svg-Q3flxdZZwHdOpI0v div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-Q3flxdZZwHdOpI0v .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-Q3flxdZZwHdOpI0v rect.text{fill:none;stroke-width:0;}#mermaid-svg-Q3flxdZZwHdOpI0v .icon-shape,#mermaid-svg-Q3flxdZZwHdOpI0v .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-Q3flxdZZwHdOpI0v .icon-shape p,#mermaid-svg-Q3flxdZZwHdOpI0v .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-Q3flxdZZwHdOpI0v .icon-shape rect,#mermaid-svg-Q3flxdZZwHdOpI0v .image-shape rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-Q3flxdZZwHdOpI0v .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-Q3flxdZZwHdOpI0v .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-Q3flxdZZwHdOpI0v :root{–mermaid-font-family:\”trebuchet ms\”,verdana,arial,sans-serif;}
知识存储
知识融合
知识抽取
数据源
结构化数据
半结构化数据
非结构化数据
实体抽取 NER
关系抽取 RE
属性抽取 AE
实体对齐
关系融合
知识推理
图数据库
三元组存储
4.2 知识抽取
#mermaid-svg-aYMWz3mgKcEg7OaV{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-aYMWz3mgKcEg7OaV .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-aYMWz3mgKcEg7OaV .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-aYMWz3mgKcEg7OaV .error-icon{fill:#552222;}#mermaid-svg-aYMWz3mgKcEg7OaV .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-aYMWz3mgKcEg7OaV .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-aYMWz3mgKcEg7OaV .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-aYMWz3mgKcEg7OaV .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-aYMWz3mgKcEg7OaV .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-aYMWz3mgKcEg7OaV .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-aYMWz3mgKcEg7OaV .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-aYMWz3mgKcEg7OaV .marker{fill:#333333;stroke:#333333;}#mermaid-svg-aYMWz3mgKcEg7OaV .marker.cross{stroke:#333333;}#mermaid-svg-aYMWz3mgKcEg7OaV svg{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-aYMWz3mgKcEg7OaV p{margin:0;}#mermaid-svg-aYMWz3mgKcEg7OaV .label{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;color:#333;}#mermaid-svg-aYMWz3mgKcEg7OaV .cluster-label text{fill:#333;}#mermaid-svg-aYMWz3mgKcEg7OaV .cluster-label span{color:#333;}#mermaid-svg-aYMWz3mgKcEg7OaV .cluster-label span p{background-color:transparent;}#mermaid-svg-aYMWz3mgKcEg7OaV .label text,#mermaid-svg-aYMWz3mgKcEg7OaV span{fill:#333;color:#333;}#mermaid-svg-aYMWz3mgKcEg7OaV .node rect,#mermaid-svg-aYMWz3mgKcEg7OaV .node circle,#mermaid-svg-aYMWz3mgKcEg7OaV .node ellipse,#mermaid-svg-aYMWz3mgKcEg7OaV .node polygon,#mermaid-svg-aYMWz3mgKcEg7OaV .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-aYMWz3mgKcEg7OaV .rough-node .label text,#mermaid-svg-aYMWz3mgKcEg7OaV .node .label text,#mermaid-svg-aYMWz3mgKcEg7OaV .image-shape .label,#mermaid-svg-aYMWz3mgKcEg7OaV .icon-shape .label{text-anchor:middle;}#mermaid-svg-aYMWz3mgKcEg7OaV .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-aYMWz3mgKcEg7OaV .rough-node .label,#mermaid-svg-aYMWz3mgKcEg7OaV .node .label,#mermaid-svg-aYMWz3mgKcEg7OaV .image-shape .label,#mermaid-svg-aYMWz3mgKcEg7OaV .icon-shape .label{text-align:center;}#mermaid-svg-aYMWz3mgKcEg7OaV .node.clickable{cursor:pointer;}#mermaid-svg-aYMWz3mgKcEg7OaV .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-aYMWz3mgKcEg7OaV .arrowheadPath{fill:#333333;}#mermaid-svg-aYMWz3mgKcEg7OaV .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-aYMWz3mgKcEg7OaV .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-aYMWz3mgKcEg7OaV .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-aYMWz3mgKcEg7OaV .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-aYMWz3mgKcEg7OaV .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-aYMWz3mgKcEg7OaV .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-aYMWz3mgKcEg7OaV .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-aYMWz3mgKcEg7OaV .cluster text{fill:#333;}#mermaid-svg-aYMWz3mgKcEg7OaV .cluster span{color:#333;}#mermaid-svg-aYMWz3mgKcEg7OaV div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-aYMWz3mgKcEg7OaV .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-aYMWz3mgKcEg7OaV rect.text{fill:none;stroke-width:0;}#mermaid-svg-aYMWz3mgKcEg7OaV .icon-shape,#mermaid-svg-aYMWz3mgKcEg7OaV .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-aYMWz3mgKcEg7OaV .icon-shape p,#mermaid-svg-aYMWz3mgKcEg7OaV .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-aYMWz3mgKcEg7OaV .icon-shape rect,#mermaid-svg-aYMWz3mgKcEg7OaV .image-shape rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-aYMWz3mgKcEg7OaV .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-aYMWz3mgKcEg7OaV .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-aYMWz3mgKcEg7OaV :root{–mermaid-font-family:\”trebuchet ms\”,verdana,arial,sans-serif;}
知识抽取
实体抽取
关系抽取
属性抽取
NER命名实体识别
实体分类
实体链接
监督学习
远程监督
开放域抽取
属性值抽取
属性归一化
实体抽取代码示例:
from transformers import AutoTokenizer, AutoModelForTokenClassification
import torch
class EntityExtractor:
"""
实体抽取器
使用预训练的NER模型识别文本中的实体
"""
def __init__(self, model_name: str = "hfl/chinese-roberta-wwm-ext"):
self.tokenizer = AutoTokenizer.from_pretrained(model_name)
self.model = AutoModelForTokenClassification.from_pretrained(model_name)
def extract(self, text: str) –> list:
"""
从文本中抽取实体
Args:
text: 输入文本
Returns:
实体列表 [{"text": "张三", "type": "PERSON", "start": 0, "end": 2}, …]
"""
# Tokenize
inputs = self.tokenizer(
text,
return_tensors="pt",
truncation=True,
max_length=512
)
# 模型推理
with torch.no_grad():
outputs = self.model(**inputs)
# 解码标签
predictions = torch.argmax(outputs.logits, dim=2)
# 提取实体
entities = []
current_entity = None
for i, (token, pred) in enumerate(zip(inputs["input_ids"][0], predictions[0])):
label = self.tokenizer.decode([pred])
# BIO标注解析
if label.startswith("B-"):
if current_entity:
entities.append(current_entity)
current_entity = {
"text": self.tokenizer.decode([token]),
"type": label[2:],
"start": i,
"end": i + 1
}
elif label.startswith("I-") and current_entity:
current_entity["text"] += self.tokenizer.decode([token])
current_entity["end"] = i + 1
if current_entity:
entities.append(current_entity)
return entities
# 使用示例
if __name__ == "__main__":
extractor = EntityExtractor()
text = "张三在阿里巴巴工作,他是一名Python开发者"
entities = extractor.extract(text)
for entity in entities:
print(f"实体: {entity['text']}, 类型: {entity['type']}")
4.3 知识融合
#mermaid-svg-BOOzFRurWdh5mAxv{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-BOOzFRurWdh5mAxv .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-BOOzFRurWdh5mAxv .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-BOOzFRurWdh5mAxv .error-icon{fill:#552222;}#mermaid-svg-BOOzFRurWdh5mAxv .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-BOOzFRurWdh5mAxv .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-BOOzFRurWdh5mAxv .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-BOOzFRurWdh5mAxv .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-BOOzFRurWdh5mAxv .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-BOOzFRurWdh5mAxv .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-BOOzFRurWdh5mAxv .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-BOOzFRurWdh5mAxv .marker{fill:#333333;stroke:#333333;}#mermaid-svg-BOOzFRurWdh5mAxv .marker.cross{stroke:#333333;}#mermaid-svg-BOOzFRurWdh5mAxv svg{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-BOOzFRurWdh5mAxv p{margin:0;}#mermaid-svg-BOOzFRurWdh5mAxv .label{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;color:#333;}#mermaid-svg-BOOzFRurWdh5mAxv .cluster-label text{fill:#333;}#mermaid-svg-BOOzFRurWdh5mAxv .cluster-label span{color:#333;}#mermaid-svg-BOOzFRurWdh5mAxv .cluster-label span p{background-color:transparent;}#mermaid-svg-BOOzFRurWdh5mAxv .label text,#mermaid-svg-BOOzFRurWdh5mAxv span{fill:#333;color:#333;}#mermaid-svg-BOOzFRurWdh5mAxv .node rect,#mermaid-svg-BOOzFRurWdh5mAxv .node circle,#mermaid-svg-BOOzFRurWdh5mAxv .node ellipse,#mermaid-svg-BOOzFRurWdh5mAxv .node polygon,#mermaid-svg-BOOzFRurWdh5mAxv .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-BOOzFRurWdh5mAxv .rough-node .label text,#mermaid-svg-BOOzFRurWdh5mAxv .node .label text,#mermaid-svg-BOOzFRurWdh5mAxv .image-shape .label,#mermaid-svg-BOOzFRurWdh5mAxv .icon-shape .label{text-anchor:middle;}#mermaid-svg-BOOzFRurWdh5mAxv .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-BOOzFRurWdh5mAxv .rough-node .label,#mermaid-svg-BOOzFRurWdh5mAxv .node .label,#mermaid-svg-BOOzFRurWdh5mAxv .image-shape .label,#mermaid-svg-BOOzFRurWdh5mAxv .icon-shape .label{text-align:center;}#mermaid-svg-BOOzFRurWdh5mAxv .node.clickable{cursor:pointer;}#mermaid-svg-BOOzFRurWdh5mAxv .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-BOOzFRurWdh5mAxv .arrowheadPath{fill:#333333;}#mermaid-svg-BOOzFRurWdh5mAxv .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-BOOzFRurWdh5mAxv .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-BOOzFRurWdh5mAxv .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-BOOzFRurWdh5mAxv .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-BOOzFRurWdh5mAxv .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-BOOzFRurWdh5mAxv .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-BOOzFRurWdh5mAxv .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-BOOzFRurWdh5mAxv .cluster text{fill:#333;}#mermaid-svg-BOOzFRurWdh5mAxv .cluster span{color:#333;}#mermaid-svg-BOOzFRurWdh5mAxv div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-BOOzFRurWdh5mAxv .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-BOOzFRurWdh5mAxv rect.text{fill:none;stroke-width:0;}#mermaid-svg-BOOzFRurWdh5mAxv .icon-shape,#mermaid-svg-BOOzFRurWdh5mAxv .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-BOOzFRurWdh5mAxv .icon-shape p,#mermaid-svg-BOOzFRurWdh5mAxv .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-BOOzFRurWdh5mAxv .icon-shape rect,#mermaid-svg-BOOzFRurWdh5mAxv .image-shape rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-BOOzFRurWdh5mAxv .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-BOOzFRurWdh5mAxv .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-BOOzFRurWdh5mAxv :root{–mermaid-font-family:\”trebuchet ms\”,verdana,arial,sans-serif;}
知识融合
实体对齐
关系融合
冲突消解
同名消歧
异名归一
关系对齐
关系推理
置信度评估
投票机制
实体对齐代码示例:
from typing import Dict, List, Optional
import numpy as np
class EntityAlignment:
"""
实体对齐
判断两个实体是否指向同一对象
"""
def __init__(self, similarity_threshold: float = 0.9):
self.threshold = similarity_threshold
def align(
self,
entity1: Dict,
entity2: Dict
) –> bool:
"""
判断两个实体是否相同
Args:
entity1: 实体1 {"name": "张三", "type": "Person", …}
entity2: 实体2 {"name": "张三丰", "type": "Person", …}
Returns:
是否为同一实体
"""
# 1. 名称相似度
name_sim = self._compute_name_similarity(
entity1.get("name", ""),
entity2.get("name", "")
)
# 2. 类型一致性
type_match = entity1.get("type") == entity2.get("type")
# 3. 属性相似度
attr_sim = self._compute_attribute_similarity(
entity1.get("attributes", {}),
entity2.get("attributes", {})
)
# 综合判断
score = 0.5 * name_sim + 0.2 * int(type_match) + 0.3 * attr_sim
return score >= self.threshold
def _compute_name_similarity(self, name1: str, name2: str) –> float:
"""计算名称相似度"""
if not name1 or not name2:
return 0.0
# 编辑距离
from difflib import SequenceMatcher
return SequenceMatcher(None, name1, name2).ratio()
def _compute_attribute_similarity(
self,
attrs1: Dict,
attrs2: Dict
) –> float:
"""计算属性相似度"""
if not attrs1 or not attrs2:
return 0.0
common_keys = set(attrs1.keys()) & set(attrs2.keys())
if not common_keys:
return 0.0
similarities = []
for key in common_keys:
if attrs1[key] == attrs2[key]:
similarities.append(1.0)
else:
similarities.append(0.0)
return np.mean(similarities)
4.4 知识存储
#mermaid-svg-04KFZTnJrFNPVcmL{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-04KFZTnJrFNPVcmL .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-04KFZTnJrFNPVcmL .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-04KFZTnJrFNPVcmL .error-icon{fill:#552222;}#mermaid-svg-04KFZTnJrFNPVcmL .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-04KFZTnJrFNPVcmL .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-04KFZTnJrFNPVcmL .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-04KFZTnJrFNPVcmL .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-04KFZTnJrFNPVcmL .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-04KFZTnJrFNPVcmL .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-04KFZTnJrFNPVcmL .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-04KFZTnJrFNPVcmL .marker{fill:#333333;stroke:#333333;}#mermaid-svg-04KFZTnJrFNPVcmL .marker.cross{stroke:#333333;}#mermaid-svg-04KFZTnJrFNPVcmL svg{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-04KFZTnJrFNPVcmL p{margin:0;}#mermaid-svg-04KFZTnJrFNPVcmL .label{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;color:#333;}#mermaid-svg-04KFZTnJrFNPVcmL .cluster-label text{fill:#333;}#mermaid-svg-04KFZTnJrFNPVcmL .cluster-label span{color:#333;}#mermaid-svg-04KFZTnJrFNPVcmL .cluster-label span p{background-color:transparent;}#mermaid-svg-04KFZTnJrFNPVcmL .label text,#mermaid-svg-04KFZTnJrFNPVcmL span{fill:#333;color:#333;}#mermaid-svg-04KFZTnJrFNPVcmL .node rect,#mermaid-svg-04KFZTnJrFNPVcmL .node circle,#mermaid-svg-04KFZTnJrFNPVcmL .node ellipse,#mermaid-svg-04KFZTnJrFNPVcmL .node polygon,#mermaid-svg-04KFZTnJrFNPVcmL .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-04KFZTnJrFNPVcmL .rough-node .label text,#mermaid-svg-04KFZTnJrFNPVcmL .node .label text,#mermaid-svg-04KFZTnJrFNPVcmL .image-shape .label,#mermaid-svg-04KFZTnJrFNPVcmL .icon-shape .label{text-anchor:middle;}#mermaid-svg-04KFZTnJrFNPVcmL .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-04KFZTnJrFNPVcmL .rough-node .label,#mermaid-svg-04KFZTnJrFNPVcmL .node .label,#mermaid-svg-04KFZTnJrFNPVcmL .image-shape .label,#mermaid-svg-04KFZTnJrFNPVcmL .icon-shape .label{text-align:center;}#mermaid-svg-04KFZTnJrFNPVcmL .node.clickable{cursor:pointer;}#mermaid-svg-04KFZTnJrFNPVcmL .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-04KFZTnJrFNPVcmL .arrowheadPath{fill:#333333;}#mermaid-svg-04KFZTnJrFNPVcmL .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-04KFZTnJrFNPVcmL .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-04KFZTnJrFNPVcmL .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-04KFZTnJrFNPVcmL .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-04KFZTnJrFNPVcmL .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-04KFZTnJrFNPVcmL .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-04KFZTnJrFNPVcmL .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-04KFZTnJrFNPVcmL .cluster text{fill:#333;}#mermaid-svg-04KFZTnJrFNPVcmL .cluster span{color:#333;}#mermaid-svg-04KFZTnJrFNPVcmL div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-04KFZTnJrFNPVcmL .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-04KFZTnJrFNPVcmL rect.text{fill:none;stroke-width:0;}#mermaid-svg-04KFZTnJrFNPVcmL .icon-shape,#mermaid-svg-04KFZTnJrFNPVcmL .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-04KFZTnJrFNPVcmL .icon-shape p,#mermaid-svg-04KFZTnJrFNPVcmL .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-04KFZTnJrFNPVcmL .icon-shape rect,#mermaid-svg-04KFZTnJrFNPVcmL .image-shape rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-04KFZTnJrFNPVcmL .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-04KFZTnJrFNPVcmL .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-04KFZTnJrFNPVcmL :root{–mermaid-font-family:\”trebuchet ms\”,verdana,arial,sans-serif;}
知识存储
图数据库
三元组存储
Neo4j
JanusGraph
NebulaGraph
RDF存储
Jena
Virtuoso
图数据库对比:
| Neo4j | 成熟稳定、Cypher查询 | 中小规模图谱 |
| JanusGraph | 分布式、可扩展 | 大规模图谱 |
| NebulaGraph | 高性能、开源 | 超大规模图谱 |
五、知识图谱在AI应用中的意义
5.1 为什么AI需要知识图谱?
#mermaid-svg-lbsjcAffoJ5ilmD2{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-lbsjcAffoJ5ilmD2 .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-lbsjcAffoJ5ilmD2 .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-lbsjcAffoJ5ilmD2 .error-icon{fill:#552222;}#mermaid-svg-lbsjcAffoJ5ilmD2 .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-lbsjcAffoJ5ilmD2 .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-lbsjcAffoJ5ilmD2 .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-lbsjcAffoJ5ilmD2 .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-lbsjcAffoJ5ilmD2 .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-lbsjcAffoJ5ilmD2 .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-lbsjcAffoJ5ilmD2 .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-lbsjcAffoJ5ilmD2 .marker{fill:#333333;stroke:#333333;}#mermaid-svg-lbsjcAffoJ5ilmD2 .marker.cross{stroke:#333333;}#mermaid-svg-lbsjcAffoJ5ilmD2 svg{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-lbsjcAffoJ5ilmD2 p{margin:0;}#mermaid-svg-lbsjcAffoJ5ilmD2 .label{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;color:#333;}#mermaid-svg-lbsjcAffoJ5ilmD2 .cluster-label text{fill:#333;}#mermaid-svg-lbsjcAffoJ5ilmD2 .cluster-label span{color:#333;}#mermaid-svg-lbsjcAffoJ5ilmD2 .cluster-label span p{background-color:transparent;}#mermaid-svg-lbsjcAffoJ5ilmD2 .label text,#mermaid-svg-lbsjcAffoJ5ilmD2 span{fill:#333;color:#333;}#mermaid-svg-lbsjcAffoJ5ilmD2 .node rect,#mermaid-svg-lbsjcAffoJ5ilmD2 .node circle,#mermaid-svg-lbsjcAffoJ5ilmD2 .node ellipse,#mermaid-svg-lbsjcAffoJ5ilmD2 .node polygon,#mermaid-svg-lbsjcAffoJ5ilmD2 .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-lbsjcAffoJ5ilmD2 .rough-node .label text,#mermaid-svg-lbsjcAffoJ5ilmD2 .node .label text,#mermaid-svg-lbsjcAffoJ5ilmD2 .image-shape .label,#mermaid-svg-lbsjcAffoJ5ilmD2 .icon-shape .label{text-anchor:middle;}#mermaid-svg-lbsjcAffoJ5ilmD2 .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-lbsjcAffoJ5ilmD2 .rough-node .label,#mermaid-svg-lbsjcAffoJ5ilmD2 .node .label,#mermaid-svg-lbsjcAffoJ5ilmD2 .image-shape .label,#mermaid-svg-lbsjcAffoJ5ilmD2 .icon-shape .label{text-align:center;}#mermaid-svg-lbsjcAffoJ5ilmD2 .node.clickable{cursor:pointer;}#mermaid-svg-lbsjcAffoJ5ilmD2 .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-lbsjcAffoJ5ilmD2 .arrowheadPath{fill:#333333;}#mermaid-svg-lbsjcAffoJ5ilmD2 .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-lbsjcAffoJ5ilmD2 .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-lbsjcAffoJ5ilmD2 .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-lbsjcAffoJ5ilmD2 .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-lbsjcAffoJ5ilmD2 .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-lbsjcAffoJ5ilmD2 .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-lbsjcAffoJ5ilmD2 .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-lbsjcAffoJ5ilmD2 .cluster text{fill:#333;}#mermaid-svg-lbsjcAffoJ5ilmD2 .cluster span{color:#333;}#mermaid-svg-lbsjcAffoJ5ilmD2 div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-lbsjcAffoJ5ilmD2 .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-lbsjcAffoJ5ilmD2 rect.text{fill:none;stroke-width:0;}#mermaid-svg-lbsjcAffoJ5ilmD2 .icon-shape,#mermaid-svg-lbsjcAffoJ5ilmD2 .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-lbsjcAffoJ5ilmD2 .icon-shape p,#mermaid-svg-lbsjcAffoJ5ilmD2 .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-lbsjcAffoJ5ilmD2 .icon-shape rect,#mermaid-svg-lbsjcAffoJ5ilmD2 .image-shape rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-lbsjcAffoJ5ilmD2 .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-lbsjcAffoJ5ilmD2 .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-lbsjcAffoJ5ilmD2 :root{–mermaid-font-family:\”trebuchet ms\”,verdana,arial,sans-serif;}
知识图谱的价值
传统AI的局限
语义鸿沟
理解表面文本缺乏深层语义
推理能力弱
无法进行复杂推理
可解释性差
黑盒决策
知识碎片化
缺乏知识关联
结构化知识
实体关系明确
推理能力
基于关系的推理
可解释性
推理路径可视化
知识关联
知识网络化
核心价值:
5.2 知识图谱在RAG中的独特作用
#mermaid-svg-EpD8tZ6OvL7vJc3I{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-EpD8tZ6OvL7vJc3I .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-EpD8tZ6OvL7vJc3I .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-EpD8tZ6OvL7vJc3I .error-icon{fill:#552222;}#mermaid-svg-EpD8tZ6OvL7vJc3I .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-EpD8tZ6OvL7vJc3I .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-EpD8tZ6OvL7vJc3I .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-EpD8tZ6OvL7vJc3I .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-EpD8tZ6OvL7vJc3I .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-EpD8tZ6OvL7vJc3I .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-EpD8tZ6OvL7vJc3I .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-EpD8tZ6OvL7vJc3I .marker{fill:#333333;stroke:#333333;}#mermaid-svg-EpD8tZ6OvL7vJc3I .marker.cross{stroke:#333333;}#mermaid-svg-EpD8tZ6OvL7vJc3I svg{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-EpD8tZ6OvL7vJc3I p{margin:0;}#mermaid-svg-EpD8tZ6OvL7vJc3I .label{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;color:#333;}#mermaid-svg-EpD8tZ6OvL7vJc3I .cluster-label text{fill:#333;}#mermaid-svg-EpD8tZ6OvL7vJc3I .cluster-label span{color:#333;}#mermaid-svg-EpD8tZ6OvL7vJc3I .cluster-label span p{background-color:transparent;}#mermaid-svg-EpD8tZ6OvL7vJc3I .label text,#mermaid-svg-EpD8tZ6OvL7vJc3I span{fill:#333;color:#333;}#mermaid-svg-EpD8tZ6OvL7vJc3I .node rect,#mermaid-svg-EpD8tZ6OvL7vJc3I .node circle,#mermaid-svg-EpD8tZ6OvL7vJc3I .node ellipse,#mermaid-svg-EpD8tZ6OvL7vJc3I .node polygon,#mermaid-svg-EpD8tZ6OvL7vJc3I .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-EpD8tZ6OvL7vJc3I .rough-node .label text,#mermaid-svg-EpD8tZ6OvL7vJc3I .node .label text,#mermaid-svg-EpD8tZ6OvL7vJc3I .image-shape .label,#mermaid-svg-EpD8tZ6OvL7vJc3I .icon-shape .label{text-anchor:middle;}#mermaid-svg-EpD8tZ6OvL7vJc3I .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-EpD8tZ6OvL7vJc3I .rough-node .label,#mermaid-svg-EpD8tZ6OvL7vJc3I .node .label,#mermaid-svg-EpD8tZ6OvL7vJc3I .image-shape .label,#mermaid-svg-EpD8tZ6OvL7vJc3I .icon-shape .label{text-align:center;}#mermaid-svg-EpD8tZ6OvL7vJc3I .node.clickable{cursor:pointer;}#mermaid-svg-EpD8tZ6OvL7vJc3I .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-EpD8tZ6OvL7vJc3I .arrowheadPath{fill:#333333;}#mermaid-svg-EpD8tZ6OvL7vJc3I .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-EpD8tZ6OvL7vJc3I .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-EpD8tZ6OvL7vJc3I .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-EpD8tZ6OvL7vJc3I .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-EpD8tZ6OvL7vJc3I .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-EpD8tZ6OvL7vJc3I .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-EpD8tZ6OvL7vJc3I .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-EpD8tZ6OvL7vJc3I .cluster text{fill:#333;}#mermaid-svg-EpD8tZ6OvL7vJc3I .cluster span{color:#333;}#mermaid-svg-EpD8tZ6OvL7vJc3I div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-EpD8tZ6OvL7vJc3I .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-EpD8tZ6OvL7vJc3I rect.text{fill:none;stroke-width:0;}#mermaid-svg-EpD8tZ6OvL7vJc3I .icon-shape,#mermaid-svg-EpD8tZ6OvL7vJc3I .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-EpD8tZ6OvL7vJc3I .icon-shape p,#mermaid-svg-EpD8tZ6OvL7vJc3I .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-EpD8tZ6OvL7vJc3I .icon-shape rect,#mermaid-svg-EpD8tZ6OvL7vJc3I .image-shape rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-EpD8tZ6OvL7vJc3I .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-EpD8tZ6OvL7vJc3I .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-EpD8tZ6OvL7vJc3I :root{–mermaid-font-family:\”trebuchet ms\”,verdana,arial,sans-serif;}
图谱增强RAG
用户Query
实体识别
图谱检索
关系推理
结构化知识
知识融合
向量检索
语义知识
LLM生成
增强答案
传统RAG
用户Query
向量检索
Top-K文档
LLM生成
答案
图谱增强RAG的优势:
| 简单事实问答 | ✅ 效果好 | ✅ 效果好 |
| 多跳推理问答 | ❌ 效果差 | ✅ 效果好 |
| 关系查询 | ❌ 无法处理 | ✅ 精准回答 |
| 知识溯源 | ❌ 难以追溯 | ✅ 路径清晰 |
| 知识更新 | ⚠️ 需重新索引 | ✅ 增量更新 |
5.3 典型应用场景
#mermaid-svg-UBRUPl25PyayHcLR{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-UBRUPl25PyayHcLR .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-UBRUPl25PyayHcLR .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-UBRUPl25PyayHcLR .error-icon{fill:#552222;}#mermaid-svg-UBRUPl25PyayHcLR .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-UBRUPl25PyayHcLR .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-UBRUPl25PyayHcLR .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-UBRUPl25PyayHcLR .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-UBRUPl25PyayHcLR .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-UBRUPl25PyayHcLR .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-UBRUPl25PyayHcLR .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-UBRUPl25PyayHcLR .marker{fill:#333333;stroke:#333333;}#mermaid-svg-UBRUPl25PyayHcLR .marker.cross{stroke:#333333;}#mermaid-svg-UBRUPl25PyayHcLR svg{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-UBRUPl25PyayHcLR p{margin:0;}#mermaid-svg-UBRUPl25PyayHcLR .label{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;color:#333;}#mermaid-svg-UBRUPl25PyayHcLR .cluster-label text{fill:#333;}#mermaid-svg-UBRUPl25PyayHcLR .cluster-label span{color:#333;}#mermaid-svg-UBRUPl25PyayHcLR .cluster-label span p{background-color:transparent;}#mermaid-svg-UBRUPl25PyayHcLR .label text,#mermaid-svg-UBRUPl25PyayHcLR span{fill:#333;color:#333;}#mermaid-svg-UBRUPl25PyayHcLR .node rect,#mermaid-svg-UBRUPl25PyayHcLR .node circle,#mermaid-svg-UBRUPl25PyayHcLR .node ellipse,#mermaid-svg-UBRUPl25PyayHcLR .node polygon,#mermaid-svg-UBRUPl25PyayHcLR .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-UBRUPl25PyayHcLR .rough-node .label text,#mermaid-svg-UBRUPl25PyayHcLR .node .label text,#mermaid-svg-UBRUPl25PyayHcLR .image-shape .label,#mermaid-svg-UBRUPl25PyayHcLR .icon-shape .label{text-anchor:middle;}#mermaid-svg-UBRUPl25PyayHcLR .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-UBRUPl25PyayHcLR .rough-node .label,#mermaid-svg-UBRUPl25PyayHcLR .node .label,#mermaid-svg-UBRUPl25PyayHcLR .image-shape .label,#mermaid-svg-UBRUPl25PyayHcLR .icon-shape .label{text-align:center;}#mermaid-svg-UBRUPl25PyayHcLR .node.clickable{cursor:pointer;}#mermaid-svg-UBRUPl25PyayHcLR .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-UBRUPl25PyayHcLR .arrowheadPath{fill:#333333;}#mermaid-svg-UBRUPl25PyayHcLR .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-UBRUPl25PyayHcLR .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-UBRUPl25PyayHcLR .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-UBRUPl25PyayHcLR .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-UBRUPl25PyayHcLR .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-UBRUPl25PyayHcLR .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-UBRUPl25PyayHcLR .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-UBRUPl25PyayHcLR .cluster text{fill:#333;}#mermaid-svg-UBRUPl25PyayHcLR .cluster span{color:#333;}#mermaid-svg-UBRUPl25PyayHcLR div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-UBRUPl25PyayHcLR .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-UBRUPl25PyayHcLR rect.text{fill:none;stroke-width:0;}#mermaid-svg-UBRUPl25PyayHcLR .icon-shape,#mermaid-svg-UBRUPl25PyayHcLR .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-UBRUPl25PyayHcLR .icon-shape p,#mermaid-svg-UBRUPl25PyayHcLR .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-UBRUPl25PyayHcLR .icon-shape rect,#mermaid-svg-UBRUPl25PyayHcLR .image-shape rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-UBRUPl25PyayHcLR .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-UBRUPl25PyayHcLR .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-UBRUPl25PyayHcLR :root{–mermaid-font-family:\”trebuchet ms\”,verdana,arial,sans-serif;}
知识图谱应用
智能问答
推荐系统
搜索引擎
金融风控
医疗诊断
知识问答多跳推理
物品关联推荐用户画像
语义搜索实体链接
风险传导关联分析
症状-疾病推理用药建议
六、知识图谱的实战实现
6.1 使用Neo4j构建知识图谱
from neo4j import GraphDatabase
from typing import List, Dict, Optional
class KnowledgeGraph:
"""
知识图谱管理器
基于Neo4j实现
"""
def __init__(
self,
uri: str = "bolt://localhost:7687",
user: str = "neo4j",
password: str = "password"
):
self.driver = GraphDatabase.driver(uri, auth=(user, password))
def close(self):
"""关闭连接"""
self.driver.close()
def create_entity(
self,
entity_type: str,
entity_name: str,
properties: Dict
):
"""
创建实体节点
Args:
entity_type: 实体类型(如Person, Company)
entity_name: 实体名称
properties: 属性字典
"""
with self.driver.session() as session:
query = f"""
MERGE (e:{entity_type} {{name: $name}})
SET e += $properties
"""
session.run(query, {
"name": entity_name,
"properties": properties
})
def create_relation(
self,
from_type: str,
from_name: str,
relation: str,
to_type: str,
to_name: str,
properties: Optional[Dict] = None
):
"""
创建关系
Args:
from_type: 起始实体类型
from_name: 起始实体名称
relation: 关系类型
to_type: 目标实体类型
to_name: 目标实体名称
properties: 关系属性
"""
with self.driver.session() as session:
query = f"""
MATCH (from:{from_type} {{name: $from_name}})
MATCH (to:{to_type} {{name: $to_name}})
MERGE (from)-[r:{relation}]->(to)
SET r += $properties
"""
session.run(query, {
"from_name": from_name,
"to_name": to_name,
"properties": properties or {}
})
def find_entity(
self,
entity_name: str,
entity_type: Optional[str] = None
) –> Optional[Dict]:
"""
查找实体
Args:
entity_name: 实体名称
entity_type: 实体类型(可选)
Returns:
实体信息
"""
with self.driver.session() as session:
if entity_type:
query = f"""
MATCH (e:{entity_type} {{name: $name}})
RETURN e.name as name, labels(e) as types, properties(e) as properties
"""
else:
query = """
MATCH (e {name: $name})
RETURN e.name as name, labels(e) as types, properties(e) as properties
"""
result = session.run(query, {"name": entity_name})
record = result.single()
if record:
return {
"name": record["name"],
"types": record["types"],
"properties": record["properties"]
}
return None
def find_relations(
self,
entity_name: str,
relation_type: Optional[str] = None,
direction: str = "both"
) –> List[Dict]:
"""
查找实体的关系
Args:
entity_name: 实体名称
relation_type: 关系类型(可选)
direction: 方向(out/in/both)
Returns:
关系列表
"""
with self.driver.session() as session:
if direction == "out":
pattern = f"(e {{name: $name}})-[r{':'+relation_type if relation_type else ''}]->(target)"
elif direction == "in":
pattern = f"(target)-[r{':'+relation_type if relation_type else ''}]->(e {{name: $name}})"
else:
pattern = f"(e {{name: $name}})-[r{':'+relation_type if relation_type else ''}]-(target)"
query = f"""
MATCH {pattern}
RETURN type(r) as relation,
target.name as target_name,
labels(target) as target_types,
properties(r) as relation_properties
"""
result = session.run(query, {"name": entity_name})
return [
{
"relation": record["relation"],
"target_name": record["target_name"],
"target_types": record["target_types"],
"relation_properties": record["relation_properties"]
}
for record in result
]
def find_path(
self,
from_name: str,
to_name: str,
max_depth: int = 3
) –> List[Dict]:
"""
查找两个实体间的路径
Args:
from_name: 起始实体名称
to_name: 目标实体名称
max_depth: 最大深度
Returns:
路径列表
"""
with self.driver.session() as session:
query = f"""
MATCH path = (start {{name: $from_name}})-[*1..{max_depth}]-(end {{name: $to_name}})
RETURN
[node in nodes(path) | node.name] as node_names,
[rel in relationships(path) | type(rel)] as relation_types,
length(path) as path_length
ORDER BY path_length
LIMIT 10
"""
result = session.run(query, {
"from_name": from_name,
"to_name": to_name
})
paths = []
for record in result:
path_info = {
"nodes": record["node_names"],
"relations": record["relation_types"],
"length": record["path_length"],
"description": self._describe_path(
record["node_names"],
record["relation_types"]
)
}
paths.append(path_info)
return paths
def _describe_path(self, nodes: List[str], relations: List[str]) –> str:
"""生成路径描述"""
description_parts = []
for i, relation in enumerate(relations):
description_parts.append(f"{nodes[i]} –[{relation}]–> {nodes[i+1]}")
return " | ".join(description_parts)
def multi_hop_query(
self,
entity_name: str,
relation_chain: List[str]
) –> List[str]:
"""
多跳查询
Args:
entity_name: 起始实体名称
relation_chain: 关系链 ["工作于", "位于"]
Returns:
结果实体列表
"""
with self.driver.session() as session:
# 构建Cypher查询
match_pattern = f"(start {{name: $entity_name}})"
for i, relation in enumerate(relation_chain):
match_pattern += f"-[:{relation}]->(n{i})"
query = f"""
MATCH {match_pattern}
RETURN n{len(relation_chain)–1}.name as result
"""
result = session.run(query, {"entity_name": entity_name})
return [record["result"] for record in result]
# 使用示例
if __name__ == "__main__":
# 初始化知识图谱
kg = KnowledgeGraph()
# 创建实体
kg.create_entity("Person", "张三", {"age": 25, "skill": "Python"})
kg.create_entity("Company", "阿里巴巴", {"industry": "互联网"})
kg.create_entity("City", "杭州", {"province": "浙江"})
# 创建关系
kg.create_relation("Person", "张三", "工作于", "Company", "阿里巴巴")
kg.create_relation("Company", "阿里巴巴", "位于", "City", "杭州")
# 查询实体
entity = kg.find_entity("张三")
print(f"实体信息: {entity}")
# 查询关系
relations = kg.find_relations("张三", direction="out")
print(f"张三的关系: {relations}")
# 多跳查询
result = kg.multi_hop_query("张三", ["工作于", "位于"])
print(f"张三工作于哪个城市: {result}")
# 关闭连接
kg.close()
6.2 知识图谱问答系统
from typing import List, Dict
from langchain_openai import ChatOpenAI
from langchain.prompts import ChatPromptTemplate
class KnowledgeGraphQA:
"""
知识图谱问答系统
"""
def __init__(self, kg: KnowledgeGraph, llm_model: str = "gpt-4"):
self.kg = kg
self.llm = ChatOpenAI(model=llm_model, temperature=0)
def answer(self, question: str) –> str:
"""
回答问题
Args:
question: 用户问题
Returns:
答案
"""
# 1. 实体识别
entities = self._extract_entities(question)
if not entities:
return "抱歉,我无法识别问题中的实体。"
# 2. 意图识别
intent = self._recognize_intent(question)
# 3. 查询图谱
graph_result = self._query_graph(entities, intent)
# 4. 生成答案
answer = self._generate_answer(question, graph_result)
return answer
def _extract_entities(self, question: str) –> List[str]:
"""从问题中提取实体"""
# 简化实现:使用关键词匹配
# 实际项目中应使用NER模型
prompt = ChatPromptTemplate.from_messages([
("system", "请从以下问题中提取实体名称,返回JSON数组格式。"),
("human", "问题:{question}\\n\\n实体:")
])
chain = prompt | self.llm
result = chain.invoke({"question": question})
import json
try:
entities = json.loads(result.content)
return entities if isinstance(entities, list) else []
except:
return []
def _recognize_intent(self, question: str) –> Dict:
"""识别问题意图"""
prompt = ChatPromptTemplate.from_messages([
("system", """分析问题的意图,返回JSON格式:
{
"type": "simple_query|multi_hop|aggregation|comparison",
"relation": "关系类型",
"target": "目标实体类型"
}"""),
("human", "问题:{question}\\n\\n意图:")
])
chain = prompt | self.llm
result = chain.invoke({"question": question})
import json
try:
return json.loads(result.content)
except:
return {"type": "simple_query", "relation": None, "target": None}
def _query_graph(self, entities: List[str], intent: Dict) –> Dict:
"""查询知识图谱"""
result = {
"entities": [],
"relations": [],
"paths": []
}
# 查询实体信息
for entity_name in entities:
entity = self.kg.find_entity(entity_name)
if entity:
result["entities"].append(entity)
# 查询关系
relations = self.kg.find_relations(entity_name)
result["relations"].extend(relations)
# 如果是关系查询
if intent["type"] == "multi_hop" and len(entities) >= 2:
paths = self.kg.find_path(entities[0], entities[1])
result["paths"] = paths
return result
def _generate_answer(self, question: str, graph_result: Dict) –> str:
"""生成答案"""
prompt = ChatPromptTemplate.from_messages([
("system", "你是一个知识问答助手。请根据知识图谱查询结果回答问题。"),
("human", """问题:{question}
知识图谱查询结果:
{graph_result}
请回答问题:""")
])
chain = prompt | self.llm
result = chain.invoke({
"question": question,
"graph_result": str(graph_result)
})
return result.content
# 使用示例
if __name__ == "__main__":
kg = KnowledgeGraph()
qa = KnowledgeGraphQA(kg)
# 提问
question = "张三在哪个城市工作?"
answer = qa.answer(question)
print(f"问题: {question}")
print(f"答案: {answer}")
七、最新技术与发展趋势
7.1 技术演进时间线
#mermaid-svg-lLaG0zCgvnZoU1FQ{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-lLaG0zCgvnZoU1FQ .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-lLaG0zCgvnZoU1FQ .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-lLaG0zCgvnZoU1FQ .error-icon{fill:#552222;}#mermaid-svg-lLaG0zCgvnZoU1FQ .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-lLaG0zCgvnZoU1FQ .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-lLaG0zCgvnZoU1FQ .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-lLaG0zCgvnZoU1FQ .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-lLaG0zCgvnZoU1FQ .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-lLaG0zCgvnZoU1FQ .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-lLaG0zCgvnZoU1FQ .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-lLaG0zCgvnZoU1FQ .marker{fill:#333333;stroke:#333333;}#mermaid-svg-lLaG0zCgvnZoU1FQ .marker.cross{stroke:#333333;}#mermaid-svg-lLaG0zCgvnZoU1FQ svg{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-lLaG0zCgvnZoU1FQ p{margin:0;}#mermaid-svg-lLaG0zCgvnZoU1FQ .edge{stroke-width:3;}#mermaid-svg-lLaG0zCgvnZoU1FQ .section–1 rect,#mermaid-svg-lLaG0zCgvnZoU1FQ .section–1 path,#mermaid-svg-lLaG0zCgvnZoU1FQ .section–1 circle,#mermaid-svg-lLaG0zCgvnZoU1FQ .section–1 path{fill:hsl(240, 100%, 76.2745098039%);}#mermaid-svg-lLaG0zCgvnZoU1FQ .section–1 text{fill:#ffffff;}#mermaid-svg-lLaG0zCgvnZoU1FQ .node-icon–1{font-size:40px;color:#ffffff;}#mermaid-svg-lLaG0zCgvnZoU1FQ .section-edge–1{stroke:hsl(240, 100%, 76.2745098039%);}#mermaid-svg-lLaG0zCgvnZoU1FQ .edge-depth–1{stroke-width:17;}#mermaid-svg-lLaG0zCgvnZoU1FQ .section–1 line{stroke:hsl(60, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-lLaG0zCgvnZoU1FQ .lineWrapper line{stroke:#ffffff;}#mermaid-svg-lLaG0zCgvnZoU1FQ .disabled,#mermaid-svg-lLaG0zCgvnZoU1FQ .disabled circle,#mermaid-svg-lLaG0zCgvnZoU1FQ .disabled text{fill:lightgray;}#mermaid-svg-lLaG0zCgvnZoU1FQ .disabled text{fill:#efefef;}#mermaid-svg-lLaG0zCgvnZoU1FQ .section-0 rect,#mermaid-svg-lLaG0zCgvnZoU1FQ .section-0 path,#mermaid-svg-lLaG0zCgvnZoU1FQ .section-0 circle,#mermaid-svg-lLaG0zCgvnZoU1FQ .section-0 path{fill:hsl(60, 100%, 73.5294117647%);}#mermaid-svg-lLaG0zCgvnZoU1FQ .section-0 text{fill:black;}#mermaid-svg-lLaG0zCgvnZoU1FQ .node-icon-0{font-size:40px;color:black;}#mermaid-svg-lLaG0zCgvnZoU1FQ .section-edge-0{stroke:hsl(60, 100%, 73.5294117647%);}#mermaid-svg-lLaG0zCgvnZoU1FQ .edge-depth-0{stroke-width:14;}#mermaid-svg-lLaG0zCgvnZoU1FQ .section-0 line{stroke:hsl(240, 100%, 83.5294117647%);stroke-width:3;}#mermaid-svg-lLaG0zCgvnZoU1FQ .lineWrapper line{stroke:black;}#mermaid-svg-lLaG0zCgvnZoU1FQ .disabled,#mermaid-svg-lLaG0zCgvnZoU1FQ .disabled circle,#mermaid-svg-lLaG0zCgvnZoU1FQ .disabled text{fill:lightgray;}#mermaid-svg-lLaG0zCgvnZoU1FQ .disabled text{fill:#efefef;}#mermaid-svg-lLaG0zCgvnZoU1FQ .section-1 rect,#mermaid-svg-lLaG0zCgvnZoU1FQ .section-1 path,#mermaid-svg-lLaG0zCgvnZoU1FQ .section-1 circle,#mermaid-svg-lLaG0zCgvnZoU1FQ .section-1 path{fill:hsl(80, 100%, 76.2745098039%);}#mermaid-svg-lLaG0zCgvnZoU1FQ .section-1 text{fill:black;}#mermaid-svg-lLaG0zCgvnZoU1FQ .node-icon-1{font-size:40px;color:black;}#mermaid-svg-lLaG0zCgvnZoU1FQ .section-edge-1{stroke:hsl(80, 100%, 76.2745098039%);}#mermaid-svg-lLaG0zCgvnZoU1FQ .edge-depth-1{stroke-width:11;}#mermaid-svg-lLaG0zCgvnZoU1FQ .section-1 line{stroke:hsl(260, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-lLaG0zCgvnZoU1FQ .lineWrapper line{stroke:black;}#mermaid-svg-lLaG0zCgvnZoU1FQ .disabled,#mermaid-svg-lLaG0zCgvnZoU1FQ .disabled circle,#mermaid-svg-lLaG0zCgvnZoU1FQ .disabled text{fill:lightgray;}#mermaid-svg-lLaG0zCgvnZoU1FQ .disabled text{fill:#efefef;}#mermaid-svg-lLaG0zCgvnZoU1FQ .section-2 rect,#mermaid-svg-lLaG0zCgvnZoU1FQ .section-2 path,#mermaid-svg-lLaG0zCgvnZoU1FQ .section-2 circle,#mermaid-svg-lLaG0zCgvnZoU1FQ .section-2 path{fill:hsl(270, 100%, 76.2745098039%);}#mermaid-svg-lLaG0zCgvnZoU1FQ .section-2 text{fill:#ffffff;}#mermaid-svg-lLaG0zCgvnZoU1FQ .node-icon-2{font-size:40px;color:#ffffff;}#mermaid-svg-lLaG0zCgvnZoU1FQ .section-edge-2{stroke:hsl(270, 100%, 76.2745098039%);}#mermaid-svg-lLaG0zCgvnZoU1FQ .edge-depth-2{stroke-width:8;}#mermaid-svg-lLaG0zCgvnZoU1FQ .section-2 line{stroke:hsl(90, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-lLaG0zCgvnZoU1FQ .lineWrapper line{stroke:#ffffff;}#mermaid-svg-lLaG0zCgvnZoU1FQ .disabled,#mermaid-svg-lLaG0zCgvnZoU1FQ .disabled circle,#mermaid-svg-lLaG0zCgvnZoU1FQ .disabled text{fill:lightgray;}#mermaid-svg-lLaG0zCgvnZoU1FQ .disabled text{fill:#efefef;}#mermaid-svg-lLaG0zCgvnZoU1FQ .section-3 rect,#mermaid-svg-lLaG0zCgvnZoU1FQ .section-3 path,#mermaid-svg-lLaG0zCgvnZoU1FQ .section-3 circle,#mermaid-svg-lLaG0zCgvnZoU1FQ .section-3 path{fill:hsl(300, 100%, 76.2745098039%);}#mermaid-svg-lLaG0zCgvnZoU1FQ .section-3 text{fill:black;}#mermaid-svg-lLaG0zCgvnZoU1FQ .node-icon-3{font-size:40px;color:black;}#mermaid-svg-lLaG0zCgvnZoU1FQ .section-edge-3{stroke:hsl(300, 100%, 76.2745098039%);}#mermaid-svg-lLaG0zCgvnZoU1FQ .edge-depth-3{stroke-width:5;}#mermaid-svg-lLaG0zCgvnZoU1FQ .section-3 line{stroke:hsl(120, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-lLaG0zCgvnZoU1FQ .lineWrapper line{stroke:black;}#mermaid-svg-lLaG0zCgvnZoU1FQ .disabled,#mermaid-svg-lLaG0zCgvnZoU1FQ .disabled circle,#mermaid-svg-lLaG0zCgvnZoU1FQ .disabled text{fill:lightgray;}#mermaid-svg-lLaG0zCgvnZoU1FQ .disabled text{fill:#efefef;}#mermaid-svg-lLaG0zCgvnZoU1FQ .section-4 rect,#mermaid-svg-lLaG0zCgvnZoU1FQ .section-4 path,#mermaid-svg-lLaG0zCgvnZoU1FQ .section-4 circle,#mermaid-svg-lLaG0zCgvnZoU1FQ .section-4 path{fill:hsl(330, 100%, 76.2745098039%);}#mermaid-svg-lLaG0zCgvnZoU1FQ .section-4 text{fill:black;}#mermaid-svg-lLaG0zCgvnZoU1FQ .node-icon-4{font-size:40px;color:black;}#mermaid-svg-lLaG0zCgvnZoU1FQ .section-edge-4{stroke:hsl(330, 100%, 76.2745098039%);}#mermaid-svg-lLaG0zCgvnZoU1FQ .edge-depth-4{stroke-width:2;}#mermaid-svg-lLaG0zCgvnZoU1FQ .section-4 line{stroke:hsl(150, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-lLaG0zCgvnZoU1FQ .lineWrapper line{stroke:black;}#mermaid-svg-lLaG0zCgvnZoU1FQ .disabled,#mermaid-svg-lLaG0zCgvnZoU1FQ .disabled circle,#mermaid-svg-lLaG0zCgvnZoU1FQ .disabled text{fill:lightgray;}#mermaid-svg-lLaG0zCgvnZoU1FQ .disabled text{fill:#efefef;}#mermaid-svg-lLaG0zCgvnZoU1FQ .section-5 rect,#mermaid-svg-lLaG0zCgvnZoU1FQ .section-5 path,#mermaid-svg-lLaG0zCgvnZoU1FQ .section-5 circle,#mermaid-svg-lLaG0zCgvnZoU1FQ .section-5 path{fill:hsl(0, 100%, 76.2745098039%);}#mermaid-svg-lLaG0zCgvnZoU1FQ .section-5 text{fill:black;}#mermaid-svg-lLaG0zCgvnZoU1FQ .node-icon-5{font-size:40px;color:black;}#mermaid-svg-lLaG0zCgvnZoU1FQ .section-edge-5{stroke:hsl(0, 100%, 76.2745098039%);}#mermaid-svg-lLaG0zCgvnZoU1FQ .edge-depth-5{stroke-width:-1;}#mermaid-svg-lLaG0zCgvnZoU1FQ .section-5 line{stroke:hsl(180, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-lLaG0zCgvnZoU1FQ .lineWrapper line{stroke:black;}#mermaid-svg-lLaG0zCgvnZoU1FQ .disabled,#mermaid-svg-lLaG0zCgvnZoU1FQ .disabled circle,#mermaid-svg-lLaG0zCgvnZoU1FQ .disabled text{fill:lightgray;}#mermaid-svg-lLaG0zCgvnZoU1FQ .disabled text{fill:#efefef;}#mermaid-svg-lLaG0zCgvnZoU1FQ .section-6 rect,#mermaid-svg-lLaG0zCgvnZoU1FQ .section-6 path,#mermaid-svg-lLaG0zCgvnZoU1FQ .section-6 circle,#mermaid-svg-lLaG0zCgvnZoU1FQ .section-6 path{fill:hsl(30, 100%, 76.2745098039%);}#mermaid-svg-lLaG0zCgvnZoU1FQ .section-6 text{fill:black;}#mermaid-svg-lLaG0zCgvnZoU1FQ .node-icon-6{font-size:40px;color:black;}#mermaid-svg-lLaG0zCgvnZoU1FQ .section-edge-6{stroke:hsl(30, 100%, 76.2745098039%);}#mermaid-svg-lLaG0zCgvnZoU1FQ .edge-depth-6{stroke-width:-4;}#mermaid-svg-lLaG0zCgvnZoU1FQ .section-6 line{stroke:hsl(210, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-lLaG0zCgvnZoU1FQ .lineWrapper line{stroke:black;}#mermaid-svg-lLaG0zCgvnZoU1FQ .disabled,#mermaid-svg-lLaG0zCgvnZoU1FQ .disabled circle,#mermaid-svg-lLaG0zCgvnZoU1FQ .disabled text{fill:lightgray;}#mermaid-svg-lLaG0zCgvnZoU1FQ .disabled text{fill:#efefef;}#mermaid-svg-lLaG0zCgvnZoU1FQ .section-7 rect,#mermaid-svg-lLaG0zCgvnZoU1FQ .section-7 path,#mermaid-svg-lLaG0zCgvnZoU1FQ .section-7 circle,#mermaid-svg-lLaG0zCgvnZoU1FQ .section-7 path{fill:hsl(90, 100%, 76.2745098039%);}#mermaid-svg-lLaG0zCgvnZoU1FQ .section-7 text{fill:black;}#mermaid-svg-lLaG0zCgvnZoU1FQ .node-icon-7{font-size:40px;color:black;}#mermaid-svg-lLaG0zCgvnZoU1FQ .section-edge-7{stroke:hsl(90, 100%, 76.2745098039%);}#mermaid-svg-lLaG0zCgvnZoU1FQ .edge-depth-7{stroke-width:-7;}#mermaid-svg-lLaG0zCgvnZoU1FQ .section-7 line{stroke:hsl(270, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-lLaG0zCgvnZoU1FQ .lineWrapper line{stroke:black;}#mermaid-svg-lLaG0zCgvnZoU1FQ .disabled,#mermaid-svg-lLaG0zCgvnZoU1FQ .disabled circle,#mermaid-svg-lLaG0zCgvnZoU1FQ .disabled text{fill:lightgray;}#mermaid-svg-lLaG0zCgvnZoU1FQ .disabled text{fill:#efefef;}#mermaid-svg-lLaG0zCgvnZoU1FQ .section-8 rect,#mermaid-svg-lLaG0zCgvnZoU1FQ .section-8 path,#mermaid-svg-lLaG0zCgvnZoU1FQ .section-8 circle,#mermaid-svg-lLaG0zCgvnZoU1FQ .section-8 path{fill:hsl(150, 100%, 76.2745098039%);}#mermaid-svg-lLaG0zCgvnZoU1FQ .section-8 text{fill:black;}#mermaid-svg-lLaG0zCgvnZoU1FQ .node-icon-8{font-size:40px;color:black;}#mermaid-svg-lLaG0zCgvnZoU1FQ .section-edge-8{stroke:hsl(150, 100%, 76.2745098039%);}#mermaid-svg-lLaG0zCgvnZoU1FQ .edge-depth-8{stroke-width:-10;}#mermaid-svg-lLaG0zCgvnZoU1FQ .section-8 line{stroke:hsl(330, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-lLaG0zCgvnZoU1FQ .lineWrapper line{stroke:black;}#mermaid-svg-lLaG0zCgvnZoU1FQ .disabled,#mermaid-svg-lLaG0zCgvnZoU1FQ .disabled circle,#mermaid-svg-lLaG0zCgvnZoU1FQ .disabled text{fill:lightgray;}#mermaid-svg-lLaG0zCgvnZoU1FQ .disabled text{fill:#efefef;}#mermaid-svg-lLaG0zCgvnZoU1FQ .section-9 rect,#mermaid-svg-lLaG0zCgvnZoU1FQ .section-9 path,#mermaid-svg-lLaG0zCgvnZoU1FQ .section-9 circle,#mermaid-svg-lLaG0zCgvnZoU1FQ .section-9 path{fill:hsl(180, 100%, 76.2745098039%);}#mermaid-svg-lLaG0zCgvnZoU1FQ .section-9 text{fill:black;}#mermaid-svg-lLaG0zCgvnZoU1FQ .node-icon-9{font-size:40px;color:black;}#mermaid-svg-lLaG0zCgvnZoU1FQ .section-edge-9{stroke:hsl(180, 100%, 76.2745098039%);}#mermaid-svg-lLaG0zCgvnZoU1FQ .edge-depth-9{stroke-width:-13;}#mermaid-svg-lLaG0zCgvnZoU1FQ .section-9 line{stroke:hsl(0, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-lLaG0zCgvnZoU1FQ .lineWrapper line{stroke:black;}#mermaid-svg-lLaG0zCgvnZoU1FQ .disabled,#mermaid-svg-lLaG0zCgvnZoU1FQ .disabled circle,#mermaid-svg-lLaG0zCgvnZoU1FQ .disabled text{fill:lightgray;}#mermaid-svg-lLaG0zCgvnZoU1FQ .disabled text{fill:#efefef;}#mermaid-svg-lLaG0zCgvnZoU1FQ .section-10 rect,#mermaid-svg-lLaG0zCgvnZoU1FQ .section-10 path,#mermaid-svg-lLaG0zCgvnZoU1FQ .section-10 circle,#mermaid-svg-lLaG0zCgvnZoU1FQ .section-10 path{fill:hsl(210, 100%, 76.2745098039%);}#mermaid-svg-lLaG0zCgvnZoU1FQ .section-10 text{fill:black;}#mermaid-svg-lLaG0zCgvnZoU1FQ .node-icon-10{font-size:40px;color:black;}#mermaid-svg-lLaG0zCgvnZoU1FQ .section-edge-10{stroke:hsl(210, 100%, 76.2745098039%);}#mermaid-svg-lLaG0zCgvnZoU1FQ .edge-depth-10{stroke-width:-16;}#mermaid-svg-lLaG0zCgvnZoU1FQ .section-10 line{stroke:hsl(30, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-lLaG0zCgvnZoU1FQ .lineWrapper line{stroke:black;}#mermaid-svg-lLaG0zCgvnZoU1FQ .disabled,#mermaid-svg-lLaG0zCgvnZoU1FQ .disabled circle,#mermaid-svg-lLaG0zCgvnZoU1FQ .disabled text{fill:lightgray;}#mermaid-svg-lLaG0zCgvnZoU1FQ .disabled text{fill:#efefef;}#mermaid-svg-lLaG0zCgvnZoU1FQ .section-root rect,#mermaid-svg-lLaG0zCgvnZoU1FQ .section-root path,#mermaid-svg-lLaG0zCgvnZoU1FQ .section-root circle{fill:hsl(240, 100%, 46.2745098039%);}#mermaid-svg-lLaG0zCgvnZoU1FQ .section-root text{fill:#ffffff;}#mermaid-svg-lLaG0zCgvnZoU1FQ .icon-container{height:100%;display:flex;justify-content:center;align-items:center;}#mermaid-svg-lLaG0zCgvnZoU1FQ .edge{fill:none;}#mermaid-svg-lLaG0zCgvnZoU1FQ .eventWrapper{filter:brightness(120%);}#mermaid-svg-lLaG0zCgvnZoU1FQ :root{–mermaid-font-family:\”trebuchet ms\”,verdana,arial,sans-serif;}
2012
Google知识图谱
商业化应用开端
2016
知识图谱+深度学习
TransE/TransR表示学习
2019
知识增强预训练
ERNIE, K-BERT
2021
知识图谱+大模型
KGLM, CoLAKE
2023
LLM+知识图谱融合
ChatKBQA, ToG
2024
GraphRAG
微软图谱增强检索
知识图谱技术演进史
7.2 GraphRAG:微软最新框架
#mermaid-svg-33eU9kpq4Ptl3YeH{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-33eU9kpq4Ptl3YeH .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-33eU9kpq4Ptl3YeH .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-33eU9kpq4Ptl3YeH .error-icon{fill:#552222;}#mermaid-svg-33eU9kpq4Ptl3YeH .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-33eU9kpq4Ptl3YeH .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-33eU9kpq4Ptl3YeH .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-33eU9kpq4Ptl3YeH .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-33eU9kpq4Ptl3YeH .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-33eU9kpq4Ptl3YeH .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-33eU9kpq4Ptl3YeH .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-33eU9kpq4Ptl3YeH .marker{fill:#333333;stroke:#333333;}#mermaid-svg-33eU9kpq4Ptl3YeH .marker.cross{stroke:#333333;}#mermaid-svg-33eU9kpq4Ptl3YeH svg{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-33eU9kpq4Ptl3YeH p{margin:0;}#mermaid-svg-33eU9kpq4Ptl3YeH .label{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;color:#333;}#mermaid-svg-33eU9kpq4Ptl3YeH .cluster-label text{fill:#333;}#mermaid-svg-33eU9kpq4Ptl3YeH .cluster-label span{color:#333;}#mermaid-svg-33eU9kpq4Ptl3YeH .cluster-label span p{background-color:transparent;}#mermaid-svg-33eU9kpq4Ptl3YeH .label text,#mermaid-svg-33eU9kpq4Ptl3YeH span{fill:#333;color:#333;}#mermaid-svg-33eU9kpq4Ptl3YeH .node rect,#mermaid-svg-33eU9kpq4Ptl3YeH .node circle,#mermaid-svg-33eU9kpq4Ptl3YeH .node ellipse,#mermaid-svg-33eU9kpq4Ptl3YeH .node polygon,#mermaid-svg-33eU9kpq4Ptl3YeH .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-33eU9kpq4Ptl3YeH .rough-node .label text,#mermaid-svg-33eU9kpq4Ptl3YeH .node .label text,#mermaid-svg-33eU9kpq4Ptl3YeH .image-shape .label,#mermaid-svg-33eU9kpq4Ptl3YeH .icon-shape .label{text-anchor:middle;}#mermaid-svg-33eU9kpq4Ptl3YeH .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-33eU9kpq4Ptl3YeH .rough-node .label,#mermaid-svg-33eU9kpq4Ptl3YeH .node .label,#mermaid-svg-33eU9kpq4Ptl3YeH .image-shape .label,#mermaid-svg-33eU9kpq4Ptl3YeH .icon-shape .label{text-align:center;}#mermaid-svg-33eU9kpq4Ptl3YeH .node.clickable{cursor:pointer;}#mermaid-svg-33eU9kpq4Ptl3YeH .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-33eU9kpq4Ptl3YeH .arrowheadPath{fill:#333333;}#mermaid-svg-33eU9kpq4Ptl3YeH .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-33eU9kpq4Ptl3YeH .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-33eU9kpq4Ptl3YeH .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-33eU9kpq4Ptl3YeH .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-33eU9kpq4Ptl3YeH .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-33eU9kpq4Ptl3YeH .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-33eU9kpq4Ptl3YeH .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-33eU9kpq4Ptl3YeH .cluster text{fill:#333;}#mermaid-svg-33eU9kpq4Ptl3YeH .cluster span{color:#333;}#mermaid-svg-33eU9kpq4Ptl3YeH div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-33eU9kpq4Ptl3YeH .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-33eU9kpq4Ptl3YeH rect.text{fill:none;stroke-width:0;}#mermaid-svg-33eU9kpq4Ptl3YeH .icon-shape,#mermaid-svg-33eU9kpq4Ptl3YeH .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-33eU9kpq4Ptl3YeH .icon-shape p,#mermaid-svg-33eU9kpq4Ptl3YeH .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-33eU9kpq4Ptl3YeH .icon-shape rect,#mermaid-svg-33eU9kpq4Ptl3YeH .image-shape rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-33eU9kpq4Ptl3YeH .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-33eU9kpq4Ptl3YeH .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-33eU9kpq4Ptl3YeH :root{–mermaid-font-family:\”trebuchet ms\”,verdana,arial,sans-serif;}
GraphRAG架构
文档集合
实体抽取
关系抽取
知识图谱构建
社区发现
社区摘要
查询时检索
全局回答
局部回答
GraphRAG核心创新:
7.3 最新论文推荐
| GraphRAG | 2024 | 社区发现+分层检索 | ⭐⭐⭐⭐⭐ |
| Think-on-Graph | 2024 | LLM+图谱推理 | ⭐⭐⭐⭐⭐ |
| ChatKBQA | 2023 | 知识图谱问答 | ⭐⭐⭐⭐ |
| KGLM | 2021 | 知识增强语言模型 | ⭐⭐⭐⭐ |
八、面试问答全解析
8.1 基础概念题
Q1: 什么是知识图谱?
答案要点:
知识图谱是一种用图结构来表示知识和建模世界中实体间关系的技术。它由节点(实体/概念)和边(关系)组成,通过三元组(主语-谓语-宾语)的形式描述知识。
关键要素:
Q2: 知识图谱和关系数据库有什么区别?
答案要点:
#mermaid-svg-UWLynjQQvqcuk4fL{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-UWLynjQQvqcuk4fL .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-UWLynjQQvqcuk4fL .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-UWLynjQQvqcuk4fL .error-icon{fill:#552222;}#mermaid-svg-UWLynjQQvqcuk4fL .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-UWLynjQQvqcuk4fL .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-UWLynjQQvqcuk4fL .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-UWLynjQQvqcuk4fL .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-UWLynjQQvqcuk4fL .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-UWLynjQQvqcuk4fL .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-UWLynjQQvqcuk4fL .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-UWLynjQQvqcuk4fL .marker{fill:#333333;stroke:#333333;}#mermaid-svg-UWLynjQQvqcuk4fL .marker.cross{stroke:#333333;}#mermaid-svg-UWLynjQQvqcuk4fL svg{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-UWLynjQQvqcuk4fL p{margin:0;}#mermaid-svg-UWLynjQQvqcuk4fL .label{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;color:#333;}#mermaid-svg-UWLynjQQvqcuk4fL .cluster-label text{fill:#333;}#mermaid-svg-UWLynjQQvqcuk4fL .cluster-label span{color:#333;}#mermaid-svg-UWLynjQQvqcuk4fL .cluster-label span p{background-color:transparent;}#mermaid-svg-UWLynjQQvqcuk4fL .label text,#mermaid-svg-UWLynjQQvqcuk4fL span{fill:#333;color:#333;}#mermaid-svg-UWLynjQQvqcuk4fL .node rect,#mermaid-svg-UWLynjQQvqcuk4fL .node circle,#mermaid-svg-UWLynjQQvqcuk4fL .node ellipse,#mermaid-svg-UWLynjQQvqcuk4fL .node polygon,#mermaid-svg-UWLynjQQvqcuk4fL .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-UWLynjQQvqcuk4fL .rough-node .label text,#mermaid-svg-UWLynjQQvqcuk4fL .node .label text,#mermaid-svg-UWLynjQQvqcuk4fL .image-shape .label,#mermaid-svg-UWLynjQQvqcuk4fL .icon-shape .label{text-anchor:middle;}#mermaid-svg-UWLynjQQvqcuk4fL .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-UWLynjQQvqcuk4fL .rough-node .label,#mermaid-svg-UWLynjQQvqcuk4fL .node .label,#mermaid-svg-UWLynjQQvqcuk4fL .image-shape .label,#mermaid-svg-UWLynjQQvqcuk4fL .icon-shape .label{text-align:center;}#mermaid-svg-UWLynjQQvqcuk4fL .node.clickable{cursor:pointer;}#mermaid-svg-UWLynjQQvqcuk4fL .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-UWLynjQQvqcuk4fL .arrowheadPath{fill:#333333;}#mermaid-svg-UWLynjQQvqcuk4fL .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-UWLynjQQvqcuk4fL .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-UWLynjQQvqcuk4fL .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-UWLynjQQvqcuk4fL .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-UWLynjQQvqcuk4fL .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-UWLynjQQvqcuk4fL .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-UWLynjQQvqcuk4fL .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-UWLynjQQvqcuk4fL .cluster text{fill:#333;}#mermaid-svg-UWLynjQQvqcuk4fL .cluster span{color:#333;}#mermaid-svg-UWLynjQQvqcuk4fL div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-UWLynjQQvqcuk4fL .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-UWLynjQQvqcuk4fL rect.text{fill:none;stroke-width:0;}#mermaid-svg-UWLynjQQvqcuk4fL .icon-shape,#mermaid-svg-UWLynjQQvqcuk4fL .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-UWLynjQQvqcuk4fL .icon-shape p,#mermaid-svg-UWLynjQQvqcuk4fL .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-UWLynjQQvqcuk4fL .icon-shape rect,#mermaid-svg-UWLynjQQvqcuk4fL .image-shape rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-UWLynjQQvqcuk4fL .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-UWLynjQQvqcuk4fL .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-UWLynjQQvqcuk4fL :root{–mermaid-font-family:\”trebuchet ms\”,verdana,arial,sans-serif;}
知识图谱
图结构
直接连接
显式关系
关系数据库
表结构
外键关联
隐式关系
| 数据模型 | 表格 | 图 |
| 关系表示 | 外键(隐式) | 边(显式) |
| 查询语言 | SQL | Cypher/SPARQL |
| 灵活性 | 需预定义Schema | Schema-less |
| 推理能力 | 无 | 支持 |
8.2 技术细节题
Q3: 如何构建一个知识图谱?
答案要点:
#mermaid-svg-DXTcp7GpJkezCoXU{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-DXTcp7GpJkezCoXU .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-DXTcp7GpJkezCoXU .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-DXTcp7GpJkezCoXU .error-icon{fill:#552222;}#mermaid-svg-DXTcp7GpJkezCoXU .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-DXTcp7GpJkezCoXU .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-DXTcp7GpJkezCoXU .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-DXTcp7GpJkezCoXU .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-DXTcp7GpJkezCoXU .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-DXTcp7GpJkezCoXU .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-DXTcp7GpJkezCoXU .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-DXTcp7GpJkezCoXU .marker{fill:#333333;stroke:#333333;}#mermaid-svg-DXTcp7GpJkezCoXU .marker.cross{stroke:#333333;}#mermaid-svg-DXTcp7GpJkezCoXU svg{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-DXTcp7GpJkezCoXU p{margin:0;}#mermaid-svg-DXTcp7GpJkezCoXU .label{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;color:#333;}#mermaid-svg-DXTcp7GpJkezCoXU .cluster-label text{fill:#333;}#mermaid-svg-DXTcp7GpJkezCoXU .cluster-label span{color:#333;}#mermaid-svg-DXTcp7GpJkezCoXU .cluster-label span p{background-color:transparent;}#mermaid-svg-DXTcp7GpJkezCoXU .label text,#mermaid-svg-DXTcp7GpJkezCoXU span{fill:#333;color:#333;}#mermaid-svg-DXTcp7GpJkezCoXU .node rect,#mermaid-svg-DXTcp7GpJkezCoXU .node circle,#mermaid-svg-DXTcp7GpJkezCoXU .node ellipse,#mermaid-svg-DXTcp7GpJkezCoXU .node polygon,#mermaid-svg-DXTcp7GpJkezCoXU .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-DXTcp7GpJkezCoXU .rough-node .label text,#mermaid-svg-DXTcp7GpJkezCoXU .node .label text,#mermaid-svg-DXTcp7GpJkezCoXU .image-shape .label,#mermaid-svg-DXTcp7GpJkezCoXU .icon-shape .label{text-anchor:middle;}#mermaid-svg-DXTcp7GpJkezCoXU .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-DXTcp7GpJkezCoXU .rough-node .label,#mermaid-svg-DXTcp7GpJkezCoXU .node .label,#mermaid-svg-DXTcp7GpJkezCoXU .image-shape .label,#mermaid-svg-DXTcp7GpJkezCoXU .icon-shape .label{text-align:center;}#mermaid-svg-DXTcp7GpJkezCoXU .node.clickable{cursor:pointer;}#mermaid-svg-DXTcp7GpJkezCoXU .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-DXTcp7GpJkezCoXU .arrowheadPath{fill:#333333;}#mermaid-svg-DXTcp7GpJkezCoXU .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-DXTcp7GpJkezCoXU .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-DXTcp7GpJkezCoXU .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-DXTcp7GpJkezCoXU .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-DXTcp7GpJkezCoXU .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-DXTcp7GpJkezCoXU .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-DXTcp7GpJkezCoXU .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-DXTcp7GpJkezCoXU .cluster text{fill:#333;}#mermaid-svg-DXTcp7GpJkezCoXU .cluster span{color:#333;}#mermaid-svg-DXTcp7GpJkezCoXU div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-DXTcp7GpJkezCoXU .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-DXTcp7GpJkezCoXU rect.text{fill:none;stroke-width:0;}#mermaid-svg-DXTcp7GpJkezCoXU .icon-shape,#mermaid-svg-DXTcp7GpJkezCoXU .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-DXTcp7GpJkezCoXU .icon-shape p,#mermaid-svg-DXTcp7GpJkezCoXU .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-DXTcp7GpJkezCoXU .icon-shape rect,#mermaid-svg-DXTcp7GpJkezCoXU .image-shape rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-DXTcp7GpJkezCoXU .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-DXTcp7GpJkezCoXU .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-DXTcp7GpJkezCoXU :root{–mermaid-font-family:\”trebuchet ms\”,verdana,arial,sans-serif;}
数据收集
知识抽取
知识融合
知识存储
知识应用
关键步骤:
Q4: 知识图谱在RAG中有什么作用?
答案要点:
#mermaid-svg-ZPfanjl60AM7D7Z1{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-ZPfanjl60AM7D7Z1 .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-ZPfanjl60AM7D7Z1 .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-ZPfanjl60AM7D7Z1 .error-icon{fill:#552222;}#mermaid-svg-ZPfanjl60AM7D7Z1 .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-ZPfanjl60AM7D7Z1 .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-ZPfanjl60AM7D7Z1 .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-ZPfanjl60AM7D7Z1 .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-ZPfanjl60AM7D7Z1 .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-ZPfanjl60AM7D7Z1 .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-ZPfanjl60AM7D7Z1 .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-ZPfanjl60AM7D7Z1 .marker{fill:#333333;stroke:#333333;}#mermaid-svg-ZPfanjl60AM7D7Z1 .marker.cross{stroke:#333333;}#mermaid-svg-ZPfanjl60AM7D7Z1 svg{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-ZPfanjl60AM7D7Z1 p{margin:0;}#mermaid-svg-ZPfanjl60AM7D7Z1 .label{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;color:#333;}#mermaid-svg-ZPfanjl60AM7D7Z1 .cluster-label text{fill:#333;}#mermaid-svg-ZPfanjl60AM7D7Z1 .cluster-label span{color:#333;}#mermaid-svg-ZPfanjl60AM7D7Z1 .cluster-label span p{background-color:transparent;}#mermaid-svg-ZPfanjl60AM7D7Z1 .label text,#mermaid-svg-ZPfanjl60AM7D7Z1 span{fill:#333;color:#333;}#mermaid-svg-ZPfanjl60AM7D7Z1 .node rect,#mermaid-svg-ZPfanjl60AM7D7Z1 .node circle,#mermaid-svg-ZPfanjl60AM7D7Z1 .node ellipse,#mermaid-svg-ZPfanjl60AM7D7Z1 .node polygon,#mermaid-svg-ZPfanjl60AM7D7Z1 .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-ZPfanjl60AM7D7Z1 .rough-node .label text,#mermaid-svg-ZPfanjl60AM7D7Z1 .node .label text,#mermaid-svg-ZPfanjl60AM7D7Z1 .image-shape .label,#mermaid-svg-ZPfanjl60AM7D7Z1 .icon-shape .label{text-anchor:middle;}#mermaid-svg-ZPfanjl60AM7D7Z1 .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-ZPfanjl60AM7D7Z1 .rough-node .label,#mermaid-svg-ZPfanjl60AM7D7Z1 .node .label,#mermaid-svg-ZPfanjl60AM7D7Z1 .image-shape .label,#mermaid-svg-ZPfanjl60AM7D7Z1 .icon-shape .label{text-align:center;}#mermaid-svg-ZPfanjl60AM7D7Z1 .node.clickable{cursor:pointer;}#mermaid-svg-ZPfanjl60AM7D7Z1 .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-ZPfanjl60AM7D7Z1 .arrowheadPath{fill:#333333;}#mermaid-svg-ZPfanjl60AM7D7Z1 .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-ZPfanjl60AM7D7Z1 .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-ZPfanjl60AM7D7Z1 .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-ZPfanjl60AM7D7Z1 .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-ZPfanjl60AM7D7Z1 .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-ZPfanjl60AM7D7Z1 .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-ZPfanjl60AM7D7Z1 .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-ZPfanjl60AM7D7Z1 .cluster text{fill:#333;}#mermaid-svg-ZPfanjl60AM7D7Z1 .cluster span{color:#333;}#mermaid-svg-ZPfanjl60AM7D7Z1 div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-ZPfanjl60AM7D7Z1 .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-ZPfanjl60AM7D7Z1 rect.text{fill:none;stroke-width:0;}#mermaid-svg-ZPfanjl60AM7D7Z1 .icon-shape,#mermaid-svg-ZPfanjl60AM7D7Z1 .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-ZPfanjl60AM7D7Z1 .icon-shape p,#mermaid-svg-ZPfanjl60AM7D7Z1 .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-ZPfanjl60AM7D7Z1 .icon-shape rect,#mermaid-svg-ZPfanjl60AM7D7Z1 .image-shape rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-ZPfanjl60AM7D7Z1 .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-ZPfanjl60AM7D7Z1 .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-ZPfanjl60AM7D7Z1 :root{–mermaid-font-family:\”trebuchet ms\”,verdana,arial,sans-serif;}
传统RAG
向量检索
语义相似
图谱增强RAG
图谱检索
关系推理
核心优势:
| 多跳推理 | ❌ 困难 | ✅ 支持 |
| 关系查询 | ❌ 无法 | ✅ 精准 |
| 可解释性 | ❌ 低 | ✅ 高 |
8.3 应用场景题
Q5: 知识图谱适合哪些业务场景?
答案要点:
#mermaid-svg-XAyZjGFlbhNghtOD{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-XAyZjGFlbhNghtOD .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-XAyZjGFlbhNghtOD .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-XAyZjGFlbhNghtOD .error-icon{fill:#552222;}#mermaid-svg-XAyZjGFlbhNghtOD .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-XAyZjGFlbhNghtOD .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-XAyZjGFlbhNghtOD .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-XAyZjGFlbhNghtOD .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-XAyZjGFlbhNghtOD .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-XAyZjGFlbhNghtOD .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-XAyZjGFlbhNghtOD .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-XAyZjGFlbhNghtOD .marker{fill:#333333;stroke:#333333;}#mermaid-svg-XAyZjGFlbhNghtOD .marker.cross{stroke:#333333;}#mermaid-svg-XAyZjGFlbhNghtOD svg{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-XAyZjGFlbhNghtOD p{margin:0;}#mermaid-svg-XAyZjGFlbhNghtOD .label{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;color:#333;}#mermaid-svg-XAyZjGFlbhNghtOD .cluster-label text{fill:#333;}#mermaid-svg-XAyZjGFlbhNghtOD .cluster-label span{color:#333;}#mermaid-svg-XAyZjGFlbhNghtOD .cluster-label span p{background-color:transparent;}#mermaid-svg-XAyZjGFlbhNghtOD .label text,#mermaid-svg-XAyZjGFlbhNghtOD span{fill:#333;color:#333;}#mermaid-svg-XAyZjGFlbhNghtOD .node rect,#mermaid-svg-XAyZjGFlbhNghtOD .node circle,#mermaid-svg-XAyZjGFlbhNghtOD .node ellipse,#mermaid-svg-XAyZjGFlbhNghtOD .node polygon,#mermaid-svg-XAyZjGFlbhNghtOD .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-XAyZjGFlbhNghtOD .rough-node .label text,#mermaid-svg-XAyZjGFlbhNghtOD .node .label text,#mermaid-svg-XAyZjGFlbhNghtOD .image-shape .label,#mermaid-svg-XAyZjGFlbhNghtOD .icon-shape .label{text-anchor:middle;}#mermaid-svg-XAyZjGFlbhNghtOD .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-XAyZjGFlbhNghtOD .rough-node .label,#mermaid-svg-XAyZjGFlbhNghtOD .node .label,#mermaid-svg-XAyZjGFlbhNghtOD .image-shape .label,#mermaid-svg-XAyZjGFlbhNghtOD .icon-shape .label{text-align:center;}#mermaid-svg-XAyZjGFlbhNghtOD .node.clickable{cursor:pointer;}#mermaid-svg-XAyZjGFlbhNghtOD .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-XAyZjGFlbhNghtOD .arrowheadPath{fill:#333333;}#mermaid-svg-XAyZjGFlbhNghtOD .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-XAyZjGFlbhNghtOD .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-XAyZjGFlbhNghtOD .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-XAyZjGFlbhNghtOD .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-XAyZjGFlbhNghtOD .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-XAyZjGFlbhNghtOD .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-XAyZjGFlbhNghtOD .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-XAyZjGFlbhNghtOD .cluster text{fill:#333;}#mermaid-svg-XAyZjGFlbhNghtOD .cluster span{color:#333;}#mermaid-svg-XAyZjGFlbhNghtOD div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-XAyZjGFlbhNghtOD .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-XAyZjGFlbhNghtOD rect.text{fill:none;stroke-width:0;}#mermaid-svg-XAyZjGFlbhNghtOD .icon-shape,#mermaid-svg-XAyZjGFlbhNghtOD .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-XAyZjGFlbhNghtOD .icon-shape p,#mermaid-svg-XAyZjGFlbhNghtOD .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-XAyZjGFlbhNghtOD .icon-shape rect,#mermaid-svg-XAyZjGFlbhNghtOD .image-shape rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-XAyZjGFlbhNghtOD .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-XAyZjGFlbhNghtOD .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-XAyZjGFlbhNghtOD :root{–mermaid-font-family:\”trebuchet ms\”,verdana,arial,sans-serif;}
知识图谱应用
智能问答
推荐系统
金融风控
医疗诊断
典型场景:
8.4 深度思考题
Q6: 知识图谱的未来发展趋势是什么?
答案要点:
#mermaid-svg-CVEBdXd18Qk6Z6Qk{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-CVEBdXd18Qk6Z6Qk .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .error-icon{fill:#552222;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .marker{fill:#333333;stroke:#333333;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .marker.cross{stroke:#333333;}#mermaid-svg-CVEBdXd18Qk6Z6Qk svg{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-CVEBdXd18Qk6Z6Qk p{margin:0;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .edge{stroke-width:3;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .section–1 rect,#mermaid-svg-CVEBdXd18Qk6Z6Qk .section–1 path,#mermaid-svg-CVEBdXd18Qk6Z6Qk .section–1 circle,#mermaid-svg-CVEBdXd18Qk6Z6Qk .section–1 path{fill:hsl(240, 100%, 76.2745098039%);}#mermaid-svg-CVEBdXd18Qk6Z6Qk .section–1 text{fill:#ffffff;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .node-icon–1{font-size:40px;color:#ffffff;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-edge–1{stroke:hsl(240, 100%, 76.2745098039%);}#mermaid-svg-CVEBdXd18Qk6Z6Qk .edge-depth–1{stroke-width:17;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .section–1 line{stroke:hsl(60, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .lineWrapper line{stroke:#ffffff;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .disabled,#mermaid-svg-CVEBdXd18Qk6Z6Qk .disabled circle,#mermaid-svg-CVEBdXd18Qk6Z6Qk .disabled text{fill:lightgray;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .disabled text{fill:#efefef;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-0 rect,#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-0 path,#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-0 circle,#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-0 path{fill:hsl(60, 100%, 73.5294117647%);}#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-0 text{fill:black;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .node-icon-0{font-size:40px;color:black;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-edge-0{stroke:hsl(60, 100%, 73.5294117647%);}#mermaid-svg-CVEBdXd18Qk6Z6Qk .edge-depth-0{stroke-width:14;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-0 line{stroke:hsl(240, 100%, 83.5294117647%);stroke-width:3;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .lineWrapper line{stroke:black;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .disabled,#mermaid-svg-CVEBdXd18Qk6Z6Qk .disabled circle,#mermaid-svg-CVEBdXd18Qk6Z6Qk .disabled text{fill:lightgray;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .disabled text{fill:#efefef;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-1 rect,#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-1 path,#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-1 circle,#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-1 path{fill:hsl(80, 100%, 76.2745098039%);}#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-1 text{fill:black;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .node-icon-1{font-size:40px;color:black;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-edge-1{stroke:hsl(80, 100%, 76.2745098039%);}#mermaid-svg-CVEBdXd18Qk6Z6Qk .edge-depth-1{stroke-width:11;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-1 line{stroke:hsl(260, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .lineWrapper line{stroke:black;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .disabled,#mermaid-svg-CVEBdXd18Qk6Z6Qk .disabled circle,#mermaid-svg-CVEBdXd18Qk6Z6Qk .disabled text{fill:lightgray;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .disabled text{fill:#efefef;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-2 rect,#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-2 path,#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-2 circle,#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-2 path{fill:hsl(270, 100%, 76.2745098039%);}#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-2 text{fill:#ffffff;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .node-icon-2{font-size:40px;color:#ffffff;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-edge-2{stroke:hsl(270, 100%, 76.2745098039%);}#mermaid-svg-CVEBdXd18Qk6Z6Qk .edge-depth-2{stroke-width:8;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-2 line{stroke:hsl(90, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .lineWrapper line{stroke:#ffffff;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .disabled,#mermaid-svg-CVEBdXd18Qk6Z6Qk .disabled circle,#mermaid-svg-CVEBdXd18Qk6Z6Qk .disabled text{fill:lightgray;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .disabled text{fill:#efefef;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-3 rect,#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-3 path,#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-3 circle,#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-3 path{fill:hsl(300, 100%, 76.2745098039%);}#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-3 text{fill:black;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .node-icon-3{font-size:40px;color:black;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-edge-3{stroke:hsl(300, 100%, 76.2745098039%);}#mermaid-svg-CVEBdXd18Qk6Z6Qk .edge-depth-3{stroke-width:5;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-3 line{stroke:hsl(120, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .lineWrapper line{stroke:black;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .disabled,#mermaid-svg-CVEBdXd18Qk6Z6Qk .disabled circle,#mermaid-svg-CVEBdXd18Qk6Z6Qk .disabled text{fill:lightgray;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .disabled text{fill:#efefef;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-4 rect,#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-4 path,#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-4 circle,#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-4 path{fill:hsl(330, 100%, 76.2745098039%);}#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-4 text{fill:black;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .node-icon-4{font-size:40px;color:black;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-edge-4{stroke:hsl(330, 100%, 76.2745098039%);}#mermaid-svg-CVEBdXd18Qk6Z6Qk .edge-depth-4{stroke-width:2;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-4 line{stroke:hsl(150, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .lineWrapper line{stroke:black;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .disabled,#mermaid-svg-CVEBdXd18Qk6Z6Qk .disabled circle,#mermaid-svg-CVEBdXd18Qk6Z6Qk .disabled text{fill:lightgray;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .disabled text{fill:#efefef;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-5 rect,#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-5 path,#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-5 circle,#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-5 path{fill:hsl(0, 100%, 76.2745098039%);}#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-5 text{fill:black;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .node-icon-5{font-size:40px;color:black;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-edge-5{stroke:hsl(0, 100%, 76.2745098039%);}#mermaid-svg-CVEBdXd18Qk6Z6Qk .edge-depth-5{stroke-width:-1;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-5 line{stroke:hsl(180, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .lineWrapper line{stroke:black;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .disabled,#mermaid-svg-CVEBdXd18Qk6Z6Qk .disabled circle,#mermaid-svg-CVEBdXd18Qk6Z6Qk .disabled text{fill:lightgray;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .disabled text{fill:#efefef;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-6 rect,#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-6 path,#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-6 circle,#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-6 path{fill:hsl(30, 100%, 76.2745098039%);}#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-6 text{fill:black;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .node-icon-6{font-size:40px;color:black;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-edge-6{stroke:hsl(30, 100%, 76.2745098039%);}#mermaid-svg-CVEBdXd18Qk6Z6Qk .edge-depth-6{stroke-width:-4;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-6 line{stroke:hsl(210, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .lineWrapper line{stroke:black;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .disabled,#mermaid-svg-CVEBdXd18Qk6Z6Qk .disabled circle,#mermaid-svg-CVEBdXd18Qk6Z6Qk .disabled text{fill:lightgray;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .disabled text{fill:#efefef;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-7 rect,#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-7 path,#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-7 circle,#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-7 path{fill:hsl(90, 100%, 76.2745098039%);}#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-7 text{fill:black;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .node-icon-7{font-size:40px;color:black;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-edge-7{stroke:hsl(90, 100%, 76.2745098039%);}#mermaid-svg-CVEBdXd18Qk6Z6Qk .edge-depth-7{stroke-width:-7;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-7 line{stroke:hsl(270, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .lineWrapper line{stroke:black;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .disabled,#mermaid-svg-CVEBdXd18Qk6Z6Qk .disabled circle,#mermaid-svg-CVEBdXd18Qk6Z6Qk .disabled text{fill:lightgray;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .disabled text{fill:#efefef;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-8 rect,#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-8 path,#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-8 circle,#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-8 path{fill:hsl(150, 100%, 76.2745098039%);}#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-8 text{fill:black;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .node-icon-8{font-size:40px;color:black;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-edge-8{stroke:hsl(150, 100%, 76.2745098039%);}#mermaid-svg-CVEBdXd18Qk6Z6Qk .edge-depth-8{stroke-width:-10;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-8 line{stroke:hsl(330, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .lineWrapper line{stroke:black;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .disabled,#mermaid-svg-CVEBdXd18Qk6Z6Qk .disabled circle,#mermaid-svg-CVEBdXd18Qk6Z6Qk .disabled text{fill:lightgray;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .disabled text{fill:#efefef;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-9 rect,#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-9 path,#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-9 circle,#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-9 path{fill:hsl(180, 100%, 76.2745098039%);}#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-9 text{fill:black;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .node-icon-9{font-size:40px;color:black;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-edge-9{stroke:hsl(180, 100%, 76.2745098039%);}#mermaid-svg-CVEBdXd18Qk6Z6Qk .edge-depth-9{stroke-width:-13;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-9 line{stroke:hsl(0, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .lineWrapper line{stroke:black;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .disabled,#mermaid-svg-CVEBdXd18Qk6Z6Qk .disabled circle,#mermaid-svg-CVEBdXd18Qk6Z6Qk .disabled text{fill:lightgray;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .disabled text{fill:#efefef;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-10 rect,#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-10 path,#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-10 circle,#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-10 path{fill:hsl(210, 100%, 76.2745098039%);}#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-10 text{fill:black;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .node-icon-10{font-size:40px;color:black;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-edge-10{stroke:hsl(210, 100%, 76.2745098039%);}#mermaid-svg-CVEBdXd18Qk6Z6Qk .edge-depth-10{stroke-width:-16;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-10 line{stroke:hsl(30, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .lineWrapper line{stroke:black;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .disabled,#mermaid-svg-CVEBdXd18Qk6Z6Qk .disabled circle,#mermaid-svg-CVEBdXd18Qk6Z6Qk .disabled text{fill:lightgray;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .disabled text{fill:#efefef;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-root rect,#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-root path,#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-root circle{fill:hsl(240, 100%, 46.2745098039%);}#mermaid-svg-CVEBdXd18Qk6Z6Qk .section-root text{fill:#ffffff;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .icon-container{height:100%;display:flex;justify-content:center;align-items:center;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .edge{fill:none;}#mermaid-svg-CVEBdXd18Qk6Z6Qk .eventWrapper{filter:brightness(120%);}#mermaid-svg-CVEBdXd18Qk6Z6Qk :root{–mermaid-font-family:\”trebuchet ms\”,verdana,arial,sans-serif;}
当前
LLM+知识图谱融合
近期
多模态知识图谱
中期
神经符号融合
远期
自主知识进化
知识图谱发展趋势
发展方向:
总结
核心要点回顾
#mermaid-svg-O1ShdHGfAXhU4ro2{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-O1ShdHGfAXhU4ro2 .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-O1ShdHGfAXhU4ro2 .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-O1ShdHGfAXhU4ro2 .error-icon{fill:#552222;}#mermaid-svg-O1ShdHGfAXhU4ro2 .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-O1ShdHGfAXhU4ro2 .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-O1ShdHGfAXhU4ro2 .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-O1ShdHGfAXhU4ro2 .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-O1ShdHGfAXhU4ro2 .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-O1ShdHGfAXhU4ro2 .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-O1ShdHGfAXhU4ro2 .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-O1ShdHGfAXhU4ro2 .marker{fill:#333333;stroke:#333333;}#mermaid-svg-O1ShdHGfAXhU4ro2 .marker.cross{stroke:#333333;}#mermaid-svg-O1ShdHGfAXhU4ro2 svg{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-O1ShdHGfAXhU4ro2 p{margin:0;}#mermaid-svg-O1ShdHGfAXhU4ro2 .edge{stroke-width:3;}#mermaid-svg-O1ShdHGfAXhU4ro2 .section–1 rect,#mermaid-svg-O1ShdHGfAXhU4ro2 .section–1 path,#mermaid-svg-O1ShdHGfAXhU4ro2 .section–1 circle,#mermaid-svg-O1ShdHGfAXhU4ro2 .section–1 polygon,#mermaid-svg-O1ShdHGfAXhU4ro2 .section–1 path{fill:hsl(240, 100%, 76.2745098039%);}#mermaid-svg-O1ShdHGfAXhU4ro2 .section–1 text{fill:#ffffff;}#mermaid-svg-O1ShdHGfAXhU4ro2 .node-icon–1{font-size:40px;color:#ffffff;}#mermaid-svg-O1ShdHGfAXhU4ro2 .section-edge–1{stroke:hsl(240, 100%, 76.2745098039%);}#mermaid-svg-O1ShdHGfAXhU4ro2 .edge-depth–1{stroke-width:17;}#mermaid-svg-O1ShdHGfAXhU4ro2 .section–1 line{stroke:hsl(60, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-O1ShdHGfAXhU4ro2 .disabled,#mermaid-svg-O1ShdHGfAXhU4ro2 .disabled circle,#mermaid-svg-O1ShdHGfAXhU4ro2 .disabled text{fill:lightgray;}#mermaid-svg-O1ShdHGfAXhU4ro2 .disabled text{fill:#efefef;}#mermaid-svg-O1ShdHGfAXhU4ro2 .section-0 rect,#mermaid-svg-O1ShdHGfAXhU4ro2 .section-0 path,#mermaid-svg-O1ShdHGfAXhU4ro2 .section-0 circle,#mermaid-svg-O1ShdHGfAXhU4ro2 .section-0 polygon,#mermaid-svg-O1ShdHGfAXhU4ro2 .section-0 path{fill:hsl(60, 100%, 73.5294117647%);}#mermaid-svg-O1ShdHGfAXhU4ro2 .section-0 text{fill:black;}#mermaid-svg-O1ShdHGfAXhU4ro2 .node-icon-0{font-size:40px;color:black;}#mermaid-svg-O1ShdHGfAXhU4ro2 .section-edge-0{stroke:hsl(60, 100%, 73.5294117647%);}#mermaid-svg-O1ShdHGfAXhU4ro2 .edge-depth-0{stroke-width:14;}#mermaid-svg-O1ShdHGfAXhU4ro2 .section-0 line{stroke:hsl(240, 100%, 83.5294117647%);stroke-width:3;}#mermaid-svg-O1ShdHGfAXhU4ro2 .disabled,#mermaid-svg-O1ShdHGfAXhU4ro2 .disabled circle,#mermaid-svg-O1ShdHGfAXhU4ro2 .disabled text{fill:lightgray;}#mermaid-svg-O1ShdHGfAXhU4ro2 .disabled text{fill:#efefef;}#mermaid-svg-O1ShdHGfAXhU4ro2 .section-1 rect,#mermaid-svg-O1ShdHGfAXhU4ro2 .section-1 path,#mermaid-svg-O1ShdHGfAXhU4ro2 .section-1 circle,#mermaid-svg-O1ShdHGfAXhU4ro2 .section-1 polygon,#mermaid-svg-O1ShdHGfAXhU4ro2 .section-1 path{fill:hsl(80, 100%, 76.2745098039%);}#mermaid-svg-O1ShdHGfAXhU4ro2 .section-1 text{fill:black;}#mermaid-svg-O1ShdHGfAXhU4ro2 .node-icon-1{font-size:40px;color:black;}#mermaid-svg-O1ShdHGfAXhU4ro2 .section-edge-1{stroke:hsl(80, 100%, 76.2745098039%);}#mermaid-svg-O1ShdHGfAXhU4ro2 .edge-depth-1{stroke-width:11;}#mermaid-svg-O1ShdHGfAXhU4ro2 .section-1 line{stroke:hsl(260, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-O1ShdHGfAXhU4ro2 .disabled,#mermaid-svg-O1ShdHGfAXhU4ro2 .disabled circle,#mermaid-svg-O1ShdHGfAXhU4ro2 .disabled text{fill:lightgray;}#mermaid-svg-O1ShdHGfAXhU4ro2 .disabled text{fill:#efefef;}#mermaid-svg-O1ShdHGfAXhU4ro2 .section-2 rect,#mermaid-svg-O1ShdHGfAXhU4ro2 .section-2 path,#mermaid-svg-O1ShdHGfAXhU4ro2 .section-2 circle,#mermaid-svg-O1ShdHGfAXhU4ro2 .section-2 polygon,#mermaid-svg-O1ShdHGfAXhU4ro2 .section-2 path{fill:hsl(270, 100%, 76.2745098039%);}#mermaid-svg-O1ShdHGfAXhU4ro2 .section-2 text{fill:#ffffff;}#mermaid-svg-O1ShdHGfAXhU4ro2 .node-icon-2{font-size:40px;color:#ffffff;}#mermaid-svg-O1ShdHGfAXhU4ro2 .section-edge-2{stroke:hsl(270, 100%, 76.2745098039%);}#mermaid-svg-O1ShdHGfAXhU4ro2 .edge-depth-2{stroke-width:8;}#mermaid-svg-O1ShdHGfAXhU4ro2 .section-2 line{stroke:hsl(90, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-O1ShdHGfAXhU4ro2 .disabled,#mermaid-svg-O1ShdHGfAXhU4ro2 .disabled circle,#mermaid-svg-O1ShdHGfAXhU4ro2 .disabled text{fill:lightgray;}#mermaid-svg-O1ShdHGfAXhU4ro2 .disabled text{fill:#efefef;}#mermaid-svg-O1ShdHGfAXhU4ro2 .section-3 rect,#mermaid-svg-O1ShdHGfAXhU4ro2 .section-3 path,#mermaid-svg-O1ShdHGfAXhU4ro2 .section-3 circle,#mermaid-svg-O1ShdHGfAXhU4ro2 .section-3 polygon,#mermaid-svg-O1ShdHGfAXhU4ro2 .section-3 path{fill:hsl(300, 100%, 76.2745098039%);}#mermaid-svg-O1ShdHGfAXhU4ro2 .section-3 text{fill:black;}#mermaid-svg-O1ShdHGfAXhU4ro2 .node-icon-3{font-size:40px;color:black;}#mermaid-svg-O1ShdHGfAXhU4ro2 .section-edge-3{stroke:hsl(300, 100%, 76.2745098039%);}#mermaid-svg-O1ShdHGfAXhU4ro2 .edge-depth-3{stroke-width:5;}#mermaid-svg-O1ShdHGfAXhU4ro2 .section-3 line{stroke:hsl(120, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-O1ShdHGfAXhU4ro2 .disabled,#mermaid-svg-O1ShdHGfAXhU4ro2 .disabled circle,#mermaid-svg-O1ShdHGfAXhU4ro2 .disabled text{fill:lightgray;}#mermaid-svg-O1ShdHGfAXhU4ro2 .disabled text{fill:#efefef;}#mermaid-svg-O1ShdHGfAXhU4ro2 .section-4 rect,#mermaid-svg-O1ShdHGfAXhU4ro2 .section-4 path,#mermaid-svg-O1ShdHGfAXhU4ro2 .section-4 circle,#mermaid-svg-O1ShdHGfAXhU4ro2 .section-4 polygon,#mermaid-svg-O1ShdHGfAXhU4ro2 .section-4 path{fill:hsl(330, 100%, 76.2745098039%);}#mermaid-svg-O1ShdHGfAXhU4ro2 .section-4 text{fill:black;}#mermaid-svg-O1ShdHGfAXhU4ro2 .node-icon-4{font-size:40px;color:black;}#mermaid-svg-O1ShdHGfAXhU4ro2 .section-edge-4{stroke:hsl(330, 100%, 76.2745098039%);}#mermaid-svg-O1ShdHGfAXhU4ro2 .edge-depth-4{stroke-width:2;}#mermaid-svg-O1ShdHGfAXhU4ro2 .section-4 line{stroke:hsl(150, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-O1ShdHGfAXhU4ro2 .disabled,#mermaid-svg-O1ShdHGfAXhU4ro2 .disabled circle,#mermaid-svg-O1ShdHGfAXhU4ro2 .disabled text{fill:lightgray;}#mermaid-svg-O1ShdHGfAXhU4ro2 .disabled text{fill:#efefef;}#mermaid-svg-O1ShdHGfAXhU4ro2 .section-5 rect,#mermaid-svg-O1ShdHGfAXhU4ro2 .section-5 path,#mermaid-svg-O1ShdHGfAXhU4ro2 .section-5 circle,#mermaid-svg-O1ShdHGfAXhU4ro2 .section-5 polygon,#mermaid-svg-O1ShdHGfAXhU4ro2 .section-5 path{fill:hsl(0, 100%, 76.2745098039%);}#mermaid-svg-O1ShdHGfAXhU4ro2 .section-5 text{fill:black;}#mermaid-svg-O1ShdHGfAXhU4ro2 .node-icon-5{font-size:40px;color:black;}#mermaid-svg-O1ShdHGfAXhU4ro2 .section-edge-5{stroke:hsl(0, 100%, 76.2745098039%);}#mermaid-svg-O1ShdHGfAXhU4ro2 .edge-depth-5{stroke-width:-1;}#mermaid-svg-O1ShdHGfAXhU4ro2 .section-5 line{stroke:hsl(180, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-O1ShdHGfAXhU4ro2 .disabled,#mermaid-svg-O1ShdHGfAXhU4ro2 .disabled circle,#mermaid-svg-O1ShdHGfAXhU4ro2 .disabled text{fill:lightgray;}#mermaid-svg-O1ShdHGfAXhU4ro2 .disabled text{fill:#efefef;}#mermaid-svg-O1ShdHGfAXhU4ro2 .section-6 rect,#mermaid-svg-O1ShdHGfAXhU4ro2 .section-6 path,#mermaid-svg-O1ShdHGfAXhU4ro2 .section-6 circle,#mermaid-svg-O1ShdHGfAXhU4ro2 .section-6 polygon,#mermaid-svg-O1ShdHGfAXhU4ro2 .section-6 path{fill:hsl(30, 100%, 76.2745098039%);}#mermaid-svg-O1ShdHGfAXhU4ro2 .section-6 text{fill:black;}#mermaid-svg-O1ShdHGfAXhU4ro2 .node-icon-6{font-size:40px;color:black;}#mermaid-svg-O1ShdHGfAXhU4ro2 .section-edge-6{stroke:hsl(30, 100%, 76.2745098039%);}#mermaid-svg-O1ShdHGfAXhU4ro2 .edge-depth-6{stroke-width:-4;}#mermaid-svg-O1ShdHGfAXhU4ro2 .section-6 line{stroke:hsl(210, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-O1ShdHGfAXhU4ro2 .disabled,#mermaid-svg-O1ShdHGfAXhU4ro2 .disabled circle,#mermaid-svg-O1ShdHGfAXhU4ro2 .disabled text{fill:lightgray;}#mermaid-svg-O1ShdHGfAXhU4ro2 .disabled text{fill:#efefef;}#mermaid-svg-O1ShdHGfAXhU4ro2 .section-7 rect,#mermaid-svg-O1ShdHGfAXhU4ro2 .section-7 path,#mermaid-svg-O1ShdHGfAXhU4ro2 .section-7 circle,#mermaid-svg-O1ShdHGfAXhU4ro2 .section-7 polygon,#mermaid-svg-O1ShdHGfAXhU4ro2 .section-7 path{fill:hsl(90, 100%, 76.2745098039%);}#mermaid-svg-O1ShdHGfAXhU4ro2 .section-7 text{fill:black;}#mermaid-svg-O1ShdHGfAXhU4ro2 .node-icon-7{font-size:40px;color:black;}#mermaid-svg-O1ShdHGfAXhU4ro2 .section-edge-7{stroke:hsl(90, 100%, 76.2745098039%);}#mermaid-svg-O1ShdHGfAXhU4ro2 .edge-depth-7{stroke-width:-7;}#mermaid-svg-O1ShdHGfAXhU4ro2 .section-7 line{stroke:hsl(270, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-O1ShdHGfAXhU4ro2 .disabled,#mermaid-svg-O1ShdHGfAXhU4ro2 .disabled circle,#mermaid-svg-O1ShdHGfAXhU4ro2 .disabled text{fill:lightgray;}#mermaid-svg-O1ShdHGfAXhU4ro2 .disabled text{fill:#efefef;}#mermaid-svg-O1ShdHGfAXhU4ro2 .section-8 rect,#mermaid-svg-O1ShdHGfAXhU4ro2 .section-8 path,#mermaid-svg-O1ShdHGfAXhU4ro2 .section-8 circle,#mermaid-svg-O1ShdHGfAXhU4ro2 .section-8 polygon,#mermaid-svg-O1ShdHGfAXhU4ro2 .section-8 path{fill:hsl(150, 100%, 76.2745098039%);}#mermaid-svg-O1ShdHGfAXhU4ro2 .section-8 text{fill:black;}#mermaid-svg-O1ShdHGfAXhU4ro2 .node-icon-8{font-size:40px;color:black;}#mermaid-svg-O1ShdHGfAXhU4ro2 .section-edge-8{stroke:hsl(150, 100%, 76.2745098039%);}#mermaid-svg-O1ShdHGfAXhU4ro2 .edge-depth-8{stroke-width:-10;}#mermaid-svg-O1ShdHGfAXhU4ro2 .section-8 line{stroke:hsl(330, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-O1ShdHGfAXhU4ro2 .disabled,#mermaid-svg-O1ShdHGfAXhU4ro2 .disabled circle,#mermaid-svg-O1ShdHGfAXhU4ro2 .disabled text{fill:lightgray;}#mermaid-svg-O1ShdHGfAXhU4ro2 .disabled text{fill:#efefef;}#mermaid-svg-O1ShdHGfAXhU4ro2 .section-9 rect,#mermaid-svg-O1ShdHGfAXhU4ro2 .section-9 path,#mermaid-svg-O1ShdHGfAXhU4ro2 .section-9 circle,#mermaid-svg-O1ShdHGfAXhU4ro2 .section-9 polygon,#mermaid-svg-O1ShdHGfAXhU4ro2 .section-9 path{fill:hsl(180, 100%, 76.2745098039%);}#mermaid-svg-O1ShdHGfAXhU4ro2 .section-9 text{fill:black;}#mermaid-svg-O1ShdHGfAXhU4ro2 .node-icon-9{font-size:40px;color:black;}#mermaid-svg-O1ShdHGfAXhU4ro2 .section-edge-9{stroke:hsl(180, 100%, 76.2745098039%);}#mermaid-svg-O1ShdHGfAXhU4ro2 .edge-depth-9{stroke-width:-13;}#mermaid-svg-O1ShdHGfAXhU4ro2 .section-9 line{stroke:hsl(0, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-O1ShdHGfAXhU4ro2 .disabled,#mermaid-svg-O1ShdHGfAXhU4ro2 .disabled circle,#mermaid-svg-O1ShdHGfAXhU4ro2 .disabled text{fill:lightgray;}#mermaid-svg-O1ShdHGfAXhU4ro2 .disabled text{fill:#efefef;}#mermaid-svg-O1ShdHGfAXhU4ro2 .section-10 rect,#mermaid-svg-O1ShdHGfAXhU4ro2 .section-10 path,#mermaid-svg-O1ShdHGfAXhU4ro2 .section-10 circle,#mermaid-svg-O1ShdHGfAXhU4ro2 .section-10 polygon,#mermaid-svg-O1ShdHGfAXhU4ro2 .section-10 path{fill:hsl(210, 100%, 76.2745098039%);}#mermaid-svg-O1ShdHGfAXhU4ro2 .section-10 text{fill:black;}#mermaid-svg-O1ShdHGfAXhU4ro2 .node-icon-10{font-size:40px;color:black;}#mermaid-svg-O1ShdHGfAXhU4ro2 .section-edge-10{stroke:hsl(210, 100%, 76.2745098039%);}#mermaid-svg-O1ShdHGfAXhU4ro2 .edge-depth-10{stroke-width:-16;}#mermaid-svg-O1ShdHGfAXhU4ro2 .section-10 line{stroke:hsl(30, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-O1ShdHGfAXhU4ro2 .disabled,#mermaid-svg-O1ShdHGfAXhU4ro2 .disabled circle,#mermaid-svg-O1ShdHGfAXhU4ro2 .disabled text{fill:lightgray;}#mermaid-svg-O1ShdHGfAXhU4ro2 .disabled text{fill:#efefef;}#mermaid-svg-O1ShdHGfAXhU4ro2 .section-root rect,#mermaid-svg-O1ShdHGfAXhU4ro2 .section-root path,#mermaid-svg-O1ShdHGfAXhU4ro2 .section-root circle,#mermaid-svg-O1ShdHGfAXhU4ro2 .section-root polygon{fill:hsl(240, 100%, 46.2745098039%);}#mermaid-svg-O1ShdHGfAXhU4ro2 .section-root text{fill:#ffffff;}#mermaid-svg-O1ShdHGfAXhU4ro2 .section-root span{color:#ffffff;}#mermaid-svg-O1ShdHGfAXhU4ro2 .section-2 span{color:#ffffff;}#mermaid-svg-O1ShdHGfAXhU4ro2 .icon-container{height:100%;display:flex;justify-content:center;align-items:center;}#mermaid-svg-O1ShdHGfAXhU4ro2 .edge{fill:none;}#mermaid-svg-O1ShdHGfAXhU4ro2 .mindmap-node-label{dy:1em;alignment-baseline:middle;text-anchor:middle;dominant-baseline:middle;text-align:center;}#mermaid-svg-O1ShdHGfAXhU4ro2 :root{–mermaid-font-family:\”trebuchet ms\”,verdana,arial,sans-serif;}
知识图谱
核心概念
三元组
实体
关系
属性
构建方法
知识抽取
知识融合
知识存储
应用价值
结构化知识
关系推理
可解释性
最新技术
GraphRAG
ToG
ChatKBQA
面试加分话术
“知识图谱的核心价值在于将非结构化知识转化为结构化表示,支持复杂的关系推理。与向量数据库的语义检索不同,知识图谱可以进行多跳推理,回答’张三的同事的老板是谁’这类复杂问题。”
“我在项目中使用Neo4j构建了教育知识图谱,包含10万+知识点节点,实现了学习路径推荐和错题归因诊断功能。通过图遍历算法,可以找到学生的知识薄弱点。”
“我关注了微软最新的GraphRAG框架,它将知识图谱与RAG结合,通过社区发现和分层检索,显著提升了长文档问答的效果。这是知识图谱在AI应用中的重要发展方向。”
文档版本: v1.0 最后更新: 2024年 作者: E教千问技术团队
参考资料
核心论文
- GraphRAG: From Local to Global (Microsoft, 2024)
- Think-on-Graph: Deep and Responsible Reasoning (2024)
- ChatKBQA: A Generate-and-Retrieve Framework (2023)
开源项目
- Neo4j图数据库
- LangChain Knowledge Graph
- Microsoft GraphRAG
技术博客
- Neo4j官方文档
- 知识图谱构建最佳实践



