Creating and Querying Personalized Versions of Wikidata on a Laptop

Hans Chalupsky, Pedro A. Szekely, Filip Ilievski, Daniel Garijo, Kartik Shenoy

Abstract

Wikidata's immense scale—exceeding 1.3 billion statements—poses significant challenges for researchers seeking to perform complex, large-scale analytics. Traditional solutions involve either restrictive public SPARQL endpoints or resource-intensive local RDF servers. We present Kypher, a query language and processor integrated into the Knowledge Graph Toolkit (KGTK). Kypher enables the creation and querying of "personalized" versions of Wikidata on standard consumer hardware. By utilizing a compact tabular representation and an optimized SQLite backend, Kypher achieves performance levels that surpass traditional triple stores on complex aggregation tasks, completing global queries in minutes that otherwise fail on high-end servers.

Introduction

Wikidata is a monumental resource, yet it remains difficult to "crunch" for bulk data analysis. Developers typically face three suboptimal choices:

  1. Web APIs: Effective for single-entity lookups but unsuitable for bulk processing.
  2. Public SPARQL Endpoints: Constrained by strict timeouts (e.g., 5 minutes), which preclude complex queries such as global class instance counting.
  3. Local RDF Clones: Require enterprise-grade hardware (256GB+ RAM) and extensive setup times.

This creates a significant gap for researchers who need to perform heavy-duty graph analytics locally without access to data-center infrastructure. Kypher addresses this by providing a middle ground for efficient, local graph processing.

Methodology

Kypher (KGTK Cypher) is built upon two core pillars designed for efficiency and portability.

KGTK Data Representation

In contrast to the verbose RDF format and its complex reification patterns, KGTK employs a compact, four-column tab-separated value (TSV) format: edge-identifier, head, edge-label, and tail. This structure minimizes the data footprint and improves disk-based access speeds.

SQLite-Based Query Engine

Kypher translates graph queries, written in a syntax inspired by Neo4j’s Cypher, into optimized SQL. These are executed using SQLite, a lightweight, file-based database engine. This approach removes the overhead of managing database servers; the entire knowledge graph is stored as a single file.

Example of raw Kypher query results showing entity counts for Wikidata classes.

Furthermore, Kypher utilizes pre-computed specialized tables, such as transitive closures of subclass hierarchies (P279*). This allows hierarchical queries, which often cause SPARQL endpoints to time out, to execute in seconds.

Experiments and Results

We evaluated Kypher on a standard laptop (32GB RAM) against a high-performance server (24 cores, 256GB RAM) running a local Wikidata SPARQL clone.

Performance Benchmarks

  • Complex Aggregation: Counting instances of every class in Wikidata took 89 minutes on the laptop. The powerful SPARQL server failed to complete the task after 24 hours.
  • Data Integration: Mapping 27,000 external artist identifiers (ULAN) to Wikidata was completed in 11.8 seconds.
  • Sub-query Efficiency: Once a "personalized" slice of data is generated (e.g., all subclasses of "film"), subsequent queries on that slice run in approximately 2.4 seconds.
Kypher query results for film-related subclasses, demonstrating the ability to join entity IDs with human-readable labels.

As illustrated in the results above, Kypher effectively manages both raw entity counts and the integration of human-readable labels, facilitating rapid data exploration.

Conclusion

Kypher demonstrates that compactness and pre-computation are key to enabling large-scale knowledge graph analytics on modest hardware. By allowing users to "slice" and "personalize" Wikidata, Kypher shifts the burden from the query engine to the data preparation phase. While the initial conversion of Wikidata dumps remains a significant one-time cost, the resulting agility in querying makes it a powerful tool for the research community. Future work will focus on expanding language features, including support for path-range patterns and subqueries.

Summary updated

BibTeX
@inproceedings{chalupsky2021creating,
  author = {Hans Chalupsky and Pedro A. Szekely and Filip Ilievski and Daniel Garijo and Kartik Shenoy},
  title = {{Creating and Querying Personalized Versions of Wikidata on a Laptop}},
  booktitle = {Wikidata@ISWC},
  year = {2021},
  url = {https://openreview.net/forum?id=G6wYgkyXRa},
}
Figure