AI Personal Learning
and practical guidance
Ali-painted frog

Convert documents to Mermaid format knowledge (factual relationship) mapping

Recently studying Ollama's API DocumentationWhen it's hard to build up complete relationships in your head, it's a good idea to generate Mermaid-formatted relationship diagrams from API documents that represent only factual relationships. Of course, you can also use it to sort out the document's character relationships, event relationships, time relationships... and so on. And so on.

Document Conversion to Mermaid Format Knowledge Graph-1


 

clue

(defvar
Extracting the knowledge graph
(
(Knowledge graph construction guide
(Topic Extraction "Please identify the core topics and key concepts in the text.")
(Hierarchical Relationships "Analyze hierarchical, containment and juxtaposition relationships between concepts.")
(Cause and Effect Relationships "Identify cause and effect, influence and dependency relationships between concepts.")
(Chronological Relationships "Sort out the chronological order of events and concepts.")
(Comparative Relationships "Compare and contrast the similarities, differences, and correlations of different concepts.")
(Clustering grouping "Clustering related concepts and dividing them into subgraphs"))
(Output constraints
(Constraint "Output is formatted as Mermaid chart code"))
(constraint "Node labels and relationship labels are in Chinese"))
(constraint "Don't return anything outside of the knowledge graph"))
(node and relationship definitions
(Formatted " ```mermaid\ngraph LR\n"))
(Formatted " %% Definition of nodes based on core concepts extracted from topics"))
(Formatted " A[\"%s\"]" Node A name)
(Formatted " B[\"%s\"]" node B name)
(Formatted " %% Define connection based on conceptual relationship.")
(Formatted " %s -->|\"%s\"| %s" Start node Relationship description Target node)
;; Other node and relationship definitions
)
(Subgraph and style definitions
(formatting " %% Define subgraphs based on conceptual clustering")
(formatting " subgraph \"%s\"\n" subgraph name)
(traverse (lambda (node) (formatted " %s\n" node)) list of subgraph nodes)
(format " end\n")
(formatting " %% Define uniform style")
(formatting " classDef default fill:#f9f9f9,stroke:#333,stroke-width:2px;\n")
(traverse (lambda (node) (format " class %s highlight;\n" node)) list of highlighted nodes)
;; Other subgraphs and style definitions
)
(Dynamic data and custom styles
(formatting " %% Handling dynamic variables ")
(Formatting " A[\"{{%s}}\"]" node A variables)
(Format " B[\"{{%s}}\"]" node B variable)
(Formatted " %% Define custom style")
(formatting " classDef customStyle fill:#00ff00,stroke:#000,stroke-width:3px;\n")
(traversing (lambda (node) (formatting " class %s customStyle;\n" node)) list of custom style nodes)
;; Other dynamic data and custom styles
(formatted " ```")
)
))
</system_instruction

${content}

 

How to use

Role: Quickly build up a graphical relationship of important information in the document, visualize and read quickly

Usage document content replacement to:${content} placement

The generated code is previewed at: https://mermaid.live/

CDN1
May not be reproduced without permission:Chief AI Sharing Circle " Convert documents to Mermaid format knowledge (factual relationship) mapping

Chief AI Sharing Circle

Chief AI Sharing Circle specializes in AI learning, providing comprehensive AI learning content, AI tools and hands-on guidance. Our goal is to help users master AI technology and explore the unlimited potential of AI together through high-quality content and practical experience sharing. Whether you are an AI beginner or a senior expert, this is the ideal place for you to gain knowledge, improve your skills and realize innovation.

Contact Us
en_USEnglish