Streamlining Knowledge Graph Creation with PyRML

Andrea Giovanni Nuzzolese · 2025

Read Streamlining Knowledge Graph Creation with PyRML by Andrea Giovanni Nuzzolese (2025) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2505-20949.txt.

Introduction

Andrea Giovanni Nuzzolese, writing alone in 2025, presents PyRML, a Python library for building knowledge graphs. Knowledge graphs weave mixed data into linked facts for many fields. Mapping languages like RML state how to turn tables into graph form. Python users lacked a native way to write and run those mappings.

PyRML supports the core of RML inside plain Python code. Mappings can be authored, run, and tested in one place. It plugs into Pandas for data and RDFlib for graph handling. Workflows stay modular and open to inspection. Shared, repeatable mappings help teams trust their graphs. The library lowers the entry bar for careful data integration.

Catalog record

CREATORAndrea Giovanni Nuzzolese
YEAR2025
COLLECTIONPAPERS
FORMATTXT
FILE SIZE37 KB
VERSION1.0
LICENSEhttp://creativecommons.org/licenses/by/4.0/
RIGHTSCC BY
SOURCEarXiv

Source: https://arxiv.org/abs/2505-20949

Browse the full library · About the Tower of Babel

Full text

The opening of the work, from the library's hosted text:

Streamlining Knowledge Graph Creation with PyRML Andrea Giovanni Nuzzolese Abstract Knowledge Graphs (KGs) are increasingly adopted as a foundational technology for integrating heterogeneous data in domains such as climate science, cultural heritage, and the life sciences. Declarative mapping languages like R2RML and RML have played a central role in enabling scalable and reusable KG construction, offering a transparent means of transforming structured and semi-structured data into RDF. In this paper, we present PyRML, a lightweight, Python-native library for building Knowledge Graphs through declarative mappings. PyRML supports core RML constructs and provides a programmable interface for authoring, executing, and testing mappings directly within Python environments. It integrates with popular data and semantic web libraries (e.g., Pandas and RDFlib), enabling transparent and modular workflows. By lowering the barrier to entry for KG creation and fostering reproducible, ontology-aligned data integration, PyRML bridges the gap between declarative semantics and practical KG engineering. 1 Introduction Knowledge Graphs [ 7 ] (KGs) have become a foundational technology for integrating and querying heterogeneous data across domains such as climate science, cultural heritage, and life sciences. A core strength of KGs lies in their ability to make data explicit, interoperable, and semantically rich, aligning with the principles of FAIR [ 14 ] (Findable, Accessible, Interoperable, and Reusable) data. Among the various approaches to constructing KGs, declarative mapping languages, such as R2RML 1 1 1 http://www.w3.org/TR/r2rml/ and RML [ 4 , 9 ] , have emerged as key enablers in both literature and practice. By explicitly stating the rules for transforming data from structured and semi-structured sources (e.g., relational databases, CSV, JSON, XML, SPARQL services, etc.) into RDF, declarative mappings promote separation of concerns, reusability, and cross-source interoperability. These characteristics are particularly beneficial for collaborative and long-lived data integration efforts, where mapping logic must be shared, adapted, and audited over time. A variety of RML-compliant engines have been developed to support the execution of declarative mappings. Examples are RMLMapper 2 2 2 https://github.com/RMLio/rmlmapper-java , CARML 3 3 3 https://github.com/carml/carml , SDM-RDFizer [ 8 ] , and Morph-KGC [ 1 ] . These tools have proven effective in translating structured data into RDF at scale and have contributed significantly to the maturation of the semantic data integration ecosystem. However, their usage often assumes familiarity with command-line interfaces, specific configuration formats, or specific programming language environments, which can present barriers to integration in modern data science workflows. In addition, features such as mapping modularity, incremental generation, unit testing, and tight coupling with ontological reasoning are still underdeveloped or inconsistently supported across tools. In this context, PyRML is conceived as a Python-native alternative that supports interactive, programmable, and transparent KG construction. It complements existing engines while focusing on usability, extensibility, and seamless integration with the Python data ecosystem. Additionally, by abstracting some of the technical complexity while maintaining expressive power, PyRML contributes to bridging the gap between declarative semantics and practical KG engineering. The remainder of this paper is the following. Section 2 provides an overview of the related work. Section 3 details the proposed system architecture with usage examples. Section 4 describes the evaluation methodology and results. Finally, Section 5 discusses conclusions and future directions. 2 Related work The construction of KGs from structured and semi-structured data has been extensively explored in the Semantic Web community 4 4 4 Please refer to https://kg-construct.github.io/awesome-kgc-tools/ for an overview on existing tools for KG construction. . The foundational approaches focused on the integration of semantic data. These include the use of a view-based paradigm [ 11 ] , such as, Global-As-View [ 6 ] (GAV), Local-As-View [ 13 ] (LAV), and Global-Local-As-View [ 5 ] (GLAV). A view defines the relationships between heterogeneous data sources and a unified mediated schema. These paradigms, originally developed in the context of data warehouse and federated databases, provided the theoretical foundation for later declarative mapping languages used in the construction of KG. In particular, the GAV approach, where each element of the mediated schema is defined as a query over the sources, closely resembles modern RML mappings, where ontology terms are defined in terms of data source structure. In contrast, LAV and GLAV underpin more expressive approaches such as Ontology-Based Data Access (OBDA), where mappings specify how source data can satisfy arbitrary ontology queries. Although powerful, OBDA systems often rely on complex reasoning services, which can hinder scalability and accessibility for practitioners [ 10 ] . In recent years, declarative mapping languages such as the RDB to RDF Mapping Language (R2RML) and RDF Mapping Language [ 4 , 9 ] (RML) have become a standard mechanism for aligning raw data with RDF vocabularies and ontologies in a transparent and maintainable way. More specifically R2RML is designed to cope with the transformation of relational databases to RDF, whilst RML generalises the mapping model of R2RML to support diverse semi-structured data sources. Accordingly, several tools have been developed to implement and execute RML mappings. The RMLMapper, written in Java, was among the first engines to support full RML core semantics and has been widely used for research and data publication tasks. CARML builds on the same paradigm, offering improved modularity and performance. More recently, tools like SDM-RDFizer [ 8 ] and Morph-KGC [ 1 ] have focused on scalability and performance, enabling the efficient generation of large KGs from relational databases and tabular data. These engines have been successfully applied in large-scale projects, such as iASiS 5 5 5 http://project-iasis.eu/ , which is an EU funded project to enable precision medicine approaches by utilising insights from patient data. Despite their robustness, existing RML engines often assume specific technological stacks (e.g., Java or Docker-based deployments), and their integration with modern data science workflows—typically centred around Python—is limited. PyRML contributes to this landscape by offering a Python-native, programmable interface for RML-based KG construction. Unlike black-box engines, PyRML enables fine-grained control over mapping composition, execution, and testing, and is designed to integrate with widely used Python libraries such as Pandas and RDFlib. This positions PyRML as a complementary tool in the RML ecosystem, addressing the need for flexible, scriptable, and developer-friendly solutions in data-centric environments. A complementary approach to data integration is presented by SPARQL Anything [ 2 ] , which enables querying heterogeneous data sources directly using SPARQL, without the need for upfront data transformation into RDF. By overloading the SERVICE clause in SPARQL 1.1, SPARQL Anything allows users to access data from various formats through a uniform SPARQL interface. This approach leverages the Facade-X meta-model [ 3 ] to provide a simplified RDF representation of diverse data sources, facilitating rapid prototyping and ad-hoc querying. While SPARQL Anything excels in on-the-fly data access, it does not produce persistent RDF graphs, which may be a limitation for applications requiring long-term data storage and reasoning capabilities. 3 The PyRML system 3.1 Architecture Figure 1 shows the modular architecture of PyRML that counts of four main modules. These modules are: (i) the API module, (ii) core Framework, (iii) Functions Provider, and (iv) Mapper. Figure 1: The architecture of PyRML API module. The API module provides the abstract base classes that define the core structure of the programming interface for capturing the RML model within the software platform. At the top of this structure is the

Read the complete text