In this tutorial, we will generate knowledge graphs from plain text, conversations, and multiple source documents using kg-gen. We start by setting up the required dependencies and configuring an LLM through LiteLLM, then we extract entities, predicates, and relationships from simple text. As we move forward, we work with longer passages using chunking and clustering, combine knowledge graphs from different sources, visualize graph structures, and analyze them using NetworkX. By the end, we will build a complete workflow that turns unstructured text into an interpretable, searchable, visual, and exportable knowledge graph.

import subprocess, sys

def pip_install(pkgs):

subprocess.run([sys.executable, "-m", "pip", "install", "-q", *pkgs], check=True)

pip_install([