The PKG API is a tool for managing personal knowledge graphs (PKGs). It provides a simple solution for end users and service providers to administrate and interact with the users' PKGs through natural language statements and simple web forms. The representation of a statement inside the PKG is defined by the PKG vocabulary. Within the API, two key modules are present: one for processing natural language statements (NL2PKG), and another for generating and executing SPARQL queries against the PKG (PKG connector).
The PKG API is served as a RESTful API and we provide a user interface, PKG Client, that allows users to manage their PKG online.
This module is responsible for processing natural language statements. The processing is divided into two steps: (1) natural language understanding handled by annotators
and (2) entity_linking
.
Available annotators and entity linkers:
StatementAnnotator
ThreeStepStatementAnnotator
: Annotates statements using a three-step approach: (1) intent recognition, (2) Subject-Predicate-Object triple extraction, and (3) preference extraction.
EntityLinker
RELEntityLinker
: Links entities using Radboud Entity Linker API.SpotlightEntityLinker
: Links entities using DBpedia Spotlight.
The PKG connector is responsible for executing SPARQL queries against the PKG. Utilities functions are responsible for generating SPARQL queries based on the intent of the user. For example, if a user wants to add a statement to the PKG, a tailored INSERT query is generated.
The backend server is a Flask server. It is responsible for connecting the users and service providers to PKGs.
Before starting the server, make sure that the requirements are installed and that CORS is disabled in your web browser.
To start the server, run the following command:
flask --app pkg_api/server run --debug
Note the --debug
flag is optional, but it is recommended to use it during development.
By default, the server will run locally on port 5000. In case you want to run the server on a different port, you can specify the port using the --port
flag.
The user interface is a React application that communicates with the server to manage the PKG. More details on how to run PKG Client can be found here.
PKG_API_BASE_URL
in the configuration in case the server is not running on the default port.
PKG_API_demo.mov
The code for the demo is available in this branch.
We follow the IAI Python Style Guide.
If you use the PKG API, please cite the following paper:
@inproceedings{Bernard:2024:WWW,
author = {Bernard, Nolwenn and Kostric, Ivica and \L{}ajewska, Weronika and Balog, Krisztian and Galus\v{c}\'{a}kov\'{a}, Petra and Setty, Vinay and Skj\ae{}veland, Martin G.},
title = {{PKG API}: {A} Tool for Personal Knowledge Graph Management},
booktitle = {Companion Proceedings of the ACM on Web Conference 2024},
pages = {1051--1054},
series = {WWW '24},
year = {2024},
doi = {10.1145/3589335.3651247},
}
PKG API is developed and maintained by the IAI group at the University of Stavanger.