KGTK: A Toolkit for Large Knowledge Graph Manipulation and Analysis

Filip Ilievski, Daniel Garijo, Hans Chalupsky, Naren Teja Divvala, Yixiang Yao, Craig Milo Rogers, Ronpeng Li, Jun Liu, Amandeep Singh, Daniel Schwabe, Pedro A. Szekely

TL;DR

KGTK is an open-source, data science-centric toolkit designed to make manipulating and analyzing massive Knowledge Graphs (KGs) like Wikidata fast and accessible. By representing complex graphs as simple tab-separated values (TSVs) and leveraging Unix pipelines, KGTK bypasses the steep learning curve and performance bottlenecks of traditional Semantic Web tools, enabling blazing-fast graph operations on standard laptops.

What Problem Does This Paper Address?

Knowledge Graphs (KGs) have become the backbone of modern AI applications, used for everything from web search to medical research. However, the traditional Semantic Web toolchain used to interact with them (RDF formats, SPARQL query languages, and triple store databases) is notoriously difficult to use at scale.

Data scientists often find these tools heterogeneous, hard to integrate with modern machine learning libraries, and painfully slow for bulk operations. For instance, simply loading a full Wikidata dump into a triple store can take over a week, and running complex analytical queries often results in database timeouts. KGTK bridges this gap by providing a Scikit-learn-inspired toolkit that treats KGs as tabular data, making it easy to filter, merge, and analyze massive graphs without needing specialized database expertise or massive server clusters.

Methods

KGTK shifts away from complex RDF serializations in favor of a simple, tab-separated values (TSV) format. This format models KGs as hypergraphs where everything (even an edge) can be treated as a node, easily supporting complex qualifiers and metadata without the performance hit of RDF "reification."

Key features of the toolkit include:

  • The KGTK File Format: A column-based TSV format that natively supports typed literals (quantities, coordinates, time) and edge qualifiers (e.g., noting the "source" or "date" of a specific relationship).
  • Comprehensive Operations: 13 core commands grouped into import, export, graph curation (validate, clean, filter, join, sort), and analytics (centrality, connected components, text embeddings).
  • Unix Pipelining: KGTK commands can be chained together using standard Unix pipes. This avoids writing massive intermediate files to disk and allows parallel, streaming execution of graph operations.
  • NLP Integration: Built-in modules to compute text-based graph embeddings using state-of-the-art language models like BERT, DistilBERT, and RoBERTa.

Datasets

The paper does not introduce a new benchmark dataset, but it demonstrates KGTK's capabilities on several massive, real-world KGs:

  • Wikidata: Used for performance benchmarking (specifically the 23.2GB "truthy" statements dump).
  • CORD-19: The COVID-19 Open Research Dataset, which the authors integrated with Wikidata and the Comparative Toxicogenomics Database (CTD) to build a disease/gene/chemical KG.
  • ConceptNet & ATOMIC: Merged to create a consolidated Commonsense Knowledge Graph (CSKG).

Key Insights and Ideas

  • Simplicity scales: By representing complex graph structures as flat TSV files, KGTK allows developers to use highly optimized, off-the-shelf data science tools (like Pandas or standard Unix utilities like awk and sort) directly on graph data.
  • Pipelining is a superpower: Chaining graph operations via Unix pipes drastically reduces memory overhead and disk I/O. This makes it feasible to process graphs with billions of edges on a standard laptop rather than requiring a massive cloud instance.
  • Bridging the Semantic Web and NLP: By including native operations to generate text embeddings for graph nodes, KGTK directly links structural graph data with modern NLP pipelines, making it easier to use KGs for downstream tasks like question answering or entity linking.

Key Results

  • Massive Speedup: In a benchmark test filtering out all entities with a "P31" (instance of) property from the 23.2GB Wikidata dump, traditional tools like Apache Jena and RDFlib took over 20 hours. The JavaScript-based graphy library took 4 hours and 15 minutes. KGTK completed the exact same operation in under 1 hour and 30 minutes.
  • Real-world Viability: The authors successfully used KGTK to build a comprehensive COVID-19 knowledge graph by merging CORD-19 data with Wikidata and computing PageRank metrics for all nodes. This task would have been practically impossible using standard SPARQL queries against public endpoints due to query complexity and timeouts.

Limitations and Future Work

Limitations: KGTK currently focuses heavily on basic graph manipulation, curation, and structural analytics. It lacks built-in advanced machine learning tools for tasks like automated link prediction, entity resolution across different graphs, and ontology mapping. Furthermore, it does not yet feature native, advanced visualization tools.

Future Work: The development team plans to add these advanced ML operations to support more complex KG tasks. They are also working on expanding import/export formats (such as GraphViz for visualization) and are actively adapting the SQID Wikidata browser so users can natively explore arbitrary KGTK files visually without needing to deploy a full Wikidata backend infrastructure.

Summary updated

BibTeX
@inproceedings{ilievski2020kgtk,
  author = {Filip Ilievski and Daniel Garijo and Hans Chalupsky and Naren Teja Divvala and Yixiang Yao and Craig Milo Rogers and Ronpeng Li and Jun Liu and Amandeep Singh and Daniel Schwabe and Pedro A. Szekely},
  title = {{KGTK: A Toolkit for Large Knowledge Graph Manipulation and Analysis}},
  booktitle = {ISWC},
  year = {2020},
  url = {https://openreview.net/forum?id=KrmwNIfYfgc},
}
Figure