152 103 43MB
English Pages 764 [743] Year 2021
LNCS 12731
Ruben Verborgh · Katja Hose · Heiko Paulheim · Pierre-Antoine Champin · Maria Maleshkova · Oscar Corcho · Petar Ristoski · Mehwish Alam (Eds.)
The Semantic Web 18th International Conference, ESWC 2021 Virtual Event, June 6–10, 2021 Proceedings
Lecture Notes in Computer Science Founding Editors Gerhard Goos Karlsruhe Institute of Technology, Karlsruhe, Germany Juris Hartmanis Cornell University, Ithaca, NY, USA
Editorial Board Members Elisa Bertino Purdue University, West Lafayette, IN, USA Wen Gao Peking University, Beijing, China Bernhard Steffen TU Dortmund University, Dortmund, Germany Gerhard Woeginger RWTH Aachen, Aachen, Germany Moti Yung Columbia University, New York, NY, USA
12731
More information about this subseries at http://www.springer.com/series/7409
Ruben Verborgh Katja Hose Heiko Paulheim Pierre-Antoine Champin Maria Maleshkova Oscar Corcho Petar Ristoski Mehwish Alam (Eds.) •
•
•
•
•
•
•
The Semantic Web 18th International Conference, ESWC 2021 Virtual Event, June 6–10, 2021 Proceedings
123
Editors Ruben Verborgh Ghent University Ghent, Belgium
Katja Hose Aalborg University Aalborg, Denmark
Heiko Paulheim University of Mannheim Mannheim, Germany
Pierre-Antoine Champin ERCIM Sophia Antipolis, France
Maria Maleshkova University of Siegen Siegen, Germany
Oscar Corcho Universidad Politécnica de Madrid Boadilla del Monte, Spain
Petar Ristoski eBay Inc. San Jose, CA, USA
Mehwish Alam FIZ Karlsruhe - Leibniz Institute for Information Infrastructure Eggenstein-Leopoldshafen, Germany
ISSN 0302-9743 ISSN 1611-3349 (electronic) Lecture Notes in Computer Science ISBN 978-3-030-77384-7 ISBN 978-3-030-77385-4 (eBook) https://doi.org/10.1007/978-3-030-77385-4 LNCS Sublibrary: SL3 – Information Systems and Applications, incl. Internet/Web, and HCI © Springer Nature Switzerland AG 2021, corrected publication 2021 This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed. The use of general descriptive names, registered names, trademarks, service marks, etc. in this publication does not imply, even in the absence of a specific statement, that such names are exempt from the relevant protective laws and regulations and therefore free for general use. The publisher, the authors and the editors are safe to assume that the advice and information in this book are believed to be true and accurate at the date of publication. Neither the publisher nor the authors or the editors give a warranty, expressed or implied, with respect to the material contained herein or for any errors or omissions that may have been made. The publisher remains neutral with regard to jurisdictional claims in published maps and institutional affiliations. This Springer imprint is published by the registered company Springer Nature Switzerland AG The registered company address is: Gewerbestrasse 11, 6330 Cham, Switzerland
Preface
What does it mean to have a conference in these strange times? Semantic drift is biting us once again. The word “conference” has its roots in Latin, where it means bringing things together. If there is one thing we cannot do yet, it is bringing people together. While we have become moderately good at online meetings and virtual gatherings of all kinds, we still have not found an adequate replacement for a coffee break. The power of spontaneous interactions is immense; undoubtedly, some of the best collaborations in our field have started over coffee — or liquids with similar cohesive abilities — in Crete. However, “to confer” also means to have discussions and exchange opinions. We believe that dialogue is one of the most important aspects of a healthy research community, and we have made it one of our goals to see how we can further drive such conversations. The results of several of those exchanges can be found in these proceedings, and in the echoes of this year’s online conference, which surely will have planted new seeds for the exciting times to come once the world opens up again. Since these times bring great changes, we took the opportunity to introduce a few more novelties for the 18th edition of the European Semantic Web Conference (ESWC 2021). While the world was closing down, we decided to make the reviewing process more open and switch from the well-established, closed Easychair platform to OpenReview. As a result, the submissions, reviews, and discussions for all papers are now available to the public, moving the paper decisions away from back room discussions to provide a transparent process. Moreover, some new research track topics were proposed. Two of the more experimental ones are “replication studies”, which gives a strong case for analyzing whether research efforts stand the test of time, and “problems to solve before you die”, which aims to shift the focus from sometimes very specific solutions for particular problems to a wider research agenda. Moreover, for the first time, “negative result” submissions were invited across all tracks, which garnered particularly good feedback. Overall, the research track attracted 121 submissions of which 30 were ultimately accepted, with a third undergoing a shepherding process, yielding an acceptance rate of 24.8%. It is particularly remarkable that the acceptance rate for negative results papers was comparable to the overall acceptance rate, which shows that reporting negative results is actually appreciated by the research community. In the research track, most contributions were submitted to the knowledge graph track, while tracks such as (i) NLP and information retrieval, (ii) matching, integration, and fusion, (iii) data dynamics, quality, and trust, and (iv) ontologies and reasoning also attracted significant numbers of contributions. Moreover, we observed some emerging topics: not quite surprisingly, knowledge graph embeddings were a hot topic among the accepted papers, but there were also enough submissions on autonomous driving to fill a dedicated session in the program.
vi
Preface
The resources track attracted a total of 36 submissions, 11 of which were accepted. The track demonstrated very well that the community is not only producing theoretical research but also datasets and artifacts that can be reused by researchers and practitioners. Finally, the in-use track attracted 10 submissions, 2 of which were finally accepted for presentation at the conference. Both the resources and the in-use track demonstrated that the field is clearly moving towards adoption of the developed methods on a large scale and in real projects. With its 18th edition, ESCW 2021 has officially stepped into adulthood, and it clearly shows in the vibrant and active community. An event like ESWC, be it offline or online, is never the outcome of the work of a few people but an effort that takes a lot of hands. Overall, ESWC 2021 had 23 people on the organization team, plus 20 track chairs for the various topical areas of the research track. 240 reviewers produced a total of 545 reviews, many of them signing with their name and thereby making the review process more transparent. We would like to give a big shout-out to everybody in this community who lent a hand to help - ESWC would not be the same without your contribution! Moreover, we would like to thank STI, OpenReview, and Springer for their support. We finally would like to thank our sponsors for supporting ESWC 2021. Here’s to meeting you all in person for a Greek salad and raki, while making new memories. April 2021
Ruben Verborgh Katja Hose Heiko Paulheim Pierre-Antoine Champin Maria Maleshkova Oscar Corcho Petar Ristoski Mehwish Alam
Organization
General Chair Ruben Verborgh
Ghent University, Belgium
Program Chairs Katja Hose Heiko Paulheim
Aalborg University, Denmark University of Mannheim, Germany
In-Use Chairs Oscar Corcho Petar Ristoski
Universidad Politécnica de Madrid, Spain IBM Research, USA
Resources Chairs Pierre-Antoine Champin Maria Maleshkova
Université Claude Bernard Lyon 1, France University of Bonn, Germany
Digital Conference Chairs Violeta Ilik Christian Hauschke
Adelphi University Libraries, USA Leibniz Information Center for Science and Technology, University Library (TIB), Germany
Workshop and Tutorial Chairs Femke Ongenae Riccardo Tommasini
Ghent University, Belgium University of Tartu, Estonia
Posters and Demo Chairs Anastasia Dimou Aidan Hogan
Ghent University, Belgium Universidad de Chile and IMFD, Chile
PhD Chairs Ilaria Tiddi Claudia d’Amato
Vrije Universiteit Amsterdam, the Netherlands University of Bari, Italy
viii
Organization
Track Chairs Simon Mayer Arne Bröring
University of St. Gallen, Switzerland Siemens AG, Germany
Sponsors Chair Daniele Dell’Aglio Christian Dirschl
Aalborg University, Denmark Wolters Kluwer Deutschland GmbH, Germany
Project Networking Chair Alexandra Garatzogianni
Leibniz Information Center for Science and Technology, University Library (TIB), Germany
Web and Publicity Chair Cogan Shimizu
Kansas State University, USA
Semantic Chair François Scharffe
Columbia University, USA
Proceedings Chair Mehwish Alam
FIZ Karlsruhe - Leibniz Institute for Information Infrastructure and Karlsruhe Institute of Technology, Germany
Subtrack Chairs Ontologies and Reasoning Cogan Shimizu Jacopo Urbani
Kansas State University, USA Vrije Universiteit Amsterdam, the Netherlands
Knowledge Graphs Marta Sabou Axel Polleres
TU Wien, Austria Vienna University of Economics and Business, Austria
Semantic Data Management, Querying and Distributed Data Maribel Acosta Hala Skaf-Moli
Ruhr-University Bochum, Germany LS2N and University of Nantes, France
Organization
Data Dynamics, Quality, and Trust Emanuele Della Valle Anisa Rula
Politecnico di Milano, Italy University of Milano-Bicocca, Italy
Matching, Integration, and Fusion Catia Pesquita Ernesto Jimenez-Ruiz
LASIGE and Universidade de Lisboa, Portugal City, University of London, UK, and University of Oslo, Norway
NLP and Information Retrieval Klaus Berberich Ziqi Zhang
Saarland University of Applied Sciences, Germany University of Sheffield, UK
Machine Learning Michael Cochez Daria Stepanova
Vrije Universiteit Amsterdam, the Netherlands Bosch Center for AI, Germany
Science Data and Scholarly Communication Andrea Giovanni Nuzzolese Rafael Gonçalves
National Research Council, Italy Stanford University, USA
Problems to Solve Before You Die Harald Sack
Frank van Harmelen
FIZ Kalrsruhe - Leibniz Institute for Information Infrastructure and Karlsruhe Institute of Technology, Germany Vrije Universiteit Amsterdam, the Netherlands
Program Committee Aaron Eberhart Achim Rettinger Adam Funk Adila Krisnadhi Aditya Mogadala Adrian Soto Suarez Adrian Brasoveanu Aidan Hogan Alasdair Gray Alessandra Russo Alessandro Adamou Alessandro Faraotti Alsayed Algergawy Anastasia Dimou
Kansas State University, USA Trier University, Germany University of Sheffield, UK Universitas Indonesia, Indonesia Saarland University, Germany Universidad Adolfo Ibáñez, Chile Modul Technology GmbH, Austria DCC, Universidad de Chile, Chile Heriot-Watt University, UK Imperial College London, UK Bibliotheca Hertziana - Max Planck Institute for Art History, Italy Sapienza University of Rome, Italy University of Jena, Germany Ghent University, Belgium
ix
x
Organization
Andrea Pomp Andrea G. B. Tettamanzi Andreas Thalhammer Andreea Iana Andriy Nikolov Angelo Salatino Anisa Rula Anna Fensel Antoine Isaac Antoine Zimmermann Arkaitz Zubiaga Armando Stellato Armin Haller Audun Stolpe Baris Sertkaya Blake Regalia Blerina Spahiu Carlos Bobed Lisbona Carlos Buil-Aranda Carole Goble Carolina Scarton Cassia Trojahn Catherine Faron Catherine Roussey Catia Pesquita Cedric Pruski Christoph Lange Christopher J. O. Baker Claudia d'Amato Claudia Marinica Cord Wiljes Dag Hovland Dagmar Gromann Danh Le Phuoc Daniel Faria Daniel Garijo Daniela Oliveira Davide Buscaldi Dennis Diefenbach Diego Moussallem Dimitris Plexousakis Domagoj Vrgoc Dominic Seyler Edna Ruckhaus Magnus Eero Hyvonen
University of Wuppertal, Germany University of Nice Sophia Antipolis, France Karlsruhe Institute of Technology, Germany University of Mannheim, Germany KMI - Open University, UK KMI - Open University, UK University of Bonn, Germany University of Innsbruck, Austria Europeana, the Netherlands Mines Saint-Etienne, France Queen Mary University London, UK University of Rome Tor Vergata, Italy Australian National University, Australia Norwegian Computing Center, Norway Frankfurt University of Applied Sciences, Germany University of California, USA University of Milan-Bicocca, Italy Universidad de Zaragoza, Spain Universidad Técnica Federico Santa María, Chile University of Manchester, UK University of Sheffield, UK Institut de Recherche en Informatique de Toulouse, France University of Cote d'Azur, France INRAE, France Universidade de Lisboa, Lisbon Paris Sud University, France RWTH Aachen University, Germany University of New Brunswick, Canada University of Bari, Italy Polytech Nantes, France Bielefeld University, Germany University of Oslo, Norway University of Vienna, Austria TU Berlin, Germany INESC-ID, Portugal USC/ISI, USA University of Lisbon, Portugal École Polytechnique, France Jean Monnet University, France Paderborn University, Germany FORTH-ICS, Greece Pontificia Universidad Católica de Chile, Chile University of Illinois Urbana-Champaign, USA Universidad Simón Bolívar, Venezuela University of Helsinki, Finland
Organization
Elena Demidova Elena Simperl Emanuel Sallinger Enrico Daga Eva Blomqvist Fabian M. Suchanek Fabio Vitali Fajar J. Ekaputra Fatiha Saïs Felix Sasaki Fernando Bobillo Filip Ilievski Flavius Frasincar Fouad Zablith Francesca Alessandra Lisi Francesco Corcoglioniti Francesco Osborne Francisco Martin-Recuerda Frederique Laforest Gayo Diallo Gengchen Maigeng Georg Rehm George Papadakis Georgeta Bordea Gerardo Simari Gerd Stumme Gerhard Wohlgenannt Gezim Sejdiu Ghislain Atemezing Gianluca Demartini Giuseppe Pirrò Giuseppe Rizzo Gong Cheng Gregory Todd Williams Guangyuan Piao Guohui Xiao Hajira Jabeen Hala Skaf-Molli Hamada M. Zahera Hanna Ćwiek-Kupczyńska Harald Sack Haridimos Kondylakis Harshvardhan J. Pandit Henry Rosales-Méndez Ibrahim Abdelaziz
xi
University of Bonn, Germany King’s College London, UK TU Wien, Vienna KMI - Open University, UK Linköping University, Sweden Telecom ParisTech, France University of Bologna, Italy TU Wien, Austria Paris Saclay University, France Technische Hochschule Brandenburg, Germany Universidad de Zaragoza, Spain USC/ISI, USA Erasmus University Rotterdam, the Netherlands American University of Beirut, Lebanon University of Bari, Italy Free University of Bozen-Bolzano, Italy KMI - Open University, UK Universidad Politécnica de Madrid, Spain INSA Lyon, France University of Bordeaux, France UC Santa Barbara, USA Deutsches Forschungszentrum für Künstliche Intelligenz, Germany University of Athens, Greece University of Bordeaux, France Universidad Nacional del Sur, Argentina Universität Kassel, Germany Vienna University of Economics and Business, Austria University of Bonn, Germany Mondeca, France University of Queensland, Australia Sapienza University of Rome, Italy LINKS Foundation, Italy Nanjing University, China Rensselaer Polytechnic Institute, USA National University of Ireland, Maynooth, Ireland Free University of Bozen-Bolzano, Italy University of Cologne, Germany University of Nantes, France Paderborn University Polish Academy of Sciences, Poland Karlsruhe Institute of Technology, Germany FORTH, Greece Trinity College Dublin, Ireland Universidad de Chile, Chile KAUST, Saudi Arabia
xii
Organization
Ilaria Tiddi Inah Omoronyia Irene Celino Ismini Lourentzou Ivan Donadello Jürgen Umbrich Javier D. Fernandez Jean-Paul Calbimonte Jerome David Jesualdo Tomas Fernandez-Breis Jetzabel Serna-Olvera Jianfeng Du Jiaoyan Chen Jodi Schneider Joe Raad Johann Petrak Johann Wanja Schaible Jose Manuel Gomez-Perez Jose Mora Josiane Xavier Parreira Juan L Reutter Juan Sequeda Jun Ma Kavitha Srinivas Kewen Wang Kjetil Kjernsmo Kody Moodley Konstantin Schekotihin Konstantin Todorov Krzysztof Janowicz Lars Gleim Lionel Medini Loris Bozzato Ludger van Elst Lukas Schmelzeisen Manolis Koubarakis Manuel Atencia Maria del Mar Roldon-Garcia Maria Poveda-Villalon Marc Spaniol Marco Luca Sbodio
Vrije Universiteit Amsterdam, the Netherlands University of Glasgow, UK Cefriel, Italy Virginia Tech, USA Fondazione Bruno Kessler, Italy Vienna University of Economics and Business, Austria Vienna University of Economics and Business, Austria University of Applied Sciences and Arts Western Switzerland, Switzerland University of Grenoble-Alpes, France Universidad de Murcia, Spain Goethe University, Germany Guangdong University of Foreign Studies, China University of Oxford, UK University of Illinois Urbana-Champaign, USA Vrije Universiteit Amsterdam, the Netherlands University of Sheffield, UK GESIS - Leibniz Institute for the Social Sciences, Germany expert.ai, Spain Huawei Technologies Ltd., Ireland Siemens Corporate Research, Austria Pontificia Universidad Católica de Chile, Chile data.world, USA Carnegie Mellon University, USA IBM Research, USA Griffith University, Australia Inrupt Inc., Norway Maastricht University, the Netherlands Alpen-Adria University of Klagenfurt, Austria University of Montpellier, France UC Santa Barbara, USA RWTH Aachen University, Germany University of Claude Bernard Lyon 1, France Fondazione Bruno Kessler, Italy German Research Center for AI, Germany University of Stuttgart, Germany National and Kapodistrian University of Athens, Greece University of Grenoble-Alpes, France University of Malaga, Spain Universidad Politécnica de Madrid, Spain Caen University, France IBM Research, Ireland
Organization
Maria Angela Pellegrino Maria Koutraki Mariano Fernandez-Lopez Marieke van Erp Martin G. Skjæveland Martin Theobald Matteo Palmonari Matthias Klusch Maulik Kamdar Maurizio Atzori Mauro Dragoni Maxime Lefrancois Mayank Kejriwal Mehwish Alam Michael Cochez Miguel A. Martinez-Prieto Milan Dojchinovski Muhammad Saleem Mustafa Jarrar Nadine Steinmetz Nandana Mihindukulasooriya Naouel Karam Natanael Arndt Nathalie Aussenac-Gilles Nathalie Hernandez Nathalie Pernelle Natthawut Kertkeidkachorn Nicolas Heist Oana Inel Olaf Hartig Oliver Lehmberg Olivier Corby Ondej Zamazal Oscar Corcho Panos Alexopoulos Pascal Hitzler Pascal Molli Paul Groth Pavel Shvaiko Pavlos Fafalios Petar Ristoski Peter Bloem
University of Salerno, Italy L3S, Germany Universidad CEU San Pablo, Spain KNAW Humanities Cluster, the Netherlands University of Stavanger, Norway University of Luxembourg, Luxembourg University of Milan-Bicocca, Italy German Research Center for AI, Germany Stanford University, USA University of Cagliari, Italy University of Trento, Italy Mines Saint-Etienne, France USC/ISI, USA FIZ Karlsruhe - Leibniz Institute for Infrastructure, Germany VU Amsterdam, the Netherlands University of Valladolid, Spain Leipzig University, Germany Leipzig University, Germany Birzeit University, Palestine TU Ilmenau, Germany IBM, USA Fraunhofer FOKUS, Germany Leipzig University, Germany CNRS, France IRIT, France University Sorbonne Paris Nord, France National Institute of Advanced Industrial Science and Technology, Japan University of Mannheim, Germany Delft University of Technology, the Netherlands Linköping University, Sweden University of Mannheim, Germany University Cote d'Azur, France Prague University of Economics and Business, Czech Republic Universidad Politécnica de Madrid Textkernel, the Netherlands Kansas State University, USA University of Nantes, France University of Amsterdam, the Netherlands University of Trento, Italy ICS-FORTH, Greece eBay, USA Vrije Universiteit Amsterdam, the Netherlands
xiii
xiv
Organization
Pierre-Antoine Champin Rafael Berlanga Rafael S. Goncalves Raghava Mutharaju Ralf Krestel Raphael Troncy Ricardo Usbeck Riccardo Tommasini Rigo Wenning Rinke Hoekstra Roghaiyeh Gachpaz Hamed Roman Kontchakov Ruben Taelman Rui Zhu Ruijie Wang Russa Biswas Ryutaro Ichise Sabrina Kirrane Sahar Vahdati Sebastian Neumaier Sebastian Richard Bader Sebastian Tramp Sebastijan Dumancic Serena Villata Sergio José Rodríguez Méndez Simon Gottschalk Simon Razniewski Simon Steyskal Simona Colucci Songmao Zhang Stasinos Konstantopoulos Stefan Dietze Steffen Staab Sven Hertling Tassilo Pellegrini Tobias Kaefer Tobias Weller Tomi Kauppinen Torsten Hahmann Umberto Straccia Vadim Ermolayev Valentina Anita Carriero Valentina Presutti Varish Mulwad
ERCIM, France Universitat Jaume I, Spain Stanford University, USA Indraprastha Institute of Information Technology, India Hasso Plattner Institute, Germany Eurecom, France Fraunhofer IAIS, Germany University of Tartu, Estonia ERCIM, France Elsevier, the Netherlands Trinity College Dublin, Ireland Birkbeck, University of London, UK Ghent University, Belgium UC Santa Barbara, USA University of Illinois Urbana-Champaign, USA Karlsruhe Institute of Technology, Germany National Institute of Informatics, Japan Vienna University of Economics and Business, Austria Leipzig University, Germany University of Applied Sciences St. Pölten, Austria Fraunhofer IAIS, Germany eccenca GmbH, Germany KU Leuven, Belgium CNRS, France Australian National University, Australia Leibniz University of Hannover, Germany Max Planck Institute for Informatics, Germany Vienna University of Economics and Business, Austria Politecnico di Bari, Italy Academy of Mathematics and Systems Science, Chinese Academy of Sciences, China NCSR Demokritos, Greece GESIS and HHU, Germany University of Stuttgart, Germany University of Mannheim, Germany University of Applied Sciences St. Pölten, Austria Karlsruhe Institute of Technology, Germany University of Mannheim, Germany Aalto University, Finland University of Maine, USA ISTI-CNR, Italy Zaporizhzhia National University, Ukraine University of Bologna, Italy University of Bologna, Italy General Electric, USA
Organization
Victor de Boer Vinh Nguyen Wei Hu Wolfgang Faber Xander Wilcke Xingyi Song Ying Ding Yuan-Fang Li Ziqi Zhang
Sponsors Platinum
Silver
Bronze
Supporter
Vrije Universiteit Amsterdam, the Netherlands U.S. National Library of Medicine, USA Nanjing University, China Alpen-Adria University of Klagenfurt, Austria Vrije Universiteit Amsterdam, the Netherlands University of Sheffield, UK University of Texas at Austin, USA Monash University, Australia University of Sheffield, UK
xv
Contents
Ontologies and Reasoning Streaming Partitioning of RDF Graphs for Datalog Reasoning . . . . . . . . . . . Temitope Ajileye, Boris Motik, and Ian Horrocks Parallelised ABox Reasoning and Query Answering with Expressive Description Logics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Andreas Steigmiller and Birte Glimm
3
23
Analysing Large Inconsistent Knowledge Graphs Using Anti-patterns . . . . . . Thomas de Groot, Joe Raad, and Stefan Schlobach
40
Processing SPARQL Property Path Queries Online with Web Preemption . . . Julien Aimonier-Davat, Hala Skaf-Molli, and Pascal Molli
57
Ontology-Based Map Data Quality Assurance. . . . . . . . . . . . . . . . . . . . . . . Haonan Qiu, Adel Ayara, and Birte Glimm
73
Knowledge Graphs (Understanding, Creating, and Exploiting) Applying Grammar-Based Compression to RDF . . . . . . . . . . . . . . . . . . . . . Michael Röder, Philip Frerk, Felix Conrads, and Axel-Cyrille Ngonga Ngomo
93
HDT Bitmap Triple Indices for Efficient RDF Data Exploration . . . . . . . . . . Maximilian Wenzel, Thorsten Liebig, and Birte Glimm
109
Programming and Debugging with Semantically Lifted States. . . . . . . . . . . . Eduard Kamburjan, Vidar Norstein Klungre, Rudolf Schlatte, Einar Broch Johnsen, and Martin Giese
126
Do Embeddings Actually Capture Knowledge Graph Semantics? . . . . . . . . . Nitisha Jain, Jan-Christoph Kalo, Wolf-Tilo Balke, and Ralf Krestel
143
A Semantic Framework to Support AI System Accountability and Audit . . . . Iman Naja, Milan Markovic, Peter Edwards, and Caitlin Cottrill
160
Semantic Data Management, Querying and Distributed Data Comparison Table Generation from Knowledge Bases . . . . . . . . . . . . . . . . . Arnaud Giacometti, Béatrice Markhoff, and Arnaud Soulet
179
xviii
Contents
Incremental Schema Discovery at Scale for RDF Data . . . . . . . . . . . . . . . . . Redouane Bouhamoum, Zoubida Kedad, and Stéphane Lopes HTTP Extensions for the Management of Highly Dynamic Data Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Lars Gleim, Liam Tirpitz, and Stefan Decker Expressibility of OWL Axioms with Patterns . . . . . . . . . . . . . . . . . . . . . . . Aaron Eberhart, Cogan Shimizu, Sulogna Chowdhury, Md. Kamruzzaman Sarker, and Pascal Hitzler
195
212 230
Data Dynamics, Quality, and Trust Refining Transitive and Pseudo-Transitive Relations at Web Scale . . . . . . . . Shuai Wang, Joe Raad, Peter Bloem, and Frank van Harmelen Data Reliability and Trustworthiness Through Digital Transmission Contracts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Simon Mangel, Lars Gleim, Jan Pennekamp, Klaus Wehrle, and Stefan Decker
249
265
Matching, Integration, and Fusion Neural Knowledge Base Repairs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Thomas Pellissier Tanon and Fabian Suchanek Natural Language Inference over Tables: Enabling Explainable Data Exploration on Data Lakes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Mario Ramirez, Alex Bogatu, Norman W. Paton, and André Freitas
287
304
NLP and Information Retrieval Grounding Dialogue Systems via Knowledge Graph Aware Decoding with Pre-trained Transformers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Debanjan Chaudhuri, Md Rashad Al Hasan Rony, and Jens Lehmann WEB-SOBA: Word Embeddings-Based Semi-automatic Ontology Building for Aspect-Based Sentiment Classification . . . . . . . . . . . . . . . . . . . . . . . . . Fenna ten Haaf, Christopher Claassen, Ruben Eschauzier, Joanne Tjan, Daniël Buijs, Flavius Frasincar, and Kim Schouten Context Transformer with Stacked Pointer Networks for Conversational Question Answering over Knowledge Graphs . . . . . . . . . . . . . . . . . . . . . . . Joan Plepi, Endri Kacupaj, Kuldeep Singh, Harsh Thakkar, and Jens Lehmann
323
340
356
Contents
xix
Machine Learning Neural Multi-hop Reasoning with Logical Rules on Biomedical Knowledge Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Yushan Liu, Marcel Hildebrandt, Mitchell Joblin, Martin Ringsquandl, Rime Raissouni, and Volker Tresp Augmenting Ontology Alignment by Semantic Embedding and Distant Supervision . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Jiaoyan Chen, Ernesto Jiménez-Ruiz, Ian Horrocks, Denvar Antonyrajah, Ali Hadian, and Jaehun Lee Convolutional Complex Knowledge Graph Embeddings. . . . . . . . . . . . . . . . Caglar Demir and Axel-Cyrille Ngonga Ngomo
375
392
409
RETRA: Recurrent Transformers for Learning Temporally Contextualized Knowledge Graph Embeddings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Simon Werner, Achim Rettinger, Lavdim Halilaj, and Jürgen Lüttin
425
Injecting Background Knowledge into Embedding Models for Predictive Tasks on Knowledge Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Claudia d’Amato, Nicola Flavio Quatraro, and Nicola Fanizzi
441
Science Data and Scholarly Communication Structured Semantic Modeling of Scientific Citation Intents . . . . . . . . . . . . . Roger Ferrod, Luigi Di Caro, and Claudio Schifanella Discovering Research Hypotheses in Social Science Using Knowledge Graph Embeddings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Rosaline de Haan, Ilaria Tiddi, and Wouter Beek
461
477
Problems to Solve Before You Die Towards a Linked Open Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Ahmed El Amine Djebri, Antonia Ettorre, and Johann Mortara
497
A Polyvocal and Contextualised Semantic Web . . . . . . . . . . . . . . . . . . . . . Marieke van Erp and Victor de Boer
506
Resources The WASABI Dataset: Cultural, Lyrics and Audio Analysis Metadata About 2 Million Popular Commercially Released Songs. . . . . . . . . . . . . . . . Michel Buffa, Elena Cabrio, Michael Fell, Fabien Gandon, Alain Giboin, Romain Hennequin, Franck Michel, Johan Pauwels, Guillaume Pellerin, Maroua Tikat, and Marco Winckler
515
xx
Contents
RuBQ 2.0: An Innovated Russian Question Answering Dataset. . . . . . . . . . . Ivan Rybin, Vladislav Korablinov, Pavel Efimov, and Pavel Braslavski A Knowledge Organization System for the United Nations Sustainable Development Goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Amit Joshi, Luis Gonzalez Morales, Szymon Klarman, Armando Stellato, Aaron Helton, Sean Lovell, and Artur Haczek
532
548
RSP4J: An API for RDF Stream Processing . . . . . . . . . . . . . . . . . . . . . . . . Riccardo Tommasini, Pieter Bonte, Femke Ongenae, and Emanuele Della Valle
565
WasmTree: Web Assembly for the Semantic Web. . . . . . . . . . . . . . . . . . . . Julian Bruyat, Pierre-Antoine Champin, Lionel Médini, and Frédérique Laforest
582
ParaQA: A Question Answering Dataset with Paraphrase Responses for Single-Turn Conversation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Endri Kacupaj, Barshana Banerjee, Kuldeep Singh, and Jens Lehmann
598
kgbench: A Collection of Knowledge Graph Datasets for Evaluating Relational and Multimodal Machine Learning . . . . . . . . . . . . . . . . . . . . . . . Peter Bloem, Xander Wilcke, Lucas van Berkel, and Victor de Boer
614
The SLOGERT Framework for Automated Log Knowledge Graph Construction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Andreas Ekelhart, Fajar J. Ekaputra, and Elmar Kiesling
631
P2P-O: A Purchase-To-Pay Ontology for Enabling Semantic Invoices . . . . . . Michael Schulze, Markus Schröder, Christian Jilek, Torsten Albers, Heiko Maus, and Andreas Dengel KOBE: Cloud-Native Open Benchmarking Engine for Federated Query Processors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Charalampos Kostopoulos, Giannis Mouchakis, Antonis Troumpoukis, Nefeli Prokopaki-Kostopoulou, Angelos Charalambidis, and Stasinos Konstantopoulos CSKG: The CommonSense Knowledge Graph . . . . . . . . . . . . . . . . . . . . . . Filip Ilievski, Pedro Szekely, and Bin Zhang
647
664
680
In-Use Track A Knowledge Graph-Based Approach for Situation Comprehension in Driving Scenarios . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Lavdim Halilaj, Ishan Dindorkar, Jürgen Lüttin, and Susanne Rothermel
699
Contents
Pay-as-you-go Population of an Automotive Signal Knowledge Graph. . . . . . Yulia Svetashova, Lars Heling, Stefan Schmid, and Maribel Acosta
xxi
717
Correction to: A Semantic Framework to Support AI System Accountability and Audit. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Iman Naja, Milan Markovic, Peter Edwards, and Caitlin Cottrill
C1
Author Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
737
Ontologies and Reasoning
Streaming Partitioning of RDF Graphs for Datalog Reasoning Temitope Ajileye(B) , Boris Motik , and Ian Horrocks Department of Computer Science, University of Oxford, Oxford, UK {temitope.ajileye,Boris.motik,Ian.horrocks}@cs.ox.ac.uk
Abstract. A cluster of servers is often used to reason over RDF graphs whose size exceeds the capacity of a single server. While many distributed approaches to reasoning have been proposed, the problem of data partitioning has received little attention thus far. In practice, data is usually partitioned by a variant of hashing, which is very simple, but it does not pay attention to data locality. Locality-aware partitioning approaches have been considered, but they usually process the entire dataset on a single server. In this paper, we present two new RDF partitioning strategies. Both are inspired by recent streaming graph partitioning algorithms, which partition a graph while keeping only a small subset of the graph in memory. We have evaluated our approaches empirically against hash and min-cut partitioning. Our results suggest that our approaches can significantly improve reasoning performance, but without unrealistic demands on the memory of the servers used for partitioning.
1
Introduction
The Resource Description Framework (RDF) is a popular data format, where triples represent relationships between resources. The Web Ontology Language (OWL) is layered on top of RDF to structure the data and support reasoning: a reasoner can derive fresh triples using domain knowledge. Thus, developing efficient reasoning algorithms for RDF has received considerable attention. A popular way to realise OWL reasoning is to encode the rules of inference in a prominent rule-based formalism called datalog. For example, the OWL 2 RL profile is a fragment of OWL designed to support datalog reasoning. Datalog reasoning is often implemented in practice by materialisation: all consequences of the data and the rules are precomputed in a preprocessing step so that queries can later be evaluated without any further processing of the rules. Modern RDF datasets can be very large; for example, the UniProt1 dataset contains over 34 billion triples. Complex reasoning over such large datasets is infeasible on a single server, so a common solution is to partition the data in a cluster of shared-nothing servers. Many such approaches for RDF querying have been proposed [4,10–13,16,22,23,28,30]. Reasoning is more involved since 1
https://www.uniprot.org/.
c Springer Nature Switzerland AG 2021 R. Verborgh et al. (Eds.): ESWC 2021, LNCS 12731, pp. 3–22, 2021. https://doi.org/10.1007/978-3-030-77385-4_1
4
T. Ajileye et al.
it requires interleaving queries and updates, but nevertheless several distributed RDF reasoners have been developed [9,17,24,26,27,29]. Rule application during reasoning requires distributed join processing, which can be costly if the triples to be joined are stored in different servers; moreover, derived triples need to be distributed across the cluster. Thus, data should ideally be partitioned in a locality-aware way to minimise overheads. Little attention has been paid thus far to the data partitioning problem. Systems based on Hadoop and Spark store the data in a distributed file system and thus typically cannot influence data placement. Systems that explicitly control data placement usually determine a triple’s destination by hashing some or all of the triple’s components (usually the subject). Hashing is very simple to implement and requires little resources, but it can incur significant overhead, particularly for subject–object and object–object joins. Other systems use min-cut graph partitioning [15] to obtain locality-aware partitions; however, this usually requires loading all data into a single server, which defeats the main goals of using a cluster. Streaming methods aim to produce good graph partitions without loading the entire graph into memory at any point in time (but by possibly reading the graph data several times). Such techniques have been developed primarily for general graphs, rather than RDF. Motivated by the desire to improve the performance of distributed RDF reasoners, in this paper we adapt the HDRF [21] and 2PS [19] state-of-the-art streaming graph partitioning algorithms to RDF. Unlike HDRF and 2PS, our HDRF3 and 2PS3 algorithms have to take into account certain idiosyncrasies of the RDF data model. For example, it is well known that subject–subject joins are very common in RDF queries, so colocating triples with the same subject is really important in RDF; however, honouring this requires modifications to HDRF and 2PS. By comparing our approaches empirically with hash and min-cut partitioning, we investigated how different data partitioning strategies affect reasoning times and network communication. We based our evaluation on the DMAT distributed datalog reasoner [3]. The reasoning algorithm of DMAT is unique in that it is independent of any specific data partitioning strategy: as long as a certain index is provided that informs the system of how data is distributed in the cluster, the algorithm can correctly compute the materialisation. We show empirically that partitioning the data into highly connected subsets can be very effective at reducing communication and thus reducing reasoning times; however, it can also lead to workload imbalances among servers, which can lead to increases in reasoning when the communication overhead is small. Overall, our 2PS3 method seems to be very effective: while requiring only modest resources for partitioning, it can more than halve the reasoning times compared to hash partitioning. Thus, we believe our technique provides an important building block of truly scalable distributed RDF reasoners. The proofs of our results, all datasets and rule sets used for testing, and the DMAT system are available as online supplementary material2 . 2
https://krr-nas.cs.ox.ac.uk/2021/stream-graph-partitioning/.
Streaming Partitioning of RDF Graphs
2
5
Preliminaries
We next recapitulate some common definitions. An RDF graph G is a finite set of triples of the form s, p, o, where s, p, and o are resources (i.e., IRIs, blank nodes, or literals) called subject, predicate, and object, respectively. The vocabulary of G is the set of all resources occurring in G. Given a resource r, let G+ (r) = {s, p, o ∈ G | s = r} and G(r) = {s, p, o ∈ G | s = r or o = r}. We call |G+ (r)| and |G(r)| the out-degree and the degree of r, respectively. A partition P of an RDF graph G is a list of RDF graphs P = G1 , . . . , Gn such n that Gi ∩ Gj = ∅ for 1 ≤ i < j ≤ n and G = i=1 Gi . We call graphs Gi partition elements. The replication set of a resource r is A(r) = {k | Gk ∩ G(r) = ∅}. For V the vocabulary of G, the replication factor of a partition P is defined as RF(G, P) =
1 |A(r)|. |V | r∈V
Given a fixed tolerance parameter α ≥ 1, the objective of graph partitioning is to compute a partition P of G such that |Gi | ≤ α |G| n holds for each 1 ≤ i ≤ n, while minimising the replication factor RF(G, P). Thus, each Gi should hold roughly the same number of triples, while ensuring that resources are replicated as little as possible. Solving this problem exactly is computationally hard, so the objective is usually weakened in practice. The algorithms we present in this paper will honour the restrictions on the sizes of Gi ; moreover, they will aim to make the replication factor small, but without minimality guarantees. A datalog rule is an expression of the form H ← B1 , . . . , Bn , where H and Bi are atoms of the form ts , tp , to , and ts , tp , and to are variables or resources. Atom H is called the head, and B1 , . . . , Bn are called the rule body. A substitution σ is a mapping of variable to resources, and Aσ denotes the result of replacing each variable in atom x with σ(x). A rule is applied to an RDF graph G by enumerating each substitution σ such that {B1 σ, . . . , Bn σ} ⊆ G, and then extending G with Hσ. To compute the materialisation of G for a set of datalog rules P , this process is iteratively repeated for each rule r ∈ P as long as possible—that is, until no new triples can be derived. In this work, we study how different partitioning strategies affect the performance of computing the materialisation when the RDF data is partitioned across a cluster of servers.
3
Related Work
In this section, we present an overview of the related approaches to distributed querying, distributed reasoning, and RDF data partitioning. Distributed Query Processing. To compute a join in a distributed setting, facts participating in the join must be brought to a server in the cluster. Many solutions to this key technical problem have been developed. Numerous systems (e.g., HadoopRDF [13] and S2RDF [23], to name a few) are built on top of big
6
T. Ajileye et al.
data frameworks such as Hadoop or Spark. Systems such as YARS2 [11] and Trinity.RDF [30] compute joins on a single server after retrieving data from the cluster. Systems such as H-RDF-3X [12], SHAPE [16], and SemStore [28] split a query into parts that can be evaluated without communication, and then combine the partial answers in a final join phase. Finally, systems such as AdPart [4] and TriAd [10] compute distributed joins by exchanging partial answers between servers. Recently, 22 systems were surveyed and 12 of those were compared experimentally [1], and TriAd and AdPart were identified as fastest. The dynamic data exchange [22] approach was later shown to be also very competitive. Distributed Reasoning. Matching rule bodies corresponds to query evaluation, so distributed reasoning includes distributed querying; however, it also involves distributed data updates, which introduces additional complexity. SociaLite [24] handles datalog extended with a variant of monotonic aggregation. Many distributed RDF reasoners can handle only limited datalog subsets [5]. For example, RDFS reasoning can be performed without any communication [27]. WebPIE [26] handles the OWL-Horst fragment using Hadoop, while CiChild [9] and SPOWL [17] handle the OWL-Horst and the OWL 2 RL fragments, respectively, in Spark. PLogSpark [29], also implemented in Spark, is one of the few distributed RDF reasoners that can handle arbitrary datalog rules. DMAT. Our DMAT system [3] supports distributed semina¨ıve evaluation of arbitrary datalog rules by extending the distributed query answering technique by Potter et al. [22]; the system uses RDFox [20] for triple storage, indexing, and retrieval. DMAT uses an index to locate the relevant data in the cluster, allowing it to be used with any partitioning strategy. This is different from most existing approaches, where the reasoning algorithms depend on the details of data partitioning. We use DMAT in our evaluation since it allows us to vary the partitioning strategies only and study how this affects the performance of reasoning. While the absolute reasoning times are specific to DMAT, the number of joins that span servers are the same for all implementations, so other systems should exhibit similar relative performance for different partitioning strategies. Data Partitioning. Although it is intuitive to expect that partitioning the data carefully to minimise communication should improve the performance of distributed systems, the effects of data partitioning remain largely unknown. Existing approaches to data partitioning can be broadly divided into three groups. The first groups consists of systems that use Hadoop or Spark to store their data in a distributed file system. The data is usually allocated randomly to servers, which makes exploiting data locality during querying/reasoning difficult. The second group consists of hash-based variants, where the destination for a triple is determined by hashing one or more triple’s components (usually subject). The third group consists of variants based on min-cut graph partitioning [15], which aims to minimise the number of edges between partitions and thus reduce
Streaming Partitioning of RDF Graphs
7
the cost of communication. Such approaches are sometimes combined with data replication (e.g., [10,12]), where a triple is stored on more than one server. All systems in the latter two groups colocate triples with the same subjects to eliminate communication for the most common subject–subject joins [8].
4
Motivation and Our Contribution
Distributed reasoning requires network communication for evaluating rule bodies and for distributing the derived triples, and communication is much slower than RAM access. One can thus intuitively expect that communication will critically determine the performance of reasoning, and that, to reduce communication and thus improve performance, joining triples are colocated whenever possible. Janke et al. [14] studied this problem for distributed query processing. Interestingly, they concluded that reducing communication can be detrimental if done at the expense of uneven server workload. However, it is unclear to what extent this study applies to reasoning. Reasoning over large datasets involves evaluating millions of queries and distributing derived triples, both of which can incur much more communication than for evaluating a single query. Moreover, imbalances in single queries could even out over all queries. Another question is how to effectively partition RDF data in a locality-aware way. As we mentioned in Sect. 3, subject hashing is commonly used in practice; while very efficient, it does not take the structure of an RDF graph into account and thus provides no locality guarantees for subject–object or object–object joins. Other commonly used approaches are based on min-cut partitioning. The METIS partitioner requires loading the entire graph into a single server, which is clearly problematical. This problem can be mitigated by using the parallelised version of METIS called ParMETIS; however, graph partitioning is an NP-hard problem, so such a solution is still likely to use considerable resources. Thus, how to partition RDF data effectively, and how this affects distributed reasoning, is still largely unknown. To answer the former question, we draw inspiration from recent work on streaming graph partitioning [2,6,18,19,21,25,31] methods, which process the graph edges a fixed number of times without ever storing the entire graph in memory. The memory used by these algorithms is often proportional to the number of graph vertices, which is usually at least an order of magnitude smaller than the number of edges. These approaches seem to provide a good basis for RDF partitioning, but they are typically formulated for general (directed or undirected) graphs. Several RDF-specific issues must be taken into account to obtain adequate partitions in the context of RDF. For example, colocating triples with the same subject was shown to be crucial for practical applications (cf. Sect. 3). Thus, in Sects. 5 and 6, we present two new streaming RDF partitioning techniques, which we obtain from the state-of-the-art algorithms HDRF [21] and 2PS [19]. The idea behind the former is to prefer replicating vertices of higher degree so that a smaller number of vertices has to be replicated overall, and the idea behind the latter is to assign to each server communities of highly connected vertices.
8
T. Ajileye et al.
In Sect. 7 we empirically investigate the connection between data partitioning and reasoning performance. To this end, we compare the performance of reasoning for different data partitioning strategies: our two new techniques, subject hash partitioning, and a variant of min-cut partitioning [22]. Our results suggest that data partitioning can indeed have a significant impact on reasoning performance, sometimes cutting the reasoning times to less than half.
5
The HDRF3 Algorithm
We now present our HDRF3 algorithm for streaming partitioning of RDF data. We follow the ‘high degree replicated first’ principle from the HDRF algorithm for general graphs [21]. In Sect. 5.1 we briefly discuss the original idea, and in Sect. 5.2 we discuss in detail how we adapted these principles to RDF. 5.1
High Degree Replicated First Streaming Partitioning
The HDRF algorithm [21] targets large undirected graphs whose vertex degree distribution resembles the power-law distribution. The algorithm aims to replicate (i.e., assign to more than one server) vertices with higher degrees, so that a smaller number of vertices is replicated overall. It processes sequentially the edges of the input graph and assigns them to servers. For each server k ∈ {1, . . . , n}, the algorithm maintains the number Nk of eges currently assigned to server k; all Nk are initially zero. For each vertex v, the algorithm maintains the degree deg(v) of v in the subgraph processed thus far, and the replication set A(v) for v. For each v, the degree deg(v) is initialised to zero, and A(v) is initialised to the empty set. To allocate an undirected edge {v, w}, the algorithm first increments deg(v) and deg(w), and then for each candidate server k ∈ {1, . . . , n} it computes the score C(v, w, k). The algorithm sends the edge {v, w} to the server k with the highest score C(v, w, k), and it increments Nk . The score C(v, w, k) consists of two parts. The first one estimates the impact that placing {v, w} on server k will have on replication, and it is computed as where CREP (v, w, k) = g(v, w, k) + g(w, v, k), deg(w) 1 + deg(v)+deg(w) if k ∈ A(v), g(v, w, k) = 0 otherwise. To understand the intuition behind this formula, assume that vertex v occurs only on server k, vertex w occurs only server k , and deg(v) > deg(w). Then, we have g(v, w, k) < g(w, v, k ), which ensures that edge {v, w} is sent to server k —that is, vertex v is replicated to server k , in line with our desire to replicate higher-degree vertices. The sum deg(v) + deg(w) in the denominator of the formula for g(v, w, k) is used to normalise the degrees of v and w. Considering CREP (v, w, k) only would risk producing partitions of unbalanced sizes. Therefore, the second part of the score is used to favour assigning
Streaming Partitioning of RDF Graphs
9
edge {v, w} to the currently least loaded server using formula CBAL (k) =
maxsize − Nk , + maxsize − minsize
where maxsize and minsize are the maximal and minimal possible partition sizes. Scores CREP (v, w, k) and CBAL (k) are finally combined using a fixed weighting factor λ as C(v, w, k) = CREP (v, w, k) + λ · CBAL (k) By tuning λ, we can determine how important is minimising imbalance in partition sizes as opposed to achieving low replication factors. The version of the algorithm presented above makes just one pass over the graph edges, and g(v, w, k) and g(w, v, k) are computed using the partial vertex degrees (i.e., degrees in the subset of the graph processed thus far). The authors of HDRF also discuss a variant where exact degrees are computed in a preprocessing pass. The authors also show empirically that this does not substantially alter the quality of the partitions that the algorithm produces. 5.2
Adapting the Algorithm to RDF Graphs
Several problems need to be addressed to adapt HDRF to RDF graphs. A minor issue is that RDF triples correspond to labelled directed edges, which we address by simply ignoring the predicate component of triples. A more important problem is to ensure that all triples with the same subject are colocated on a single server, which, as we already mentioned in Sect. 4, is key to ensuring good performance of distributed RDF systems. To address this, we compute the destination for all triples with subject s the first time we see such a triple. The pseudo-code of HDRF3 is shown in Algorithm 1. It takes as input a parameter α determining the maximal acceptable imbalance in partition element sizes, the balance parameter λ as in HDRF, and another parameter δ that we describe shortly. In a preprocessing pass over G (not shown in the pseudo-code), the algorithm determines the size of the graph |G|, and the out-degree |G+ (r)| and the degree |G(r)| of each resource r in G. The algorithm also maintains (i) the replication set A(r) for each resource, which is initially empty, (ii) a mapping T of resources occurring in subject position to servers, which is initially undefined on all resources, and (iii) the numbers N1 , . . . , Nn and R1 , . . . , Rn of triples and resources, respectively, assigned to servers thus far, which are initially zero. The algorithm makes a single pass over the graph and processes each triple s, p, o ∈ G using the function ProcessTriple. Mapping T keeps track of the servers that will receive triples with a particular subject resource. Thus, if T (s) is undefined (line 2), the algorithm sets T (s) to the server with the highest score (line 3) in a way analogous to HDRF. All triples with the same subject encountered later will be assigned to server T (s), so counter NT (s) is updated with the out-degree of s (line 4). Finally, the triple is sent to server T (s) (line 5),
10
T. Ajileye et al.
Algorithm 1. HDRF3 Require: tolerance parameter α > 1 the balance parameter λ the degree imbalance parameter δ the target number of servers n |G|, |G+ (r)|, and |G(r)| for each resource r in G are known A(r) := ∅ for each resource r in G Mapping T of resources to servers, initially undefined on all resources Nk := Rk := 0 for each server k ∈ {1, . . . , n} 1: 2: 3: 4:
function ProcessTriple(s, p, o) if T (s) is undefined then T (s) := arg maxk∈{1,...,n} Score(s, o, k) NT (s) := NT (s) + |G+ (s)|
6:
Add (s, p, o) to GT (s) if T (s) ∈ A(s) then Add T (s) to A(s) and increment RT (s)
7:
if T (s) ∈ A(o) then Add T (s) to A(o) and increment RT (s)
5:
8: 9: 10: 11: 12: 13:
function Score(s, o, k) CREP := 0 if k ∈ A(s) and Deg(k) ≤ min∈{1,...,n} Deg() + δ then |G(o)| CREP := CREP + 1 + |G(s)|+|G(o)| if k ∈ A(o) and Deg(k) ≤ min∈{1,...,n} Deg() + δ then |G(s)| CREP := CREP + 1 + |G(s)|+|G(o)| Nk +|G+ (s)| α|G| k Nk CREP + λ |G| CBAL
14:
CBAL := 1 − n
15:
return
16: 17:
function Deg(k) return (Rk = 0) ? 0 : Nk /Rk
and the replication sets of s and o and the number of resources RT (s) on server T (s) are updated if needed (lines 6 and 7). The score of sending triple s, p, o to server k is calculated as in HDRF. The replication part CREP of the score is computed in lines 11 and 13. Unlike the original HDRF algorithm, we assign all triples with subject s to a server the first time we encounter resource s, so having complete degree is important to take into account the impact of further triples with the same subject. Moreover, we observed empirically that it is beneficial for the performance of reasoning to have partition elements with roughly similar average resource degrees. Function Deg estimates the current average degree of resources in server k as a quotient of the currently numbers of triples (Nk ) and resources (Rk ) assigned to server k. Then, in lines 11 and 13, CREP is updated only if the average degree of server k is close (i.e., within δ) to the minimal average degree.
Streaming Partitioning of RDF Graphs
11
The balance factor is computed in line 14, and it is obtained by taking into account that the maximum size of a partition element is α|G|/n. using λ in line 15. However, unlike Finally, CREP and CBAL are combined k Nk the original HDRF algorithm, factor |G| ensures that partition balance grows in importance towards the end of partitioning. As we mentioned in Sect. 2, producing a balanced partition while minimising the replication factor is computationally hard, so the minimality requirement is typically dropped. The following result shows that Algorithm 1 honours the balance requirements, provided that α and λ are chosen in a particular way. Proposition 1. Algorithm 1 produces a partition that satisfies |Gi | ≤ α |G| n for each 1 ≤ i ≤ n whenever α and λ are selected such that α>1+n
6
maxr |G+ (r)| |G|
and
λ≥
n
4α α−1 n
−
maxr |G+ (r)| |G|
2 .
The 2PS3 Algorithm
We now present our 2PS3 algorithm for RDF, which adapts the two-phase streaming algorithm 2PS [19]. In Sect. 6.1 we discuss the original idea, and in Sect. 6.2 we discuss in detail how to apply these principles to RDF. 6.1
Two-Phase Streaming
The 2PS algorithm processes undirected graphs in two phases. In the first phase, the algorithm clusters resources into communities with the goal of placing highly connected resources into a single community. This is achieved by initially assigning each resource in the graph to a separate community. Then, when processing an edge {v, w} in the first phase, the current sizes of the current communities of v and w are compared, and the resource belonging to the smaller community is merged into the larger community. Thus, communities are iteratively coarsened as edges of the input graph are processed in the first phase. The entire first phase can be repeated several times to improve community detection. After all edges are processed in the first phase, the identified communities are greedily assigned to servers. Then, the graph is processed in the second phase, and edges are assigned to the communities of their vertices. 6.2
The Algorithm
Just like in the case of HDRF, the main challenge in extending 2PS to RDF is to deal with the directed nature of RDF triples, and to ensure that triples with the same subject are assigned to the same server. The pseudo-code of 2PS3 is shown in Algorithm 2. As in HDRF3 , the algorithm uses a preprocessing phase to determine the size of graph |G| and the
12
T. Ajileye et al.
Algorithm 2. 2PS3 Require: tolerance parameter α > 1 the target number of servers n |G| and |G+ (r)| for each resource r in G are known C(r) := cr and S(cr ) := |G+ (r)| for each resource r in G, where cr is a community unique for r 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30:
function ProcessTriple-Phase-I(s, p, o) Let rmax := arg maxr∈{s,o} S(C(r)), and let rmin be the other vertex if S(C(rmax )) + |G+ (rmin )| < (α − 1) |G| then n S(C(rmax )) := S(C(rmax )) + |G+ (rmin )| S(C(rmin )) := S(C(rmin )) − |G+ (rmin )| C(rmin ) := C(rmax )
function AssignCommunities Nk := 0 for each server k ∈ {1, . . . , n} for each community c occurring in the image of the mapping C do T (c) := arg mink∈{1,...,n} |Nk | NT (c) := NT (c) + S(c) function ProcessTriple-Phase-II(s, p, o) Add (s, p, o) to T (C(s))
out-degree |G+ (r)| of each resource. Thus, 2PS3 uses three phases; however, to stress the relationship with the 2PS algorithm, we call the algorithm 2PS3 . The algorithm maintains a global mapping C of resources to communities— that is, C(r) is the community of each resource r. Thus, two resources r1 and r2 are in the same community if C(r1 ) = C(r2 ). Initially, each resource r is placed into its own community cr . As the algorithm progresses, the image of C will contain fewer and fewer communities. Once communities are assigned to servers, a triple s, p, o will be assigned to the server of community C(s), thus ensuring that all triples with the same subject are colocated. The algorithm also maintains a global function that maps each community c to its size S(c). Please note that S(c) does not hold the number of resources currently assigned to community c; rather, S(c) provides us with the number of triples whose subject is assigned to community c. Because of that, S(cr ) is initially set to |G+ (r)| for each resource r, rather than to 1. After initialisation, the algorithm processes each triple s, p, o ∈ G using function ProcessTriple-Phase-I. In line 19, the algorithm compares the sizes S(C(s)) and S(C(o)) of the communities to which s and o, respectively, are currently assigned. It identifies rmax as the resource whose current community size is larger, and rmin as the resource whose current community size is smaller (ties are broken arbitrarily). The aim of this is to move rmin into the community of rmax , but this is done only if, after the move, we can satisfy the requirement on the sizes of partition elements: if each community contains no more than (α − 1) |G| n triples, we can later assign communities to servers greedily and the
Streaming Partitioning of RDF Graphs
13
resulting partition elements will contain fewer than α |G| n triples. This is reflected in the condition in line 19: if satisfied, the algorithm updates the sizes of the communities of rmax and rmin (lines 21–22), and it moves rmin into the community of rmax (line 23). If desired, G can be processed repeatedly several times using function ProcessTriple-Phase-I to improve the communities. Once all triples of G are processed, function AssignCommunities assigns communities to servers. To this end, for each server k, the algorithm maintains the number Nk of triples currently assigned to partition element k. Then, the communities from the image of C (i.e., the communities that have ‘survived’ after shuffling the resources in the first phase) are assigned by greedily preferring the least loaded server. Finally, using function ProcessTriple-Phase-II, each triple s, p, o ∈ G is assigned to the server of community C(s). As in HDRF3 , our algorithm is not guaranteed to minimise the replication factor. However, the following result shows that the algorithm will honor the restriction on the sizes of partition elements for a suitable choice of α. Proposition 2. Algorithm 2 produces a partition that satisfies |Gi | ≤ α |G| n for each 1 ≤ i ≤ n whenever α is selected such that α>1+
7
maxr |G+ (r)| . |G|
Evaluation
To see how partitioning affects distributed reasoning, we computed the materialisation for three large datasets, which we partitioned using subject hash partitioning (Hash), a variant of min-cut partitioning [22] (METIS), and our HDRF3 and 2PS3 algorithms. We introduce our datasets in Sect. 7.1; we present the test protocol in Sect. 7.2; and we discuss our results in Sect. 7.3. 7.1
Datasets
Apart from the well-known LUBM3 benchmark, we are unaware of publicly available large RDF datasets that come equipped with complex datalog programs. Thus, we manually created programs for two well-known large datasets. All programs and datasets are available from the Web page from the introduction, and some statistical information about the datasets is shown in Table 1. LUBM-8K. We used the LUBM dataset for 8,000 universities, containing 1.10 billion triples. Moreover, we used the extended lower bound datalog program by Motik et al. [20]. The program was constructed to stress-test reasoning systems, and it was obtained by translating the OWL 2 RL portion of the LUBM ontology into datalog and manually adding several hard recursive rules that produce many redundant derivations. To the best of our knowledge, this program has not yet been used in the literature to test distributed RDF reasoners. 3
http://swat.cse.lehigh.edu/projects/lubm/.
14
T. Ajileye et al.
WatDiv-1B. The WatDiv4 benchmark was developed as a test for SPARQL querying. We used the 1.09 billion triples provided by the creators of WatDiv. Since WatDiv does not include an ontology or datalog program, we manually produced a program consisting of 32 chain, cyclical, and recursive rules. MAKG∗ . The Microsoft Academic Knowledge Graph (MAKG) [7] is an RDF translation of the Microsoft Academic Graph—a heterogeneous dataset of scientific publication records, citations, authors, institutions, journals, conferences, and fields of study. The original MAKG dataset contains 8 billion triples and includes links to datasets in the Linked Open Data Cloud. To obtain a more manageable dataset, we selected a subset, which we call MAKG∗ , of 3.67 billion core triples. Since MAKG does not have an ontology, we manually created a datalog program consisting of 15 chain, cyclical, and recursive rules. Table 1. Datasets & programs Dataset
Dataset stats
Program stats
λ
Mat. stats
Triples (G) Res. (M) Deg. Rules Recr. Avg. body Triples (G) Der. (G) LUBM-8K 1.10
260
WatDiv-1B 1.09
100
4.21 103 11.29
32
3
1.20
2.66
63.45
819
2
2.10
1.77
2.09
800
MAKG∗
3.67 490 7.48 15 2 2.20 5.63 17.47 800 Legend: res. = #resources; deg. = triples/res.; recr. = #recursive rules; avg. body = average #body atoms; der. = #derivations; λ = a HDRF3 parameter
7.2
Test Protocol
As mentioned in Sect. 3, our DMAT system can be used with an arbitrary data partitioning strategy, so it provides us with an ideal testbed for our experiments. We ran our experiments on the Amazon EC2 cloud, with servers connected by 10 Gbps Ethernet. To compute the materialisation, we used ten servers of the r5 family, each equipped with a 2.3 GHz Intel Broadwell processor and 128 GB of RAM; the latter was needed since DMAT stores all data in RAM. We used an additional, smaller coordinator server to store the dictionary (i.e., mapping of resources to integers) and distribute the datalog program and the graphs to the cluster; this server did not participate in reasoning. Finally, we used another server with 784 GB of RAM to partition the data using METIS. To speed up loading times, we preprocessed all datasets by replacing all resources with integers. The coordinator distributed the triples to the workers for Hash, HDRF3 , and 2PS3 ; for METIS, we loaded the precomputed partitions directly into the workers. To hash the triples’ subjects, we simply multiplied the integer subject value by a large prime in order to randomise the distribution of the subjects. In our algorithms, we used α = 1.25. With HDRF3 , we used 4
https://dsg.uwaterloo.ca/watdiv/.
Streaming Partitioning of RDF Graphs
15
δ = 0.25 and we set λ to the lowest value satisfying Proposition 1; the values of λ thus vary for each dataset and are shown in Table 1. Finally, with 2PS3 , we processed the graphs twice in the first phase. After loading the dataset and the program into all servers, we computed the materialisation while recording the wall-clock time and the total number of messages sent between the servers. 7.3
Test Results and Discussion
For each of the four partitioning strategies, Table 2 shows the minimum, maximum, and median numbers of triples in partition elements, given as percentages of the overall numbers of triples. The table also shows the replication factor (see Sect. 2 for a definition) and the time needed to compute the partitions. Finally, the table shows the reasoning times and the numbers of messages. Partition Times and Balance. All partitioning schemes produced partition elements with sizes within the tolerance parameters: Hash achieves perfect balance if the hash function is uniform; METIS explicitly aims to equalise partition sizes; and our two algorithms do so by design and the choice of parameters. For all streaming methods, the partitioning times were not much higher than the time required to read the datasets from disk and send triples to their designated servers. In contrast, METIS partitioning took longer than materialisation on LUBM-8K and WatDiv-1B, and on MAKG∗ it ran out of memory even though we used a very large server equipped with 784 GB of RAM. Replication, Communication, and Reasoning Times. Generally lowest replication factors were achieved with 2PS3 : only METIS achieved a lower value on WatDiv-1B, and HDRF3 achieved a comparable value on MAKG∗ . The replication factor of Hash was highest in all cases, closely followed by HDRF3 . Moreover, lower replication factors seem to corelate closely with decreased communication overhead; for example, the number of messages was significantly smaller on LUBM-8K and MAKG∗ with 2PS3 than with other schemes. This reduction seems to generally lead to a decrease in reasoning times: 2PS3 was the fastest than the other schemes on LUBM-8K and MAKG∗ ; for the former, the improvement over Hash is by a factor of 2.25. However, the reasoning times do not always corelate with the replication factor: on WatDiv-1B, METIS and 2PS3 were slower than Hash and HDRF3 , despite exhibiting smaller replication factors. Workload Balance. To investigate further, we show in Fig. 1 the numbers of derivations and the total size of partial messages processed by each of the ten servers in the cluster. As one can see, partitioning the data into strongly connected clusters can introduce a workload imbalance: the numbers of derivations and messages per server are quite uniform for Hash and, to an extent, for HDRF3 ; in contrast, with 2PS3 and METIS, certain servers seem to be doing much more work than others, particularly on WatDiv-1B and MAKG∗ . Thus,
16
T. Ajileye et al.
reducing communication seems to be important, but only to a point. For example, 2PS3 reduces communication drastically on LUBM-8K, and this seems to ‘pay off’ in terms of reasoning times. On MAKG∗ , the reduction in communication seems to lead to modest improvements in reasoning times, despite a more pronounced workload imbalance. On WatDiv-1B, however, communication overhead does not appear to be significant with any partitioning strategy, so the workload imbalance is the main determining factor of the reasoning times. Overall Performance. In general, 2PS3 seems to provide a good performance mix: unlike METIS, it can be implemented without placing unrealistic requirements on the servers used for partitioning; it can significantly reduce communication; and, while this can increase reasoning times due to workload imbalances, such increases do not appear to be excessive. Thus, 2PS3 is a good alternative to hash partitioning, which has been the dominant technique used thus far. Table 2. Partition & reasoning Method Partitioning stats [n=10] Min (%) Max (%) Med (%) RF
Reasoning stats Time (s) Time (s) Messages (G)
LUBM-8K[1.10G triples] Hash
10.00
10.00
10.00
METIS
9.24
10.66
9.98
HDRF3
9.35
10.47
10.00
2PS3
9.06
10.35
10.00
1.60
530
17,400
71.67
1.19 15,300
12,580
15.44
1.43
590
15,740
46.05
1.08
700
7, 740
9.22
WatDiv-1B[1.09G triples] Hash
10.00
10.00
10.00
2.48
520
1,870
8.95
9.70
10.35
10.00
2.16 15,100
2,690
4.54
HDRF3 10.00
10.00
10.00
2.48
590
1, 850
8.95
2PS3
10.02
10.00
2.40
1,080
2,520
8.81
10.00
1.99
2, 220
8,000
29.24
METIS
9.92
MAKG∗ [3.66G triples] Hash
10.00
10.00
METIS Partitioning exhausted 784 GB of memory HDRF3 10.00
10.00
10.00
1.66
3,500
7,160
26.15
2PS3
10.06
10.00
1.67
3,640
6, 870
24.70
9.91
Streaming Partitioning of RDF Graphs
17
LUBM-8K Derivations (G)
LUBM-8K Partial Messages (GB) 80 10
60 40
5
20 0
1
2
3
4
5
6
7
8
0
9 10
1
2
WatDiv-1B Partial Messages (GB) 20
2
15
1.5
10
1
5
0.5
0
1
2
3
4
5
6
7
8
3
4
5
6
7
8
9 10
WatDiv-1B Derivations (G) Hash METIS HDRF3 2PS3
0
9 10
1
2
MAKG∗ Partial Messages (GB)
3
4
5
6
7
8
9 10
MAKG∗ Derivations (G) 6
40 30
4
20 2
10 0
1
2
3
4
5
6
7
8
9 10
0
1
2
3
Server
4
5
6
7
8
9 10
Server
Fig. 1. Reasoning by servers
8
Conclusion and Future Work
We have presented two novel algorithms for streaming partitioning of RDF data in distributed RDF systems. We have compared our methods against hashing and min-cut partitioning, which have been the dominant partitioning methods thus far. Our methods are much less resource-intensive than min-cut partitioning, and they are not significantly more complex than hashing. Particularly the 2PS3 method often exhibits better reasoning performance, thus contributing to the scalability of distributed RDF systems. In our future work, we will aim to further improve the performance of reasoning by developing ways to reduce imbalances in the workload among servers. One possibility to achieve this might be to analyse the datalog program before partitioning and thus identify workload hotspots. Acknowledgments. This work was supported by the SIRIUS Centre for Scalable Access in the Oil and Gas Domain, and the EPSRC project AnaLOG.
18
A
T. Ajileye et al.
Proofs for Sect. 5
To prove Proposition 1, we will need to reason about the state of the counters Nk from the HDRF3 algorithm. Thus, in the rest of this appendix, we use Nki to refer to the value of Nk from Algorithm 1 after processing the i-th triple of G. Lemma 1. For α > 1 and λ > 0, each run of Algorithm 1 on a graph G satisfies the following property after processing the i-th triple of G: 4α i i max Nk − min Nk < Mλ , where Mλ = |G| + max |G+ (r)|. (1) r k k nλ Proof. We prove the claim by induction on the index i of the triple being processed. For the induction base, the claim is clearly true for i = 0. For the induction step, assume that property (1) holds after the i-th triple has been process, and consider processing triple si+1 , pi+1 , oi+1 . If T (si+1 ) is defined, then Nki+1 = Nki for each server k, so (1) clearly holds. Otherwise, let k1 and k2 be the and Nki+1 are minimal and maximal, respectively, among servers such that Nki+1 1 2 i+1 i all Nk at step i + 1. If Nk2 is also maximal among all Nki at step 1 and triple si+1 , pi+1 , oi+1 is sent to a server different from k2 , then property (1) clearly holds at step i + 1. Thus, the only remaining case is when the triple is sent to server k2 . The scores for k1 and k2 are of the following form, for j ∈ {1, 2}: Ni Scorej = (CREP )j + λ k k (CBAL )j |G| For convenience, let k Nki = S. We can bound Score1 as follows: Score1 = (CREP )1 + λ
S (CBAL )1 |G|
S (CBAL )1 |G|
Nki 1 + |G+ (si+1 )| λS 1−n = |G| α|G| ≥λ
Moreover, we can bound Score2 as follows, where we use the fact that the definition of (CREP )2 clearly ensures (CREP )2 < 4: λS (CBAL )2 Score2 = (CREP )2 + |G|
Nki 2 + |G+ (si+1 )| λS 1−n 1 and λ be as stated in the proposition. Note that the condition on α ensures α − 1 maxr |G+ (r)| − > 0. n |G|
20
T. Ajileye et al.
We now show that Mλ ≤ (α − 1) |G| n holds. Towards this goal, we make the following observations: λ≥
4α ≤ λn
n
4α α−1 n
−
maxr |G+ (r)| |G|
2
α − 1 maxr |G+ (r)| − n |G|
2
α − 1 maxr |G+ (r)| 4α ≤ − λn n |G|
α−1 4α ≤ |G| − max |G+ (r)| r λn n 4α |G| + max |G+ (r)| ≤ (α − 1) |G| r λn n |G|
Now P = G1 , . . . , Gn be the partition produced by Algorithm 1. Clearly, we have mink |Gk | ≤ |G| n . Now consider an arbitrary server k. Property (1) of Lemma 1 ensures |Gk | ≤ |G|/n + Mλ . Moreover, the condition on Mλ proved above ensures |Gk | ≤
|G| |G| |G| + (α − 1) =α . n n n
This holds for every server k, which implies our claim.
B
Proofs for Sect. 6
Proposition 2. Algorithm 2 produces a partition that satisfies |Gi | ≤ α |G| n for each 1 ≤ i ≤ n whenever α is selected such that α>1+
maxr |G+ (r)| . |G|
Proof. For each community c, the following property holds at each point during algorithm’s execution: S(c) = |G+ (r)| (2) r with C(r)=c
To see this, note that S is initialised by setting S(cr ) = |G+ (r)| for each resource r. Moreover, lines 21 and 22 clearly ensure that the property is preserved when mapping C is updated in line 23. We prove by induction that function AssignCommunities ensures the following inequality: max Nk − min Nk ≤ (α − 1) k
k
|G| . n
(3)
Streaming Partitioning of RDF Graphs
21
For the induction base, all Nk are initialised to zero, so (3) holds after line 25. For the induction step, assume that (3) holds before line 28 is evaluated for some community c. Let k1 = arg mink Nk and k2 = arg maxk Nk , and let Nk be the updated values of Nk after line 28; we clearly have Nk = Nk for all k = k1 , Nk 1 = Nk1 + S(c), and mink Nk ≥ mink Nk . We have two possibilities. – Nk 1 ≤ Nk2 . Then, maxk Nk = Nk2 and so the following condition holds, where the induction assumption ensures the second inequality: max Nk − min Nk ≤ max Nk − min Nk ≤ (α − 1) k
k
k
k
|G| . n
– Nk 1 > Nk2 . Then, maxk Nk = Nk1 + S(c). Moreover, the requirement on the choice of α in our claim and the condition in line 20 of the algorithm ensure holds for each community c at any point in time during that S(c) ≤ (α−1)|G| n an algorithm’s run. This, in turn, ensures the following property: max Nk − min Nk = S(c) ≤ (α − 1) k
k
|G| . n
Thus, (3) holds. In addition, at the end of function AssignCommunities, we have mink Nk ≤ |G| k Nk = |G|. This, in turn, ensures n because max Nk ≤ min Nk + (α − 1) k
k
|G| |G| ≤α . n n
In the second phase, each triple s, p, o is assigned to T (C(s)). But then, (2) clearly ensures |Gk | = Nk for each k, which implies our claim.
References 1. Abdelaziz, I., Harbi, R., Khayyat, Z., Kalnis, P.: A survey and experimental comparison of distributed SPARQL engines for very large RDF data. PVLDB 10(13), 2049–2060 (2017) 2. Agathangelos, G., Troullinou, G., Kondylakis, H., Stefanidis, K., Plexousakis, D.: Incremental data partitioning of RDF data in SPARK. In: ESWC, pp. 50–54 (2018) 3. Ajileye, T., Motik, B., Horrocks, I.: Datalog materialisation in distributed RDF stores with dynamic data exchange. In: ISWC, pp. 21–37 (2019) 4. Harbi, R., Abdelaziz, I., Kalnis, P., Mamoulis, N., Ebrahim, Y., Sahli, M.: Accelerating SPARQL queries by exploiting hash-based locality and adaptive partitioning. VLDB J. 25(3), 355–380 (2016). https://doi.org/10.1007/s00778-016-0420-y 5. Antoniou, G., et al.: A survey of large-scale reasoning on the web of data. Knowl. Eng. Rev. 33, e21 (2018) 6. Echbarthi, G., Kheddouci, H.: Streaming METIS partitioning. In: ASONAM, pp. 17–24 (2016) 7. F¨ arber, M.: The microsoft academic knowledge graph: a linked data source with 8 billion triples of scholarly data. In: ISWC, pp. 113–129 (2019) 8. Gallego, M.A., Fern´ andez, J.D., Mart`ınez-Prieto, M.A., de la Fuente, P.: An Empirical Study of Real-World SPARQL Queries. CoRR abs/1103.5043 (2011)
22
T. Ajileye et al.
9. Gu, R., Wang, S., Wang, F., Yuan, C., Huang, Y.: Cichlid: efficient large scale RDFS/OWL reasoning with spark. In: IPDPS, pp. 700–709 (2015) 10. Gurajada, S., Seufert, S., Miliaraki, I., Theobald, M.: TriAD: a distributed sharednothing RDF engine based on asynchronous message passing. In: SIGMOD, pp. 289–300 (2014) 11. Harth, A., Umbrich, J., Hogan, A., Decker, S.: YARS2: a federated repository for querying graph structured data from the web. In: ISWC, pp. 211–224 (2007) 12. Huang, J., Abadi, D.J., Ren, K.: Scalable SPARQL querying of large RDF graphs. PVLDB 4(11), 1123–1134 (2011) 13. Husain, M.F., McGlothlin, J.P., Masud, M.M., Khan, L.R., Thuraisingham, B.M.: Heuristics-based query processing for large RDF graphs using cloud computing. IEEE TKDE 23(9), 1312–1327 (2011) 14. Janke, D., Staab, S., Thimm, M.: On data placement strategies in distributed RDF stores. In: SBD, pp. 1:1–1:6 (2017) 15. Karypis, G., Kumar, V., Comput, S.: A fast and high quality multilevel scheme for partitioning irregular graphs. SIAM J. Sci. Comput. 20, 359–392 (1998) 16. Lee, K., Liu, L.: Scaling queries over big RDF graphs with semantic hash partitioning. PVLDB 6(14), 1894–1905 (2013) 17. Liu, Y., McBrien, P.: Spowl: spark-based owl 2 reasoning materialisation. In: BeyondMR 2017 (2017) 18. Mayer, C., et al.: ADWISE: adaptive window-based streaming edge partitioning for high-speed graph processing. In: ICDCS, pp. 685–695 (2018) 19. Mayer, R., Orujzade, K., Jacobsen, H.: 2ps: High-quality edge partitioning with two-phase streaming. CoRR abs/2001.07086 (2020) 20. Motik, B., Nenov, Y., Piro, R., Horrocks, I., Olteanu, D.: Parallel materialisation of datalog programs in centralised, main-memory RDF systems. In: AAAI, pp. 129–137 (2014) 21. Petroni, F., Querzoni, L., Daudjee, K., Kamali, S., Iacoboni, G.: HDRF: streambased partitioning for power-law graphs. In: CIKM, pp. 243–252 (2015) 22. Potter, A., Motik, B., Nenov, Y., Horrocks, I.: Dynamic data exchange in distributed RDF stores. IEEE TKDE 30(12), 2312–2325 (2018) 23. Sch¨ atzle, A., Przyjaciel-Zablocki, M., Skilevic, S., Lausen, G.: S2RDF: RDF querying with SPARQL on spark. PVLDB 9(10), 804–815 (2016) 24. Seo, J., Park, J., Shin, J., Lam, M.: Distributed socialite: a datalog-based language for large-scale graph analysis. PVLDB 6, 1906–1917 (2013) 25. Stanton, I., Kliot, G.: Streaming graph partitioning for large distributed graphs. In: KDD, pp. 1222–1230 (2012) 26. Urbani, J., Kotoulas, S., Maassen, J., van Harmelen, F., Bal, H.: WebPIE: a webscale parallel inference engine using MapReduce. JWS 10, 59–75 (2012) 27. Weaver, J., Hendler, J.A.: Parallel materialization of the finite RDFS closure for hundreds of millions of triples. In: ISWC, pp. 682–697 (2009) 28. Wu, B., Zhou, Y., Yuan, P., Jin, H., Liu, L.: SemStore: a semantic-preserving distributed RDF triple store. In: CIKM. pp. 509–518 (2014) 29. Wu, H., Liu, J., Wang, T., Ye, D., Wei, J., Zhong, H.: Parallel materialization of datalog programs with spark for scalable reasoning. In: WISE, pp. 363–379 (2016) 30. Zeng, K., Yang, J., Wang, H., Shao, B., Wang, Z.: A distributed graph engine for web scale RDF data. PVLDB 6(4), 265–276 (2013) 31. Zhang, W., Chen, Y., Dai, D.: AKIN: a streaming graph partitioning algorithm for distributed graph storage systems. In: CCGRID, pp. 183–192 (2018)
Parallelised ABox Reasoning and Query Answering with Expressive Description Logics Andreas Steigmiller(B) and Birte Glimm Ulm University, Ulm, Germany {andreassteigmiller,birteglimm}@uni-ulm.de Abstract. Automated reasoning support is an important aspect of logic-based knowledge representation. The development of specialised procedures and sophisticated optimisation techniques significantly improved the performance even for complex reasoning tasks such as conjunctive query answering. Reasoning and query answering over knowledge bases with a large number of facts and expressive schemata remains, however, challenging. We propose a novel approach where the reasoning over assertional knowledge is split into small, similarly sized work packages to enable a parallelised processing with tableau algorithms, which are dominantly used for reasoning with more expressive Description Logics. To retain completeness in the presence of expressive schemata, we propose a specifically designed cache that allows for controlling and synchronising the interaction between the constructed partial models. We further report on encouraging performance improvements for the implementation of the techniques in the tableau-based reasoning system Konclude.
1 Introduction Description Logics (DLs) are a family of logic-based representation formalisms that provide the logical underpinning of the well-known Web Ontology Language (OWL). The knowledge expressed with DLs is typically separated into terminological (aka TBox or schema) and assertional knowledge (aka ABox or facts), where the former describes the relationships between concepts (representing sets of individuals with common characteristics) as well as roles (specifying the relationships between pairs of individuals) and the latter asserts these concepts and roles to concrete individuals of the application domain. Automated reasoning systems derive implicit consequences of the explicitly stated information, which, for example, allows for detecting modelling errors and for enriching queries by additional answers that are implied by the knowledge. Expressive DLs, such as SROIQ [11], allow for describing the application domain in more detail, but require sophisticated reasoning algorithms and are typically more costly in terms of computational resources. Nevertheless state-of-the-art reasoning systems are usually able to handle real-world ontologies, which often also use expressive language features, due to a large range of developed optimisation techniques. The increasing volume of data in many application domains leads, however, also to larger amounts of assertional knowledge. For less expressive schemata (where A. Steigmiller—Funded by the German Research Foundation (Deutsche Forschungsgemeinschaft, DFG) in project number 330492673. c Springer Nature Switzerland AG 2021 R. Verborgh et al. (Eds.): ESWC 2021, LNCS 12731, pp. 23–39, 2021. https://doi.org/10.1007/978-3-030-77385-4_2
24
A. Steigmiller and B. Glimm
reasoning is usually deterministic), the interest in ontology-based data access (OBDA) led to several advancements, e.g., query rewriting, materialization techniques, or combined approaches. To cope with the reasoning challenges in the presence of an expressive schema several techniques have been developed, which often complement each other. There are, for example, summarisation [3, 6] and abstraction techniques [8], which derive consequences for representative individuals and transfer the results to many other individuals with the same or a similar (syntactical) structure. These techniques do not necessarily work well for all ontologies, may be limited to certain queries or (fragments of) DLs, or require expensive computations, e.g., justifications. Several techniques also reduce reasoning to datalog [1, 5, 21] since datalog engines are targeted towards data intensive applications. This reduction, however, often leads to some additional overhead and, in some cases, it can be necessary to fall back to a fully-fledged DL reasoner, e.g., for handling non-deterministic features. Other approaches partition the ABox or extract modules out of it [20] such that each part can be processed independently [19]. Moreover, approaches based on big data principles such as map and reduce have been proposed [18]. However, they are typically also limited to specific language features and/or queries and do not work for arbitrary ontologies. Particularly challenging is the support of conjunctive queries with complex concept atoms or with existential variables that may bind to anonymous individuals, which are only implied by the knowledge base, since these features typically make it difficult to appropriately split the ABox upfront in such a way that queries can correctly be answered without too much data exchange. Many state-of-the-art reasoners directly integrate techniques that improve ABox reasoning, e.g., (pseudo) model checking [10] or bulk processing with binary retrieval [9]. Most reasoners for expressive DLs are based on (variants of) tableau algorithms, which construct abstractions of models called completion graphs. By caching (parts of) the completion graph from the initial consistency check, subsequent reasoning tasks and queries can be answered more efficiently [12, 16]. However, constructing and caching entire completion graphs for knowledge bases with large ABoxes requires significant amounts of (main) memory, which may be more than what is typically available. In this paper, we propose to dynamically split the model construction process for tableau algorithms. This allows for (i) handling larger ABoxes since not everything has to be handled at once and for (ii) exploiting parallelisation. The proposed splits lead to similarly sized work packages that can be processed concurrently without direct synchronisation. To ensure that the partial models constructed in parallel are “compatible” with each other, we employ a cache where selected consequences for individuals are stored. For processing new or reprocessing incompatible parts of the knowledge base, we retrieve cached consequences and ensure with appropriate reuse and expansion strategies that the constructed partial models are eventually compatible with the cache, such that it can (asynchronously) be updated. Conjunctive query answering is supported by adapting the expansion criteria and by appropriately splitting the propagation work through the (partial) models for determining query answers. The paper is organised as follows: Sect. 2 introduces some preliminaries about DLs and tableau algorithms; Sect. 3 describes the cache; Sect. 4 discusses the adaptations for query answering and Sect. 5 presents implementation details and results of experiments before we conclude in Sect. 6. An accompanying technical report [14] provides further details, examples, proofs, and evaluation results.
Parallelised ABox Reasoning and Query Answering
25
Table 1. Core features of SROIQ (#M denotes the cardinality of the set M) Syntax
Semantics
Individuals: Individual
a
aI ∈ ΔI
Roles:
Atomic role
r
r I ⊆ ΔI × ΔI
Inverse role
r−
{γ, δ | δ, γ ∈ rI }
Atomic concept
A
AI ⊆ ΔI
Nominal
{a}
{aI }
Top
ΔI
Bottom
⊥
∅
Negation
¬C
ΔI \ C I
Conjunction
C D
C I ∩ DI
Disjunction
C D
C I ∪ DI
Existential restriction
∃r.C
{δ | ∃γ ∈ C I : δ, γ ∈ rI }
Universal restriction
∀r.C
{δ | δ, γ ∈ rI → γ ∈ C I }
Concepts:
Number restriction, ∈ { , } n r.C Axioms:
{δ | #{δ, γ ∈ rI and γ ∈ C I } n}
General concept inclusion
CD
C I ⊆ DI
Role inclusion
rs
rI ⊆ sI
Role chains
r1 ◦ . . . ◦ rn S r1I ◦ . . . ◦ rnI ⊆ S I C(a)
aI ∈ C I
Role assertion
r(a, b)
aI , bI ∈ rI
Equality assertion
a≈b
aI = bI
Assertions: Concept assertion
2 Description Logics and Reasoning Preliminaries The syntax of DLs is defined using a vocabulary consisting of countably infinite pairwise disjoint sets NC of atomic concepts, NR of atomic roles, and NI of individuals. A role is either atomic or an inverse role r− , r ∈ NR . The syntax and semantics of complex concepts and axioms are defined in Table 1. Note that we omit the presentation of some features (e.g., datatypes) and restrictions (e.g., number restrictions may not use “complex roles”, i.e., roles that occur on the right-hand side of role chains or are implied by such roles) for brevity. A knowledge base/ontology K is a finite set of axioms. One typically distinguishes terminological axioms in the TBox T (e.g., C D) and assertions in the ABox A (e.g., C(a)) of K, i.e., K = (T , A). We use inds(K) to refer to the individuals of K. An interpretation I = (ΔI , ·I ) consists of a non-empty domain ΔI and an interpretation function ·I . We say that I satisfies a general concept inclusion (GCI) C D, written I |= C D, if C I ⊆ DI (analogously for other axioms and assertions as shown in Table 1). If I satisfies all axioms of K, I is a model of K and K is consistent/satisfiable if it has a model. A tableau algorithm decides the consistency of a knowledge base K by trying to construct an abstraction of a model for K, a so-called completion graph. A completion ˙ where each node v ∈ V (edge v, w ∈ E) represents graph G is a tuple (V, E, L, ), one or more (pairs of) individuals. Each node v (edge v, w) is labelled with a set of concepts (roles), L(v) (L(v, w)), which the individuals represented by v (v, w) are
26
A. Steigmiller and B. Glimm
instances of. The relation ˙ records inequalities between nodes. We call C ∈ L(v) (r ∈ L(v, w)) a concept (role) fact, which we write as C(v) (r(v, w)). A node v is a nominal node if {a} ∈ L(v) for some individual a and a blockable node otherwise. For r ∈ L(v, w) and r ∗ s, with ∗ the reflexive, transitive closure over role inclusions of K (including their inverses), we call w an s-successor of v and v an s-predecessor of w. A node w is called an s-neighbour of v if w is an s-successor of v or v an s− -successor of w. We use ancestor and descendant as the transitive closure of the predecessor and successor relation, respectively. We say that vn is an implied descendant of v0 if there is a path v0 , v1 , . . . , vn such that vi+1 is a successor of vi for 0 ≤ i < n and each v j with j > 0 does not represent an individual of inds(K). A completion graph is initialised with one node for each individual in the input knowledge base. Concepts and roles are added to the node and edge labels as specified by concept and role assertions. For simplicity, we assume that, for each individual a ∈ inds(K), a nominal {a} is added to L(va ). This allows for easily handling equality assertions by adding {b} to L(va ) for a ≈ b ∈ A. As a convention, we write va to refer to the node representing a ∈ inds(K), i.e., {a} ∈ L(va ). Note that va and vb can refer to the same node if {a} and {b} are in its label. Complex concepts are then decomposed using a set of expansion rules, where each rule application can add new concepts to node labels and/or new nodes and edges, thereby explicating the structure of a model. The rules are applied until either the graph is fully expanded (no more rules are applicable), in which case the graph can be used to construct a model that is a witness to the consistency of K, or an obvious contradiction (called a clash) is discovered (e.g., a node v with C, ¬C ∈ L(v)), proving that the completion graph does not correspond to a model. K is consistent if the rules (some of which are non-deterministic) can be applied such that they build a fully expanded, clash-free completion graph. Cycle detection techniques such as pairwise blocking [11] prevent the infinite generation of new nodes.
3 Caching Individual Derivations Since tableau-based reasoning algorithms reduce (most) reasoning tasks to consistency checking, parallelising the completion graph construction has general benefits on the now ubiquitous multi-core processor systems. Partitioning the ABox upfront such that no or little interaction is required between the partitions [19] no longer works for expressive DLs, such as SROIQ, or complex reasoning tasks, such as conjunctive query answering (with complex concepts and/or existential variables). This is, for example, due to implied connections between individuals (e.g., due to nominals) or due to the consideration of new concept expressions at query time. The effect of parallelisation is further hindered by the multitude of optimisations, required to properly deal with real-world ontologies, which often introduce dependencies between rules and (parts of) completion graphs, resulting in the need of data synchronisation. For example, the anywhere blocking optimisation (cycle detection) investigates all previously constructed nodes in the completion graph in order to determine whether a node is blocked. Hence, a parallelisation approach where a completion graph is modified in parallel can be difficult to realise since it could require a lot of synchronisation. For ontologies with large ABoxes, it seems more suitable to build completion graphs for parts of the ABox separately (by independent threads) and, since independence of
Parallelised ABox Reasoning and Query Answering
27
the parts cannot be assumed, to align the results afterwards. Such an alignment can, however, be non-trivial on several levels: For example, if different non-deterministic decisions have been made for individuals in overlapping parts or due to technical details of the often complex data structures for completion graphs, e.g., efficient processing queues, caching status of node labels, etc. Our parallelisation approach focuses on aligning completion graphs for ABox parts and we address the challenges by employing a cache for certain derivations for individuals, which facilitates the alignment process. For this, consistency checking roughly proceeds as follows: We randomly split the ABox into equally sized parts that are distributed to worker threads. When a thread begins to process one of these ABox parts, it retrieves stored derivations from the cache for (possibly) affected individuals in that part. The thread then tries to construct a fully expanded and clash-free local completion graph for the ABox part by reusing cached derivations and/or by expanding the processing to individuals until they are “compatible” with the cache. Compatibility requires that the local completion graph is fully expanded as well as clash-free and that it can be expanded such that it matches the derivations for the remaining individuals in the cache. If it is required to extend the processing to some “neighbouring” individuals for achieving compatibility (e.g., if different non-deterministic decisions are required for the already processed individuals), then also the cached derivations for these individuals are retrieved and considered. If this process succeeds, the cache is updated with the new or changed derivations for the processed individuals. If compatibility cannot be obtained (e.g., due to expansion limitations that ensure similarly sized work packages), then the cache entries of incompletely handled individuals are marked such that they are considered later separately. For this, a thread loads the data for (some) marked individuals and tries to construct a fully expanded and clash-free completion graph for them until full compatibility is obtained. If clashes occur that depend on reused (non-deterministic) derivations from the cache, then the corresponding individuals can be identified such that their expansion can be prioritized and/or the reuse of their derivations can be avoided. As a result, (in)consistency of the knowledge base can eventually be detected, as soon as all problematic individuals are directly expanded and all relevant non-deterministic decisions are investigated together. Before describing the different aspects of the approach and the work-flow in more detail, we define a basic version of the cache and how derivations are stored and used. Definition 1 (Individual Derivations Cache). Let K be a knowledge base. We use fclos(K), rols(K), and inds(K) for the sets of concepts, roles, and individuals that can
occur in K or in a completion graph for K. An individual derivations cache C is a (partial) mapping of individuals from inds(K) to cache entries, where the cache entry for an individual a ∈ inds(K) consists of: • K C ⊆ 2fclos(K) and PC ⊆ 2fclos(K) : the sets of known and possibly instantiated concepts of a, respectively, • I ⊆ 2inds(K) : the individuals that are (indirectly) connected via nominals to a, • ∃ : rols(K) → IN0 : mapping a role r to the number of existentially derived successors for a and r, and • K R : rols(K) → 2inds(K) and PR : rols(K) → 2inds(K) : mapping a role r to the sets of known and possible neighbours of a and r, respectively.
28
A. Steigmiller and B. Glimm
We write K C (a, C), PC (a, C), I(a, C), ∃(a, C), K R (a, C), and PR (a, C) to refer to the individual parts of the cache entry C(a). We write a ∈ C if C is defined for a. Note that we distinguish between known and possible information in the cache, which mostly correspond to the deterministically and non-deterministically derived consequences in completion graphs. Non-deterministically derived facts in completion graphs can usually be identified via branching tags for dependency directed backtracking [2, 17]. If the cache is clear from the context, we simply write K C (a) or K R (a)(r), where the latter returns the known (deterministically derived) r-neighbours of a. Let K = (T , A) be a knowledge base and A j ⊆ A the processed ABox part. In ˙ for K = addition to the usual initialisation of a completion graph G = (V, E, L, ) (T , A j ), we add K C (a) to L(va ) and r to L(va , vb ) if b ∈ K R (a)(r), for each va , vb ∈ V. If a node v ∈ V exists with {c} ∈ L(v) or ¬{c} ∈ L(v), but vc V, then we add vc with {c} ∈ L(vc ) to V and initialise vc analogously. Once G is extended into a fully expanded and clash-free completion graph, we identify the derivations for cache entries for each individual a with va ∈ V. Since deterministically derived consequences remain valid for all possible completion graphs, we update the corresponding cache entries by adding the deterministically derived consequences, e.g., for K C , whereas non-deterministically derived consequences may change and, thus, replace existing cache entries, e.g., for PC . A completion graph for (T , A j ) is compatible with the cache if it can be extended to a fully expanded and clash-free completion graph for (T , A1 ∪ . . . ∪ A j ), where A1 ∪ . . . ∪ A j−1 are the previously processed (and cached) ABox parts. As argued above, this might require the integration and processing of individuals from the cache during the completion graph expansion. Hence, we define when individuals in the cache potentially influence or are influenced by the completion graph. Definition 2 (Cache Influence and Compatibility). Let K = (T , A) be a knowledge ˙ a completion graph for (T , A j ) with A j ⊆ A, and va ∈ V. We base, G = (V, E, L, ) use #exrolsr (va ) for the number of r-neighbours of va that do not represent an individual of inds(K) and neighbr (va ) for the r-neighbours of va that represent an individual of inds(K). For an individual derivations cache C (c.f. Definition 1), an individual b ∈ C with vb V is potentially influenced by G if D1 ∀r.C ∈ L(va ), b ∈ K R (a)(r) ∪ PR (a)(r), and C K C (b) ∪ PC (b); D2 n r.C ∈ L(va ), b ∈ K R (a)(r) ∪ PR (a)(r), and {C, ¬C} ∩ (K C (b) ∪ PC (b)) = ∅; D3 n r.C ∈ L(va ), b ∈ K R (a)(r) ∪ PR (a)(r), and #[{d | d ∈ K R (c)(r) ∪ PR (c)(r) with {c} ∈ L(va )} ∪ neighbr (va )] + #exrolsr (va ) > n; D4 b ∈ I(a) and C ∈ L(va ), C K C (a) ∪ PC (a) or n r.C ∈ L(va ) with ∃(a)(r) > 0;
or D5 {c} ∈ L(va ), {c} K C (a) ∪ PC (a), a ∈ K R (b)(r) ∪ PR (b)(r) and c K R (b)(r) ∪ PR (b)(r) or b ∈ K R (a)(s) ∪ PR (a)(s) and b K R (c)(s) ∪ PR (c)(s). An individual b ∈ C with vb V is potentially influencing the completion graph G if G1 b ∈ PR (a)(r); G3 b ∈ I(a), C ∈ PC (a), C L(va ); or R C G2 b ∈ K (a)(r), C ∈ P (a), C L(va ); G4 {a} ∈ PC (b) or ¬{a} ∈ PC (b);
We say that G is compatible with a cache C if there is no individual b that is potentially influenced by G or potentially influencing G.
Parallelised ABox Reasoning and Query Answering
29
Roughly speaking, an individual is potentially influenced by a completion graph if integrating it into the completion graph could lead to new consequences being propagated to it. In contrast, an individual potentially influences a completion graph if the integration of it could result in new consequences for the local completion graph. The conditions for determining influenced individuals have a strong correspondence with the tableau expansion rules (cf. [11]). In fact, Condition D1, D2, and D3 basically check whether the ∀-, the choose-, or the -rule could potentially be applicable, i.e., whether the handling of ∀r.C or r n.C concepts requires the consideration of neighbours from the cache. The first part of Condition D4 further checks whether some individual is indirectly connected to a via a nominal for an implied descendant for an individual b and whether new consequences could be propagated to that descendant. This could be the case if the label for a differs to the concepts for a in the cache. The second part handles potential cases where new nominals may have to be introduced and may influence b or descendants of b. Finally, Condition D5 ensures that neighbours are integrated if individuals are newly merged such that their neighbour relations in the cache can be updated. Instead of mirroring Conditions D1–D4 for determining influencing individuals, we use the relatively simple Conditions G1–G4 since they allow for simpler data structures and efficient cache updates. Condition G1 and G2 simply check whether some possible instances are missing in the local completion graph, which may stem from a neighbouring individual from the cache. Condition G3 analogously checks for a potentially influencing individual b that is indirectly connected via the nominal {a} in the label of an implied descendant of b. Condition G4 checks for merges and inequality information caused by non-deterministically derived nominal expressions for other individuals. The following example, inspired by the well-known UOBM ontology, illustrates consistency checking with the cache. Example 1. Suppose an ABox consisting of the two parts: A1 = { ∀enr− .(∀takes.GC ∀takes.UGC)(uni), likes(stud, soccer), enr(stud, uni), takes(stud, course)}, ∀likes− .SoccerFan(soccer), A2 = { ∃hc.∃likes.{soccer}(prof), ∀teaches.∀takes− .¬TennisFan(prof),
teaches(prof, course), likes(prof, soccer)}.
We abbreviate Undergraduate Course as UGC, Graduate Course as GC, enrolled in as enr, has child as hc, and student as stud. For checking A1 , we initialise a completion graph with nodes and edges that reflect the individuals and assertions in A1 (cf. upper part of Fig. 1). To satisfy the universal restriction for vsoccer , we apply the ∀-rule, which propagates SoccerFan to vstud . Analogously, the universal restriction for vuni propagates ∀takes.GC ∀takes.UGC to vstud . We assume that the disjunct ∀takes.GC is checked first, i.e., it is non-deterministically added to L(vstud ). Then the concept GC is propagated to vcourse . The completion graph for A1 is now fully expanded and clash-free. We next extract the data for the cache (as shown in the lower part of Fig. 1). The completion graph for A2 is analogously initialised (cf. upper part of Fig. 2). For the concept ∃hc.∃likes.{soccer} ∈ L(vprof ), the ∃-rule of the tableau algorithm builds a blockable hc-successor for vprof with ∃likes.{soccer} in its label, for which another successor is created that is merged with vsoccer (due to the nominal) lead-
30
A. Steigmiller and B. Glimm
Fig. 1. Local completion graph (upper part) and entries of the individual derivations cache (lower part) for handling ABox A1 of Example 1
ing to the depicted edge to vsoccer . Due to the universal restriction ∀likes− .SoccerFan in L(vsoccer ), SoccerFan is propagated to v1 and to vprof . For the universal restriction ∀teaches.∀takes− .¬TennisFan ∈ L(vprof ), we propagate ∀takes− .¬TennisFan to vcourse . Now, there are no more tableau expansion rules applicable to the constructed completion graph, but it is not yet compatible with the cache and we have to integrate (potentially) influenced or influencing individuals. In fact, course causes two incompatibilities: On the one hand, Condition D1 identifies stud as (potentially) influenced due to ∀takes− .¬TennisFan ∈ L(vcourse ) and because stud is a takes− -neighbour of course according to the cache (cf. Fig. 1). On the other hand, Condition G2 is satisfied (since GC L(vcourse ) but GC ∈ PC (course)) and, therefore, the neighbour stud listed in K R (course)(takes− ) is identified as potentially influencing. We integrate stud by creating the node vstud , by adding the concepts {stud} and ∀takes.GC ∀takes.UGC from the cache to L(vstud ), and by creating an edge to vcourse labelled with takes as well as an edge to vsoccer labelled with likes. Now, the rule application for ∀takes− .¬TennisFan ∈ L(course) propagates ¬TennisFan to vstud . In addition, by reprocessing the disjunction ∀takes.GC ∀takes.UGC for vstud , we obtain GC ∈ L(vcourse ) if the same disjunct is chosen. As a result, the completion graph is fully expanded and clash-free w.r.t. A2 and it is compatible with the cache. Hence, the cache can be updated resulting in the entries depicted in the lower part of Fig. 2. Note that only vuni has not been integrated in the completion graph for A2 , but there is usually a bigger gain for larger ABoxes. For parallelising the work-flow with the cache, one has to update and use the entries in a consistent/atomic way such that the state is clear. This can efficiently (and asynchronously) be realised by associating an update id with each cached individual and allow them to have an “inconsistent state” in the cache (see technical report for details). If an update extracted from a constructed completion graph refers to a cache entry of an individual with a changed update id (i.e., the cache entry has been changed by another thread), then the non-deterministically derived consequences are simply added and the state of the individual is set inconsistent (e.g., by adding ⊥ to PC (a)). If all parts of the ABox are processed, then we repeatedly retrieve individuals with inconsistent states from the cache and reprocess them until compatibility is achieved. Repeatedly deriv-
Parallelised ABox Reasoning and Query Answering
31
Fig. 2. Local completion graph (upper part, expansions from cache due to incompatibilities in red) and entries of the individual derivations cache (lower part, changes in blue) for handling ABox A2 of Example 1. (Color figure online)
ing different consequences for individuals and correspondingly updating the cache in parallel can, however, threaten termination of the procedure. To retain termination, we simply increase the number of individuals that are processed by one thread such that, in the worst-case, all individuals with inconsistent states are eventually processed together. A naive expansion to all influenced individuals can cause a significant work imbalance for knowledge bases that use complex roles or have intensively connected individuals. In fact, if many neighbour individuals are influenced by universal restrictions or by the merging of nodes, then the expansion to all of them could result in an enormous completion graph processed by one thread, which could limit the effectiveness of the parallelisation. This can be addressed by “cutting the propagation” in the completion graph, for which we then notify the cache that the states of the remaining individuals have to be considered inconsistent such that their processing can be continued later. This cannot avoid the (theoretical) worst-case of processing the whole knowledge base in the end, but it seems to work well for many real-world ontologies, as indicated by our evaluation.
4 Query Answering Support Compared to other more sophisticated reasoning tasks, conjunctive query answering is typically more challenging since an efficient reduction to consistency checking is not easy. However, a new approach for answering (conjunctive) queries has recently been introduced, where the query atoms are “absorbed” into several simple DL-axioms [13]. These “query axioms” are of the form C ↓x.S x , S x ∀r.S rx , S x A S Ax , and S x S y
32
A. Steigmiller and B. Glimm
S xy , where ↓x.S x is a binder concept that triggers the creation of variable mappings in the extended tableau algorithm and S (possibly with sub- and/or superscripts) are socalled query state concepts that are associated with variable mappings, as defined in the following, in order to keep track of partial matches of the query in a completion graph. Definition 3 (Variable Mappings). A variable mapping μ is a (partial) function from ˙ M) be an (extended) completion graph, variable names to nodes. Let G = (V, E, L, , where M(C, v) denotes the sets of variable mappings that are associated with a concept C in L(v). A variable mapping μ1 ∪ μ2 is defined by setting (μ1 ∪ μ2 )(x) = μ1 (x) if x is in the domain of μ1 , and (μ1 ∪ μ2 )(x) = μ2 (x) otherwise. Two variable mappings μ1 and μ2 are compatible if μ1 (x) = μ2 (x) for all x in the domain of μ1 as well as μ2 . The join M1 M2 between the sets of variable mappings M1 and M2 is defined as: M1 M2 = {μ1 ∪ μ2 | μ1 ∈ M1 , μ2 ∈ M2 and μ1 is compatible with μ2 }. Rules of the extended tableau algorithm are shown in Table 2 (without considering blocking), which handle the new axioms and concepts by correspondingly creating and propagating variable mappings. For example, a binder concept ↓x.S x ∈ L(v) is handled by adding S x to L(v) and by creating a mapping {x → v} that is associated with S x for v, i.e., {x → v} ∈ M(S x , v). Although conjunctive query answering with arbitrary existential variables is still open for SROIQ, the approach works for knowledge bases where only a limited number of new nominal nodes is enforced (by using an extended analogous propagation blocking technique) [13], which is generally the case in practice. As an example, a simple query with only the atoms r(x, y) and s(y, x) (with x, y both answer variables) can systematically be absorbed into the axioms ↓x.S x , S x ∀r.S rx , S rx ↓y.S y , S rx S y S xy , S xy ∀s.S sxy , and S sxy S x S xyx . The query state concept S rx , for example, represents the state where bindings for x are propagated to r-successors, i.e., r(x, y) is satisfied. For bindings that are propagated back over s-edges via ∀s.S sxy , the final binary inclusion axiom checks whether the cycle is closed. If it is, the joined variable mappings are associated with S xyx from which answer candidates can be extracted once a fully expanded and clash-free completion graph is found. Note that with sophisticated absorption techniques, variable mappings can often be derived deterministically, i.e., they directly constitute query answers. Non-deterministically obtained variable mappings do, however, require a separate entailment check to verify that there exist no counter example with the query variables equally bound as in the non-deterministically derived variable mapping. This can be realised by restricting the generated binder concepts of the absorption process to only create corresponding bindings and by triggering a clash with the additional axiom S xyx ⊥. While query answering by absorption is able to process queries for many (expressive) real-world ontologies [13], especially queries with existential variables can require a substantial amount of computation. A significant bottleneck is often the (variable mappings) propagation task, i.e., the creation and propagation of the variable mappings to get all potential answers from a completion graph. Building and using completion graphs for partial ABoxes (possibly in parallel) is difficult since it is unclear which joins of bindings can occur in answers and, hence, how the ABox can suitably be partitioned. The individual derivations cache can, however, also help to split the propagation work for variable mappings such that each thread can completely determine a few
Parallelised ABox Reasoning and Query Answering
Table 2. Tableau rule extensions ↓-rule: if ↓x.C ∈ L(v), and C L(v) or {x → v} M(C, v) then L(v) = L(v) ∪ {C}, M(C, v) = M(C, v) ∪ {{x → v}} ∀-rule: if ∀r.C ∈ L(v), there is an r-neighbour w of v with C L(w) or M(∀r.C, v) M(C, w) then L(w) = L(w) ∪ {C}, M(C, w) = M(C, w) ∪ M(∀r.C, v) 1 -rule: if S x1 ...xn C ∈ K, S x1 ...xn ∈ L(v), and C L(v) or M(S x1 ...xn , v) M(C, v) then L(v) = L(v) ∪ {C}, M(C, v) = M(C, v) ∪ M(S x1 ...xn , v) 2 -rule: if S x1 ...xn A C ∈ K, {S x1 ...xn , A} ⊆ L(v), and C L(v) or M(S x1 ...xn , v) M(C, v) then L(v) = L(v) ∪ {C}, M(C, v) = M(C, v) ∪ M(S x1 ...xn , v) 3 -rule: if S 1x1 ...xn S 2y1 ...ym C ∈ K, {S 1x1 ...xn , S 2y1 ...ym } ⊆ L(v), and (M(S 1x1 ...xn , v) M(S 2y1 ...ym , v)) M(C, v) then L(v) = L(v) ∪ {C}, M(C, v) = M(C, v) ∪ (M(S 1x1 ...xn , v) M(S 2y1 ...ym , v))
33
Algorithm 1. recPropTask(R, i) Input: Variable binding restrictions R and the index of the next to be handled variable 1: if i ≤ n then 2: B ← recPropTask(R, i + 1) 3: for each x j with 1 ≤ j < i do 4: R(x j ) ← B(x j ) 5: end for 6: while |B(xi )| ≥ l do 7: R(xi ) ← R(xi ) \ B(xi ) 8: Bt ← recPropTask(R, i + 1) 9: B(xi ) ← Bt (xi ) 10: end while 11: B(xi ) ← ∅ 12: else 13: G ← buildComplGraph(R, l) 14: C ← C ∪ answerCands(G) 15: B ← extractBoundIndis(G) 16: end if 17: return B Returning the bound individuals from the last constructed completion graph
answer candidates over a part of the ABox. This enables (a uniform) parallelisation of the propagation task. Note that a partitioning of individuals for the first variable can be used for a naive parallelisation: We create several propagation tasks and restrict the ↓-rule to bind the first variable only to the individuals of the handled partition. This can, however, lead to a work imbalance if many answers are based on the same individual for the first variable and we cannot easily impose restrictions for the other variables since we do not know which combinations of individuals can occur in answers. We can, however, use a dynamic approach, where we limit the number of individuals to which a variable can be bound. Each individual bound to such a “bindinglimited” variable is recorded and in the next propagation task we exclude bindings to already tested individuals. This can, for example, be realised with the recursive function recPropTask sketched in Algorithm 1, which takes as input a mapping R from variables to (still) allowed bindings for individuals and the index i of the current variable (assuming that the variables are sorted in the order in which they are absorbed). The function accesses and modifies some variables via side effects, namely l, denoting the limit for the number of allowed bindings for each variable, n, standing for the number of variables in the query, and C, denoting the set of answer candidates. The function is initially called with R(x) = inds(K) for each variable x in the query and with i = 1 such that the
34
A. Steigmiller and B. Glimm
restrictions for the first variable are managed first. As long as there are more variables to handle, the function calls itself recursively for the next variable (cf. Line 2) and checks for the returned sets of bound individuals, denoted with B, from the last generated completion graph whether the limit l has been reached for the current variable. If this is the case, then the bindings for previous variables are “frozen”, i.e., they are interpreted as the only allowed bindings (cf. Line 3–5), and the used bindings for the current variable are excluded for the next propagation task (cf. Line 7). This ensures that all combinations are tested step-by-step and that each propagation task only creates and propagates a limited amount of variable mappings. In fact, if the restrictions for all variables are set, then they are used for constructing the next completion graph (Line 13), where R and l are checked by an adapted ↓-rule. Subsequently, we can extract the found answer candidates (Line 14) and the individuals that have been used for bindings (Line 15). Note that the concepts from the query absorption typically cause an expansion of the local completion graph due to influence criteria, e.g., if ∀r.S rx is in the label of some node, then Condition G1 identifies all r-neighbours from the cache as (potentially) influenced and the corresponding nodes need to be integrated into the completion graph to propagate the associated variable mappings to them. This can result in significant propagation work, in particular, for complex roles and individuals with many neighbours. Moreover, exhausted binding restrictions for the next variable might prevent us from actually using the mappings. To address this, one can impose propagation restrictions for universal restrictions of the form ∀r.S rx such that the local completion graph is only expanded to nodes for which bindings are possible for the next variable. This can easily be implemented by adapting the query absorption to annotate universal restrictions with the variable of the role atom to which the propagation occurs. For example, a concept of the form ∀r.S rx resulting from the query atom r(x, y) is annotated with y, denoted as ∀r→y .S rx . Condition D1 is then adapted to only identify individuals as influenced that are allowed as bindings for the labelled variable of the universal restriction. ˙ M) be an Definition 4 (Query Propagation Influence). Let G = (V, E, L, , (extended) completion graph for a knowledge base K, C an individual derivations cache (c.f. Definition 1), va ∈ V a node representing the individual a, and y a query variable. A restriction set R(y) ⊆ inds(K) for y restricts the individuals to which y can be bound, i.e., only to a node va if a ∈ R(y). An individual b ∈ C such that no node in V contains {b} in its label is (query propagation) influenced if Q1 ∀r→y .S rx1 ,...,xn ∈ L(va ), b ∈ K R (a)(r) ∪ PR (a)(r), and b ∈ R(y).
As mentioned, if the restrictions for a variable are not known upfront, then one can collect them dynamically by only imposing a limit for the number of individuals for the restriction set. While we check whether an individual b is query propagation influenced w.r.t. a variable y and the amount of individuals in the restriction set R(y) is less than the limit, we simply add b to R(y) such that Condition G1 is satisfied. Analogously, we add b to R(y) when we test whether we can bind y to b for ↓-concepts and the limit is not yet reached. When the limit is reached, no more individuals are added to the restriction set and, therefore, no other (combinations of) variable mappings are created and the completion graph is not further expanded to other individuals. The collected
Parallelised ABox Reasoning and Query Answering
35
restrictions are then used in the next propagation task to enforce the exploration of other (combinations of) variable mappings. Note, however, that steering the expansion with the query propagation influence condition cannot straightforwardly be used for roles with recursive role inclusion axioms (e.g., transitive roles) due to the unfolding process and since it would be too restrictive. One could possibly improve the handling for complex roles with non-trivial adaptations to the tableau algorithm, but it is unclear whether this is worth the effort. In particular, even if the individuals are expanded, the binding restrictions are already adhered to by the ↓-rule and one can simply prioritise the absorption of other roles first.
5 Implementation and Experiments We implemented the individual derivations cache with the sketched extensions in the tableau-based reasoning system Konclude with minor adaptations to fit the architecture and the optimisations of Konclude. In particular, we use Konclude’s efficient, but incomplete saturation procedure [15] to initialise the cache entries for all individuals. If completeness of the saturation cannot be guaranteed for an individual, we mark the corresponding cache entry as inconsistent such that it is reprocessed with the tableau algorithm. Parallel processing (via small batches) is straightforward for the saturation as individuals with their assertions are handled separately. This automatically leads to a very efficient handling of the “simple parts” of an ABox and it only remains to implement the (repeated) reprocessing of individuals with inconsistent cache entries. Since tableau algorithms are usually quite memory intensive, scalability of the parallelisation not only depends on the CPUs but also on the memory bandwidth and access. Hence, the memory allocator must scale well and the data must be organised in a way that allows for effectively using the CPU caches (e.g., by writing the data of entries with one thread in cohesive memory areas). We investigated different memory allocators (hoard, tcmalloc, jemalloc) and integrated jemalloc [7] since it seems to work best in our scenario. The worker threads for constructing completion graphs only extract the data for cache updates. A designated thread then integrates the cache updates, based on the update ids introduced on page 8, which reduces blocking, improves memory management, and allows for more sophisticated update mechanisms. To further improve the utilisation of multi-processor systems and to avoid bottlenecks, we also parallelised some other processing steps, e.g., parsing of large RDF triple files, some preprocessing aspects (i.e., extracting internal representations from RDF triples), and indexing of the cache entries for retrieving candidates for query answering. Also note that some higher-level reasoning tasks of Konclude are already (naively) parallelised by creating and processing several consistency checking problems in parallel. For evaluating the approach,1 we used the large ontologies and the appertaining queries from the PAGOdA evaluation [21], which includes the well-known LUBM and UOBM benchmarks as well as the real-world ontologies ChEMBL, Reactome, and
1
Source code, evaluation data, all results, and a Docker image (koncludeeval/parqa) are available at online, e.g., at https://zenodo.org/record/4606566.
36
A. Steigmiller and B. Glimm
Table 3. Evaluated ontologies, number of queries (from the PAGOdA+VLog evaluation), and parsing times with different number of threads in seconds (speedup factor in parentheses) Ontology
DL
ChEMBL
SRIQ(D) 3, 171 ALEHI+ (D) 93 SHIN(D) 600 ALCHOIQ(D) 608 ALCHOIQ(D) 608 SHIN(D) 246
LUBM800 Reactome Uniprot100 Uniprot40 UOBM500
#Axioms #Assertions #Q 255.8 · 106
6+3
110.5 · 106
35 + 3
87.6 · 106
7+3
109.5 · 106
K-1
K-2
K-4
K-8
1830 935 (2.0) 497 (3.7) 268 (6.8) 363 184 (2.0) 102 (3.6) 66
34 (1.9)
56 (6.5)
19 (3.6)
11 (6.2)
–(see footnote 2)
409 229 (1.8) 119 (3.5)
63 (6.7)
42.8 · 106
13 + 3
215 113 (1.9)
59 (3.6)
33 (6.5)
127.4 · 106
20 + 0
431 227 (1.9) 121 (3.5)
66 (6.5)
Uniprot2 from the European Bioinformatics Institute. To improve the evaluation w.r.t. the computation of large amounts of answers, we further include the queries from tests for the datalog engine VLog [4], but we use them w.r.t. the original TBoxes. We run the evaluations on a Dell PowerEdge R730 server with two Intel Xeon E5-2660V3 CPUs at 2.4 GHz and 512 GB RAM under a 64bit Ubuntu 18.04.3 LTS. For security reasons and due to multi user restrictions, we could, however, only utilise 480 GB RAM and 8 CPU cores of the server in a containerised environment (via LXD). Metrics of the evaluated ontologies are depicted on the left-hand side of Table 3, whereas the right-hand side shows the (concurrent) parsing times for the ontologies in seconds, where K-1, K-2, K-4, and K-8 stand for the versions of Konclude, where 1, 2, 4, and 8 threads are used, respectively. Since the parallel parsing hardly requires any synchronisation and only accesses the memory in a very restricted way, it can be seen as a baseline for the achievable scalability (there are minor differences based on how often the different types of assertions occur). The left-hand side of Table 4 shows the (concurrent) pre-computation times, i.e., the time that is required to get ready for query answering after parsing the ontology, which includes the creation of the internal representation, preprocessing the ontology (e.g., absorption), saturating the concepts and individuals, repeatedly reprocessing the individuals with inconsistent cache entries, classifying the ontology, and preparing data structures for an on-demand/lazy realization. Consistency checking clearly dominates the (pre-)computation time such that the other steps can mostly be neglected for the evaluation (e.g., classification takes only a few milliseconds for these ontologies). As shown in Table 4, our parallelisation approach with the individual derivations cache is able to significantly reduce the time required for consistency checking, but the scalability w.r.t. the number of threads depends on the ontology. For LUBM and ChEMBL, the approach scales almost as well as the parsing process, whereas the scalability w.r.t. Reactome seems limited. The Reactome ontology intensively relies on (inverse) functional roles such that many and large clusters of same individuals are derived in the reasoning process. With a naive implementation of the cache, we would store, for each individual in a cluster, all derived neighbour relations, which easily becomes infeasible if large clusters of same individuals are linked. For our implementation of the cache, 2
We evaluated query answering on a sample (denoted with Uniprot40 ) since the full Uniprot ontology (Uniprot100 ) is inconsistent and, hence, not interesting for evaluating query answering.
Parallelised ABox Reasoning and Query Answering
37
Table 4. (Pre-)computation and accumulated query answering times for the evaluated ontologies with different numbers of threads in seconds (speedup factor in parentheses) Ontology
(Pre-)computing K-1
ChEMBL
K-2
Query answering K-4
K-8
K-1
2421 1244 (1.9) 663 (3.7) 397 (6.1) 12767
K-2
K-4
K-8
8927 (1.4)
4507 (2.8)
3231 (4.0)
LUBM800
2793 1658 (1.7) 831 (3.4) 437 (6.4) 2777
1829 (1.5)
1026 (2.7)
569 (4.8)
Reactome
1408 687 (2.0)
524 (1.8)
333 (2.8)
232 (4.0)
427 (3.3) 361 (3.9) 935
Uniprot100 1343 742 (1.8)
429 (3.1) 302 (4.4) N/A(see footnote 2) N/A(see footnote 2) N/A(see footnote 2) N/A(see footnote 2)
Uniprot40
289 (3.7) 198 (5.5) 28
21 (1.3)
16 (1.8)
14 (2.0)
394 (3.3) 245 (5.4) 3774
1799 (2.1)
947 (4.0)
554 (6.8)
1090 532 (2.0)
UOBM500 1317 735 (1.8)
we identify and utilise representative individuals to store the neighbour relations more effectively, but we require consistent cache entries for this. If the clusters of same individuals are updated in parallel, which often leads to inconsistent cache entries, more neighbour relations must be managed and, thus, the parallelisation of ontologies such as Reactome only works to a limited extent with the current implementation. Also note that the enormous amounts of individuals in these ontologies make it impossible for the previous version of Konclude to build full completion graphs covering the entire ABox, i.e., the version of Konclude without the cache quickly runs out of memory for these ontologies. Also note that the individuals from the cache are mostly picked in the order in which they are indexed, i.e., more or less randomly due to hashing of pointers. Nominals, however, are indexed first and, hence, are prioritised in the (re)processing. Clearly, the processing order can have a significant influence on how much (re-)processing is required, but the runs for the evaluated real-world ontologies showed hardly any variance since most consequences could be derived locally. The right-hand side of Table 4 reveals the query answering times (and scalability), accumulated for each ontology. Since not all steps are parallelised and the version of Konclude with only one thread uses specialised and more efficient implementations in some cases (e.g., an optimised join algorithm for results from several sub-queries, whereas the parallelised version is based on several in-memory map-reduce steps), query answering scalability leaves still room for improvement. Nevertheless, without splitting the propagation tasks, several queries cannot be computed, i.e., the version of Konclude without the presented (query answering) splitting techniques cannot answer all of the queries within the given memory and time limits. Moreover, the parallelisation significantly improves the query answering times and the improvements are larger, the more computation is required. As a comparison, PAGOdA requires 19, 666 s for loading and preprocessing all ontologies and more than 101, 817 s for query answering, where it reached the memory limit for one query and for two the time limit of 10 h.
6 Conclusions We show how the now ubiquitous multi-core processors can be used for parallelising reasoning tasks such as consistency checking and (conjunctive) query answering for expressive Description Logics. For this, we split the assertional knowledge of an
38
A. Steigmiller and B. Glimm
ontology to similarly sized work packages for tableau-based reasoning. The technical foundation is a cache that stores chosen consequences derived for individuals and appropriate expansion as well as cache maintenance strategies to ensure correctness and termination. Our experiments with the reasoning system Konclude show promising performance improvements. The approach may even be a suitable basis for distributed reasoning in a compute cluster, where cache entries are distributed over different machines, and for incremental/stream reasoning, where a few assertions are (frequently) added or removed.
References 1. Allocca, C., et al.: Large-scale reasoning on expressive Horn ontologies. In: Proceedings of 3rd International Workshop on the Resurgence of Datalog in Academia and Industry, vol. 2368. CEUR (2019) 2. Baader, F., Calvanese, D., McGuinness, D., Nardi, D., Patel-Schneider, P. (eds.): The Description Logic Handbook: Theory, Implementation, and Applications, 2nd edn. Cambridge University Press, Cambridge (2007) 3. Bajraktari, L., Ortiz, M., Simkus, M.: Compiling model representations for querying large ABoxes in expressive DLs. In: Proceedings of 27nd International Joint Conference on Arti. Intelligence (2018) 4. Carral, D., Dragoste, I., Gonz´alez, L., Jacobs, C.J.H., Kr¨otzsch, M., Urbani, J.: VLog: a rule engine for knowledge graphs. In: Proceedings of 18th International Semantic Web Conference (ISWC 2019) (2019) 5. Carral, D., Gonz´alez, L., Koopmann, P.: From horn-SRIQ to datalog: a data-independent transformation that preserves assertion entailment. In: Proceedings of 33rd AAAI Conference on Artificial Intelligence (AAAI 2019). AAAI Press (2019) 6. Dolby, J., Fokoue, A., Kalyanpur, A., Schonberg, E., Srinivas, K.: Scalable highly expressive reasoner (SHER). J. Web Semant. 7(4), 357–361 (2009) 7. Evans, J.: A scalable concurrent malloc(3) implementation for FreeBSD. In: Proceedings of 3rd Technical BSD Conference (BSDCan 2006) (2006) 8. Glimm, B., Kazakov, Y., Tran, T.: Ontology materialization by abstraction refinement in Horn SHOIF . In: Proceedings of 31st AAAI Conference on Artifical Intelligence (AAAI 2017), pp. 1114–1120. AAAI Press (2017) 9. Haarslev, V., M¨oller, R.: On the scalability of description logic instance retrieval. J. Autom. Reason. 41(2), 99–142 (2008) 10. Haarslev, V., M¨oller, R., Turhan, A.-Y.: Exploiting pseudo models for TBox and ABox reasoning in expressive description logics. In: Gor´e, R., Leitsch, A., Nipkow, T. (eds.) IJCAR 2001. LNCS, vol. 2083, pp. 61–75. Springer, Heidelberg (2001). https://doi.org/10.1007/3540-45744-5 6 11. Horrocks, I., Kutz, O., Sattler, U.: The even more irresistible SROIQ. In: Proceedings of 10th International Conference on Principles of Knowledge Representation and Reasoning. AAAI Press (2006) 12. Sirin, E., Cuenca Grau, B., Parsia, B.: From wine to water: optimizing description logic reasoning for nominals. In: Proceedings of 10th International Conference on Principles of Knowledge Representation and Reasoning (KR 2006). AAAI Press (2006) 13. Steigmiller, A., Glimm, B.: Absorption-based query answering for expressive description logics. In: Ghidini, C., Hartig, O., Maleshkova, M., Sv´atek, V., Cruz, I., Hogan, A., Song, J., Lefranc¸ois, M., Gandon, F. (eds.) ISWC 2019. LNCS, vol. 11778, pp. 593–611. Springer, Cham (2019). https://doi.org/10.1007/978-3-030-30793-6 34
Parallelised ABox Reasoning and Query Answering
39
14. Steigmiller, A., Glimm, B.: Parallelised ABox reasoning and query answering with expressive description logics - technical report. Technical report, Ulm University, Ulm, Germany (2021). https://www.uni-ulm.de/fileadmin/website uni ulm/iui.inst.090/ Publikationen/2021/StGl2021-PARQA-TR-ESWC.pdf 15. Steigmiller, A., Glimm, B., Liebig, T.: Coupling tableau algorithms for expressive description logics with completion-based saturation procedures. In: Demri, S., Kapur, D., Weidenbach, C. (eds.) IJCAR 2014. LNCS (LNAI), vol. 8562, pp. 449–463. Springer, Cham (2014). https://doi.org/10.1007/978-3-319-08587-6 35 16. Steigmiller, A., Glimm, B., Liebig, T.: Completion graph caching for expressive description logics. In: Proceedings of 28th International Workshop on Description Logics (DL 2015) (2015) 17. Tsarkov, D., Horrocks, I., Patel-Schneider, P.F.: Optimizing terminological reasoning for expressive description logics. J. Autom. Reason. 39, 277–316 (2007) 18. Urbani, J., Kotoulas, S., Maassen, J., van Harmelen, F., Bal, H.E.: Webpie: a web-scale parallel inference engine using mapreduce. J. Web Semant. 10, 59–75 (2012) 19. Wandelt, S., M¨oller, R.: Distributed island-based query answering for expressive ontologies. In: Proceedings of 5th International Conference on Advances in Grid and Pervasive Computing (GPC 2010) (2010) 20. Wandelt, S., M¨oller, R.: Towards ABox modularization of semi-expressive description logics. J. Appl. Ontol. 7(2), 133–167 (2012) 21. Zhou, Y., Cuenca Grau, B., Nenov, Y., Kaminski, M., Horrocks, I.: PAGOdA: pay-as-you-go ontology query answering using a datalog reasoner. J. Artif. Intell. Res. 54, 309–367 (2015)
Analysing Large Inconsistent Knowledge Graphs Using Anti-patterns Thomas de Groot(B) , Joe Raad, and Stefan Schlobach Department of Computer Science, Vrije Universiteit Amsterdam, Amsterdam, The Netherlands {t.j.a.de.groot,j.raad,k.s.schlobach}@vu.nl
Abstract. A number of Knowledge Graphs (KGs) on the Web of Data contain contradicting statements, and therefore are logically inconsistent. This makes reasoning limited and the knowledge formally useless. Understanding how these contradictions are formed, how often they occur, and how they vary between different KGs is essential for fixing such contradictions, or developing better tools that handle inconsistent KGs. Methods exist to explain a single contradiction, by finding the minimal set of axioms sufficient to produce it, a process known as justification retrieval. In large KGs, these justifications can be frequent and might redundantly refer to the same type of modelling mistake. Furthermore, these justifications are –by definition– domain dependent, and hence difficult to interpret or compare. This paper uses the notion of anti-pattern for generalising these justifications, and presents an approach for detecting almost all anti-patterns from any inconsistent KG. Experiments on KGs of over 28 billion triples show the scalability of this approach, and the benefits of anti-patterns for analysing and comparing logical errors between different KGs.
Keywords: Linked open data
1
· Reasoning · Inconsistency
Introduction
Through the combination of web technologies and a judicious choice of formal expressivity (description logics which are based on decidable 2-variable fragments of first order logic), it has become possible to construct and reason over Knowledge Graphs (KGs) of sizes that were not imaginable only few years ago. Nowadays, KGs of billions of statements are routinely deployed by researchers from various fields and companies. Since most of the large KGs are traditionally built over a longer period of time, by different collaborators, these KGs are highly prone for containing logically contradicting statements. As a consequence, reasoning over these KGs becomes limited and the knowledge formally useless. Typically, once these contradicting statements in a KG are retrieved, they are either logically explained [22] and repaired [20], or ignored via non-standard reasoning [13]. This work falls in the first category of approaches where the c Springer Nature Switzerland AG 2021 R. Verborgh et al. (Eds.): ESWC 2021, LNCS 12731, pp. 40–56, 2021. https://doi.org/10.1007/978-3-030-77385-4_3
Analysing Large Inconsistent Knowledge Graphs Using Anti-patterns
41
focus is to find and explain what has been stated in the KG that causes the inconsistency. Understanding how these contradictions are formed and how often they might occur is essential for fixing and avoiding such contradictions. At least, it is a necessary step for developing better tools that can handle inconsistent KGs. For explaining contradictions, the notion of justification, which is a minimal subset of the KG that is sufficient for the contradiction to hold, plays a key role [12].
(a) Explanation of contradiction A
(b) Explanation of contradiction B
Fig. 1. Screenshot of the ontology editor Prot´eg´e showing the explanations of two contradictions found in the Pizza ontology
Example 1. In the renowned Pizza ontology 1 that serves as a tutorial for OWL and the ontology editor Prot´eg´e, we can find two contradictions that were asserted by its developers on purpose. The first contradiction (A) demonstrates the unsatisfiable class CheesyVegetableTopping, that has two disjoint parents CheeseTopping and VegetableTopping. The second contradiction (B) demonstrates a common mistake made with setting a property’s domain, where the class Pizza is asserted as the domain of the property hasTopping. This statement means that the reasoner can infer that all individuals using the hasTopping property must be of type Pizza. On the other hand, we find in the same ontology a property restriction on the class IceCream, stating that all members of this class must use the hasTopping property. However, since it is also specified that the classes Pizza and IceCream are disjoint, now enforcing an unsatisfiable class to have a member leads to an inconsistency in the ontology. As presented in Fig. 1, justifications serve to explain such contradictions, by showing the minimal set of axioms from the ontology that causes the contradiction to hold. Although justifications provide a good basis for debugging data quality and modelling issues in the KG, their specificity in explaining the contradictions 1
https://protege.stanford.edu/ontologies/pizza/pizza.owl.
42
T. de Groot et al.
increases in some cases the complexity for analysing and dealing with these detected contradictions. Particularly in large KGs, these complexities are amplified and encountered in different dimensions. Firstly, existing methods to retrieve entailment justifications do not scale to KGs with billions of triples. Secondly, these retrieved contradictions with their justifications can be too frequent to manually analyse and understand the modelling mistakes made by the ontology designer. This is especially inconvenient when a significant number of these retrieved justifications actually refer to the same type of mistake, but instantiated in different parts of the KG (e.g. similar misuse of the domain and range properties in multiple cases). Thirdly, since justifications represent a subset of the KG, they are by definition domain dependent, and requires some domain knowledge for understanding the contradiction. This fact is obviously more limiting in complex domains, such as medical KGs, as opposed to the Pizza ontology example above. These various challenges in finding and understanding justifications in their traditional form, poses the following research questions: Q1: Can we define a more general explanation for contradictions, that categorises the most common mistakes in a KG, independently from its domain? Q2: Can we retrieve these generalised explanations from any KG, independently from its size? Q3: How can these generalised explanations help analysing and comparing certain characteristics between the most commonly used KGs in the Web? This paper introduces a method for extracting and generalising justifications from any inconsistent KG. We call these generalised justifications anti-patterns, as they can be seen as common mistakes produced either in the modelling or population phases, or possibly stemming from erroneous data linkage. We have developed an open-source tool that can retrieve these anti-patterns from any (inconsistent) KG. We test the scalability and the completeness of the approach on several KGs from the Web, including LOD-a-lot, DBpedia, YAGO, Linked Open Vocabularies, and the Pizza ontology, with a combined size of around 30 billion triples. Despite deploying a number of heuristics to ensure scalability, our experiments show that our method can still detect a large number of antipatterns in a KG, in reasonable runtime and computation capacity. Finally, we publish these detected anti-patterns in an online catalogue encoded as SPARQL queries, and show how these anti-patterns can be put to use for analysing and comparing certain characteristics of these inconsistent KGs. The rest of the paper is structured as follows. Section 2 presents related works. Section 3 presents the preliminaries and notation. Section 4 introduces our notion of anti-patterns and describes our approach for detecting them. Section 5 presents the evaluation of the approach. Section 6 presents inconsistency analyses conducted on several large inconsistent KGs. Section 7 concludes the paper.
2
Related Work
Dealing with inconsistent knowledge bases is an old problem, and solutions have been proposed as early as 1958 by Stephen Toulmin [24], where reasoning over
Analysing Large Inconsistent Knowledge Graphs Using Anti-patterns
43
consistent subbases was proposed. Explaining why a knowledge base entails a certain logical error (or entailment in general) has taken up traction in the last decade, leading to the most prevalent form of explanation in OWL knowledge bases called justification: minimal subsets of the graphs preserving entailments [15,22]. A number of approaches, described in [3], aims at supporting users’ understanding of single justifications for single entailments. Such approaches focus on reducing the axioms in justifications to their relevant parts and remove superfluous information [12,14], providing intermediate proof steps to explain subsets of justifications [11], or attempting to improve understandability of an explanation by abstracting from the logical formalism to natural language [17]. In this work, we focus on a complementary part of the problem, where the goal is to facilitate the understandability of multiple justifications, of logically incorrect entailments, that share the same structure. For this, we rely on the notion of anti-pattern that represents a generalisation of such justifications. The term ‘anti-pattern’ appears in the work of [21], where the authors manually classify a set of patterns that are commonly used by domain experts in their DL formalisations, and that normally result in inconsistencies. In addition antipatterns are also studied in [19], where the authors use a combination of reasoning and clustering methods for extracting common patterns in the detected justifications. However, this approach cannot be applied to any inconsistent KG, as it requires the KG to be mapped to the foundational ontology DOLCE-Zero. Moreover, the notion of justifications with the same structure has been previously investigated but not formalised by [16], while the more complex notion of justification template has been introduced by [3], where several equivalence relations over justifications has been explored. In comparison with the mentioned works, this is the first work that relies on a simpler notion of justifications’ generalisation, for the goal of analysing common logical errors in KGs, at the scale of the Web. Our method for detecting such anti-patterns reuses part of the work of [18], where the authors propose the efficient algorithm for path finding that we use in our subgraph generation. Our work can also be compared to an earlier large scale justification retrieval approach that uses MapReduce [26] but was mainly evaluated over synthetic data sets, and recent analyses [4,7,8], that aim at studying general characteristics of large KGs in the Web.
3
Background
In this section, we give the preliminary background and introduce the notation. We consider a vocabulary of two disjoint sets of symbols2 : L for literals and I for IRIs (Internationalised Resource Identifiers). The elements of T = L ∪ I are called RDF terms, and those of I × I × T are called RDF triples. An RDF knowledge graph G is a set of RDF triples. Let V be a set of variable symbols disjoint from T , a triple pattern is a tuple t ∈ (I ∪ V ) × (I ∪ V ) × (T ∪ V ), representing an RDF triple with some positions 2
We do not consider blank nodes in this work.
44
T. de Groot et al.
replaced by variables. Any finite set of triple patterns is a basic graph pattern (BGP) P , and forms the basis of SPARQL for answering queries (matching a BGP to a subgraph of G by substituting variables with RDF terms). We use var(t) and var(P ) to denote the set of variables occurring in a triple pattern t and a BGP P , respectively3 . A substitution µ is a total mapping from V to T i.e., µ: V → T . The domain of µ, denoted by dom(µ), is the subset of V where µ is defined. Given a triple pattern t and a mapping µ such that dom(µ) := var(t), µ(t) is the triple obtained by replacing the variables in t according to µ. Similarly, given a BGP P and a substitution µ such that dom(µ) := var(P ), µ(P ) is the set of triples obtained by replacing the variables in the triples of P with respect to µ. Finally, we use the standard notions of entailment, satisfiability and consistency for RDF(S) and OWL [2,10]. Most importantly, an inconsistent KG is a graph for which no model exists, i.e. a formal interpretation that satisfies all the triples in the graph given the semantics of the used vocabularies. Let E be some entailment relation, and e a triple such that G |= e. A subgraph J(e) of G is called a justification for the inferred triple e, if J(e) |= e, and J s.t. J ⊂ J(e) and J |= e (i.e. a justification is a minimal subset of the knowledge graph that is responsible for the inferred triple). When e is involved in a contradiction, then naturally, its justification J(e) will play a key role in explaining the contradiction.
4
Defining and Detecting Anti-patterns
In this section, we introduce the notion of anti-patterns, and describe our approach for retrieving anti-patterns from any inconsistent KG. 4.1
Anti-patterns
As previously defined, a justification is a minimal description of a single entailment (or contradiction), which can be represented as an instantiated BGP. If G is consistent w.r.t. some entailment relation E, one could call a BGP P a pattern for G if there is a substitution µ(P ) such that G |= µ(P ). In other words, if there is a variable assignment such that all instantiated graph patterns are entailed by the knowledge graph. Suppose now that the knowledge graph G is inconsistent w.r.t E. In that case, trivially not every BGP would be a pattern. Therefore we define, the more interesting syntactic notion of a BGP as an anti-pattern for G w.r.t E, as a minimal set of triple patterns that can be instantiated into an inconsistent subset of G. We define the notion of anti-patterns as follows. Definition 1 (Anti-Pattern). P is an anti-pattern of a Knowledge Graph G if there is a substitution µ(P ) s.t. µ(P ) ⊆ G, and µ(P ) is minimally inconsistent w.r.t some entailment relation E, i.e. P s.t. P ⊂ P and µ(P ) is inconsistent. 3
Therefore, var(t) ⊆ var(P ) whenever t ∈ P .
Analysing Large Inconsistent Knowledge Graphs Using Anti-patterns
45
For an anti-pattern P , we denote by |P | the size of this anti-pattern, defined as the number of triple patterns in P . We define also the notion of support sup(P ) for an anti-pattern, as the number of substitutions µ(P ). Intuitively, µ(P ) refers to a particular justification in G, and the support refers to the number of justifications occurring in the KG for a certain anti-pattern. In order to transform a justification into an anti-pattern, we replace the elements in the subject and object position of the BGP with variables. In order to prevent breaking the contradiction, elements appearing in the predicate position of a justification are not replaced in the anti-pattern, with the exception of one case: elements appearing in the predicate position and also appearing in the subject or object position of the same justification.
(a) Anti-pattern of contradiction A
(b) Anti-pattern of contradiction B
Fig. 2. Graphical representation of the anti-patterns of the two contradictions found in the Pizza ontology of Example 1, with circles representing the variables V and rectangles representing the RDF terms T .
Going back to Example 1, we presented two explanations of contradictions found in the Pizza ontology. Contradiction A shows an inconsistency in the ontology in which the unsatisfiable class CheesyVegetableTopping, that is a subclass of the two disjoint classes CheeseTopping and VegetableTopping, is instantiated. While this example refers to a specific case of a contradiction entailed from the description of these three classes, it also refers to a common type of modelling or linking mistake that can be present in another (part of the) ontology. For instance, using the same principle, the modeller could have also created the class FruitVegetableTopping as subclass of the two disjoint classes FruitTopping and VegetableTopping. This formalisation of certain types of mistakes is what we refer to as anti-patterns. Figure 2 presents the two anti-patterns generalising the justifications of contradictions A and B. For instance in the anti-pattern of contradiction A, the three classes CheesyVegetableTopping, CheeseTopping and VegetableTopping are replaced with the variables C1 , C2 and C3 , respectively. In this anti-pattern, replacing the predicate owl:disjointWith with a variable p1 would break the contradiction, since p1 could potentially be matched in the KG with another predicate such as rdfs:subClassOf. On the other hand, we can see in the anti-pattern of contradiction B that the predicate hasTopping is replaced
46
T. de Groot et al.
with the variable p1 , since it also appears in the subject position of the triple hasTopping, rdfs:domain, Pizza. This allows the same anti-pattern to generalise other justifications in the KG, that follow the same pattern but involve a different property than hasTopping. 4.2
Approach
This section describes our approach for finding anti-patterns from any inconsistent KG. Finding anti-patterns from a KG would mainly consist of two steps: retrieving justifications of contradictions, and then generalising these detected justifications into anti-patterns. Such approach is expected to deal with multiple dimensions of complexity, mainly: Knowledge Graphs can be too large to query. Now that KGs with billions of triples have become the norm rather than the exception, such approach must have a low hardware footprint, and must not assume that every KG will always be small enough to fit in memory or to be queried in traditional triple stores. Justification retrieval algorithms do not scale. Finding all contradictions, and computing their justifications is a computationally expensive process, as it typically requires loading the full KG into memory. Therefore, when dealing with KGs of billions of triples, existing justification retrieval methods and tools do not scale [5]. Theoretically, guaranteeing the retrieval of all anti-patterns given any inconsistent KG requires firstly finding all contradictions with their justifications, and then generalising these justifications into anti-patterns. In practice, and as a way to tackle the above listed challenges, our approach introduces a number of heuristics in various steps of the approach. These heuristics emphasises the scalability of the approach, opposed to guaranteeing its completeness regarding the detection of all anti-patterns. Mainly, an initial step is introduced in the pipeline that consists of splitting the original KG into smaller and overlapping subgraphs. Depending on the splitting strategy, this step can impact the number of retrieved justifications, which in its turn can potentially impact the number of the retrieved anti-patterns. In the following, we describe the mains steps of our approach consisting of (1) splitting the KG, (2) retrieving the contradictions’ justifications, and (3) generalising these justifications. Figure 3 summarises these three steps. 1. Splitting the KGs. Due to the large size of most recent KGs, running a justification retrieval algorithm over the complete KG to retrieve all contradictions is impractical. To speed up this process or even make it feasible for some larger KGs, we split the KG into smaller subgraphs. Each subgraph is generated by extending a root node as a starting point, that is retrieved by taking a distinct RDF term that appears in the subject position of at least one triple. As a result, the number of generated subgraphs is always equal to the number of distinct
Analysing Large Inconsistent Knowledge Graphs Using Anti-patterns
47
Fig. 3. Diagram that shows the pipeline used to extract subgraphs, find justifications in these subgraphs, and generalise these justifications to anti-patterns.
subjects in a KG. Using a breadth-first search, the graph is expanded by finding all the triples that have the root node as the subject, and these triples are added to the subgraph. Next, all the nodes in the object position are expanded, together with the predicates, and the graph is expanded as long as possible, or until the maximum amount of triples Gmax set by the user is reached4 . In Sect. 5, we empirically estimate the optimal Gmax value for large general domain KGs, based on the trade-off between scalability of the approach and its completeness in terms of the detected anti-patterns. 2. Justification Retrieval. Out of these newly formed subgraphs, we are only interested in the ones that are inconsistent. Therefore, we firstly check for the consistency of each of these subgraphs and discard the consistent ones. Then, for each of the inconsistent subgraphs, we run a justification retrieval algorithm to retrieve the detected inconsistencies with their justifications. For this, we use the justification retrieval algorithm in the Openllet reasoner with the OWL 2 EL profile, that walks through the graph and finds the minimal justification for each contradiction. It continues to search for justifications until no more justification can be found in the graph5 . This step is executed for each subgraph, and all the justifications are then pushed to the final stage of the pipeline. 3. Justification Generalisation. While most justifications are different, as each one represents a set of instantiated triple patterns, the underlying noninstantiated BGPs do not have to be. The underlying BGP forms the basis of the anti-patterns. To retrieve all anti-patterns from the detected justifications, we first generalise the justification to an anti-pattern by removing the instantiated 4 5
Alternatively one can use a neighbourhood radius to limit the size of a subgraph instead of Gmax . since justification retrieval algorithms can potentially run for a long time in the search for additional justifications in a KG, we set a runtime limit between 10 and 20 s based on the considered subgraph size.
48
T. de Groot et al.
subject and object on the nodes (when applicable, also the instantiated predicate is removed, such as the case described in Sect. 4.1). Justifications with the same underlying pattern are grouped together. Therefore, given a justification and its generalisation into anti-pattern, we check whether an anti-pattern with the same structure already exists. Comparing anti-patterns with different variable names consists in checking whether these anti-patterns are isomorphic. For this, we implement a version of the VF2 algorithm [6], with the addition of matching the instantiated edges of the anti-patterns (i.e. matching the predicates that do not appear in the subject or object position of the same justification). If the anti-pattern P of a certain justification is matched to an existing anti-pattern, we group this justification with the other justifications generalised by this antipattern, and increment sup(P ) by 1. Otherwise, a new anti-pattern is formed as a generalisation of this justification. This algorithm continues until all justifications have been matched to their corresponding anti-patterns. Implementation. The source code of our approach is publicly available online6 . It is implemented in JAVA, and relies on a number of open-source libraries, mainly jena 7 , hdt-java 8 , openllet 9 , and owlapi 10 . All experiments in the following sections have been performed on an Ubuntu server, 8 CPU Intel 2.40 GHz, with 256 GB of memory.
5
Experiments
As a way of emphasising scalability over completeness, our approach for finding anti-patterns from any inconsistent KG implements an initial step that consists of splitting the KG into smaller and overlapping subgraphs. In the first part of these experiments (Sect. 5.1), we empirically evaluate the impact of the subgraph size limit Gmax on the efficiency of the approach. Then, based on the Gmax estimated from the first experiment, we show (in Sect. 5.2) the scalability of our approach on some of the largest KGs publicly available on the Web. 5.1
Completeness Evaluation
In this section, we measure the impact of splitting the KG both on the number of detected anti-patterns, and the runtime of the approach. The goal of this experiment is to ultimately find the optimal subgraph size limit to consider in the first step of the approach. For evaluating completeness, this experiment requires datasets in which Openllet can retrieve (almost) all inconsistencies with their justifications. For this, we rely on the three following datasets: 6 7 8 9 10
https://github.com/thomasdegroot18/kbgenerator. https://jena.apache.org. https://github.com/rdfhdt/hdt-java. https://github.com/Galigator/openllet. https://owlcs.github.io/owlapi.
Analysing Large Inconsistent Knowledge Graphs Using Anti-patterns
49
– Pizza ontology: dataset of 1,944 triples serving as a tutorial for OWL. We choose this dataset based on the fact that its contradictions and anti-patterns are known, and therefore can represent a gold standard for our approach. – Linked Open Vocabularies (LOV): dataset of 888,017 triples representing a high quality catalogue of reusable vocabularies for the description of data on the Web [25]. We choose this dataset since it is small enough to retrieve almost all of its contradictions and their justifications using Openllet. – YAGO: dataset of more than 158 million triples covering around 10 million entities derived from Wikipedia, WordNet and GeoNames [23]. We choose this dataset to observe whether the optimal size limit varies significantly between the previous datasets and this relatively larger one. In the following experiments, we vary the subgraph size limit Gmax , and observe the number of detected anti-patterns and the corresponding runtime for each of the three steps of our approach. Table 1 presents the first experiment, conducted on the only considered dataset which all of its contradictions are known and can be computed on the whole graph. These results show that splitting the Pizza dataset into smaller, but overlapping, subgraphs does not impact the coverage of the approach, as both available anti-patterns in this dataset are detected even when small subgraph size limits are considered. Table 1. Impact of the subgraph size limit Gmax on the number of detected antipatterns and the runtime of the approach (in seconds) for the Pizza dataset. Gmax
Step 1 Step 2 Step 3 Number of Detected Total runtime runtime runtime runtime subgraphs antipatterns
50
2
3
1
2
0.01
335
100
2
4.3
1.3
3
0.01
186
250
2
8
3
5
0.05
77
500
2
13
6
7
0.04
38
750
2
18
8
10
0.08
25
1K
2
23
10
13
0.08
19
No limit 2
3.2
–
3.1
0.1
–
Table 2 presents the results of the same experiment conducted on the LOV and YAGO datasets. We adapt the considered Gmax to the size of these datasets. These results show that in both datasets, choosing a subgraph size limit of 5,000 triples provides the optimal trade-off between the runtime of the approach and the number of detected anti-patterns for both these KGs. Moreover, and similarly to the previous experiment, we observe that the justification retrieval step (i.e. Step 2) is the most time consuming step, accounting in some cases up to 94% of the total runtime. Finally, and as it was not possible to run Openllet on graphs larger than 100K triples, this experiment does not guarantee for both datasets that all possible contradictions and anti-patterns can be detected when splitting
50
T. de Groot et al.
Table 2. Impact of the subgraph size limit Gmax on the number of detected antipatterns and the runtime of the approach (in seconds) for LOV and YAGO. Gmax Detected Total antirunpatterns time
Step 1 runtime
Step 2 runtime
Step 3 runtime
Number of subgraphs
500 1K 5K 10K 25K 50K 100K
0 2 39 39 39 39 39
1, 783 3, 505 4, 525 5, 106 5, 347 5, 497 5, 758
216 429 668 739 835 858 946
1, 566 3, 073 3, 829 4, 349 4, 493 4, 615 4, 792
2 3 28 18 18 24 20
101, 673 50, 960 10, 218 5, 109 2, 041 1, 014 507
YAGO 500 1K 5K 10K 25K 50K 100K
0 0 135 135 135 135 135
3, 403 39, 41 14, 342 18, 283 19, 174 34, 177 68, 264
649 1, 223 2, 125 2, 265 2, 938 3, 289 3, 976
2, 753 2, 717 12, 004 15, 739 16, 013 30, 684 64, 081
1 1 214 279 223 204 206
18, 203, 648 9, 123, 936 1, 829, 442 914, 721 365, 422 181, 547 90, 773
LOV
the graph. Moreover, it does not guarantee that the optimal subgraph size limit for these two datasets can be generalised to other datasets. Therefore, we only consider the 5,000 triples limit as an estimation for an optimal Gmax when splitting large general domain KGs, for the goal of detecting anti-patterns in any inconsistent dataset. 5.2
Scalability Evaluation
In the second part of these experiments, we evaluate the scalability of our approach on some of the largest KGs publicly available on the Web. In addition to the YAGO dataset, we choose the two following datasets: – LOD-a-lot: dataset of over 28 billion triples based on the graph merge of 650K datasets from the LOD Laundromat crawl in 2015 [9]. – DBpedia (English): dataset of over 1 billion triples covering 4.58 million entities extracted from Wikipedia [1]. Based on the results of the previous experiment, we set the value of Gmax to 5,000 triples and run our approach for each of these three datasets. Table 3 shows that finding most anti-patterns from some of the largest KGs is feasible, but computationally expensive. Specifically, detecting 135 and 13 different antipatterns in YAGO and DBpedia takes approximately 4 and 13 h, respectively. Moreover, detecting 222 different anti-patterns from the LOD-a-lot takes almost
Analysing Large Inconsistent Knowledge Graphs Using Anti-patterns
51
a full week. This long runtime is mostly due to our naive implementation, as the most costly step of retrieving justifications could be parallelised, instead of sequentially retrieving these justifications for each subgraph. Table 3. Results of detecting anti-patterns from three of the largest KGs in the Web: LOD-a-lot, DBpedia and YAGO.
Number of triples Number of distinct namespaces Number of distinct anti-patterns Largest anti-pattern size Runtime (in hours)
6
LOD-a-lot
DBpedia
YAGO
28,362,198,927 9,619 222 19 157.56
1,040,358,853 20 13 12 13.01
158,991,568 11 135 16 3.98
KG Inconsistency Analysis
In the previous section, we showed that it is feasible to detect anti-patterns from some of the largest KGs in the Web, when the KG is split into overlapping subgraphs with a maximum size of 5,000 triples. In this section, we further analyse these retrieved anti-patterns and compare the detected logical errors between these three KGs. 6.1
What is the Most Common Size of Anti-patterns?
We already saw from Table 3 that the largest anti-patterns in the LOD-a-lot, DBpedia, and YAGO contain respectively 19, 12, and 16 edges. Looking at their size distribution, Fig. 4 shows that the most common size of an anti-pattern |P | ranges between 11 and 14 triple patterns for LOD-a-lot and YAGO, and between 6 and 11 triple patterns for DBpedia. This result, in addition to a manual verification of some of these anti-patterns, shows that most inconsistencies in DBpedia stem from direct instantiations of unsatisfiable classes, while the ones in LOD-a-lot and YAGO require following longer transitive chains, such as rdfs:subClassOf chains. 6.2
What are the Most Common Types of Anti-patterns Found in These KGs?
Anti-patterns represent a generalised notion of justifications that describe common mistakes in a KG. In our analysis of the detected anti-patterns in these three KGs, we found that a number of the different anti-patterns refer to an even more general type of mistakes, and can be further grouped together. This general type of anti-patterns consists of anti-patterns with the same structure of nodes
52
T. de Groot et al.
Fig. 4. Size distribution of the anti-patterns in these three KGs.
and edges, but with different size. Based on this principle, we can distinguish between three general types of anti-patterns found in these investigated KGs: kite graphs, cycle graphs, and domain or range-based graphs. Figure 5 presents a sample of detected anti-patterns referring to these three general types, and Table 4 presents their distribution in the three investigated KGs. It shows that kite graphs anti-patterns are the most common in the LOD-a-lot and YAGO, whilst cycle graph anti-patterns are the most common in DBpedia. All detected variants of these three general type of anti-patterns can be explored online11 .
Fig. 5. Sample of three anti-patterns, referring to three general types: kite graph (left), cycle graph (middle), and domain or range-based graph (right).
11
https://thomasdegroot18.github.io/kbgenerator/Webpages/statisticsOverview. html.
Analysing Large Inconsistent Knowledge Graphs Using Anti-patterns
53
Table 4. General types of anti-patterns found in these three KGs. Type of anti-patterns
LOD-a-lot DBpedia YAGO
Kite graphs 156 54 Cycle graphs Domain or Range-based graphs 12
6.3
1 12 0
108 11 16
What is the Benefit in Practice of Generalising Justifications into Anti-patterns?
Fig. 6. Distribution of anti-pattern support.
In addition to the fact that justifications are domain-dependent and possibly complex, understanding and analysing justifications of contradictions can also be impractical due to their redundancy and frequency. This is particularly true in the three large investigated KGs, as we can see in Fig. 6. This plot presents the distribution of the anti-pattern support sup(P ) in these three KGs. It shows that the detected anti-patterns make the millions of retrieved justifications in the LOD-a-lot, DBpedia, and YAGO more manageable, by generalising them into 222, 13, and 135 anti-patterns, respectively. Specifically, Table 5 shows that on average each anti-pattern generalises around 5M, 7.7K, and 133K justifications in the LOD-a-lot, DBpedia, and YAGO, respectively. It also shows that a single anti-pattern in the LOD-a-lot generalises more than 45M retrieved justifications. Interestingly, the LOD-a-lot –a dataset that represents the largest publicly available crawl of the LOD Cloud to date– contains over a billion justifications, while DBpedia and YAGO –two of the most popular available RDF datasets–contain around 100K and 18M justifications, respectively. Thus, indicating that the quality of DBpedia (0.0009%), estimated by the number of detected justifications per triple in G, is significantly higher in comparison with LOD-a-lot (3.9%) and YAGO (11.3%).
54
T. de Groot et al. Table 5. Impact of generalising justifications to anti-patterns
7
sup(P )
LOD-a-lot
DBpedia YAGO
Minimum Maximum Average Median Total Total per triple
2 45,935,769 4,988,176.9 23,126 1,107,375,273 3.9%
1 32,997 7,796.07 4,469 101,349 0.009%
1 379,546 133,998.31 106,698 18,089,773 11.3%
Conclusion
In this work, we introduced anti-patterns as minimal sets of (possibly) uninstantiated basic triple patterns that match inconsistent subgraphs in a KG. We can use anti-patterns to locate, generalise, and analyse types of contradictions. Retrieving contradictions from a KG and finding the extent to which a KG is inconsistent can now be formulated as a simple SPARQL query using antipatterns as BGPs. Our second contribution is a tool that can extract a large number of anti-patterns from any inconsistent KG. For evaluating our approach, we showed on relatively small KGs that our approach can detect in practice all anti-patterns despite splitting the KG, and showed on KGs of billions of triples that our approach can be applied at the scale of the Web. Specifically, we showed on the LOD-a-lot, DBpedia, and YAGO datasets that billions of justifications can be generalised into hundreds of anti-patterns. While these findings prove the spread of billions of logically contradicting statements in the Web of Data, this work also shows that these contradictions can now be easily located in other KGs (e.g. using a SELECT query), and possibly repaired (e.g. using a CONSTRUCT query). The source code, as well as the list of detected anti-patterns from these KGs are publicly available as SPARQL queries, with their support in each dataset. We are aiming to extend this work by (1) including additional datasets such as Wikidata and additional commonly used domain specific datasets, (2) exploiting the previously computed transitive closure of more than half a billion owl:sameAs links [4], 3 billion rdf:type statements with 4 million rdfs:subClassOf in the LODa-lot, for the goal of detecting additional types of anti-patterns, and (3) analysing the origins of these anti-patterns which consists of analysing billions of detected justifications, and in the case of the LOD-a-lot dataset also consists of obtaining the provenance of each statement from the LOD Laundromat crawl.
Analysing Large Inconsistent Knowledge Graphs Using Anti-patterns
55
References 1. Auer, S., Bizer, C., Kobilarov, G., Lehmann, J., Cyganiak, R., Ives, Z.: DBpedia: a nucleus for a web of open data. In: Aberer, K., et al. (eds.) ASWC/ISWC -2007. LNCS, vol. 4825, pp. 722–735. Springer, Heidelberg (2007). https://doi.org/10. 1007/978-3-540-76298-0 52 2. Baader, F., Calvanese, D., McGuinness, D., Patel-Schneider, P., Nardi, D., et al.: The Description Logic Handbook: Theory, Implementation and Applications. Cambridge University Press, Cambridge (2003) 3. Bail, S.: The justificatory structure of OWL ontologies. Ph.D. thesis, The University of Manchester (United Kingdom) (2013) 4. Beek, W., Raad, J., Wielemaker, J., van Harmelen, F.: sameAs.cc: the closure of 500M owl: sameAs statements. In: Gangemi, A., et al. (eds.) ESWC 2018. LNCS, vol. 10843, pp. 65–80. Springer, Cham (2018). https://doi.org/10.1007/978-3-31993417-4 5 5. Bonte, P., et al.: Evaluation and optimized usage of owl 2 reasoners in an eventbased ehealth context. In: 4e OWL Reasoner Evaluation (ORE) Workshop, pp. 1–7 (2015) 6. Cordella, L.P., Foggia, P., Sansone, C., Vento, M.: A (sub) graph isomorphism algorithm for matching large graphs. IEEE Trans. Pattern Anal. Mach. Intell. 26(10), 1367–1372 (2004) 7. Debattista, J., Lange, C., Auer, S., Cortis, D.: Evaluating the quality of the lod cloud: an empirical investigation. Semant. Web (Preprint) 9, 1–43 (2018) 8. F¨ arber, M., Bartscherer, F., Menne, C., Rettinger, A.: Linked data quality of dbpedia, freebase, opencyc, wikidata, and yago. Semant. Web 9(1), 77–129 (2018) 9. Fern´ andez, J.D., Beek, W., Mart´ınez-Prieto, M.A., Arias, M.: LOD-a-lot. In: Gangemi, C., et al. (eds.) ISWC 2017. LNCS, vol. 10588, pp. 75–83. Springer, Cham (2017). https://doi.org/10.1007/978-3-319-68204-4 7 10. Hitzler, P., Krotzsch, M., Rudolph, S.: Foundations of Semantic Web Technologies. CRC Press, Boca Raton (2009) 11. Horridge, M., Parsia, B.: From justifications towards proofs for ontology engineering. In: Twelfth International Conference on the Principles of Knowledge Representation and Reasoning (2010) 12. Horridge, M., Parsia, B., Sattler, U.: Laconic and precise justifications in OWL. In: Sheth, A., Staab, S., Dean, M., Paolucci, M., Maynard, D., Finin, T., Thirunarayan, K. (eds.) ISWC 2008. LNCS, vol. 5318, pp. 323–338. Springer, Heidelberg (2008). https://doi.org/10.1007/978-3-540-88564-1 21 13. Huang, Z., Van Harmelen, F., Ten Teije, A.: Reasoning with inconsistent ontologies. IJCAI 5, 254–259 (2005) 14. Kalyanpur, A., Parsia, B., Grau, B.C.: Beyond asserted axioms: fine-grain justifications for owl-dl entailments. In: International Workshop on Description Logics DL, vol. 6 (2006) 15. Kalyanpur, A., Parsia, B., Sirin, E., Hendler, J.: Debugging unsatisfiable classes in owl ontologies. J. Web Semant. 3(4), 268–293 (2005) 16. Nguyen, T.A.T., Power, R., Piwek, P., Williams, S.: Justification patterns for owl dl ontologies (2011) 17. Nguyen, T.A.T., Power, R., Piwek, P., Williams, S.: Measuring the understandability of deduction rules for owl. In: International Workshop on Debugging Ontologies and Ontology Mappings-WoDOOM12, Galway, Ireland, 8 Oct 2012, no. 079 pp. 1–12.. Link¨ oping University Electronic Press (2012)
56
T. de Groot et al.
18. Noori, A., Moradi, F.: Simulation and comparison of efficency in pathfinding algorithms in games. Ciˆencia e Natura 37(6–2), 230–238 (2015) 19. Paulheim, H., Gangemi, A.: Serving DBpedia with DOLCE – more than just adding a cherry on top. In: Arenas, M., et al. (eds.) ISWC 2015. LNCS, vol. 9366, pp. 180– 196. Springer, Cham (2015). https://doi.org/10.1007/978-3-319-25007-6 11 20. Plessers, P., De Troyer, O.: Resolving inconsistencies in evolving ontologies. In: Sure, Y., Domingue, J. (eds.) ESWC 2006. LNCS, vol. 4011, pp. 200–214. Springer, Heidelberg (2006). https://doi.org/10.1007/11762256 17 21. Roussey, C., Corcho, O., Vilches-Bl´ azquez, L.M.: A catalogue of owl ontology antipatterns. In: International Conference on Knowledge Capture, pp. 205–206 (2009) 22. Schlobach, S., Cornet, R., et al.: Non-standard reasoning services for the debugging of description logic terminologies. IJCAI 3, 355–362 (2003) 23. Suchanek, F.M., Kasneci, G., Weikum, G.: Yago: a core of semantic knowledge. In: International conference on World Wide Web, pp. 697–706. ACM (2007) 24. Toulmin, S.E.: The Uses of Argument. Cambridge University Press, Cambridge (2003) 25. Vandenbussche, P.Y., Atemezing, G.A., Poveda-Villal´ on, M., Vatant, B.: Linked open vocabularies (lov): a gateway to reusable semantic vocabularies on the web. Semant. Web 8(3), 437–452 (2017) 26. Wu, G., Qi, G., Du, J.: Finding all justifications of owl entailments using tms and mapreduce. In: International Conference on Information and Knowledge Management, pp. 1425–1434 (2011)
Processing SPARQL Property Path Queries Online with Web Preemption Julien Aimonier-Davat, Hala Skaf-Molli(B) , and Pascal Molli LS2N – University of Nantes, Nantes, France {Julien.Aimonier-Davat,Hala.Skaf,Pascal.Molli}@univ-nantes.fr
Abstract. SPARQL property path queries provide a succinct way to write complex navigational queries over RDF knowledge graphs. However, the evaluation of these queries over online knowledge graphs such as DBPedia or Wikidata is often interrupted by quotas, returning no results or partial results. To ensure complete results, property path queries are evaluated client-side. Smart clients decompose property path queries into subqueries for which complete results are ensured. The granularity of the decomposition depends on the expressivity of the server. Whatever the decomposition, it could generate a high number of subqueries, a large data transfer, and finally delivers poor performance. In this paper, we extend a preemptable SPARQL server with a partial transitive closure operator (PTC) based on a depth limited search algorithm. We show that a smart client using the PTC operator is able to process SPARQL property path online and deliver complete results. Experimental results demonstrate that our approach outperforms existing smart client solutions in terms of HTTP calls, data transfer and query execution time.
1
Introduction
Context and Motivation: Property paths were introduced in SPARQL 1.1 [14] to add extensive navigational capabilities to the SPARQL query language. They allow to write sophisticated navigational queries over Knowledge Graphs (KGs). SPARQL queries with property paths are widely used. For instance, they represent a total of 38% of the entire log of wikidata [5]. However, executing these complex queries against online public SPARQL services is challenging, mainly due to quotas enforcement that prevent queries to deliver complete results [9–11]. In this paper, we focus on how to execute SPARQL property path queries online and get complete results? Related Works: The problem of executing property path queries online and get complete results have been already studied in the context of Triple Pattern Fragment (TPF) [8,17] and Web Preemption [1]. Current approaches decompose property path queries into many triple pattern or BGP queries that are guaranteed to terminate. However, such an approach generates a large number of queries which significantly degrades performance. c Springer Nature Switzerland AG 2021 R. Verborgh et al. (Eds.): ESWC 2021, LNCS 12731, pp. 57–72, 2021. https://doi.org/10.1007/978-3-030-77385-4_4
58
J. Aimonier-Davat et al.
Fig. 1. Property path queries on online knowledge graphs
Approach and Contributions: In this paper, we extend a preemptable SPARQL server with a preemtable Partial Transitive Closure (PTC) operator based on a depth limited search algorithm. We show that a smart client using the PTC operator is able to compute SPARQL 1.1 property path queries online and get complete results without decomposing queries. In this paper: (i) We show how to build a PTC preemptable operator. (ii) We show how to build a smart-client that computes transitive closures from partial transitive closures. (iii) We compare the performances of our PTC approach with existing smart client approaches and SPARQL 1.1 servers. Experimental results demonstrate that our approach outperforms smart client approaches in terms of query execution time, number of HTTP calls and data transfer. This paper is organized as follows. Section 2 reviews related works. Section 3 introduces web preemption and property paths. Sections 4 presents the PTC approches and algorithms. Section 5 presents our experimental results. Finally, the conclusion is outlined in Sect. 6.
2
Related Works
Property paths closely correspond to regular expressions and are crucial to perform non-trivial navigation in knowledge graphs. Regular expressions involve operators such as ‘ * ’ (transitive closure operator, zero or more occurrenceskleene star), ‘ | ’ (OR operator), ‘ / ’ (sequence operator), ‘ ∧ ’ (inverse operator), ‘ ! ’ (NOT operator) that allow to describe complex paths of arbitrary length. For instance, the query SELECT ?x ?y WHERE { ?x foaf:knows* ?y } requires to compute the transitive closure of the relation foaf:knows over all pairs (x, y) present in a knowledge graph. SPARQL Endpoints. Many techniques [4,12] allow to evaluate property paths. There is currently two main approaches: graph traversal based approaches and recursive queries. Whatever the approach we consider, path queries with transitive closures are challenging to evaluate for online Knowledge Graphs such as DBPedia or Wikidata. To ensure a fair usage policy of resources, public SPARQL endpoints enforce quotas [6] in time and resources for executing queries. As queries are stopped by quotas, many queries return no results or
Processing SPARQL Property Path Queries Online with Web Preemption
59
partial results. For instance, the query Q1 in Fig. 1 returns no result on Wikidata because it has been stopped after running more than 60s. The query Q21 on DBPedia returns partial results because it has been killed after delivering the first 10000 results. Decomposition and Restricted Interfaces Approaches. The problem of executing property path queries online and get complete results have been already studied with SPARQL restricted interfaces represented by Triple Pattern Fragment (TPF) [8,17] and Web Preemption [1]. As a TPF server [8,17] ensures the termination of any triple pattern query, a TPF smart client [15] decomposes the evaluation of a property path into multiple triple pattern queries that are sent to the server. This requires to compute several joins on the client, especially to compute transitive closure expressions. This generates many calls and a huge data transfer, resulting in poor performances as pointed out in [1]. As preemptable SPARQL server [10] ensures the termination of any BGP query, the SaGe smart client [1] decomposes the query into BGP queries that are sent to the server. As BGP are supported, performances are better than TPF. However, the preemptable server does not support transitive closures. Consequently, to process the query Q1 of Fig. 1a the smart client breaks the Basic Graph Pattern (BGP) of Q1 into 3 triple patterns. The triple patterns are then processed using nested loop joins where joins are performed on the client. The transitive closure is processed using a simple Breadth First Search (BFS) algorithm implemented on client-side. This process remains clearly data-transfer intensive and generates a very high number of calls to the server. As each call has to pay for the network latency, the execution time of the query is dominated by the network costs.
3
Web Preemption and Property Paths
Web preemption [10] is the capacity of a web server to suspend a running SPARQL query after a fixed quantum of time and resume the next waiting query. When suspending a query Q, a preemptable server saves the internal state of all operators of Q in a saved plan Qs and sends Qs to the client. The client can continue the execution of Q by sending Qs back to the server. When reading Qs , the server restarts the query Q from where it has been stopped. As a preemptable server can restart queries from where they have been stopped and makes a progress at each quantum, it eventually delivers complete results after a bounded number of quanta. However, web preemption comes with overheads. The time taken by the suspend and resume operations represents the overhead in time of a preemptable server. The size of Qs represents the overhead in space of a preemptable server and may be transferred over the network each time a query is suspended by the server. To be tractable, a preemptable server has to minimize these overheads. 1
Q1 and Q2 are respectively executed at the public SPARQL endpoints of Wikidata and DBPedia, at August 5 2020.
60
J. Aimonier-Davat et al.
As shown in [10], suspending a simple triple pattern query is in constant time, i.e., just store the last triple scanned in Qs . Assuming that a dataset D is indexed with traditional B-Trees on SPO, POS and OSP, resuming a triple pattern query given the last triple scanned is in O(log(|D|) where |D| is the size of the dataset D. Many operators such as join, union, projection, bind and most filters can be saved and resumed in constant time as they just need to manage one-mappingat-a-time. These operators are processed by the preemptable SPARQL server. However, some operators need to materialize intermediate results and cannot be saved in contant time. For example, the “ORDER BY” operator needs to materialize the results before sorting them. Such operators are classified as fullmappings and are processed by the smart client. For example, to process an “ORDER BY”, all results are first transferred to the smart client that finally sort them. If delegating some operators to the client-side allows effectively to process any SPARQL queries, it has a cost in term of data transfer, number of calls to the server to terminate the query, and execution time. Unfortunately, to compute property path expressions with transitive closures we need a serverside operator that belongs to the full-mappings operators. DFS Graph-traversal based approaches require to store at least the current path in the graph that can be in the worst case, of the size of the graph. Recursive-queries approaches require to store a temporary relation that is incrementally saturated, and that also cannot be saved in constant time. Currently, a BGP containing a path expression with a closure is fully processed by the smart-client following the decomposition approach described in the related works (cf Sect. 2). The only way to reduce the number of calls is to extend a preemptable server with a transitive closure operator such that BGP containing path patterns can be processed on server-side. However, algorithms that implement transitive closure such as DFS and BFS are not preemptable, i.e., cannot be suspended and resumed in constant time. Problem Statement: Define an α operator able to compute the transitive closure such that the complexity in time and space of suspending and resuming α is in constant time.
4
The Partial Transitive Closure Approach
To compute SPARQL 1.1 property paths online and deliver complete results, our approach relies on two key ideas: – First, thanks to the ability of the web preemption to save and load iterators, it is possible to implement a Partial Transitive Closure (PTC) operator that can be saved and resumed in O(k). A PTC operator computes the transitive closure of a relation but cuts the exploration of the graph at a depth k. Nodes that are visited at depth k are called frontier nodes. However, such an operator is not able to compute property path expressions as defined in SPARQL 1.1, i.e., transitive closures may be incomplete and return duplicates.
Processing SPARQL Property Path Queries Online with Web Preemption
61
Fig. 2. Graph D and query Q3
– Second, by sending frontier nodes to the smart client, it is possible to restart the evaluation of a property path query from the frontier nodes. Consequently, a smart client using the PTC operator can fully compute SPARQL 1.1 property paths. Such a strategy to compute property paths outperforms smart client approaches as queries are evaluated on the server without any joins on client-side. In this paper, we focus on the evaluation of transitive path expressions without nested stars. For example, property paths like (ab*)* are not considered and will be the subject of future work. We assume that non-transitive expressions such as alternatives or sequences are decomposed and evaluated following [14]. 4.1
The PTC Operator
A Partial Transitive Closure P T C(v, p, k) is defined for a starting node v, a non-transitive path expression p and a depth k. P T C(v, p, k) returns all pairs (u, d) with u a node, such that it exists a path from v to u that conforms to the expression (p)d where d ≤ k and d is minimal. The frontier nodes for a P T C(v, p, k) are the nodes reached at depth k, i.e., {u | (u, d) ∈ P T C(v, p, k) ∧ d = k}. To illustrate, consider the P T C(A, Sa, 2) that returns all nodes reachable from A through a path that conforms to the expression (Sa)d with d ≤ 2. On the graph D of Fig. 2a, P T C(A, Sa, 2) = { (B, 1), (C, 1), (D, 2), (E, 2) } where both D and E are frontier nodes. If P T C(n, p, k) returns no frontier nodes then the transitive closure is complete, i.e., k was large enough to capture the transitive closure for parameters v and p. Otherwise, frontier nodes are used by the smart client to continue the evaluation of the transitive closure until no new frontier nodes are discovered. In our context, the depth limit k (maxDepth) is fixed by the preemptable SPARQL endpoint administrator and can be seen as a global variable of the preemptable server.
62
J. Aimonier-Davat et al.
Algorithm 1: ALP auxiliary function 1
Let eval(v, p) be the function that returns all terms reachable from the RDF term v, by going through a path that matches the non-transitive path expression p. Let MaxDepth be the depth limit Function ALP(v:term, p:path): R ← ∅ // set of terms V ← ∅ // set of pairs (Term, Integer) ALP (v, p, R, V ) return R
2 3 4 5 6 7
8 9 10 11 12 13 14 15 16 17 18
Function ALP(v, p, R, V): S ← [(v, 0)] // stack of terms while S = ∅ do (u, d) ← S.pop() R.add(u) V.add((u, d)) if d ≥ M axDepth then continue X ← eval(u, p) forall x ∈ X do if (x, d ) ∈ V , d ≤ d then S.add((x, d + 1))
To implement a PTC operator, we rely on a depth-limited search (DLS) algorithm [13] 2 . DLS is fundamentally a depth-first search where the search space is limited to a maximum depth. Algorithm 1 redefines the ALP auxiliary function of the SPARQL 1.1 specification to follow our definition of P T C. To avoid counting beyond a Yottabyte [2], each node is annotated with the depth at which it has been reached (Line 13). A node is revisited only if it is reached with a shortest path (Line 17). Compared to an existential semantics [2] where nodes can be visited only once, the time complexity is degraded because nodes can be revisited at most k times. However, using an existential semantics does not allow to ensure the P T C semantics, as pointed out in [16]. To illustrate, consider P T C(A, Sa, 2) evaluated previously. Under an existential semantics, starting at node A, node B is first visited at depth 1, then C at depth 2 and both B and C are marked as visited. As C cannot be revisited at depth 1, P T C(A, Sa, 2) returns pairs {(B, 1), (C, 2)}. In spite of there is a path from A to D and E that match (Sa)2 , nodes D and E are not returned. Moreover, C appears as a frontier node and will be explored by the smart client whereas it is not a frontier node. 4.2
pPTC: A Preemptable PTC Iterator
The most important element of an iterative DLS is the stack of nodes to explore. To build a preemptable iterator based on the DLS, its stack must be saved and resumed in constant time. To achieve this goal, we do not pushed nodes on the stack, but iterators that are used to expand nodes and explore the graph. Algorithm 2 presents our preemptable Partial Transitive Closure iterator, called pP T C. To illustrate how a property path query is evaluated using pP T C, suppose the server is processing query Q3 with the physical query plan of Fig. 3. When the third index loop join iterator is first activated, it pulls the bag of 2
Iterative Deepening Depth-First Search (IDDFS) can also be used, but IDDFS retraverse same nodes many times.
Processing SPARQL Property Path Queries Online with Web Preemption
63
Algorithm 2: A Preemptable PTC Iterator, evaluating a kleene star expression without nested stars
1 2 3 4 5 6 7 8 9 10 11 12 13 14
Require: p: path expression without stars v: RDF term μ: set of mappings tpid : path pattern identifier Data: M axDepth: depth limit S: empty stack of preemptable iterators V : set of pairs (RDF term, Integer) CT : empty set of control tuples Function Open(): iter ← createIter(v, p, ?o) S.push(iter.save()) μc ← nil iter ← nil
15
Function Save(): if iter = nil then S.push(iter.save())
29
17 18 19 20 21 22 23 24 25 26 27 28 30 31 32
return S, path, tpid , μc Function Load(S’, path’, tpid ’, S ← S’ path ← path’ tpid ← tpid ’ μc ← μc
16
μc ):
33 34 35 36
Function GetNext(): while S = ∅ do if μc = nil then while μc = nil and S = ∅ do iter ← S.pop().load() μc ← iter.getNext() if μc = nil then return nil non interruptible if iter = nil then S.push(iter.save()) iter ← nil n ← μc [?o] if ∃(n, d) ∈ V , d ≤ |S| then continue V.add((n, |S|)) if |S| < M axDepth then child ← createIter(n, p, ?o) S.push(child.save()) CT.add((tpid , μ, (n, |S|))) solution ← μ ∪ μc ; μc ← nil return solution return nil
mappings μ = { ?x → A, ?y → C, ?y1 → T 4 } from its left child. Then, it applies μ to tp4 to generate the bounded pattern b = T4 Sc+ ?z, creates a pP T C iterator to evaluate b and calls the GetN ext() operation of the pP T C iterator, i.e., its right child. To expand a node v, pP T C creates an iterator iter = createIter(v, p, ?o). Each time iter.GetN ext() is called, it returns a solution mapping μc where μc [?o] is the next node reachable from v through a path that conforms to p. In Fig. 3 the first time the GetN ext() operation of the pP T C iterator is called, it expands the node T 4. Expanding T 4 with p = Sc is equivalent to evaluate the triple pattern T4 Sc ?z. Consequently, pP T C calls the function createIter(T 4, Sc, ?z) to create a ScanIterator on the top of the stack S and calls its GetN ext() operation to retrieve the first child of T 4, i.e., T 2. When pP T C want to expand T 2, the iterator used to expand T 4 is saved and a new iterator is created at the top of the stack. As depicted in Fig. 3, compared to a traditional DLS like Algorithm 1 (Lines 16-18) the siblings of T 2 are not stored on the stack before expanding T 2. Because a preemptable iterator is used to explore T 4, it can be resumed later to continue the exploration of T 2 siblings, i.e., only iterators need
64
J. Aimonier-Davat et al.
Fig. 3. Physical execution plan of query Q3 with the internal state of iterators for k=2
to be saved, one for each node on the current path. As the space complexity of a saved preemptable iterator is bounded by the size of the query plan and not the size of the data [10], by limiting the exploration depth at k, we ensure that the size of S is bounded by k. Consequently, the pP T C iterator can be saved and resumed in O(k). Quanta and Complexities. During one quantum, the pP T C operator maintains a structure to keep track of visited nodes with their corresponding depth. To be preemptable, this structure has to be flushed at the end of the quantum, keeping only the stack of iterators between two quanta. In the worst case, we can consider visited nodes as always empty. In this case, the pP T C iterator enumerates all simple paths leading to a #P complexity as described in [2]. In the best case, the pP T C iterator has the same time complexity as P T C. Controls for the PTC-Client. To allow a smart client to resume a property path query and continue the evaluation beyond the frontier nodes, visited nodes are contextualized and sent to the client. For each visited node, a pP T C iterator generates a control tuple ct = (tpid , μ, (n, d)) (Line 33) where tpid is the identifier of the path pattern that produced ct, μ is the current mappings when ct has been produced and (n, d) is a pair representing a visited node with its depth. For example, suppose that the server is processing query Q3 using the physical query plan of Fig. 3. When the first index loop join is activated, it pulls the bag of mappings { ?x → A } from its left child, and next calls the GetN ext() operation of the pP T C iterator, i.e., its right child. In this context, the pP T C iterator explores node A at depth 1 by evaluating A Sa ?y, returns the bag of mappings { ?x → A, ?y → C } and generates the control tuple (T P 2id , {?x → A}, (A, 1)). All control tuples generated during a quantum are stored in a shared memory which is specific to the query during a quantum. At the end of the quantum, control tuples and solution mappings are sent to the client. The data transfer of the control tuples represents the overhead of our P T C approach. To reduce the data transfer, control tuples ct1 , ..., ctn that share the same tpid and μ are grouped together into a tuple (tpid , μ, [(n1 , d1 ), ..., (nn , dn )]).
Processing SPARQL Property Path Queries Online with Web Preemption
65
Algorithm 3: PTC-Client
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
Data: M axDepth: depth limit F IF O: empty queue of tuples (query Q, ptcid , frontier node n) V : maps each ptcid to a set of pairs (node, depth) R: empty multi-set of solution mappings Function EvalClient(query): FIFO.enqueue((query, nil, nil)) while F IF O = ∅ do (Q, ptcid , n) ← FIFO.dequeue() if ∃(n , d ) ∈ V [ptcid ], n = n ∧ d < M axDepth then continue (ω, ct) ← ServerEval(Q) R←R∪ω for (tpid , μ, vc) ∈ ct do ptcid ← hash(μ, tpid ) for (node, depth) ∈ vc do if ∃(n , d ) ∈ V [ptcid ], n = node then V[ptcid ].add(node, min(d , depth)) else V[ptcid ].add(node, depth) if depth = M axDepth then Qe ← ExpandQuery(Q, tpid , μ, node) FIFO.enqueue(Qe , ptcid , node)
18
return R
4.3
The PTC-Client
The general idea of the PTC-Client is to use the control tuples returned by the server-side pP T C iterators to expand frontier nodes until no more frontier nodes can be discovered, i.e., transitive closures are complete. Algorithm 3 describes the behavior of the PTC-client. It is fundamentally an iterative Breadth-First Search (BFS) algorithm that traverses frontier nodes. The FIFO queue stores the frontier nodes to traverse with their context. R is the multi-set of results.The V variable represents the visited nodes. As a path expression may be instantiated many times, we store a set of visited per instance of path expression, i.e., ptcid . Figure 4 illustrates the first iteration of Algorithm 3 using query Q3 of Fig. 2b. First, the query Q3 is evaluated on the server by calling ServerEval (Line 6). ServerEval accepts any SPARQL property path query and returns a set ω of solution mappings and a set ct of control tuples. The sets ω and ct for query Q3 are depicted in Fig. 4 by the two tables. As we can, all visited nodes are discovered with a depth = 1, as MaxDeph = 1, they are all frontier nodes. Consequently, the Algorithm 3 will expand Q3 with all these frontiers nodes.
66
J. Aimonier-Davat et al.
Fig. 4. First iteration of ClientEval(Q3) as defined in Algorithm 3 with graph D and M axDepth = 1
ExpandQuery takes a query Q , a set of partial mappings and a frontier node n as input (Line 16) and produces a new query as output. ExpandQuery processes in three steps. (1) The subject of the path pattern identified by tpid in Q is replaced by n. (2) Triple patterns tp in Q such as μ(tp) is fully bounded are removed. (3) To preserve the mappings μ from Q to Qe , a BIND clause is created for each variable in dom(μ). Figure 4 illustrates the query returned by ExpandQuery for each frontier node returned by ServerEval(Q3). Queries Q31, Q32, Q33, Q34 and Q35 are finally pushed in the FIFO queue (Line 17) to be evaluated at the next iteration. It could happen that the evaluation of an expanded query reached an enqueued frontier node with a shortest path (Line 12). In this case, the expanded query is not evaluated (Line 5).
5
Experimental Study
In this experimental study, we want to empirically answer the following questions: What is the impact of the maxDepth and the time quantum parameters on the evaluation of SPARQL property path queries, both in terms of data transfer, number of HTTP calls and query execution time? How does the PTC approach perform compared to smart client approaches and SPARQL endpoints? In our experiments Jena-Fuseki and Virtuoso are used as the baselines to compare our approach with SPARQL endpoints, while the multi-predicate automaton approach [1] is used as the baseline for the smart client approaches. We implemented the PTC operator in Python as an extension of the SaGe
Processing SPARQL Property Path Queries Online with Web Preemption
67
Fig. 5. Impact of the different parameters on performance for the gMark queries
server, while the PTC client is implemented in JavaScript. The resulting system, i.e., the SaGe server with our PTC operator and the JavaScript client, is called SaGe-PTC. The code and the experimental setup are available on the companion website3 . 5.1
Experimental Setup
Dataset and Queries: The dataset and queries are generated by gMark [3], a framework designed to generate synthetic graph instances coupled with complex property path query workloads. We use the “Shop” use-case configuration file4 to generate a graph instance of 7,533,145 triples and a workload of 30 queries. All our queries contain from 1 to 4 transitive closure expressions, for which numerical occurrences indicators have been replaced by Kleene plus “+” operators. Compared Approaches: We compare the following approaches: – SaGe-PTC is our implementation of the PTC approach. The dataset generated by gMark is stored using the SaGe HDT backend. The SaGe server is configured with a page size limit of 10000 solution mappings and 10000 control tuples. Different configurations of SaGe-PTC are used. (i) SaGe-PTC-2, SaGe-PTC-3, SaGe-PTC-5, SaGe-PTC-10 and SaGe-PTC-20 are configured with a time quantum of 60 s and a maxDepth of 2, 3, 5, 10 and 20, respectively. (ii) SaGe-PTC-500ms, SaGe-PTC-1sec and SaGe-PTC-60sec are configured with a maxDepth of 20 and a time quantum of 500 ms, 1 s and 60 s, respectively. – SaGe-Multi is our baseline for the smart client approaches. Property path queries are evaluated on a SaGe smart client using the decomposition approach defined in [1]. For a fair evaluation, SaGe-Multi runs against the SaGePTC server with a time quantum of 60 s. We did not include Comunica [15] in the setup as it has already been compared with SaGe-Multi in [1] and SaGe-Multi dominates Comunica for all evaluation metrics. 3 4
https://github.com/JulienDavat/property-paths-experiments. https://github.com/gbagan/gmark/blob/master/use-cases/shop.xml.
68
J. Aimonier-Davat et al.
Fig. 6. Execution time per query for SPARQL endpoint and smart client approaches compared to our PTC approach
– Virtuoso is the Virtuoso SPARQL endpoint (v7.2.5) as of December 2020. Virtuoso is configured without quotas in order to deliver complete results. We also configured Virtuoso with a single thread to fairly compare with other engines. – Jena-Fuseki is the Apache Jena Fuseki endpoint (v3.17.0) with the same configuration as Virtuoso, i.e., without quotas and a single thread. Evaluation Metrics: Presented results correspond to the average obtained of three successive executions of the queries workload. Each query is evaluated with a time-out of 30 min. (1) Execution time is the total time between starting the query execution and the production of the final results by the client. (ii) Data transfer is the total number of bytes transferred to the client during the query execution. (iii) Number of HTTP calls is the total number of HTTP calls issued by the client during the query execution. Hardware Setup: We run our experimentations on a google cloud virtual machine (VM) instance. The VM is a c2-standard-4 machine with 4 virtual CPU, 16 GB of RAM and a 256 GB SSD. Both clients and servers run on the same machine. Each client is instrumented to count the number of HTTP requests sent to the server and the size of the data transferred to the client.
Processing SPARQL Property Path Queries Online with Web Preemption
69
Fig. 7. Number of HTTP calls per query for SPARQL endpoint and smart client approaches compared to our PTC approach
5.2
Experimental Results
What is the Impact of the Quantum on Performance ? To measure the impact of the quantum on performance, we run our workload with different quanta; 500 ms, 1 s and 60 s. The maxDepth is set to 20 for each quantum, such as all queries terminate without frontier nodes. Figure 5a presents SaGe-PTC performance for SaGe-PTC-500 ms, SaGe-PTC-1 s and SaGe-PTC-60 s. As expected, increasing the quantum improves performance. With large quantum, a query needs less calls to complete, which in turn improves the execution time. Concerning the data transfer, the visited nodes of pP T C iterators are flushed at the end of each quantum, which leads to revisit already visited nodes. Consequently, the less a query needs quanta to complete, the less it transfers duplicates. What is the Impact of maxDepth on Performance? To measure the impact of maxDepth on performance, we run our 30 queries with different values of maxDepth; 2, 3, 5 and 10. To reduce the impact of the quantum, we choose a large quantum of 60 s. Figure 5b presents SaGe-PTC performance for SaGePTC-2, SaGe-PTC-3, SaGe-PTC-5 and SaGe-PTC-10. As we can see, the maxDepth impacts significantly the performance in terms of execution time, data transfer and number of calls. Increasing the maxDepth drastically improves performance because it allows to capture larger transitive closures. This means less control tuples are transferred to the client and less expanded queries are executed on the server.
70
J. Aimonier-Davat et al.
Fig. 8. Data transfer per query for SPARQL endpoint and smart client approaches compared to our PTC approach
How does the PTC Approach Perform Compared to the Smart Client Approaches and SPARQL Endpoints? The PTC approach computes SPARQL property path queries without joins on the client. When maxDepth is high enough, no expanded queries are sent to the server. We just have to pay the web preemption overheads and the duplicates transferred by the PTC approach. Consequently, we expect our approach to be somewhere between SPARQL endpoints and smart clients in terms of performance. Close to SPARQL endpoints when maxDepth is high and better than smart clients in the general case. We compare SaGe-PTC with SaGeMulti, Jena-Fuseki and Virtuoso. We run SaGe-PTC with both maxDepth = 5 (SaGe-PTC-5 ) and maxDepth = 20 (SaGe-PTC-20 ). Figures 6, 8 and 7 respectively present the execution time, the data transfer and the number of HTTP calls for each approach. As expected, SaGe-PTC outperforms SaGe-Multi regardless the query. Because SaGe-PTC does not decompose BGPs, the number of calls is drastically reduced, as shown in Fig. 7. Concerning the data transfer, both SaGe-PTC and SaGe-Multi transfer the visited nodes. However SaGe-PTC does not transfer any intermediate results, saving a lot of data transfer. Compared to Jena-Fuseki both approaches use a similar graph traversal algorithm. However Jena-Fuseki has no overheads, i.e., is optimal in terms of data transfer and number of calls. Only one call is sent per query and only the final results are transferred to the client. Consequently, we expect Jena-Fuseki to perform better than SaGe-PTC. Surprisingly Jena-Fuseki does not dominate the PTC approach. SaGe-PTC-20 is very close to Jena-Fuseki for queries where Jena-Fuseki does not time-out. As queries return no frontier nodes, overheads
Processing SPARQL Property Path Queries Online with Web Preemption
71
compared to Jena-Fuseki are small. The differences between the two approaches are mainly due to a join ordering issue. Compared to SaGe-PTC-20, with SaGePTC-5 queries need to send expanded queries to terminate. As expected, SaGePTC-5 offers performance between that of SPARQL endpoints and that of smart clients. For most queries, its performance are very close to SaGe-PTC-20. We conjecture that most transitive closures for our queries can be computed with small maxDepth. When there is a large number of frontier nodes to explore, performance degrades but remains better than those of smart client approaches. We expect Virtuoso to be optimal as it implements the state of art query optimization techniques. Surprisingly, Virtuoso does not dominate SaGe-PTC. Virtuoso generates errors for 12 queries out of 30. It cannot execute the 12 queries either because of the missing of a starting point or because it has not enough space resources to materialize the transitive closure. Virtuoso issues are mainly due to the simple path semantics when dealing with dense graphs. Of course, the number of calls for Virtuoso is optimal. However, using a simple path semantics leads to high data transfer when path queries are executed against dense graphs.
6
Conclusion
In this paper, we proposed an original approach to process SPARQL property path queries online and get complete results. Thanks to a preemptable Partial Transitive Closure operator, a smart client is ensured to grab all mappings that are reachable at a depth fixed by the server. Thanks to control information delivered during SPARQL property path queries processing, a smart client generates queries to find missing mappings. Unlike current smart clients, the PTC smart client does not break BGPs containing path patterns. Even in presence of path patterns, all joins are performed on server-side without the need to transfer intermediate results to the client. As demonstrated in the experimentations, the PTC approach outperforms existing smart clients and reduces significantly the gap of performance with SPARQL endpoints. This approach raises several interesting perspectives. First, there is a large room for optimisation: better join ordering in presence of path patterns, pruning some calls when path patterns are “reachability” oriented, and better evaluation of resuming queries according to their shapes. Second, it may be interesting to explore if partial transitive closure is compatible with partial aggregates [7]. If the aggregation functions are computed on client-side, then there is no issue for computing aggregation in presence of path patterns. However, partial aggregates computed with partial transitive closures on server-side may return incorrect results. Acknowledgments. This work is supported by the ANR DeKaloG (Decentralized Knowledge Graphs) project, ANR-19-CE23-0014, CE23 - Intelligence artificielle.
72
J. Aimonier-Davat et al.
References 1. Aimonier-Davat, J., Skaf-Molli, H., Molli, P.: How to execute sparql property path queries online and get complete results? In: 4rth Workshop on Storing, Querying and Benchmarking the Web of Data (QuWeDa 2020) Workshop at ISWC2020 (2020) 2. Arenas, M., Conca, S., P´erez, J.: Counting beyond a yottabyte, or how sparql 1.1 property paths will prevent adoption of the standard. In: Proceedings of the 21st International Conference on World Wide Web, pp. 629–638 (2012) 3. Bagan, G., Bonifati, A., Ciucanu, R., Fletcher, G.H., Lemay, A., Advokaat, N.: gmark: schema-driven generation of graphs and queries. IEEE Trans. Knowl. Data Eng. 29(4), 856–869 (2016) 4. Bonifati, A., Fletcher, G., Voigt, H., Yakovets, N.: Querying graphs. Synth. Lect. Data Manag. 10(3), 1–184 (2018) 5. Bonifati, A., Martens, W., Timm, T.: Navigating the maze of wikidata query logs. In: The World Wide Web Conference, pp. 127–138 (2019) 6. Buil-Aranda, C., Hogan, A., Umbrich, J., Vandenbussche, P.Y.: Sparql webquerying infrastructure: ready for action? In: International Semantic Web Conference, pp. 277–293 (2013) 7. Grall, A., Minier, T., Skaf-Molli, H., Molli, P.: Processing sparql aggregate queries with web preemption. In: European Semantic Web Conference, pp. 235–251 (2020) 8. Hartig, O., Letter, I., P´erez, J.: A formal framework for comparing linked data fragments. In: International Semantic Web Conference, pp. 364–382 (2017) 9. Hasnain, A., Mehmood, Q., Zainab, S.S., Hogan, A.: Sportal: profiling the content of public sparql endpoints. Int. J. Semant. Web Inf. Syst. (IJSWIS) 12(3), 134–163 (2016) 10. Minier, T., Skaf-Molli, H., Molli, P.: Sage: Web preemption for public sparql query services. In: The World Wide Web Conference, pp. 1268–1278 (2019) 11. Polleres, A., Kamdar, M.R., Fern´ andez, J.D., Tudorache, T., Musen, M.A.: A more decentralized vision for linked data. In: 2nd Workshop on Decentralizing the Semantic Web (DeSemWeb 2018) co-located with ISWC 2018 (2018) 12. Reutter, J.L., Soto, A., Vrgoˇc, D.: Recursion in sparql. In: International Semantic Web Conference, pp. 19–35 (2015) 13. Russell, S.J., Norvig, P.: Artificial Intelligence - A Modern Approach. Prentice Hall series in artificial intelligence, 2nd edn. Prentice Hall, Upper Saddle River (2003) 14. Steve, H., Andy, S.: SPARQL 1.1 query language. In: Recommendation W3C (2013). https://www.w3.org/TR/sparql11-query 15. Taelman, R., Van Herwegen, J., Vander Sande, M., Verborgh, R.: Comunica: a modular sparql query engine for the web. In: International Semantic Web Conference, pp. 239–255 (2018) 16. Udupa, A., Desai, A., Rajamani, S.: Depth bounded explicit-state model checking. In: International SPIN Workshop on Model Checking of Software, pp. 57–74 (2011) 17. Verborgh, R., et al.: Triple pattern fragments: a low-cost knowledge graph interface for the web. J. Web Semant. 37, 184–206 (2016)
Ontology-Based Map Data Quality Assurance Haonan Qiu1,2(B) , Adel Ayara1 , and Birte Glimm2 1
2
BMW Car IT GmbH, Ulm, Germany {haonan.qiu,adel.ayara}@bmw.de Institute of Artificial Intelligence, University of Ulm, Ulm, Germany [email protected]
Abstract. A lane-level, high-definition (HD) digital map is needed for autonomous cars to provide safety and security to the passengers. However, it continues to prove very difficult to produce error-free maps. To avoid the deactivation of autonomous driving (AD) mode caused by map errors, ensuring map data quality is a crucial task. We propose an ontology-based workflow for HD map data quality assurance, including semantic enrichment, violation detection, and violation handling. Evaluations show that our approach can successfully check the quality of map data and suggests that violation handling is even feasible on-the-fly in the car (on-board), avoiding the autonomous driving mode’s deactivation. Keywords: Autonomous driving
1
· Digital maps · Ontologies · Rules
Introduction
Autonomous cars act in a highly dynamic environment and consistently have to provide safety and security to passengers. A detailed, high-definition (HD) map is needed for a car to understand its surroundings, which provides lanelevel information to support vehicle perception and highly precise localisation [3]. The creation of a road map involves a series of decisions on how features of the road are to be represented concerning the map scale, level of generalization, projection, datum, and coordinate system. Every step of map creation may introduce an error in one of the map features and Fig. 1 shows a road gap that has been found in a commercially available HD map, which caused a degradation of the autonomous driving (AD) mode and a driver take-over request. Usually, a take-over request is conducted for safety reasons when the AD system is approaching its limits due to, for example, weather conditions. In general, a take-over request is a complex and risky process and should be avoided as much as possible and, in case of map errors, the request is not even related to system limits. Therefore, the goal of our work is to use ontologies and reasoning to find and fix map errors to extend the AD function’s availability. Ensuring (general) data quality with an ontology-based approach has been well-studied recently [6,7,12]. Yilmaz et al. [27,28] have even demonstrated the feasibility c Springer Nature Switzerland AG 2021 R. Verborgh et al. (Eds.): ESWC 2021, LNCS 12731, pp. 73–89, 2021. https://doi.org/10.1007/978-3-030-77385-4_5
74
H. Qiu et al.
Fig. 1. Snap shots of a normal driving scenario without map errors and active AD mode (left-hand side) and an error scenario (right-hand side) with deactivated AD mode and a driver take-over request due to a gap in the road model
of using ontological methods for spatial data quality evaluation. The latter work does, however, not consider map-specific concepts, e.g., lanes and the resulting challenges, and neither are the challenges and possibilities of handling violations considered. We address these challenges and present an ontology-based approach for ensuring map data quality. The main contributions are: – We present a workflow for ensuring map data quality based on OWL 2 RL ontologies [13] and Datalog rules [1]. – We present the develop Map Quality Violation Ontology (MQVO) and a set of constraint rules for violation detection. – We demonstrate violation handling strategies using violation tolerance and resolution. – We evaluate the performance of violation detection and the correctness of violation resolution using RDFox [21] and realistic map data. The rest of this paper is structured as follows: Sect. 2 introduces related work, followed by some preliminaries in Sect. 3. Section 4 describes the workflow consisting of semantic enrichment, violation detection, and violation handling. In Sect. 5, we describe the experimental setup and results, and we conclude in Sect. 6. Additional explanations, rules, available resources and evaluation discussion can be found in an accompanying technical report [22].
2
Related Work
Spatial data quality can be assessed with ontology-based approaches. Mostafavi et al. [18] propose an ontology-based approach for quality assessment of spatial databases. The ontology is encoded in Prolog, and queries are used to determine the existence of inconsistencies. Wang et al. [25] investigate the feasibility of applying rule-based spatial data quality checks over mobile data using the Semantic Web Rule Language (SWRL). The authors show that the system has the capability to warn the data collector if there is any inconsistent data
Ontology-Based Map Data Quality Assurance
75
gathered in the field. Yilmaz et al. [28] created an ontology associated with spatial concepts from the Open Geospatial Consortium and rules implemented as GeoSPARQL queries for detecting inconsistencies. Yilmaz et al. also developed the Spatial Data Quality Ontology together with SWRL rules for performing quality assessment [27]. Huang et al. [14] investigate the feasibility of combining ontologies and semantic constraints modelled in the Shapes Constraint Language (SHACL) for ensuring the semantic correctness of geospatial data from different levels of detail. A number of RDF stores also support geospatial queries and integrity constraints, e.g., Stardog,1 Virtuoso,2 and GraphDB.3 The existing ontology-based approaches, however, focus on general spatial data. Map-related concepts and relationships, such as the relationships among coordinate points, lanes, and roads, are not studied. While SHACL is designed for RDF validation, by checking nodes w.r.t. class axioms or paths w.r.t. property axioms, it cannot describe complex (spatial) relationship constraints, which is crucial for map data. Although SHACL provides validation reports, it does not provide a mechanism (e.g., vocabulary) for fixing errors, while we aim at supporting violation detection and handling in a closed loop.
3
Preliminaries
In this section, we present relevant background for map data, the Resource Description Framework, and rules. 3.1
Map Data
Our work is focused on the Navigation Data Standard (NDS) [20]. Map data is partitioned in to adjacent tiles. They form approximately rectangular territorial sections. The magnification level determines the edge length of a tile. Nodes within a map tile represent a point location on the surface of the Earth by a pair of longitude (y-coordinate) and latitude (x-coordinate) coordinates. Links represent a stretch of road between two nodes and are represented by a line segment (corresponding to a straight section of the road) or a curve having a shape that is generally described by intermediate points called shape points along the link. Shape points are represented by x-y coordinates as nodes, but shape points do not serve the purpose of connecting links, as do nodes. Link and road are synonyms and road has the same meaning as in everyday language use. Links have attributes such as travel direction and types, such as highway. The ordering of the shape points is with respect to the travel direction. The geometry of Lanes is described by shape points too. Lanes are connected via lane connectors. Each lane is described by two lane boundaries with lane marking types (solid/dashed, single/double, etc.). Finally, lanes are organized into lane groups with link references. We refer the interested reader to the literature for further details about HD maps [11,15]. 1 2 3
https://www.stardog.com/. https://virtuoso.openlinksw.com/. https://graphdb.ontotext.com/.
76
3.2
H. Qiu et al.
RDF Graphs
Resource Description Framework (RDF) is a W3C standardised model for data interchange in applications on the Web, where a subject (s) and a object (o) are related with an explicit predicate (p). These simple s-p-o statements can be seen as a directed, labelled (knowledge) graph. We formally introduce RDF graphs as follows: Definition 1 (RDF Graph [5]). Let I, L, and B be pairwise disjoint infinite sets of IRIs, literals, and blank nodes, respectively. A tuple (s, p, o) ∈ I ∪ B × I × (I ∪ L ∪ B) is called an RDF triple, where s is the subject, p is the predicate, and o is the object. An RDF graph G is finite set of RDF triples and induces a set of vertices V = {s | (s, p, o) ∈ G} ∪ {o | (s, p, o) ∈ G}. On top of RDF, we use the RL (rule language) profile of the Web Ontology Language (OWL) [13] and custom Datalog rules [1] (RDFox syntactic variant) to model complex knowledge and to infer, in particular, spatial relationships. 3.3
Rules
For defining such Datalog rules, we fix countable, disjoint sets of constants and variables. A term is a constant or a variable. An atom has the form P (t1 , . . . , tk ), where P is a k-ary predicate and each ti , 1 ≤ i ≤ k, is a term. We focus on unary and binary atoms only (i.e., 1 ≤ k ≤ 2), which correspond to classes and properties of the ontology, respectively. An atom is ground if it does not contain variables. A fact is a ground atom and a dataset is a finite set of facts, e.g., as defined in an ontology. A Datalog rule is a logical implication of the form H1 , . . . , Hj ← B1 , . . . , Bk , where each Hi , 1 ≤ i ≤ j, is a head atom, and each B , 1 ≤ ≤ k, is a body atom. A Datalog program is a finite set of rules. A negative body atom has the form, NOT EXISTS v1 , . . . , vj IN B, where each vi , 1 ≤ i ≤ j, is a variable and B is an atom. A rule r is safe if variables that appear in the head or in a negative body atom also appear in a positive body atom. A safe Datalog rule can be extended with stratified negation by extending the rule to have negative body atoms, where there is no cyclic dependency between any predicate and a negated predicate. An aggregate is a function that takes a multiset of values as input and returns a single value as output. An aggregate atom has the form Aggregate(B1 , . . . , Bk ON x1 , . . . , xj BIND f1 (e1 ) AS r1 . . . BIND fn (en ) AS rn ), where each Bi , 1 ≤ i ≤ k, is an atom, each xu , 1 ≤ u ≤ j, is a variable that appears in Bi , each fv , 1 ≤ v ≤ n, is an aggregate function, each ew , 1 ≤ w ≤ n, is an expression containing variables from Bi , and each rz , 1 ≤ z ≤ n, is a constant for a variable that does not appear in Bi .
4
Ensuring Map Data Quality
In this section, we present the workflow of ensuring map data quality consisting of: (i) semantic enrichment, (ii) violation detection, and (iii) violation handling (see Fig. 2). We next describe these steps in more detail.
Ontology-Based Map Data Quality Assurance
77
Fig. 2. Workflow diagram of ensuring map data quality
Fig. 3. An HD map ontology based on NDS (partial rendering)
4.1
Semantic Enrichment
We adopt the concept of semantic enrichment [10] and use a set of rules for inferring spatial semantics, e.g., start/end points and direct lane successors. This allows us to express complex spatial relationships, which are the basis for the subsequent violation detection and handling process. We modelled an HD map ontology based on the NDS specification for describing the map entities as shown in Fig. 3. The rules can be categorised into: (1) primitive rules, (2) bounding rules, (3) coordinate distance rules, and (4) topological rules: (1) Primitive rules enrich instances with one-step inferences regarding relationships and attributes and their results serve as input for all other rules. For a concrete example consider: hasLane(x, y) ← LaneGroup(x), laneGroupId(x, i), Lane(y), laneGroupId(y, i). (2) Bounding rules infer the boundaries of an area or the range of a lane or road, such as a start/end shape point of a lane or the left or right-most lane. As a concrete example, consider: StartShapePoint (z) ← Lane(l), AGGREGATE(hasShapePoint(l, p), index(p, idx) ON l BIND MIN(idx) AS m), hasShapePoint(l, z), index(z, m).
AGGREGATE takes the matches for hasShapePoint(l, p) and index(p, idx) as input and groups them based on the lane l. The aggregation function MIN then selects the minimal index per group and assigns this value to m using BIND.
78
H. Qiu et al.
Fig. 4. Classes and properties in MQVO
Since there is no suitable aggregate function for selecting the point for the index m, it remains to get the point z that has the index m. (3) Coordinate distance rules indicate the distance between two points using coordinates. An auxiliary concept (CoordinateDistance) represents the ternary relation that connects the source point to the target point via two object properties hasSource and hasTarget and the calculated distance value via the data property distance: CoordinateDistance(d), hasSource(d, s), hasTarget(d, t), distance(d, z) ← ShapePoint(s), x(s, xs ), y(s, ys ), ShapePoint(t), x(t, xt ), y(t, yt ), BIND(sqrt((xs − xt )2 + (ys − yt )2 ) AS z), BIND(SKOLEM("d", s, t) AS d). The SKOLEM function allows for dynamically generating “fresh” IRIs [5] based on the string "d" and the variable bindings for s and t. (4) Topology rules refer to topological relations, more specifically, lateral (left/right) and longitudinal (predecessor/successor) relations. Connectivity can naturally be expressed using recursive rules. The base case (one-step connectivity) is usually inferred based on a pre-defined connectivity reference. For example, the hasDirectNext relation over lanes is defined based on source and destination connectors, while for links, it is defined by comparing the coordinates of start and end points of links. 4.2
Violation Detection
We developed the Map Quality Violation Ontology (MQVO) and a set of spatial constraint rules to detect violations after the enrichment process. The MQVO describes the type of violation, the affected objects, the severity level, etc. and provides information to guide the subsequent violation handling process. The spatial constraint rules are classified into (1) topology, (2) geometry and (3) attribute checking rules. We first describe MQVO, then we introduce the three types of constraint checking rules. Map Quality Violation Ontology. We developed MQVO to describe map data errors since, to the best of our knowledge, there are no ontologies for the
Ontology-Based Map Data Quality Assurance
79
Table 1. Constraint axioms as Datalog Constraint Atoms (DCA). We use C for classes, op for object, dp for data, and p for object or data properties. OWL Axiom
Datalog Constraint Atom (DCA)
Existential quantification Individual value restriction Literal value restriction HasKey Min () Cardinality restriction
C(x), NOT EXISTS y IN (C(y), p(x, y)) C(x), NOT op(x, individual) C(x), NOT dp(x, literal) C(x), dp(x, z), C(y), dp(y, z), FILTER(x = y) C(x), AGGREGATE(p(x, v) ON x BIND count(v) AS n), FILTER(n max), ∈ {>, p then Lg = Lg ∪ {us ve } ; // gap at the start if ve < q then Lg = Lg ∪ {ue ve } ; for i = 1 . . . n − 1 do uv = getDirectNext(ui vi ) ; if vi < u then Lg = Lg ∪ {ui vi , uv} ; else if vi > u then Lo = Lo ∪ {ui vi , uv} ;
// gap at the end // apply topology rules // gap in the middle // overlapping
and Herring [9]. In this paper, we model full coverage constraints, checking if a set of other map objects fully covers a given map object. For example, a link should be fully covered by a set of lane groups. To describe such constraints, we first introduce some basic notations. Definition 2. A line (segment) pq is defined by its start point p and its end point q, where p = q. A (base) line pq is fully covered by a sequence of lines u1 v1 . . . un vn if p = u1 , q = vn , and vi = ui+1 for each 1 ≤ i < n, where ui = vi . We say that there is a gap at the start if p < u1 , a gap at the end if vn < q, a gap in the middle if vi < ui+1 for some 1 ≤ i < n, and there is an overlapping if vi > ui+1 for some 1 ≤ i < n. Algorithm 1 presents the pseudo-code of full coverage checking. Given a base line pq and a sequence of line segments L without self-loops, the algorithm first identifies the start and end segment in L (lines 2–3) using bounding rules. The algorithm checks if there is a gap at the start or end w.r.t. the base line (lines 4– 7). At last, it iterates through the given line segments and, for each segment, it gets the direct next line segment (line 9) through topology rules, checks if there is any gap in the middle (lines 8–10) or any overlapping (lines 11–12). (2) Geometry Checking Rules are designed to check the geometric representation of links (lanes). The link (lane) model uses an ordered sequence of shape points describing the geometry of a polyline that represents a link (lane). We further subdivide geometry checking rules into cardinality and geometric accuracy checking rules. Cardinality checking rules use minimum or maximum cardinality restrictions in VRRTs. Geometric accuracy is checked via coordinate proximity using distance thresholds [8] to account for different levels of accuracy and
Ontology-Based Map Data Quality Assurance
81
precision [29] in the collected map data. The following rule, where we abbreviate hasAffectedObject as hao, illustrates the case of checking a radius distance threshold of geometric points in two connected lanes. Violation(v), hao(v, up ), hao(v, vq ), hasReason(v, ”GeometryError”) ← Lane(p), Lane(q), hasDirectNext(p, q), endPoint(p, up ), startPoint(q, vq ), CoordinateDistance(c), hasSource(c, q), hasTarget(c, p), distance(c, d), Threshold(t), hasValue(t, vt ), FILTER(d > vt ), BIND(SKOLEM("d", up , vq ) AS v). (3) Attribute Accuracy Checking Rules are used to check if the recorded attributes of map data representing real-world entities are correct and consistent. The attributes could be feature classifications, text information for feature names, or descriptions, and they ought to be consistent with each other. For example, if a road is classified as a motorway, it should also have a controlledaccess designed for high-speed vehicular traffic. Controlled-access is modelled as a data property with a Boolean value. Hence, the corresponding violation detection rule can be modelled using a literal value restriction in the VRRT. 4.3
Violation Handling
Violations are handled based on the severity level. If a critical violation is detected during the map pre-loading phase, the autonomous driving mode is switched off, and control is handed over to the driver in the corresponding region. For non-critical violations, we rely on violation tolerance and violation resolution strategies considering the spatial relations. Violation tolerance is feasible because errors in the low-level (raw) data do not necessarily affect the decision taken at the knowledge (human-perceivable) level in intelligent systems [26]. In cases where the violations cannot be tolerated, spatial knowledge, e.g., topological relations, can be used to resolve violations [2,17]. These strategies allow us to support autonomous driving applications, even in the presence of low-level data errors. We apply graph aggregation [16] for violation tolerance and decomposition [4] for violation resolution to achieve knowledge level consistency. Essentially, these strategies take advantage of graph structure similarity, which is captured by the notion of isomorphisms : Definition 3 (RDF Graph Isomorphism [5]). Let G1 and G2 be RDF graphs with V1 , V2 the induced vertices of G1 and G2 , respectively. We say that G1 and G2 are isomorphic, if there is a bijection μ : V1 → V2 such that μ(b) ∈ B for each b ∈ V1 ∩ B, μ() ∈ L for each ∈ V1 ∩ L, μ(v) ∈ I for each v ∈ V1 ∩ I, and, for each triple (s, p, o) ∈ G1 , (μ(s), p, μ(o)) ∈ G2 . We call such μ an isomorphism between G1 and G2 . Based on isomorphism, we introduce graph aggregation and its use for violation tolerance. Apart from its use in violation tolerance, graph aggregation is
82
H. Qiu et al.
Fig. 5. A violation-free example of RDF graph aggregation over lanes
helpful in itself to obtain a higher-level view of the map data, with a focus on the details that are important for autonomous driving. Definition 4 (RDF Graph Aggregation). Let G1 , G2 , and G be RDF graphs with vertices V1 , V2 , and V , respectively, such that G1 is isomorphic to G2 witness by the isomorphism μ. A (partial) function α : V1 ∪V2 → V is an abstraction function w.r.t. G1 , G2 , and G if, for each v ∈ V , there are nodes v1 ∈ V1 and v2 ∈ V2 such that μ(v1 ) = v2 and α(v1 ) = α(v2 ) = v. If an abstraction function w.r.t. G1 , G2 , and G exists, we call G an aggregation graph of G1 and G2 . We generalise the notion of an abstraction graph to a set of pairwise isomorphic graphs G1 , . . . , Gn in a natural way. Figure 5 shows an example where we apply graph aggregation over lanes of two lane groups with ID 1 and 2. We abbreviate lane as l, laneGroup as lg, and link as lk, e.g., l11 stands for lane11. Subfigure (a) shows a map visualisation, while (b) shows the corresponding graph representation, and the aggregation is shown in the upper part. Note that the mapping with a dotted line shows the isomorphism between graph A and graph B (we omit the mapping for identical values such as a mapping from true in graph A to true in graph B). The dashed lines show the abstraction function, where we again omit identical value mappings. The abstraction function only maps the lanes (l11 in graph A and l21 in graph B) as well as the lane index and direction attribute. The lane aggregation aligns with the human perception of l11 and l21 as one continuous lane. (1) Violation Tolerance. Figure 6 shows an example with a violation, which consists of a duplicate lane group ID. More precisely, lg1 and lg2 both have ID 1 in the map data. As a result of this, the map data is parsed as containing just one lane group (with ID 1), which also causes l11 and l21 to be considered equal as they both have ID 1 and belong to the lane group with ID 1. Hence, we get identical RDF graphs for l11 (graph A) and l21 (graph B), which is a special case of RDF graph isomorphism. Applying the abstraction function (as in Fig. 6, dashed line) results, however, in the same (correct) aggregation graph (graph C) as for the violation-free scenario shown in Fig. 5. Hence, the RDF graph aggregation can tolerate some data errors.
Ontology-Based Map Data Quality Assurance
83
Fig. 6. An example of lane aggregation with lane group ID uniqueness violation
Fig. 7. A example of lane ambiguity caused by lane group ID duplication.
(2) Violation Resolution. We illustrate how violations can be resolved (in particular, lane ambiguity) using graph decomposition. Definition 5 (RDF Graph Decomposition). An RDF decomposition of an RDF graph G is a collection of edge-disjoint, isomorphic subgraphs G1 , . . . , Gn of G such that every edge of G belongs to exactly one Gi , 1 ≤ i ≤ n. We denote ˆ = {G1 , G2 , . . . , Gn }. such a decomposition of G as G Figure 7 shows an example of lane ambiguity also caused by a lane group ID duplication. Subfigure (a) shows a normal map visualisation of lg1 and lg2 located in separate roads. Subfigure (b) shows the graph representation resulting from a duplicate ID of lg1 and lg2 which causes l11 and l21 to merge into one lane instance having both lanes’ spatial relationships, such as associated points, links and successor lanes. Based on the graph structure of the ambiguous graph, there exists a mapping between subgraph A and B, which indicates the application of RDF decomposition. Hence, we apply RDF graph decomposition to fix the topology and distance measurements to restore geometry. Figure 8 shows the concrete steps: (1) violation detection, (2) topology correction, and (3) assignment of geometric points.
84
H. Qiu et al.
Fig. 8. Lane ambiguity violation resolution steps
In Step 1, a topology violation is detected if a lane group is associated with two disconnected links. This is modelled by checking the existence of a connection between links associated to a lane group using an existential qualification in a VRRT, and an instance of LaneViolation is generated having topology (an instance of class Topology) as its QualityParameter. In Step 2, the topology correction is achieved via graph decomposition and relationship establishment. The original graph of l11/21 can be decomposed into isomorphic subgraphs A and B. Two new lane instances (nl1 and nl2) are generated with the correct topological relationships. NewLane(l), hasFeature(n, f ), hasDirectNext(l, n), hasOriginalLane(l, m) ← LaneViolation(v), hasQualityParameter(v, topology), hao(v, m), hasLane(lg1 , m), isOn(lg1 , f ), LaneGrp(lg2 ), hasLane(lg2 , n), isOn(lg2 , f ), hasDirectNext(m, n), index(m, i), BIND(SKOLEM("d", f, i) AS l) In Step 3, geometric shape point assignment is achieved via a point grouping strategy which compares the distance from each shape point of the lane to the first and last shape point of the lane associated links. The shape points are then grouped if the difference between the calculated distance and the links’ length is within a threshold, e.g., 10 m. hasPossibleLanePoint(f, p) ← LaneViolation(v), hasQualityParameter(v, topology), hao(v, l), hasShapePoint(l, p), hasFeature(l, f ), length(f, n), hasFirstShapePoint(f, u), hasLastShapePoint(f, v), CoordinateDistance(d1 ), hasSource(d1 , p), hasTarget(d1 , u), distance(d1 , t1 ), CoordinateDistance(d2 ), hasSource(d2 , p), hasTarget(d2 , v), distance(d2 , t2 ), FILTER(ABS((t1 + t2 ) − n) < 10).
Ontology-Based Map Data Quality Assurance
85
While assigning the point groups to correct new lanes, geometric point grouping is verified by comparing the number of points in each group to the total number of points of the original lane to prevent wrong point group assignments. hasShapePoint(n, p) ← NewLane(n), hasOriginalLane(n, l), numPoints(l, u), hasFeature(n, f ), hasPossibleLanePoint(f, p), numPossibleLanePoints(f, m), FILTER(m < u).
5
Evaluation
Tile-based map data is stored as Binary Large Object (BLOB) in an NDS map database. We use SQLite Python APIs to extract map data and construct RDF triples based on the HD map ontology (see Fig. 3). We have implemented the proposed workflow of ensuring map data quality into an application called SmartMapApp using RDFox 4.0.0 as reasoner. The evaluation was performed on a 64-bit Ubuntu virtual machine with 8 Intel(R) Core(TM) i7-8550U CPU @ 1.80 GHz running at 33 MHz with 15 GB memory. We first show the performance of semantic enrichment and violation detection and then we evaluate the correctness of violation handling. 5.1
Violation Detection
We used 10 adjacent real map tiles along Federal Motorway 92 (Bundesautobahn 92) in Germany for violation detection evaluation, and record the computation time after doing a warm-up run by executing the tasks 3 times sequentially . Semantic enrichment is performed via 42 rules and violation detection consists of 37 rules (see Table 2). The result of the two phases is summarised in Fig. 9. The computation time for both phases increases with respect to the data size. The average number of input triples is 146, 182, the average execution time of semantic enrichment is 1, 584 ms, and the average execution time of violation detection is 197 ms. 5.2
Violation Handling
We consider the use case of lane group ID uniqueness violations to evaluate violation handling strategies. We show the result of violation tolerance over the error on a high way described in Fig. 1 (see Sect. 1), and violation resolution over an error on separated roads. At last, we discuss the evaluation results.
86
H. Qiu et al.
Fig. 9. Performance of semantic enrichment and violation detection over real map data; the left-hand side scale shows the execution time for semantic enrichment (dots on a solid line) and violation detection (diamonds on a dotted line) in seconds; the number of input triples is shown in form of bars using the scale on the right-hand side Table 2. Number of rules used for semantic enrichment and violation detection Semantic enrichment rules
Violation detection rules
Primitive rules
15 Topology checking rules
10
Bounding rules
14 Geometry checking rules
14
Coordinate distance rules
3 Attribute accuracy checking rules 13
Topology rules
10 Total
Total
42
37
Violation Tolerance. The error in Fig. 1 occurred in the map data containing a highway in Germany. Part of this highway is represented as five continuous lane groups with the same number of lanes. Two of the lane groups have the same ID, which caused the degradation of the autonomous driving mode. We applied graph aggregation over both the ground truth and dirty data. The lane aggregation results agree on both inputs, which shows that the lane group ID issue can be solved (see Table 3). Violation Resolution. We evaluated the resolution strategy over two lane groups containing only one lane allocated to different links. The ID duplication caused the lanes in these two lane groups to be merged into one lane. Table 4 shows the result of applying graph decomposition over the dirty data. Row 2 (dirty data) shows that the lane is ambiguous as it has the length, number of shape points, successors, and related links of both lanes. Row 3 shows that the graph decomposition can resolve the error and all lane properties are correctly recovered. Overall, the results demonstrate that our approach can improve map data quality, resulting in a better error-tolerance of AD systems. On the one hand, the performance of the violation detection allows the deployment of the proposed solution in the back-end (cloud side) to check the map data before sending it to the car or on-board (embedded side, in the car) in case of loss of connectivity
Ontology-Based Map Data Quality Assurance
87
Table 3. The violation tolerance over a lane using graph aggregation, both ground truth and dirty data are aggregated results Lane
Length (m) #Points Successor Link
Ground truth BE9D6 2034
54
563E
02
Dirty data
54
563E
02
BE9D6 2034
Table 4. The violation resolution of a lane using graph decomposition Lane
Length (m) #Points Successor
Ground truth
1116 0 358
Dirty data
1116 0 214, 358
Resolved violation 1116 0 358
14
1117 0
Link 199
5, 14
1117 0, 1188 0 199, 197
14
1117 0
199
with the back-end. On the other hand, the evaluation of the violation handling strategies has shown that we could avoid the deactivation of the AD mode by detecting the error and correcting the map data in both cases of the lane group error. The cost of reasoning generally depends not only on the number of rules but also on the complexity of the combination of certain rules and the input data. For details of how RDFox performs reasoning, we refer interested readers to the description of the materialization algorithm in RDFox [19].
6
Conclusion and Future Work
In this paper, we present an ontology-based approach for ensuring map data quality. We propose a workflow considering semantic enrichment, violation detection and violation handling. Semantic enrichment is achieved via a set of rules combined with an HD map ontology and the results provide the needed spatial knowledge for violation detection and handling. Violation detection is modelled via the novel Map Quality Violation Ontology and suitable constraint violation rules. At last, we show novel violation handling strategies over non-critical violations using graph aggregation and graph decomposition. We evaluate the performance of violation detection and the correctness of violation handling. The results show that our approach can successfully check the quality of map data and suggests that violation handling is even feasible on-the-fly in the car (on-board), avoiding the autonomous driving mode’s deactivation. We plan to integrate this approach into the developed knowledge-spatial architecture [23], and test the approach in ROS (Robot Operating System) [24], which requires a re-implementation of the Java-based SmartMapApp in C++.
References 1. Abiteboul, S., Hull, R., Vianu, V.: Foundations of Databases, vol. 8. AddisonWesley, Reading (1995)
88
H. Qiu et al.
2. Ai, T., Yang, M., Zhang, X., Tian, J.: Detection and correction of inconsistencies between river networks and contour data by spatial constraint knowledge. Cartogr. Geogr. Inf. Sci. 42(1), 79–93 (2015) 3. Armand, A., Ibanez-Guzman, J., Zinoune, C.: Digital maps for driving assistance systems and autonomous driving. In: Watzenig, D., Horn, M. (eds.) Automated Driving, pp. 201–244. Springer, Cham (2017). https://doi.org/10.1007/978-3-31931895-0 9 4. Arumugam, S., Hamid, I., Abraham, V.: Decomposition of graphs into paths and cycles. J. Discrete Math. 2013, 721051 (2013) 5. Cyganiak, R., Wood, D., Lanthaler, M.: RDF 1.1 Concepts and abstract syntax-3. RDF graphs. https://www.w3.org/TR/rdf11-concepts/ (2014). Accessed 14 Sep 2020 6. De Meester, B., Heyvaert, P., Arndt, D., Dimou, A., Verborgh, R.: RDF graph validation using rule-based reasoning. Semant. Web J. 12, 117–142 (2020) 7. Debattista, J., Lange, C., Auer, S.: daQ, an ontology for dataset quality information. In: Linked Data on the Web (LDOW) (2014) 8. Devillers, R., Jeansoulin, R., Goodchild, M.F.: Fundamentals of Spatial Data Quality. ISTE, London (2006) 9. Egenhofer, M.J., Herring, J.: TheCategorizing binary topological relations between regions, lines, and points in geographic databases. The 9(94–1), 76 (1990) 10. Eiter, T., F¨ ureder, H., Kasslatter, F., Parreira, J.X., Schneider, P.: Towards a semantically enriched local dynamic map. Int. J. Intell Transp. Syst. Res. 17(1), 32–48 (2019) 11. Gran, C.W.: HD-Maps in autonomous driving. Master’s thesis, NTNU (2019) 12. Heyvaert, P., Dimou, A., De Meester, B., Verborgh, R.: Rule-driven inconsistency resolution for knowledge graph generation. Semant. Web J. 10, 1071–1086 (2019) 13. Hitzler, P., Kr¨ otzsch, M., Parsia, B., Patel-Schneider, P.F., Rudolph, S.: OWL 2 Web Ontology Language: Prime, 2nd edn. http://www.w3.org/TR/owl2-primer/ (27 October 2009) 14. Huang, W.: Knowledge-based geospatial data integration and visualization with semantic web technologies. In: 2019 Doctoral Consortium at the 18th International Semantic Web Conference (ISWC-DC 2019), vol. 2548, pp. 37–45. CEURWS (2019) 15. Liu, R., Wang, J., Zhang, B.: High definition map for automated driving: overview and analysis. J. Navigat. 73(2), 324–341 (2020) 16. Maali, F., Campinas, S., Decker, S.: Gagg: A Graph Aggregation Operator. In: Gandon, F., Sabou, M., Sack, H., d’Amato, C., Cudr´e-Mauroux, P., Zimmermann, A. (eds.) ESWC 2015. LNCS, vol. 9088, pp. 491–504. Springer, Cham (2015). https://doi.org/10.1007/978-3-319-18818-8 30 17. Majic, I., Naghizade, E., Winter, S., Tomko, M.: Discovery of topological constraints on spatial object classes using a refined topological model. J. Spatial Inf. Sci. 2019(18), 1–30 (2019) 18. Mostafavi, M.A., Edwards, G., Jeansoulin, R.: An ontology-based method for quality assessment of spatial data bases. In: Third International Symposium on Spatial Data Quality. Geoinfo Series, vol. 1/28a, pp. 49–66 (April 2004) 19. Motik, B., Nenov, Y., Piro, R., Horrocks, I., Olteanu, D.: Parallel materialisation of datalog programs in centralised, main-memory rdf systems. In: Proceedings of the Twenty-Eighth AAAI Conference on Artificial Intelligence (AAAI’2014 ), pp. 129–137. AAAI Press (2014) 20. NDS Association: The standard for map data. https://nds-association.org/. Accessed 27 May 2020
Ontology-Based Map Data Quality Assurance
89
21. Nenov, Y., Piro, R., Motik, B., Horrocks, I., Wu, Z., Banerjee, J.: RDFox: A Highlyscalable RDF store. In: The Semantic Web - ISWC 2015. pp. 3–20 (2015) 22. Qiu, H., Ayara, A., Glimm, B.: Ontology-Based Map Data Quality assuranceTechnical Report. https://cloudstore.uni-ulm.de/s/ftSSDmdnbfx35R7 (2020) 23. Qiu, H., Ayara, A., Glimm, B.: Ontology-based processing of dynamic maps in automated driving. In: 12th International Joint 2020 Conference on Knowledge Discovery, Knowledge Engineering and Knowledge Management, vol. 2. SCITEPRESS (in press) 24. Quigley, M., et al.: ROS: an open-source Robot Operating System. In: ICRA Workshop on Open Source Software, vol. 3, p. 5 (2009) 25. Wang, F., M¨ as, S., Reinhardt, W., Kandawasvika, A.: Ontology based quality assuranc e for mobile data acquisition. In: EnviroInfo. pp. 334–341 (2005) 26. Xu, X., Huang, H.H.: Exploring data-level error tolerance in high-performance solid-state drives. IEEE Trans. Reliabil 64(1), 15–30 (2014) 27. Yilmaz, C., Comert, C., Yildirim, D.: SDQO and sfQ, ontologies for spatial data quality. IN: ISPRS - International Archives of the Photogrammetry, Remote Sensing and Spatial Information Sciences XLII-2/W13, pp. 1275–1280 (2019) 28. Yilmaz, C., C¨ omert, C ¸ .: Ontology based quality evaluation for spatial data. Int. Arch. Photogram. Remote Sens. Spatial Inf. Sci. 40, 95–99 (2015) 29. Zheng, L., Li, B., Yang, B., Song, H., Lu, Z.: Lane-level road network generation techniques for lane-level maps of autonomous vehicles: a survey. Sustainability 11(16), 4511 (2019)
Knowledge Graphs (Understanding, Creating, and Exploiting)
Applying Grammar-Based Compression to RDF Michael R¨oder1,2(B) , Philip Frerk1 , Felix Conrads1 , and Axel-Cyrille Ngonga Ngomo1,2 1
DICE Group, Department of Computer Science, Paderborn University, Paderborn, Germany {michael.roeder,axel.ngonga}@upb.de 2 Institute for Applied Informatics, Leipzig, Germany
Abstract. Data compression for RDF knowledge graphs is used in an increasing number of settings. In parallel to this, several grammar-based graph compression algorithms have been developed to reduce the size of graphs. We port gRePair— a state-of-the-art grammar-based graph compression algorithm—to RDF (named RDFRePair). We compare this promising technique with respect to the compression ratio to the state-of-the-art approaches for RDF compression dubbed HDT, HDT++ and OFR as well as a k2 -trees-based RDF compression. We run an extensive evaluation on 40 datasets. Our results suggest that RDFRePair achieves significantly better compression ratios and runtimes than gRePair. However, it is outperformed by k2 trees, which achieve the overall best compression ratio on real-world datasets. This better performance comes at the cost of time, as k2 trees are clearly outperformed by OFR w.r.t. compression and decompression time. A pairwise Wilcoxon Signed Rank Test suggests that while OFR is significantly more time-efficient than HDT and k2 trees, there is no significant difference between the compression ratios achieved by k2 trees and OFR. In addition, we point out future directions for research. All code and datasets are available at https://github.com/dice-group/GraphCompression and https://hobbitdata. informatik.uni-leipzig.de/rdfrepair/evaluation datasets/, respectively. Keywords: RDF compression · Graph compression · Benchmarking
1 Introduction The first prominent use of data compression can be traced back to the 19th century with works such as the Morse code, which uses a precursor of entropy-based compression by assigning shorter codes to high-frequency letters [16]. Data compression is now used in an ever growing number of settings, especially due to the steadily increasing size of application-relevant datasets [7, 8, 10, 12, 15, 17]. This holds in particular for RDF knowledge graphs, which grow continuously in both number and sheer size [10]. The need for compressing RDF data has hence fueled a considerable body of research. RDF compression algorithms achieve better compression ratios than humanreadable compact RDF representations (e.g., Turtle [3], Notation-3 [4]) by serializing RDF data in a manner which still allows for querying. The wide range of available c Springer Nature Switzerland AG 2021 R. Verborgh et al. (Eds.): ESWC 2021, LNCS 12731, pp. 93–108, 2021. https://doi.org/10.1007/978-3-030-77385-4_6
94
M. R¨oder et al.
approaches spans algorithms implemented directly in storage solutions [2] over algorithms able to exploit the semantics of RDF knowledge graphs [12, 15] to syntax-based compression techniques [8, 10]. Most of these approaches abide by the general concept of separating an RDF graph into three different parts [8]: a header, a dictionary and a representation of the triples. The header contains general statistical information. Since it is not necessary for the decompression of the RDF graph, we will not further take it into consideration throughout the rest of this paper. The dictionary maps the URIs and literal values of the graph to ids. These ids are used within the triples file for a space-efficient representation. This general concept is wide spread when it comes to the compression of RDF graphs [8, 10]. The graph processing community has also been aware of the need for compression and has developed a range of approaches ranging from tree-based strategies [5] to techniques based on automatically generated graph context-free grammars [13]. Especially the latter work of Maneth et al. attracted our interest since the authors implemented a prototypical compressor and evaluated it on different types of graphs (including some RDF graphs). Based on a comparison with a k 2 -trees-based compression they conclude that “o]ver RDF graphs [...] our compressor gives the best results, sometimes factors of several magnitudes smaller than other compressors” [13]. However, no previous work has addressed the concrete task of porting and comparing the current state of the art in grammar-based graph compression with the current reigning RDF compression algorithms. We address exactly this research gap. In this paper, we port one of the currently best performing graph compression approaches, i.e., gRePair [13] and adapt it to RDF knowledge graphs. In addition, we develop an efficient implementation of k 2 trees [1, 5] for RDF. The resulting approaches are compared with HDT, HDT++ and OFR in a large-scale evaluation over 40 datasets w.r.t. their runtime and compression ratio. Our results suggest that OFR and k 2 trees achieve comparable results and outperform other RDF compression approaches significantly with respect to compression ratio—including gRePair. Our result analysis unveils more efficient dictionary compression approaches yield the potential for better RDF compression ratios. A comparison with respect to query execution performance is not part of this paper. In the following section, we present related work. Section 3 comprises preliminaries before our approach is described in Sect. 4. We describe our evaluation and report results in Sect. 5 before we conclude in Sect. 6.
2 Related Work The existing compression algorithms for RDF data can be separated into two groups— syntactic compression algorithms and semantic compression algorithms. A syntactic compression takes the given RDF graph and uses an economical syntax to encode its information. For example, Fer´nandez et al. [8] present the HDT compression.1 It is an implementation of a dictionary and several triple representations. The dictionary reduces the space needed to store the URIs by using a prefix tree. The most efficient 1
https://www.w3.org/Submission/HDT/.
Applying Grammar-Based Compression to RDF
95
triple representation groups triples by their subject and after that by their predicate. The ´ grouped triples are represented by using id arrays and bitsets. Alvarez-Garc´ ıa et al. [1, 2] the k 2 -triples approach that uses k 2 trees to store triples to ensure that even large RDF graphs can be handled by in-memory data stores. However, the authors do not compare the approach with other RDF graph compression approaches. Similar to k 2 -triples, Wang et al. [18] proposes the usage of octrees to compress the representation of triples. Their evaluation shows that this approach achieves better compression ratios than HDT for 4 example datasets. However, to the best of our knowledge the implementations of k 2 -triples and octrees are not publicly available. Hern´andez-Illera et al. [10] extend HDT to HDT++ by using predicate families, i.e., combinations of predicates that cooccur very often. Instead of storing the predicate ids for each of these triples, HDT++ stores the id of the predicate family together with the object ids. The evaluation shows that especially for highly structured datasets, HDT++ achieves better compression ratios than HDT. For 3 out of the 4 datasets used for the evaluation, HDT++ outperforms a k 2 tree-based compression. The Objects-First Representation (OFR) presented by Swacha et al. [17] uses a two-staged algorithm. In the first stage, the dictionary and the triples are compressed. Instead of a single dictionary, the algorithm uses several indexes that handle different parts like subject, predicate or object URIs, subject or object names, or literals. The triples are represented as object, subject, predicate tuples and subsequently sorted in ascending order, thus allowing the usage of a delta encoding for the objects. This means that only one bit is necessary to encode whether the object of a triple remains the same as the object of the previous triple or whether its ID is increased by 1. The encoding of the subject follows a similar idea with a special handling of large deltas between the IDs. The predicate IDs are encoded as usual numbers. In the second stage of the algorithm, a general compression algorithm is applied. Depending on the data, the first step uses different output streams to write the data. The authors argue that this allows the second-stage algorithm to find more patterns within streams that contain similar data. In their evaluation, the authors show that using either the Deflate or the LZMA algorithm in the second stage outperforms the HDT algorithm using the same algorithms as a post processing. However, the usage of general compression algorithms prevents the execution of queries on the compressed dataset. The group of semantic compression algorithms aims at the reduction of the number of triples that need to be stored by replacing repetitive parts of the graph. A general approach to the reduction of graphs are grammar-based compressions. Maneth et al. [13] propose the gRePair algorithm. The approach searches for edge pairs—named digrams—that occur often within a graph. The occurrences of the digrams are replaced by hyper edges. In an additional grammar, the rules for replacing the hyper edges with their digrams is stored. The remaining graph is stored using a k 2 tree. Although the authors suggest that this compression can potentially be ported to RDF and used for querying, we are the first to port gRePair to RDF knowledge graphs. Pan et al. [15] propose to search for redundant graph patterns and replace them by triples with newly created predicates and a grammar comprising rules for the decompression. However, a comparison with existing RDF compression approaches like HDT with respect to their compression ratio is missing and the source code is not available. Gayathri et al. [9] propose the mining of logical Horn-rules. Based on these rules, triples that can be inferred are removed from the graph. In the evaluation,
96
M. R¨oder et al.
the authors show that depending on the dataset 27–40% of the triples can be removed. In a similar way, Joshi et al. [12] propose a compression technique which is based on frequent item set mining. Frequent patterns that can be recovered by applying rules are removed from the graph. Their evaluation shows that for several datasets, more than 50% of the triples can be removed and that the removal can lead to an improvement of the performance of the HDT compression algorithm.
3 Preliminaries Definition 1 (Sets). Let U , B and L be the mutually disjoint sets of URI references, blank nodes and literals, respectively [11]. Let P ⊆ U be the set of all properties. Definition 2 (RDF triple). An RDF triple t = (s, p, o) ∈ (U ∪ B) × P × (U ∪ B ∪ L) displays the statement that the subject s is related to the object o via the predicate p [11]. Definition 3 (RDF graph). An RDF graph can be defined as directed labeled multigraph, i.e., as a tuple G = (V, E, λ) where V = {v1 , ..., vn } is the set of nodes; E is a (t) (h) multiset of edges ei = (vi , vi ) ∈ V 2 and λ : E → P is the edge label mapping. Definition 4 (Digram). A digram d = (pi , pj ) is defined as two edges that share at least one node and are labeled with two edge labels pi and pj . It follows, that each digram can link up to three nodes. Each node is either an external or an internal node, where a node is called external if it has at least one edge that does not belong to the digram. Note that in contrast to Maneth et al. [13], we do not define digrams as hyperedges, i.e., we limit ourselves to digrams with one or two external nodes for two reasons: First, this allows the usage of digrams as normal edges in a directed labeled graph as defined above. Second, preliminary implementations showed that digrams with more than two external nodes might not lead to better compression ratios. Our definition leads to 33 different shapes of digrams. 8 examples thereof are depicted in Fig. 1. A digram occurrence is defined as the occurrence of such a digram in a given graph. Definition 5 (Digram-compressed RDF graph). Let D be the set of all digrams. A digram-compressed RDF graph is an RDF graph which has an extended label mapping function λ : E → P ∪ D. Definition 6 (Non-terminal edge). A non-terminal edge is an edge in a digramcompressed RDF graph that is not mapped to a predicate but to a digram. Definition 7 (Grammar). A grammar G is defined as G = (S, D), where S is a digram-compressed RDF graph named start graph and D is the set of digrams used to compress the graph. Definition 8 (Quadrant). A matrix of dimension 2n × 2n can be divided into four sub-matrices of equal size 2n−1 × 2n−1 . These submatrices are called quadrants. The quadrants will represent the following rows and columns of the original matrix:
Applying Grammar-Based Compression to RDF
97
Fig. 1. Examples of digram shapes. The external nodes have additional edges that are not part of the digram (depicted in light gray).
– – – –
First quadrant: (0, 0) to (2n−1 − 1, 2n−1 − 1); Second quadrant: (0, 2n−1 ) to (2n−1 − 1, 2n ); Third quadrant: (2n−1 , 0) to (2n , 2n−1 − 1); Fourth quadrant: (2n−1 , 2n−1 ) to (2n , 2n ).
Definition 9 (Compression Ratio). Let so and sc be the file size in bytes of the original RDF file and the compressed file, respectively. The compression ratio r is defined as r = sc so . The smaller the compression ratio, the better is the performance of a compression algorithm.
4 Approaches We implemented two approaches for RDF compression: RDFRePair and k 2 . We begin by presenting RDFRePair, an RDF compression approach based on the gRePair algorithm proposed by Maneth et al. [13]. It adapts the gRePair approach to RDF and combines it with the dictionary of [8]. The workflow of RDFRePair comprises 4 main steps: 1) Indexing the nodes and edge labels of the input graph, 2) running the gRePair algorithm, 3) creating k 2 trees for the remaining, compressed graph and 4) serializing the graph. The second approach skips the second step and solely relies on an efficient imple´ ıa et al. [1]. These steps are explained mentation of k 2 trees as proposed by Alvarez-Garc´ in the following before we explain the decompression of the graph in Sect. 4.5. The execution of queries on the compressed graph is out of the scope of this paper. 4.1 Indexing The first step is to load the input RDF graph into memory and index all nodes and edge labels within the graph. Maneth et al. [13] state that “[a]ny method for dictionary compression can be used to additionally compress the dictionary (e.g. [14])”. Hence, we use the dictionary implementation of HDT [8].
98
M. R¨oder et al.
Fig. 2. Example of an adjacency matrix to a k2 tree and its serialization.
4.2
gRePair Algorithm
In this step, the algorithm will create a Grammar G from the indexed graph G as described by Maneth et al. [13]. This step consists of the following sub steps. 1. Initial digram scan: The algorithm iterates over all vertices. For each vertex, all pairs of edges connected to that vertex are counted as potential digrams. 2. Sort digrams: All digrams with at least two occurrences are sorted descending by their frequency using a priority queue. 3. Get most frequent digram d: The most frequent digram is removed from the priority queue. 4. Replace all occurences of d: All occurrences of d within the graph are replaced with non-terminal edges and the edges receive the label d. All replaced occurrences are added to a list which is necessary for the later serialization of the digram d. 5. Find new digrams: Since new edges have been introduced, new digrams could have been created. All vertices connected to at least one of these newly created nonterminal edges are given to the digram search algorithm to search for new digrams. If new digrams are found, they are added to the queue. 6. Repeat: if the queue is not empty, go back to step 2.
4.3
k2 Trees
The grammar G created by the gRePair algorithm is split up in a start graph S and the set of digrams D. As proposed by Maneth et al. [13], an adjacency matrix is created for each edge label in S. The matrix is of dimension |V | × |V | and its cells represent the edges between the subject (row index) and the object (column index). If an edge with the edge label of the matrix exists between a subject and an object the representing cell is set to 1. Hence, the matrix is typically sparse. Thereafter, the k 2 trees are built from these matrices. To this end, each path from the root of the k 2 tree to its leaves is built individually before it is merged with all other paths of the matrix. The path creation algorithm is shown in Algorithm 1. First, the matrix is resized to 2h × 2h where h ∈ N is the lowest integer that fulfills 2h ≥ |V |. The added rows and columns are filled with zeros. After that, the matrix is transformed into a tree using a recursion. Starting with the root node, the matrix is divided into 4 quadrants as defined in Definition 8 and four child nodes are added to the root node.
Applying Grammar-Based Compression to RDF
99
Algorithm 1: k 2 tree path creation algorithm.
1 2 3 4 5 6 7 8 9 10
Input: Matrix M, Integer h Output: k2 -Tree x1 = 0, y1 = 0, x2 = 2h , y2 = 2h root = new TreeNode() currentNode = root for Point p : M.getPoints() do quadrant = getQuadrant(p, x1, y1, x2, y2) child = new TreeNode() currentNode.set(quadrant, child) currentNode = child shrinkBoundaries(x1, y1, x2, y2, quadrant) return root
Algorithm 2: k 2 tree path merge algorithm.
1 2 3 4
Input: TreeNode node, Map map, Integer k, Integer h Output: List of individual paths in k2 -tree if k==h OR node == null then return for child C : node.getChildren() do map.get(k).add(C)
6
for child C : node.getChildren() do merge(C, map, k+1, h)
7
return map
5
The value of a child node is either 1 if the quadrant contains at least one cell with a 1 value. Otherwise, the child node gets the value 0. This is done recursively for each child having a 1 until the quadrants are of size 2 × 2. In that case, the 4 numbers of the quadrant are used for the 4 child nodes. Instead of implementing the recursion directly, we implemented a more efficient algorithm, which comprises two steps. First, the algorithm iterates over all cells of the matrix having a 1 value. For each of these cells, the path within a k 2 tree is determined as shown in Algorithm 1. Beginning with the complete matrix, the algorithm determines the quadrant in which the cell is located and adds a child node to the path before shrinking the quadrant. Thereafter, all generated paths are merged as shown in Algorithm 2. Afterwards the map represents the k 2 Tree optimized for later serialization. 4.4 Serialization The serializiation of the created grammar G comprises the serialization of the start graph and the serialization of the digrams. Start Graph. The start graph is serialized as a sequence of its k 2 -trees. Each tree is preceded by the ID of its edge label (4 bytes). Each tree node is represented by a single
100
M. R¨oder et al. 4
8
12
16
Edge Label Index 1 (INT) Edge Label Index 2 (INT) Size
Digram Shape ID Internal Data: {Internal Index1 (, Internal Index2)},...
Fig. 3. Digram serialization. One line represents 2 bytes.
bit. Hence, the tree is serialized as a sequence of bits representing its nodes from top to bottom. If the tree has an uneven number of nodes, the last byte will be padded with zeros. An example is shown in Fig. 2. In this example the whole tree can be stored using only 2 bytes. Digrams. The digrams used to reduce the graph are serialized as depicted in Fig. 3. A serialized digram comprises the two edge labels, a size flag, a shape ID and the IDs of all internal nodes of all occurrences of this digram. The edge label IDs are two integers that represent the IDs of the properties or digrams the two edges of the digram have.2 The size flag uses two bits to decode the number of bytes that are used for the single internal node IDs. This allows the usage of 1, 2, 3 or 4 byte IDs. The shape ID comprises 6 bits that are used to store the ID of the digram shape (i.e., one of the different 33 shapes). The last part of the digram lists the IDs of the internal nodes of all occurrences of the digram. To this end, the occurrences of the digram are sorted based on the ID(s) of its external nodes. Hence, the mapping of internal nodes to the single occurrences of the digram are stored implicitly without taking any additional space. Maneth et al. [13] propose an optimization that reassigns the IDs of vertices in the graph to implicitly store the IDs of internal nodes as well. However, this would raise a new requirement for the dictionary or consume additional space to store the mapping of IDs. 4.5
Decompression
In this section, we briefly describe the process of decompressing a compressed graph. First, the dictionary is loaded. After that all k 2 trees for all terminal edges are loaded and directly transformed into the RDF triples they represent. The digrams are then read and iterated upon in reverse order. The non-terminal edges of each digram’s k 2 -tree are sorted by the IDs of vertices they connect. Based on this order, the single non-terminals can be replaced by the two edges and the internal nodes. Since the non-terminal edges are handled in the same order as during the serialisation, the internal nodes are read in the correct order. Depending on the two edge labels a digram contains, the generated
2
In the current implementation, we use 32 Bit integers. They can be extended to 64 Bits for very large graphs.
Applying Grammar-Based Compression to RDF
101
terminal edges are directly written into the result RDF graph. If non-terminals are created, they are added to the list of their digram. The order of digrams ensures that only non-terminal edges of yet unprocessed digrams can be found.
5 Evaluation Our evaluation aims to answer the following research questions: – RQ1: How do RDFRePair and k 2 perform compared to state-of-the-art RDF graph compression algorithms w.r.t. compression ratio and (de)compression times? – RQ2: To which extent does the dictionary affect the compressed size? – RQ3: Which RDF dataset features influence the compression ratio? 5.1 Experimental Setup To answer the research questions above, we execute several experiments using different RDF datasets and compression algorithms.3 For each dataset-algorithm combination, we use the algorithm to compress and decompress the dataset. During that, we gather four measures: 1) the compression ratio, 2) the runtime of the compression, 3) the runtime of the complete decompression and 4) the amount of space of the compressed dataset that is used to store the dictionary. In addition, we analyze the datasets using the following metrics to answer the third question: number of triples, classes and resources, URI resources, properties, as well as star pattern similarity and structuredness. We elaborate upon the last two measures in the following. In [13], the authors mention that a graph similar to the star pattern is beneficial for gRePair, because gRePair can make use of this structure to find many digram occurrences around those high-degree nodes. A directed graph is described as a star pattern if one node v ∈ V is connected to all other nodes, whereas no other nodes are connected to each other. Hence, the following necessary (but not sufficient) condition must apply: ∃v ∈ V, ∀e ∈ E : v ∈ e. As graphs tend to be more complex than such simple patterns, we define a metric describing how similar a given graph is to a star pattern. Let deg(v) be the degree of a node v. Let N be a list of all nodes sorted by their deg-values in descending order and Nx be the first x nodes of N . We define the star pattern similarity (SP S) metric as follows. deg(n) ∈ [0 : 1] (1) SP S = n∈Nx deg(n) n∈N In our experiments we choose x = 0.001 · |N |. Duan et al. [6] compare synthetic and real-world RDF datasets and conclude that synthetic datasets tend to be more structured. To measure this structuredness, they count how regularly properties occur for instances of classes. If all instances of a class have 3
All experiments were executed on a 64-bit Ubuntu 16.04 machine, an Intel(R) Xeon(R) CPU E5-2698 v3 @ 2.30 GHz with 64 CPUs and 128 GB RAM. Only the experiments for WatDiv were executed on a 64-bit Debian machine with 128 CPUs and 1TB RAM.
102
M. R¨oder et al.
Table 1. Datasets used for the evaluation. Name
Abbreviation
#Triples
#Resources
dc-2010-complete-alignments
SD0
5 919
821
#Classes 36
ekaw-2012-complete-alignments
SD1
13 114
1 604
36
eswc-2006-complete-alignments
SD2
6 654
1 259
25
eswc-2009-complete-alignments
SD3
9 456
1 247
34
eswc-2010-complete-alignments
SD4
18 122
2 226
36
eswc-2011-complete-alignments
SD5
25 865
3 071
36
iswc-2002-complete-alignments
SD6
13 450
1 953
36
iswc-2003-complete-alignments
SD7
18 039
2 565
36
iswc-2005-complete-alignments
SD8
28 149
3 877
36
iswc-2010-complete-alignments
SD9
32 022
3 842
36
external links en
DB0
49 999
7 070
0
geo coordinates en
DB1
49 999
54 870
1
homepages en
DB2
49 999
12 505
0
instance types transitive en
DB3
49 999
98 666
273
instance types en
DB4
49 999
48 913
306
mappingbased objects en
DB5
49 998
37 159
0
persondata en
DB6
49 999
9 516
2
transitive redirects en
DB7
49 999
82 386
0
wikidata-20200308-lexemes-BETA
WD0
49 828
9 965
15
wikidata-20200404-lexemes-BETA
WD1
49 827
9 931
15
wikidata-20200412-lexemes-BETA
WD2
49 828
9 932
15
wikidata-20200418-lexemes-BETA
WD3
49 828
9 902
15
lubm-1
LUBM-1
100 545
17 209
15
lubm-10
LUBM-10
1 272 577
207 461
15
lubm-100
LUBM-100
13 405 383
2 179 801
15
lubm-1000
LUBM-1000
watdiv
WAT
133 573 856
21 715 143
15
1 098 871 666
52 120 471
12 500 145
external links en
EL
7 772 283
9 128 582
0
geo coordinates en
GC
2 323 568
580 897
1
homepages en
HO
688 563
1 300 927
0
instance types en
IT
5 150 432
5 044 646
422 388
instance types transitive en
ITT
31 254 270
4 737 461
mappingbased objects en
MO
18 746 173
5 901 219
0
persondata en
PD
10 310 094
1 522 938
18
transitive redirects en
TR
7 632 358
10 404 804
0
archives-hub
AH
1 361 815
135 643
46
jamendo
JA
1 047 950
410 929
11
scholarydata dump
SDD
859 840
95 016
46
wikidata-20200308-lexemes-BETA
WD
42 914 845
6 061 049
22
dblp-20170124
DBLP
88 150 324
28 058 722
14
Applying Grammar-Based Compression to RDF
103
triples with the same properties, the class is highly structured. If some of the instances have triples with properties that other instances of the same class do not have, the class is less structured. The structuredness of a dataset is the weighted average of the class structuredness values with a higher weight for classes with many instances and many properties. 5.2 Datasets Table 1 shows the summary of the datasets.4 We use 40 datasets in total. Note that gRePair and in part RDFRePair were not able to handle large datasets in our experiments. To still be able to compare them with other approaches, we introduce 4 Wikidata and 8 DBpedia subsets cut at 50 k lines. 5.3 Compression Algorithms For the evaluation of RDFRePair, we select a subset of the algorithms listed as related work. We choose HDT because of its wide adoption and its usage as reference algorithm in several publications.5 In addition, we compare our evaluation with HDT++ and OFR since both algorithms are reported to perform at state-of-the-art level and better than HDT.6 We also use our k 2 implementation since the implementations used in the related work (e.g., [1]) do not seem to be available as open source. In addition, we received a prototypical implementation of the gRePair algorithm from the authors of [13]. Given that the original gRePair implementation is a proof of concept, it is rather far from stable regarding decompression. Apart from that, the implementation does not create a dictionary. To alleviate this problem, the HDT dictionary size was added for a fair comparison. The OFR compression provides several files representing the compressed graph. To combine these files and further compress them the authors suggested to use either Deflate (zip) or LZMA (7z). However, since our goal is to compare comparisons that would be able to answer SPARQL queries, we do not use additional, binary compression algorithms. Instead, we sum up the sizes of the individual files. The addition of other algorithms (see Sect. 2) was prevented by the non-availability of their implementation or their reported poor compression ratio. 5.4 Results Figure 4 shows the compression ratios achieved by the different algorithms. To compare the compression ratios across the different datasets, we use a one-tailed Wilcoxon signed-rank test for a pairwise comparison of the compression algorithms. Table 2 lists 4
5 6
The datasets can be found at https://w3id.org/dice-research/data/rdfrepair/evaluation datasets/. For scholarly data (DF0–DF9), we use the rich datasets (see http://www.scholarlydata.org/ dumps/). https://github.com/rdfhdt/hdt-java. HDT++ is available at https://github.com/antonioillera/iHDTpp-src. OFR is not publicly available. However, the authors were so kind to provide us the binaries.
104
M. R¨oder et al.
(a) ScholarlyData sections (rich)
(b) Wikidata subsets cut at 50k lines
(c) DBpedia subsets cut at 50k lines
(d) DBpedia sections
(e) LUBM generation for 1, 10, 100 and 1000 Universities, and WatDiv 1.1 billion triples
(f) Real-world datasets
Fig. 4. Compression ratio for the compression algorithms on the single datasets. Smaller values are better.
the p-values of the tests. These results suggest that RDFRePair leads to significantly better compression ratios than the original prototypical gRePair implementation. However, RDFRePair is significantly outperformed by k 2 and OFR. The prototypical implementation of gRePair is outperformed by all other approaches. Overall, OFR and our implementation of the k 2 algorithm lead to the best compression ratios with k 2 performing better on non-synthetic datasets. None of these two algorithms is able to significantly
Applying Grammar-Based Compression to RDF
105
Table 2. p-value of a one-tailed Wilcoxon signed rank test with respect to compression ratio. A bold value indicates that the algorithm in the row leads to a significantly better compression ratio than the algorithm in the column (p < α = 0.05). r1 \ r2 RDFRePair gRePair HDT k2 OFR HDT++
RDFRePair gRePair HDT — ≈1.0 0.21 ≈0.0 0.01 0.11
≈0.0 — 0.05 ≈0.0 ≈0.0 ≈0.0
(a) LUBM generation for 1, 10, 100 and 1000 Universities, and WatDiv 1.1 billion triples
0.79 0.95 — ≈0.0 ≈0.0 ≈0.0
k2 ≈1.0 ≈1.0 ≈1.0 — 0.49 ≈1.0
OFR HDT++ 0.99 ≈1.0 ≈1.0 0.51 — 0.93
0.89 ≈1.0 ≈1.0 ≈0.0 0.07 —
(b) Real-world datasets
Fig. 5. Compression time in ms (log). Smaller values are better.
outperform the other one with respect to the compression ratio. Our findings contradict the results of Maneth et al. [13] that gRePair performs better than k 2 . OFR has the shortest runtime w.r.t. compression and decompression time (depicted in Figs. 5 and 6). It is followed by HDT and HDT++. k 2 shows a longer runtime than these three algorithms. The prototypical implementation of gRePair is the slowest algorithm. In addition, gRePair and RDFRePair were not able to compress 12 of the 40 datasets within 2 h, respectively. Figure 7 depicts the amount of space used to store the compressed dictionary in comparison to the overall size of the compressed dataset. 5 of the 6 approaches share a similar dictionary implementation based on [8]. For all these approaches, the dictionary consumes the majority of the space. Especially for the k 2 compression, the average size of the dictionary over all datasets is 80%. In comparison, the OFR dictionary achieves smaller dictionary sizes on some of the datasets. This suggests that improvements to the dictionary can lead to much better compression ratios for HDT, HDT++ and k 2 . The correlation analysis reveals that all algorithms have a correlation between their performance and the number of classes. However, this seems to be an indirect relation that is caused by the datasets that contain solely one-to-one mappings like
106
M. R¨oder et al.
(a) LUBM generation for 1, 10, 100 and 1000 Universities
(b) Real-world datasets
Fig. 6. Decompression time in ms (log). Smaller values are better.
(a) LUBM generation for 1, 10, 100 and 1000 Universities, and WatDiv 1.1 billion triple
(b) Real-world datasets
Fig. 7. Size of the dictionary in comparison to the compressed dataset size in %.
DB0 or EL. These datasets have no classes and are hard to compress because of their one-to-one structure. Neither the SPS nor the structuredness metric show any significant correlations. The results show that RDFRePair underachieves. A further analysis reveals that the optimization described in Sect. 4.4, i.e., to store the IDs of internal nodes implicitly by renumbering all nodes in the graph, is one of the major features of gRePair.7 This leads to very good results in the evaluation done by Maneth et al. [13]. This optimization seems to contradict the statement that a dictionary compression as proposed by Mart´ınez-Prieto et al. [14] can be used (see Sect. 4.1) since the dictionary compression needs to allow the gRePair algorithm to freely redefine the IDs of all nodes. However, Mart´ınez-Prieto et al. separate the space of node IDs into several ranges. Based on the role of a node in the graph, it has to receive an ID of a certain range. This allows different indexing and compression strategies for the different ranges. However, such a 7
For a fair comparison, we turned this feature of gRePair in our evaluation off. Otherwise, it couldn’t be used with the HDT dictionary.
Applying Grammar-Based Compression to RDF
107
Table 3. Values of Kendall’s Tau rank correlation between compression ratio and dataset metrics. A bold value indicates a significant correlation (α = 0.02). ∗ only experiments that terminated in time were taken into account. RDFRePair∗ gRePair∗ #Triples
0.27
#Classes
−0.47
0.32
HDT
k2
0.17
0.13
OFR HDT++ 0.03
0.11
−0.57 −0.51 −0.50 −0.43
−0.52
#UriResources
0.23
0.27
0.17
0.13
0.04
#Resources
0.37
0.40
0.24
0.20
0.12
0.17
#Properties
−0.17
−0.13 −0.22 −0.24 −0.15
−0.19
SPS Structuredness
0.09 −0.20
0.10
0.00 −0.01
0.04
−0.24 −0.21 −0.18 −0.30
−0.21
0.14
0.06
node can not get an ID assigned by gRePair. We measured the amount of space the internal nodes consume. Especially for type graphs with a simple structure (e.g., DB4) the internal nodes consume up to 98% of the memory of the compressed triples (i.e., the memory of the compressed dataset without the dictionary). We call this the internal node size ratio. The datasets used by Maneth et al. [13] seem to favor the usage of digrams. Two out of the six datasets have an internal node size ratio of 99% while three other datasets have ratios of more than 50%. In our evaluation, the majority of datasets has an internal node size ratio below 50%. More diverse datasets like SD0–SD9 have ratios between 9% and 16%. Even without storing internal nodes, RDFRePair and gRePair would still show a lower performance than k 2 trees for such datasets but with the cost of a dictionary that may less optimized for querying and compression.
6 Conclusion This paper presented several contributions. First, we presented RDFRePair—an improved implementation of the gRePair algorithm ported to the compression of RDF graphs. Second, we present an efficient implementation of the k 2 trees for the same goal. Third, we ran a large-scale evaluation comparing RDFRePair and k 2 with HDT, HDT++, OFR and a prototypical implementation of gRePair. Our results could not support the assumption that grammar-based compressions like gRePair are able to outperform existing RDF graph compressions. Instead, our results suggest that in most cases the best compression ratio of RDF datasets can be achieved by using either k 2 trees or OFR with k 2 trees performing best on average when faced with real data. On the other hand, OFR clearly shows a better runtime performance. There are existing implementations for executing SPARQL queries on k 2 trees while an implementation for the query execution for OFR is missing. During the analysis of our results, we couldn’t identify significant correlations between the compressor’s performance and the features of the datasets. However, our results suggest that future work may focus on further improving the dictionary since it consumes the majority of the space. Acknowledgements. This work has been supported by the German Federal Ministry for Economic Affairs and Energy (BMWi) within the project SPEAKER under the grant no
108
M. R¨oder et al.
01MK20011U and by the EU H2020 Marie Skłodowska-Curie project KnowGraphs under the grant agreement no 860801.
References ´ 1. Alvarez-Garc´ ıa, S., Brisaboa, N., Fern´andez, J.D., Mart´ınez-Prieto, M.A., Navarro, G.: Compressed vertical partitioning for efficient RDF management. Knowl. Inf. Syst. 44(2), 439–474 (2014). https://doi.org/10.1007/s10115-014-0770-y ´ ˆ 2. Alvarez-Garc´ ıa, S., Brisaboa, N.R., Fern´andez, J.D., Mart´ıAnez-Prieto, M.A.: Compressed k2 -Triples for Full-In-Memory RDF Engines. In: AMCIS 2011 Proceedings. IEEE (2011) 3. Beckett, D., Berners-Lee, T., Prud’hommeaux, E., Carothers, G.: RDF 1.1 Turtle. W3C Recommendation, W3C (February 2014) 4. Berners-Lee, T.: Primer: Getting into RDF & Semantic Web Using N3. Technical Report W3C, (October 2010) 5. Brisaboa, N.R., Ladra, S., Navarro, G.: k 2-trees for compact web graph representation. In: International Symposium on String Processing and Information Retrieval (2009) 6. Duan, S., Kementsietsidis, A., Srinivas, K., Udrea, O.: Apples and oranges: a comparison of RDF benchmarks and real RDF datasets. In: Proceedings of the 2011 ACM SIGMOD International Conference on Management of Data (SIGMOD 2011), pp. 145–156. ACM (2011) 7. Fern´andez, J.D., Gutierrez, C., Mart´ınez-Prieto, M.A.: RDF compression: basic approaches. In: Proceedings of the 19th International Conference on World Wide Web (2010) 8. Fern´andez, J.D., Gutierrez, C., Mart´ınez-Prieto, M.A, Polleres, A., Arias, M.: Binary RDF Representation for Publication and Exchange (HDT). Web Semant. Sci. Serv. Agents World Wide Web 19, 22–41 (2013) 9. Gayathri, V., Kumar, P.S.: Horn-rule based compression technique for RDF data. In: Proceedings of the 30th Annual ACM Symposium on Applied Computing (SAC 2015), pp. 396–401. Association for Computing Machinery, New York (2015) 10. Hern´andez-Illera, A., Mart´ınez-Prieto, M.A., Fern´andez, J.D.: Serializing RDF in compressed space. In: 2015 Data Compression Conference, pp. 363–372. IEEE (2015) 11. Hitzler, P., Kr¨otzsch, M., Rudolph, S., Sure, Y.: Semantic Web: Grundlagen. Springer (2007). 10.1007/978-3-319-93417-4 12. Joshi, A.K., Hitzler, P., Dong, G.: Logical linked data compression. In: Cimiano, P., Corcho, O., Presutti, V., Hollink, L., Rudolph, S. (eds.) ESWC 2013. LNCS, vol. 7882, pp. 170–184. Springer, Heidelberg (2013). https://doi.org/10.1007/978-3-642-38288-8 12 13. Maneth, S., Peternek, F.: Grammar-based graph compression. Inf. Syst. 76, 19–45 (2018) 14. Mart´ınez-Prieto, M.A., Fern´andez, J.D., C´anovas, R.: Compression of RDF dictionaries. In: Proceedings of the 27th Annual ACM Symposium on Applied Computing (SAC 2012), pp. 340–347. Association for Computing Machinery, New York (2012). https://doi.org/10.1145/ 2245276.2245343 15. Pan, J.Z., P´erez, J.M.G., Ren, Y., Wu, H., Wang, H., Zhu, M.: Graph pattern based RDF data compression. In: Supnithi, T., Yamaguchi, T., Pan, J.Z., Wuwongse, V., Buranarach, M. (eds.) JIST 2014. LNCS, vol. 8943, pp. 239–256. Springer, Cham (2015). https://doi.org/10. 1007/978-3-319-15615-6 18 16. Salomon, D.: Data Compression: The Complete Reference. Springer, New York (2004). 10.1007/b97635 17. Swacha, J., Grabowski, S.: OFR: an efficient representation of RDF datasets. In: Languages, Applications and Technologies. pp. 224–235. Springer International Publishing (2015) 18. Wang, K., Fu, H., Peng, S., Gong, Y., Gu, J.: A RDF data compress model based on octree structure. In: 2017 12th IEEE Conference on Industrial Electronics and Applications (ICIEA). pp. 990–994 (2017)
HDT Bitmap Triple Indices for Efficient RDF Data Exploration Maximilian Wenzel1(B) , Thorsten Liebig2(B) , and Birte Glimm1(B) 1
Institute of Artificial Intelligence, University of Ulm, Ulm, Germany {maximilian.wenzel,birte.glimm}@uni-ulm.de 2 derivo GmbH, Ulm, Germany [email protected]
Abstract. The exploration of large, unknown RDF data sets is difficult even for users who are familiar with Semantic Web technologies as, e.g., the SPARQL query language. The concept of faceted navigation offers a userfriendly exploration method through filters that are chosen such that no empty result sets occur. Computing such filters is resource intensive, especially for large data sets, and may cause considerable delays in the user interaction. One possibility for improving the performance is the generation of indices for partial solutions. In this paper, we propose and evaluate indices in form of the Bitmap Triple (BT) data structure, generated over the Header-Dictionary-Triples (HDT) RDF compression format. We show that the resulting indices can be utilized to efficiently compute the required exploratory operations for data sets with up to 150 million triples. In the experiments, the BT indices exhibit a stable performance and outperform other deployed approaches in four out of five compared operations.
1
Introduction
Exploring large data sets is increasingly important in many scenarios. In the context of Semantic Web technologies, however, the exploration of a large, unfamiliar RDF data set can be very challenging, in particular, for novice users of Semantic Web technologies. Faceted navigation is an approach to ease the exploration process by providing users with filters for a given set of resources such that it is guaranteed that applying the filters yields a non-empty result. Several approaches and systems support faceted navigation: Ontogator [9], /facet [8], and BrowseRDF [15] are among the first text-based, faceted browsers, where the latter provides metrics for an automatic ranking for the available filters. GraFa [13] targets large-scale, heterogeneous RDF graphs and employs a materialisation strategy and a full-text index for queries to improve the response time. The browsers SemFacet [2,10] and Broccoli [3] support faceted search, i.e., they combine faceted navigation with full-text search. Apart from textbased faceted browsers, there are also graph-based visualisation systems such as gFacet [7] and SemSpect [11]. The operations needed for faceted navigation are, however, very costly, especially for large data sets. To improve the performance of the required operations, c Springer Nature Switzerland AG 2021 R. Verborgh et al. (Eds.): ESWC 2021, LNCS 12731, pp. 109–125, 2021. https://doi.org/10.1007/978-3-030-77385-4_7
110
M. Wenzel et al.
most (if not all) of the above systems use indices. Sometimes, such indices require, however, even more space than the original data set. Therefore, the development of techniques for keeping such indices as small as possible is of great importance. An established compression format for RDF data is Header-Dictionary-Triples (HDT) [5,12], where each resource of the data set is assigned a unique integer ID in a dictionary component. These IDs are then used to generate a compressed representation of all RDF triples in a binary data structure called Bitmap Triples (BT). HDT further has the advantage that triple patterns can efficiently be resolved over the BT data structure. In this work, we propose two BT indices on top of an HDT file for efficiently executing the operations required in faceted navigation. For this, we extend the original BT definition to allow for representing BT indices over subsets of the original RDF graph. An exploration over a given HDT file is especially useful since the HDT format is intended to be an exchange format for RDF data sets. Therefore, using an exchanged HDT file as a basis for a faceted navigation back end might be practical in order to get an overview of an initially unknown data set. In an empirical evaluation, we demonstrate that the generation of these indices is feasible for data sets with up to 150 million triples and that the time and space needed for generating the indices is less than what is required for generating the original HDT file. Based on the indices, a stable and consistently improved performance can be observed compared to executing the operations over the HDT file itself and other in-memory triple stores. Section 2 introduces the concept of and operations needed for faceted navigation as well as the fundamentals of the HDT format. Section 3 then introduces the novel BT indices and their use in the required exploratory operations. In Sect. 4, we empirically evaluate our approach and other existing approaches over various real-world data sets. Section 5 concludes the paper.
2
Preliminaries
Before going into the details of our proposed indices, we introduce the operations needed for faceted navigation, the basics of Header Dictionary Triples and the Bitmap Triples compression format. 2.1
Faceted Navigation
Faceted navigation is an approach to retrieve data which is organised in facets and facet values. In this paper, we consider faceted navigation over RDF graphs: Definition 1 (RDF). Let I, L, and B be pairwise disjoint infinite sets of IRIs, literals, and blank nodes, respectively. A tuple (s, p, o) ∈ (I ∪ B) × I × (I ∪ L ∪ B) is called an RDF triple, where s is the subject, p is the predicate, and o is the object. An RDF graph G is a finite set of RDF triples. We set SG = {s | (s, p, o) ∈ G}, PG = {p | (s, p, o) ∈ G}, OG = {o | (s, p, o) ∈ G}.
HDT Bitmap Triple Indices for Efficient RDF Data Exploration
111
Fig. 1. Screenshot of the GraFa [13] application. Proceeding from an initial class, the user refines the set of instances by the step-wise selection of available filters.
Given an RDF graph G, we define the set CG of classes as containing all resources C such that G RDFS-entails the triple (C, rdf : type, rdfs : Class). We say that a resource s has type C if G RDFS-entails the triple (s, rdf : type, C) and the instances of a class C are all resources that have the type C in G. In the context of faceted search, for a triple (s, p, o) ∈ G, we also call p a facet, and we call s and o facet values. We normally omit “RDF” in our terminology if no confusion is likely and we abbreviate IRIs using the prefixes rdf, rdfs, and owl to refer to the RDF, RDFS, and OWL namespaces, respectively. The initial step in the faceted exploration of a graph is to filter resources according to classes. Once a user has chosen a class, the instances of the class constitute the centre of the exploration. This centre is then step-by-step refined by applying filters. Definition 2 (Filters). Let G be an RDF graph, a centre M ⊆ SG ∪OG w.r.t. G is a subset of the resources in G. Let V be a countably infinite set of variables disjoint from I ∪ L ∪ B. In order to distinguish variables from resources, we prefix variables with a ?. A triple pattern is a member of the set (I ∪ B ∪ V ) × (I ∪ V ) × (I ∪ L ∪ B ∪ V ). An incoming property-value filter is a triple pattern of the form (s, p, ?o), while an outgoing property-value filter is of the form (?s, p, o). Given a centre M w.r.t. G, applying the property-value filters (s, p, ?o) and (?s, p, o) to M yields {o | o ∈ M, (s, p, o) ∈ G} and {s | s ∈ M, (s, p, o) ∈ G}, respectively. A property filter is a triple pattern of the form (?s, p, ?o). Applying (?s, p, ?o) to a centre M yields a set of incoming resources Mp→ = {s | o ∈ M, (s, p, o) ∈ G} and a set of outgoing resources Mp← = {o | s ∈ M, (s, p, o) ∈ G}. Given a centre M w.r.t. G, a filter f is available, if applying f over M yields a non-empty result. In faceted navigation, only available filters must be presented to the user. The above defined notions and operations are used, for example, in the application GraFa [13] as shown in Fig. 1.
112
M. Wenzel et al.
Fig. 2. Excerpt from the SemSpect [1] application exploring the Panama Papers data set. (1) A user selects an initial class (in SemSpect denoted as “category”), which then represents the centre. (2) Proceeding from the centre, all reachable classes are computed. (3) The user chooses one of the reachable classes which subsequently constitutes the new centre.
Since the exploration is also often based on classes and their instances, which are then filtered, another important concept is that of reachable classes: Definition 3 (Reachable Classes). Let G be an RDF graph and M a centre. A class C induces a set of incoming (outgoing) facets {p | (s, p, o) ∈ G, s ∈ M, o has type C} ({p | (s, p, o) ∈ G, o ∈ M, s has type C}) w.r.t. M . We say that C is an incoming (outgoing) reachable class w.r.t. M , if the induced set of incoming (outgoing) facets is non-empty. If the direction (incoming/outgoing) is clear from the context, we simply speak about reachable classes. From a centre M , a user may choose a reachable class C and an appropriate facet p to continue the exploration. As a result, an incremental join operation is performed to join the incoming (outgoing) resources with the instances of the class C. Subsequently, this set becomes the new centre. From there, the available filters and the reachable classes are computed again. As an example for the reachable classes and incremental join operation, an excerpt from the application SemSpect [1] is shown in Fig. 2. 2.2
RDF Compression
Traditional RDF serialisation formats (e.g., RDF/XML, Turtle, or N3) have a high level of redundancy and a simple lookup requires a sequential scan of the document. The binary Header Dictionary Triples (HDT) [5,12] format addresses these shortcomings by providing a compressed triple structure that can be queried without the need of decompression. An HDT file is composed of three parts: (i) the Header provides metadata about the data set in plain RDF format, (ii) the Dictionary provides a mapping between strings and unique IDs, and (iii) the Triples encode the RDF graph using IDs. We next consider the concrete implementation of the dictionary and the triples component in more detail as they constitute the basis of the proposed indices. Definition 4 (HDT). Let SOG = SG ∩ OG denote the set of shared resources, Spure = SG \ SOG the set of pure subjects, and Opure = OG \ SOG the set of pure objects. For a set S, we use S to denote the lexicographic order of elements in S.
HDT Bitmap Triple Indices for Efficient RDF Data Exploration
113
The HDT dictionary provides a mapping μ such that μ maps a resource ri at position i (starting with position 1) of a list L to i if L = SOG , to |SOG | + i if L = Spure , to |SOG | + i if L = Opure , and to i if L = PG . Note that a given ID can belong to different sets, but the disambiguation of the correct set is trivial when we know the position (subject, predicate, or object) of the ID in a triple. Furthermore, the distinction into four sets helps to assign shorter IDs since the entries are stored in a binary sequence, where the length of the sequence depends on the maximal used ID. The ID 0 is reserved as a wildcard character in triple ID queries. The dictionary is eventually stored using plain front-coding [4] – a compression format for lexicographically sorted dictionaries based on the fact that consecutive entries are likely to share a common prefix. The Triples component uses the assigned IDs to form a compressed representation of a graph G using the Plain Triples, Compact Triples or Bitmap Triples [5] format. Definition 5 (Plain Triples). Given an RDF graph G, the Plain Triples representation PT(G) of G is obtained by replacing each triple (s, p, o) ∈ G with (μ(s), μ(p), μ(o)), where μ is the HDT dictionary mapping. The Compact Triples representation of G is obtained from PT(G) based on adjacency lists of predicates and objects for the subjects: Definition 6 (Compact Triples). For a subject ID s in the plain triples format PT(G) of an RDF graph G, pred(s) denotes the ordered sequence of predicate IDs in {p | (s, p, o) ∈ PT(G)}; for a subject ID s and a predicate ID p in PT(G), obj(s, p) denotes the ordered sequence of object IDs in {o | (s, p, o) ∈ PT(G)}. Let s1 , . . . , sn be the ordered sequence of distinct subject IDs in PT(G). The Compact Triples encoding CT(G) of G consists of two ID sequences: The predicate sequence Sp = pred(s1 )0 . . . 0pred(sn ) and the objects sequence So = So1 . . . Son , where each partial object sequence Soi , 1 ≤ i ≤ n, is the concatenation obj(si , p1 )0 . . . 0obj(si , pm )0 and p1 , . . . , pm = pred(si ). Note that the unused ID 0 is used to terminate predicate and object sequences. The Bitmap Triples representation of G is obtained from CT(G) by further compressing the lists with the help of additional bitmap sequences: Definition 7 (Bitmap Triples). Let G be an RDF graph and CT(G) its compact triples representation such that Sp = Sp1 0 . . . 0Spn and So = So1 0 . . . 0Som are the predicate and object sequence of CT(G), respectively. Let ip and jo denote the length of Spi and Soj , 1 ≤ i ≤ n, 1 ≤ j ≤ m, respectively. The Bitmap Triples encoding BT(G) of G consists of two ID sequences Sˆp = 1 Sp . . . Spn and Sˆo = So1 . . . Som , obtained from Sp and So by dropping the 0s, and two bit sequences Bp and Bo such that the length of Bp and Bo is the same as the length of Sˆp and Sˆo , respectively, and the value at position pos in Bp (Bo ) is 1 if pos = 1p + . . . + ip for some i, 1 ≤ i ≤ n, (pos = 1o + . . . + jo , for some j, 1 ≤ j ≤ m) and it is 0 otherwise.
114
M. Wenzel et al.
Fig. 3. Example for the compressed triple formats from Fernandez et al. [5]
Figure 3, from an example introduced by Fernandez et al. [5], illustrates the different formats. While we omit the dictionary component, the Plain Triples show that the IDs 1 . . . 3 are subject IDs and that the ID 1 denotes a shared resource as it also occurs in the object position. The further (pure) objects have the IDs 2 . . . 6. The IDs 1 . . . 4 also represent predicates. The subject 1 is used with the (distinct) predicates 2 and 3, hence, pred(1) is 23. Analogously, pred(2) = 124 and pred(3) = 3. In Sp these sequences are separated by a 0 and So analogously encodes the objects for each subject–predicate pair. In the Bitmap Triples encoding, the sequences Sˆp and Sˆo simply drop any 0 from Sp and So . The bit sequence Bp tells us with a value of 1, when a sequence in Sˆp ends, i.e., the first sequence 23 (of length 2) ends at (and including) position 2. The following sequence 124 (of length 3) starts at position 3 and the next 1 at position 5 (2 + 3) of Bp indicates the end of the sequence. The bit sequence Bo analogously terminates the sequences in Sˆo . HDT is not merely a compression format but also provides the efficient resolution of triple patterns on the compressed representation of an RDF graph by deploying succinct data structures for the BT implementation [5]. SP-O index queries can be efficiently accomplished in O(log(n)), i.e., the triple patterns (s, p, o), (s, p, 0), (s, 0, o) and (s, 0, 0) can be resolved, where 0 denotes a wildcard match and s, p, o represent resource IDs at the corresponding triple position. For other triple patterns, the so far discussed solutions do not suffice and Mart´ınezPrieto et al. [12], therefore, introduced a compact full-index called HDT Focused on Querying (FoQ), which is created over the original HDT file and which consists of a further PS-O and OP-S index.
3
Faceted Navigation Indices Based on HDT BT
In order to efficiently compute the available filters, reachable classes, filter operations and the corresponding incremental joins as described in Sect. 2, we propose the use of additional (in-memory) BT indices over subsets of the original RDF data set. Therefore, in order to represent only a sub-graph, an adaptation of the original Bitmap Triples format (Definition 7) is needed. We illustrate this for the standard SP-O triple component order, but the approach can analogously be transferred to the PO-S and PS-O BT indices. We decided against self-indexing individual triples in the Bitmap Triples component of the HDT file because we need to perform efficient triple pattern queries on the subgraphs
HDT Bitmap Triple Indices for Efficient RDF Data Exploration
115
Fig. 4. Bitmap triples from the example in Fig. 3 (left-hand side) and for the subgraph containing triples with subject IDs 1 and 3 (right-hand side) with the additional subject sequence Ss to obtain the original subject IDs
in the triple component order PO-S and PS-O. For instance, in case of triple pattern queries (?s, p, o), the self-indexing approach does not require less space since these patterns can only be efficiently resolved by indexing all subjects for the appropriate predicate-object pairs. Definition 8 (Partial BT SP-O Index). Let G be an RDF graph and G ⊆ G a sub-graph of G. A partial BT index for G consists of BT(G ) and the ID sequence Ss = s1 · · · sn , where s1 , . . . , sn is the ordered sequence of distinct subject IDs in PT(G ). For an SP-O index over a sub-graph G of an RDF graph G, the implicit subject ID, which is stored by the bit sequence Bp , does not correspond to the actual subject dictionary ID of the original HDT file. Therefore, the additional ID sequence Ss indicates the actual subject ID from the dictionary to each implicit subject ID. Figure 4 shows again the Bitmap triples from Fig. 3 (left-hand side) and the Bitmap Triples for the sub-graph containing only triples with subject IDs 1 and 3. The additional subject sequence Ss is used to obtain the original subject IDs for the HDT mapping. In order to resolve triple patterns of the form (s, 0, 0) (with 0 as wildcard) on a partial SP-O BT index, the subject ID s is first converted into the implicit subject ID of the corresponding partial BT index. For this purpose a binary search operation is executed on the sequence Ss to obtain the position of s in Ss , which corresponds to the implicit subject ID in the bit sequence Bp of BT(G ). Afterwards, the resolution of triple patterns involves the same steps as for the standard Bitmap Triples [12]. However, when iterating over the results from a search over a partial BT index, each subject ID sr from the search results has to be converted into the appropriate subject ID se over the full graph, which can be accomplished by the simple access operation se := Ss [sr ]. Based on our definition of partial BT indices, we propose the use of two additional (in-memory) BT indices: Property-Value and Class-to-Class indices. Definition 9 (Property-Value Index). Let G be an RDF graph with C ∈ CG a class. An incoming property value (PV) index w.r.t. C is a partial PS-O BT index over {(s, p, o) ∈ G | o has type C}. An outgoing PV index w.r.t. C is a PO-S BT index over {(s, p, o) ∈ G | s has type C}.
116
M. Wenzel et al. Table 1. Data sets utilised in the experiments Data Set
RDF Dump File (.ttl) #Triples
#Classes
LinkedMDBa
282 MB
3,579,532
41
Lobbying filingsb 306 MB
5,344,200
7
Panama papersc
1,140 MB
19,903,231
18
Reactomed
1,350 MB
48,556,891
82
SciGraphe
8,500 MB
39,692,376
20
YAGO 2f
9,920 MB
158,991,568 373,442
OpenPermIDg
11,470 MB
152,527,813 21
a http://www.cs.toronto.edu/∼oktie/linkedmdb/linkedmdb-18-05-
2009-dump.nt. are not authorized to publish the data set in RDF format. REST API for XML download: https://lda.senate.gov/api/. Accessed 15 Oct 2019. c https://doi.org/10.5281/zenodo.4319930. d https://doi.org/10.5281/zenodo.4415888. e https://www.springernature.com/gp/researchers/scigraph. f http://yago.r2.enst.fr/. g https://permid.org/. b We
In order to efficiently calculate all available filters and the filter operations, we generate incoming and outgoing PV indices for all classes in an RDF graph. In case of the incoming and outgoing PV indices, the PS-O and the PO-S triple component order has been chosen, respectively, to fetch all relevant triples for a given incoming property-value filter (s, p, ?o) and outgoing property-value filter (?s, p, o), respectively. In order to efficiently compute reachable classes, we further propose Classto-Class indices: Definition 10 (Class-to-Class Index). Let G be an RDF graph with C, D ∈ CG classes. A Class-to-Class (CtC) index w.r.t. C and D is a partial PS-O BT index over {(s, p, o) ∈ G | s has type C, o has type D}. We generate CtC indices for each pair of classes C, D ∈ CG . The PS-O triple component order facilitates the computation of incremental join operations between instances of the classes C and D since all existing triples in the corresponding index can efficiently be retrieved for a given facet p.
4
Implementation and Evaluation
We next present the empirical evaluation of the proposed additional BT indices. We start by describing used data sets as well as the time and space required to create and store the proposed BT indices for these data sets. We then introduce the different benchmarked approaches and the queries and tasks used in the evaluation before we present the actual results. All presented experiments were conducted on an Intel(R) Core(TM) i7-3930K CPU @ 3.20 GHz, 6 cores, 64 GB DDR3 @ 1334 MHz.
HDT Bitmap Triple Indices for Efficient RDF Data Exploration
117
100% 80%
60% 40% 20% 0% LinkedMDB HDT File FoQ Index CtC Indices PV Indices
00:33 00:02 00:09 00:10
Lobbying Filings 00:29 00:03 00:09 00:15
Panama Papers 01:44 00:27 00:35 01:09
Reactome
SciGraph
OpenPermID
04:06 01:00 02:55 04:04
12:43 01:58 00:55 01:59
22:10 16:49 03:38 07:29
Fig. 5. Time required for generating the representations (format mm:ss)
4.1
Data Sets and Index Generation
The (partial) BT indices were implemented in Java with the HDT Java library1 as foundation and the code is available on GitHub as open-source project.2 Since our implementation does not support RDFS-entailment, the required inferences (for types of the resources) are materialised upfront using RDFox [14]. For each RDF file, we generate an HDT file, which serves as the basis for the CtC and PV indices. Note that RDF classes, which do not contribute to the semantic domain of the RDF model such as rdfs:Resource, are not considered in the indices. In order to get an impression of the required generation time and resulting file size, the proposed BT indices have been generated for various data sets (see Table 1). For the YAGO 2 data set, the CtC and PV indices could not be generated because of insufficient main memory capacity for the high number of distinct RDF classes. In Fig. 5, the time required to generate all CtC and PV indices is compared to the time needed to create the HDT file and the compact HDT Focused on Querying (FoQ) full-index [12]. Figure 6 shows the size of the BT indices compared to the size of the original RDF dump file, the HDT file and the HDT FoQ index. Neither the time for generating the CtC nor the PV index exceeds the time for generating the HDT file on any data set. The files that are utilised in an actual faceted exploration, i.e., the PV, CtC, and FoQ indices and the HDT file,
1 2
https://github.com/rdfhdt/hdt-java. https://github.com/MaximilianWenzel/hdt-bt-indices-java-lib.
118
M. Wenzel et al. OpenPermID SciGraph Reactome Panama Papers Lobbying Filings LinkedMDB 0%
20% LinkedMDB
RDF Dump File (.l) HDT File FoQ Index CtC Indices PV Indices
282 MB 32 MB 19 MB 10 MB 17 MB
Lobbying Filings 307 MB 35 MB 24 MB 9 MB 24 MB
40% Panama Papers 1,204 MB 125 MB 107 MB 54 MB 190 MB
60%
80%
100%
Reactome
SciGraph
OpenPermID
1,354 MB 299 MB 236 MB 546 MB 804 MB
8,497 MB 1,060 MB 254 MB 32 MB 187 MB
11,469 MB 1,449 MB 1,068 MB 161 MB 788 MB
Fig. 6. File size comparison of the various representations
require between 18–30% of the Turtle file size in five out of six data sets. Only for the Reactome data set, 139% of the Turtle file size is needed which is due to the high interconnectivity, i.e., the high number of triples t = (s, p, o) where s and o have an RDF class assigned. The consumed storage space subsequently corresponds to the required main memory capacity during an exploration. 4.2
Performance Benchmark Setup
We consider the following approaches in the experimental evaluation: 1. HDT Jena: The Jena ARQ query engine3 used over an HDT file. 2. RDFox: The commercial, in-memory triple store RDFox [14]. 3. Plain HDT: Our implementation using only the original HDT file and the FoQ index. 4. PV indices: Our implementation used with PV indices, the HDT file and the FoQ index. The FoQ index is utilized to perform efficient triple pattern queries that enhance the property-value filter and available filter operations if a given centre M has less resources than a threshold θ, which was experimentally determined [16]. For instance, in case of property-value filter operations, θ = 5, 000. 5. CtC indices: Our implementation used with CtC indices and the HDT file. 6. Hybrid: Our implementation used with PV indices, the CtC indices, the HDT file and the FoQ index. Our evaluation initially also included other triple stores. However, we limit our result presentation to a comparison with RDFox and HDT Jena as these were 3
https://jena.apache.org/documentation/query/index.html.
HDT Bitmap Triple Indices for Efficient RDF Data Exploration
119
the best performing systems for the kinds of queries needed in faceted exploration. When interpreting the results, it should be noted that RDFox and HDT Jena offer full SPARQL 1.1 support and RDFox further supports incremental reasoning. This is in contrast to our HDT BT indices which are particularly optimized but also limited to faceted query answering. Our approach also comes with a single upfront HDT BT indices creation time. For instance, the largest considered data set, OpenPermID, can be loaded query ready in 93 s into an RDFox data store, whereas the generation of our CtC and PV indices alone requires about 11 m. The used queries and tasks in the experiments are designed to fulfill the following two requirements: (i) The queries should be representative for the data set. We use the principle of stratified randomisation to design queries, which correspond to a specific level of difficulty. Since it was not always possible to generate sufficient queries for all difficulty levels, the actual number of queries in an experiment may vary depending on the data set. We comment on this in the evaluation results. (ii) The queries should be representative for a faceted navigation scenario. To address this, we use the following query types and tasks in our benchmark: 1. Filter queries apply a sequence of property-value filters to a given centre M . Since incoming and outgoing filters require the same computational effort using the PV indices, only outgoing filters are considered. As result, all IRIs of the resources from the filtered centre are returned. Overall, we consider 1 to 3 filters over 3 levels of difficulty with 10 queries per difficulty level, where the relevant parameters for the difficulty level comprise the size of M and size of the result set obtained by applying the filter. Thus, the maximal number of evaluated filter queries per data set is nmax = 3 · 3 · 10 = 90. 2. The task of computing all available filters is based on a filter query, which is used to initialise a centre M . Relative to this centre, all available incoming and outgoing property-value filters are computed. As result, the number of distinct facet values for each facet is subsequently returned. Overall, we use 1 filter over 3 levels of difficulty with 10 queries per difficulty level, i.e., we evaluate at most nmax = 30 task executions per data set. 3. Class queries start with a given initial centre M0 and perform n incremental join operations to an incoming or outgoing reachable class. All IRIs of the resources from the final centre Mn are subsequently returned. The number of joins n corresponds to the number of used facets. The parameters, which were considered in the query generation process for the corresponding level of difficulty, are again the size of M0 and, on the other hand, the number of triples that participate in the join operations. We evaluate class queries that use 1 to 4 joins over 3 levels of difficulty with 10 queries per difficulty level, i.e., we evaluate at most nmax = 120 task executions per data set. The incremental join operations are explicitly indicated in the resulting SPARQL queries by using nested subqueries with single result variables to lower the number of intermediate results and eventually increase the efficiency, i.e., each SPARQL query begins with the resulting centre Mn and the preceding class
120
M. Wenzel et al.
Mn−1 is defined in an appropriate subquery which in turn uses a subquery for its respective predecessor Mn−2 if present. 4. The task of computing all reachable classes starts from a centre of resources, obtained using a class query, and computes the reachable classes relative to this centre. The returned result is the number of reachable classes, i.e., the number of incoming and outgoing facets w.r.t a reachable class as described in Definition 3. We use class queries with 1 join over 3 levels of difficulty and 10 queries per difficulty level. Overall, we evaluate at most nmax = 30 task executions per data set. 5. Hybrid queries combine class and filter queries. We obtain a centre M by executing a class query (which requires a series of joins) and then apply a filter query to the obtained centre. All IRIs of the resulting resources are returned. Again, we consider 3 levels of difficulty which coincide with the number of applied filters and the difficulty level of the underlying class query. We evaluate hybrid queries that use 1 to 4 joins over 3 levels of difficulty with 10 queries per difficulty level, i.e., we evaluate at most nmax = 120 task executions per data set. Note that all operations in our experiments compute exact results which is of course more expensive than the calculation of partial results. Partial results, however, often increase the scalability of the eventual application, which is observed, for instance, in the SPARQL query builder SPARKLIS [6]. The complete execution of an experiment comprises the following steps: First,the query engine is initialised and the queries are loaded from a file into main memory. Second, a warm-up round begins where all queries are executed before the actual experiment. Afterwards, the execution time of all queries is measured in two consecutive rounds and the minimum required time is documented. If a query requires more than ten seconds for the execution, a timeout occurs and is documented correspondingly. A timeout of ten seconds has been chosen because an execution time beyond ten seconds is unreasonable concerning the user-experience in an exploratory setting. 4.3
Experimental Results
In the following sections all results from the experiments are presented. The collected time measurements were evaluated using the programming language R and are summarized by box plots. The value n represents the actual number of queries from each experiment. Recall that not for all difficulty levels sufficiently many queries could be generated and, hence, n ≤ nmax . We present the experimental results of the four largest data sets from Table 1 for which the PV and CtC indices could be generated. The full experimental results and queries are available online [16]. Figure 7 shows the results of the filter queries. The PV indices and the Plain HDT approach perform equally well on all data sets – no considerable benefits are obtained using additional PV indices on top of the original HDT file. Apart from a few outliers, e.g., on the Reactome data set, RDFox is the leading approach for the resolution of filter queries with reference to the median since it is the lowest
HDT Bitmap Triple Indices for Efficient RDF Data Exploration
121
Fig. 7. Results of the filter query experiment
Fig. 8. Results of the available filters experiment
observed on all data sets. RDFox and the Jena ARQ query engine both utilise query planning in contrast to Plain HDT and the PV indices. The performance of our implementation could certainly be improved with additional query planning, which is a topic for future research. Figure 8 shows the results of the available filters experiment. Since the available filters are computed relative to the current centre, we only compare the PV
122
M. Wenzel et al.
Fig. 9. Results of the class query experiment
indices approach with the Plain HDT approach. A fair comparison with the other approaches, which execute SPARQL queries, would be difficult in this scenario. Apparently, the Plain HDT approach and the PV indices perform generally well in that 50% of the queries always require less than 1 s. For larger data sets such as Reactome and OpenPermID, the Plain HDT approach, however, reveals significant performance issues, where occasionally a query requires more than 5 s in case of the Reactome data set and in case of the OpenPermID data set even a timeout occurred. In contrast, the PV indices approach constantly requires less than 2 s and shows stable performance across all queries. The results of the class queries are shown in Fig. 9. Concerning the HDT Jena approach, at least 21% timeouts occurred on all data sets. Although RDFox requires in all cases less than 1 s for at least 75% of the queries, several outliers appear in case of the SciGraph and OpenPermID data set, where furthermore 1% of the queries timed out. Plain HDT shows a stable performance in case of the Panama Papers data set, but in other cases, such as OpenPermID, 18% timeouts occur and, in sum, about 25% of the queries require more than 5 s for the completion. The CtC indices show an overall stable performance with a maximum required execution time on the SciGraph data set at around 3 s. In Fig. 10, the results from the reachable classes task are presented. Since the reachable classes are computed relative to the current centre, we only compare the CtC indices approach with the Plain HDT approach. A fair comparison with the other approaches would be difficult in this scenario. As can be seen, the CtC indices outperform the Plain HDT approach for all data sets. Especially
HDT Bitmap Triple Indices for Efficient RDF Data Exploration
123
Fig. 10. Results of the reachable classes experiment
Fig. 11. Results of the hybrid query experiment
concerning the data sets SciGraph, Reactome and OpenPermID, Plain HDT requires in some cases even more than 10 s whereas the CtC indices need at most about 1 s for the execution. The results of the hybrid queries are presented in Fig. 11. Those approaches, which utilise query planing, i.e., the Jena ARQ query engine and RDFox, have evident benefits concerning the resolution of hybrid queries. For instance, in
124
M. Wenzel et al.
case of RDFox, 75% of the measured times from SciGraph and OpenPermID are considerably lower than those of the Plain HDT and the Hybrid approach. Nevertheless, at least 5% of the queries timed out in case of HDT Jena on all data sets and, in case of Reactome and OpenPermID, RDFox shows a worst case evaluation time of about 3 s and 7 s, respectively. The maximum execution time of the Hybrid approach is considerably lower on all data sets than the maximum time required by Plain HDT. The Hybrid approach has furthermore a worst case evaluation time of 2 s, as can be observed for the SciGraph data set, whereas, e.g., 38% of the queries executed by Plain HDT on the OpenPermID data set led to a time out.
5
Conclusion
In this paper, we propose an approach to generate additional indices on top of the RDF compression format HDT for the efficient exploration of RDF data sets. To achieve this objective, the Bitmap Triples (BT) data structure of the HDT file was extended to a BT index which is able to store subsets of the original RDF graph. In order to cover all required exploratory operations of a faceted navigation scenario, two kinds of BT indices have been introduced, namely the Property-Value (PV) and the Class-to-Class (CtC) indices. Our evaluation over real-world data sets shows that the generation of the CtC and PV indices is feasible for data sets with up to 150 million triples and 82 RDF classes. Neither the generation time of the PV nor of the CtC indices exceeded the duration for generating the original HDT file. Likewise, the file sizes of the PV and CtC indices do not surpass the original HDT file size. In the performance benchmark, the CtC indices, the PV indices and the Hybrid approach, i.e., the combination of both kinds of indices, show an overall stable performance for all considered exploratory operations across all data sets with a maximum execution time of 3 s. We conclude that such BT indices represent a significant contribution for the Semantic Web and faceted navigation in particular and that further improvements are possible, when the approach is combined with other optimisations such as query planning and a memory efficient BT indices generation method.
References 1. Semspect by derivo. http://semspect.de/. Accessed 14 Jan 2020 ˇ Zheleznyakov, D.: 2. Arenas, M., Cuenca Grau, B., Kharlamov, E., Marciuˇska, S., Faceted search over RDF-based knowledge graphs. J. Web Semant. 37, 55–74 (2016) 3. Bast, H., B¨ aurle, F., Buchhold, B., Haußmann, E.: Easy access to the freebase dataset. In: Proceedings of 23rd International Conference on World Wide Web, pp. 95–98 (2014) 4. Brisaboa, N.R., C´ anovas, R., Claude, F., Mart´ınez-Prieto, M.A., Navarro, G.: Compressed string dictionaries. In: Pardalos, P.M., Rebennack, S. (eds.) SEA 2011. LNCS, vol. 6630, pp. 136–147. Springer, Heidelberg (2011). https://doi.org/10. 1007/978-3-642-20662-7 12
HDT Bitmap Triple Indices for Efficient RDF Data Exploration
125
5. Fern´ andez, J.D., Mart´ınez-Prieto, M.A., Guti´errez, C., Polleres, A., Arias, M.: Binary RDF representation for publication and exchange (HDT). J. Web Semant. 19, 22–41 (2013) 6. Ferr´e, S.: Sparklis: an expressive query builder for SPARQL endpoints with guidance in natural language. Semant. Web 8(3), 405–418 (2017) 7. Heim, P., Ziegler, J., Lohmann, S.: gFacet: a browser for the web of data. In: Proceedings of International Workshop on Interacting with Multimedia Content in the Social Semantic Web, vol. 417, pp. 49–58. CEUR-WS.org (2008) 8. Hildebrand, M., van Ossenbruggen, J., Hardman, L.: /facet: a browser for heterogeneous semantic web repositories. In: Cruz, I., et al. (eds.) ISWC 2006. LNCS, vol. 4273, pp. 272–285. Springer, Heidelberg (2006). https://doi.org/10. 1007/11926078 20 9. Hyv¨ onen, E., Saarela, S., Viljanen, K.: Ontogator: combining view- and ontologybased search with semantic browsing. J. Inf. Retrieval 16, 17 (2003) 10. Kharlamov, E., Giacomelli, L., Sherkhonov, E., Cuenca Grau, B., Kostylev, E.V., Horrocks, I.: SemFacet: making hard faceted search easier. In: Proceedings of ACM on Conference on Information and Knowledge Management, pp. 2475–2478 (2017) 11. Liebig, T., Vialard, V., Opitz, M.: Connecting the dots in million-nodes knowledge graphs with SemSpect. In: Proceedings of International Semantic Web Conference (Posters, Demos & Industry Tracks) (2017) 12. Mart´ınez-Prieto, M.A., Arias Gallego, M., Fern´ andez, J.D.: Exchange and consumption of huge RDF data. In: Simperl, E., Cimiano, P., Polleres, A., Corcho, O., Presutti, V. (eds.) ESWC 2012. LNCS, vol. 7295, pp. 437–452. Springer, Heidelberg (2012). https://doi.org/10.1007/978-3-642-30284-8 36 13. Moreno-Vega, J., Hogan, A.: GraFa: scalable faceted browsing for RDF graphs. In: Vrandeˇci´c, D., et al. (eds.) ISWC 2018. LNCS, vol. 11136, pp. 301–317. Springer, Cham (2018). https://doi.org/10.1007/978-3-030-00671-6 18 14. Nenov, Y., Piro, R., Motik, B., Horrocks, I., Wu, Z., Banerjee, J.: RDFox: a highlyscalable RDF store. In: Arenas, M., et al. (eds.) ISWC 2015. LNCS, vol. 9367, pp. 3–20. Springer, Cham (2015). https://doi.org/10.1007/978-3-319-25010-6 1 15. Oren, E., Delbru, R., Decker, S.: Extending faceted navigation for RDF data. In: Cruz, I., et al. (eds.) ISWC 2006. LNCS, vol. 4273, pp. 559–572. Springer, Heidelberg (2006). https://doi.org/10.1007/11926078 40 16. Wenzel, M.: HDT bitmap triple indices - results of the experiments (Mar 2021). https://doi.org/10.5281/zenodo.4608413
Programming and Debugging with Semantically Lifted States Eduard Kamburjan(B) , Vidar Norstein Klungre, Rudolf Schlatte, Einar Broch Johnsen, and Martin Giese Department of Informatics, University of Oslo, Oslo, Norway {eduard,vidarkl,rudi,einarj,martingi}@ifi.uio.no
Abstract. We propose a novel integration of programming languages with semantic technologies. We create a semantic reflection mechanism by a direct mapping from program states to RDF knowledge graphs. This mechanism enables several promising novel applications including the use of semantic technology, including reasoning, for debugging and validating the sanity of program states, and integration with external knowledge graphs. Additionally, by making the knowledge graph accessible from the program, method implementations can refer to state semantics rather than objects, establishing a deep integration between programs and semantics. This allows the programmer to use domain knowledge formalized as, e.g., an ontology directly in the program’s control flow. We formalize this integration by defining a core object based programming language that incorporates these features. A prototypical interpreter is available for download.
1
Introduction
Knowledge graphs and ontologies are eminently useful representations of formal knowledge about individuals and universals. They are less suitable for the representation of change, and in particular dynamic behavior. Different approaches have been proposed that attempt to express program behavior in terms of actions on a DL interpretation [26] or a DL knowledge base [1]. A recent approach has combined a guarded command language with DL reasoning [6] to enable probabilistic model checking over the combination. Each of these approaches entails its own set of technical challenges, and they are also quite different from current state-of-the-art programming paradigms. In this work, we present a comparatively simple connection between programs and knowledge graphs: we give a direct mapping of program states in an objectbased language to an RDF graph, including the running program’s objects, fields, and call stack. An immediate application of this mapping is to use semantic technology for program debugging, visualisation, querying, validation, reasoning, etc. In this paper, semantic debugging refers to the process of detecting and correcting conceptual mistakes at the appropriate level of global object access instead of interacting with only individual objects, as in conventional debuggers. c Springer Nature Switzerland AG 2021 R. Verborgh et al. (Eds.): ESWC 2021, LNCS 12731, pp. 126–142, 2021. https://doi.org/10.1007/978-3-030-77385-4_8
Programming and Debugging with Semantically Lifted States
127
The RDF graph can be exposed within the programming language, which adds a semantic reflection layer to the programs. This enables semantic programming where the semantic view of the state can be exploited in the program. In particular, it allows one to use the knowledge of the application domain within the program. The programming language can further support a mechanism that extends the RDF graph with triples based on the results of specially designated methods. The approach is implemented and available. In this work, the RDF graph is close to the object structure, thus representing an internal domain of the program. Our long-term goal is to use the same principles for external domains that correspond to a program’s application domain. This will enable semantic integration between programs as well as linking them to external knowledge graphs and other data sources, thus extending ontologybased data access and integration (see e.g. [9]) to programs and behavioural specifications [13] that allow modeling of complex concurrent systems [16]. Contributions. The contributions of this paper are (1) the concept of interpreting a program state as a knowledge graph to enable semantic state access, (2) the application enabled by this concepts and (3) the SMOL language that implements the concept and exemplifies the applications. Paper Overview. Section 2 gives a motivating example of mapping program states to an ‘internal’ knowledge graph. Section 3 gives syntax and semantics of SMOL, the used programming language, and defines the mapping of SMOL program states to RDF graphs. Section 4 extends SMOL with a statement to access its own knowledge graph, thereby adding reflection by semantic state access. Section 5 extends SMOL with a way to add computed triples to the knowledge graph. Section 6 describes the implementation, Sect. 7 discusses related work, and Sect. 8 concludes. Further details of this work may be found in an accompanying technical report [17].
2
Motivating Example
We start by giving an example of the use of domain models in programming to demonstrate semantic bugs and motivate semantic programming. Semantic bugs are programming errors that arise from mismatches between the implementation and the domain that is implemented. Such bugs are unlikely to cause immediate runtime errors and are, thus, harder to catch. Instead, they require to examine the program state through a conceptual lens, i.e., in terms of the implemented domain. Semantic debugging is the process of detecting and fixing such errors. The implemented domain can be external or internal. An external domain relates the implementation to some concept outside the program. For example, a class modeling a car that contains a list of its wheels. If the list contains only one element, this is a semantic bug: the object does not represent a car. An internal domain relates the implementation to itself. Example 1. Consider 2–3 trees [2], a data structure to access key-value pairs. Such trees have three kinds of nodes: leaves have one or two data values and no
128
E. Kamburjan et al.
children, 2-nodes that have one data value and two children and 3-nodes that have two data values and three children. The keys are sorted within the tree; e.g., in a 2-node, all keys below the left child are smaller than the key stored in the node and all below the right child are larger. Listing 1 shows an implementation of such a tree. In the implementation, a node is a 2-node if the fields dataR and childR are set to null and the other fields are non-null. A node is a 3-node if all fields are non-null. A leaf has no children and at least one data value. 1 2 3 4 5 6 7 8 9
class Node(dataL, dataR, childL, get(k) if(this.dataL = null) then r if(k = this.dataL.key) then r if(k ). KG based question answering (KGQA) is already a well-researched topic [6]. However, generative dialogue systems with integrated KGs have only been explored more recently [7, 12, 20]. To model the response using the KG, all current methods assume that the entity in the input query or a sub-graph of the whole KG, which can be used to generate the answer, is already known [20, 36]. This assumption makes it difficult to scale such systems to real-world scenarios, because the task of extracting sub-graphs or, alternatively, performing entity linking in large knowledge graphs is non-trivial [27]. An example of a knowledge graph based dialogue system is shown in Fig. 1. In order to generate the response James Cameron is the director, the system has to link the entity mentioned in the question in the first turn i.e. Titanic, and identify the relation in the KG connecting the entities Titanic with James Cameron, namely directed by. Additionally, to obtain a natural dialogue system, it should also reply with coherent responses (e.g. “James Cameron is the director”) and should be able to handle small-talk such as greetings, humour etc. Furthermore, in order to perform multi-turn dialogues, the system should also be able to perform co-reference resolution and connect the pronoun (he) in the second question with James Cameron. In order to tackle these research challenges, we model the dialogue generation process by jointly learning the entity and relation information during the dialogue generation process using a pre-trained BERT model in an end-to-end manner. The model’s response generation is designed to learn to predict relation(s) from the input KG instead of the actual object(s) (intermediate representation). Additionally, a graph Laplacian based method is used to encode the input sub-graph and use it for the final decoding process.
Grounding Dialogue Systems via Knowledge Graph Aware Decoding
325
Experimental results suggest that the proposed method improves upon previous state-of-the-art approaches for both goal and non-goal oriented dialogues. Our code is publicly available on Github1 . Overall, the contributions of this paper are as follows: – A novel approach, leveraging the knowledge graph elements (entities and relations) in the questions along with pre-trained transformers, which helps in generating suitable knowledge grounded responses. – We have also additionally encoded the sub-graph structure of the entity of the input query with a Graph Laplacian, which is traditionally used in graph neural networks. This novel decoding method further improves performance. – An extensive evaluation and ablation study of the proposed model on two datasets requiring grounded KG knowledge: an in-car dialogue dataset and soccer dialogues for goal and non-goal oriented setting, respectively. Evaluation results show that the proposed model produces improved knowledge grounded responses compared to other state-of-the-art dialogue systems w.r.t. automated metrics, and humanevaluation for both goal and non-goal oriented dialogues.
2 Model Description
Fig. 2. KGIRNet model diagram.
We aim to solve the problem of answer generation in a dialogue using a KG as defined below. 1
https://github.com/SmartDataAnalytics/kgirnet/.
326
D. Chaudhuri et al.
Definition 1 (Knowledge Graph). Within the scope of this paper, we define a knowledge graph KG as a labelled, undirected multi-graph consisting of a set V of nodes and a set E of edges between them. There exists a function, fl that maps the nodes and vertices of a graph to a string. The neighborhood of a node of radius k (or k-hop) is the set of nodes at a distance equal to or less than k. This definition is sufficiently generic to be applicable to knowledge graphs based on RDF2 (Resource Description Framework) as well as property graphs [13]. The vertices V of the KG represent entities e ∈ V , while the edges represent the relationships between those entities. A fact is an ordered triple consisting of an entity e (or subject s), an object o and the relation r (a.k.a. predicate p) between them, denoted by (s, p, o). The proposed model for dialogue generation, which we call KGIRNet, is quintessentially a sequence-to-sequence based model with a pre-trained transformer serving as its input as illustrated in Fig. 2. In contrast to previous works, we introduce an intermediate query representation using the relation information, for training. We also employ a Graph Laplacian based method for encoding the input sub-graph of the KG that aids in predicting the correct relation(s) as well as filter out irrelevant KG elements. Our approach consists of the following steps for which more details are provided below: Firstly, we encode the input query q with a pre-trained BERT model (Sect. 2.1). Next we detect a core entity e occurring in q (Sect. 2.2). Input query q and generated output is appended to the dialogue context in every utterance. The input query, encoded using the BERT model is then passed through an LSTM encoder to get an encoded representation (Sect. 2.3). This encoded representation is passed onto another LSTM decoder (Sect. 2.5), which outputs a probability distribution for the output tokens at every timestep. Additionally, the model also extracts the k-hop neighbourhood of e in the KG and encodes it using graph based encoding (Sect. 2.6) and perform a Hadamard product with token probability distribution from the decoder. The decoding process stops when it encounters a special token, < EOS > (end of sentence). Dotted lines in the model diagram represent operations performed at a different time-step t in the decoding process where solid lines are performed once for each utterance or input query. In this work, we define complex questions as questions which require multiple relations to answer the given question. For example, for the following query: “please tell me the location, time and the parties that are attending my meeting”, the model needs to use 3 relations from the KG for answering, namely location, time and parties. The answer given by the model could be : “you have meeting scheduled on friday at 10am with boss in conference room 102 to go over budget”. The model is able to retrieve important relation information from the KG during decoding. However, the model is not able to handle questions which go beyond the usage of explicitly stored relations and require inference capabilities . 2.1
Query Encoding
BERT is a pre-trained multi-layer, bi-directional transformer [32] model proposed in [8]. It is trained on unlabelled data for two-phased objective: masked language model 2
https://www.w3.org/RDF/.
Grounding Dialogue Systems via Knowledge Graph Aware Decoding
327
and next sentence prediction. For encoding any text, special tokens [CLS] and [SEP] are inserted at the beginning and the end of the text, respectively. In the case of KGIRNet, the input query q = (q1 , q2 , ...qn ) at turn td in the dialogue, along with the context up to turn td − 1 is first encoded using this pre-trained BERT model which produces hidden states (T1 , T2 ....Tn ) for each token and an aggregated hidden state representation C for the [CLS] (first) token. We encode the whole query q along with the context, concatenated with a special token, < EOU > (end of utterance). 2.2 Entity Detection The aggregated hidden representation from the BERT model C is passed to a fully connected hidden layer to predict the entity einp ∈ V in the input question as given by einp = sof tmax(went C + bent )
(1)
where, went and bent are the parameters of the fully connected hidden layer. 2.3 Input Query Encoder The hidden state representations (T1 , T2 ....Tn ) of the input query q (and dialogue context) using BERT is further encoded using an LSTM [14] encoder which produces a final hidden state at the n-th time-step given by hen = fenc (Tn , hen−1 )
(2)
fenc is a recurrent function and Tn is the hidden state for the input token qn from BERT. The final representation of the encoder response is a representation at every n denoted by (3) He = (he0 , he1 ....heN ) 2.4 Intermediate Representation As an intermediate response, we let the model learn the relation or edge label(s) required to answer the question, instead of the actual object label(s). In order to do this, we additionally incorporated the relation labels obtained by applying the label function fl to all edges in the KG into the output vocabulary set. If the output vocabulary size for a vanilla sequence-to-sequence model is vo , the total output vocabulary size becomes vod which is the sum of vo and vkg . The latter being the labels from applying the fl to all edges (or relations) in the KG. For example, if in a certain response, a token corresponds to an object label ol (obtained by applying fl to o) in the fact (e, r, o), the token is replaced with a KG token vkg corresponding to the edge or relation label rl of r ∈ E in the KG. During training, the decoder would see the string obtained by applying fl to the edge between the entities Titanic and James Cameron, denoted here as r:directedBy. Hence, it will try to learn the relation instead of the actual object. This makes the system more generic and KG aware, and easily scalable to new facts and domains. During evaluation, when the decoder generates a token from vkg , a KG lookup is done to decode the label ol of the node o ∈ V in the KG (V being the set of nodes or vertices in the KG). This is generally done using a SPARQL query.
328
2.5
D. Chaudhuri et al.
Decoding Process
The decoding process generates an output token at every time-step t in the response generation process. It gets as input the encoded response He and also the KG distribution from the graph encoding process as explained later. The decoder is also a LSTM, which is initialized with the encoder last hidden states and the first token used as input to it is a special token, < SOS > (start of sentence). The decoder hidden states are similar to that of the encoder as given by the recurrent function fdec hdn = fdec (wdec , hdn−1 )
(4)
This hidden state is used to compute an attention over all the hidden states of the encoder following [19], as given by αt = sof tmax(Ws (tanh(Wc [He ; hdt ]))
(5)
where, Wc and Ws are the weights of the attention model. The final weighted context representation is given by αt ht (6) h˜t = t
This representation is concatenated (represented by ;) with the hidden states of the decoder to generate an output from the vocabulary with size vod . The output vocab distribution from the decoder is given by Odec = Wo ([ht ; h˜dt ])
(7)
In the above equation, Wo are the output weights with dimension Rhdim Xvod . hdim being the dimension of the hidden layer of the decoder LSTM. The total loss is the sum of the vocabulary loss and the entity detection loss. Finally, we use beam-search [31] during the decoding method. 2.6
Sub-Graph Encoding
In order to limit the KGIRNet model to predict only from those relations which are connected to the input entity predicted from step 2.2, we encode the sub-graph along with its labels and use it in the final decoding process while evaluating. The k-hop sub-graph of the input entity is encoded using Graph Laplacian [16] given by ˜ in (8) Genc = D−1 Af ˜ Where, A = A + I. A being the adjacency matrix, I is the identity matrix and D is the degree matrix. fin is a feature representation of the vertices and edges in the input graph. Genc is a vector with dimensions Rik corresponding to the total number of nodes and edges in the k-hop sub-graph of e. An example of the sub-graph encoding mechanism is shown in Fig. 3. The final vocabulary distribution Of ∈ Rvod is a Hadamard product of this graph vector and the vocabulary distribution output from the decoder. Of = Odec Genc
(9)
Grounding Dialogue Systems via Knowledge Graph Aware Decoding
329
Fig. 3. Sub-graph encoding using graph laplacian.
This step essentially helps the model to give additional importance to the relations connected at k-hop based on its similarity with the query also to filter(mask) out relations from the response which are not connected to it. For the query in 3 who is the director of Avatar and how was it rated ? The graph laplacian based encoding method using only relation labels already gives higher scores for the relations directed by and rating, which are required by the question. This vector when multiplied with the final output vocabulary helps in better relation learning.
3 Experimental Setup 3.1 Datasets Available datasets for knowledge grounded conversations are the in-car dialogue data as proposed by [12] and soccer dialogues over football club and national teams using a knowledge graph [7]. The former contains dialogues for assisting the driver of a car with data related to weather, schedules and navigation, in a goal-oriented setting. The soccer dataset contains non-goal oriented dialogues about questions on different soccer teams along with a knowledge graph consisting of facts extracted from Wikipedia about the respective clubs and national soccer teams. Both the datasets were collected using Amazon Mechanical Turk (AMT) by the respective authors [7, 12]. The statistics of the datasets are provided in Table 1. As observed, the number of dialogues for both the dataset is low. To perform a KG grounded dialogue as in KG based question-answering [10], it is important to annotate the dialogues with KG information such as the entities and
330
D. Chaudhuri et al.
relations, the dialogues are about. Such information were missing in the soccer dataset, hence we have semi-automatically annotated them with the input entity einp in the query q and the relations in the k-hop sub-graph of the input entity required to answer q. For the domain of in-car it was possible to automatically extract the entity and relation information from the dialogues and input local KG snippets. Table 1. Dataset statistics. In-car dialogues
Soccer dialogues
Number of triples, entity, relations 8561, 271, 36
4301, 932, 30
Train Validation Test Number of dialogues Number of utterances KG-grounded questions (%)
3.2
2011 242 5528 657 44.95 33.94
Train Validation Test
256 1328 709 6523 43.84 6.53
149 737 4.61
348 1727 3.88
Evaluation Metrics
We evaluate the models using the standard evaluation metrics BLEU [25] and Entity F1 scores as used in the discussed state-of-the-art models. However, unlike [20] we use Entity F1 scores based on the nodes V of the KG, as inspired by previous works on KG based question answering [3]. Additionally, we use METEOR [1] because it correlates the most with human judgement scores [30]. 3.3
Model Settings
Table 2. Evaluation on goal and non-goal oriented dialogues. Models
In-car dialogues
Soccer dialogues
Inference time
BLEU Entity F1 METEOR BLEU Entity F1 METEOR Utterances/sec Seq2Seq
4.96
10.70
21.20
1.37
0.0
7.8
133
Mem2Seq [20]
9.43
24.60
28.80
0.82
04.95
7.8
88
GLMP [36]
9.15
21.28
29.10
0.43
22.40
7.7
136
Transformer [32] 8.27
24.79
29.06
0.45
0.0
6.7
7
DialoGPT [39]
7.35
21.36
20.50
0.76
0.0
5.5
2
KG-Copy [7]
–
–
–
1.93
03.17
10.89
262
KGIRNet
11.76
32.67
30.02
1.51
34.33
8.24
37
For entity detection we used a fully connected layer on top of CNN-based architecture. Size of the hidden layer in the fully connected part is 500 and a dropout value of 0.1 is used and ReLU as the activation function. In the CNN part we have used 300 filters with kernel size 3, 4 and 5. We use BERT-base-uncased model for encoding the input
Grounding Dialogue Systems via Knowledge Graph Aware Decoding
331
query. The encoder and decoder is modelled using an LSTM (long short term memory) with a hidden size of 256 and the KGIRNet model is trained with a batch size of 20. The learning rate of the used encoder is 1e−4. For the decoder we select a learning rate of 1e−3. We use the Adam optimizer to optimize the weights of the neural networks. For all of our experiments we use a sub-graph size of k = 2. For calculating fin as in Eq. 8, we use averaged word embedding similarity values between the query and the labels of the sub-graph elements. The similarity function used in this case is cosine similarity. We save the model with best validation Entity f1 score. Table 3. Relation linking accuracy on SQB [37] dataset. Method
Model
Accuracy
Supervised
Bi-LSTM [21] HR-LSTM [38]
38.5 64.3
Unsupervised Embedding Similarity 60.1 Graph Laplacian (this work) 69.7
4 Results In this section, we summarize the results from our experiments. We evaluate our proposed model KGIRNet against the current state-of-the-art systems for KG based dialogues; namely Mem2Seq [20], GLMP [36], and KG-Copy [7]3 . To include a baseline method, the results from a vanilla Seq2Seq model using an LSTM encoder-decoder are also reported in Table 2, along with a vanilla transformer [32] and a pre-trained GPT-2 model, DialoGPT [39] fine-tuned individually on both the datasets. We observe that KGIRNet outperforms other approaches for both goal (in-car) and non-goal oriented (soccer) dialogues except for BLEU and METEOR scores on the soccer dataset. The effect of knowledge groundedness is particularly visible in the case of soccer dialogues, where most models (except GLMP) produces feeble knowledge grounded responses. The Entity F1 score used here is adapted from [3] and is defined as the average of F1-scores of the set of predicted objects, for all the questions in the test set. In addition to evaluating dialogues, we also evaluate the proposed graph laplacian based relation learning module for the task of knowldge-graph based relation linking. Although, it is a well-researched topic and some systems claim to have solved the problem [26], but such systems are not able to handle relations which are not present in the training data [37]. The latter also proposed a new, balanced dataset (SQB) for simple question answering which has same proportions of seen and unseen relations in the test or evaluation set. We have evaluated our unsupervised graph laplacian based method for relation linking on the SQB dataset against supervised methods namely Bi-LSTM [21], hr-bilstm [38] and unsupervised method such as text embedding based similarity between the query and the relations connected to the subject entity with 1-hop. 3
KG-Copy reports on a subset of the in-car testset hence it is not reported here.
332
D. Chaudhuri et al.
The results are reported in Table 3. As observed, Graph Laplacian performs better wrt. supervised methods on unseen relations and also better than shallow embedding based similarity. This is one of the motivation for using this simple method during KGIRNet’s decoding process. We run all the inference on a setup with 32 GB of RAM and 8 GB of VGA and a Bandwidth of 256.3 GB/s.
5 Discussion For in-car dialogues, we train and evaluate on queries which require knowledge from the KG, hence we omit the scheduling conversations where the driver asks the car to schedule a meeting/conference. In order to get the knowledge graph candidate triples for all the other models (Mem2Seq and GLMP), we provide them with the 2-hop subgraph of the correct input entity instead of the local knowledge as used in the respective models; this, represents a scenario closer to a real-world KG grounded conversation. For the in-car dataset, the human baseline BLEU score as reported in [12] is 13.5 (the KGIRNet score is 11.76). The BLEU scores for soccer are low because non-goal oriented dialogues are more complicated to model due to large vocabulary sizes (more than 3 times the vocabulary size of the of in-car dataset). Also in the case of soccer dialogues, number of factual conversation is low (4%) compared to the total number of utterances and also the conversations are more generic and repetitive in nature. Table 4. Analyzing sample predictions. Input query
True response
Predicted responses Mem2Seq
KGIRNet
(S) who is currently coaching bvb dortmund
lucien favre
the is the coach
yes , they have a good
lucien favre is the coach of bvb dortmund
(S) when did italy last win the world cup
2006
italy won the world cup in 2006
i think they have a good team
italy won the world cup in 2006
(C) what time is my doctorappointment?
your doctorappointment is scheduled for friday at 11am
your next is at 1pm at 7pm
your your doctorappointment is doctorappointment is at 1pm on friday at 11am
(C) i need gas
Valero is 4 miles away
there is a valero away
chevron is gas station away chevron is at away
5.1
GLMP
there is a valero nearby
Human Evaluation
We perform a human-based evaluation on the whole test dataset of the generated responses from the KGIRNet model and its closest competitors, i.e. Mem2Seq, GLMP and DialoGPT models. We asked 3 internal independent annotators who are not the authors of this paper (1 from CS and 2 from non-CS background) to rate the quality of the generated responses between 1–5 with respect to the dialogue context (higher is
Grounding Dialogue Systems via Knowledge Graph Aware Decoding
333
better). Note that for each dataset, we provide the annotators with 4 output files in CSV format (containing the predictions of each model) and the knowledge graph in RDF format. Each of the CSV files contains data in 5 columns: question, original response, predicted response, grammatical correctness, similarity between original and predicted response. In the provided files, the 4th (grammatically correctness) and 5th (similarity between original and predicted response) columns are empty and we ask the annotators to fill them with values (within a range of 1–5) according to their judgement. The measures requested to evaluate upon are correctness (Corr.) and human-like (human) answer generation capabilities. Correctness is measured by comparing the response to the correct answer object. Reference responses are provided besides the system generated response in order to check the factual questions. The results are reported in Table 5a. Cohen’s Kappa of the annotations is 0.55. 5.2 Ablation Study As an ablation study we train a sequence-to-sequence model with pre-trained fasttext embeddings as input (S2S), and the same model with pre-trained BERT as input embedding (S2S BERT). Both these models do not have any information about the structure of the underlying knowledge graph. Secondly, we try to understand how much the intermediate representation aids to the model, so we train a model (KGIRNet NB) with fasttext embeddings as input instead of BERT along with intermediate relation representation. Thirdly, we train a model with pre-trained BERT but without the haddamard product of the encoded sub-graph and the final output vocabulary distribution from Step 2.6. This model is denoted as KGIRNet NS. As observed, models that are devoid of any KG structure has very low Entity F1 scores, which is more observable in the case of soccer dialogues since the knowledge grounded queries are very low, so the model is not able to learn any fact(s) from the dataset. The proposed intermediate relation learning along with Graph Laplacian based sub-graph encoding technique observably assists in producing better knowledge grounded responses in both the domains; although, the latter aids in more knowledge groundedness in the domain of soccer dialogues (higher Entity F1 scores). We also did an ablation study on the entity detection accuracy of the end-to-end KGIRNet model in the domain of in-car and compared it with a standalone Table 5. In-depth evaluation of KGIRNet model. In-Car Corr. Human Mem2Seq 3.09 3.70 GLMP 3.01 3.88 DialoGPT 2.32 3.43
Soccer Corr. Human 1.14 3.48 1.10 2.17 1.32 3.88
In-Car Dialogues BLEU EntityF1 4.96 S2S 10.70 7.53 S2S BERT 09.10 KGIRNet NB 9.52 29.03 KGIRNet NS 11.40 33.03
KGIRNet 3.60
1.59
KGIRNet
Models
4.42
3.78
(a) Human evaluation.
Models
11.76
32.67
Soccer Dialogues BLEU EntityF1 1.49 0.0 1.44 0.0 0.91 29.85 1.05 28.35 1.51
(b) Ablation study.
34.32
334
D. Chaudhuri et al.
Convolutional neural network (CNN) model which predicts the entity from the input query, the accuracies are 79.69% and 77.29% respectively. 5.3
Qualitative Analysis
The responses generated by KGIRNet are analyzed in this section. Responses from some of the discussed models along with the input query are provided in Table 44 . We compare the results with two other state-of-the-art models with the closest evaluation scores, namely Mem2Seq and GLMP. The first two responses are for soccer dialogues, while the latter two are for in-car setting. We inspect that qualitatively the proposed KGIRNet model produces better knowledge grounded and coherent responses in both the settings. In the case of soccer dialogues, predicting single relation in the response is sufficient, while for the case of in-car dialogues, responses can require multiple relation identification. KGIRNet model is able to handle such multiple relations as well (e.g., r:date friday and r:time 11 am for the third utterance). Table 6. Analyzing fact-fullness of KGIRNet. Input query
True response
Predicted response
Intermediate response
Who is senegal captain?
Cheikhou kouyate
Sadio mane is the captain of senegal
r:captain is the captain of @entity
Who is the goalie for iceland
Hannes halldorsson Runar alex runarsson
r :goalkeeper
To understand more about the advantages of KG grounded generation process, consider the examples from the soccer dataset below in Table 6, in which the model has failed. We have also included the intermediate responses that are generated from the decoder before the KG lookup phase for the reference. In the first case, while constructing the KG, the captain was Sadio Mane, whereas the during the dialogue collection phase the probable captain was Checikhou Kouyate (as per the annotator). These errors on temporal information can easily be tackled using Knowledge Grounded dialogue systems, where the system can potentially reflect current information with updated real world knowledge. For the second case, the current main goalkeeper for the Iceland national football team is Hannes Halld´orsson; however, R´unar Alex R´unarsson is also among the 3 goalkeepers for the team and the model has no additional information to disambiguate between them to produce the same response as the human annotator. KGIRNet is also able to infer conversational context implicitly in dialogues with the system (Table 7).
4
In the table (S) and (C) refers to example from Soccer and In-car dataset respectively.
Grounding Dialogue Systems via Knowledge Graph Aware Decoding
335
Table 7. A conversation with KGIRNet. User:
what s the weather forecast for today and tomorrow ?
KGIRNet: what city do you want the weather for User:
los angeles
KGIRNet: it will be 40f - 60f on monday warm on tuesday windy on wednesday hot on thursday User:
thanks
KGIRNet: you are welcome
5.4 Error Analysis To analyze more on the shortcomings of our proposed KGIRNet, we stated some sample erroneous responses from the model in Table 8. The first three are from soccer and the rest in-car dialogues. The model often produces generic responses for soccer as in the first example. Our model is only able to handle simple factoid queries and not able to answer queries requiring comparative reasoning such as best player, youngest player etc., as observable from the second and third cases. In the second case, the model answers with the coach’s name and when asked for the best player for Argentina and it replies with the name of an Uruguayan player in the third case. The model also produces generic relations like coach name, number of world cup championship as response when any such keyword is present in the input. For the in-car dataset, the replies are less generic and more coherent; however, in cases like the fourth example, the model is not able to perform logical reasoning (negation). Moreover, the model fails in cases where the input entity is not recognized correctly as in case of the last example. Although, the name of the friend is fetched from the vocabulary, but the predicted entity is wrong hence the model is not able to decode the relation r:address from the KG during decoding. Table 8. Error analysis of KGIRNet. Input query
True response
Predicted response
Portugal win the last eurocup?
Yes they won the last europcup
Portugal has won the world cup
Who is switzerland´s best player?
Xherdan shaqiri
Petkovic is the coach of switzerland
Who is considered their best player?
Traditionally their top scorers
Luis suarez is the best player in argentina
will it be warm in grand rapids on saturday
It will not be warm in grand rapids on saturday
It is not predicted to fall on tuesday in grand rapids
Where does my friend live?
Tom lives at 580 van ness ave
Tom s house is located at r:address
336
D. Chaudhuri et al.
In general, the model’s entity detection fails in case of conversations with long dialogue contexts. Incorporating KG information into the entity detection process, where we consider the sub-graph of the entity in the first interaction can potentially help in further performance improvements.
6 Related Work Leveraging background information for dialogue system improvement is a wellresearched topic, especially in goal-oriented setting [2, 9, 35]. [12] proposed the in-car dataset which uses a knowledge base for in-car conversation about weather, location etc. Recently, [20] proposed memory-network based encoder-decoder architecture for integrating knowledge into the dialogue generation process on this dataset. Improved models in this task are proposed by [15, 36]. [7] proposed a soccer dialogue dataset along with a KG-Copy mechanism for non-goal oriented dialogues which are KG-integrated. In a slightly similar research line, in past years, we also notice the use of variational autoencoders (VAE) [17, 40] and generative adversarial networks (GANs) [18, 23] in dialogue generation. However, knowledge graph based dialogue generation is not wellexplored in these approaches. More recently, transformer-based [32] pre-trained models have achieved success in solving various downstream tasks in the field of NLP such as question answering [29] [8], machine translation [34], summarization [11]. Following the trend, a hierarchical transformer is proposed by [28] for task-specific dialogues. The authors experimented on MultiWOZ dataset [5], where the belief states are not available. However, they found the use of hierarchy based transformer models effective in capturing the context and dependencies in task-specific dialogue settings. In a different work, [24] experimented transformer-based model on both the task-specific and non-task specific dialogues in multi-turn setting. In a recent work, [39] investigated on transformer-based model for non-goal oriented dialogue generation in single-turn dialogue setting. Observing the success of transformer-based models over the recurrent models in this paper we also employ BERT in the dialogue generation process which improves the quality of generated dialogues (discussed in Sect. 4 and 5). In past years, there is a lot of focus on encoding graph structure using neural networks, a.k.a. Graph Neural Networks (GNNs) [4, 33]. In the field of computer vision, Convolutional Neural Networks (CNNs) are used to extract the most meaningful information from grid-like data structures such as images. A generalization of CNN to graph domain, Graph Convolutional Networks (GCNs) [16] has become popular in the past years. Such architectures are also adapted for encoding and extracting information from knowledge graphs [22]. Following a similar research line, in this paper, we leverage the concept of Graph Laplacian [16] for encoding sub-graph information into the learning mechanism.
7 Conclusion and Future Work In this paper, we have studied the task of generating knowledge grounded dialogues. We bridged the gap between two well-researched topics, namely knowledge grounded
Grounding Dialogue Systems via Knowledge Graph Aware Decoding
337
question answering and end-to-end dialogue generation. We propose a novel decoding method which leverages pre-trained transformers, KG structure and Graph Laplacian based encoding during the response generation process. Our evaluation shows that out proposed model produces better knowledge grounded response compared to other stateof-the-art approaches, for both the task and non-task oriented dialogues. As future work, we would like to focus on models with better understanding of text in order to perform better KG based reasoning. We also aim to incorporate additional KG structure information in the entity detection method. Further, a better handling of infrequent relations seen during training may be beneficial. Acknowledgement. We acknowledge the support of the excellence clusters ScaDS.AI (BmBF IS18026A-F), ML2R (BmBF FKZ 01 15 18038 A/B/C), TAILOR (EU GA 952215) and the projects SPEAKER (BMWi FKZ 01MK20011A) and JOSEPH (Fraunhofer Zukunftsstiftung).
References 1. Banerjee, S., Lavie, A.: Meteor: An automatic metric for MT evaluation with improved correlation with human judgments. In: Proceedings of the acl Workshop on Intrinsic and Extrinsic Evaluation Measures for Machine Translation and/or Summarization, pp. 65–72 (2005) 2. Bordes, A., Boureau, Y.L., Weston, J.: Learning end-to-end goal-oriented dialog. arXiv preprint arXiv:1605.07683 (2016) 3. Bordes, A., Usunier, N., Chopra, S., Weston, J.: Large-scale simple question answering with memory networks. ArXiv abs/1506.02075 (2015) 4. Bronstein, M.M., Bruna, J., LeCun, Y., Szlam, A., Vandergheynst, P.: Geometric deep learning: going beyond euclidean data. IEEE Signal Process. Mag. 34(4), 18–42 (2017) 5. Budzianowski, P., et al.: Multiwoz-a large-scale multi-domain wizard-of-oz dataset for taskoriented dialogue modelling. arXiv preprint arXiv:1810.00278 (2018) 6. Chakraborty, N., Lukovnikov, D., Maheshwari, G., Trivedi, P., Lehmann, J., Fischer, A.: Introduction to neural network based approaches for question answering over knowledge graphs (2019) 7. Chaudhuri, D., Rony, M.R.A.H., Jordan, S., Lehmann, J.: Using a KG-copy network for nongoal oriented dialogues. In: Ghidini, C. (ed.) ISWC 2019. LNCS, vol. 11778, pp. 93–109. Springer, Cham (2019). https://doi.org/10.1007/978-3-030-30793-6 6 8. Devlin, J., Chang, M.W., Lee, K., Toutanova, K.: Bert: Pre-training of deep bidirectional transformers for language understanding. In: NAACL-HLT, (1) (2019) 9. Dhingra, B., et al.: Towards end-to-end reinforcement learning of dialogue agents for information access (2016) 10. Diefenbach, D., Lopez, V., Singh, K., Maret, P.: Core techniques of question answering systems over knowledge bases: a survey. Knowl. Inf. Syst. 55(3), 529–569 (2018) 11. Egonmwan, E., Chali, Y.: Transformer-based model for single documents neural summarization. In: Proceedings of the 3rd Workshop on Neural Generation and Translation, pp. 70–79 (2019) 12. Eric, M., Krishnan, L., Charette, F., Manning, C.D.: Key-value retrieval networks for taskoriented dialogue. In: Proceedings of the 18th Annual SIGdial Meeting on Discourse and Dialogue (August 2017) 13. Gubichev, A., Then, M.: Graph pattern matching: Do we have to reinvent the wheel? In: Proceedings of Workshop on Graph Data, ACM (2014) 14. Hochreiter, S., Schmidhuber, J.: Long short-term memory. Neural Comput. 9(8), 1735–1780 (1997)
338
D. Chaudhuri et al.
15. Kassawat, F., Chaudhuri, D., Lehmann, J.: Incorporating joint embeddings into goal-oriented dialogues with multi-task learning. In: Hitzler, P. (ed.) ESWC 2019. LNCS, vol. 11503, pp. 225–239. Springer, Cham (2019). https://doi.org/10.1007/978-3-030-21348-0 15 16. Kipf, T.N., Welling, M.: Semi-supervised classification with graph convolutional networks. arXiv preprint arXiv:1609.02907 (2016) 17. Li, R., Li, X., Chen, G., Lin, C.: Improving variational autoencoder for text modelling with timestep-wise regularisation. In: Proceedings of the 28th International Conference on Computational Linguistics (December 2020) 18. L´opez Zorrilla, A., De Velasco V´azquez, M., Torres Bara˜nano, M.I.: A differentiable generative adversarial network for open domain dialogue (2019) 19. Luong, M.T., Pham, H., Manning, C.D.: Effective approaches to attention-based neural machine translation. arXiv preprint arXiv:1508.04025 (2015) 20. Madotto, A., Wu, C.S., Fung, P.: Mem2Seq: Effectively incorporating knowledge bases into end-to-end task-oriented dialog systems. In: Proceedings of the 56th Annual Meeting of the Association for Computational Linguistics, vol. 1, Long Papers (July 2018) 21. Mohammed, S., Shi, P., Lin, J.: Strong baselines for simple question answering over knowledge graphs with and without neural networks. In: Proceedings of the 2018 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, vol. 2, Short Papers (June 2018) 22. Neil, D., Briody, J., Lacoste, A., Sim, A., Creed, P., Saffari, A.: Interpretable graph convolutional neural networks for inference on noisy knowledge graphs (2018) 23. Olabiyi, O., Salimov, A.O., Khazane, A., Mueller, E.: Multi-turn dialogue response generation in an adversarial learning framework. In: Proceedings of the First Workshop on NLP for Conversational AI (August 2019) 24. Oluwatobi, O., Mueller, E.: Dlgnet: a transformer-based model for dialogue response generation. In: Proceedings of the 2nd Workshop on Natural Language Processing for Conversational AI, pp. 54–62 (2020) 25. Papineni, K., Roukos, S., Ward, T., Zhu, W.J.: Bleu: a method for automatic evaluation of machine translation. In: Proceedings of the 40th Annual Meeting on Association for Computational Linguistics, pp. 311–318. Association for Computational Linguistics (2002) 26. Petrochuk, M., Zettlemoyer, L.: SimpleQuestions nearly solved: a new upper bound and baseline approach. In: Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing (October–November 2018) 27. Rosales-M´endez, H., Poblete, B., Hogan, A.: What should entity linking link? In: AMW (2018) 28. Santra, B., Anusha, P., Goyal, P.: Hierarchical transformer for task oriented dialog systems. arXiv preprint arXiv:2011.08067 (2020) 29. Shao, T., Guo, Y., Chen, H., Hao, Z.: Transformer-based neural network for answer selection in question answering. IEEE Access 7, 26146–26156 (2019) 30. Sharma, S., El Asri, L., Schulz, H., Zumer, J.: Relevance of unsupervised metrics in task-oriented dialogue for evaluating natural language generation. arXiv preprint arXiv:1706.09799 (2017) 31. Tillmann, C., Ney, H.: Word reordering and a dynamic programming beam search algorithm for statistical machine translation. Comput. Linguist. 29(1), 97–133 (2003) 32. Vaswani, A., et al.: Attention is all you need. In: Advances in Neural Information Processing Systems, pp. 5998–6008 (2017) 33. Veliˇckovi´c, P., Cucurull, G., Casanova, A., Romero, A., Lio, P., Bengio, Y.: Graph attention networks. arXiv preprint arXiv:1710.10903 (2017) 34. Wang, Q., et al.: Learning deep transformer models for machine translation. arXiv preprint arXiv:1906.01787 (2019)
Grounding Dialogue Systems via Knowledge Graph Aware Decoding
339
35. Wen, T.H., et al.: A network-based end-to-end trainable task-oriented dialogue system. arXiv preprint arXiv:1604.04562 (2016) 36. Wu, C.S., Socher, R., Xiong, C.: Global-to-local memory pointer networks for task-oriented dialogue. arXiv preprint arXiv:1901.04713 (2019) 37. Wu, P., et al.: Learning representation mapping for relation detection in knowledge base question answering. In: Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics (July 2019) 38. Yu, M., Yin, W., Hasan, K.S., dos Santos, C., Xiang, B., Zhou, B.: Improved neural relation detection for knowledge base question answering. In: Proceedings of the 55th Annual Meeting of the Association for Computational Linguistics, vol. 1, Long Papers (July 2017) 39. Zhang, Y., et al.: Dialogpt: Large-scale generative pre-training for conversational response generation (2019) 40. Zhao, T., Zhao, R., Eskenazi, M.: Learning discourse-level diversity for neural dialog models using conditional variational autoencoders. In: Proceedings of the 55th Annual Meeting of the Association for Computational Linguistics, vol. 1, Long Papers (July 2017)
WEB-SOBA: Word Embeddings-Based Semi-automatic Ontology Building for Aspect-Based Sentiment Classification Fenna ten Haaf, Christopher Claassen, Ruben Eschauzier, Joanne Tjan, Dani¨el Buijs, Flavius Frasincar(B) , and Kim Schouten Erasmus University Rotterdam, PO Box 1738, 3000 DR Rotterdam, The Netherlands {450812fh,456177cc,480900re,413647jt,483065db}@student.eur.nl, {frasincar,schouten}@ese.eur.nl
Abstract. For aspect-based sentiment analysis (ABSA), hybrid models combining ontology reasoning and machine learning approaches have achieved state-of-the-art results. In this paper, we introduce WEBSOBA: a methodology to build a domain sentiment ontology in a semiautomatic manner from a domain-specific corpus using word embeddings. We evaluate the performance of a resulting ontology with a state-of-theart hybrid ABSA framework, HAABSA, on the SemEval-2016 restaurant dataset. The performance is compared to a manually constructed ontology, and two other recent semi-automatically built ontologies. We show that WEB-SOBA is able to produce an ontology that achieves higher accuracy whilst requiring less than half of user time, compared to the previous approaches. Keywords: Ontology learning · Word embeddings analysis · Aspect-based sentiment analysis
1
· Sentiment
Introduction
One of the most valuable pieces of information for any business is the opinion of their customers. One source of data that can be of great help is the growing mass of online reviews posted on the Web and social media. The review forum Yelp, for example, features more than 200 million reviews about restaurants and other businesses [28]. Interpreting this massive amount of text manually would be difficult and time consuming. This is where the field of sentiment analysis plays an important role. It is a subfield of natural language processing (NLP), that encompasses the study of people’s emotions and attitudes from written language [14]. In particular, this paper focuses on aspect-based sentiment analysis (ABSA), which aims to compute sentiments pertaining to specific features, the so-called ‘aspects’, of a product or service [22]. This results in a more in-depth sentiment analysis, as reviews can contain varying sentiment polarities (negative, neutral, or positive) about different aspects. This means that through ABSA, businesses c Springer Nature Switzerland AG 2021 R. Verborgh et al. (Eds.): ESWC 2021, LNCS 12731, pp. 340–355, 2021. https://doi.org/10.1007/978-3-030-77385-4_20
WEB-SOBA: Word Embeddings-Based Semi-automatic Ontology
341
can identify which specific aspects, such as food quality or atmosphere, need to be improved upon, allowing them to make the right adjustments in their business model [19]. ABSA firstly requires that the aspects and their categories in sentences are identified (aspect detection) and consequently determines the sentiment with respect to these aspects (sentiment classification) [24]. The focus of this paper is on the sentiment classification component of sentence-level ABSA, using benchmark data where the aspects are already given [21]. Various methods have been used for sentiment classification, many of which rely on machine learning methods [8]. [24] proposes a knowledge-based method using domain sentiment ontologies, which represent a formal definition of the concepts that are related to a specific domain. [24] shows that using common domain sentiment knowledge encoded into an ontology gives better performance for sentiment classification, whilst requiring less training data to do so. [23] further shows that even better performance is achieved by a Two-Step Hybrid Model (TSHM) approach. For this approach, the first step is to use a domain sentiment ontology to predict a sentiment and, if this is inconclusive, use a machine learning algorithm that predicts the sentiment as a backup solution. The ontologies needed as an input for these hybrid models can be obtained through different methods. One approach is to manually build an ontology [23,24], but this is time consuming and needs to be done for each domain separately. Automatic ontology construction is also an option as [3] proposes, but this process is less accurate because there is no human supervision in creating the ontology. [31] shows that a semi-automatic approach, where human input is required to control for possible mistakes made by the ontology builder, comes close to the human made ontology in accuracy whilst being more time-efficient. While the authors of [31] made use of word co-occurrences to build their ontology, the use of word embeddings has not been investigated until now for constructing a domain sentiment ontology. The advantage of word embeddings is that words are mapped to vectors, which allows for easy computation with words. Moreover, word embeddings also capture semantic features of the words such as similarity to other words. Previous authors have shown that word embeddings outperform word co-occurrence based methods for various NLP tasks [1]. In this paper, we propose a semi-automatic ontology builder called Word Embeddings-Based Semi-Automatic Ontology Builder for Aspect-Based Sentiment Analysis (WEB-SOBA). We aim to build a domain sentiment ontology from a domain corpus based on word embeddings, to exploit semantic relations between words. The source code written in Java of this project can be found at https://github.com/RubenEschauzier/WEB-SOBA. The rest of the paper has the following structure. In Sect. 2 we discuss related relevant literature that forms the background of our research. In Sect. 3, an overview of the used datasets is given. Further, we describe our methodology in Sect. 4 and present our evaluation criteria and results in Sect. 5. Last, we give our conclusions and make suggestions for future work in Sect. 6.
342
2
F. ten Haaf et al.
Related Works
In this section, we provide an overview of the relevant literature on hybrid methods, ontology building, and word embeddings. 2.1
Hybrid Methods
The authors of [7] are among the first to suggest that a combination or ‘hybrid’ of knowledge-based and machine learning methods are promising in sentiment analysis. Following such a hybrid approach, [23] proposes a combination of knowledge and statistics. The used machine learning approach is the bag-of-words (BoW) model, where the authors train a multi-class Support Vector Machine (SVM) that is able to classify an aspect into one of three sentiment values: negative, neutral, or positive. The authors show that using a BoW model only as a backup when making predictions using an ontology (Ont+BoW) results in an improvement compared to alternative models. Similar to the two-stage approach in [23,27] uses a combination of methods in a framework called HAABSA, to predict the sentiment values in sentencelevel ABSA. Instead of using the BoW model, the authors use a Left-CenterRight separated neural network with Rotatory attention (LCR-Rot) model from [30]. [27] finds that an alteration of the LCR-Rot model (LCR-Rot-Hop) as the backup model, where the rotatory attention mechanism is applied multiple times, has the highest performance measure and is even able to outperform the Ont+BoW model of [23]. For this reason we favor using this approach to evaluate the performance of our ontology. 2.2
Ontology Building
As described by [6], there are various subtasks associated with the development of an ontology. The first step is to gather linguistic knowledge in order to be able to recognize domain-specific terms as well as synonyms of those terms. All terms with the same meaning need to be clustered together to form concepts (e.g., ‘drinks’ and ‘beverage’ can both be a lexicalization of the concept Drinks). In addition, hierarchical relationships need to be established (e.g., given the class Food and the class Fries, Fries should be recognized as a subclass of Food). Next, non-hierarchical relations between concepts are defined, as well as certain rules in order to be able to derive facts that are not explicitly encoded by the ontology. A manually built ontology is given in [23]. Since this ontology was made manually, it has great performance by design. However, building the ontology requires a lot of time. [31] shows that using a semi-automatically built ontology substantially decreases the human time needed to create an ontology, while having comparable results to benchmark models. The authors of [31] focus on using word frequencies in domain corpora for ontology building. [9] further extends this work by making use of synsets, or sets of synonyms, in term extraction, concept formation, and concept subsumption. However, differently than [9] and [31], we focus on using word embeddings for the automated part of the ontology
WEB-SOBA: Word Embeddings-Based Semi-automatic Ontology
343
building, meaning that words are mapped to vectors that retain certain similarities between words. As discussed in the previous section, [1] shows that word embeddings outperform word co-occurrences for certain NLP tasks. We hypothesize that word embeddings can be effective for ontology building based on this previous work. 2.3
Word Embeddings
A word embedding is a method for mapping various words to a single vector space. It creates vectors in a way that retains information about the word the vector represents, whilst having relatively low dimensionality when compared to the bag-of-words approach. Some of the most well-known methods for word embedding are proposed by [16], known as local context window methods. These methods primarily consider a word within the local context it appears, such that the vector of the word is determined by its sentence-level neighbours. The authors introduce the Continuous Bag-of-Words model (CBOW) and the Skip-gram model. It is shown that these local window context methods outperform previous global matrix factorization methods like Latent Semantic Analysis (LSA) and Latent Dirichlet Allocation (LDA) [16]. CBOW and Skip-gram are not only able to represent words, but can also detect syntactic and semantic word similarities. Relations like Athens→Greece are established by training on large text files that contain similar relations, e.g., Rome→Italy. Implementations of CBOW and Skip-gram are publicly available in the ‘word2vec’ project. A different method for embedding words was introduced in response to CBOW and Skip-gram. [20] combines global factorization and local context window methods in a bilinear regression model called the Global Vector method, abbreviated as GloVe. GloVe produces word embeddings by primarily considering non-zero word co-occurrences of the entire document. A last method for word embedding, called FastText, is introduced by [4]. FastText extends the Skip-gram model by including ‘subword’ information. The advantage of such an approach is that a vector representation of an unknown word can be formed by concatenating words, e.g., the vector for ‘lighthouse’ is associated with the vector for ‘light’ + the vector for ‘house’. There is no well-defined ‘best’ word embedding amongst word2vec, GloVe, and FastText for all NLP tasks. Some authors suggest that the difference in performance is mainly due to differences in hyperparameter settings between methods [13]. Other authors suggest that the word embedding methods are similar in practice, as can be found in the results of [18] and [25], for example. There are some exclusive features for each method, however. As an example, FastText can generate a word embedding for a word that does not exist in the database. On the other hand, word2vec is training time efficient and has a small memory footprint. For these practical considerations, we opt for the word2vec algorithm in our research.
344
3
F. ten Haaf et al.
Data
In sentiment analysis, there are a number of standard datasets that are widely used. We focus on datasets for the restaurant domain, because this is also the domain based upon which the ontologies from [9,23], and [31] were built, lending for easier comparison. To create an ontology, we need a domain-specific corpus and a contrasting corpus, in order to find how frequent certain words appear in a domain, relative to general documents. The domain-specific corpus is created using the Yelp Open Dataset [28]. This dataset consist of consumer reviews of various types of businesses. We filter out the reviews that are not about restaurants, resulting in with 5,508,394 domain-specific reviews of more than 500,000 restaurants. For the contrasting corpus, we use the pre-trained word2vec model google-news-300 [12], containing vectors for 3 million words with a dimensionality of 300. To evaluate our ontology, we use the SemEval-2016 Task 5 restaurant data for sentence-level analysis [21]. It is a standard dataset that contains restaurant reviews. It is structured per review and each review is structured per sentence, with reviews having varying amounts of sentences. There are 676 sentences in the test set and 2000 sentences in the training set. Each sentence contains opinions relating to specific targets in the sentence. The category of a target is also annotated, which is made up of an entity E (e.g., restaurant, drinks) and attribute A (e.g., prices, quality) pairing E#A. Furthermore, each identified E#A pair is annotated with a polarity from the set P = {negative, neutral, positive}. When an entity is only implicitly present in a sentence, the target is labeled as NULL. Since most machine learning methods need a target phrase to be present, the implicit sentences are not used in the analysis. These implicit aspects make up around 25% of the training set, leaving still 1879 explicit aspects. Figure 1 gives an overview of the aspects and polarities labeled in the dataset.
Fig. 1. Percentage of occurrence for aspects per sentence (a) and polarities per aspects (b) for the SemEval-2016 Task 5 restaurant dataset.
WEB-SOBA: Word Embeddings-Based Semi-automatic Ontology
4
345
Methodology
In this section, we explain how our ontology builder works, which we refer to as the Word Embedding-Based Semi-Automatic Ontology Builder for AspectBased Sentiment Analysis (WEB-SOBA). Additionally, we discuss the user input required at various points in the ontology building process. 4.1
Word Embeddings
The word embedding method we use for our ontology building is word2vec, which uses a two-layer neural network [17]. There are two variations to this. In the Continuous Bag-of-Words (CBOW) model, the embedding is learned by predicting the current word based on its context (the surrounding words). Another approach is to learn by predicting the surrounding words given a current word. This approach is called the Skip-gram model. CBOW is better for frequent words, while Skip-gram does a better job for infrequent words. Moreover, CBOW can be trained faster than Skip-gram. However, in practical applications the performance is fairly similar. For this paper, due to the previously given advantages, we use the CBOW model to make the word embeddings. This model is trained using the following loss function: J=
T 1 log p(wt |wt−c , . . . , wt−1 , wt+1 , . . . , wt+c ), T t=1
(1)
where [−c, c] is the word context of the word wt and T represents the number of words in the sequence. 4.2
Ontology Framework
The first step to build our ontology is to decide upon the basic structure that will be used. We use the same structure as the ontology presented by [23]. This ontology contains two main classes: Mention and SentimentValue. SentimentValue consists of the subclasses Positive and Negative. Please note that our ontology does not model neutral sentiment. This is a deliberate choice, as neutral sentiment has an inherent subjectivity [23]. The skeletal structure already starts with a certain number of Mention subclasses based on the entities and attributes that make up categories within the domain, denoted as ENTITY#ATTRIBUTE (e.g., FOOD#QUALITY). For the considered restaurant domain, the Mention subclasses are: Restaurant, Location, Food, Drinks, Price, Experience, Service, Ambiance, Quality, and Style&Options. In addition we also use the attributes General and Miscellaneous, but we do not explicitly represent them in sub-classes. Figure 2 illustrates the Mention subclasses in our base ontology and how they are related to each other to make ENTITY#ATTRIBUTE pairs.
346
F. ten Haaf et al.
Fig. 2. Entities and Attributes, as E#A pairs.
In this ontology we make a distinction between the part-of-speech of a term, i.e., whether it is a verb (Action), noun (Entity), or adjective (Property). The Mention classes are superclasses of classes denoting the aspect and the part-ofspeech. For example, PricesPropertyMention is a subclass of PricesMention and PropertyMention. Each of these classes then contains classes which are a subclass of the corresponding Mention class and the SentimentValue class. For example, a class LocationPositiveProperty is a subclass of the classes LocationPropertyMention and Positive. There are three types of sentiment-carrying classes: Type-1 (generic sentiment), Type-2 (aspect-specific sentiment), and Type-3 (context-dependent sentiment). The first type always has the same sentiment value regardless in what context the concept is found (e.g., the concept ‘good’ is always positive). This type of Mention subclasses are also immediately a subclass of the GenericPositive or GenericNegative classes, which are subclasses of the SentimentValue classes Positive and Negative, respectively. Next, sentiment Type-2 words only apply to a specific category of aspects and with the same sentiment. For example, the word ‘delicious’ applies to food and drinks but is never used when talking about service. Therefore, when determining the sentiment of an aspect in the service category, this word could be ignored. Finally, Type-3 words indicate different sentiments depending on the aspect category. For example, ‘cold’ beer is positive whereas ‘cold’ pizza is negative. All concepts in the ontology can have two types of properties. The Mention classes can first of all have one or multiple aspect properties through which they are linked to all the aspect categories for which they are applicable. For example, FoodMention is linked to FOOD#PRICES, FOOD#QUALITY, and FOOD#OPTIONS. Second, differently than the main Mention and SentimentValue classes, the classes have lexical representations attached. User Intervention. The user helps initialise the skeletal ontology by providing some lexicalizations for the base classes. In particular, we add some Type-1 sentiment words, such as ‘enjoy’, ‘hate’, ‘great’, and ‘bad’. For each of these terms, the 15 most similar words obtained through word embeddings are suggested to the user. The user can then accept or reject adding these words as an extra lexicalization of the corresponding class. The reason to initialise the ontology in this manner is that these generic, context-independent Type-1 words such as ‘enjoy’
WEB-SOBA: Word Embeddings-Based Semi-automatic Ontology
347
and ‘hate’ do indicate a sentiment, but are used in a wide range of contexts. Therefore, these words are less likely to be extracted when determining terms specific to the restaurant domain, yet they are still useful if they are added to our ontology. 4.3
Term Selection
To first gather domain-specific words, we use the Yelp dataset [28] containing text about our domain and extract all adjectives, nouns, and, verbs from the text using the part-of-speech tagger of the Stanford NLP Processing Group [26]. Adverbs can also be considered for sentiment information, but they sometimes affect the intensity of the sentiment rather than the polarity [11]. Consequently, we only use adjectives, nouns, and verbs for our analysis, as they carry the primary sentiment information of the sentence. Afterwards, we select certain terms from the list of domain-specific words that are to be proposed to the user. We first assign a TermScore (TS) to each word, calculated using the DomainSimilarity (DS) and the MentionClassSimilarity (MCS). The DS can be computed using the cosine similarity. The function for DS of word i is: vi,D · vi,G , (2) DS i = vi,D · vi,G where vi,D is the vector of word i in the domain-related word embedding model and vector vi,G is generated for word i in the general word embedding model. If a word is domain-specific, the cosine similarity between vi,D and vi,G is low which indicates a low value for DS as well. The MCS calculates the maximum similarity for word i to one of the Mention classes. The function for MCS of word i is: v i · va MCS i = max , (3) a∈A vi · va where A is the set of Mention classes, which are Restaurant, Location, Food, Drinks, Price, Experience, Service, Ambiance, Quality, and Style&Options. The more similar terms are to the lexical representation of the name of one of the mention classes, the higher the value of MCS. The function TS is defined as the harmonic mean of DS and MCS. Because we want the DSi value as low as possible, we take its reciprocal value. Both DS and MCS play an important role, because we want words to be both specific to the domain (as represented by DS), and at the same time we want them to be important to the base classes in our domain (as measured by MCS). The function for the TS of each term i is: TSi =
2 , DSi + MSCi −1
(4)
A specific threshold parameter is used, one for each of the three lexical classes (adjectives, nouns, and verbs), to determine whether to suggest terms to the user.
348
F. ten Haaf et al.
A term will be selected and proposed to the user if its TS exceeds the threshold of the lexical class, which the term belongs to. A critical issue here is deciding the value of the threshold parameter. The value of this parameter determines the amount of terms the user is asked to review. By setting the value of the threshold too low, a lot of terms have to be considered by the user, which is very time consuming. When the value of the threshold parameter is too high, crucial words will be omitted and thus absent from the ontology. The threshold value is defined for lexical class lc (part-of-speech) as follows: 2 ∗ , (5) THlc = max n 1 THlc accepted + accepted where T Hlc is a threshold score for lexical class lc, n is the number of suggested terms, and accepted is the number of accepted terms. T H ∗ is defined per lexical class so that we maximize the number of accepted terms and the number of accepted terms relative to suggested terms for each lexical class. User Intervention. After the TermScore of a term exceeds the threshold and the term is suggested to the user, the user can accept or reject whether to add this term to the list of all relevant terms for the ontology. If the term is a verb or a noun, the user decides if the term refers to an aspect, or if it refers to a sentiment. Adjectives are always treated as denoting a sentiment. If the term is added as a Sentiment Mention, the user has to decide if the word is a Type-1 Sentiment Mention or not, and if so, if the word is positive or negative. Furthermore, we select all words for each accepted term that are similar to the accepted term using word embeddings. If the cosine similarity is larger than a certain threshold, the word is added to the ontology. We find in preliminary research that a threshold of 0.7 ensures that the vast majority of words added are valuable to the ontology. 4.4
Sentiment Term Clustering
After selecting the important terms for our ontology and letting the user define whether the terms are Sentiment Mentions or Aspect Mentions, we can create a hierarchy for the words that were deemed to be sentiment words. In this case, we want to determine the SentimentValue of each word, as well as determine which Mention class(es) the word belongs to if it is not a GenericPositive or GenericNegative sentiment. A drawback of using word2vec word embeddings for our application is that the generated vectors do not directly account for sentiment. For example, the vectors for ‘good’ and ‘bad’ are very similar to each other because they appear in the same context, even though they convey a different sentiment. This complicates the process of determining the sentiment for our Sentiment Mention words. Our proposed solution to this problem is to refine our existing word2vec model, as trained on the Yelp dataset, by making the vectors sentiment-aware.
WEB-SOBA: Word Embeddings-Based Semi-automatic Ontology
349
[29] uses the Extended version of Affective Norms of English Words (E-ANEW) as a sentiment lexicon. This sentiment lexicon is a dataset that attaches emotional ratings to words. Using this sentiment lexicon, the authors find and rank the k (e.g., k = 10) most similar words in terms of emotional ratings to the target word that needs to be refined, where the most similar word gets the highest rank. These words are called the neighbours of our target word. The neighbours of our target word are then also ranked in terms of their cosine similarity, where again the word with the highest similarity gets the highest rank. After creating these sentiment and similarity rankings, the vector of the target word is refined so that it is: (1) closer to its neighbours that are sentimentally similar, (2) further away from dissimilar neighbors, and (3) still relatively close to the original vector. Using these vectors we cluster our Sentiment Mention terms. For each term we calculate the cosine similarity between all of our base Mention classes and rank them in descending order. Additionally, we calculate the negative and positive score of our Sentiment Mention term in the following way: v i · vp v i · vn N Si = max (6) P Si = max p∈P n∈N vi · vp vi · vn where P S i and N S i are the positive and negative score for termi . P and N are a collection of positive and negative words that span different intensities of positivity and negativity, respectively. The set of negative words is as follows: P= {‘good’, ‘decent’, ‘great’, ‘tasty’, ‘fantastic’, ‘solid’, ‘yummy’, ‘terrific’}. The set of positive words is: N ={‘bad’, ‘awful’, ‘horrible’, ‘terrible’, ‘poor’, ‘lousy’, ‘shitty’, ‘horrid’}. Finally, we have vi , vp , and vn which are the word embeddings of word i, p, and n, respectively. We predict our termi to be positive if the P Si is higher than N Si . If the P Si is lower than N Si , the termi is considered to be negative. User Intervention. The user is asked for each Sentiment Mention term if it can refer to the base Mention class that it has the highest cosine similarity to. If the user accepts the term into the recommended Mention class, the user is asked then to confirm if the predicted polarity of the Sentiment Mention is correct. Thereafter, the user is asked the same for the Mention class that has the second highest cosine similarity to our term. This continues until either all Mention classes are accepted or one Mention class is rejected. After the process terminates, the Sentiment Mention term is added to the ontology in accordance to the decisions made by the user. Each Sentiment Mention can be added to multiple Mention classes, because a Sentiment Mention can convey sentiment for multiple Mention classes. An example of this is the word ‘idyllic’, which can convey sentiment about the restaurant, location, experience, and ambiance.
350
4.5
F. ten Haaf et al.
Aspect Term Hierarchical Clustering
The next step is clustering and building the ontology’s hierarchy for the Aspect Mention terms. As previously stated, words can be represented in a vector space using word embeddings, which means it is possible to cluster these terms. Building the ontology’s hierarchy is done in two steps. First, we implement an adjusted k-means clustering approach to cluster the accepted terms into clusters corresponding to the base Mention classes. These clusters are Restaurant, Location, Food, Drinks, Price, Experience, Service, Ambiance, Quality, and Style&Options. Since the base mention classes are known, we can just add each data point to the base cluster with which it has the highest cosine similarity (using the lexical representations corresponding to the names of these clusters). After clustering the terms into the base subclasses, the next step is building a hierarchy for each subclass using agglomerative hierarchical clustering. Terms start in a single cluster and are slowly merged together per iteration based on a linkage criteria. The method we choose for implementation is called Average Linkage Clustering, abbreviated as ALC, as it is less sensitive to outliers. It is defined as: 1 d(a, b) (7) ALC(A, B) = |A| · |B| a∈A b∈B
where d(a, b) is the Euclidean distance between vectors a and b, where a is in cluster A and b is in cluster B. At each iteration, terms with the lowest ALC value are clustered, creating the required hierarchy. For our ALC algorithm, we make use of the implementation described by [2]. Based on preliminary experiments of implementing the elbow method, the maximum depth that our dendrogram can possibly have is set to three for each subclass. User Intervention. For each Mention class, each term belonging to that cluster is presented to the user and the user can accept or reject it. If the user rejects it, the user is prompted to specify the right cluster. By doing this, all terms start in the correct cluster before building a hierarchy.
5
Evaluation
In this section, we discuss the procedure by which we evaluate our proposed ontology. We compare the performance of our ontology with benchmark (semi-) manually built ontologies. In Sect. 5.1 we describe the performance measures we use for evaluation. Next, in Sect. 5.2 and Sect. 5.3 we present our results. All results were obtained on an Intel(R) Core(TM) i5-4690k CPU in combination with an NVIDIA GeForce GTX 970 GPU and 16 GB RAM. 5.1
Evaluation Procedure
The output of our proposed methodology is a domain-specific sentiment ontology based on word embeddings. This ontology is used in combination with machine
WEB-SOBA: Word Embeddings-Based Semi-automatic Ontology
351
learning methods to classify the sentiment of aspects. We evaluate the quality of our proposed method by looking at the time required to construct the ontology and its performance for sentiment classification. To determine which configuration performs better, we use the Welch t-test to compare the cross-validation outcomes. As we build the ontology semi-automatically, it is interesting to consider the time required to make a WEB-SOBA ontology. The ontology building time can be divided in human time spent and computer time spent. We try to minimize the total time spent on building the ontology, but value time spent by humans as more expensive than time spent by computers. Ultimately, we expect that our ontology performs better than the ontology of [9] and [31] if the word embeddings truly outperform word co-occurrences. However, we expect the best performance from the ontology of [23] as this ontology was entirely made by hand to perform best. The experiments are executed on the HAABSA implementation [27]. The experimental setup for testing our ontology is simple, as we can directly plug our ontology into the HAABSA code after it has been semi-automatically constructed. We test the following ontologies: Manual [23], SOBA [31], SASOBUS [9], and WEB-SOBA. These ontologies are evaluated when used by themselves and when used in conjunction with the LRC-Rot-Hop backup model in the HAABSA framework. 5.2
Ontology Building Results
We now evaluate the WEB-SOBA ontology. In the end, 376 classes are added to our ontology, of which there are 15 Type-1 sentiment words, 119 Type-2 sentiment words, and 0 Type-3 sentiment words. These results are not fully unexpected: there are few Type-1 sentiment words, because these words are often not domain-specific and therefore less likely to be selected by the term selection algorithm. There are also no Type-3 sentiment words selected, possibly because there are not many of these in the dataset. To put it into perspective, the manual ontology of [23] has only 15 Type-3 sentiment words. Table 1 presents the distribution of classes, lexicalizations, and synonyms in our ontology, compared to the other benchmark ontologies. Table 1. Distribution of ontology classes and properties for the manual ontology, SOBA, and WEB-SOBA. Manual SASOBUS SOBA WEB-SOBA Classes
365
558
470
376
Lexicalizations 374
1312
1087
348
It is clear from Table 1 that our ontology is not as extensive compared to the other three ontologies. However, this does not necessarily mean that the ontology
352
F. ten Haaf et al.
should have a worse performance, as it is possible that the most important terms of the domain are captured. Another important factor to consider is the building time duration. Table 2 presents the time that is required for user input and for computing in minutes, compared to benchmark ontologies. Table 2. Time duration of the building process for the manual ontology, SOBA, and WEB-SOBA. Manual SASOBUS SOBA WEB-SOBA User time (minutes) Computing time (minutes)
420
180
90
40
0
300
90
30 (+300)
Table 2 shows that with respect to user time required, WEB-SOBA clearly outperforms the other semi-automatic ontology builders, and, obviously, the manual ontology as well. The computing time for running the code between user inputs is only 30 min, which is also lower than the computing time required for the SOBA and SASOBUS ontologies. However, the word embeddings need to be created the first time the program is used and the terms in the Yelp dataset have to be extracted, which requires an additional 300 min of computing time. After the vectors have been made, they can be reused in the same domain. This substantially decreases the time needed to do a different NLP task in the same domain. Additionally, the computation times are higher because the dataset used for this ontology contains millions of reviews compared to the 5001 reviews used to create SOBA and SASOBUS. 5.3
Evaluation Results
We compare the results of WEB-SOBA with the results of the Manual ontology from [23], the SOBA ontology of [31], and the SASOBUS ontology of [9]. Table 3 presents the performance of the ontologies by themselves, while Table 4 presents the results of the Ontology+LCR-Rot-Hop approach [27]. The tables additionally present p-values for the Welch t-test to test for equal means (under unequal variances) for the cross-validation accuracies. Table 3. Comparison results for different ontologies by themselves on SemEval-2016 Task 5 restaurant data. Out-of-sample In-sample Cross-validation Accuracy
Welch t-test
Accuracy Accuracy St. dev. Manual SASOBUS SOBA WEB-SOBA
Manual
78.31%
75.31%
74.10%
0.044
–
SASOBUS
76.62%
73.82%
70.69%
0.049
0.118
SOBA
77.23%
74.56%
71.71%
0.061
0.327
0.685
–
WEB-SOBA 77.08%
72.11%
70.50%
0.050
0.107
0.636
0.935
– –
WEB-SOBA: Word Embeddings-Based Semi-automatic Ontology
353
Table 4. Results for ontologies on SemEval-2016 Task 5 restaurant data, evaluated with LCR-Rot-Hop model as backup. Out-of-sample In-sample Cross-validation Accuracy
Welch t-test
Accuracy Accuracy St. dev. Manual SASOBUS SOBA WEB-SOBA
Manual
86.65%
87.96%
82.76%
0.022
–
SASOBUS
84.76%
83.38%
80.20%
0.031
0.052
SOBA
86.23%
85.93%
80.15%
0.039
0.088
0.975
–
88.87%
84.72%
0.017
0.043
0.001
0.005
WEB-SOBA 87.16%
– –
The tables presented above show that WEB-SOBA achieves similar performance to other semi-automatically built ontologies when evaluated by itself, even though it required less than half of the user time to build. When combined with the LCR-Rot-Hop backup method, the WEB-SOBA ontology performs better than all other ontologies including the manual one (at 5% significance level). This shows that our ontology complements the machine learning method well. Our approach is generalizable to other domains as well. For another domain one only needs to provide the following items: a text corpus, the category classes, and the positive/negative word collections. Even if the overall time is comparable with the one of a manual approach, one major benefit for our approach is that most of the time is spent by system computations instead of user work. As limitations, our solution is not able to deal with polysemous words and our data set was not able to provide for Type-3 sentiment words.
6
Conclusion
For this research paper, we used word embeddings to semi-automatically build an ontology for the restaurant domain to be used in aspect-based sentiment analysis. The ontology builder we propose reduces both computing and user time required to construct the ontology, given that the word embeddings for a specific domain are already made. Furthermore, our method requires less user time compared to recently proposed semi-automatic ontology builders based on word co-occurrences, whilst it achieves similar or better performance. Our proposed ontology even reaches higher accuracy compared to the performance of a manually built one when implemented in a hybrid method with the LCRRot-Hop model as backup. As future work we would like to analyse for which aspects the proposed approach gives the best performance. Also, we suggest that the performance of an ontology used for ABSA can likely be improved by using a contextual word embeddings method, such as BERT [10]. These contextual methods assign a different vector to the same word in a different context. We expect that these contextual word embeddings lead to more accurate sentiment classification, as the various meanings of words are taken into account. However, these methods cannot be directly implemented into the current ontology structure, as the same word gets a different vector in a different linguistic context. As future
354
F. ten Haaf et al.
work we propose to extend the ontology structure by allowing the same word to appear for multiple concepts by conditioning its presence on a certain meaning. In addition, we plan to use domain modelling [5] that complements well our contrastive corpus-based solution by providing domain-specific terms that are more generic than the current ones. Furthermore, the clustering of terms can be improved. Our proposed clustering method works for a relatively moderate amount of domain terms, but is not feasible for a huge number of domain terms. For an efficient hierarchical clustering method for Big Data, one could exploit the BIRCH algorithm as in [15].
References 1. Baroni, M., Dinu, G., Kruszewski, G.: Don’t count, predict! A systematic comparison of context-counting vs. context-predicting semantic vectors. In: 52nd Annual Meeting of the Association for Computational Linguistics (ACL 2014), pp. 238– 247. ACL (2014) 2. Behnke, L.: https://github.com/lbehnke/hierarchical-clustering-java (2012) 3. Blaschke, C., Valencia, A.: Automatic ontology construction from the literature. Genome Inform. 13, 201–213 (2002) 4. Bojanowski, P., Grave, E., Joulin, A., Mikolov, T.: Enriching word vectors with subword information. Trans. Assoc. Comput. Linguist. 5, 135–146 (2017) 5. Bordea, G., Buitelaar, P., Polajnar, T.: Domain-independent term extraction through domain modelling. In: 10th International Conference on Terminology and Artificial Intelligence (TIA 2013) (2013) 6. Buitelaar, P., Cimiano, P., Magnini, B.: Ontology learning from text: an overview. In: Ontology Learning from Text: Methods, Evaluation and Applications, vol. 123, pp. 3–12 (2005) 7. Cambria, E.: Affective computing and sentiment analysis. IEEE Intell. Syst. 31(2), 102–107 (2016) 8. Cambria, E., Das, D., Bandyopadhyay, S., Feraco, A.: A Practical Guide to Sentiment Analysis. SAC, vol. 5. Springer, Cham (2017). https://doi.org/10.1007/9783-319-55394-8 9. Dera, E., Frasincar, F., Schouten, K., Zhuang, L.: SASOBUS: semi-automatic sentiment domain ontology building using Synsets. In: Harth, A., et al. (eds.) ESWC 2020. LNCS, vol. 12123, pp. 105–120. Springer, Cham (2020). https://doi.org/10. 1007/978-3-030-49461-2 7 10. Devlin, J., Chang, M.W., Lee, K., Toutanova, K.: BERT: pre-training of deep bidirectional transformers for language understanding. In: 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies (NAACL-HLT 2019) ACL, pp. 4171–4186 (2019) 11. Dragut, E., Fellbaum, C.: The role of adverbs in sentiment analysis. In: Proceedings of Frame Semantics in NLP: A Workshop in Honor of Chuck Fillmore (1929–2014), pp. 38–41 (2014) 12. Google (2013). https://code.google.com/archive/p/word2vec/ 13. Levy, O., Goldberg, Y., Dagan, I.: Improving distributional similarity with lessons learned from word embeddings. Trans. Assoc. Comput. Linguist. 3, 211–225 (2015) 14. Liu, B.: Sentiment analysis and opinion mining. Synth. Lect. Hum. Lang. Technol. 5(1), 1–167 (2012)
WEB-SOBA: Word Embeddings-Based Semi-automatic Ontology
355
15. Mahmoud, N., Elbeh, H., Abdlkader, H.M.: Ontology learning based on word embeddings for text big data extraction. In: 14th International Computer Engineering Conference (ICENCO 2018), pp. 183–188. IEEE (2018) 16. Mikolov, T., Chen, K., Corrado, G., Dean, J.: Efficient estimation of word representations in vector space. In: 1st International Conference on Learning Representations (ICLR 2013) (2013) 17. Mikolov, T., Sutskever, I., Chen, K., Corrado, G.S., Dean, J.: Distributed representations of words and phrases and their compositionality. In: 27th Annual Conference on Neural Information Processing Systems (NIPS 2013), pp. 3111–3119. Curran Associates (2013) 18. Naili, M., Chaibi, A.H., Ghezala, H.H.B.: Comparative study of word embedding methods in topic segmentation. In: 23rd International Conference on KnowledgeBased and Intelligent Information & Engineering Systems (KES 2019), vol. 112, pp. 340–349 (2017) 19. Pang, B., Lee, L.: Opinion mining and sentiment analysis. Found. Trends Inf. Retrieval 2(1–2), 1–135 (2008) 20. Pennington, J., Socher, R., Manning, C.D.: GloVe: global vectors for word representation. In: 2014 Conference on Empirical Methods in Natural Language Processing (EMNLP 2014), pp. 1532–1543. ACL (2014) 21. Pontiki, M., et al.: SemEval-2016 task 5: aspect-based sentiment analysis. In: 10th International Workshop on Semantic Evaluation (SemEval 2016), pp. 19–30. ACL (2016) 22. Schouten, K., Frasincar, F.: Survey on aspect-level sentiment analysis. IEEE Trans. Knowl. Data Eng. 28(3), 813–830 (2016) 23. Schouten, K., Frasincar, F.: Ontology-driven sentiment analysis of product and service aspects. In: Gangemi, A., et al. (eds.) ESWC 2018. LNCS, vol. 10843, pp. 608–623. Springer, Cham (2018). https://doi.org/10.1007/978-3-319-93417-4 39 24. Schouten, K., Frasincar, F., de Jong, F.: Ontology-enhanced aspect-based sentiment analysis. In: Cabot, J., De Virgilio, R., Torlone, R. (eds.) ICWE 2017. LNCS, vol. 10360, pp. 302–320. Springer, Cham (2017). https://doi.org/10.1007/ 978-3-319-60131-1 17 25. Shi, T., Liu, Z.: Linking GloVe with word2vec. arXiv preprint arXiv:1411.5595 (2014) 26. Toutanova, K., Manning, C.D.: Enriching the knowledge sources used in a maximum entropy part-of-speech tagger. In: 2000 Joint SIGDAT Conference on Empirical Methods in Natural Language Processing and Very Large Corpora (EMNLP 2010), pp. 63–70. ACL (2000) 27. Wallaart, O., Frasincar, F.: A hybrid approach for aspect-based sentiment analysis using a lexicalized domain ontology and attentional neural models. In: Hitzler, P., et al. (eds.) ESWC 2019. LNCS, vol. 11503, pp. 363–378. Springer, Cham (2019). https://doi.org/10.1007/978-3-030-21348-0 24 28. Yelp (2019). https://www.yelp.com/dataset 29. Yu, L.C., Wang, J., Lai, K.R., Zhang, X.: Refining word embeddings for sentiment analysis. In: 2017 Conference on Empirical Methods in Natural Language Processing (EMNLP 2017), pp. 534–539. ACL (2017) 30. Zheng, S., Xia, R.: Left-center-right separated neural network for aspect-based sentiment analysis with rotatory attention. arXiv preprint arXiv:1802.00892 (2018) 31. Zhuang, L., Schouten, K., Frasincar, F.: SOBA: semi-automated ontology builder for aspect-based sentiment analysis. J. Web Semant. 60, 100–544 (2020)
Context Transformer with Stacked Pointer Networks for Conversational Question Answering over Knowledge Graphs Joan Plepi1 , Endri Kacupaj2(B) , Kuldeep Singh3 , Harsh Thakkar4 , and Jens Lehmann2,5 1
2
Technische Universit¨at Darmstadt, Darmstadt, Germany [email protected] Smart Data Analytics Group, University of Bonn, Bonn, Germany {kacupaj,jens.lehmann}@cs.uni-bonn.de 3 Zerotha Research and Cerence GmbH, Bonn, Germany [email protected] 4 Zerotha Research and Osthus GmbH, Bonn, Germany [email protected] 5 Fraunhofer IAIS, Dresden, Germany [email protected]
Abstract. Neural semantic parsing approaches have been widely used for Question Answering (QA) systems over knowledge graphs. Such methods provide the flexibility to handle QA datasets with complex queries and a large number of entities. In this work, we propose a novel framework named CARTON (Context trAnsformeR sTacked pOinter Networks), which performs multi-task semantic parsing for handling the problem of conversational question answering over a large-scale knowledge graph. Our framework consists of a stack of pointer networks as an extension of a context transformer model for parsing the input question and the dialog history. The framework generates a sequence of actions that can be executed on the knowledge graph. We evaluate CARTON on a standard dataset for complex sequential question answering on which CARTON outperforms all baselines. Specifically, we observe performance improvements in F1score on eight out of ten question types compared to the previous state of the art. For logical reasoning questions, an improvement of 11 absolute points is reached. Keywords: Conversational question answering · Knowledge graph · Context transformer · Stacked pointer networks
1 Introduction Recently, there has been an increased demand for chatbots and voice assistants to communicate and assist humans in different domains such as chitchat, medical, news, enterprise, etc. ([7]). Question answering is a common phenomenon in chatbot conversations to seek specific information. While such questions inherit a conversational J. Plepi and E. Kacupaj–Equal contribution to this research. Work was done while the author Joan Plepi was a student at University of Bonn. c Springer Nature Switzerland AG 2021 R. Verborgh et al. (Eds.): ESWC 2021, LNCS 12731, pp. 356–371, 2021. https://doi.org/10.1007/978-3-030-77385-4_21
CARTON
357
Table 1. An example dialog from CSQA dataset [19] describing various states of a conversation. Turn State T1 T2
USER: Can you tell me which cities border Verderio Inferiore ?
Response
SYSTEM: Cornate d’Adda, Bernareggio, Robbiate
Coreference question USER: And which cities flank that one ? Clarification
T3 T4
Utterance
Simple question
SYSTEM: Did you mean Robbiate?
Clarification question USER: No, I meant Cornate d’Adda Response
SYSTEM: Bottanuco, Busnago, Trezzo sull’Adda
Logical question
USER: Which ones share border with Robbiate and are not part of Azerbaijan?
Response
SYSTEM: Trezzo sull’Adda, Busnago, Bottanuco
context, humans also tend to ask questions that require complex reasoning to answer in a real-world scenario. The complexity of questions may differ at various granularity (e.g., simple, logical, quantitative, and comparative). Table 1 presents a few examples from a complex question answering dataset with a conversational context [19]. The example dialogue has several question types and challenges. For example, in the first turn, the user asks a simple direct question, and in the following turn, she asks a question that refers to the context from the previous turn. Furthermore, in the last turn, there is a question that requires logical reasoning to offer a multitude of complexity. Given these questions are from the general knowledge domain, the information required to answer questions can be extracted from publicly available large-scale Knowledge Graphs (KGs) such as DBpedia [11], Freebase [1], and Wikidata [27]. Neural semantic parsing approaches for question answering over KGs have been widely studied in the research community [5, 8, 9, 13]. In a given question, these approaches use a semantic parsing model to produce a logical form which is then executed on the KG to retrieve an answer. While traditional methods tend to work on small KGs [28], more recent approaches also work well on large-scale KGs [8, 21]. Often, researchers targeting large scale KGs focus on a stepwise method by first performing entity linking and then train a model to learn the corresponding logical form for each question type [4, 8]. Work in [21] argues that the stepwise approaches have two significant issues. First, errors in upstream subtasks (e.g., entity detection and linking, predicate classification) are propagated to downstream ones (e.g., semantic parsing), resulting in accumulated errors. For example, case studies in previous works [4, 8, 29] show that entity linking error is one of the significant errors leading to the wrong results in the question-answering task. Second, when models for the subtasks are learned independently, the supervision signals cannot be shared among the models for mutual benefits. To mitigate the limitations of the stepwise approach, [21] proposed a multi-task learning framework where a pointer-equipped semantic parsing model is designed to resolve coreference in conversations, and intuitively, empower joint learning with a type-aware entity detection model. The framework combines two objectives: one for semantic parsing and another for entity detection. However, the entity detection model uses supervision signals only from the contextual encoder, and no further signal is provided from the decoder or the semantic parsing task.
358
J. Plepi et al.
In this paper, we target the problem of conversational (complex) question answering over large-scale knowledge graph. We propose CARTON (Context trAnsformeR sTacked pOinter Networks)- a multi-task learning framework consisting of a context transformer model extended with a stack of pointer networks for multi-task neural semantic parsing. Our framework handles semantic parsing using the context transformer model while the remaining tasks such as type prediction, predicate prediction, and entity detection are handled by the stacked pointer networks. Unlike [21] which is current state-of-the-art, CARTON’s stacked pointer networks incorporate knowledge graph information for performing any reasoning and does not rely only on the conversational context. Moreover, pointer networks provide the flexibility for handling outof-vocabulary [26] entities, predicates, and types that are unseen during training. Our ablation study 5.1 further supports our choices. In contrast with the current state of the art, another significant novelty is that the supervision signals in CARTON propagate in sequential order, and all the components use the signal forwarded from the previous components. To this end, we make the following contributions in the paper: – CARTON - a multi-task learning framework for conversational question answering over large scale knowledge graph. – For neural semantic parsing, we propose a reusable grammar that defines different logical forms that can be executed on the KG to fetch answers to the questions. CARTON achieves new state of the art results on eight out of ten question types from a large-scale conversational question answering dataset. We evaluate CARTON on the Complex Sequential Question Answering (CSQA) [19] dataset consisting of conversations over linked QA pairs. The dataset contains 200K dialogues with 1.6M turns, and over 12.8M entities. Our implementation, the annotated dataset with proposed grammar, and results are on a public github1 . The rest of this article is organized as follows: Sect. 2 summarizes the related work. Section 3 describes the CARTON framework. Section 4 explains the experimental settings and the results are reported in Sect. 5. Section 6 concludes this article.
2 Related Work Semantic Parsing and Multi-task Learning Approaches. Our work lies in the areas of semantic parsing and neural approaches for question answering over KGs. Works in [6, 15, 16, 31] use neural approaches to solve the task of QA. [15] introduces an approach that splits the question into spans of tokens to match the tokens to their respective entities and predicates in the KG. The authors merge the word and character-level representation to discover better matching in entities and predicates. Candidate subjects are generated based on n-grams matching with words in the question, and then pruned based on predicted predicates. However, their experiments are focused on simple questions. [31] propose a probabilistic framework for QA systems and experiment on a new benchmark dataset. The framework consists of two modules. The first one model the 1
https://github.com/endrikacupaj/CARTON.
CARTON
359
probability of the topic entity y, constrained on the question. The second module reasons over the KG to find the answer a, given the topic entity y which is found in the first step and question q. Graph embeddings are used to model the subgraph related to the question and for calculating the distribution of the answer depended from the question q and the topic y. [13] introduce neural symbolic machine (NSM), which contains a neural sequence-to-sequence network referred also as the “programmer”, and a symbolic non-differentiable LISP interpreter (“computer”). The model is extended with a key-value memory network, where keys and values are the output of the sequence model in different encoding or decoding steps. The NSM model is trained using the REINFORCE algorithm with weak supervision and evaluated on the WebQuestionsSP dataset [30]. [8] also present an approach that maps utterances to logical forms. Their model consists of a sequence-to-sequence network, where the encoder produces the embedding of the utterance, and the decoder generates the sequence of actions. Authors introduce a dialogue memory management to handle the entities, predicates, and logical forms are referred from a previous interaction. Finally, MaSP [21] present a multi-task model that jointly learns type-aware entity detection and pointer equipped logical form generation using a semantic parsing approach. Our proposed framework is inspired by them; however, we differ considerably on the following points: 1) CARTON’s stacked pointer networks incorporate knowledge graph information for performing reasoning and do not rely only on the conversational context as MaSP does. 2) The stacked pointer network architecture is used intentionally to provide the flexibility for handling out-ofvocabulary entities, predicates, and types that are unseen during training. The MaSP model does not cover out-of-vocabulary knowledge since the model was not intended to have this flexibility. 3) CARTON’s supervision signals are propagated in sequential order, and all the components use the signal forwarded from the previous component. 4) We employ semantic grammar with new actions for generating logical forms. While [21] employs almost the same grammar as [8]. Other Approaches. There has been extensive research for task-oriented dialog systems such as [10] that induces joint text and knowledge graph embeddings to improve task-oriented dialogues in the domains such as restaurant and flight booking. Work present in [2] proposes another dataset, “ConvQuestions” for conversations over KGs along with an unsupervised model. Some other datasets for conversational QA include CANARD and TREC CAsT [24]. Overall, there are several approaches proposed for conversational QA, and in this paper, we closely stick to multi-task learning approaches for CARTON’s comparison and contributions.
3 Carton Our focus is on conversations containing complex questions that can be answered by reasoning over a large-scale KG. The training data consists of utterances u and the answer label a. We propose a semantic parsing approach, where the goal is to map the utterance u into a logical form z, depending on the conversation context. A stack of three pointer networks is used to fill information extracted from the KG. The final generated logical form aims to fetch the correct answer once executed on the KG. Figure 1 illustrates the overall architecture of CARTON framework.
360
J. Plepi et al.
Fig. 1. Context transformer with stacked pointer networks architecture (CARTON). It consists of three modules: 1) A Transformer-based contextual encoder finds the representation of the current context of the dialogue. 2) A logical decoder generates the pattern of the logical forms defined in Table 2. 3) The stacked pointer network initializes the KG items to fetch the correct answer.
3.1
Grammar
We predefined a grammar with various actions as shown in Table 2 which can result in different logical forms that can be executed on the KG. Our grammar definition is inspired by [8] which MaSP [21] also employs. However, we differ in many semantics of the actions and we even defined completely new actions. For example, find action is split into find(e, p) that corresponds to finding an edge with predicate p to the subject e; and find reverse(e, p) finds an edge with predicate p with object e. Moreover, per type is not defined by [8] in their grammar. Table 3 indicates some (complex) examples from CSQA dataset [19] with gold logical form annotations using our predefined grammar. Following [14], each action definition is represented by a function that is executed on the KG, a list of input parameters, and a semantic category that corresponds to the output of the function. For example, set → find(e, p), it has a set as a semantic category, a function find with input parameters e, p. We believe that the defined actions are sufficient for creating sequences that cover complex questions and we provide empirical evidences in Sect. 5. Every action sequence can be parsed into a tree, where the model recursively writes the leftmost non-terminal node until the whole tree is complete. The same approach is followed to execute the action sequence, except that the starting point is the tree leaves.
CARTON
361
Table 2. Predefined grammar with respective actions to generate logical forms. Action
Description
Set → find(e, p)
Set of objects (entities) with subject e and predicate p
Set → find reverse(e, p)
Set of subjects (entities) with object e and predicate p
Set → filter by type(set, tp)
Filter the given set of entities based on the given type
Set → filter mult types(set1 , set2 ) Filter the given set of entities based on the given set of types Boolean → is in(set, entity)
Check if the entity is part of the set
Boolean → is subset (set1 , set2 )
Check if set2 is subset of set1
Number → count(set)
Count the number of elements in the set
Dict → per type(p, tp1 , tp2 )
Extracts a dictionary, where keys are entities of type1 and values are the Number of objects of type2 related with p
Dict → per type rev(p, tp1 , tp2 )
Extracts a dictionary, where keys are entities of type1 and values are the Number of subjects of type2 related with p
Set → greater(num, dict)
Set of entities that have greater count than num
Set → lesser(num, dict)
Set of entities that have lesser count than num
Set → equal(num, dict)
Set of entities that have equal count with num
Set → approx(num, dict)
Set of entities that have approximately same count with num
Set → argmin(dict)
Set of entities that have the most count
Set → argmax(dict)
Set of entities that have the least count
Set → union(set1 , set2 )
Union of set1 and set2
Set → intersection(set1 , set2 )
Intersection of set1 and set2
Set → difference(set1 , set2 )
Difference of set1 and set2
3.2 Context Transformer The section describes the semantic parsing part of CARTON, which is a context transformer. The transformer receives input a conversation turn that contains the context of the interaction and generates a sequence of actions. Formally, an interaction I consists of the question q that is a sequence x = {x1 , . . . , xn }, and a label l that is a sequence y = {y1 , . . . , ym }. The network aims to model the conditional probability p(y|x). Contextual Encoder. In order to cope with coreference and ellipsis phenomena, we require to include the context from the previous interaction in the conversation turn. To accomplish that, the input to the contextual encoder is the concatenation of three utterances from the dialog turn: 1) the previous question, 2) the previous answer, and 3) the current question. Every utterance is separated from one another using a < SEP > token. A special context token < CT X > is appended at the end where the embedding
362
J. Plepi et al. Table 3. Examples from the CSQA dataset [19], annotated with gold logical forms.
Question Type Question
Logical Forms
Simple Question (Direct)
Q1: Which administrative territory is the birthplace of Antonio Reguero ?
filter type( find(Antonio Reguero, place of birth), administrative territorial entity)
Simple Question (Ellipsis)
Q1: Which administrative territories are twin towns of Madrid ? A1: Prague, Moscow, Budapest Q2: And what about Urban Community of Brest?
filter type( find(Urban Community of Brest, twinned administrative body), administrative territorial entity)
Q1: What was the sport that Marie Pyko was a part of ? Simple A1: Association football Question (Coreferenced) Q2: Which political territory does that person belong to ?
filter type( find(Marie Pyko, country of citizenship), political territorial entity)
Quantitative Reasoning (Count) (All)
count(union( filter type( Q1: How many beauty contests and business find reverse( Caracas, located in), enterprises are located at that city ? beauty contest), A1: Did you mean Caracas? filter type( Q2: Yes find reverse(Caracas, located in), business enterprises)))
Quantitative Reasoning (All)
Q1; Which political territories are known to have diplomatic connections with max number of political territories ?
argmax( per type( diplomatic relation, political territorial entity, political territorial entity))
Comparative Reasoning (Count) (All)
Q1: How many alphabets are used as the scripts for more number of languages than Jawi alphabet ?
count(greater(count( filter type(find(Jawi alphabet, writing system), language)), per type(writing system, alphabet, language)))
Comparative Reasoning (All)
greater(filter type( find(composer, main subject), occupations), and( Q1: Which occupations were more number per type(main subject, publications, of publications and works mainly about than composer ? occupations), per type(main subject, work, occupations)))
Verification
Q1: Was Geir Rasmussen born at that administrative territory ?
is in( find(Geir Rasmussen, place of birth), Chicago)
CARTON
363
of this utterance is used as the semantic representation for the entire input question. Given an utterance q containing n words {w1 , . . . , wn }, we use GloVe [18] to embed the words into a vector representation space of dimension demb . More specifically, we get a sequence x = {x1 , . . . , xn } where xi is given by, xi = GloV e(wi ) and xi ∈ Rdemb . Next, the word embeddings x, are forwarded as input to the contextual encoder, that uses the multi-head attention mechanism from the Transformer network [25]. The encoder outputs the contextual embeddings h = {h1 , . . . , hn }, where hi ∈ Rdemb , and it can be written as: h = encoder(x; θ(enc) ) where θ(enc) are the trainable parameters of the contextual encoder. Logical Form Decoder. For the decoder, we likewise utilize the Transformer architecture with a multi-head attention mechanism. The decoder output is dependent on contextual embeddings h originated from the encoder. The decoder detects each action and general semantic object from the KG, i.e., the decoder predicts the correct logical form, without specifying the entity, predicate, or type. Here, the decoder vocabulary consists of V = {A0 , A1 , . . . , A18 , entity, predicate, type} where A0 , A1 , . . . , A18 are the short names of actions in Table 2. The goal is to produce a correct logical form sequence. The decoder stack is a transformer model supported by a linear and a softmax layer to estimate the probability scores, i.e., we can define it as: (dec)
s(dec) = decoder(h; θ(dec) ), pt = sof tmax(W (dec) st
)
(1)
(dec)
where st is the hidden state of the decoder in time step t, θ(dec) are the model parameters, W (dec) ∈ R|V |×demb are the weights of the feed-forward linear layer, and pt ∈ R|V | is the probability distribution over the decoder vocabulary for the output token in time step t. 3.3 Stacked Pointer Networks As we mentioned, the decoder only outputs the actions without specifying any KG items. To complete the logical form with instantiated semantic categories, we extend our model with an architecture of stacked pointer networks [26]. The architecture consists of three-pointer networks and each one of them is responsible for covering one of the major semantic categories (types, predicates, and entities) required for completing the final executable logical form against the KG. The first two pointer networks of the stack are used for predicates and types semantic category and follow a similar approach. The vocabulary and the inputs are the entire predicates and types of the KG. We define the vocabularies, V (pd) = {r1 , . . . , rnpd } and V (tp) = {τ1 , . . . , τntp }, where npd and ntp is the total number of predicates and types in the KG, respectively. To compute the pointer scores for each predicate or type
364
J. Plepi et al.
candidate, we use the current hidden state of the decoder and the context representation. We model the pointer networks with a feed-forward linear network and a softmax layer. We can define the type and predicate pointers as: (pd)
pt (pd)
(pd) (pd) vt ),
= sof tmax(W 1 (tp)
(pd)
(tp)
pt
(tp) (tp)
= sof tmax(W 1 vt
),
(2)
(tp)
| where pt ∈ R|V and pt ∈ R|V | are the probability distributions over the (pd) (tp) ∈ predicate and type vocabularies respectively. The weight matrices W 1 , W 1 1×dkg . Also, vt is a joint representation that includes the knowledge graph embedR dings, the context and the current decoder state, computed as: (pd)
vt
(tp) vt
(pd)
= tanh(W 2 =
[st ; hctx ] + r),
(tp) tanh(W 2 [st ; hctx ]
(pd)
+ τ ),
(3)
(tp)
where the weight matrices W 2 , W 2 ∈ Rdkg ×2demb , transform the concatenation of the current decoder state st with the context representation hctx . We denote with (pd) | are the dkg the dimension used for knowledge graph embeddings. r ∈ Rdkg ×|V (tp) dkg ×|V | predicate embeddings and τ ∈ R are the type embeddings. tanh is the nonlinear layer. Please note, that the vocabulary of predicates and types is updated during evaluation, hence the choice of pointer networks. The third pointer network of the stack is responsible for the entity prediction task. Here we follow a slightly different approach due to the massive number of entities that the KG may have. Predicting a probability distribution over KG with a considerable number of entities is not computationally feasible. For that reason, we decrease the size of entity vocabulary during each logical form prediction. In each conversation, we predict a probability distribution only for the entities that are part of the context. Our entity “memory” for each conversation turn involves entities from the previous question, previous answer, and current question. The probability distribution over the entities is then calculated in the same way as for predicates and types where the softmax is: (ent)
pt (ent)
(ent)
(ent) (ent) vt ),
= sof tmax(W 1
(4)
(ent)
where pt ∈ R|Vk | , and Vk is the set of entities for the k th conversation turn. (ent) 1×dkg The weight matrix W 1 ∈R and the vector vt is then computed following the same equations as before: (ent)
vt
(ent)
= tanh(W 2
([st ; hctx ]) + ek )
(5)
where ek is the sequence of entities for the k th conversation turn. In general, the pointer networks are robust to handle a different vocabulary size for each time step [26]. Moreover, given the knowledge graph embeddings, our stacked pointer networks select the relevant items from the knowledge graph depending on the conversational context. In this way, we incorporate knowledge graph embeddings in order to perform any reasoning and do not rely only on utterance features. Furthermore, the [21] utilizes a single pointer network that only operates on the input utterance to select the already identified entities. Our stacked pointer networks do not use the input utterance but rather directly rely on the knowledge graph semantic categories (types, predicates, and entities).
CARTON
365
3.4 Learning For each time step, we have four different predicted probability distributions. The first is the decoder output over the logical form’s vocabulary, and the three others from the stacked pointer networks for each of the semantic categories (entity, predicate, and type). Finally, we define CARTON loss function as: ⎛ ⎞ m 1 ⎝ (c) ⎠, Losst = − log pi [i=y(t) ] + (6) I[y(t) =c] logp (c ) i [i=yi t ] i i m i=1 c∈{ent,pd,tp}
where Losst is the loss function computed for the sequence in time step t, m is the length of the logical form, y (t) is the gold sequence of logical form, and y (ct ) is the gold label for one of the semantic categories c ∈ {ent, pd, tp}.
4 Experimental Setup Dataset and Experiment Settings. We conduct our experiments on the Complex Sequential Question Answering (CSQA) dataset2 [19]. CSQA was built on the Wikidata KG. The CSQA dataset consists of around 200K dialogues where each partition train, valid, test contains 153K, 16K, 28K dialogues, respectively. The questions in the CSQA dataset involve complex reasoning on Wikidata to determine the correct answer. The different question types that appear in the dataset are simple questions, logical reasoning, verification, quantitative reasoning, comparative reasoning, and clarification. We can have different subtypes for each one of them, such as direct, indirect, coreference, and ellipsis questions. We stick to one dataset in experiments due to the following reasons 1) all the multi-task learning framework has been trained and tested only on the CSQA dataset. Hence, for a fair evaluation and comparison of our approach inheriting the evaluation settings same as [19, 21], we stick to the CSQA dataset. 2) other approaches [2, 24] on datasets such as ConvQA, TREC CAsT, etc. are not multi-task learning approaches. Further, we cannot retrain [8, 19, 21] on these datasets due to their missing logical forms employed by each of these models. We incorporate a semi-automated preprocessing step to annotate the CSQA dataset with gold logical forms. For each question type and subtype in the dataset, we create a general template with a pattern sequence that the actions should follow. Thereafter, for each question, we follow a set of rules to create the specific gold logical form that extracts the gold sequence of actions based on the type of the question. The actions used for this process are the one in Table 2. CARTON Configurations. For the transformer network, we use the configurations from [25]. Our model dimension is dmodel = 512, with a total number of H = 8 heads and layers L = 4. The inner feed-forward linear layers have dimension df f = 2048, (4 * 512). Following the base transformer parameters, we apply residual dropout to the summation of the embeddings and the positional encodings in both encoder and decoder 2
https://amritasaha1812.github.io/CSQA.
366
J. Plepi et al.
stacks with a rate of 0.1. On the other hand, the pointer networks also use a dropout layer for the linear projection of the knowledge graph embeddings. For predicates and types, we randomly initialize the embeddings and are jointly learned during training. The KG embeddings dimension of predicate and types match the transformer model dimension, dkg = 512. However, for the entities, we follow a different initialization. Due to a significantly high number of the entities, learning the entity embeddings from scratch was inefficient and resulted in poor performance. Therefore, to address this issue, we initialized the entity embeddings using sentence embeddings that implicitly use underlying hidden states from BERT network [3]. For each entity, we treat the tokens that it contains as a sentence, and we feed that as an input. We receive as output the entity representation with a dimension dent = 768. Next, we feed this into a linear layer that learns, during training, to embed the entity into the same dimension as the predicates and types. Models for Comparison. To compare the CARTON framework, we use the last three baselines that have been evaluated on the employed dataset. The authors of the CSQA dataset introduce the first baseline: HRED+KVmem [19] model. HRED+KVmem employs a seq2seq [23] model extended with memory networks [12, 22]. The model uses HRED model [20] to extract dialog representations and extends it with a KeyValue memory network [17] for extracting information from KG. Next, D2A [8] uses a semantic parsing approach based on a seq2seq model, extended with dialog memory manager to handle different linguistic problems in conversations such as ellipsis and coreference. Finally, MaSP [21] is the current SotA and is also a semantic parsing approach. Evaluation Metrics. To evaluate CARTON, we use the same metrics as employed by the authors of the CSQA dataset [19] and previous baselines. We use the “F1-score” for questions that have an answer composed by a set of entities. “Accuracy” is used for the question types whose answer is a number or a boolean value (YES/NO).
5 Results We report our empirical results in Table 4, and conclude that CARTON outperforms baselines average on all question types (row “overall” in the table). We dig deeper into the accuracy per question type to understand the overall performance. Compared to the current state-of-the-art (MaSP), CARTON performs better on eight out of ten question types. CARTON is leading MaSP in question type categories such as Logical Reasoning (All), Quantitative Reasoning (All), Simple Question (Coreferenced), Simple Question (Direct), Simple Question (Ellipsis), Verification (Boolean), Quantitative Reasoning (Count), and Comparative Reasoning (Count). Whereas, MaSP retains the state of the art for the categories of Clarification and Comparative Reasoning (All). The main reason for weak results in Comparative Reasoning (All) is that our preprocessing step finds limitation in covering this question type and is one of the shortcoming
CARTON
367
Table 4. Comparisons among baseline models on the CSQA dataset having 200K dialogues with 1.6M turns, and over 12.8M entities. MaSP
CARTON (ours) Δ
66.70% 35.53% 48.85% 67.31% 56.41% 57.69% 78.42% 81.14%
79.26% 80.79% 68.90% 69.04% 73.75% 76.47% 85.18% 83.73%
81.35% 47.31% 62.00% 80.80% 80.62% 87.09% 85.92% 85.07%
+2.09% –33.48% –6.90% +11.76% +6.87% +10.62% +0.74% +1.34%
37.33% 45.05% 40.94% 17.78%
45.56% 60.63% 43.39% 22.26%
61.28% 77.82% 57.04% 38.31%
+15.72% +17.19% +13.65% +16.05%
Methods
HRED-KV D2A
Question type (QT)
F1 score
Overall 9.39% 16.35% Clarification 2.96% Comparative reasoning (All) 8.33% Logical reasoning (All) 0.96% Quantitative reasoning (All) Simple question (Coreferenced) 7.26% 13.64% Simple question (Direct) 9.95% Simple question (Ellipsis) Question type (QT)
Accuracy
Overall 14.95% 21.04% Verification (Boolean) Quantitative reasoning (Count) 12.13% Comparative reasoning (Count) 8.67%
of our proposed grammar3 . We investigated several reasonable ways to cover Comparative Reasoning (All) question type. However, it was challenging to produce a final answer set identical to the gold answer set. For instance, consider the question “Which administrative territories have diplomatic relations with around the same number of administrative territories than Albania?” that includes logic operators like “around the same number”, which is ambiguous because CARTON needs to look for the correct answer in a range of the numbers. Whereas, MaSP uses a BFS method to search the gold logical forms and performance is superior to CARTON. The limitation with Comparative Reasoning question type also affects CARTON’s performance in the Clarification question type where a considerable number of questions correspond to Comparative Reasoning. Based on analysis, we outline the following two reasons for CARTON’s outperformance over MaSP: First, the MaSP model requires to perform entity recognition and linking to generate the correct entity candidate. Even though MaSP is a multi-task model, errors at entity recognition step will still be propagated to the underlying coreference network. CARTON is agnostic of such a scenario since the candidate entity set considered for each conversation turn is related to the entire relevant context (the previous question, answer, and current question). In CARTON, entity detection is performed only by stacked pointer networks. Hence no error propagation related to entities affects previous steps of the framework. Second, CARTON uses better supervision signals than MaSP. As mentioned earlier, CARTON supervision signals propagate in sequential order, and all components use the signal forwarded from the previous 3
For instance, when we applied the preprocessing step over the test set, we could not annotate the majority of the examples for the Comparative Reasoning (All) question type.
368
J. Plepi et al.
Table 5. CARTON ablation study. “W/o St. Pointer” column shows results when stacked pointers in CARTON is replaced by classifiers. Question type (QT)
CARTON W/o St. Pointers
Clarification Comparative reasoning (All) Logical reasoning (All) Quantitative reasoning (All) Simple question (Coreferenced) Simple question (Direct) Simple question (Ellipsis)
47.31% 62.00% 80.80% 80.62% 87.09% 85.92% 85.07%
42.47% 55.82% 68.23% 71.59% 85.28% 83.64% 82.11%
Verification (Boolean) 77.82% Quantitative reasoning (Count) 57.04% Comparative reasoning (Count) 38.31%
70.38% 51.73% 30.87%
components. In contrast, the MaSP model co-trains entity detection and semantic parsing with different supervision signals. 5.1
Ablation Study
An ablation study is conducted to support our architectural choices of CARTON. To do so, we replace stacked pointer networks module with simple classifiers. In particular, predicates and types are predicted using two linear classifiers using the representations from the contextual encoder. Table 5 illustrates that the modified setting (w/o St. Pointers) significantly under-performs compared to CARTON in all question types. The stacked pointer networks generalize better in the test set due to their ability to learn meaningful representations for the KG items and align learned representations with the conversational context. While classifiers thoroughly learn to identify common patterns between examples without incorporating any information from the KG. Furthermore, our framework’s improved results are implied from the ability of stacked pointer networks to handle out-of-vocabulary entities, predicates, and types that are unseen during training. 5.2
Error Analysis
We now present a detailed analysis of CARTON by reporting some additional metrics. Table 6 reports the accuracy of predicting the KG items such as entity, predicate, or type using CARTON. The prediction accuracy of KG items is closely related to the performance of our model, as shown in Table 4. For example, in the Quantitative (All) question type (Table 4), predicting the correct type has an accuracy of 73.46% which is lowest compared to other question types. The type prediction is essential in such category of questions, where a typical logical form possibly is: “argmin, find tuple counts, predicate, type1, type2”. Filtering by the wrong type gets the incorrect result. Please
CARTON
369
Table 6. CARTON stacked pointer networks results for each question type. We report CARTON’s accuracy in predicting the KG items such as entity, predicate, or type. Question type (QT)
Entity
Predicate Type
Clarification Comparative reasoning (All) Logical reasoning (All) Quantitative reasoning (All) Simple question (Coreferenced) Simple question (Direct) Simple question (Ellipsis)
36.71% 67.63% 64.7% – 81.13% 86.07% 98.87%
94.76% 97.92% 83.18% 98.46% 91.09% 91% 92.49%
80.79% 77.57% 91.56% 73.46% 80.13% 82.19% 80.31%
Verification (Boolean) 43.01% 94.72% Quantitative reasoning (Count) 79.60% 94.46% Comparative reasoning (Count) 70.29% 98.05%
– 79.51% 78.38%
note, there is no “entity” involved in the logical forms of Quantitative (All) question type. Hence, no entity accuracy is reported. Another interesting result is the high accuracy of the entities and predicates in Comparative (Count) questions. Also, the accuracy of type detection is 78.38%. However, these questions’ accuracy was relatively low, only 38.31%, as reported in Table 4. We believe that improved accuracy is mainly affected due to the mapping process of entities, predicates, and types to the logical forms that is followed to reach the correct answer. Another insightful result is on Simple (Ellipsis), where CARTON has a high entity accuracy compared with Simple Question. A possible reason is the short length of the question, making it easier for the model to focus on the right entity. Some example of this question type is “And what about Bonn?”, where the predicate is extracted from the previous utterance of the question. We compute the accuracy of the decoder which is used to find the correct patterns of the logical forms. We also calculate the accuracy of the logical forms after the pointer networks initialize the KG items. We report an average accuracy across question types for generating logical form (by decoder) as 97.24%, and after initializing the KG items, the average accuracy drops to 75.61%. Higher accuracy of logical form generation shows the decoder’s effectiveness and how the Transformer network can extract the correct patterns given the conversational context. Furthermore, it also justifies that the higher error percentage is generated while initializing the items from the KG. When sampling some of the wrong logical forms, we found out that most of the errors were generated from initializing a similar predicate or incorrect order of the types in the logical actions.
6 Conclusions In this work, we focus on complex question answering over a large-scale KG containing conversational context. We used a transformer-based model to generate logical forms.
370
J. Plepi et al.
The decoder was extended with a stack of pointer networks in order to include information from the large-scale KG associated with the dataset. The stacked pointer networks, given the conversational context extracted by the transformer, predict the specific KG item required in a particular position of the action sequence. We empirically demonstrate that our model performs the best in several question types and how entity and type detection accuracy affect the performance. The main drawback of the semantic parsing approaches is the error propagated from the preprocessing step, which is not 100% accurate. However, to train the model in a supervised way, we need the gold logical form annotations. The model focuses on learning the correct logical forms, but there is no feedback signal from the resulting answer generated from its logical structure. We believe reinforcement learning can solve these drawbacks and is the most viable next step of our work. Furthermore, how to improve the performance of Clarification and Comparative Reasoning question type is an open question and a direction for future research. Acknowledgments. The project leading to this publication has received funding from the European Union’s Horizon 2020 research and innovation program under the Marie Skłodowska-Curie grant agreement No. 812997 (Cleopatra).
References 1. Bollacker, K.D., Cook, R.P., Tufts, P.: Freebase: a shared database of structured general human knowledge. In: AAAI 2007 (2007) 2. Christmann, P., Saha Roy, R., Abujabal, A., Singh, J., Weikum, G.: Look before you hop: conversational question answering over knowledge graphs using judicious context expansion. In: CIKM (2019) 3. Devlin, J., Chang, M.W., Lee, K., Toutanova, K.: BERT: pre-training of deep bidirectional transformers for language understanding. In: NAACL (2019) 4. Dong, L., Lapata, M.: Language to logical form with neural attention. In: ACL (2016) 5. Dong, L., Lapata, M.: Coarse-to-fine decoding for neural semantic parsing. In: ACL. association for Computational Linguistics (2018) 6. Dong, L., Wei, F., Zhou, M., Xu, K.: Question answering over freebase with multi-column convolutional neural networks. In: ACL (2015) 7. Fensel, D., et al.: Why We Need Knowledge Graphs: Applications. Knowledge Graphs, pp. 95–112. Springer, Cham (2020). https://doi.org/10.1007/978-3-030-37439-6 4 8. Guo, D., Tang, D., Duan, N., Zhou, M., Yin, J.: Dialog-to-action: Conversational question answering over a large-scale knowledge base. In: Advances in Neural Information Processing Systems 31: Annual Conference on Neural Information Processing Systems 2018, NeurIPS 2018 (2018) 9. Jia, R., Liang, P.: Data recombination for neural semantic parsing. In: ACL (Long Papers). Association for Computational Linguistics (2016) 10. Kassawat, F., Chaudhuri, D., Lehmann, J.: Incorporating joint embeddings into goal-oriented dialogues with multi-task learning. In: Hitzler, P. (ed.) ESWC 2019. LNCS, vol. 11503, pp. 225–239. Springer, Cham (2019). https://doi.org/10.1007/978-3-030-21348-0 15 11. Lehmann, J., et al.: Dbpedia - a large-scale, multilingual knowledge base extracted from wikipedia. Seman. Web 6(2), 167–195 (2015) 12. Li, Z., Zhang, Y., Wei, Y., Wu, Y., Yang, Q.: End-to-end adversarial memory network for cross-domain sentiment classification. In: ICAI (2017)
CARTON
371
13. Liang, C., Berant, J., Le, Q.V., Forbus, K.D., Lao, N.: Neural symbolic machines: Learning semantic parsers on freebase with weak supervision. In: Proceedings of the 55th Annual Meeting of the Association for Computational Linguistics, ACL Long Papers. Association for Computational Linguistics (2017) 14. Lu, W., Ng, H.T., Lee, W.S., Zettlemoyer, L.S.: A generative model for parsing natural language to meaning representations. In: 2008 Conference on Empirical Methods in Natural Language Processing, EMNLP 2008, ACL (2008) 15. Lukovnikov, D., Fischer, A., Lehmann, J., Auer, S.: Neural network-based question answering over knowledge graphs on word and character level. In: Barrett, R., Cummings, R., Agichtein, E., Gabrilovich, E. (eds.) The Web Conference. ACM (2017) 16. Luo, K., Lin, F., Luo, X., Zhu, K.: Knowledge base question answering via encoding of complex query graphs. In: EMNLP (2018) 17. Miller, A.H., Fisch, A., Dodge, J., Karimi, A., Bordes, A., Weston, J.: Key-value memory networks for directly reading documents. In: Su, J., Carreras, X., Duh, K. (eds.) Proceedings of the 2016 Conference on Empirical Methods in Natural Language Processing, EMNLP (2016) 18. Pennington, J., Socher, R., Manning, C.: Glove: global vectors for word representation. In: Proceedings of the 2014 Conference on Empirical Methods in Natural Language Processing (EMNLP), ACL (2014) 19. Saha, A., Pahuja, V., Khapra, M.M., Sankaranarayanan, K., Chandar, S.: Complex sequential question answering: Towards learning to converse over linked question answer pairs with a knowledge graph. In: Proceedings of the Thirty-Second AAAI Conference on Artificial Intelligence, (AAAI-2018), AAAI Press (2018) 20. Serban, I.V., Sordoni, A., Bengio, Y., Courville, A.C., Pineau, J.: Building end-to-end dialogue systems using generative hierarchical neural network models. In: AAAI (2016) 21. Shen, T., et al.: Multi-task learning for conversational question answering over a large-scale knowledge base. In: Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing. Association for Computational Linguistics (2019) 22. Sukhbaatar, S., Szlam, A., Weston, J., Fergus, R.: End-to-end memory networks. In: NeurlPS (2015) 23. Sutskever, I., Vinyals, O., Le, Q.V.: Sequence to sequence learning with neural networks. In: Advances in neural information processing systems (2014) 24. Vakulenko, S., Longpre, S., Tu, Z., Anantha, R.: Question rewriting for conversational question answering. arXiv preprint arXiv:2004.14652 (2020) 25. Vaswani, A., et al.: Attention is all you need. In: NeurlPS (2017) 26. Vinyals, O., Fortunato, M., Jaitly, N.: Pointer networks. In: Advances in neural information processing systems (2015) 27. Vrandeˇci´c, D., Kr¨otzsch, M.: Wikidata: a free collaborative knowledgebase. Commun. ACM 57(10), 78–85 (2014) 28. Xiao, C., Dymetman, M., Gardent, C.: Sequence-based structured prediction for semantic parsing. In: Proceedings of the 54th Annual Meeting of the Association for Computational Linguistics, vol. 1, Long Papers. Association for Computational Linguistics (2016) 29. Xu, K., Reddy, S., Feng, Y., Huang, S., Zhao, D.: Question answering on Freebase via relation extraction and textual evidence. In: ACL (2016) 30. Yih, W., Richardson, M., Meek, C., Chang, M., Suh, J.: The value of semantic parse labeling for knowledge base question answering. In: Proceedings of the 54th Annual Meeting of the Association for Computational Linguistics, ACL. The Association for Computer Linguistics (2016) 31. Zhang, Y., Dai, H., Kozareva, Z., Smola, A.J., Song, L.: Variational reasoning for question answering with knowledge graph. In: Proceedings of the Thirty-Second AAAI Conference on Artificial Intelligence, (AAAI-2018), AAAI Press (2018)
Machine Learning
Neural Multi-hop Reasoning with Logical Rules on Biomedical Knowledge Graphs Yushan Liu1,3(B) , Marcel Hildebrandt1,3 , Mitchell Joblin1 , Martin Ringsquandl1 , Rime Raissouni2,3 , and Volker Tresp1,3 1
Siemens, Otto-Hahn-Ring 6, 81739 Munich, Germany {yushan.liu,marcel.hildebrandt,mitchell.joblin,martin.ringsquandl, volker.tresp}@siemens.com 2 Siemens Healthineers, Hartmanntraße 16, 91052 Erlangen, Germany [email protected] 3 Ludwig Maximilian University of Munich, Geschwister-Scholl-Platz 1, 80539 Munich, Germany
Abstract. Biomedical knowledge graphs permit an integrative computational approach to reasoning about biological systems. The nature of biological data leads to a graph structure that differs from those typically encountered in benchmarking datasets. To understand the implications this may have on the performance of reasoning algorithms, we conduct an empirical study based on the real-world task of drug repurposing. We formulate this task as a link prediction problem where both compounds and diseases correspond to entities in a knowledge graph. To overcome apparent weaknesses of existing algorithms, we propose a new method, PoLo, that combines policy-guided walks based on reinforcement learning with logical rules. These rules are integrated into the algorithm by using a novel reward function. We apply our method to Hetionet, which integrates biomedical information from 29 prominent bioinformatics databases. Our experiments show that our approach outperforms several state-of-the-art methods for link prediction while providing interpretability. Keywords: Neural multi-hop reasoning · Reinforcement learning Logical rules · Biomedical knowledge graphs
1
·
Introduction
Advancements in low-cost high-throughput sequencing, data acquisition technologies, and compute paradigms have given rise to a massive proliferation of data describing biological systems. This new landscape of available data spans a multitude of dimensions, which provide complementary views on the structure of biological systems. Historically, by considering single dimensions (i. e., single types of data), researchers have made progress in understanding many important phenomena. More recently, there has been a movement to develop statistical and c Springer Nature Switzerland AG 2021 R. Verborgh et al. (Eds.): ESWC 2021, LNCS 12731, pp. 375–391, 2021. https://doi.org/10.1007/978-3-030-77385-4_22
376
Y. Liu et al.
computational methods that leverage more holistic views by simultaneously considering multiple types of data [40]. To achieve this goal, graph-based knowledge representation has emerged as a promising direction since the inherent flexibility of graphs makes them particularly well-suited for this problem setting.
Fig. 1. (a) Visualization of the heterogeneous biomedical KG Hetionet [13] (reprint under the use of the CC BY 4.0 license). (b) Schema of Hetionet: Hetionet has 11 different entity types and 24 possible relations between them. Source: https://het.io/ about/.
Biomedical knowledge graphs (KGs) are becoming increasingly popular for tasks such as personalized medicine, predictive diagnosis, and drug discovery [9]. Drug discovery, for example, requires a multitude of biomedical data types combined with knowledge across diverse domains (including gene-protein bindings, chemical compounds, and biological pathways). These individual types of data are typically scattered across disparate data sources, published for domainspecific research problems without considering mappings to open standards. To this end, KGs and Semantic Web technologies are being applied to model ontologies that combine knowledge and integrate data contained in biomedical data sources, most notably Bio2RDF [2], for classical query-based question answering. From a machine learning perspective, reasoning on biomedical KGs presents new challenges for existing approaches due to the unique structural characteristics of the KGs. One challenge arises from the highly coupled nature of entities in biological systems that leads to many high-degree entities that are themselves densely linked. For example, as illustrated in Fig. 1a, genes interact abundantly among themselves. They are involved in a diverse set of biological pathways and molecular functions and have numerous associations with diseases. A second challenge is that reasoning about the relationship between two entities often requires information beyond second-order neighborhoods [13].
Neural Multi-hop Reasoning with Logical Rules
377
Methods that rely on shallow node embeddings (e. g., TransE [4], DistMult [38]) typically do not perform well in this situation. Approaches that take the entire multi-hop neighborhoods into account (e. g., graph convolutional networks, RGCN [30]) often have diminishing performance beyond two-hop neighborhoods (i. e., more than two convolutional layers), and the high-degree entities can cause the aggregation operations to smooth out the signal [16]. Symbolic approaches (e. g., AMIE+ [10], RuleN [21]) learn logical rules and employ them during inference. These methods might be able to take long-range dependencies into account, but due to the massive scale and diverse topologies of many real-world KGs, combinatorial complexity often prevents the usage of symbolic approaches [14]. Also, logical inference has difficulties handling noise in the data [24]. Under these structural conditions, path-based methods present a seemingly ideal balance for combining information over multi-hop neighborhoods. The key challenge is to find meaningful paths, which can be computationally difficult if the search is not guided by domain principles. Our goal is to explore how a pathbased approach performs in comparison with alternative state-of-the art methods and to identify a way of overcoming weaknesses present in current approaches. We consider the drug repurposing problem, which is characterized by finding novel treatment targets for existing drugs. Available knowledge about drugdisease-interactions can be exploited to reduce costs and time for developing new drugs significantly. A recent example is the repositioning of the drug remdesivir for the novel disease COVID-19. We formulate this task as a link prediction problem where both compounds and diseases correspond to entities in a KG. We propose a neuro-symbolic reasoning approach, PoLo (Policy-guided walks with Logical rules), that leverages both representation learning and logic. Inspired by existing methods [5,12,18], our approach uses reinforcement learning to train an agent to conduct policy-guided random walks on a KG. As a modification to approaches based on policy-guided walks, we introduce a novel reward function that allows the agent to use background knowledge formalized as logical rules, which guide the agent during training. The extracted paths by the agent act as explanations for the predictions. Our results demonstrate that existing methods are inadequately designed to perform ideally in the unique structural characteristics of biomedical data. We can overcome some of the weaknesses of existing methods and show the potential of neuro-symbolic methods for the biomedical domain, where interpretability and transparency of the results are highly relevant to facilitate the accessibility for domain experts. In summary, we make the following contributions: – We propose the neuro-symbolic KG reasoning method PoLo that combines policy-guided walks based on reinforcement learning with logical rules. – We conduct an empirical study using a large biomedical KG where we compare our approach with several state-of-the-art algorithms. – The results show that our proposed approach outperforms state-of-the-art alternatives on a highly relevant biomedical prediction task (drug repurposing) with respect to the metrics hits@k for k ∈ {1, 3, 10} and the mean reciprocal rank.
378
Y. Liu et al.
We briefly introduce the notation and review the related literature in Sect. 2. In Sect. 3, we describe our proposed method1 . Section 4 details an experimental study, and we conclude in Sect. 5.
2
Background
2.1
Knowledge Graphs
Let E denote the set of entities in a KG and R the set of binary relations. Elements in E correspond to biomedical entities including, e. g., chemical compounds, diseases, and genes. We assume that every entity belongs to a unique type in T , defined by the mapping τ : E → T . For example, τ (AURKC) = Gene indicates that the entity AURKC has type Gene. Relations in R specify how Fig. 2. Subgraph of Hetionet illustrating the entities are connected. We define drug repurposing use case. The two paths that a KG as a collection of triples connect the chemical compound sorafenib and KG ⊂ E × R × E in the form the disease kidney cancer can be used to pre(h, r, t), which consists of a head dict a direct edge between the two entities. entity, a relation, and a tail entity. Head and tail of a triple are also called source and target, respectively. From a graphical point of view, head and tail entities correspond to nodes in the graph while the relation indicates the type of edge between them. For any relation r ∈ R, we denote the corresponding inverse relation with r−1 (i. e., (h, r, t) is equivalent to (t, r−1 , h)). Triples in KG are interpreted as true known facts. For example, the triple (Sorafenib, treats, Liver Cancer) ∈ KG in Fig. 2 corresponds to the known fact that the kinase inhibitor drug sorafenib is approved for the treatment of primary liver cancer. The treats relation is of particular importance for this work since we frame the task of drug repurposing as a link prediction problem with respect to edges of the type treats. The domain of treats consists of chemical compounds, and the range is given by the set of all diseases. We further distinguish between two types of paths: instance paths and metapaths. An instance path of length L ∈ N on KG is given by a sequence r
r
r
L 1 2 e2 −→ . . . −→ eL+1 ) , (e1 −→
where (ei , ri , ei+1 ) ∈ KG. We call the corresponding sequence of entity types r
r
r
1 2 L (τ (e1 ) −→ τ (e2 ) −→ . . . −→ τ (eL+1 ))
1
The source code is available at https://github.com/liu-yushan/PoLo.
Neural Multi-hop Reasoning with Logical Rules
379
a metapath. For example, treats
resembles
(Sorafenib −−−→ Liver Cancer − −−−−− → Kidney Cancer)
constitutes an instance path of length 2, where treats
resembles
(Compound −−−→ Disease − −−−−− → Disease)
is the corresponding metapath. 2.2
Logical Rules
Logical rules that are typically employed for KG reasoning can be written in the form head ← body. We consider cyclic rules of the form (τ1 , rL+1 , τL+1 ) ←
L
(τi , ri , τi+1 ) ,
i=1
where τi ∈ T . The rule is called cyclic since the rule head (not to be confused with the head entity in a triple) connects the source τ1 and the target τL+1 of rL r1 r2 τ2 −→ . . . −→ τL+1 ), which is described by the rule body. the metapath (τ1 −→ The goal is to find instance paths where the corresponding metapaths match the rule body in order to predict a new relation between the source and the target entity of the instance path. For the drug repurposing task, we only consider rules where the rule head is a triple with respect to the treats relation. Define CtD := (Compound, treats, Disease). Then, a generic rule has the form rL r2 r3 r1 CtD ← Compound −→ τ2 −→ τ3 −→ . . . −−→ Disease .
In particular, the rule body corresponds to a metapath starting at a compound and terminating at a disease. For example (see Fig. 2), consider the rule binds−1
binds
treats
CtD ← (Compound −−−→ Gene −−−−−→ Compound −−−→ Disease) .
The metapath of the instance path binds
binds−1
treats
(Sorafenib −−−→ AURKC −−−−−→ Pazopanib −−−→ Kidney Cancer)
matches the rule body, suggesting that sorafenib can also treat kidney cancer. 2.3
Related Work
Even though real-world KGs contain a massive number of triples, they are still expected to suffer from incompleteness. Therefore, link prediction (also known as KG completion) is a common reasoning task on KGs. Many classical artificial intelligence tasks such as recommendation problems or question answering can be rephrased in terms of link prediction.
380
Y. Liu et al.
Symbolic approaches have a far-reaching tradition in the context of knowledge acquisition and reasoning. Reasoning with logical rules has been addressed in areas such as Markov logic networks (MLNs) [28] or inductive logic programming [25]. However, such techniques typically do not scale well to modern, large-scale KGs. Recently, novel methods such as RuleN [21] and its successor AnyBURL [19,20] have been proposed that achieve state-of-the-art performance on popular benchmark datasets such as FB15k-237 [31] and WN18RR [7]. Subsymbolic approaches map nodes and edges in KGs to low-dimensional vector representations known as embeddings. Then, the likelihood of missing triples is approximated by a classifier that operates on the embedding space. Popular embedding-based methods include translational methods like TransE [4], more generalized approaches such as DistMult[38] and ComplEx [32], multi-layer models like ConvE [7], and tensor factorization methods like RESCAL [26]. Moreover, R-GCN [30] and CompGCN [34] have been proposed, which extend graph convolutional networks [16] to multi-relational graphs. Despite achieving good results on the link prediction task, a fundamental problem is their non-transparent nature since it remains hidden to the user what contributed to the predictions. Moreover, most embedding-based methods have difficulties in capturing longrange dependencies since they only minimize the reconstruction error in the immediate first-order neighborhoods. Especially the expressiveness of long-tail entities might be low due to the small number of neighbors [11]. Neuro-symbolic methods combine the advantages of robust learning and scalability in subsymbolic approaches with the reasoning properties and interpretability of symbolic representation. For example, Neural LP [39] and Neural Theorem Provers (NTPs) [29] integrate logical rules in a differentiable way into a neural network architecture. The method pLogicNet [27] combines MLNs with embedding-based models and learns a joint distribution over triples, while the Logic Tensor Network [8] inserts background knowledge into neural networks in the form of logical constraints. However, many neuro-symbolic approaches suffer from limited transferability and computational inefficiency. Minervini et al. have presented two more scalable extensions of NTPs, namely the Greedy NTP (GNTP) [22], which considers the top-k rules that are most likely to prove the goal instead of using a fixed set of rules, and the Conditional Theorem Prover (CTP) [23], which learns an adaptive strategy for selecting the rules. Multi-hop reasoning or path-based approaches infer missing knowledge based on using extracted paths from the KG as features for various inference tasks. Along with a prediction, multi-hop reasoning methods provide the user with an explicit reasoning chain that may serve as a justification for the prediction. For example, the Path Ranking Algorithm (PRA) [17] frames the link prediction task as a maximum likelihood classification based on paths sampled from nearest neighbor random walks on the KG. Xiong et al. extend this idea and formulate the task of path extraction as a reinforcement learning problem (DeepPath [37]). Our proposed method is an extension of the path-based approach MINERVA [5], which trains a reinforcement learning agent to perform a policy-guided random walk until the answer entity to an input query is reached.
Neural Multi-hop Reasoning with Logical Rules
381
One of the drawbacks of existing policy-guided walk methods is that the agent might receive noisy reward signals based on spurious triples that lead to the correct answers during training but lower the generalization capabilities. Moreover, biomedical KGs often exhibit both long-range dependencies and highdegree nodes (see Sect. 4.1). These two properties and the fact that MINERVA’s agent only receives a reward if the answer entity is correct make it difficult for the agent to navigate over biomedical KGs and extend a path in the most promising way. As a remedy, we propose the incorporation of known, effective logical rules via a novel reward function. This can help to denoise the reward signal and guide the agent on long paths with high-degree nodes.
3
Our Method
We pose the task of drug repurposing as a link prediction problem based on graph traversal. The general Markov decision process definition that we use has initially been proposed in the algorithm MINERVA [5], with our primary contribution coming from the incorporation of logical rules into the training process. The following notation and definitions are adapted to the use case. Starting at a query entity (a compound to be repurposed), an agent performs a walk on the graph by sequentially transitioning to a neighboring node. The decision of which transition to make is determined by a stochastic policy. Each subsequent transition is added to the current path and extends the reasoning chain. The stochastic walk process iterates until a finite number of transitions has been made. Formally, the learning task is modeled via the fixed-horizon Markov decision process outlined below. Environment. The state space S is given by E 3 . Intuitively, we want the state to encode the location el of the agent for step l ∈ N, the source entity ec , and the target entity ed , corresponding to the compound that we aim to repurpose and the target disease, respectively. Thus, a state Sl ∈ S for step l ∈ N is represented by Sl := (el , ec , ed ). The agent is given no information about the target disease so that the observed part of the state space is given by (el , ec ) ∈ E 2 . The set of available actions from a state Sl is denoted by ASl . It contains all outgoing edges from the node el and the corresponding tail nodes. We also include self-loops for each node so that the agent has the possibility to stay at the current node. More formally, ASl := {(r, e) ∈ R × E : (el , r, e) ∈ KG} ∪ {(∅, el )}. Further, we denote with Al ∈ ASl the action that the agent performed in step l. The environment evolves deterministically by updating the state according to the previous action. The transition function is given by δ(Sl , Al ) := (el+1 , ec , ed ) with Sl = (el , ec , ed ) and Al = (rl , el+1 ). Policy. We denote the history of the agent up to step l with Hl := (Hl−1 , Al−1 ) for l ≥ 1, with H0 := ec and A0 := ∅. The agent encodes the transition history via an LSTM [15] by (1) hl = LSTM (hl−1 , al−1 ) ,
382
Y. Liu et al.
where al−1 := [r l−1 ; el ] ∈ R2d corresponds to the vector space embedding of the previous action (or the zero vector for a0 ), with r l−1 and el denoting the embeddings of the relation and the tail entity in Rd , respectively. The historydependent action distribution is given by dl = softmax (Al (W 2 ReLU (W 1 [hl ; el ]))) ,
(2)
where the rows of Al ∈ R|ASl |×2d contain the latent representations of all admissible actions from Sl . The matrices W1 and W2 are learnable weight matrices. The action Al ∈ ASl is drawn according to Al ∼ Categorical (dl ) .
(3)
The Eqs. (1)–(3) are repeated for each transition step. In total, L transitions are sampled, where L is a hyperparameter that determines the maximum path length, resulting in a path denoted by r
r
r
L 1 2 e2 −→ . . . −→ eL+1 ) . P := (ec −→
For each step l ∈ {1, 2, . . . , L}, the agent can also choose to remain at the current location and not extend the reasoning path. Equations (1) and (2) define a mapping from the space of histories to the space of distributions over all admissible actions. Thus, including Eq. (3), a stochastic policy πθ is induced, where θ denotes the set of all trainable parameters in Eq. (1) and (2). Metapaths. Consider the set of metapaths M = {M1 , M2 , . . . , Mm }, where each element corresponds to the body of a cyclic rule with CtD as rule head. For every metapath M , we denote with s(M ) ∈ R>0 a score that indicates a quality measure of the corresponding rule, such as the confidence or the support with respect to making a correct prediction. Moreover, for a path P , we denote with P˜ the corresponding metapath. Rewards and Optimization. During training, after the agent has reached its final location, a terminal reward is assigned according to R(SL+1 ) = 1{eL+1 =ed } + bλ
m
s(Mi )1P˜ =Mi .
(4)
i=1
The first term indicates whether the agent has reached the correct target disease that can be treated by the compound ec . It means that the agent receives a reward of 1 for a correct prediction. The second term indicates whether the extracted metapath corresponds to the body of a rule and adds to the reward accordingly. The hyperparameter b can either be 1, i. e., the reward is always increased as long as the metapath corresponds to the body of a rule, or b can be set to 1{eL+1 =ed } , i. e., an additional reward is only applied if the prediction is
Neural Multi-hop Reasoning with Logical Rules
383
also correct. Heuristically speaking, we want to reward the agent for extracting a metapath that corresponds to a rule body with a high score. The hyperparameter λ ≥ 0 balances the two components of the reward. For λ = 0, we recover the algorithm MINERVA. We employ REINFORCE [35] to maximize the expected rewards. Thus, the agent’s maximization problem is given by arg max E(ec ,treats,ed )∼D EA1 ,A2 ,...,AL ∼πθ R(SL+1 ) ec , ed , (5) θ
where D denotes the true underlying distribution of (ec , treats, ed )-triples. During training, we replace the first expectation in Eq. (5) with the empirical average over the training set. The second expectation is approximated by averaging over multiple rollouts for each training sample.
4 4.1
Experiments Dataset Hetionet
Hetionet [13] is a biomedical KG that integrates information from 29 highly reputable and cited public databases, including the Unified Medical Language System (UMLS) [3], Gene Ontology [1], and DrugBank [36]. It consists of 47,031 entities with 11 different types and 2,250,197 edges with 24 different types. Figure 1b illustrates the schema and shows the different types of entities and possible relations between them. Hetionet differs in many aspects from the standard benchmark datasets that are typically used in the KG reasoning literature. Table 1 summarizes the basic statistics of Hetionet along with the popular benchmark datasets FB15k-237 [31] and WN18RR [7]. One of the major differences between Hetionet and the two other benchmark datasets is the density of triples, i. e., the average node degree in Hetionet is significantly higher than in the other two KGs. Entities of type Anatomy are densely connected hub nodes, and in addition, entities of type Gene have an average degree of around 123. This plays a crucial role for our application since many relevant paths that connect Compound and Disease traverse entities of type Gene (see Fig. 1b and Table 2). The total counts and the average node degrees according to each entity type are shown in Appendix A. We will discuss in Sect. 4.5 further how particularities of Hetionet impose challenges on existing KG reasoning methods. We aim to predict edges with type treats between entities that correspond to compounds and diseases in order to perform candidate ranking according to the likelihood of successful drug repurposing in a novel treatment application. There are 1552 compounds and 137 diseases in Hetionet with 775 observed links of type treats between compounds and diseases. We randomly split these 755 triples into training, validation, and test set, where the training set contains 483 triples, the validation set 121 triples, and the test set 151 triples.
384
Y. Liu et al.
4.2
Metapaths as Background Information
Himmelstein et al. [13] evaluated 1206 metapaths that connect entities of type Compound with entities of type Disease, which correspond to various pharmacological efficacy mechanisms. They identified 27 effective metapaths that served as features for a logistic regression model that outputs a treatment probability of a compound for a disease. Out of these metapaths, we select the 10 metapaths as background information that have at most path length 3 and exhibit positive regression coefficients, which indicates their importance for predicting drug efficacy. We use the metapaths as the rule bodies and the confidence of the rules as the quality scores (see Sect. 3). The confidence of a rule is defined as the rule support divided by the body support in the data. We estimate the confidence score for each rule by sampling 5,000 paths whose metapaths correspond to the rule body and then computing how often the rule head holds. An overview of the 10 metapaths and their scores is given in Table 2. Table 1. Comparison of Hetionet with the two benchmark datasets FB15k-237 and WN18RR. Dataset
Entities Relations Triples
Hetionet
47,031
24
2,250,197 95.8
FB15k-237 14,541
237
310,116 19.7
WN18RR
40,943
11
Avg. degree
93,003
2.2
Table 2. All 10 metapaths used in our model and their corresponding scores. s(M ) Metapath M includes−1
includes
0.446 (Compound − −−−−−− → Pharmacologic Class −−−−−→ treats Compound −−−→ Disease) resembles
resembles
treats
0.265 (Compound − −−−−− → Compound − −−−−− → Compound −−−→ Disease) binds
associates−1
0.184 (Compound −−−→ Gene −−−−−−−−→ Disease) resembles
treats
0.182 (Compound − −−−−− → Compound −−−→ Disease) palliates
palliates−1
treats
0.169 (Compound −−−−−→ Disease −−−−−−−→ Compound −−−→ Disease) binds
binds−1
treats
0.143 (Compound −−−→ Gene −−−−−→ Compound −−−→ Disease) causes
causes−1
treats
0.058 (Compound −−−−→ Side Effect −−−−−→ Compound −−−→ Disease) treats
resembles
0.040 (Compound −−−→ Disease − −−−−− → Disease) resembles
binds
associates−1
0.017 (Compound − −−−−− → Compound −−−→ Gene −−−−−−−−→ Disease) binds
expresses−1
localizes−1
0.004 (Compound −−−→ Gene −−−−−−−→ Anatomy − −−−−−− → Disease)
Neural Multi-hop Reasoning with Logical Rules
4.3
385
Experimental Setup
We apply our method PoLo to Hetionet and calculate the values for hits@1, hits@3, hits@10, and the mean reciprocal rank (MRR) for the link prediction task. All metrics in the paper are filtered [4] and evaluated for tail-sided predictions. During inference, a beam search is carried out to find the most promising paths, and the target entities are ranked by the probability of their corresponding paths. Moreover, we consider another evaluation scheme (PoLo (pruned)) that retrieves and ranks only those paths from the test rollouts that correspond to one of the metapaths in Table 2. All the other extracted paths are not considered in the ranking. We compare PoLo with the following baseline methods. The rule-based method AnyBURL [19,20] mines logical rules based on path sampling and uses them for inference. The methods TransE [4], DistMult [38], ComplEx [32], ConvE [6], and RESCAL [26] are popular embedding-based models, and we use the implementation from the LibKGE library2 . To cover a more recent paradigm in graph-based machine learning, we include the graph convolutional approaches R-GCN [30] and CompGCN [34]. We also compare our method with the neurosymbolic method pLogicNet [27]. The two neuro-symbolic approaches NTP [29] and Neural LP [39] yield good performance on smaller datasets but are not scalable to large datasets like Hetionet. We have also conducted experiments on the two more scalable extensions of NTP (GNTP [22] and CTP [23]), but both were not able to produce results in a reasonable time. More experimental details can be found in Appendix B. 4.4
Results
Table 3 displays the results for the experiments on Hetionet. The reported values for PoLo and MINERVA correspond to the mean across five independent training runs. The standard errors for the reported metrics are between 0.006 and 0.018. PoLo outperforms all baseline methods with respect to all evaluation metrics. Applying the modified ranking scheme, our method yields performance gains of 27.7% for hits@1, 14.9% for hits@3, 8.1% for hits@10, and 16.2% for the MRR with respect to best performing baseline. Figure 3a shows the rule accuracy, i. e., the percentage of correct target entities for extracted paths that follow rule metapaths, for PoLo and MINERVA during training. Both lines behave similarly in the beginning, but the rule accuracy of PoLo increases significantly around epoch 20 compared to MINERVA. It seems that giving the agent an extra reward for extracting rules also improves the probability of arriving at correct target entities when applying the rules. We also compare the metric hits@1 (pruned) for the evaluation of the validation set during training (see Fig. 3b). Around epoch 20, where the rule accuracy of PoLo increases compared to MINERVA, hits@1 (pruned) also increases while it decreases for MINERVA. The additional reward for extracting rule paths could 2
https://github.com/uma-pi1/kge.
386
Y. Liu et al. Table 3. Comparison with baseline methods on Hetionet. Method
Hits@1 Hits@3 Hits@10 MRR
AnyBURL TransE DistMult ComplEx ConvE RESCAL R-GCN CompGCN pLogicNet MINERVA
0.229 0.099 0.185 0.152 0.100 0.106 0.026 0.172 0.225 0.264
PoLo 0.314 PoLo (pruned) 0.337
0.375 0.199 0.305 0.285 0.225 0.166 0.245 0.318 0.364 0.409
0.553 0.444 0.510 0.470 0.318 0.377 0.272 0.543 0.523 0.593
0.322 0.205 0.287 0.250 0.180 0.187 0.135 0.292 0.333 0.370
0.428 0.470
0.609 0.641
0.402 0.430
Fig. 3. (a) Rule accuracy during training. (b) Hits@1 (pruned) for the evaluation of the validation set during training.
be seen as a regularization that alleviates overfitting and allows for longer training for improved results. The metapath that was most frequently extracted by PoLo during testing is causes
causes−1
treats
(Compound −−−−→ Side Effect −−−−−→ Compound −−−→ Disease) .
This rule was followed in 37.3% of the paths during testing, of which 16.9% ended at the correct entity. During testing, PoLo extracted metapaths that correspond to rules in 41.7% of all rollouts while MINERVA only extracted rule paths in 36.9% of the cases. The accuracy of the rules, i. e., the percentage of correct target entities when rule paths are followed, is 19.0% for PoLo and 17.6% for MINERVA.
Neural Multi-hop Reasoning with Logical Rules
4.5
387
Discussion
We have integrated logical rules as background information via a new reward mechanism into the multi-hop reasoning method MINERVA. The stochastic policy incorporates the set of rules that are presented to the agent during training. Our approach is not limited to MINERVA but can act as a generic mechanism to inject domain knowledge into reinforcement learning-based reasoning methods on KGs [18,37]. While we employ rules that are extracted in a data-driven fashion, our method is agnostic towards the source of background information. The additional reward for extracting a rule path can be considered as a regularization that induces the agent to walk along metapaths that generalize to unseen instances. In particular, for PoLo (pruned), we consider only extracted paths that correspond to the logical rules. However, the resulting ranking of the answer candidates is not based on global quality measures of the rules (e. g., the confidence). Rather, the ranking is given by the policy of the agent (i. e., metapaths that are more likely to be extracted are ranked higher), which creates an adaptive reweighting of the extracted rules that takes the individual instance paths into account. Multi-hop reasoning methods contain a natural transparency mechanism by providing explicit inference paths. These paths allow domain experts to evaluate and monitor the predictions. Typically, there is an inherent trade-off between explainability and performance, but surprisingly, our experimental findings show that path-based reasoning methods outperform existing black-box methods on the drug repurposing task. Concretely, we compared our approach with the embedding-based methods TransE, DistMult, ComplEx, ConvE, and RESCAL. These methods are trained to minimize the reconstruction error in the immediate first-order neighborhood while discarding higher-order proximities. However, most explanatory metapaths in the drug repurposing setting have length 2 or more [13]. While MINERVA and PoLo can explicitly reason over multiple hops, our results indicate that embedding-based methods that fit low-order proximities seem not to be suitable for the drug repurposing task, and it is plausible that other reasoning tasks on biomedical KGs could result in similar outcomes. R-CGN and CompGCN learn node embeddings by aggregating incoming messages from neighboring nodes and combining this information with the node’s own embedding. These methods are in principle capable of modeling long-term dependencies. Since the receptive field contains the entire set of nodes in the multi-hop neighborhood, the aggregation and combination step essentially acts as a low-pass filter on the incoming signals. This can be problematic in the presence of many high-degree nodes like in Hetionet where the center node receives an uninformative signal that smooths over the neighborhood embeddings. The approaches pLogicNet and AnyBURL both involve the learning of rules and yield similar performance on Hetionet, which is worse than PoLo. Most likely, the large amount of high-degree nodes in Hetionet makes the learning and application of logical rules more difficult. Other neuro-symbolic methods such as NTP, its extensions, and Neural LP were not scalable to Hetionet.
388
Y. Liu et al.
To illustrate the applicability of our method, consider the example of the chemical compound sorafenib (see Fig. 2), which is known for treating liver cancer, kidney cancer, and thyroid cancer. The top predictions of our model for new target diseases include pancreatic cancer, breast cancer, and hematologic cancer. This result seems to be sensible since sorafenib already treats three other cancer types. The database ClinicalTrials.gov [33] lists 16 clinical studies for testing the effect of sorafenib on pancreatic cancer, 33 studies on breast cancer, and 6 studies on hematologic cancer, showing that the predicted diseases are meaningful targets for further investigation. Another example of drug repurposing on Hetionet is provided in Appendix C. 4.6
Experiments on Other Datasets
We also conduct experiments on the benchmark datasets FB15k-237 and WN18RR and compare PoLo with the other baseline methods. Since we do not already have logical rules available, we use the rules learned by AnyBURL. We can only apply cyclic rules for PoLo, so we also compare to the setting where we only learn and apply cyclic rules with AnyBURL. Our method mostly outperforms MINERVA and Neural LP on both datasets. For FB15k-237, PoLo has worse performance than AnyBURL and most embedding-based methods, probably because the number of unique metapaths that occur a large number of times in the graph is lower compared to other datasets [5]. This makes it difficult for PoLo to extract metapaths sufficiently often for good generalization. pLogicNet yields better performance on FB15k237 than PoLo but worse performance on WN18RR. The results of AnyBURL on FB15k-237 and WN18RR when only using cyclic rules are worse than when also including acyclic rules. It seems that acyclic rules are important for predictions as well, but PoLo cannot make use of these rules. The detailed results for both datasets can be found in Appendix D.
5
Conclusion
Biomedical knowledge graphs present challenges for learning algorithms that are not reflected in the common benchmark datasets. Our experimental findings suggest that existing knowledge graph reasoning methods face difficulties on Hetionet, a biomedical knowledge graph that exhibits both long-range dependencies and a multitude of high-degree nodes. We have proposed the neuro-symbolic approach PoLo that leverages both representation learning and logic. Concretely, we integrate logical rules into a multi-hop reasoning method based on reinforcement learning via a novel reward mechanism. We apply our method to the highly relevant task of drug repurposing and compare our approach with embeddingbased, logic-based, and neuro-symbolic methods. The results indicate a better performance of PoLo compared to popular state-of-the-art methods. Further, PoLo also provides interpretability by extracting reasoning paths that serve as explanations for the predictions.
Neural Multi-hop Reasoning with Logical Rules
389
Acknowledgements.. This work has been supported by the German Federal Ministry for Economic Affairs and Energy (BMWi) as part of the project RAKI (01MD19012C).
References 1. Ashburner, M., et al.: Gene Ontology: tool for the unification of biology. Nat. Genet. 25(1), 25–29 (2000) 2. Belleau, F., Nolin, M.A., Tourigny, N., Rigault, P., Morissette, J.: Bio2RDF: towards a mashup to build bioinformatics knowledge systems. J. Biomed. Inform. 41(5), 706–716 (2008) 3. Bodenreider, O.: The unified medical language system (UMLS): integrating biomedical terminology. Nucleic Acids Res. 32(Database), D267–D270 (2004) 4. Bordes, A., Usunier, N., Garcia-Duran, A., Weston, J., Yakhnenko, O.: Translating embeddings for modeling multi-relational data. In: The 27th Conference on Neural Information Processing Systems (2013) 5. Das, R., et al.: Go for a walk and arrive at the answer: reasoning over paths in knowledge bases using reinforcement learning. In: The 6th International Conference on Learning Representations (2018) 6. Defferrard, M., Bresson, X., Vandergheynst, P.: Convolutional neural networks on graphs with fast localized spectral filtering. In: The 13th Conference on Neural Information Processing Systems (2016) 7. Dettmers, T., Minervini, P., Stenetorp, P., Riedel, S.: Convolutional 2D knowledge graph embeddings. In: The 32nd AAAI Conference on Artificial Intelligence (2018) 8. Donadello, I., Serafini, L., Garcez, A.: Logic tensor networks for semantic image interpretation. In: The 26th International Joint Conference on Artificial Intelligence (2017) 9. D¨ orpinghaus, J., Jacobs, M.: Semantic knowledge graph embeddings for biomedical research: data integration using linked open data. In: SEMANTiCS (2019) 10. Gal´ arraga, L., Teflioudi, C., Hose, K., Suchanek, F.M.: Fast rule mining in ontological knowledge bases with AMIE+. VLDB J. 24, 707–730 (2015) 11. Guo, L., Sun, Z., Hu, W.: Learning to exploit long-term relational dependencies in knowledge graphs. In: The 36th International Conference on Machine Learning (2019) 12. Hildebrandt, M., Serna, J.A.Q., Ma, Y., Ringsquandl, M., Joblin, M., Tresp, V.: Reasoning on knowledge graphs with debate dynamics. In: The 34th AAAI Conference on Artificial Intelligence (2020) 13. Himmelstein, D.S., et al.: Systematic integration of biomedical knowledge prioritizes drugs for repurposing. Elife 6, e26726 (2017) 14. Hitzler, P., Kr¨ otzsch, M., Rudolph, S.: Foundations of Semantic Web Technologies. Chapman & Hall/CRC Textbooks in Computing (2009) 15. Hochreiter, S., Schmidhuber, J.: Long short-term memory. Neural Comput. 9(8), 1735–1780 (1997) 16. Kipf, T.N., Welling, M.: Semi-supervised classification with graph convolutional networks. In: The 5th International Conference on Learning Representations (2017) 17. Lao, N., Cohen, W.W.: Relational retrieval using a combination of pathconstrained random walks. Mach. Learn. 81(1), 53–67 (2010) 18. Lin, X.V., Socher, R., Xiong, C.: Multi-hop knowledge graph reasoning with reward shaping. In: The 2018 Conference on Empirical Methods in Natural Language Processing (2018)
390
Y. Liu et al.
19. Meilicke, C., Chekol, M.W., Fink, M., Stuckenschmidt, H.: Reinforced anytime bottom up rule learning for knowledge graph completion. Preprint arXiv:2004.04412 (2020) 20. Meilicke, C., Chekol, M.W., Ruffinelli, D., Stuckenschmidt, H.: Anytime bottomup rule learning for knowledge graph completion. In: The 28th International Joint Conference on Artificial Intelligence (2019) 21. Meilicke, C., Fink, M., Wang, Y., Ruffinelli, D., Gemulla, R., Stuckenschmidt, H.: Fine-grained evaluation of rule-and embedding-based systems for knowledge graph completion. In: The 17th International Semantic Web Conference (2018) 22. Minervini, P., Boˇsnjak, M., Rockt¨ aschel, T., Riedel, S., Grefenstette, E.: Differentiable reasoning on large knowledge bases and natural language. In: The 34th AAAI Conference on Artificial Intelligence (2020) 23. Minervini, P., Riedel, S., Stenetorp, P., Grefenstette, E., Rockt¨ aschel, T.: Learning reasoning strategies in end-to-end differentiable proving. In: The 37th International Conference on Machine Learning (2020) 24. Mitchell, T.: Machine Learning. McGraw-Hill Series in Computer Science (1997) 25. Muggleton, S.: Inductive logic programming. N. Gener. Comput. 8(4), 295–318 (1991) 26. Nickel, M., Tresp, V., Kriegel, H.P.: A three-way model for collective learning on multi-relational data. In: The 28th International Conference on Machine Learning (2011) 27. Qu, M., Tang, J.: Probabilistic logic neural networks for reasoning. In: The 33rd Conference on Neural Information Processing Systems (2019) 28. Richardson, M., Domingos, P.: Markov logic networks. Mach. Learn. 62(1–2), 107– 136 (2006) 29. Rockt¨ aschel, T., Riedel, S.: End-to-end differentiable proving. In: The 31st Conference on Neural Information Processing Systems (2017) 30. Schlichtkrull, M., Kipf, T.N., Bloem, P., Van Den Berg, R., Titov, I., Welling, M.: Modeling relational data with graph convolutional networks. In: The 15th Extended Semantic Web Conference (2018) 31. Toutanova, K., Chen, D., Pantel, P., Poon, H., Choudhury, P., Gamon, M.: Representing text for joint embedding of text and knowledge bases. In: The 2015 Conference on Empirical Methods in Natural Language Processing (2015) 32. Trouillon, T., Welbl, J., Riedel, S., Gaussier, E., Bouchard, G.: Complex embeddings for simple link prediction. In: The 33rd International Conference on Machine Learning (2016) 33. U. S. National Library of Medicine (2000). clinicaltrials.gov 34. Vashishth, S., Sanyal, S., Nitin, V., Talukdar, P.: Composition-based multirelational graph convolutional networks. In: The 9th International Conference on Learning Representations (2020) 35. Williams, R.J.: Simple statistical gradient-following algorithms for connectionist reinforcement learning. Mach. Learn. 8(3–4), 229–256 (1992) 36. Wishart, D.S., et al.: DrugBank: a comprehensive resource for in silico drug discovery and exploration. Nucleic Acids Res. 34(Database), D668–D672 (2006) 37. Xiong, W., Hoang, T., Wang, W.Y.: DeepPath: a reinforcement learning method for knowledge graph reasoning. In: The 2017 Conference on Empirical Methods in Natural Language Processing (2017) 38. Yang, B., Yih, W., He, X., Gao, J., Deng, L.: Embedding entities and relations for learning and inference in knowledge bases. In: The 3rd International Conference on Learning Representations (2015)
Neural Multi-hop Reasoning with Logical Rules
391
39. Yang, F., Yang, Z., Cohen, W.W.: Differentiable learning of logical rules for knowledge base reasoning. In: The 31st Conference on Neural Information Processing Systems (2017) 40. Zitnik, M., Nguyen, F., Wang, B., Leskovec, J., Goldenberg, A., Hoffman, M.M.: Machine learning for integrating data in biology and medicine: principles, practice, and opportunities. Inf. Fusion 50, 71–91 (2019)
Augmenting Ontology Alignment by Semantic Embedding and Distant Supervision Jiaoyan Chen1(B) , Ernesto Jim´enez-Ruiz2,3 , Ian Horrocks1 , Denvar Antonyrajah4 , Ali Hadian4 , and Jaehun Lee5 1
Department of Computer Science, University of Oxford, Oxford, UK [email protected] 2 University of London, London, UK 3 SIRIUS, University of Oslo, Oslo, Norway 4 Samsung Research, Staines-upon-Thames, UK 5 Samsung Research, Seoul, Korea
Abstract. Ontology alignment plays a critical role in knowledge integration and has been widely investigated in the past decades. State of the art systems, however, still have considerable room for performance improvement especially in dealing with new (industrial) alignment tasks. In this paper we present a machine learning based extension to traditional ontology alignment systems, using distant supervision for training, ontology embedding and Siamese Neural Networks for incorporating richer semantics. We have used the extension together with traditional systems such as LogMap and AML to align two food ontologies, HeLiS and FoodOn, and we found that the extension recalls many additional valid mappings and also avoids some false positive mappings. This is also verified by an evaluation on alignment tasks from the OAEI conference track. Keywords: Ontology alignment · Semantic embedding supervision · Siamese neural network
1
· Distant
Introduction
Ontologies are widely used to represent, manage and exchange (domain) knowledge. However, the content of any single ontology is often incomplete even in a single domain and, moreover, many real world applications rely on cross-domain knowledge. Integration of multiple ontologies is therefore a critical task, and is often implemented by identifying cross-ontology mappings between classes that have an equivalent- or sub-class relationship. This process is known as ontology alignment or ontology matching [8,26,29].1 1
Ontology alignment also includes mappings between individuals and properties, as well as mappings with more complicated relationships beyond atomic subsumption and equivalence. In this study we focus on mappings between equivalent classes.
c Springer Nature Switzerland AG 2021 R. Verborgh et al. (Eds.): ESWC 2021, LNCS 12731, pp. 392–408, 2021. https://doi.org/10.1007/978-3-030-77385-4_23
Augmenting Ontology Alignment
393
Ontology alignment has been investigated for many years. State of the art (SOTA) systems such as LogMap [17,18] and AgreementMakerLight (AML) [9] often combine multiple strategies such as lexical matching, structural matching and logical reasoning. Such systems typically use lexical matching as their starting point, and while this captures string or token similarity, it fails to capture the contextual meaning of words. Logical reasoning can be used to improve mapping quality, but this often wrongly rejects some valid mappings [27]. In practice, such systems often need (combinations of) hand-craft matching methods to achieve good performance for a new task. The last decade has seen an extensive investigation of semantic embedding, a branch of machine learning (ML) techniques which can encode symbols such as natural language words, ontology concepts, knowledge graph entities and relations into vectors with their semantics (e.g., correlation with the neighbours) [20,23,31]. This enables us to augment the aforementioned ontology alignment systems with ML algorithms that can exploit richer semantics so as to recall some missed mappings and avoid some false positives. In this paper we present a ML extension that utilizes distant supervision and semantic embedding, and that can be used to augment classic ontology alignment systems. Briefly, it first uses the original ontology alignment system plus class disjointness constraints (as heuristic rules) to generate high precision seed mappings, and then uses these mappings to train a Siamese Neural Network (SiamNN) for predicting cross-ontology class mappings via semantic embeddings in OWL2Vec∗ —an ontology tailored language model [3]. We have tested our ML-augmentation with the SOTA systems LogMap and AML in a real world ontology alignment task identified by our industrial partner Samsung Research UK, i.e., the alignment of two food ontologies: HeLiS [7] and FoodOn [6]. The augmentation improved recall by more that 130% while at the same time achieving small improvements in precision. Smaller but still significant improvements in precision and recall were also achieved on an alignment task from the Ontology Alignment Evaluation Initiative (OAEI) [1]. In the remainder of this paper we use LogMap as a concrete example of our ML extension, but the extension can be directly applied to AML and to any other system that is capable of generating high precision mappings to be used in the training phase.
2 2.1
Preliminaries and Related Work LogMap
LogMap is a scalable logic-based ontology matching system [17,18]. It is often one of the best performing systems for real-world tasks such as those in the biomedical tracks of the OAEI [1]. Figure 1 shows the procedure followed by LogMap to compute an alignment M given two input ontologies O1 and O2 . LogMap first builds a lexical index for each ontology based on its entity labels and label variations (e.g., synonyms). These indexes are used to efficiently computing an over-estimation Mo of the
394
J. Chen et al.
mappings between O1 and O2 . Mappings in Mo are not necessarily correct, but they link lexically-related entities and usually have a high recall, while still representing a manageable subset of all possible mappings (i.e., the Cartesian product of the sets of classes in the input ontologies) [16]. From the mapping over-estimation Mo , LogMap identifies a number of highconfidence mappings called anchor mappings (Ma ). These mappings are used to assess the structural and logical compatibility of the remaining candidate mappings in Mo via a structural index, which significantly reduces the cost of answering taxonomic and disjointness queries. Mappings in Mo are also assessed according to the lexical similarity of the involved entities. Finally, LogMap outputs a set of selected mappings M between O1 and O2 , and additionally gives as output the anchor mappings Ma and the mapping over-estimation Mo .
Fig. 1. LogMap system in a nutshell [18]
2.2
Machine Learning for Ontology Alignment
Machine learning (ML) has recently been explored for ontology alignment. ML should facilitate the exploitation of both class information (e.g., names and annotations) and their context in an ontology (i.e., their semantics). However, to develop a robust model, several critical issues have to be addressed. Next we will discuss these issues and current solutions, and compare our method with them. Features. The symbolic information of a class, such as its textual label and neighbourhood graph structure, should be transformed into real values before they can be utilized by ML algorithms, and informative variables (i.e., features) should be extracted to achieve high performance. One solution, as implemented in, e.g., GLUE [5] and POMap++ [21], is extracting pre-defined features such as edit distance between labels and syntactic similarity. Another solution, as adopted by, e.g., Zhang et al. [33], DOME [13], OntoEmma [30], Bento et al. [2], DeepFCA [22] and VeeAlign [15], is learning relevant features via representation learning models such as neural networks, or/and using pre-trained semantic embeddings (i.e., vectors of characters, words or classes with their
Augmenting Ontology Alignment
395
semantics kept in the vector space). Some methods such as [25,30] adopt both pre-defined features and semantic embeddings. Meanwhile, instead of word embeddings pre-trained by an external corpus, tailored character embeddings or document embeddings have been explored. ERSOM [32] learns ontology tailored word embeddings via an Auto-Encoder and a similarity propagation method with the classes’ meta information and context, while DeepAlignment [19] extends ERSOM by incorporating the synonymy and antonymy word relationships. Samples. With semantic embeddings, we can identify mappings by calculating the vector distance (or similarity) between classes as in [19,32]. However, such an unsupervised approach depends on how the semantic embeddings are learned. For ontology-tailored embeddings, which usually achieve better performance than pre-trained embeddings, the vector spaces of the two to-be-aligned ontologies are independent and thus two equivalent cross-ontology classes may still have a large vector distance. To address the above issue and further improve the performance, we can utilize (semi-)supervised ML solutions which rely on labeled mappings (i.e., samples) to learn features and train models to predict mappings. Besides costly human annotation for the training samples, one ML solution is transfer learning between tasks, i.e., re-using known mappings from other aligned ontologies. For example, OntoEmma [30] trains the model using 50, 523 positive mappings between the ontologies of the Unified Medical Language System, while [25] transfers samples from tasks of one OAEI track to another. However, the effectiveness of such sample transfer significantly depends on the sources to be transferred, and it may be hard to find a suitable source for a new alignment task. In practice, neither [30] nor [25] outperformed the classic systems such as AML and LogMap on the evaluated OAEI tracks. Scalable Mapping Prediction. Unlike ontology alignment systems based on lexical indexes, an ML-based method usually needs to predict or calculate the scores of all cross-ontology class pairs, which can lead to scalability problems with large ontologies. One solution for this issue is to use blocking techniques such as locality-sensitive hashing [11] and embedding-based lexical index clustering [16]. Another solution, adopted by ERSOM [32] and DeepAlignment [19], is to use optimized search algorithms such as Stable Marriage. The prediction model can also be deployed together with a set of traditional alignment systems, the union of whose outputs can act as a reduced set of candidates with a good recall [25], or with some logic-based constraints or rules which can filter out some candidates and reduce the search space. In our ML extension, we addressed the feature issue via the combination of an ontology embedding method named OWL2Vec∗ [3], which is a neural language model tailored to the ontology’s text, graph structure and logical axioms; and a SiamNN, which learns features of the input classes and bridges the gap between the two embedding spaces. Unlike current (semi-)supervised learning methods, our ML extension addresses the sample shortage issue via a distant supervision strategy, where some confident mappings derived by the to-be-extended system (such as the anchor mappings of LogMap) are used to generate positive and negative samples, with some high-level class disjointness constraints used to improve
396
J. Chen et al.
sample quality. To reduce the search space when aligning large ontologies, we can optionally use the to-be-extended system (or some other traditional system) to compute a set of candidate mappings with very high recall (similar to [25]); in the case of LogMap we can use its so-called mapping over-estimation.
3
Use Case
Ontologies. In this section we present the use case of aligning HeLiS2 [7] and FoodOn3 [6]—two large OWL4 ontologies. FoodOn captures detailed food knowledge and other knowledge from relevant domains such as agriculture, chemistry and environment, with 359 instances, 28,182 classes and 241,581 axioms within the description logic (DL) SRIQ. HeLiS captures general knowledge on both food and healthy lifestyles with 20,318 instances, 277 classes and 172,213 axioms within the DL ALCHIQ(D). In order to facilitate alignment, HeLiS instances were transformed into classes, with associated rdf:type triples being transformed into rdfs:subClassOf triples. This transformation changes the ontology’s semantics, but the ontology integration still supports the knowledge graph construction application in industry and does not impact the evaluation of different systems. A fragment of HeLiS and FoodOn is shown in Fig. 2, where each class is represented by a short name/label for readability. Motivations. By providing more complete and fine-grained knowledge covering both food and lifestyles, an alignment of HeLiS and FoodOn can be used to improve personalisation and can benefit popular applications in areas such as sport, health and wellbeing. The alignment can also be used for ontology quality assurance (QA) by identifying missing and logically inconsistent relationships through cross checking. One QA example is discovering the missing subsumption relationship between “Soybean Milk” and “Soybean Food Product” in FoodOn (where “Soybean Milk” is only categorized as “Beverage”) by mapping them to their HeLiS counterparts “SoyMilk” and “SoyProducts” whose subsumption relationship is defined. We have identified more than 500 such new subsumption relationships between FoodOn classes through aligning FoodOn and HeLiS [14]. Challenges. The technical challenges of aligning HeLiS and FoodOn lie in several aspects. First, as in many ontology matching tasks, we need to address the ambiguity between classes with similar names or with similar neighbourhood structures, the logical inconsistency that can be caused by mappings, the very large search space (with over 580 million candidate mappings), and so on. Second, FoodOn is itself composed of multiple source ontologies, including NCBITaxon and The Environment Ontology, and thus its class hierarchy includes branches covering not only food categorization but also food source categorization (closely related to biological taxonomy), chemical element categorization, etc. Similarly 2 3 4
HeLiS project: https://horus-ai.fbk.eu/helis/. FoodOn project: https://foodon.org/. Web Ontology Language: https://www.w3.org/TR/owl-features/.
Augmenting Ontology Alignment
397
Fig. 2. Fragments of the HeLiS and FoodOn ontologies. The dash arrow means some intermediate classes are hidden. The red (green resp.) arrow denotes false (true resp.) mappings. (Color figure online)
HeLiS has branches of nutrients, food and so on. Similar names and local contexts (e.g., of food products and food sources) can lead to “branch conflicting” mappings whose classes lie in branches with different meanings. One example is the incorrect mapping between “Caesar’s Mushrooms” of HeLiS (a food) and “Caesar’s Mushroom” of FoodOn (a food source) as illustrated in Fig. 2. Classic systems often fail to identify such errors, even when using logical assessment (as in LogMap) due to missing class disjointness axioms in the source ontologies.
4
Methodology
We will present our ML extension w.r.t. LogMap, as shown in Fig. 3. It comprises three steps: (i) compute the seed mappings starting from a set of high precision mappings (such as LogMap’s “anchor” mappings) and applying class disjointness constraints (branch conflicts) to further improve precision; (ii) construct samples and train a mapping prediction model (a SiamNN whose input is a pair of classes or their associated paths); and (iii) compute the output mappings, (optionally) starting from a set of high recall candidate mappings (such as LogMap’s overestimation mappings) to reduce the search space. Note this extension can be used with any “traditional” system that is capable of generating high precision mappings for use in the training phase (in our evaluation we use AML as well as LogMap). 4.1
Seed Mappings
To achieve high-confidence seed mappings (Ms ) for training, we define a set of disjointness constraints between cross ontology classes to filter out some falsepositive mappings from the LogMap anchor mappings (Ma ). A disjointness constraint is denoted δ = (c1 , c2 ), where c1 and c2 are typically very general classes in O1 and O2 respectively, acting as the “root” classes of different knowledge branches. For example, in Fig. 2, “Food” of HeLiS and “Food Source” of
398
J. Chen et al.
Fig. 3. The ML extension for LogMap
FoodOn comprise one disjointness constraint, while “Food” of HeLiS and “Chemical Entity” of FoodOn comprise another constraint. The set of constraints, which we denote Δ, together with the original alignment system act as heuristic rules in normal distant supervision. In our HeLiS-FoodOn case study, we manually defined four disjointness constraints based on knowledge of the domain and the ontology architectures. Given that disjointness constraints typically involve only very general classes, defining them does not require very detailed knowledge of the domain; moreover, we can use statistical analysis of the mappings computed by LogMap to identify candidate disjointness constraints, or even to fully automate the definition of Δ. For example, given two sibling classes c and c in O1 and a class s in O1 , if there are n mappings from subclasses of c to subclasses of s and n mappings from subclasses of c to subclasses of s, with n n, then c is likely to be disjoint with s and (c , s) can be used as a (candidate) disjointness constraint. When using Δ to filter a mapping m = (c1 , c2 ) ∈ Ma , we consider not just c1 and c2 , but all subsumers of c1 and c2 in the corresponding ontologies O1 and O2 . For this purpose we use the OWL reasoner HermiT [12] to compute the set of subsumers (both explicitly asserted and entailed) of a given class c, which we denote Pc . Then, given a mapping m = (c1 , c2 ) ∈ Ma , we discard m as a false-positive if there is some (c1 , c2 ) ∈ Δ such that c1 ∈ Pc1 and c2 ∈ Pc2 ; if this is not the case, then we add m to the set of seed mappings Ms . 4.2
Siamese Neural Network
We first generate positive and negative class mappings (samples), then embed these samples as vectors using OWL2Vec∗ , and finally we train a SiamNN as the mapping prediction model. The seed mappings Ms are adopted as the positive samples and are randomly divided into a training set Mts and a validation set Mvs by a given ratio γ. We then generate the corresponding negative sample
Augmenting Ontology Alignment
399
sets of Mts and Mvs , denoted as Mts and Mvs respectively, as follows. For each mapping m = (c1 , c2 ) in Mts or Mvs , we generate one negative sample m by replacing c1 with a class c1 randomly selected from O1 , and we generate a second negative sample m by replacing c2 with a class c2 randomly selected from O2 . Note that the random replacements could produce positive samples from Ms ; we discard any such negative samples. We also adopt those anchor mappings that violate the class disjointness constraints, i.e., Ma \Ms , as negative samples, and randomly partition them into a training set Mta and a validation set Mva with the same ratio of γ. We finally get the training samples as a tuple of Mts and Mts ∪ Mta to train the SiamNN, and the validation samples as a tuple of Mvs v and Ms ∪ Mva to adjust the hyper parameters such as the network architecture and the embedding option. The OWL2Vec∗ embedding of an ontology is a language model tailored to the given ontology. It can be first pre-trained with a large normal text corpus such as Word2Vec and then fine-tuned with a corpus whose sequences include walks over the ontology’s graph structure, the ontology’s axioms, the ontology’s textual information (e.g., class labels, definitions and comments), etc. It can also be directly trained with the ontology’s corpus. In this study, we evaluated both training settings. The OWL2Vec∗ embedding encodes a class in two ways: directly adopting the vector of the class’s URI or calculating the average word vector of the words of the class labels. We prefer the latter as it can utilize both pre-training and fine-tuning, and often performs better for ontologies with rich textual information such as FoodOn. Please refer to [3] for more details on OWL2Vec∗ . Given a class c, we denote its OWL2Vec∗ embedding as v(c). For each mapping sample m = (c1 , c2 ) ∈ Mts , we consider two kinds of embeddings to transform it into a tuple composed of two vectors. The first option is directly adopting its OWL2Vec∗ embeddings v(c1 ) and v(c2 ), i.e., v(m) = {v(c1 ), v(c2 )}. The second option is to augment the context of c1 and c2 by embedding the associated paths of c1 and c2 , i.e., the sequences of classes obtained by traversing the class hierarchy back to owl:Thing. As one class may have multiple such paths, we randomly select at most two paths for each class, and thus one class mapping sample leads to at most four path mapping samples. For two paths associated with c1 and c2 , denoted as p1 = (c1 , ..., cn1 ) ∈ P1 and p2 = (c2 , ...,cn2 ) ∈ P2 respectively, the mapping c 1 cn 2 1 embedding v(m) is calculated as either n11 cni =c v(c ), v(c ) or i j cj =c2 n2 1 {[v(c1 ), ..., v(cn1 )] , [v(c2 ), ..., v(cn2 )]}, where [·, ·] denotes the vector concatenation. The former embeds a path by averaging the embeddings of its classes, while the latter embeds a path by concatenating the embeddings of its classes. In a given ontology, different paths can have different lengths. To align the vectors of different samples, we fix the path length for the ontology by setting it to the length of the longest path, and pad the shorter paths with placeholders whose embeddings are zero vectors. Note the path lengths of O1 and O2 can be different. The SiamNN is composed of two networks that have the same architecture. The two vectors of an input mapping are fed into the two networks respectively,
400
J. Chen et al.
two features (denoted as f1 and f2 ) are then calculated accordingly, and their 1 −f2 is further calculated as the output, where · normalized distance d = ff1 +f 2 denotes the Euclidean norm of a vector. A smaller distance indicates that the two classes corresponding to the two input vectors are more likely to constitute a valid mapping, and vice versa. The two networks are learned together by minimizing the following contrastive loss using the Adam optimizer: Loss =
N yi × di + (1 − yi ) × max { − di , 0} i=0
2
(1)
where i denotes the ith mapping sample, di denotes its output distance, yi denotes its label (yi = 1 if the mapping is positive, yi = 0 otherwise), N denotes the sample number and denotes a margin value. Note the insight behind the SiamNN is to map the two input vectors into the same space via two networks (non-linear transformations) which at the same time learn features. Different network architectures can be adopted for feature learning. We evaluated one simple network (Multi-layer Perception (MLP) with two hidden layers), one classic sequence learning model (Bidirectional Recurrent Neural Networks (BiRNN) with Gate Recurrent Units [4]), and the BiRNN with an additional attention layer (AttBiRNN). 4.3
Prediction, Filtering and Ensemble
We can simply consider all cross-ontology class pairs to be candidate mappings, but this leads to a very large number if the ontologies are large. In our extension to LogMap, we adopt its over-estimation class mappings Mo as the candidates. This reduces the potential number of candidates from around 580 million to 8, 891 when aligning HeLiS and FoodOn, and at the same time helps to avoid false positive mappings. Each mapping m = (c1 , c2 ) ∈ Mo is embeded into a tuple of vectors in the same way as in training the SiamNN except that only one path is randomly selected for each class if path embedding is adopted. A distance d ∈ [0, 1] is then predicted by the SiamNN, and a score y is further calculated as 1 − d. A higher score indicates a more likely mapping, and vice versa. A score threshold θ is used to filter out unlikely mappings: m is accepted if y ≥ θ, and rejected otherwise. To determine θ, we utilized the validation samples: the threshold is increased from 0 to 1 with a small step (e.g., 0.02), and the value leading to the best performance (e.g., the highest F1 score in aligning HeLiS and FoodOn) on Mvs and Mvs ∪ Mva is adopted. The resulting class mappings are denoted as Mp (predicted mappings). We filter out any predicted class mappings in Mp that violate class disjointness constraints Δ as when generating seed mappings (see Sect. 4.1). We further filter the mappings in Mp using a subsumption-based logical assessment. Specifically, a class in one ontology cannot be equivalent to multiple classes that are in a sub-class relationship in the other ontology. For example, “Canned Mushroom” of HeLiS cannot be equivalent to both “mushroom (canned)” and “mushroom
Augmenting Ontology Alignment
401
(home canned)” in FoodOn in Fig. 2. If this happens, then the mapping with a lower prediction score should be discarded. More formally, if Mp includes two mappings (c1 , c2 ) and (s1 , s2 ) such that either c1 = s1 and c2 subsumes s2 in O2 , or c2 = s2 and c1 subsumes s1 in O1 , then we discard the mapping with the lower prediction score. The remaining mappings are denoted as Mp . Mp is merged with the seed mappings Ms to give the final ensemble output: M = Mp ∪ Ms . Note that although the seed mappings are used as positive samples for training, it is still possible that some of them will have low prediction scores as embedding, learning and prediction is a probabilistic procedure.
5
Evaluation
5.1
HeLiS and FoodOn
Experiment Setting. We first evaluate the ML extension5 for aligning HeLiS and FoodOn, where we augment LogMap6 by using its anchor mappings for the seeds. The augmented system is denoted as LogMapanc -ML. It is compared with the original LogMap and another SOTA system AML v3.17 which has been highly ranked in many OAEI tasks [10]. In order to precisely assess an alignment of two ontologies we would need a set of gold standard (GS) mappings against which to measure precision and recall. This is typically not available due to the cost of checking each of a potentially very large number of possible mappings. In the case of HeLiS and FoodOn we have a partial GS consisting of 372 mappings obtained by manually checking a much larger set of candidate mappings computed by LogMap; however, this is still (highly) incomplete, and clearly biased towards mappings that can be found using the techniques employed in LogMap. Therefore, besides the recall of this partial GS (denoted as RecallGS ), we have computed approximate precision and recall (denoted as Precision≈ and Recall≈ , respectively) as follows. First, given a (possibly empty) set of GS mappings G and a set of computed mappings M , we estimate Precision≈ for G and M (denoted Precision≈ G,M ) by selecting at random a set S ⊆ M \ G and manually checking the mappings in S to identify the set Sv ⊆ S of valid mappings. We then compute: Precision≈ G,M =
v| |M ∩ G| + |S T PG,M |S| × |M \ G| = , |M | |M |
(2)
where |·| denotes set cardinality, and T PG,M represents the approximate number of true positive mappings. Note that, if G = ∅ (i.e., no gold standard is available), then this becomes simply |Sv |/|S|; if M \ G = ∅ (i.e., all the output mappings are among the GS), then this becomes precision w.r.t. the GS. For the recall, we estimate the total number of valid mappings using the GS as well as the union 5 6 7
Codes: https://github.com/KRR-Oxford/OntoAlign/tree/main/LogMap-ML. https://github.com/ernestojimenezruiz/loap-matcher. https://github.com/AgreementMakerLight/AML-Project.
402
J. Chen et al.
of the output mappings of all available systems (i.e., LogMapanc -ML, LogMap and AML), which we denote M ; then, for a given system that computes a set of mappings M , we estimate the recall of the system to be: Recall≈ =
T PG,M |G| +
|Sv | |S |
× |M \ G|
,
(3)
where S denotes a random set from M \ G and Sv ⊆ S are the valid mappings in S (by manual checking). We further calculate an approximate F1 Score: F1≈ =
2 × Precision≈ × Recall≈ . Precision≈ + Recall≈
(4)
The settings of LogMapanc -ML are adjusted by optimizing the result on the validation mapping set Mvs , which consists of 10% of all the seed mappings, and the results in Table 1 are based on these optimized settings. For the validation results of different settings, please see the ablation study in Sect. 5.3. Table 1. The results of aligning HeLiS and FoodOn Mappings # Precision≈ Recall≈ F1≈
Method
RecallGS
LogMap (anchor mappings)
311
0.887
0.278
0.423
0.602
LogMap
417
0.676
0.284
0.400
0.712
AML
544
0.636
0.349
0.451
0.694
LogMap -ML (no ensemble)
1154
0.675
0.785
0.726
0.806
LogMapanc -ML
1207
0.685
0.833
0.752 0.839
anc
Results. In Table 1 we can see that LogMapanc -ML without the ensemble to the seed mappings outputs 1154 mappings—more than twice as many as the original LogMap and AML—while the ensemble (i.e., including the seed mappings) adds 53 more mappings. LogMapanc -ML has much higher recall than AML and LogMap; for example, Recall≈ is increased from 0.284 to 0.833 when the ML extension is added to LogMap. This is consistent with our assumption that SiamNN together with the OWL2Vec∗ embedding can consider more additional contextual information and word semantics of two to-be-mapped classes. Meanwhile, LogMapanc -ML (no ensemble) has similar precision to LogMap and 6.1% higher precision than AML, while the ensemble with the seed mappings further improves precision from 0.675 to 0.685. As a result, F1≈ of LogMapanc -ML is 88.3% higher than LogMap and 67.0% higher than AML.
Augmenting Ontology Alignment
5.2
403
OAEI Conference Track
Experiment Setting. We also evaluated our ML extension on all the 21 class alignments of the 17 ontologies of the OAEI conference track,8 where the open reference ra1 with 259 class mappings (i.e., the GS) is adopted to calculate the standard precision, recall and F1 score. Note that we merge the output mappings of the 21 alignments of each system and compare all the mappings to the GS to directly calculate these metrics. The results are shown in Table 2. As the output mappings of AML and LogMap available on the OAEI website of 2020 are slightly different from those generated by our local running of LogMap and AML v3.1 (perhaps this is due to different parameter settings or versions), we report both results, where the former is denoted by the superscript ‘oaei’. Instead of processing each ontology alignment independently, we merged the seed mappings of all the 21 alignments to train one prediction model and applied this model to predict the candidate mappings of all the alignments. We did not use the LogMap over-estimation mappings but adopted all the cross-ontology class pairs of each alignment, as the total number (98, 688) did not cause scalability issues. As well as LogMapanc -ML, we also report the results of LogMap-ML and LogMapoaei -ML, which adopt the corresponding LogMap output mappings for the seeds. To show the generality, we also applied the ML extension to AML, which we denote AMLoaei -ML. Note that the output mappings of LogMap and AML are adopted for training because they have high precision in this case. The reported results of all the ML extensions are based on the class input embedded by the pre-trained OWL2Vec∗ and the SiamNN with MLP. The baselines include four classic systems (i.e., Wiktionary [28], SANOM [24], LogMap and AML), two SOTA ML-based systems (i.e., VeeAlign [15] and DeepAlignment [19]), and StringEquiv which labels a mapping as true if its class names are the same (case insensitive). Note precision and recall are based on the average of several repetitions of training and prediction, while F1 score is calculated with the averaged precision and recall. The DeepAlignment result is from its paper [19]. Results. From Table 2 we can first confirm the observation from HeLiS and FoodOn, i.e., that the ML extension can improve both the recall and precision of the original alignment system: the F1 score is improved by 9.9%, 4.3%, 3.4% and 2.4% for LogMapanc , LogMap, LogMapoaei and AMLoaei respectively. The improvements are not as large as in aligning HeLiS and FoodOn because the to-be-aligned conference ontologies are much smaller and less complex, and the original systems have already been highly optimized for these alignments. Second, our augmented method LogMapoaei -ML is a bit worse than VeeAlignoaei 9 and quite competitive to SANOMoaei , w.r.t. the F1 score. Note these two systems are ranked in the first positions in the 2020 and 2019 rankings, respectively. LogMapoaei -ML also has a slightly higher F1 score than DeepAlignment. Meanwhile, the F1 score of the augmented AML, i.e., AMLoaei -ML is very competitive 8 9
http://oaei.ontologymatching.org/2020/conference/. VeeAlign has been tailored to the Conference and Multifarm OAEI tracks [15].
404
J. Chen et al. Table 2. The results of the OAEI conference track. Method
Mappings # Precision Recall F1 score
StringEquiv
148
0.935
0.498
0.650
AML
223
0.803
0.691
0.743
SANOMoaei
252
0.778
0.757
0.767
184
0.821
0.583
0.682
253
0.791
0.772
0.781
0.710
0.800 0.750
Wiktionary
oaei
VeeAlignoaei
DeepAlignment – LogMapanc
139
0.892
0.479
0.629
LogMapanc -ML 157
0.917
0.555
0.691
LogMap
190
0.842
0.618
0.713
LogMap-ML
190
0.881
0.645
0.745
LogMapoaei
198
0.843
0.645
0.731
LogMapoaei -ML 197
0.875
0.665
0.756
AMLoaei
220
0.827
0.703
0.760
AMLoaei -ML
222
0.842
0.723
0.778
to VeeAlignoaei and is better than the other baselines (e.g., 1.4% higher than SANOMoaei ). As the ML extension is trained based on the confident seed mappings from the original systems, the augmented AML and LogMap have much higher precision than VeeAlignoaei , SANOMoaei and DeepAlignment. 5.3
Ablation Study
Experiment Setting. We present the ablation study of the prediction model with different embedding and neural network settings. To this end, standard precision, recall, F1 score and accuracy of the trained model on the validation mapping set are reported. The threshold θ is searched from 0 to 1 with a step of 0.02, and the reported results are based on the threshold that leads to the best F1 score. All the four metrics are calculated by averaging the results of several repetitions of training and validation. Note the model with the best F1 score and its associated optimum θ are adopted in calculating the final output mappings as evaluated in Sect. 5.1. As the validation set, especially its generated negative mappings, are quite simple in comparison with the candidate mappings for prediction, the validation results in Table 3 are much better than the final results in Table 1, but this does not impact our validation of different settings. We evaluated (i) Word2Vec which was trained with a corpus of Wikipedia articles from 2018, OWL2Vec∗ without pre-training and OWL2Vec∗ pre-trained with the above Wikipedia corpus; (ii) different networks including the SiamNNs, and the original networks (MLP, BiRNN and AttBiRNN) for which the two input vectors are concatenated; and (iii) the class vs the path as the input. The dimensions of Word2Vec, OWL2Vec∗ and the pre-trained OWL2Vec∗ are set to
Augmenting Ontology Alignment
405
200, 100 and 200 respectively. The hidden neural sizes of MLP and BiRNN are both set to 200, while the attention size of AttBiRNN is set to 50. The epoch number and the batch size are set to 14 and 8 in training. Table 3. The results over the validation mapping set of different embedding and network settings for aligning HeLiS and FoodOn. Class embedding is adopted as the input. Embedding (class)
Neural network
Precision Recall F1 score Accuracy
Word2Vec
MLP BiRNN AttBiRNN SiamNN (MLP) SiamNN (BiRNN) SiamNN (AttBiRNN)
0.809 0.741 0.790 0.874 0.808 0.828
0.798 0.940 0.941 0.941 0.952 0.952
0.803 0.827 0.859 0.903 0.874 0.884
0.869 0.869 0.897 0.932 0.909 0.917
OWL2Vec∗ (without MLP pre-training) BiRNN AttBiRNN SiamNN (MLP) SiamNN (BiRNN) SiamNN (AttBiRNN)
0.769
0.869
0.815
0.869
0.751 0.708 0.854 0.924 0.829
0.929 0.976 0.976 0.833 0.905
0.830 0.820 0.911 0.874 0.862
0.873 0.857 0.936 0.921 0.901
MLP
0.826
0.845
0.835
0.889
BiRNN AttBiRNN SiamNN (MLP) SiamNN (BiRNN) SiamNN (AttBiRNN)
0.821 0.828 0.952 0.914 0.854
0.905 0.860 0.905 0.881 0.893
0.859 0.842 0.927 0.897 0.871
0.901 0.893 0.952 0.933 0.913
OWL2Vec∗ (with pre-training)
Results. On the one hand we find OWL2Vec∗ with pre-training has better performance than the original Word2Vec and OWL2Vec∗ without pre-training; for example, the best F1 scores of these three settings are 0.927, 0.903 and 0.911 respectively. This observation, which is consistent under different settings, is as expected because the pre-trained OWL2Vec∗ incorporates words’ common sense semantics and local context in the ontology. On the other hand we can find the SiamNNs outperform their original networks, and the SiamNN with MLP achieves the best performance. The former validates that the SiamNN architecture, which can align two embedding spaces according to the given training mappings, is more suitable for this task. The latter means further feature learning by RNN over the embedding makes no additional contribution in comparison with MLP. We also validated the above networks using path embedding as input,
406
J. Chen et al.
and the results are worse than their correspondences using the class embedding as input; for example, the best validation F1 score is 0.885 which is worse than 0.927 in Table 3. This may be due to the fact that the relevant predictive information from the class subsumers has already been encoded by OWL2Vec∗ .
6
Conclusion and Discussion
In this paper we presented a general ML extension to existing ontology alignment systems such as LogMap and AML. Briefly, it first adopts the confident mappings from an original system, such as the anchor mappings of LogMap, as well as some external class disjointness constraints, to generate training samples, then uses an ontology tailored language model OWL2Vec∗ and a SiamNN to train a model and predict the candidate mappings, and finally filters out invalid mappings according to their predicted scores and a subsumption-based logical assessment. According to the evaluation on an industrial use case and the alignments of the OAEI conference track, the ML extension is shown to be effective in improving both precision and recall. We discuss below some more subjective observations and possible directions for future work. Running Time. Computation of the ML extension mainly lies in training and validation. With a laptop equipped by 2.3 GHz Intel Core i5 and 16 GB memory, the training of the 6 networks as set out in Sect. 5.3 with the class input using the pre-trained OWL2Vec∗ and the seeds from LogMap anchors takes 1.3 min for HeLiS and FoodOn, and 1.1 min for the OAEI conference track. It is possible to achieve even better matching performance via an exhaustive exploration of more settings, e.g., the network hidden layer size, but this requires significantly more computation. Seed Mappings. In distant supervision we assume that the seed mappings used for training are precise. In aligning HeLiS and FoodOn, we also considered extracting the seed mappings from the output mappings of LogMap and AML, both of which have a larger size but lower precision (0.676 and 0.636 respectively) compared to the LogMap anchors. However both lead to lower precision and recall, and the approximate F1 score drops to 0.657 and 0.696 respectively. Class disjointness constraints are also important for filtering out false-positive mappings and generating high precision seeds mappings; in the future work we plan to study semi-automatic neural-symbolic methods for deriving robust class disjointness constraints.
References 1. Algergawy, A., et al.: Results of the ontology alignment evaluation initiative 2019. In: OM@ ISWC, pp. 46–85 (2019). http://oaei.ontologymatching.org/ 2. Bento, A., Zouaq, A., Gagnon, M.: Ontology matching using convolutional neural networks. In: Proceedings of LREC, pp. 5648–5653 (2020)
Augmenting Ontology Alignment
407
3. Chen, J., Hu, P., Jimenez-Ruiz, E., Holter, O.M., Antonyrajah, D., Horrocks, I.: OWL2Vec*: embedding of OWL ontologies. CoRR (2020) 4. Cho, K., et al.: Learning phrase representations using RNN encoder-decoder for statistical machine translation. In: EMNLP, pp. 1724–1734 (2014) 5. Doan, A., Madhavan, J., Domingos, P., Halevy, A.: Ontology matching: a machine learning approach. In: Staab, S., Studer, R. (eds) Handbook on Ontologies. International Handbooks on Information Systems, pp. 385–403. Springer, Heidelberg (2004). https://doi.org/10.1007/978-3-540-24750-0 19 6. Dooley, D.M., et al.: FoodOn: a harmonized food ontology to increase global food traceability, quality control and data integration. npj Sci. Food 2(1), 1–10 (2018) 7. Dragoni, M., Bailoni, T., Maimone, R., Eccher, C.: HeLiS: an ontology for supporting healthy lifestyles. In: Vrandeˇci´c, D., et al. (eds.) ISWC 2018. LNCS, vol. 11137, pp. 53–69. Springer, Cham (2018). https://doi.org/10.1007/978-3-030-00668-6 4 8. Euzenat, J., Shvaiko, P.: Conclusions. Ontology Matching, pp. 399–405. Springer, Heidelberg (2013). https://doi.org/10.1007/978-3-642-38721-0 13 9. Faria, D., Pesquita, C., Santos, E., Palmonari, M., Cruz, I.F., Couto, F.M.: The agreementmakerlight ontology matching system. In: Meersman, R., et al. (eds.) OTM 2013. LNCS, vol. 8185, pp. 527–541. Springer, Heidelberg (2013). https:// doi.org/10.1007/978-3-642-41030-7 38 10. Faria, D., Pesquita, C., Tervo, T., Couto, F.M., Cruz, I.F.: AML and AMLC results for OAEI 2019. In: OM@ISWC, pp. 101–106 (2019) 11. Gionis, A., Indyk, P., Motwani, R., et al.: Similarity search in high dimensions via hashing. VLDB 99(6), 518–529 (1999) 12. Glimm, B., Horrocks, I., Motik, B., Stoilos, G., Wang, Z.: HermiT: an OWL 2 reasoner. J. Autom. Reason. 53(3), 245–269 (2014) 13. Hertling, S., Paulheim, H.: DOME results for OAEI 2019. In: OM@ ISWC (2019) 14. Horrocks, I., Chen, J., Jaehun, L.: Tool support for ontology design and quality assurance. In: ICBO 2020 Integrated Food Ontology Workshop (IFOW) (2020) 15. Iyer, V., Agarwal, A., Kumar, H.: VeeAlign: a supervised deep learning approach to ontology alignment. In: OM@ISWC (2020) 16. Jim´enez-Ruiz, E., Agibetov, A., Chen, J., Samwald, M., Cross, V.: Dividing the ontology alignment task with semantic embeddings and logic-based modules. In: ECAI (2020) 17. Jim´enez-Ruiz, E., Cuenca Grau, B.: LogMap: logic-based and scalable ontology matching. In: Aroyo, L., et al. (eds.) ISWC 2011. LNCS, vol. 7031, pp. 273–288. Springer, Heidelberg (2011). https://doi.org/10.1007/978-3-642-25073-6 18 18. Jim´enez-Ruiz, E., Cuenca Grau, B., Zhou, Y., Horrocks, I.: Large-scale interactive ontology matching: algorithms and implementation. In: ECAI (2012) 19. Kolyvakis, P., Kalousis, A., Kiritsis, D.: DeepAlignment: unsupervised ontology matching with refined word vectors. In: Proceedings of NAACL, pp. 787–798 (2018) 20. Kulmanov, M., Smaili, F.Z., Gao, X., Hoehndorf, R.: Semantic similarity and machine learning with ontologies. Brief. Bioinform. (2020) 21. Laadhar, A., Ghozzi, F., Bousarsar, I.M., Ravat, F., Teste, O., Gargouri, F.: POMap++ results for OAEI 2019: fully automated machine learning approach for ontology matching. In: OM@ISWC, pp. 169–174 (2019) 22. Li, G.: DeepFCA: matching biomedical ontologies using formal concept analysis embedding techniques. In: Proceedings of ICMHI, pp. 259–265 (2020) 23. Mikolov, T., Chen, K., Corrado, G., Dean, J.: Efficient estimation of word representations in vector space. CoRR (2013) 24. Mohammadi, M., Hofman, W., Tan, Y.H.: Simulated annealing-based ontology matching. ACM Trans. Manag. Inf. Syst. (TMIS) 10(1), 1–24 (2019)
408
J. Chen et al.
25. Nkisi-Orji, I., Wiratunga, N., Massie, S., Hui, K.-Y., Heaven, R.: Ontology alignment based on word embedding and random forest classification. In: Berlingerio, M., Bonchi, F., G¨ artner, T., Hurley, N., Ifrim, G. (eds.) ECML PKDD 2018. LNCS (LNAI), vol. 11051, pp. 557–572. Springer, Cham (2019). https://doi.org/10.1007/ 978-3-030-10925-7 34 26. Otero-Cerdeira, L., Rodr´ıguez-Mart´ınez, F.J., G´ omez-Rodr´ıguez, A.: Ontology matching: a literature review. Exp. Syst. Appl. 42(2), 949–971 (2015) 27. Pesquita, C., Faria, D., Santos, E., Couto, F.M.: To repair or not to repair: reconciling correctness and coherence in ontology reference alignments. In: OM@ ISWC, pp. 13–24 (2013) 28. Portisch, J., Hladik, M., Paulheim, H.: Wiktionary matcher. In: OM@ISWC, pp. 181–188 (2019) 29. Shvaiko, P., Euzenat, J.: Ontology matching: state of the art and future challenges. IEEE Trans. Knowl. Data Eng. 25(1), 158–176 (2013) 30. Wang, L., Bhagavatula, C., Neumann, M., Lo, K., Wilhelm, C., Ammar, W.: Ontology alignment in the biomedical domain using entity definitions and context. In: Proceedings of the BioNLP 2018 Workshop, pp. 47–55 (2018) 31. Wang, Q., Mao, Z., Wang, B., Guo, L.: Knowledge graph embedding: a survey of approaches and applications. IEEE Trans. Knowl. Data Eng. 29(12), 2724–2743 (2017) 32. Xiang, C., Jiang, T., Chang, B., Sui, Z.: ERSOM: a structural ontology matching approach using automatically learned entity representation. In: EMNLP (2015) 33. Zhang, Y., et al.: Ontology matching with word embeddings. In: Sun, M., Liu, Y., Zhao, J. (eds.) CCL/NLP-NABD-2014. LNCS (LNAI), vol. 8801, pp. 34–45. Springer, Cham (2014). https://doi.org/10.1007/978-3-319-12277-9 4
Convolutional Complex Knowledge Graph Embeddings Caglar Demir(B) and Axel-Cyrille Ngonga Ngomo Data Science Research Group, Paderborn University, Paderborn, Germany [email protected]
Abstract. We investigate the problem of learning continuous vector representations of knowledge graphs for predicting missing links. Recent results suggest that using a Hermitian inner product on complex-valued embeddings or convolutions on real-valued embeddings can be effective means for predicting missing links. We bring these insights together and propose ConEx—a multiplicative composition of a 2D convolution with a Hermitian inner product on complex-valued embeddings. ConEx utilizes the Hadamard product to compose a 2D convolution followed by an affine transformation with a Hermitian inner product in C. This combination endows ConEx with the capability of (1) controlling the impact of the convolution on the Hermitian inner product of embeddings, and (2) degenerating into ComplEx if such a degeneration is necessary to further minimize the incurred training loss. We evaluated our approach on five of the most commonly used benchmark datasets. Our experimental results suggest that ConEx outperforms state-of-the-art models on four of the five datasets w.r.t. Hits@1 and MRR even without extensive hyperparameter optimization. Our results also indicate that the generalization performance of state-of-the-art models can be further increased by applying ensemble learning. We provide an open-source implementation of our approach, including training and evaluation scripts as well as pretrained models (github.com/dice-group/Convolutional-Complex-Knowledge-GraphEmbeddings).
1
Introduction
Knowledge Graphs (KGs) represent structured collections of facts modelled in the form of typed relationships between entities [13]. These collections of facts have been used in a wide range of applications, including web search [10], cancer research [29], and even entertainment [21]. However, most KGs on the Web are far from being complete [24]. For instance, the birth places of 71% of the people in Freebase and 66% of the people in DBpedia are not found in the respective KGs. In addition, more than 58% of the scientists in DBpedia are not linked to the predicate that describes what they are known for [20]. Link prediction on KGs refers to identifying such missing information [9]. Knowledge Graph Embedding (KGE) models have been particularly successful at tackling the link prediction task [24]. c Springer Nature Switzerland AG 2021 R. Verborgh et al. (Eds.): ESWC 2021, LNCS 12731, pp. 409–424, 2021. https://doi.org/10.1007/978-3-030-77385-4_24
410
C. Demir and A.-C. N. Ngomo
We investigate the use of a 2D convolution in the complex space C to tackle the link prediction task. We are especially interested in an effective composition of the non-symmetric property of Hermitian products with the parameter sharing property of a 2D convolution. Previously, Trouillon et al. [35] showed the expressiveness of a Hermitian product on complex-valued embeddings Re(eh , er , et ), where eh , er , and et stand for the embeddings of head entity, relation and tail entity, respectively; et is the complex conjugate of et . The Hermitian product used in [35] is not symmetric and can be used to model antisymmetric relations since Re(eh , er , et ) = Re(et , er , eh ). Dettmers et al. [9] and Nguyen et al. [23] indicated the effectiveness of using a 2D convolution followed by an affine transformation to predict missing links. Additionally, Balaˇzevi´c et al. [3] showed that 1D relation-specific convolution filters can be an effective means to tackle the link prediction task. Chen et al. [6] suggested applying a 2D convolution followed by two capsule layers on quaternion-valued embeddings. In turn, the results of a recent work [28] highlighted the importance of extensive hyperparameter optimization and new training strategies (see Table 1). The paper showed that the link prediction performances of previous state-of-the-art models (e.g., RESCAL, ComplEx and DistMult [26,35,37]) increased by up to 10% absolute on benchmark datasets, provided that new training strategies are applied. Based on these considerations, we propose ConEx—a multiplicative composition of a 2D convolution operation with a Hermitian inner product of complex-valued embedding vectors. By virtue of its novel architecture, ConEx is able to control the impact of a 2D convolution on predicted scores, i.e., by endowing ComplEx with two more degrees of freedom (see Sect. 4). Ergo, ConEx is able to degenerate to ComplEx if such a degeneration is necessary to further reduce the incurred training loss. We evaluated ConEx on five of the most commonly used benchmark datasets (WN18, WN18RR, FB15K, FB15K-237 and YAGO3-10). We used the findings of [28] on using Bayesian optimization to select a small sample of hyperparameter values for our experiments. Hence, we did not need to perform an extensive hyperparameter optimization throughout our experiments and fixed the seed for the pseudo-random generator to 1. In our experiments, we followed the standard training strategy commonly used in the literature [3,4]. Overall, our results suggest that ConEx outperforms state-of-the-art models on four out of five benchmark datasets w.r.t. Hits@N and Mean Reciprocal Rank (MRR). ConEx outperforms ComplEx and ConvE on all benchmark datasets in all metrics. Results of our statistical hypothesis testing indicates that the superior performance of ConEx is statistically significant. Our ablation study suggests that the dropout technique and the label smoothing have the highest impact on the performance of ConEx. Furthermore, our results on the YAGO3-10 dataset supports the findings of Ruffinelli et al. [28] as training DistMult and ComplEx with new techniques resulted in increasing their MRR performances by absolute 20% and 19%, respectively. Finally, our results suggest that the generalization performance of models can be further improved by applying ensemble learning. In particular, ensembling ConEx leads to a new state-of-the-art performance on WN18RR and FB15K-237.
Convolutional Complex Knowledge Graph Embeddings
2
411
Related Work
A wide range of works have investigated KGE to address various tasks such as type prediction, relation prediction, link prediction, question answering, item recommendation and knowledge graph completion [7,8,14,26]. We refer to [5,16,24,27,36] for recent surveys and give a brief overview of selected KGE techniques. Table 1 shows scoring functions of state-of-the-art KGE models. RESCAL [26] is a bilinear model that computes a three-way factorization of a third-order adjacency tensor representing the input KG. RESCAL captures various types of relations in the input KG but is limited in its scalability as it has quadratic complexity in the factorization rank [33]. DistMult [37] can be seen as an efficient extension of RESCAL with a diagonal matrix per relation to reduce the complexity of RESCAL [4]. DistMult performs poorly on antisymmetric relations while performing well on symmetric relations [33]. Note that through applying the reciprocal data augmentation technique, this incapability of DistMult is alleviated [28]. TuckER [4] performs a Tucker decomposition on the binary tensor representing the input KG, which enables multi-task learning through parameter sharing between different relations via the core tensor. Table 1. State-of-the-art KGE models with training strategies. e denotes embeddings, e ∈ C corresponds to the complex conjugate of e. . ∗ denotes a convolution operation with ω kernel. f denotes rectified linear unit function. ⊗, ◦, · denote the Hamilton, the Hadamard and an inner product, respectively. In ConvE, the reshaping operation is omitted. The tensor product along the n-th mode is denoted by ×n and the core tensor is represented by W. MSE, MR, BCE and CE denote mean squared error, margin ranking, binary cross entropy and cross entropy loss functions. NegSamp and AdvNegSamp stand for negative sampling and adversarial sampling. Model
Scoring function
VectorSpace
Loss
Training
Optimizer
Regularizer
RESCAL [26]
eh · Wr · et
eh , et ∈ R
MSE
Full
ALS
L2 Weighted L2
DistMult [37]
eh , er , et
eh , er , et ∈ R
MR
NegSamp
Adagrad
ComplEx [35]
Re(eh , er , et )
eh , er , et ∈ C
BCE
NegSamp
Adagrad
Weighted L2
ConvE [9]
f (vec(f ([eh ; er ] ∗ ω))W) · et
eh , er , et ∈ R
BCE
KvsAll
Adam
Dropout, BatchNorm
TuckER [4]
W ×1 eh ×2 er ×3 et − eh ◦ er − et
eh , er , et ∈ R
BCE
KvsAll
Adam
Dropout, BatchNorm
eh , er , et ∈ C
CE
AdvNegSamp
Adam
-
RotatE [31] QuatE [38]
eh ⊗ e r · et
eh , er , et ∈ H
CE
AdvNegSamp
Adagrad
Weighted L2
ConEx
conv(eh , er ) ◦ Re(eh , er , et )
eh , er , et ∈ C
BCE
KvsAll
Adam
Dropout, BatchNorm
ComplEx [35] extends DistMult by learning representations in a complex vector space. ComplEx is able to infer both symmetric and antisymmetric relations via a Hermitian inner product of embeddings that involves the conjugatetranspose of one of the two input vectors. ComplEx yields state-of-the-art performance on the link prediction task while leveraging linear space and time complexity of the dot products. Trouillon et al. [34] showed that ComplEx is equivalent to HolE [25]. Inspired by Euler’s identity, RotatE [31] employs a rotational model taking predicates as rotations from subjects to objects in complex space via the element-wise Hadamard product [16]. RotatE performs well on composition/transitive relations while ComplEx performs poorly [31]. QuatE [38] extends the
412
C. Demir and A.-C. N. Ngomo
complex-valued space into hypercomplex by a quaternion with three imaginary components, where the Hamilton product is used as compositional operator for hypercomplex valued-representations. ConvE [9] applies a 2D convolution to model the interactions between entities and relations. Through interactions captured by 2D convolution, ConvE yields a state-of-art performance in link prediction. ConvKB extends ConvE by omitting the reshaping operation in the encoding of representations in the convolution operation [23]. Similarly, HypER extends ConvE by applying relation-specific convolution filters as opposed to applying filters from concatenated subject and relation vectors [3].
3 3.1
Preliminaries and Notation Knowledge Graphs
Let E and R represent the set of entities and relations, respectively. Then, a KG G = {(h, r, t) ∈ E × R × E} can be formalised as a set of triples where each triple contains two entities h, t ∈ E and a relation r ∈ R. A relation r in G is – symmetric if (h, r, t) ⇐⇒ (t, r, h) for all pairs of entities h, t ∈ E, – anti-symmetric if (h, r, t) ∈ G ⇒ (t, r, h) ∈ G for all h = t, and – transitive/composite if (h, r, t) ∈ G ∧ (t, r, y) ∈ G ⇒ (h, r, y) ∈ G for all h, t, y ∈ E [18,31]. The inverse of a relation r, denoted r−1 , is a relation such that for any two entities h and t, (h, r, t) ∈ G ⇐⇒ (t, r−1 , h) ∈ G. 3.2
Link Prediction
The link prediction refers to predicting whether unseen triples (i.e., triples not found in G) are true [16]. The task is often formalised by learning a scoring function φ : E × R × E → R [16,24] ideally characterized by φ(h, r, t) > φ(x, y, z) if (h, r, t) is true and (x, y, z) is not.
4
Convolutional Complex Knowledge Graph Embeddings
Inspired by the previous works ComplEx [35] and ConvE [9], we dub our approach ConEx (convolutional complex knowledge graph embeddings). Motivation. Sun et al. [31] suggested that ComplEx is not able to model triples with transitive relations since ComplEx does not perform well on datasets containing many transitive relations (see Table 5 and Sect. 4.6 in [31]). Motivated by this consideration, we propose ConEx, which applies the Hadamard product to compose a 2D convolution followed by an affine transformation with a Hermitian inner product in C. By virtue of the proposed architecture (see Eq. 1), ConEx is endowed with the capability of
Convolutional Complex Knowledge Graph Embeddings
413
1. leveraging a 2D convolution and 2. degenerating to ComplEx if such degeneration is necessary to further minimize the incurred training loss. ConEx benefits from the parameter sharing and equivariant representation properties of convolutions [11]. The parameter sharing property of the convolution operation allows ConEx to achieve parameter efficiency, while the equivariant representation allows ConEx to effectively integrate interactions captured in the stacked complex-valued embeddings of entities and relations into computation of scores. This implies that small interactions in the embeddings have small impacts on the predicted scores1 . The rationale behind this architecture is to increase the expressiveness of our model without increasing the number of its parameters. As previously stated in [35], this nontrivial endeavour is the keystone of embedding models. Ergo, we aim to overcome the shortcomings of ComplEx in modelling triples containing transitive relations through combining it with a 2D convolutions followed by an affine transformation on C. Approach. Given a triple (h, r, t), ConEx : C3d → R computes its score as ConEx(h, r, t) = conv(eh , er ) ◦ Re(eh , er , et ), where conv(·, ·) : C2d → Cd is defined as conv(eh , er ) = f vec(f ([eh , er ] ∗ ω)) · W + b ,
(1)
(2)
where f (·) denotes the rectified linear unit function (ReLU), vec(·) stands for a flattening operation, ∗ is the convolution operation, ω stands for kernels/filters in the convolution, and (W, b) characterize an affine transformation. By virtue of its novel structure, ConEx is enriched with the capability of controlling the impact of a 2D convolution and Hermitian inner product on the predicted scores. Ergo, the gradients of loss (see Eq. 6) w.r.t. embeddings can be propagated in two ways, namely, via conv(eh , er ) or Re(eh , er , et ). Equation 1 can be equivalently expressed by expanding its real and imaginary parts: ConEx(h, r, t) =
d
Re(γ)k Re(eh )k Re(er )k Re(et )k
(3)
k=1
= Re(γ), Re(eh ), Re(er ), Re(et ) + Re(γ), Re(eh ), Im(er ), Im(et ) + Im(γ), Im(eh ), Re(er ), Im(et ) − Im(γ), Im(eh ), Im(er ), Re(et )
(4)
where et is the conjugate of et and γ denotes the output of conv(eh , er ) for brevity. Such multiplicative inclusion of conv(·, ·) equips ConEx with two more degrees of freedom due the Re(γ) and Im(γ) parts. 1
We refer to [11] for further details of properties of convolutions.
414
C. Demir and A.-C. N. Ngomo
Connection to ComplEx. During the optimization, conv(·, ·) is allowed to reduce its range into γ ∈ C such that Re(γ) = 1 ∧ Im(γ) = 1. This allows ConEx to degenerate into ComplEx as shown in Eq. 5: ConEx(h, r, t) = γ ◦ ComplEx(h, r, t).
(5)
This multiplicative inclusion of conv(·, ·) is motivated by the scaling parameter in the batch normalization (see Sect. 3 in [15]). Consequently, ConEx is allowed use a 2D convolution followed by an affine transformation as a scaling factor in the computation of scores. Training. We train our approach by following a standard setting [4,9]. Similarly, we applied the standard data augmentation technique, the KvsAll training procedure2 . After the data augmentation technique for a given pair (h, r), we compute scores for all x ∈ E with φ(h, r, x). We then apply the logistic sigmoid function σ(φ((h, r, t))) to obtain predicted probabilities of entities. ConEx is trained to minimize the binary cross entropy loss function L that determines the incurred loss on a given pair (h, r) as defined in the following: |E|
L=−
1 (i) ˆ (i) )), (y log(ˆ y(i) ) + (1 − y(i) )log(1 − y |E| i=1
(6)
ˆ ∈ R|E| is the vector of predicted probabilities and y ∈ [0, 1]|E| is the where y binary label vector.
5
Experiments
5.1
Datasets
We used five of the most commonly used benchmark datasets (WN18, WN18RR, FB15K, FB15K-237 and YAGO3-10). An overview of the datasets is provided in Table 2. WN18 and WN18RR are subsets of Wordnet, which describes lexical and semantic hierarchies between concepts and involves symmetric and antisymmetric relation types, while FB15K, FB15K-237 are subsets of Freebase, which involves mainly symmetric, antisymmetric and composite relation types [31]. We refer to [9] for further details pertaining to the benchmark datasets.
2
Note that the KvsAll strategy is called 1-N scoring in [9]. Here, we follow the terminology of [28].
Convolutional Complex Knowledge Graph Embeddings
415
Table 2. Overview of datasets in terms of number of entities, number of relations, and node degrees in the train split along with the number of triples in each split of the dataset. Dataset
|E|
|R|
YAGO3-10 123,182 37 FB15K
5.2
Degr. (M ± SD) |G Train | 9.6 ± 8.7
14,951 1,345 32.46 ± 69.46
1,079,040
|G Validation | |G Test | 5,000
5,000
483,142 50,000
59,071
WN18
40,943 18
3.49 ± 7.74
141,442
5,000
5,000
FB15K-237
14,541 237
19.7 ± 30
272,115 17,535
20,466
WN18RR
40,943 11
2.2 ± 3.6
86,835
3,034
3,134
Evaluation Metrics
We used the filtered MRR and Hits@N to evaluate link prediction performances, as in previous works [4,9,31,35]. We refer to [28] for details pertaining to metrics. 5.3
Experimental Setup
We selected the hyperparameters of ConEx based on the MRR score obtained on the validation set of WN18RR. Hence, we evaluated the link prediction performance of ConEx on FB15K-237, YAGO3-10, WN18 and FB15K by using the best hyperparameter configuration found on WN18RR. This decision stems from the fact that we aim to reduce the impact of extensive hyperparameter optimization on the reported results and the CO2 emission caused through relying on the findings of previously works [28]. Strubell et al. [30] highlighted the substantial energy consumption of performing extensive hyperparameter optimization. Moreover, Ruffinelli et al. [28] showed that model configurations can be found by exploring relatively few random samples from a large hyperparameter space. With these considerations, we determined the ranges of hyperparameters for the grid search algorithm optimizer based on their best hyperparameter setting for ConvE (see Table 8 in [28]). Specifically, the ranges of the hyperparameters were defined as follows: d: {100, 200}; dropout rate:{.3, .4} for the input; dropout rate: {.4, .5} for the feature map; label smoothing: {.1} and the number of output channels in the convolution operation: {16, 32}; the batch size: {1024}; the learning rate: {.001}. After determining the best hyperparameters based on the MRR on the validation dataset; we retrained ConEx with these hyperparameters on the combination of train and valid sets as applied in [17]. Motivated by the experimental setups for ResNet [12] and AlexNet [19], we were interested in quantifying the impact of ensemble learning on the link prediction performances. Ensemble learning refers to learning a weighted combination of learning algorithms. In our case, we generated ensembles of models by averaging the predictions of said models.3 To this end, we re-evaluated state-ofthe-art models, including TucKER, DistMult and ComplEx on the combination 3
Ergo, the weights for models were set to 1 (see the Sect. 16.6 in [22] for more details).
416
C. Demir and A.-C. N. Ngomo
of train and validation sets of benchmark datasets. Therewith, we were also able to quantify the impact of training state-of-the-art models on the combination of train and validation sets. Moreover, we noticed that link prediction performances of DistMult and ComplEx, on the YAGO3-10 dataset were reported without employing new training strategies (KvsAll, the reciprocal data augmentation, the batch normalization, and the ADAM optimizer). Hence, we trained DistMult, ComplEx on YAGO3-10 with these strategies. 5.4
Implementation Details and Reproducibility
We implemented and evaluated our approach in the framework provided by [2,4]. Throughout our experiments, the seed for the pseudo-random generator was fixed to 1. To alleviate the hardware requirements for the reproducibility of our results and to foster further reproducible research, we provide hyperparameter optimization, training and evaluation scripts along with pretrained models at the project page.
6
Results
Tables 3, 4 and 10 report the link prediction performances of ConEx on five benchmark datasets. Overall, ConEx outperforms state-of-the-art models on four out of five datasets. In particular, ConEx outperforms ComplEx and ConvE on all five datasets. This supports our original hypothesis, i.e., that the composition of a 2D convolution with a Hermitian inner product improves the prediction of relations in complex spaces. We used the Wilcoxon signed-rank test to measure the statistical significance of our link prediction results. Moreover, we performed an ablation study (see Table 8) to obtain confidence intervals for prediction performances of ConEx. These results are shown in the Appendix. Bold and underlined entries denote best and second-best results in all tables. ConEx outperforms all state-of-the-art models on WN18 and FB15K (see Table 10 in the Appendix), whereas such distinct superiority is not observed on WN18RR and FB15K-237. Table 3 shows that ConEx outperforms many state-of-the-art models, including RotatE, ConvE, HypER, ComplEx, NKGE, in all metrics on WN18RR and FB15K-237. This is an important result for two reasons: (1) ConEx requires significantly fewer parameters to yield such superior results (e.g., ConEx only requires 26.63M parameters on WN18RR, while RotatE relies on 40.95M parameters), and (2) we did not tune the hyperparameters of ConEx on FB15K-237. Furthermore, the results reported in Table 3 corroborate the findings of Ruffinelli et al. [28]: training DistMult and ComplEx with KvsAll, the reciprocal data augmentation, the batch normalization, and the ADAM optimizer leads to a significant improvement, particularly on FB15K-237. During our experiments, we observed that many state-of-the-art models are not evaluated on YAGO3-10. This may stem from the fact that the size of YAGO3-10 prohibits performing extensive hyperparameter optimization
Convolutional Complex Knowledge Graph Embeddings
417
Table 3. Link prediction results on WN18RR and FB15K-237. Results are obtained from corresponding papers. ‡ represents recently reported results of corresponding models. WN18RR FB15K-237 MRR Hits@10 Hits@3 Hits@1 MRR Hits@10 Hits@3 Hits@1 DistMult [9] ComplEx [9] ConvE [9] RESCAL† [28] DistMult† [28] ComplEx† [28] ConvE† [28] HypER [3] NKGE [38] RotatE [31] TuckER [4] QuatE [38]
.430 .440 .430 .467 .452 .475 .442 .465 .450 .476 .470 .482
.490 .510 .520 .517 .530 .547 .504 .522 .526 .571 .526 .572
.440 .460 .440 .480 .466 .490 .451 .477 .465 .492 .482 .499
.390 .410 .400 .439 .413 .438 .411 .436 .421 .428 .443 .436
.241 .247 .335 .357 .343 .348 .339 .341 .330 .338 .358 .366
.419 .428 .501 .541 .531 .536 .521 .520 .510 .533 .544 .556
.263 .275 .356 .393 .378 .384 .369 .376 .365 .375 .394 .401
.155 .158 .237 .263 .250 .253 .248 .252 .241 .241 .266 .271
DistMult ComplEx TuckER
.439 .453 .466
.527 .546 .515
.455 .473 .476
.399 .408 .441
.353 .332 .363
.539 .509 .553
.390 .366 .400
.260 .244 .268
ConEx
.481
.550
.493
.448
.366
.555
.403
.271
even with the current state-of-the-art hardware systems. Note that YAGO3-10 involves 8.23 and 8.47 times more entities than FB15K and FB15K-237, respectively. Table 4 indicates that DistMult and ComplEx perform particularly well on YAGO3-10, provided that KvsAll, the reciprocal data augmentation, the batch normalization, and the ADAM optimizer are employed. These results support findings of Ruffinelli et al. [28]. During training, we observed that the training loss of DistMult and ComplEx seemed to converge within 400 epochs, whereas the training loss of TuckER seemed to continue decreasing. Ergo, we conjecture that TuckER is more likely to benefit from increasing the number of epochs than DistMult and ComplEx. Table 4 shows that the superior performance of ConEx against state-of-the-art models including DistMult, ComplEx, HypER can be maintained on the largest benchmark dataset for the link prediction. Delving into the link prediction results, we observed an inconsistency in the test splits of WN18RR and FB15K-237. Specifically, the test splits of WN18RR and FB15K-237 contain many out-of-vocabulary entities4 . For instance, 6% of the test set on WN18RR involves out-of-vocabulary entities. During our experiments, we did not remove such triples to obtain fair comparisons on both
4
github.com/TimDettmers/ConvE/issues/66.
418
C. Demir and A.-C. N. Ngomo
Table 4. Link prediction results on YAGO3-10. Results are obtained from corresponding papers. YAGO3-10 MRR Hits@10 Hits@3 Hits@1 DistMult [9] ComplEx [9] ConvE [9] HypER [3] RotatE [31]
.340 .360 .440 .533 .495
.540 .550 .620 .678 .670
.380 .400 .490 .580 .550
.240 .260 .350 .455 .402
DistMult ComplEx TuckER
.543 .547 .427
.683 .690 .609
.590 .594 .476
.466 .468 .331
ConEx
.553
.696
.601
.474
datasets. To quantify the impact of unseen entities on link prediction performances, we conducted an additional experiment. Link Prediction per Relation. Table 5 reports the link prediction per relation performances on WN18RR. Overall, models perform particularly well on triples containing symmetric relations such as also see and similar to. Compared to RotatE, DistMult, ComplEx and TuckER, ConEx performs well on triples containing transitive relations such as hypernym and has part. Allen et al. [1] ranked the complexity of type of relations as R > S > C in the link prediction task. Based on this ranking, superior performance of ConEx becomes more apparent as the complexity of relations increases. Ensemble Learning. Table 6 reports the link prediction performances of ensembles based on pairs of models. These results suggest that ensemble learning can be applied as an effective means to boost the generalization performance of existing approaches including ConEx. These results may also indicate that models may be further improved through optimizing the impact of each model on the ensembles, e.g., by learning two scalars α and β in αConEx(s, p, o) + βTuckER(s, p, o) instead of averaging predicted scores. Parameter Analysis. Table 7 indicates the robustness of ConEx against the overfitting problem. Increasing the number of parameters in ConEx does not lead to a significant decrease in the generalization performance. In particular, ConEx achieves similar generalization performance, with p = 26.63M and p = 70.66M , as the difference between MRR scores are less than absolute 1%. This cannot be explained with convolutions playing no role as ConEx would then degrade back to ComplEx and achieve the same results (which is clearly not the case in our experiments).
Convolutional Complex Knowledge Graph Embeddings
419
Table 5. MRR link prediction on each relation of WN18RR. Results of RotatE are taken from [38]. The complexity of type of relations in the link prediction task is defined as R > S > C [1]. Relation name
Type RotatE DistMult ComplEx TuckER ConEx
hypernym
S
.148
.102
.106
.121
.149
instance hypernym
S
.318
.218
.292
.375
.393
member meronym
C
.232
.129
.181
.181
.171
synset domain topic of
C
.341
.226
.266
.344
.373
has part
C
.184
.143
.181
.171
.192 .318
member of domain usage
C
.318
.225
.280
.213
member of domain region
C
.200
.095
.267
.284
.354
derivationally related form R
.947
.982
.984
.985
.986
also see
R
.585
.639
.557
.658
.647
verb group
R
.943
1.00
1.00
1.00
1.00
similar to
R
1.00
1.00
1.00
1.00
1.00
Table 6. Link prediction results of ensembled models on WN18RR and FB15K-237. Second rows denote link prediction results without triples containing out-of-vocabulary entities. ConEx-ConEx stands for ensembling two ConEx trained with the dropout rate 0.4 and 0.5 on the feature map. WN18RR
FB15K-237
MRR Hits@10 Hits@3 Hits@1 MRR Hits@10 Hits@3 Hits@1 DistMult-ComplEx .446
.545
.467
.398
.359
.546
.397
.265
.475
.579
.497
.426
.359
.546
.397
.265
DistMult-TuckER ConEx-DistMult ConEx-ComplEx ConEx-TuckER ConEx-ConEx
.446
.533
.461
.405
.371
.563
.410
.275
.476
.569
.492
.433
.371
.563
.411
.275
.454
.545
.471
.410
.371
.563
.409
.275
.484
.580
.501
.439
.367
.556
.403
.272
.470
.554
.487
.428
.370
.559
.407
.276
.501
.589
.518
.456
.360
.547
.397
.267
.483
.549
.494
.449
.375
.568
.414
.278
.514
.583
.526
.479
.375
.568
.414
.278
.485
.559
.495
.450
.376
.569
.415
.279
.517
.594
.526
.479
.376
.570
.415
.279
420
C. Demir and A.-C. N. Ngomo
Table 7. Influence of different hyperparameter configurations for ConEx on WN18RR. d, c and p stand for the dimensions of embeddings in C, number of output channels in 2D convolutions and number of free parameters in millions, respectively. d
7
c
p
WN18RR MRR Hits@10 Hits@3 Hits@1
300 64 70.66M .475
.540
.490
.442
250 64 52.49M .475
.541
.488
.441
300 32 47.62M .480
.548
.491
.447
250 32 36.39M .479
.545
.490
.446
300 16 36.10M .479
.550
.494
.445
250 16 28.48M .477
.544
.489
.443
200 32 26.63M .481
.550
.493
.447
100 32 10.75M .474
.533
.480
.440
100 16 9.47M
.476
.536
.486
.441
50
.448
.530
.477
.401
32 4.74M
Discussion
The superior performance of ConEx stems from the composition of a 2D convolution with a Hermitian inner product of complex-valued embeddings. Trouillon et al. [35] showed that a Hermitian inner product of complex-valued embeddings can be effectively used to tackle the link prediction problem. Applying the convolution operation on complex-valued embeddings of subjects and predicates permits ConEx to recognize interactions between subjects and predicates in the form of complex-valued feature maps. Through the affine transformation of feature maps and their inclusion into a Hermitian inner product involving the conjugate-transpose of complex-valued embeddings of objects, ConEx can accurately infer various types of relations. Moreover, the number and shapes of the kernels permit to adjust the expressiveness , while ConEx retains the parameter efficiency due to the parameter sharing property of convolutions. By virtue of the design, the expressiveness of ConEx may be further improved by increasing the depth of the conv(·, ·) via the residual learning block [12].
8
Conclusion and Future Work
In this work, we introduced ConEx—a multiplicative composition of a 2D convolution with a Hermitian inner product on complex-valued embeddings. By virtue of its novel structure, ConEx is endowed with the capability of controlling the impact of a 2D convolution and a Hermitian inner product on the predicted scores. Such combination makes ConEx more robust to overfitting, as is affirmed with our parameter analysis. Our results open a plethora of other
Convolutional Complex Knowledge Graph Embeddings
421
research avenues. In future work, we plan to investigate the following: (1) combining the convolution operation with Hypercomplex multiplications, (2) increasing the depth in the convolutions via residual learning block and (3) finding more effective combinations of ensembles of models. Acknowledgments. This work has been supported by the BMWi-funded project RAKI (01MD19012D) as well as the BMBF-funded project DAIKIRI (01IS19085B). We are grateful to Diego Moussallem for valuable comments on earlier drafts and to Pamela Heidi Douglas for editing the manuscript.
Appendix Statistical Hypothesis Testing. We carried out a Wilcoxon signed-rank test to check whether our results are significant. Our null hypothesis was that the link prediction performances of ConEx, ComplEx and ConvE come from the same distribution. The alternative hypothesis was correspondingly that these results come from different distributions. To perform the Wilcoxon signed-rank test (two-sided), we used the differences of the MRR, Hits@1, Hits@3, and Hits@10 performances on WN18RR, FB15K-237 and YAGO3-10. We performed two hypothesis tests between ConEx and ComplEx as well as between ConEx and ConvE. In both tests, we were able to reject the null hypothesis with a p-value < 1%. Ergo, the superior performance of ConEx is statistically significant. Ablation Study. We conducted our ablation study in a fashion akin to [9]. Like [9], we evaluated 2 different parameter initialisations to compute confidence n n x)2 s 1 i (xi −¯ ¯ = n i xi and s = , intervals that is defined as x ¯ ±1.96· √n , where x n respectively. Hence, the mean and the standard deviation are computed without Bessel’s correction. Our results suggest that the initialization of parameters does not play a significant role in the link performance of ConEx. The dropout technique is the most important component in the generalization performance of ConEx. This is also observed in [9]. Moreover, replacing the Adam optimizer with the RMSprop optimizer [32] leads to slight increases in the variance of the link prediction results. During our ablation experiments, we were also interested in decomposing ConEx through removing conv(·, ·), after ConEx is trained with it on benchmark datasets. By doing so, we aim to observe the impact of a 2D convolution in the computation of scores. Table 9 indicates that the impact of conv(·, ·) differs depending on the input knowledge graph. As the size of the input knowledge graph increases, the impact of conv(·, ·) on the computation of scores of triples increases.
422
C. Demir and A.-C. N. Ngomo
Table 8. Ablation study for ConEx on FB15K-237. dp and ls denote the dropout technique and the label smoothing technique, respectively. FB15K-237 MRR Hits@10
Hits@3
Hits@1
Full
.366 ± .000 .556 ± .001 .404 ± .001 .270 ± .001
No dp on inputs
.282 ± .000 .441 ± .001 .313 ± .001 .203 ± .000
No dp on feature map .351 ± .000 .533 ± .000 .388 ± .001 .259 ± .001 No ls
.321 ± .001 .498 ± .001 .354 ± .001 .232 ± .002
With RMSprop
.361 ± .004 .550 ± .007 .400 ± .005 .267 ± .003
Table 9. Link prediction results on benchmark datasets. ConEx− stands for removing conv(·, ·) in ConEx during the evaluation. ConEx ConEx− MRR Hits@10 Hits@3 Hits@1 MRR Hits@10 Hits@3 Hits@1 WN18RR
.481
.550
.493
.448
.401
.494
.437
.346
FB15K-237 .366
.555
.403
.271
.284
.458
.314
.198
YAGO3-10 .553
.696
.601
.477
.198
.324
.214
.136
Table 10. Link prediction results on WN18 and FB15K obtained from [4, 38]. WN18 FB15K MRR Hits@10 Hits@3 Hits@1 MRR Hits@10 Hits@3 Hits@1 DistMult ComplEx ANALOGY R-GCN TorusE ConvE HypER SimplE TuckER QuatE
.822 .941 .942 .819 .947 .943 .951 .942 .953 .950
.936 .947 .947 .964 .954 .956 .958 .947 .958 .962
.914 .936 .944 .929 .950 .946 .955 .944 .955 .954
.728 .936 .939 .697 .943 .935 .947 .939 .949 .944
.654 .692 .725 .696 .733 .657 .790 .727 .795 .833
.824 .840 .854 .842 .832 .831 .885 .838 .892 .900
.733 .759 .785 .760 .771 .723 .829 .773 .833 .859
.546 .599 .646 .601 .674 .558 .734 .660 .741 .800
ConEx
.976
.980
.978
.973
.872
.930
.896
.837
Link Prediction Results on WN18 and FB15K. Table 10 reports link prediction results on the WN18 and FB15K benchmark datasets.
Convolutional Complex Knowledge Graph Embeddings
423
References 1. Allen, C., Balazevic, I., Hospedales, T.: Interpreting knowledge graph relation representation from word embeddings. In: International Conference on Learning Representations (2021). https://openreview.net/forum?id=gLWj29369lW 2. Balaˇzevi´c, I., Allen, C., Hospedales, T.: Multi-relational poincar´e graph embeddings. In: Advances in Neural Information Processing Systems, pp. 4465–4475 (2019) 3. Balaˇzevi´c, I., Allen, C., Hospedales, T.M.: Hypernetwork knowledge graph embeddings. In: Tetko, I.V., K˚ urkov´ a, V., Karpov, P., Theis, F. (eds.) ICANN 2019. LNCS, vol. 11731, pp. 553–565. Springer, Cham (2019). https://doi.org/10.1007/ 978-3-030-30493-5 52 4. Balaˇzevi´c, I., Allen, C., Hospedales, T.M.: Tucker: tensor factorization for knowledge graph completion. arXiv preprint arXiv:1901.09590 (2019) 5. Cai, H., Zheng, V.W., Chang, K.C.C.: A comprehensive survey of graph embedding: problems, techniques, and applications. IEEE Trans. Knowl. Data Eng. 30(9), 1616–1637 (2018) 6. Chen, H., Wang, W., Li, G., Shi, Y.: A quaternion-embedded capsule network model for knowledge graph completion. IEEE Access 8, 100890–100904 (2020) 7. Demir, C., Moussallem, D., Ngomo, A.-C.N.: A shallow neural model for relation prediction. arXiv preprint arXiv:2101.09090 (2021) 8. Demir, C., Ngomo, A.-C.N.: A physical embedding model for knowledge graphs. In: Wang, X., Lisi, F.A., Xiao, G., Botoeva, E. (eds.) JIST 2019. LNCS, vol. 12032, pp. 192–209. Springer, Cham (2020). https://doi.org/10.1007/978-3-030-41407-8 13 9. Dettmers, T., Minervini, P., Stenetorp, P., Riedel, S.: Convolutional 2d knowledge graph embeddings. In: 32nd AAAI Conference on Artificial Intelligence (2018) 10. Eder, J.S.: Knowledge graph based search system. US Patent App. US13/404,109 (21 June 2012) 11. Goodfellow, I., Bengio, Y., Courville, A.: Deep Learning. MIT Press (2016) 12. He, K., Zhang, X., Ren, S., Sun, J.: Deep residual learning for image recognition. In: Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 770–778 (2016) 13. Hogan, A., et al.: Knowledge graphs. arXiv preprint arXiv:2003.02320 (2020) 14. Huang, X., Zhang, J., Li, D., Li, P.: Knowledge graph embedding based question answering. In: Proceedings of the 12th ACM International Conference on Web Search and Data Mining, pp. 105–113 (2019) 15. Ioffe, S., Szegedy, C.: Batch normalization: accelerating deep network training by reducing internal covariate shift. arXiv preprint arXiv:1502.03167 (2015) 16. Ji, S., Pan, S., Cambria, E., Marttinen, P., Yu, P.S.: A survey on knowledge graphs: representation, acquisition and applications. arXiv preprint arXiv:2002.00388 (2020) 17. Joulin, A., Grave, E., Bojanowski, P., Nickel, M., Mikolov, T.: Fast linear model for knowledge graph embeddings. arXiv preprint arXiv:1710.10881 (2017) 18. Kazemi, S.M., Poole, D.: Simple embedding for link prediction in knowledge graphs. In: Advances in Neural Information Processing Systems, pp. 4284–4295 (2018) 19. Krizhevsky, A., Sutskever, I., Hinton, G.E.: ImageNet classification with deep convolutional neural networks. Commun. ACM 60(6), 84–90 (2017) 20. Krompaß, D., Baier, S., Tresp, V.: Type-constrained representation learning in knowledge graphs. In: Arenas, M., et al. (eds.) ISWC 2015. LNCS, vol. 9366, pp. 640–655. Springer, Cham (2015). https://doi.org/10.1007/978-3-319-25007-6 37
424
C. Demir and A.-C. N. Ngomo
21. Malyshev, S., Kr¨ otzsch, M., Gonz´ alez, L., Gonsior, J., Bielefeldt, A.: Getting the most out of Wikidata: semantic technology usage in Wikipedia’s knowledge graph. In: Vrandeˇci´c, D., et al. (eds.) ISWC 2018. LNCS, vol. 11137, pp. 376–394. Springer, Cham (2018). https://doi.org/10.1007/978-3-030-00668-6 23 22. Murphy, K.P.: Machine Learning: A Probabilistic Perspective. MIT Press (2012) 23. Nguyen, D.Q., Nguyen, T.D., Nguyen, D.Q., Phung, D.: A novel embedding model for knowledge base completion based on convolutional neural network. arXiv preprint arXiv:1712.02121 (2017) 24. Nickel, M., Murphy, K., Tresp, V., Gabrilovich, E.: A review of relational machine learning for knowledge graphs. Proc. IEEE 104(1), 11–33 (2015) 25. Nickel, M., Rosasco, L., Poggio, T.: Holographic embeddings of knowledge graphs. arXiv preprint arXiv:1510.04935 (2015) 26. Nickel, M., Tresp, V., Kriegel, H.P.: A three-way model for collective learning on multi-relational data. In: ICML, vol. 11, pp. 809–816 (2011) 27. Qin, C., et al.: A survey on knowledge graph based recommender systems. Scientia Sinica Informationis 50, 937 (2020) 28. Ruffinelli, D., Broscheit, S., Gemulla, R.: You can teach an old dog new tricks! on training knowledge graph embeddings. In: International Conference on Learning Representations (2019) 29. Saleem, M., Kamdar, M.R., Iqbal, A., Sampath, S., Deus, H.F., Ngonga Ngomo, A.-C.: Big linked cancer data: integrating linked TCGA and PubMed. J. Web Semant. 27, 34–41 (2014) 30. Strubell, E., Ganesh, A., McCallum, A.: Energy and policy considerations for deep learning in NLP. arXiv preprint arXiv:1906.02243 (2019) 31. Sun, Z., Deng, Z.H., Nie, J.Y., Tang, J.: RotatE: knowledge graph embedding by relational rotation in complex space. arXiv preprint arXiv:1902.10197 (2019) 32. Tieleman, T., Hinton, G.: Lecture 6.5-rmsprop: divide the gradient by a running average of its recent magnitude. COURSERA: Neural Netw. Mach. Learn. 4(2), 26–31 (2012) ´ Welbl, J., Riedel, S., Bouchard, G.: 33. Trouillon, T., Dance, C.R., Gaussier, E., Knowledge graph completion via complex tensor factorization. J. Mach. Learn. Res. 18(1), 4735–4772 (2017) 34. Trouillon, T., Nickel, M.: Complex and holographic embeddings of knowledge graphs: a comparison. arXiv preprint arXiv:1707.01475 (2017) ´ Bouchard, G.: Complex embed35. Trouillon, T., Welbl, J., Riedel, S., Gaussier, E., dings for simple link prediction. In: International Conference on Machine Learning, pp. 2071–2080 (2016) 36. Wang, Q., Mao, Z., Wang, B., Guo, L.: Knowledge graph embedding: a survey of approaches and applications. IEEE Trans. Knowl. Data Eng. 29(12), 2724–2743 (2017) 37. Yang, B., Yih, W., He, X., Gao, J., Deng, L.: Embedding entities and relations for learning and inference in knowledge bases. In: ICLR (2015) 38. Zhang, S., Tay, Y., Yao, L., Liu, Q.: Quaternion knowledge graph embeddings. In: Advances in Neural Information Processing Systems, pp. 2731–2741 (2019)
RETRA: Recurrent Transformers for Learning Temporally Contextualized Knowledge Graph Embeddings Simon Werner1(B) , Achim Rettinger1 , Lavdim Halilaj2 , and J¨ urgen L¨ uttin2 1 Trier University, Trier, Germany {werners,rettinger}@uni-trier.de 2 Bosch Research, Renningen, Germany {lavdim.halilaj,juergen.luettin}@de.bosch.com
Abstract. Knowledge graph embeddings (KGE) are vector representations that capture the global distributional semantics of each entity instance and relation type in a static Knowledge Graph (KG). While KGEs have the capability to embed information related to an entity into a single representation, they are not customizable to a specific context. This is fundamentally limiting for many applications, since the latent state of an entity can change depending on the current situation and the entity’s history of related observations. Such context-specific roles an entity might play cannot be captured in global KGEs, since it requires to generate an embedding unique for each situation. This paper proposes a KG modeling template for temporally contextualized observations and introduces the Recurrent Transformer (RETRA), a neural encoder stack with a feedback loop and constrained multiheaded self-attention layers. RETRA enables to transform global KGEs into custom embeddings, given the situation-specific factors of the relation and the subjective history of the entity. This way, entity embeddings for down-stream Knowledge Graph Tasks (KGT) can be contextualized, like link prediction for location recommendation, event prediction, or driving-scene classification. Our experimental results demonstrate the performance gains standard KGEs can obtain, if they are customized according to the situational context.
Keywords: Knowledge graph embedding embeddings · Modeling temporal context
1
· Contextualized
Motivation
We all play different roles in our lives. In private settings we might act differently than in professional settings. What we represent in a situation depends on contextual factors and there is not a single universally valid representation that captures all roles of a person equally well. In contrast, standard Knowledge Graph Embedding (KGE) methods produce a single vector representation c Springer Nature Switzerland AG 2021 R. Verborgh et al. (Eds.): ESWC 2021, LNCS 12731, pp. 425–440, 2021. https://doi.org/10.1007/978-3-030-77385-4_25
426
S. Werner et al.
for entity instances and relation types in the corresponding Knowledge Graph (KG). Each embedding captures the global distributional semantic of the KG in respect to this entity and is optimized for predicting universally valid facts, a Knowledge Graph Task (KGT) known as link prediction. This assumption of universality rarely holds in real-world inference tasks, since the situational context is crucial for making nuanced predictions. When trying to contextualize global KGEs to a situation, two Research Questions (RQ) come to mind: RQ1: How can concrete situations, specifically situational context, be modelled appropriately within knowledge graphs? RQ2: How can static knowledge graph embeddings be transformed into contextualized representations, that capture the specifics of a concrete situations? In this paper we argue, that a single static KGE per entity and relation is not adequate for many KGTs. Instead, entities and relations need to be put into context by factors specific to the current situation and their subjective history.1 This requires a different entity embedding for each situation, not just one that attempts to be universally valid. Consequently, there is the need to customize static KGEs to situational and subjective contexts. More precisely, we argue that current models cannot generate relation embeddings that capture the situation-specific relational context (we refer to this limitation as (Lim1)) and entity embeddings that contain the subject’s history of related observations (we refer to this limitation as (Lim2)). W.r.t. RQ1: We propose temporally contextualized KG facts (tcKG facts) as a modelling template for situation-specific information in a KG. This adds a temporal sequence of hyper-edges (time-stamped subject-relation-object triples where the relation is n-ary in order to capture n contextualizing factors) to an existing static KG (see Sect. 3). W.r.t. RQ2: We contribute the deep learning framework RETRA, which transforms static global entity and relation embeddings into temporally contextualized embeddings, given corresponding tcKG facts. This situation-specific embedding reflects the role an entity plays in a certain context and allows to make situational predictions (see Sect. 4). RETRA uses a novel recurrent architecture and a constrained multi-headed self-attention layer that imposes the relational structure of temporally contextualized KG facts during training (see Sect. 5). In order to demonstrate how broadly applicable tcKG and RETRA are we apply and test them in three diverse scenarios, namely location recommendation, event prediction and driving-scene classification. Our empirical results indicates that contextualizing pre-trained KGEs boosts predictive performance in all cases (see Sect. 6). 1
In psychology and neuroscience this distinction might be referred to as semantics vs. episodic memory (see [19]).
RETRA: Embedding Temporally Contextualized Knowledge Graphs
2
427
Related Work
Our work attempts to transfer the success of contextualizing word embeddings in Natural Language Processing to Knowledge Graph Embeddings (KGE). 2.1
Contextualized Word Embeddings
Word embeddings have been the driving force in Natural Language Processing (NLP) in recent years. Soon after the learning of static embeddings of lexical items became popular their drawbacks became apparent since they conflate all meanings of a word into a single point in vector space. More precisely, static semantic representations suffer from two important limitations: (Lim1) ignoring the role of situational context in triggering nuanced meanings; (Lim2) due to restricting the scope of meaning to individual entities, it is difficult to capture higher order semantic dependencies, such as compositionality and sequential arrangements between entities. Both limitations were recognized early and addressed by approaches that generate contextualized word representations given surrounding words in a sentence. Before the now dominant transformer approach [20], LSTMs where used to contextualize word embeddings [7]. In the area of KGE the need for contextualizing embeddings has not gotten much attention yet, as we will outline next. 2.2
Knowledge Graph Embedding
In recent years KGE has been a very vibrant field in Machine Learning and Semantic Technologies (see [8] for a survey). KGE methods can be roughly characterized by the representation space and the scoring function: The representation space is traditionally Euclidean Rd , but many different spaces like Complex Cd (e.g., in [18]) or Hypercomplex Hd (cmp. [25]) have been used as well. In this work we focus on Euclidean vector spaces only, since they are used for Neural Network embedding models like our RETRA. The scoring function measures the plausibility of an (unknown) subjectpredicate-object triple (referred to as “fact”), given the model parameters. The function produces a scalar score that is obtained by an additive or a multiplicative combination of subject, predicate and object embedding. In this work we focus only on optimizing a given KGE without altering its scoring function. Standard KGE methods don’t take into account temporal information or contextual factors that may influence the plausibility of a fact. In this work we are trying to complement static KGEs without replacing them. To the best of our knowledge there is no existing KGE method that attempts to address both limitations, but they have been addressed individually, as detailed next. 2.3
Knowledge Hypergraph Embedding
Approaches to embed contextualized KG facts is not in the center of current KGE research. However, the use of n-ary relations and the modeling of context as a
428
S. Werner et al.
hypergraph has been proposed before the KGE hype. Such approaches from Statistical Relational Learning were based on graphical models and tensor factorization [16]. A more recent approach extends the current KGE method SimplE [10] to hypergraphs [4] but does not take into account temporal or sequential information. Thus, those approaches address (Lim1), but not (Lim2). In addition, they don’t allow to input standard KGE models to transform their embeddings into contextualized KGEs. 2.4
Temporal KGE
Embedding temporal dynamics of a knowledge graph and thus tackling (Lim2) has seen some attention recently. Basic approaches to temporal KGE, model facts as temporal quadruples. They are optimized for scoring the plausibility of (unknown) facts at a given point in time [3,11]. A more sophisticated approach is proposed in [14]. It checks the temporal consistency given contextual relations of the subject and object. Besides the inability of those models to model n-ary sequential context, we are also taking a different focus by using the temporal dimension to model the history of experiences of a subject. A more entity-centric perspective is taken in [17] which attempts to model the temporal evolution of entities. This comes close to what we attempt regarding (Lim2), but again, it does not cover n-ary relations and is not intended to transform given embeddings into contextualized ones, if provided with a history of subjective experiences. [9] take a relation-specific perspective instead, but still suffer from the same limitations as the above mentioned techniques. 2.5
Contextualized KGE
Central to our RETRA-approach is its ability to transform static input embeddings into contextualized KGEs. A similar approach and the same perspective is being adopted in [22]. There, entities and relations are expected to appear in different graph contexts and consequently should change their representation according to the context (Lim1). We agree with this perspective, but argue that temporal evolution is equally important (Lim2). [21] attempt a relationspecific embedding of entities and propose an LSTM-based approach to so. While RETRA is also inspired by Recurrent Neural Networks, we take a more subjectspecific perspective. Besides that, temporal and n-ary relations are not considered in [21]. The same limitations apply to [24], but the use of a Transformer is similar to our approach. However, word embeddings are used as inputs to the transformation function instead of pre-trained static KGEs in RETRA. Summing up, RETRA offers a unique combination that no previous method has attempted: n-ary relations (Lim1) and sequential subjective experience (Lim2) are exploited to transform static KGE into contextualize ones. RETRA achieves this by two major technical novelties: Modeling KGs with temporally contextualized facts and extending Transformers with a feedback loop and a constrained self-attention layer (Fig. 1).
RETRA: Embedding Temporally Contextualized Knowledge Graphs
429
Fig. 1. From subject-predicate-object KG triples, to temporal tKG facts which occur at time t, to contextualized cKG facts which allow to model influencing factors as an n-ary relation, to tcKG facts which contextualize the KG observation at a certain time. This models the observations of a sequence of relations rc the subject eo is involved in.
3
Modeling Subjective Temporal Context
To address RQ1 we start from the assumption that static KG facts act as background knowledge but the inference task depends on the situational context and the subject’s memory. Consequently, we need to extend triples as follows: KG facts are defined as a triple (es , r, eo ) where es , eo ∈ {e1 , . . . , ene } is from the set of ne entity instances and r ∈ {r1 , . . . , rnr } from the set of nr relation types. KG facts constitute subject-predicate-object statements that are assumed as being static and stable background knowledge. tKG facts are quadruples (es , r, eo , t) where t ∈ N indicates a point in a sequence when the fact occurred. In many scenarios t is obtained from discretizing timestamps and thus creates a globally ordered set of facts, where nt is the total number of points in time (cmp. [17])2 . KG facts without a temporal dimension are considered true for any t. cKG facts are (n+1)-tuples (es , rc , eo , ec1 , . . . , ecnc ) that allow to model context as an nc -ary relation. ec1 , . . . , ecnc are the nc context entities influencing the relation rc between subject es and object eo . As for KG facts, cKG facts are considered non-dynamic background knowledge given the current situation. tcKG facts are (n + 2)-tuples (es , rc , eo , t, ec1 , . . . , ecnc ) which represent sequentially contextualized KG facts by combining the features of tKGs and cKGs. Intuitively, they capture a specific situation which subject es is experiencing at time t. ec are influencing factors towards es ’s relation to object eo .
2
Please note, that temporal KGs have mostly been using t to model the point in time when a fact is being observed. Here, we are taking a slightly different perspective by modeling in which point in time a subject es makes an experience in relation to similar experiences it has made at previous points in time.
430
S. Werner et al.
Fig. 2. tcKG facts (shown in black) and their relation to static background knowledge (KG and cKG facts, shown in gray) as a temporally unrolled KG.
With tcKG facts as additional building blocks, we can now model taskspecific temporally contextualized KGs as temporal hypergraphs (i.e., relations are potentially nc -ary and potentially associated with timestamps t). This subjective temporal context is input to RETRA as follows: 1. Given an nc -ary relation rc we first define one entity participating in rc as the subject es whose perspective is represented in respect to an object eo .3 2. The contexts c1 , . . . , cnc are given by the remaining entities involved in the nc -ary relation. They define the influencing factors in a concrete situation. 3. If available, the context can be extended by entities deterministically dependent on eo . Non-deterministically dependent context of eo or ec or facts that are not specific to a certain point in time t only, are not explicitly modelled (see gray edges and gray nodes in Fig. 2). 4. Finally, the temporal context is modeled by nc relation instances of rc that involve es as the subject. Sorted by time-stamp t, rc defines the sequential context from the perspective of es towards its relation to eo (see black edges an black nodes in Fig. 2). Note, that the context entities ec do change in every step, as does eo , thus eot1 = eot2 . Consequently, all the facts associated to ec and eo do change in every step (gray edges and gray nodes in Fig. 2). Only es and the relation-type of rc stay fixed as defined above. With the above selection procedure we obtain a sequence of tcKG facts from the KG by filtering for relations rc with subject es . Consequently, such a model of 3
Note, that this is a deliberate modeling choice that is not due to technical limitations. RETRA can model any sets of subjects and objects since transformers allow variable numbers of inputs and can mask any subset during training. We chose this restriction, since this is pragmatically the most common pattern and avoids a cluttered notation.
RETRA: Embedding Temporally Contextualized Knowledge Graphs
431
dynamic context consists of a sequence of (es , rc )-tuples with varying sequencelength nt . In each step rc has an varying object eo and is characterized by nc contextual factors ec .4 For illustration purposes, Table 1 shows instantiations of the tcKG modelling pattern according to our three applications domains location recommendation, event prediction and driving-scene classification (see Sect. 6 for details). Table 1. Illustrating examples of instantiated tcKG patterns for three applications. Application
Subject es
Relation rc Object eo
Contexts c1 ,. . . , cnc
Location recommendation
User
ChecksIn
Time of day, weather, day of week, location type . . .
Event prediction
Source actor EventType Involved Target country, source target orga- country, sector, . . . nizations
Driving-scene classification
Ego vehicle
4
InvolvedIn
Location
Conflicttype
Ego lane, foe road users, foes’ lanes, signaling, acceleration, speed, . . .
Embedding Subjective Temporal Context
So far, the tcKG modelling pattern provides an explicit representation of dynamic context of a subject and a relation-type as a sequence of sub-graphs (see Fig. 2). The second contribution of this paper, addressing RQ2, is a machine learning method that captures this information in two embeddings, the subjective context es and the relational context r c .5 Once we obtain those embeddings we then can use any embeddings-based KGT scoring functions, e.g., for contextualized link prediction. One way to capture dynamic context in a single embedding is to represent the history of sequential information in a latent state. As common in Hidden Markov Models or Recurrent Neural Nets, all t − 1 previous contextualized observation are reduced into one embedding capturing the latent state up to this point. In our model, this memory is captured in the es embedding. We thus define the probability P of the contextualized relation representation r c as being conditioned on P (r c |es , r, eo , ec1 , . . . , ecnc ). The subjective context representation es depends on r c but also on the previous experience est−1 in similar situations: P (est |est−1 , r ct , eot ). These conditional dependencies are visualized in Fig. 3. 4
5
Note, that the arity nc does not need to be fixed in each step and for each es . Variablelength context, unknown or missing ec s can be modelled and handled efficiently with RETRA, since transformers can handle variable input lengths. We indicate embedding vectors for nodes e and relations r with bold symbols to contrast them to symbolic nodes e and relations r from the KG.
432
S. Werner et al.
Fig. 3. Sequential context for subject and relation embedding es and r. The object eo and contextual factors ec refer to a different symbolic KG entity eo and ec in every step. They are given by (pre-trained) static KGEs. In contrast es and r represent the same symbolic KG node es and hyper-edge r, regardless of time and context. However, the embedding is customized with a situation-specific contextualized embedding, depending on the temporal and relational context.
5
RETRA: The Recurrent Transformer
Learning customized embeddings based on subjective sequential context requires a novel Neural Network (NN) architecture. 5.1
The RETRA Architecture
Encoders
Encoders
Fig. 4. Recurrency in the RETRA architecture: In the first step, es is not temporally contextualized but a static KGE embedding. In t = 2 the contextualized est1 is used as input to generate the temporally contextualized est2 .
Our model is inspired by the encoder stack of transformers [20] and Recurrent Neural Networks (RNNs) and can thus be called a Recurrent Transformer (RETRA). We can’t use common RNN architectures, like LSTMs [7], nor transformer models, since both don’t handle multiple variable length inputs per step in a temporal sequence. Regarding input and output, RETRA receives the pretrained static embeddings es , r, eo , ec1 , . . . , ecnc and outputs the contextualized r c . In addition, es ’s previous subjective memory est−1 is passed on to generate
RETRA: Embedding Temporally Contextualized Knowledge Graphs
433
the temporally contextualized embedding est for the current step. Thus, the only non-pre-trained embedding passed on to the next step is est−1 (cmp. Fig. 4). The final crucial building block to transform r −→ r c and est−1 −→ est is handled inside the encoder stack. Similar to [20] we use a stack of encoder layers, each consisting of a self-attention layer followed by a feed forward network. We adapt each attention head in the self-attention layer to resemble the structure of the relations defined by a tcKG. Thus, we don’t need to calculate the pairwise attention for all inputs to the encoder, but can attend r c only to {es , r, eo , ec1 , . . . , ecnc }. Similarly, we can constrain the attention of est to {est−1 , r ct , eot } only. This is displayed by the diagonal arrows inside the first encoder layer in Fig. 5.6
Fig. 5. Inside the Encoders in the RETRA architecture (cmp. Fig. 4): Stacked encoderlayers, each with constrained multi-headed self-attention, followed by the scoring function which returns a scalar score for (es , r, eo )-triple.
5.2
Training RETRA
To optimize the weight matrices in the feed-forward and self-attention layers using backpropagation we need to measure the plausibility of predicted facts (using a scoring function) and its deviation from known facts given in the training data (using a loss function). In principal RETRA is independent of the choice of the scoring function and training objective (see Table 5 in [8] for an overview of state-of-the-art KGE models and their scoring functions). Any scoring functions and training objectives can be plugged into RETRA as long as it allows to calculate a gradient.7 We settle on the most common KGE training objective, 6 7
The constraining inside the attention heads is an engineering choice and acts as an inductive bias. Any other constraining is possible including no constraining. Also, many other self-supervised training objectives are possible. Starting from relation masking to temporal subject masking (mask subject est and condition the prediction on est−1 ).
434
S. Werner et al.
namely link prediction, which we in “transformer terms” refer to as “object masking”. The training target is to correctly predict eot+1 given est and rtc , where eot+1 is masked out. Thus, the weights need to be adjusted, such that the scoring function f (est , r ct , eot ) outputs a high score for the correct eot+1 from the training data (and a low score for all other entities). Using a soft-max function on the predicted scores for each eo s allows to calculate the cross-entropy loss against the correct triple and backprop the error. In this paper we are only interested in optimizing the embeddings regardless of the scoring function provided. Thus, we compare the predictive performance of a given KGE model, including its scoring function, to using the same scoring function but transforming the embeddings to temporally contextualized KGEs.
6
Implementation and Empirical Testing
This section provides implementation details and reports empirical results from three diverse application domains. An overview of the features selected in each domain as tcKG facts is provided in Table 1. The SUMO dataset and the parameters used for training in the following experimental section are available in our repository8 on Github.com. Once we get the internal approval, the code to run the experiments will also be made available there. The proposed RETRA approach is implemented based on PyTorch’s9 Transformer Encoder layer, which provides an internal self-attention layer. As seen in Fig. 5, we use an embedded triple (est1 , r, eot2 ) plus its contexts ec1 , . . . , ecnc as input and assume the output to contain the contextualized embeddings est2 and r ct2 . Of those embeddings, the contextualized subject embedding replaces or complements the global subject embedding in the next time-step. This is repeated over the whole sequence of experiences of es . By doing so, the subject embedding alters based on the history of previous inputs and its current context. One key feature of RETRA is its complementarity to existing KGE methods. In the use-cases we present here, we use the static KGEs and their respective scoring functions from three established baseline KGE techniques, namely TransE [1], SimplE [10] and HolE [15]. The implementations of the baseline models were acquired using the OpenKE10 framework, which offers fast implementations of various KGE approaches. The focus of this work is not to obtain the best overall predictive performance but to show how temporal contextualization can improve existing KGEs. For that reason we picked three basic and established baselines.
8 9 10
https://github.com/siwer/Retra. https://pytorch.org/. https://github.com/thunlp/OpenKE.
RETRA: Embedding Temporally Contextualized Knowledge Graphs
6.1
435
Location Recommendation
For location recommendation, we use the New York City dataset11 which was created and used for a different recommendation scenario before [23]. The data consists of check-ins from Foursquare12 , which is a location based social network. Every check-in consists of various information, including user, location, location type, country and time. The recommendation target is a location or Point of Interest (POI) for a particular user, given background knowledge about the locations and the history of visits or checkIns of users at POIs. The ranking is done by using a scoring function f (es , r, eo ) provided by the baseline KGE approaches. The result of a forward step in this scenario is a tensor containing the scores for every potential location in the data. This information plus the information about the known target location given in the training data serves for calculating the cross-entropy loss. Location Recommendation - Experimental Design: We consider the ‘raw’ setting provided in the data set, since we are treating every check-in as one distinct time-step. The data set contains 104,991 distinct check-ins, 3,626 distinct locations, 3,754 distinct users and 281 distinct types. For training and testing we were using a random 80–20 split of our data. Users with only one check-in were not considered because a sequence of at least two check-ins is needed for contextualization. In addition to the input of a triple (es , r, eo ), we explicitly passed the preceding location and the current location’s type as context. The check-ins are not uniformly distributed over users. There are many users with only one or two check-ins, and few users with a lot of check-ins (up to 4,069). The same pattern can be identified with the locations. This extreme imbalance makes this a very challenges task, since we assume that a longer sequence provides more information on a certain user’s behaviour than a short sequence would do. Basic KGE approaches are unable to incorporate the inherent sequential and n-ary relational information provided by such a dataset and are thus fundamentally limited for this task. For both approaches, we have chosen the default number of dimensions (130) as the embedding size. Location Recommendation - Experimental Results: It can be seen in Table 2, that all baseline approaches have performance issues, which we attribute to the skewed distribution. Still, we use these approaches as our global baseline embeddings to see if it is possible to incorporate more information by modelling the sequence and the context information and thus obtain an increase in performance. When the baseline KGEs are combined with RETRA we indeed obtain a huge relative performance increase. Numbers in bold indicate the best results. While the overall performance is still low, the results show that the usage of sequential and contextual information for enhancing entity embeddings can improve the performance of standard KGE approaches by a factor of up to 15. 11 12
https://github.com/eXascaleInfolab/LBSN2Vec. https://foursquare.com.
436
S. Werner et al.
Table 2. Metrics for the best runs of the baseline and combined approaches. “Imp” refers to the relative percentage of performance change compared to the corresponding baseline metric. Approach
Hit@10 Hit@3
Hit@1
Imp Hit@10 Imp Hit@3 Imp Hit@1
TransE
0.0100
0.0017
0.0004
-
-
-
SimplE
0.0077
0.0035
0.0013
-
-
-
HolE
0.0038
0.0004
0.0
-
-
-
RETRA+TransE 0.0203
0.0005
0.0001
103%
−70%
−75%
RETRA+SimplE 0.0592 0.0521 0.0194 668%
1388%
1392%
RETRA+HolE
25%
0%
0.0209
0.0005
0.0
450%
When testing different combinations of model parameters, we observed that the learning rate has the strongest influence on the performance. Changing the number of transformer layers does not seem to have a big impact in general. Apparently, the interactions between features is not complex enough to require several attention layers. For all tested scoring functions, the combination with RETRA led to an improvement in performance. 6.2
Driving Situation Classification
Much progress has been made towards automated driving. One challenging task in automated driving is to capture relevant traffic participants and integrated prediction and planning of the next movement by considering the given context and possible interactive scenarios. Here, we define the problem as predicting the driving maneuver (e.g. following, merging, overtaking) of a vehicle given the current state of the driving scene. According to [12] approaches for vehicle motion prediction can be grouped into physics-based, maneuver-based and interactionbased. Interaction-based methods extend maneuver-based methods by modelling the dependencies between pairs of vehicles. Related work based on different deep neural network approaches and feature combinations for trajectory prediction has been described in [13] in which surrounding vehicles and their features are extracted from fixed grid cells. Our approach in comparison uses relational data between the ego and foe vehicles. Our motivation is that explicit representation of triples might lead to improved modelling of interactions between vehicles. Driving Situation Classification - Experimental Design: We use SUMO13 (Simulations of Urban Mobility), an open source, highly portable, microscopic and continuous multi-modal traffic simulation package to generate driving data. More than 50,000 driving scenes of a motorway were generated. The vehicle parameters as well as driving styles were varied widely in order to simulate a large variety of vehicles and driving behaviours. This resulted in situations such 13
https://www.eclipse.org/sumo/.
RETRA: Embedding Temporally Contextualized Knowledge Graphs
437
as risky driving situations, abandoned driving maneuvers, unexpected stops and even accidents. We have developed a knowledge graph to represent the simulated data by entities (e.g. scene, situation, vehicle, scenario), relations between entities (e.g. isPartOf, occursIn, type) and their associated features (e.g. speed, acceleration, driving direction, time-to-collision). This resulted in more than 900 Mio. RDF-triples with around 2 million scenes which comprise more than 5 million Lane Change and Conflict situations, respectively. It represents a valuable benchmark data-set for driving situation analysis. More information on the design and creation process of the data-set is available in [6]. Table 3. Results for the SUMO Driving Situation Classification data set. The task was to predict the correct situation type, given surrounding traffic. All performance metrics (hit@k, mean rank (MR) and mean reciprocal rank (MRR)) indicate that context is crucial and more previous observations information improves the performance more. Approach
Sequence length Hit@3
Hit@1
MR
HolE
0
0.9366
0.5235
1.76 0.72
TransE
0
0.7668
0.2729
2.56 0.53
SimplE
0
-
-
RETRA+FF 0
0.9946 0.8060
-
MRR
-
1.23 0.89
RETRA+FF 5
0.9731
0.8212
1.23 0.90
RETRA+FF 10
0.9672
0.8382
1.17 0.91
RETRA+FF 15
0.9858
0.8455
1.17 0.92
RETRA+FF 20
0.9871
0.8469 1.16 0.92
Driving Situation Classification - Experimental Results: We conducted two sets of experiments on the SUMO data, which both aimed at predicting the type of a conflict. We needed to make this distinction since the baseline KGE methods cannot use context and thus have to make predictions based on the situation-ID. Instead, RETRA learns a dedicated situation embedding based on the context and previous driving scenes. When experimenting with the different baseline KGE scoring functions we noticed that a fully connected feed forward layer (FF) as a trainable scoring function performs better. The results are shown in the first four rows of Table 3. Since various SimplE implementation we tried did not scale to the size of this data set, we can’t report any results. Obviously, RETRA+FF considerably outperforms the baselines, even as a non-recurrent version. This is mostly due to its ability to contextualize a situation embedding which avoids the need for explicit situation-IDs. Since the previous steps in time leading up to the current situation are potentially important in driving scenes, we specifically investigated the influence of previous situations on the predictive performance. The last four rows of Table 3 show how RETRA handles different numbers of recurrence steps, by feeding in
438
S. Werner et al.
the preceding 5–20 driving situations leading up to the current point in time. It can be observed that the longer sequences are the better the results get. This confirms the assumption that the history is important in driving situations and RETRA is able to exploit it. 6.3
Event Prediction
The Integrated Crisis Early Warning System [2] contains information on geopolitical events and conflicts and is a widely used benchmark for both static and temporal KGE approaches. We specifically use this dataset to showcase how contextualizing can improve and generalize binary KGE approaches. Event Prediction - Data Set: For our experiments, we use the 2014 subset14 of the ICEWS data as described in [5] as a basis, and add contextual information that we take from the original 2014 data15 . In addition to the triples consisting of Source, Event Text and Target, we use the entities Source Sector, Source Country, Target Country and Intensity to contextualize the Source. Event Prediction - Experimental Results: The target is to predict the target entity, typically the organization involved in the event, given the source entity, aka actor, and the relation. In both setups, we optimize a cross-entropy loss by calculating scores for all possible triples in a query (s, r, ?). The target is to produce the highest score for the original triple given in the ground-truth. In addition to using only the information presented in triples, we also consider contextual information for our training. This is achieved by passing all information through RETRA and using the contextualized subject entity for the query (sc , r, ?). In this way, the embeddings are learnt in such a manner that they contribute to the contextualizing given a binary scoring function from our baseline Table 4. Contextualized vs. non-contextualized KGE for different scoring functions on the ICEWS event prediction data set.
14 15
Metric
Contextualized TransE SimplE HolE
Non-contextualized TransE SimplE HolE
Hits@1 Hits@3 Hits@10 Hits@100
0.519 0.691 0.821 0.941
0.570 0.739 0.843 0.941
0.537 0.703 0.822 0.940
0.264 0.398 0.532 0.775
MR MRR
152.92 0.625
91.02 0.669
88.00 311.85 0.638 0.358
0.264 0.398 0.532 0.775
0.299 0.463 0.623 0.840
311.85 0.358
193.13 0.409
https://github.com/nle-ml/mmkb/tree/master/TemporalKGs. https://dataverse.harvard.edu/dataset.xhtml?persistentId=doi:10.7910/DVN/ 28075.
RETRA: Embedding Temporally Contextualized Knowledge Graphs
439
KGE methods. As shown in Table 4, using the contextual information results in a huge improvement in performance for all tested baseline scoring functions and evaluation metrics. This, again, indicates that context is crucial and RETRA is able to exploit it, regardless of the KGE scoring function used.
7
Conclusion and Future Work
In this paper we propose the modeling template tcKG for temporally contextualized KG facts (addressing RQ1 ) and RETRA, a Deep Learning model intended to transform static Knowledge Graph Embeddings into temporally contextualized ones, given a sequence of tcKG facts (addressing RQ2 ). With RETRA we tackle two limitations of current KGE models, namely their lack of taking nary relational context into account (Lim1 ) and capturing the evolution of an entity embedding, given its subjective history of similar previous events (Lim2 ). Our experimental results on three data sets from diverse application domains indicate that existing KGE methods for global embeddings can benefit from using RETRA to contextualize their embeddings. We could also demonstrate that both, context and history, does boost performance considerably. Although there have been a number of recent contributions to the area of contextualized KGEs, we still see large potential for future work beyond additional empirical testing and technical improvements to RETRA. From the perspective of knowledge representation the fundamental question remains how to best capture influencing factors that contextualize the meaning of an entity or relation. We see this as a crucial challenge for making KGs more actionable in concrete real-world situation. Once this is solved efficiently, we expect a similar boost to KGEs as Transformers generated for word embeddings.
References 1. Bordes, A., Usunier, N., Garcia-Dur´ an, A., Weston, J., Yakhnenko, O.: Translating embeddings for modeling multi-relational data. In: Proceedings of the 26th International Conference on Neural Information Processing Systems, NIPS 2013, , Red Hook, NY, USA, vol. 2, pp. 2787–2795. Curran Associates Inc. (2013) 2. Boschee, E., Lautenschlager, J., O’Brien, S., Shellman, S., Starz, J., Ward, M.: ICEWS coded event data (2015). https://doi.org/10.7910/DVN/28075 3. Dasgupta, S.S., Ray, S.N., Talukdar, P.: HyTE: hyperplane-based temporally aware knowledge graph embedding. In: Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing, pp. 2001–2011 (2018) 4. Fatemi, B., Taslakian, P., Vazquez, D., Poole, D.: Knowledge hypergraphs: prediction beyond binary relations (2020) 5. Garc´ıa-Dur´ an, A., Dumancic, S., Niepert, M.: Learning sequence encoders for temporal knowledge graph completion. CoRR abs/1809.03202 (2018). http://arxiv. org/abs/1809.03202 6. Halilaj, L., Dindorkar, I., Luettin, J., Rothermel, S.: A knowledge graph-based approach for situation comprehension in driving scenarios. In: 18th Extended Semantic Web Conference - In-Use Track (2021). https://openreview.net/forum? id=XBWVwf4lab8
440
S. Werner et al.
7. Hochreiter, S., Schmidhuber, J.: Long short-term memory. Neural Comput. 9(8), 1735–1780 (1997) 8. Ji, S., Pan, S., Cambria, E., Marttinen, P., Yu, P.S.: A survey on knowledge graphs: Representation, acquisition and applications. arXiv preprint arXiv:2002.00388 (2020) 9. Jiang, T., et al.: Towards time-aware knowledge graph completion. In: Proceedings of the 26th International Conference on Computational Linguistics: Technical Papers, COLING 2016, pp. 1715–1724 (2016) 10. Kazemi, S.M., Poole, D.: Simple embedding for link prediction in knowledge graphs (2018) 11. Leblay, J., Chekol, M.W.: Deriving validity time in knowledge graph. In: Companion Proceedings of the Web Conference, vol. 2018, pp. 1771–1776 (2018) 12. Lef`evre, S., Vasquez, D., Laugier, C.: A survey on motion prediction and risk assessment for intelligent vehicles. ROBOMECH J. 1(1), 1–14 (2014). https://doi. org/10.1186/s40648-014-0001-z 13. Lenz, D., Diehl, F., Truong-Le, M., Knoll, A.C.: Deep neural networks for Markovian interactive scene prediction in highway scenarios. In: 2017 IEEE Intelligent Vehicles Symposium IV, Los Angeles, CA, USA, 11–14 June 2017, pp. 685–692. IEEE (2017). https://doi.org/10.1109/IVS.2017.7995797 14. Liu, Yu., Hua, W., Xin, K., Zhou, X.: Context-aware temporal knowledge graph embedding. In: Cheng, R., Mamoulis, N., Sun, Y., Huang, X. (eds.) WISE 2020. LNCS, vol. 11881, pp. 583–598. Springer, Cham (2019). https://doi.org/10.1007/ 978-3-030-34223-4 37 15. Nickel, M., Rosasco, L., Poggio, T.: Holographic embeddings of knowledge graphs. In: Proceedings of the 13th AAAI Conference on Artificial Intelligence, AAAI 2016, pp. 1955–1961. AAAI Press (2016) 16. Rettinger, A., Wermser, H., Huang, Y., Tresp, V.: Context-aware tensor decomposition for relation prediction in social networks. Soc. Netw. Anal. Min. 2(4), 373–385 (2012) 17. Trivedi, R., Dai, H., Wang, Y., Song, L.: Know-evolve: deep temporal reasoning for dynamic knowledge graphs. In: Proceedings of the 34th International Conference on Machine Learning, vol. 70, pp. 3462–3471. JMLR.org (2017) ´ Bouchard, G.: Complex embed18. Trouillon, T., Welbl, J., Riedel, S., Gaussier, E., dings for simple link prediction. In: International Conference on Machine Learning (ICML) (2016) 19. Tulving, E., et al.: Episodic and semantic memory. Organ. Mem. 1, 381–403 (1972) 20. Vaswani, A., et al.: Attention is all you need. In: Advances in Neural Information Processing Systems, pp. 5998–6008 (2017) 21. Wang, H., Kulkarni, V., Wang, W.Y.: Dolores: deep contextualized knowledge graph embeddings. arXiv preprint arXiv:1811.00147 (2018) 22. Wang, Q., et al.: CoKE: contextualized knowledge graph embedding. arXiv preprint arXiv:1911.02168 (2019) 23. Yang, D., Qu, B., Yang, J., Cudre-Mauroux, P.: Revisiting user mobility and social relationships in LBSNs: a hypergraph embedding approach, pp. 2147–2157 (May 2019) 24. Yao, L., Mao, C., Luo, Y.: KG-BERT: Bert for knowledge graph completion. arXiv preprint arXiv:1909.03193 (2019) 25. Zhang, S., Tay, Y., Yao, L., Liu, Q.: Quaternion knowledge graph embeddings. In: Advances in Neural Information Processing Systems, pp. 2731–2741 (2019)
Injecting Background Knowledge into Embedding Models for Predictive Tasks on Knowledge Graphs Claudia d’Amato1,2(B) , Nicola Flavio Quatraro1 , and Nicola Fanizzi1,2 1 Dipartimento di Informatica, Universit`a degli Studi di Bari Aldo Moro, Bari, Italy {claudia.damato,nicola.fanizzi}@uniba.it, [email protected] 2 CILA, Universit`a degli Studi di Bari Aldo Moro, Bari, Italy
Abstract. Embedding models have been successfully exploited for Knowledge Graph refinement. In these models, the data graph is projected into a lowdimensional space, in which graph structural information are preserved as much as possible, enabling an efficient computation of solutions. We propose a solution for injecting available background knowledge (schema axioms) to further improve the quality of the embeddings. The method has been applied to enhance existing models to produce embeddings that can encode knowledge that is not merely observed but rather derived by reasoning on the available axioms. An experimental evaluation on link prediction and triple classification tasks proves the improvement yielded implementing the proposed method over the original ones. Keywords: Knowledge graphs · Embeddings · Link prediction · Triple classification · Representation learning
1 Introduction Knowledge Graphs (KGs) are becoming important for several research fields. Although a standard shared definition for KGs is still not available, there is a general consensus on assuming them as organizations of data and information by means of graph structures [12]. KGs are often the result of a complex (integration) process involving multiple sources, human expert intervention and crowdsourcing. Several examples of large KGs exist, spanning from enterprise products, such as those built by Google and Amazon, to mention a few of them, to other open KGs such as the well known DBpedia, Freebase, Wikidata and YAGO [12]. Despite significant efforts for making KGs as comprehensive and reliable as possible, due to the complex building process they tend to suffer of two major problems: incompleteness and noise [12, 20]. As an example, it was found that about 70% of the persons described in DBpedia lack of information regarding their nationality and birth place [8]. Thus, a significant research effort have been devoted to knowledge graph refinement, aiming at correcting these issues with KGs [22]. Among the others, two tasks have gained a major attention: Link Prediction, aiming at predicting missing links between entities, and Triple Classification, that consists in assessing c Springer Nature Switzerland AG 2021 R. Verborgh et al. (Eds.): ESWC 2021, LNCS 12731, pp. 441–457, 2021. https://doi.org/10.1007/978-3-030-77385-4_26
442
C. d’Amato et al.
the correctness of a statement with respect to a KG. In recent years, numeric approaches to these tasks have gained considerable popularity on account of their effectiveness and scalability when applied to large KGs. Such models typically map entities and relations forming complex graph structures to simpler representations (feature-vectors) and aim at learning prediction functions to be exploited for the mentioned tasks. Particularly, the scalability purpose motivated the interest delved towards embedding models [4] which have been shown to ensure good performances on very large KGs. Knowledge graph embedding methods aim at converting the data graph into an optimal low-dimensional space in which graph structural information and graph properties are preserved as much as possible [4, 15]. The low-dimensional spaces enable computationally efficient solutions that scale better with the KG dimensions. Graph embedding methods differ in their main building blocks: the representation space (e.g. point-wise, complex, discrete, Gaussian, manifold), the encoding model (e.g. linear, factorization, neural models) and the scoring function (that can be based on distance, energy, semantic matching or other criteria) [15]. In general, the objective consists in learning embeddings such that the score of a valid (positive) triple is lower than the score of an invalid triple standing for a sort of negative examples. A major problem with these models is that KGs are mostly encoded exploiting available positive assertions (examples) whilst negative constraints are more rarely found, making negative examples more hardly derivable [2]. As positive-only learning settings may be tricky and prone to over-generalization, negative examples (invalid triples) have to be sought for either by randomly corrupting true/observed triples or deriving them having made the local-closed world assumption on the data collection. In both cases, wrong negative information may be generated and thus used when training and learning the embedding models; hence alternative solutions are currently investigated [2]. Even more so, existing embedding models do not make use of the additional semantic information encoded within KGs, when more expressive representations are adopted, indeed the need for semantic embedding methods has been argued [5, 13, 23]. In this paper we present an approach to graph embeddings that, beyond the graph structural information and properties, is also able to exploit the available knowledge expressed in rich representations like RDFS and OWL. Recent works [19] have proven the effectiveness of combinations of embedding methods and strategies relying on reasoning services for the injection of Background Knowledge (BK) to enhance the performance of a specific predictive model. Following this line, we propose T RANS OWL, aiming at injecting BK particularly during the learning process, and its upgraded version T RANS ROWL, where a newly defined and more suitable loss function and scoring function are also exploited. Particularly, we focus on the application of this idea to enhance well-known basic scalable models, namely T RANS E [3] and T RANS R [16], the latter tackling some weak points in T RANS E, such as the difficulty of modeling specific types of relationships [2]. We built upon such models to better cope with additional various types of relationships, intervening also on the training process. Indeed, the proposed solutions can take advantage of an informed corruption process that leverages on reasoning capabilities, while limiting the amount of false negatives that a less informed random corruption process may cause.
Injecting Background Knowledge into Embedding Models
443
It is important to note that, in principle, the proposed approach could be applied to more complex (and recent) KG embedding methods. In this work we intended to show the feasibility of the approach, starting with well established models before moving on towards more sophisticated ones, which would need an additional formalization. The proposed solutions are actually able to improve their effectiveness compared to the original models that focus on structural graph properties with a random corruption process. This is proven through an experimentation focusing on link prediction and triple classification tasks on standard datasets. The rest of the paper is organized as follows. Basics on KG embedding models that are functional to our method definition are presented in Sect. 2. The formalization of our proposed solutions is illustrated in Sect. 3 while in Sect. 4 the experimental evaluation is provided. Related work is discussed in Sect. 5. Conclusions are delineated in Sect. 6.
2 Basics on Embedding Methods In the following we assume the reader has familiarity with the standard representation and reasoning frameworks such as RDF, RDFS and OWL, hence we will consider RDF graphs made up of triples s, p, o of RDF terms, respectively the subject, the predicate, and the object, such that s ∈ U ∪ B where U stands for a set of URIs and B as for a set of blank nodes, p ∈ U and o ∈ U ∪ B ∪ L where L stands for a set of literals. In the following, given an RDF graph G, we denote as EG the set of all entities occurring as subjects or objects in G, and as RG the set of all predicates occurring in G. In this section, basics on knowledge graph embeddings methods [4] are recalled, with a special focus on T RANS E [3] and T RANS R [16]. Several models have been actually proposed for embedding KGs in low-dimensional vector spaces, by learning a unique distributed representation (or embedding) for each entity and predicate in the KG [4] and different representation spaces have been considered (e.g. point-wise, complex, discrete, Gaussian, manifold). Here we focus on vector embedding in the set of real numbers. Regardless of the learning procedure, these models share a fundamental characteristic: given a KG G, they represent each entity x ∈ EG by means of a continuous embedding vector ex ∈ Rk , where k ∈ N is a user-defined hyperparameter. Similarly, each predicate p ∈ RG is associated to a scoring function fp : Rk ×Rk → R, also referred to as energy function [20]. For each pair of entities s, o ∈ EG , the score fp (es , eo ) measures the confidence that the statement encoded by s, p, o holds true. T RANS E introduces a very simple but effective and efficient model: each entity x ∈ EG is represented by an embedding vector ex ∈ Rk , and each predicate p ∈ RG is represented by a (vector) translation operation ep ∈ Rk . The score of a triple s, p, o is given by the similarity (negative L1 or L2 distance) of the translated subject embedding (es + ep ) to the object embedding eo : fp (es , eo ) = −(es + ep ) − eo {1,2} .
(1)
In the case of T RANS R, a different score function fp is considered, that preliminarily projects es and eo to the different d-dimensional space of the relational embeddings ep through a suitable matrix M ∈ Rk×d : fp (es , eo ) = −(Mes + ep ) − Meo {1,2} .
(2)
444
C. d’Amato et al.
The optimal embedding and translation vectors for predicates are learned jointly. The method relies on a stochastic optimization process, that iteratively updates the distributed representations by increasing the score of the triples in G, i.e. the observed triples Δ, while lowering the score of unobserved triples standing as negative examples contained in Δ . Unobserved triples are randomly generated by means of a corruption process, which replaces either the subject or the object of each observed triple with another entity in G. Formally, given an observed triple t ∈ G, let CG (t) denote the set of all triples derived by corrupting t. Then: Δ = CG (s, p, o) = {˜ s, p, o | s˜ ∈ EG } ∪ {s, p, o˜ | o˜ ∈ EG }. (3) s,p,o∈Δ
s,p,o∈Δ
The embedding of all entities and predicates in the G is learned by minimizing a marginbased ranking loss. Formally, let θ ∈ Θ denote a configuration for all entity and predicate embeddings (i.e. the model parameters), where Θ denotes the parameters space. The optimal model parameters θˆ ∈ Θ is learned by solving a constrained optimization problem that amounts to minimizing the following loss functional: minimize [γ + fp (es , eo ) − fp (es˜, eo˜)]+ (4) θ∈Θ
s,p,o∈Δ ˜ s,p,˜ o∈Δ
subject to ∀x ∈ EG : ex = 1, where [x]+ = max{0, x}, and γ ≥ 0 is a hyperparameter referred to as margin. The loss functional in the problem enforces the score of observed triples to be higher than the score of unobserved triples. The constraints prevent the training process to trivially solve the problem by increasing the entity embedding norms.
3 Evolving Models Through Background Knowledge Injection Our approach aims at improving proposed embedding models for KGs, verifying the intuition that the exploitation of expressive schema-level axioms may help increase the model effectiveness. We first present T RANS OWL, injecting BK during the learning process when applied to entity-based models like T RANS E. Then we move on towards a new formalization that is T RANS ROWL, which exploits T RANS R, to better handle the various types of relations, besides of adopting a newly defined and more suitable loss function and scoring function. 3.1
T RANS OWL
T RANS OWL aims at enhancing simple but effective and efficient entity-based embedding models like T RANS E with a better use of the available BK. The final goal is showing the feasibility of our approach, that in principle can be applied to more complex models with additional formalization. In T RANS OWL the original T RANS E setting is maintained while resorting to reasoning with schema axioms to derive further triples to be considered for training and that are generated consistently with the semantics of the
Injecting Background Knowledge into Embedding Models
445
properties. Specifically, T RANS OWL defines specific constraints on the energy functions for each considered axiom, that guide the way embedding vectors are learned. It extends the approach in [19], generating a model characterized by two main components devoted to inject BK in the embedding-based model during the training phase: Reasoning: It is used for generating corrupted triples that can certainly represent negative instances, thus avoiding false negatives, for a more effective model training. Specifically, using a reasoner1 it is possible to generate corrupted triples exploiting the available axioms, specified in RDFS and OWL, namely domain, range, disjointWith, functionalProperty; moreover, false positives can be detected and avoided. BK Injection: A set of different axioms w.r.t. those mentioned above are employed for the definition of constraints on the energy function considered in the training phase so that the resulting vectors related to such axioms reflect specific properties: equivalentClass, equivalentProperty, inverseOf and subClassOf. In T RANS OWL the basic loss function minimized in T RANS E (see Eq. 4) is more complex adding a number of terms consistently with the constraints on the energy function based on the underlying axioms. The most interesting one amounts to generating, new triples to be added to the training set on the grounds of the specified axioms. The definition of the loss function along this setting is given as follows: [γ + fr (h, t) − fr (h , t )]+ + [γ + fq (t, h) − fq (t , h )]+ L= h,r,t∈Δ h ,r,t ∈Δ
+
t,q,h∈ΔinverseOf t ,q,h ∈Δ inverseOf
[γ + fs (h, t) − fs (h , t )]+ +
h,s,t∈ΔequivProperty h ,s,t ∈Δ equivProperty
+
[γ + ftypeOf (h, l) − ftypeOf (h , l )]+
h,typeOf,lΔ∪∈ΔequivClass h ,typeOf,l ∈Δ ∪Δ equivClass
[(γ − β) + f (h, p) − f (h , p )]+
(5)
h,subClassOf,p∈ΔsubClass h ,subClassOf,p ∈Δ subClass
where q ≡ r− , s ≡ r (properties), l ≡ t and t p, the sets of triples denoted by Δπ , where π ∈ {inverseOf, equivProperty, equivClass, subClass}, represent the additional triples generated by a reasoner exploiting such properties and f (h, p) = eh −ep . The different formulation for the case of subClassOf is motivated by the fact that it encodes the additional constraint (expressing major specificity) ftypeOf (e, p) > ftypeOf (e, h) where e is an instance, h subClassOf p and ftypeOf (e, p) = ee +etypeOf −ep as for the original formulation. This also motivates the adoption of the β factor, that is required to determine the direction of the inequality to be obtained for the energy values associated to subclass entities (one w.r.t. the other). As for the equivalentClass formulation, the rationale is to exploit as much as possible the information that can be made explicit during the training phase. Particularly, we ground on the fact that the typeOf relation is one of the most common predicates in KGs, and as such it is used as a primary target of the training phase. In order to clarify this aspect, let us consider a class A equivalent to a class B. Given the triple h, typeOf, A it is possible to derive also h, typeOf, B. Training the model on those derived triples brings a considerable number of new triples. 1
Facilities available in the Apache Jena framework were used: https://jena.apache.org.
446
3.2
C. d’Amato et al.
T RANS ROWL
The main motivation for T RANS OWL was to set up a framework that was able to take into account the BK while using a simple model. However, some of the limits of the models grounded on T RANS E originate from an inability to suitably represent the specificity of the various types of properties. Specifically, the main limitations of T RANS E are related to the poor modeling of reflexive and non 1-to-1 relations as well as to their interplay. Such limitations can cause generating spurious embedding vectors with null values or analogous vectors among different entities, thus compromising the ability of making correct predictions. A noteworthy case regards the typeOf property, a common N -to-N relationship. Modeling such property with T RANS E amounts to a simple vector translation; the considered individuals and classes may be quite different in terms of properties and attributes they are involved in, thus determining strong semantic differences (according to [27]) taking place at large reciprocal distances in the underlying vector space, hence revealing the weakness of employing the mere translation. T RANS R is more suitable to handle such specificity. Thus, further evolving the approach used to derive T RANS OWL from T RANS E, a similar setting is applied to T RANS R, resulting in another model dubbed T RANS ROWL, with the variant T RAN S ROWL R . Particularly, to be more effective on cases involving complex types of relations, a more elaborate vectorial representation is adopted, usually resulting from hyperplane projection [25, 26] or different vector spaces [14, 16]. The underlying model influences the computation of the loss function gradient, that is required to train the model. Hence the main variation introduced by the new model regards the way the entities, within the energy function, are projected in the vector space of the relations, which increases the complexity without compromising the overall scalability. The limitations of T RANS E w.r.t. typeOf can be nearly overcome once the new setting based on T RANS R is adopted. The latter, indeed, associates to typeOf, and to all other properties, a specific vector space where entity vectors are projected to. This leads to training specific projection matrices for typeOf so that the projected entities can be located more suitably to be linked by the vector translation associated to typeOf. Furthermore, methods based on the regularization of the embeddings by exploiting the available axioms [19] prove that resorting to available BK may enhance their effectiveness on account of the addition of more specific constraints to the loss function. As such, the resulting T RANS ROWL model maintains the same setting for reasoning adopted by T RANS OWL, but adopt a different utilization of the available axioms in two variants, one analogous to T RANS OWL and the other, dubbed T RANS ROWLR , following the method based on the regularization of the embeddings via equivalence and inverse property axioms [19]. T RANS ROWL adapts to the T RANS R by introducing in the loss function (Eq. 5) the T RANS R score function f (·) (Eq. 2) and additional weighting parameters:
Injecting Background Knowledge into Embedding Models
L=
[γ + fr (h, t) − fr (h , t )]+ + λ1
h,r,t∈Δ h ,r,t ∈Δ
+λ2
[γ + fs (h, t) − fs (h , t )]+ + λ3
[γ + fq (t, h) − fq (t , h )]+
t,q,h∈ΔinverseOf t ,q,h ∈Δ inverseOf
h,s,t∈ΔequivProperty h ,s,t ∈Δ equivProperty
+λ4
447
[γ + ftypeOf (h, l) − ftypeOf (h , l )]+
h,typeOf,l∈Δ∪ΔequivClass h ,typeOf,l ∈Δ ∪Δ equivClass
[(γ − β) + f (t, p) − f (t , p )]+
(6)
t,subClassOf,p∈ΔsubClass t ,subClassOf,p ∈Δ subClass
where q ≡ r− , s ≡ r (properties), l ≡ t and t p (classes), the different triple sets, denoted by Δπ with π ∈ {inverseOf, equivProperty, equivClass, subClass}, contain additional triples generated by a reasoner exploiting these properties and f (case of subClass) is defined as for T RANS OWL, considering the embedding vectors coming from T RANS R. The parameters λi , i ∈ {1, . . . , 4}, weigh the influence that each function term in Eq. 6 has during the learning phase, analogously to the approach in [19]. In the embedding methods exploiting axiom-based regularization [19], the constraints on vectors to be satisfied, representing the related properties of the entities and relations, are explicitly expressed within the loss function. Considering the model T RANS ER [19], the regularization term based on the equivalence and inverse property axioms is defined as follows: [γ + fr (h, t) − fr (h , t )]+ + λ r + q + λ r − p (7) L= r≡q − ∈TinverseOf
h,r,t∈Δ (h ,r ,t )∈Δ
r≡p∈TequivProp
with the hyperparameter λ and where TinverseOf = {r1 ≡ q1− , r2 ≡ q2− , ..., rn ≡ qn− } and TequivProp = {r1 ≡ p1 , r2 ≡ p2 , ..., rn ≡ pn } stand for the set of inverse properties and equivalent properties following from the axioms in the BK. To adapt this approach to T RANS ROWL, it is required to include constraints on the considered additional properties, such as equivalentClass and subClassOf, and further constraints on the projection matrices associated to each relation. This variant of T RANS ROWL, that is dubbed T RANS ROWLR , is formalized as follows: [γ + fr (h, t) − fr (h , t )]+ L= h,r,t∈Δ h ,r ,t ∈Δ
+λ1
r≡q − ∈TinverseOf
+λ3
e ≡e ∈TequivClass
Mr − Mq
r≡q − ∈TinverseOf
r − p + λ4
r≡p∈TequivProp
+λ5
r + q + λ2
Mr − Mp
r≡p∈TequivProp
e − e + λ6
1 − β − (s − s )
(8)
s ⊆s ∈TsubClass
where TinverseOf = {r1 ≡ q1− , r2 ≡ q2− , ..., rn ≡ qn− }, and TequivProp = {r1 ≡ p1 , r2 ≡ p2 , ..., rn ≡ pn }, resp. the sets of inverse and of equivalent properties, TequivClass = {e1 ≡ e1 , e2 ≡ e2 , ..., en ≡ en } and TsubClass = {s1 s1 , s2 s2 , ..., sn sn } resp.
448
C. d’Amato et al.
the sets of equivalent classes and subclasses. Parameters λi , i ∈ {1, . . . , 6}, determine the weights to be assigned to each constraint and β has the same role mentioned above. The additional term for projection matrices is required for inverseOf and equivProp triples to favor the equality of their projection matrices. This is for having the same energy associated, via score function, to the triples in their respective sets. Considering for instance h, r, t and h, p, t, if r equivProp p, their energy should be equal. The idea of taking into account the regularization of the embeddings by means of the axioms, has been experimentally tested (see Sect. 4) in order to assess whether directly imposing such constraints is more advantageous than generating further triples, based on the same constraints, as in the original definition of the T RANS ROWL model.
4 Experimental Evaluation In this evaluation we focused on T RANS OWL, T RANS ROWL, T RANS ROWLR compared to the original models T RANS E and T RANS R as a baseline. The evaluation aims at assessing the improvement brought by the choices made for defining new models, grounded on the exploitation of BK injection. Specifically, we tested the performance of the mentioned models and related systems on the task of Link Prediction, together with Type Prediction (that, given typeOftriple for a subject, verifies if the model is able to correctly predict a class the individual belongs to). Then we also tested the models on Triple Classification problems, i.e. the ability to classify new triples as true or false. Preliminarily, in the following section, the settings of the experiments are described jointly with the references to the adopted datasets and source code. 4.1
Experiment Setup
Datasets. The models were tested on four datasets drawn from the following KGs, that have been considered in the experimental evaluations of related works [6, 17]. DBpedia. It is a well-known KG with data extracted from Wikipedia. Its vocabulary has 320 classes and 1650 properties. The English version2 describes 4,58M resources, 4,22M of them classified in an ontology. Its dimensions and the presence of 27M RDF links towards 30+ external sources make it one of the principal reference of the Linked Data cloud. We considered two datasets that were extracted to ensure suitable axioms to test the models under evaluation, namely axioms on domain, range, disjointWith, functionalProperty, equivalentClass, equivalentProperty, inverseOf and subClassOf, in the two variants dubbed3 DBpedia100K [6], containing about 100K entities and 321 relations in 600K triples, and DBpedia15K 4 [17], containing about 12.8K entities and 278 relations in 180K triples.
2 3 4
https://wiki.dbpedia.org/about. https://github.com/iieir-km/ComplEx-NNE AER/tree/master/datasets/DB100K. https://github.com/nle-ml/mmkb/tree/master/DB15K.
Injecting Background Knowledge into Embedding Models
449
DBPediaYAGO. YAGO 5 is a KG organizing knowledge coming from different sources such as WordNet, GeoNames and Wikipedia, including 350K+ classes, 10M entities and 120M assertions [22]. It has been exploited to extend and complete DBpedia15K, resulting in DBPediaYAGO exploiting the many links connecting to DBpedia. DBPediaYAGO is characterized by about 290K triples, with 88K entities and 316 relations. NELL. The dataset6 comes from a knowledge extraction system for eliciting facts from corpora of Web pages. The resulting KG amounts to 2.810K+ assertions regarding 1.186 different relations and categories. We considered a fragment of NELL2RDFvanilla7 , that does not contain all of the properties that can be exploited by the proposed model variants. The considered dataset is made up of about 150K triples, with 272 properties and 68K entities. The aim was to test the models on a dataset with a limited set of exploitable properties, namely subClassOf, inverseOf, functionalProperty, disjointWith, range and domain. The abundance of subClassOf-triples, together with a limited number of typeOf-triples for each entity, is meant to test if the models are able to compensate this partial incompleteness and improve the performance of the base models. Considering the inverseOf-axioms allows to compare directly the performance of T RANS ROWL and T RANS ROWLR , when generating new triples for training or regularizing the embeddings. Parameter Settings. All models were set up along the same procedure and parameter values, consistently with the experiments illustrated in [3, 16]: learning rate: 0.001; minibatch dimension: 50; entity/relation vector dimension = 100; epochs: {250, 500, 1000}. This choice is motivated by the fact that our first aim is to verify the possible improvements of the proposed solutions over the basic models when exactly the same conditions, including the parameter values, apply. Due to a tendency to overfitting that is known to affect T RANS R, it requires an initialization of the embeddings performed via T RANS E (see [16]). Similarly, also T RAN S ROWL and its variant were initialized with these embeddings. Overfitting has been checked on the models derived from T RANS R along the different numbers of epochs. Moreover, the bern strategy for triple corruption phase was adopted, as this choice led to a better performance compared to the unif strategy in previous experimental evaluations of this class of models [14, 16, 25, 26]. The unif strategy generates negative triples by sampling a pair of entities for subject and object from EG , assigning uniform probabilities to the possible replacements; bern assigns different chances (along with a Bernoulli distribution) based on the nature (1-to-1,1-to-N, N-to-N) of the relation. As for the T RANS ROWL loss function regularization hyperparameters λi , the following values have been found: inverseOf λ1 = 1; equivalentProperty λ2 = 1; equivalentClass λ3 = 0.1; subClassOf λ4 = 0.01; whilst as for T RANS ROWLR : λ1 = λ2 = λ3 = λ4 = λ5 = λ6 = 0.1;
5 6 7
https://yago-knowledge.org/. http://rtw.ml.cmu.edu/rtw/. http://nell-ld.telecom-st-etienne.fr/.
450
C. d’Amato et al.
Each dataset was partitioned into training, validation and test sets by randomly selecting 70%, 10%, 20% of the triples per run. Datasets and their partitions, resulting embedding models, together with the source code are available in a public repository8 . 4.2
Link Prediction
Following the standard methodologies for evaluating Translational Distance Models, we focus on predicting the missing individuals in given incomplete triples. Specifically the models are used to predict triples h, r, t, with h, t ∈ EG and r ∈ RG , corresponding to the patterns ?, r, t, h, r, ?. The typical metrics considered for this task are Mean Rank and H@10 (the lower the better, and vice-versa, resp.), that are based on predictions rankings. Two variants are generally taken into account, Raw and Filtered, where the latter filters off triples that amount to corrupted ones, i.e. negative cases generated for training the model. For a deeper insight, we measured separately the performance considering all properties but typeOf, and then on typeOf only. This allows to verify the improvement brought by the new models considering Type Prediction (i.e. classification) problems on the classes of each KG. As mentioned above, the embeddings were initialized by a first run of T RANS E (1000 epochs), and the training was run for up to further 1000 epochs. To appreciate the performance trends, for T RANS R and its extensions, we also report the test results for models trained in intermediate numbers of epochs, namely 250 and 500. This is in order to check the occurrence of overfitting cases as discussed above. The complete outcomes of the link prediction experiments are illustrated in Table 1 (best results are bolded, with ties decided by the precise figures). Preliminarily, comparing the overall performance of T RANS E and T RANS OWL, the latter seems to be able to improve only on classification tasks (those targeting typeOf) and in the experiments on DBpediaYAGO and NELL, it proves even better, in terms of MR, than T RANS R and derived models. This suggests that T RANS OWL is particularly suitable for classification. However, in most of the cases the best performance on this task was achieved by T RANS ROWL especially in terms of H@10. Compared to the results achieved by T RANS R, one cannot conclude that the subClassOf axioms have determined the same improvements of T RANS OWL compared to T RANS E, suggesting that more complex models may require more advanced strategies. Conversely, the results regarding the other properties (no typeOf columns) confirmed that T RANS R and derived models are more suitable for general link prediction problems: T RANS ROWL and T RANS ROWLR in most of the cases performed much better than T RANS E and T RANS OWL. Compared to T RANS R, T RANS ROWL and T RANS ROWLR showed a better performance, except few cases in which T RANS R resulted slightly better especially in terms of MR, but they were close runner-ups. The improvement w.r.t. T RANS E and T RANS OWL is due to the more suitable representation for the relations. This is more evident from the outcomes on DBpedia100K and DBpediaYAGO, the latter having been specifically extended to improve the completeness. As argued in [11], a more complete dataset yields a larger number of triples 8
https://github.com/Keehl-Mihael/TransROWL-HRS.
Injecting Background Knowledge into Embedding Models Table 1. Link prediction outcomes (MR = Mean Rank and H@10 = Hits@10) DBpedia15K Model
Epochs
no typeOf
typeOf
MR
H@10
MR
H@10
MR
H@10
MR
H@10
(raw)
(raw)
(flt.)
(flt.)
(raw)
(raw)
(flt.)
(flt.)
T RANS E
1000
587.07
32.46
573.94
35.01
692.29
9.75
67.05
T RANS OWL
1000
621.06
32.24
607.91
34.85
493.46
13.20
29.14
20.85
250
583.72
60.57
570.54
63.37
498.58
84.86
26.42
93.09
T RANS R
500
587.37
60.66
574.12
63.42
499.39
85.01
20.15
94.51
T RANS R
1000
600.12
60.67
586.83
63.57
504.13
85.01
13.96
95.50
T RANS ROWL
250
584.94
60.88
571.74
63.48
493.24
84.91
25.10
93.72
T RANS ROWL
500
598.03
60.77
584.79
63.58
487.44
84.97
17.50
95.38
T RANS ROWL
1000
606.73
60.59
593.45
63.48
484.04
85.18
13.53
96.54
T RANS R
T RANS ROWLR
15.68
250
585.84
60.68
572.62
63.40
498.50
84.85
26.60
93.10
R
500
592.78
60.66
579.55
63.42
491.98
84.97
19.73
95.52
T RANS ROWLR
1000
607.43
60.71
594.13
63.65
497.40
85.12
16.50
96.24
T RANS ROWL DBpedia100K Model
Epochs
no typeOf
typeOf
MR
H@10
MR
H@10
MR
H@10
MR
H@10
(raw)
(raw)
(flt.)
(flt.)
(raw)
(raw)
(flt.)
(flt.)
T RANS E
1000
2233.40
38.56
2204.39
41.11
2224.26
3.62
1615.68
T RANS OWL
1000
2430.51
38.12
2401.67
40.69
2152.89
5.64
1728.52
6.02
250
2160.79
52.83
2131.51
55.45
1911.06
92.21
1480.79
92.23
T RANS R
500
2152.40
53.02
2122.94
55.67
1927.16
92.17
1479.44
92.35
T RANS R
1000
2142.10
53.17
2112.42
55.96
1957.42
92.04
1480.26
92.25
T RANS ROWL
250
2165.42
52.67
2136.25
55.26
1904.80
92.22
1483.62
92.23
T RANS ROWL
500
2147.47
52.92
2118.12
55.59
1933.79
92.22
1498.14
92.37
1000
2147.56
53.24
2117.87
56.03
1961.75
92.29
1503.87
92.43
T RANS R
T RANS ROWL
3.86
T RANS ROWL
R
250
2159.51
52.76
2130.29
55.35
1915.67
91.98
1485.03
92.18
T RANS ROWL
R
500
2136.73
52.92
2107.29
55.64
1955.90
92.07
1515.07
92.27
T RANS ROWLR
1000
2121.52
53.08
2091.81
55.95
1971.98
92.24
1511.07
92.43
MR
H@10
MR
H@10
MR
H@10
MR
H@10
(raw)
(raw)
(flt.)
(flt.)
(raw)
(raw)
(flt.)
(flt.)
DBpediaYAGO Model
Epochs
no typeOf
typeOf
T RANS E
1000
7417.08
19.24
7385.12
20.20
587.19
8.71
157.14
T RANS OWL
1000
7455.49
19.21
7423.56
20.18
580.29
8.68
162.03
19.43
250
7279.11
44.04
7247.16
45.13
656.10
83.66
187.91
93.47
T RANS R
500
7256.86
44.03
7224.74
45.18
738.33
81.33
249.10
88.68
T RANS R
1000
7271.50
44.64
7239.09
46.07
844.51
81.98
348.65
88.99
T RANS ROWL
250
7279.37
43.76
7247.37
44.92
702.22
84.48
243.45
94.54
T RANS ROWL
500
7274.77
43.94
7242.67
45.13
796.46
83.44
314.03
92.93
1000
7209.02
44.45
7176.64
45.84
868.27
82.81
373.90
91.17
250
7274.52
43.61
7242.52
44.78
667.70
83.21
208.90
93.22
T RANS ROWLR
500
7196.12
44.15
7164.00
45.34
752.57
82.08
271.03
90.52
T RANS ROWLR
1000
7226.55
44.13
7194.21
45.52
845.42
81.71
352.16
88.77
MR
H@10
MR
H@10
MR
H@10
MR
H@10
(raw)
(raw)
(flt.)
(flt.)
(raw)
(raw)
(flt.)
(flt.)
T RANS R
T RANS ROWL T RANS ROWL
R
19.42
NELL Model
Epochs
no typeOf
typeOf
T RANS E
1000
7162.08
19.01
6969.07
26.54
2872.45
6.55
2708.90
T RANS OWL
1000
9622.40
15.54
9423.73
21.72
2263.09
6.52
2092.51
6.92
250
7118.13
47.13
6921.77
55.10
2796.70
79.28
2628.58
79.70
T RANS R
500
6928.74
47.31
6728.67
55.62
2585.97
79.19
2415.26
79.66
T RANS R
1000
6891.20
47.40
6681.76
55.93
2315.08
79.94
2140.16
80.50
T RANS ROWL
250
7263.08
46.76
7066.55
54.72
2775.22
79.05
2606.66
79.40
T RANS ROWL
500
7005.75
46.86
6804.32
55.07
2545.47
79.44
2374.09
79.86
T RANS ROWL
1000
7136.77
46.72
6929.10
55.40
2334.50
80.00
2161.67
80.56
250
7530.80
45.89
7334.86
53.51
2714.23
78.40
2547.79
78.75
T RANS ROWLR
500
7300.14
46.04
7098.93
53.89
2527.41
79.81
2357.55
80.20
T RANS ROWLR
1000
7339.53
46.09
7132.22
54.15
2310.11
79.52
2138.99
80.21
T RANS R
T RANS ROWLR
6.82
451
452
C. d’Amato et al.
describing single entities/relations, as the resulting prediction model, with more parameters to be fitted, can be better trained. The case of the NELL dataset is more peculiar, as it aimed at testing the models in a condition of larger incompleteness and with a smaller number of properties to be exploited for knowledge injection. Specifically, this dataset is characterized by a much lower number of typeOf-triples per entity, thus making classification a much harder task. This lack is (partly) compensated by a wealth of subClassOf axioms that can be exploited during the training of class vectors (an ability, introduced in T RANS OWL, that is shared also by T RANS ROWL and T RANS ROWLR ). Another type of axioms that abound in the NELL dataset is inverseOf. The link prediction results (no typeOftriples) show a lower performance of both T RANS OWL and T RANS ROWL, which suggests that the underlying approach has margins for improvements in its definition and/or calls for a better fitting of the regularization parameters. Considering the outcomes on intermediate models (after 250 or 500 epochs elapsed) we observe that the methods were not able to improve the resulting models along with the iterations: in a few cases the overall best results were achieved by models trained after fewer epochs had elapsed. This suggests that a more refined regularization would be required. Lastly, we noticed that T RANS ROWL and T RANS ROWLR turned out substantially equivalent in terms of effectiveness, thus indicating efficiency as a criterion for the choice between the alternatives. 4.3
Triple Classification
Triple Classification is another KG refinement task that focuses on discerning correct from incorrect triples with respect to the KG. Also for this task, the way for evaluating predictive models has be consistent with the KG embedding methods. The evaluation procedure introduced in [24] measures the ability to predict whether a triple is positive or negative, i.e. it represents a true or false fact w.r.t. the KG. To make this decision, a threshold sr is to be determined for each r ∈ RG so to maximize the False Positive Rate (FPR), then test triples will be deemed as positive when their energy-based score is greater than sr , and negative otherwise [18, 26]. The value for sr was estimated considering a random sample of r-triples selected from the training set. They represent the triples that the model has learned to deem as true; for each sampled triple the energy value is computed, measuring the degree of likelihood associated to the triple, setting the threshold sr to the minimum value. The ability of the model to correctly classify triples is evaluated considering the thresholds obtained for the single relations; this unavoidably increases the chance of predicting as true triples that are actually false, thus it allows to better evaluate the model robustness on the classification of typeOf-triples (especially with simple models such as T RANS E). Analogously to the previous experiments the performance indices were determined separating the cases of typeOf-triples from those involving the other properties. This allows to better focus on the performance of the proposed models on this relation. The corrupted (negative) triples required for the tests, were generated by reasoning on range and domain axioms for the experiment excluding typeOf, while disjointWith axioms were exploited to get false typeOf-triples.
Injecting Background Knowledge into Embedding Models Table 2. Triple classification outcomes (Accuracy, Precision, Recall and FP Rate) DBpedia15K Model
Epochs
no typeOf
typeOf Acc
P
R
T RANS E
1000
0.663
0.991
0.407
0.006
0.899
0.781
0.958
0.865
T RANS OWL
1000
0.658
0.967
0.407
0.023
0.975
0.990
0.933
0.127
T RANS R
250
0.655
0.998
0.390
0.002
0.961
0.928
0.954
0.616
T RANS R
500
0.650
0.996
0.380
0.002
0.978
0.979
0.953
0.303
T RANS R
1000
0.641
0.998
0.364
0.001
0.972
0.966
0.946
0.378
250
0.646
0.996
0.373
0.003
0.969
0.924
0.987
0.857
T RANS ROWL
500
0.652
0.997
0.385
0.002
0.985
0.993
0.960
0.141
T RANS ROWL
1000
0.631
0.997
0.347
0.002
0.962
0.999
0.882
0.006
250
0.648
0.997
0.377
0.002
0.937
0.989
0.816
0.049
T RANS ROWLR
500
0.647
0.997
0.376
0.002
0.938
0.994
0.815
0.027
T RANS ROWLR
1000
0.628
0.998
0.342
0.001
0.981
0.969
0.972
0.523
Epochs
no typeOf
FPR
T RANS ROWL
T RANS ROWLR
Acc
P
R
FPR
FPR
DBpedia100K Model
typeOf Acc
P
R
T RANS E
1000
0.742
0.993
0.390
0.004
0.958
0.667
0.943
0.891
T RANS OWL
1000
0.714
0.901
0.359
0.058
0.980
0.908
0.835
0.337
T RANS R
250
0.730
0.997
0.359
0.001
0.983
0.890
0.900
0.526
T RANS R
500
0.721
0.998
0.337
0.001
0.980
0.853
0.910
0.635
T RANS R
1000
0.711
0.998
0.313
0.001
0.976
0.884
0.800
0.344
250
0.744
0.998
0.392
0.001
0.983
0.924
0.851
0.321
T RANS ROWL
500
0.730
0.995
0.361
0.003
0.979
0.965
0.768
0.106
T RANS ROWL
1000
0.705
0.998
0.300
0.001
0.987
0.940
0.895
0.353
250
0.732
0.997
0.364
0.002
0.952
0.635
0.936
0.893
T RANS ROWLR
500
0.717
0.997
0.328
0.002
0.971
0.951
0.668
0.094
T RANS ROWLR
1000
0.704
0.998
0.298
0.001
0.981
0.872
0.890
0.543
Epochs
no typeOf
FPR
T RANS ROWL
T RANS ROWLR
Acc
P
R
FPR
DBpediaYAGO Model
typeOf Acc
P
R
T RANS E
1000
0.654
0.914
0.428
0.066
0.962
0.969
0.841
0.144
T RANS OWL
1000
0.692
0.887
0.441
0.091
0.931
0.961
0.688
0.081
T RANS R
250
0.658
0.953
0.331
0.024
0.885
0.965
0.449
0.029
T RANS R
500
0.656
0.964
0.325
0.017
0.861
0.955
0.335
0.023
T RANS R
1000
0.644
0.964
0.300
0.016
0.844
0.946
0.247
0.018
250
0.662
0.965
0.336
0.018
0.980
0.982
0.919
0.170
T RANS ROWL
500
0.658
0.964
0.328
0.018
0.867
0.988
0.351
0.006
T RANS ROWL
1000
0.649
0.968
0.307
0.014
0.905
0.973
0.547
0.032
250
0.651
0.963
0.315
0.017
0.876
0.965
0.406
0.024
T RANS ROWLR
500
0.648
0.978
0.302
0.010
0.864
0.959
0.349
0.023
T RANS ROWLR
1000
0.636
0.981
0.277
0.007
0.854
0.953
0.299
0.020
FPR
T RANS ROWL
T RANS ROWLR
Acc
P
R
FPR
NELL Model
Epochs
no typeOf
typeOf Acc
P
R
T RANS E
1000
0.733
0.755
0.691
0.420
0.626
0.276
0.900
0.959
T RANS OWL
1000
0.675
0.677
0.671
0.493
0.819
0.430
0.615
0.680
T RANS R
250
0.751
0.810
0.656
0.311
0.715
0.305
0.672
0.823
T RANS R
500
0.751
0.819
0.644
0.285
0.749
0.311
0.544
0.726
T RANS R
1000
0.758
0.843
0.636
0.245
0.803
0.389
0.519
0.630
250
0.745
0.816
0.632
0.279
0.562
0.246
0.911
0.969
T RANS ROWL
500
0.744
0.815
0.633
0.282
0.735
0.311
0.610
0.776
T RANS ROWL
1000
0.744
0.835
0.608
0.234
0.763
0.334
0.560
0.717
250
0.737
0.807
0.621
0.281
0.634
0.268
0.804
0.919
T RANS ROWLR
500
0.743
0.830
0.612
0.245
0.723
0.293
0.583
0.771
T RANS ROWLR
1000
0.739
0.845
0.587
0.207
0.760
0.337
0.598
0.745
T RANS ROWL
T RANS ROWLR
Acc
P
R
FPR
453
454
C. d’Amato et al.
The experimental setting is analogous to the first part (see Sect. 4.1). Table 2 reports the complete results for each dataset in terms of accuracy, precision, recall, and false positive rate. Focusing preliminarily on the results of T RANS E and T RANS ROWL, we can appreciate a general improvement of the latter especially in terms of FPR (typeOf problems) and in terms of accuracy and recall in (no typeOf) experiments on two datasets in which it outperformed also the other models. The overall results show that T RANS ROWL and T RANS ROWLR , achieve the best performance, with a few exceptions, particularly in terms of FPR, also on account of a higher precision and limited decays in terms of recall thus resulting in comparable accuracy measures. These similar performance are likely due to the similar formulation of the respective loss function. In the case of T RANS ROWL it determines the generation of further triples, based on the specified axioms, used to train the models: all entities and relations are involved in training. Conversely, in the case of T RANS ROWLR , only entities and relations that comply with the properties in the constraints are considered. This may explain the slightly superior performance of T RANS ROWL. Analogously to the experiments in Sect. 4.2, a more incomplete dataset like NELL turned out to be more difficult for methods relying on a rich BK, whereas a more complete dataset like DBpediaYAGO, yielded a better performance of the newly proposed models with differences between the problems focusing on/excluding typeOf-triples. Considering the outcomes on intermediate models again there is no clear indication of improvement with the elapsing of the epochs on all performance indexes. This may suggest that involving targeted objectives in the training loop may help.
5 Related Work The presented knowledge injection approach could be applied to many other embedding models [4] with the aim of exploiting the rich schema-level axioms often available in the context of the Semantic Web. However, various approaches have been proposed that leverage different specific forms of prior knowledge to learn better representations exploited for KG refinement tasks. In [9] a novel method was proposed jointly embedding KGs and logical rules, where triples and rules are represented in a unified framework. Triples are represented as atomic formulae while rules are represented as more complex formulae modeled by t-norm fuzzy logics admitting antecedents single atoms or conjunctions of atoms with variables as subjects and objects. A common loss over both representation is defined which is minimized to learn the embeddings. The specific form of BK which has to be available for the KG constitutes the main drawback of these approaches. In [21] a solution based on adversarial training is proposed that exploits Datalog clauses to encode assumptions which are used to regularize neural link predictors. An inconsistency loss is derived that measures the degree of violation of such assumptions on a set of adversarial examples. Training is defined as a minimax problem, in which the models are trained by jointly minimizing the inconsistency loss on the adversarial examples jointly with a supervised loss. A specific form of BK is required and a specific form of local CWA is assumed to reason with it. The availability of such clauses and the assumptions on their semantics represent the main limitations of this approach.
Injecting Background Knowledge into Embedding Models
455
Another neural-symbolic approach exploiting prior knowledge through Logic Tensor Networks [7] has been applied to similar classification tasks. A common shortcoming of the related methods is that BK is often not embedded in a principled way. In [10], investigating the compatibility between ontological knowledge and different types of embeddings, they show that popular embedding methods are not capable of modeling even very simple types of rules, hence they are not able to learn the underlying dependencies. A general framework is introduced in which relations are modeled as convex regions which exactly represent ontologies expressed by a specific form of rules, that preserve the semantics of the input ontology. In [1] the limitations of the current embedding models were identified: theoretical inexpressiveness, lack of support for inference patterns, higher-arity relations, and logical rule incorporation. Thus, they propose the translational embedding model B OX E which embeds entities as points, and relations as a set of hyper-rectangles, which characterize basic logical properties. This model was shown to offer a natural encoding for many logical properties and to be able to inject rules from rich classes of rule languages.
6 Conclusions and Ongoing Work We have proposed an approach to learn embedding models based on exploiting prior knowledge both during the learning process and the triple corruption process to improve the quality of the low-dimensional representation of knowledge graphs. New models have been defined T RANS OWL, T RANS ROWL and T RANS ROWLR , implemented as publicly available systems. An experimental evaluation on knowledge graph refinement tasks has proved the improvements of the derived models compared to the original ones, but also some shortcomings that may suggest valuable research directions to be pursued. We are currently working on the application of the presented approach to newer embedding models which have been proved more effective than those considered in this work. We intend to extend the approach by exploiting further schema-axioms as well as hierarchical patterns on properties that can be elicited from the embeddings, namely clusters of relations and hierarchies of sub-relations. We are also planning to apply embedding models for solving other predictive problems related to the KGs. Following some previous works, further methods based on embedding spaces induced by specific kernel functions will also be investigated. Acknowledgment. We would like to thank Giovanni Sansaro who formalized and developed the code for the preliminary version of TransOWL for his bachelor thesis.
References 1. Abboud, R., Ceylan, ˙I.˙I., Lukasiewicz, T., Salvatori, T.: BoxE: a box embedding model for knowledge base completion. In: Proceedings of NeurIPS 2020 (2020) 2. Arnaout, H., Razniewski, S., Weikum, G.: Enriching knowledge bases with interesting negative statements. In: Das, D., et al. (eds.) Proceedings of AKBC 2020 (2020). https://doi.org/ 10.24432/C5101K
456
C. d’Amato et al.
3. Bordes, A., Usunier, N., Garcia-Duran, A., Weston, J., Yakhnenko, O.: Translating embeddings for modeling multi-relational data. In: Burges, C.J.C., et al. (eds.) Proceedings of NIPS 2013, pp. 2787–2795. Curran Associates, Inc. (2013) 4. Cai, H., Zheng, V.W., Chang, K.: A comprehensive survey of graph embedding: problems, techniques, and applications. IEEE Trans. Knowl. Data Eng. 30(09), 1616–1637 (2018). https://doi.org/10.1109/TKDE.2018.2807452 5. d’Amato, C.: Machine learning for the semantic web: lessons learnt and next research directions. Semant. Web 11(1), 195–203 (2020). https://doi.org/10.3233/SW-200388 6. Ding, B., Wang, Q., Wang, B., Guo, L.: Improving knowledge graph embedding using simple constraints. In: Proceedings of ACL 2018, vol. 1, pp. 110–121. ACL (2018). https://doi.org/ 10.18653/v1/P18-1011 7. Donadello, I., Serafini, L.: Compensating supervision incompleteness with prior knowledge in semantic image interpretation. In: Proceedings of IJCNN 2019, pp. 1–8. IEEE (2019). https://doi.org/10.1109/IJCNN.2019.8852413 8. Dong, X.L., et al.: Knowledge vault: a web-scale approach to probabilistic knowledge fusion. In: Proceedings of KDD 2014, pp. 601–610 (2014) 9. Guo, S., Wang, Q., Wang, L., Wang, B., Guo, L.: Jointly embedding knowledge graphs and logical rules. In: Proceedings of EMNLP 2016, pp. 192–202. ACL (2016). https://doi.org/ 10.18653/v1/D16-1019 10. Guti´errez-Basulto, V., Schockaert, S.: From knowledge graph embedding to ontology embedding? An analysis of the compatibility between vector space representations and rules. In: Thielscher, M., Toni, F., Wolter, F. (eds.) Proceedings of KR 2018, pp. 379–388. AAAI Press (2018) 11. He, S., Liu, K., Ji, G., Zhao, J.: Learning to represent knowledge graphs with gaussian embedding. In: Proceedings of CIKM 2015, pp. 623–632. ACM (2015). https://doi.org/10. 1145/2806416.2806502 12. Hogan, A., et al.: Knowledge graphs. arXiv:2003.02320 (2020) 13. Jayathilaka, M., Mu, T., Sattler, U.: Visual-semantic embedding model informed by structured knowledge. In: Rudolph, S., Marreiros, G. (eds.) Proceedings of STAIRS 2020. CEUR, vol. 2655. CEUR-WS.org (2020). http://ceur-ws.org/Vol-2655/paper23.pdf 14. Ji, G., He, S., Xu, L., Liu, K., Zhao, J.: Knowledge graph embedding via dynamic mapping matrix. In: Proceedings of ACL-IJCNLP 2015, vol. 1, pp. 687–696. ACL (2015). https://doi. org/10.3115/v1/P15-1067 15. Ji, S., Pan, S., Cambria, E., Marttinen, P., Yu, P.S.: A survey on knowledge graphs: representation, acquisition and applications. arXiv:2002.00388 (2020) 16. Lin, Y., Liu, Z., Sun, M., Liu, Y., Zhu, X.: Learning entity and relation embeddings for knowledge graph completion. In: AAAI 2015 Proceedings, pp. 2181–2187. AAAI Press (2015) 17. Liu, Y., Li, H., Garcia-Duran, A., Niepert, M., Onoro-Rubio, D., Rosenblum, D.S.: MMKG: multi-modal knowledge graphs. In: Hitzler, P., et al. (eds.) ESWC 2019. LNCS, vol. 11503, pp. 459–474. Springer, Cham (2019). https://doi.org/10.1007/978-3-030-21348-0 30 18. Lv, X., Hou, L., Li, J., Liu, Z.: Differentiating concepts and instances for knowledge graph embedding. In: Riloff, E., et al. (eds.) Proceedings of EMNLP 2018, pp. 1971–1979. ACL (2018). https://doi.org/10.18653/v1/D18-1222 19. Minervini, P., Costabello, L., Mu˜noz, E., Nov´acˇ ek, V., Vandenbussche, P.-Y.: Regularizing knowledge graph embeddings via equivalence and inversion axioms. In: Ceci, M., Hollm´en, J., Todorovski, L., Vens, C., Dˇzeroski, S. (eds.) ECML PKDD 2017. LNCS (LNAI), vol. 10534, pp. 668–683. Springer, Cham (2017). https://doi.org/10.1007/978-3-319-71249-9 40 20. Minervini, P., d’Amato, C., Fanizzi, N.: Efficient energy-based embedding models for link prediction in knowledge graphs. J. Intell. Inf. Syst. 47(1), 91–109 (2016). https://doi.org/10. 1007/s10844-016-0414-7
Injecting Background Knowledge into Embedding Models
457
21. Minervini, P., Demeester, T., Rockt¨aschel, T., Riedel, S.: Adversarial sets for regularising neural link predictors. In: Elidan, G., et al. (eds.) UAI 2017 Proceedings. AUAI Press (2017) 22. Paulheim, H.: Knowledge graph refinement: a survey of approaches and evaluation methods. Semant. Web 8, 489–508 (2016). https://doi.org/10.3233/SW-160218 23. Paulheim, H.: Make embeddings semantic again! In: Proceedings of the ISWC 2018 P&DIndustry-BlueSky Tracks. CEUR Workshop Proceedings (2018) 24. Socher, R., Chen, D., Manning, C.D., Ng, A.Y.: Reasoning with neural tensor networks for knowledge base completion. In: Proceedings of NIPS 2013, pp. 926–934 (2013) 25. Sun, Z., Huang, J., Hu, W., Chen, M., Guo, L., Qu, Y.: TransEdge: translating relationcontextualized embeddings for knowledge graphs. In: Ghidini, C., et al. (eds.) ISWC 2019. LNCS, vol. 11778, pp. 612–629. Springer, Cham (2019). https://doi.org/10.1007/978-3-03030793-6 35 26. Wang, Z., Zhang, J., Feng, J., Chen, Z.: Knowledge graph embedding by translating on hyperplanes. In: Proceedings of AAAI 2014, pp. 1112–1119. AAAI Press (2014) 27. Yang, B., Yih, W., He, X., Gao, J., Deng, L.: Embedding entities and relations for learning and inference in knowledge bases. In: Proceedings of ICLR 2015 (2015)
Science Data and Scholarly Communication
Structured Semantic Modeling of Scientific Citation Intents Roger Ferrod, Luigi Di Caro(B) , and Claudio Schifanella Department of Computer Science, University of Turin, Turin, Italy {roger.ferrod,luigi.dicaro,claudio.schifanella}@unito.it
Abstract. The search for relevant information within large scholarly databases is becoming an unaffordable task where deeper semantic representations of citations could give impactful contributions. While some researchers have already proposed models and categories of citations, this often remains at a theoretical level only or it simply reduces the problem to a short-text classification of the context sentence. In this work, we propose CiTelling: a radically new model of fine-grained semantic structures lying behind citational sentences able to represent their intent and features. After an extensive and multiple annotation of 1380 citations (https://github.com/rogerferrod/CiTelling), we tested the validity and the reliability of the proposal through both qualitative and quantitative analyses. In particular, we were able to 1) extend the current depth of existing semantic representations when used in computational scenarios, 2) achieve high inter-annotator agreement and 3) obtain state-of-the-art classification results with straightforward neural network models.
Keywords: Citation semantics Semantic annotation
1
· Scientific literature exploration ·
Introduction
Exploring and understanding the heart of millions of scientific articles is not an easy situation for a young researcher. Actually, only keeping abreast of research progress is becoming an increasingly difficult task even for senior and experienced scientists. Digital technologies are now being adopted since years to lighten such process, by providing advanced “semantic” search services based on keywords rather than metadata extraction and filtering procedures. Numerous techniques have been developed to analyze large amounts of data such as the petabytes produced by the Large Hadron Collider or the hundreds of millions of bases contained in the human genome, but natural language cannot be naturally represented by numbers and easily manipulated by computers. Moreover, the research literature is made of complex textual content which is naturally oriented to be read by humans only. However, while the actual understanding of the scientific content remains in the researchers’ hands, a great support may come from the application of data c Springer Nature Switzerland AG 2021 R. Verborgh et al. (Eds.): ESWC 2021, LNCS 12731, pp. 461–476, 2021. https://doi.org/10.1007/978-3-030-77385-4_27
462
R. Ferrod et al.
and language technologies to the citational aspect of the articles. Citations, indeed, represent a fundamental mechanism for both making new research and keeping track of what is going on within a scientific field. For example, an article A may cite an article B for different purposes: to extend, to criticize, to compare with, to refer to some used data or technique, and so forth. In other words, citations are crucial for both production and search, but semantic technologies are still far away from being supportive to the daily work of researchers. Under this light, models such as [22] investigated possible types of citations, together with descriptions and examples. However, categories are sometimes very specific and linked to a few examples, making them difficult to be employed in concrete applications. Alternatively, recent works proposed Machine Learning approaches for the automatic classification of sentences containing citations into few classes such as extension, use, etc. The problem with the latter approach is the reduction of the complexity of the single citation semantics into a short-text classification task, where the expected output is simply one label to associate with the sentence containing the citation. In this contribution, we draw from these experiences to create a fine-grained semantic model of citations which can be instead employed in computational scenarios, manually producing an annotation (available at https://github.com/ rogerferrod/CiTelling) of more than one thousand cases for testing its validity through both human agreements and neural network-based classification results. The goal of this work is thus threefold: 1) to propose a computationallyaffordable semantic model for citations inheriting and enriching key features of state-of-the-art efforts; 2) to provide an extensive and multiple-user annotation of citational sentences; and 3) to demonstrate the model validity through both human- and machine-based evaluations.
2
Related Work
There exists a large body of literature focusing on the processing of scientific texts for purposes such as data curation (e.g. [17]), search (e.g., [4]), topic modeling (e.g., [3]), summarization (e.g., [25]), and so forth. In this context, our work has similarities with different approaches related to the modeling and use of the citations within large scholar databases, such as (i) semantic modeling of citations (e.g., [6,13,16,22]), (ii) data analysis and extraction of relevant information (e.g., [9,20,23]), and (iii) exploration of the scientific literature by means of faceted search queries and visualization tools (e.g., [1,2,10,11,18]). In this paper, we focus on the first task of modeling citations, specifically inheriting both the theoretical and top-down approach of CiTo [22] and recent state-of-the-art technologies for automatic citation classification [6]. More in details, in [22], the authors identified and formalized different types of possible citation meanings in scientific articles. However, the proposed ontology includes a wide set of complex cases, making it exclusively suitable for manual (and costly) annotations of individual references. In [12], the authors presented
Structured Semantic Modeling of Scientific Citation Intents
463
an unsupervised technique based instead on a completely automatic clustering process, identifying and describing 11 classes of citations. More recently, [6] proposed a classifier based on Scaffolds models [24] that was able to identify 6 classes of citations on the ACL-ARC dataset [7] and 3 classes on a larger dataset named SciCite [6] with state-of-the-art accuracy levels. In particular, we used these works as baseline for the evaluation, finding that our model allows to achieve comparable performance with extremely simpler neural network-based classifiers on equally-distributed and semantically-deeper citation intents.
3
Motivations and Research Questions
3.1
Semantic Structures in Citations
Our main goal is to build a fine-grained semantic representation of citations to capture and harmonize their i ) intent type, ii ) direction, iii ) objects or concepts involved, and iv ) context. To better express our idea, let us consider the example below: “We use the Scaffold network classifier (Cohan 2019) to incorporate syntactic structures [...] ” According to CiTo [22], this example should fit the ontological category use, as well as for the state-of-the-art classification system proposed in [6]. However, in the latter case the procedure is only limited to the classification of the sentence. In our work, instead, we face the citation classification problem under a more structured semantic view. In particular, our aim is to model the above citation in the following way: (a)
SUBJECT_PAPER_ID: ; INTENT: ; OBJECT: ; OF_PAPER_ID: ; IN_CONTEXT: ;
A part from being more informative than in [22] and [6], our model is able to cope with more complex (but frequent) cases. For instance, consider the citation below: “(Peter et al. 2018) uses the SVD factorization method.” In this second case, both [22] and [6] approaches would simply associate a label use to the whole sentence, as in the previous example. Instead, we model this different case as:
464
(b)
R. Ferrod et al.
SUBJECT_PAPER_ID: ; INTENT: ; OBJECT: ; OF_PAPER_ID: n/a; CONTEXT: n/a;
It is important to note that, in the latter case (b), the identifier does not enter into the model, since the paper only plays the role of container. In other words, only contains the information that links the cited paper with the object . To the best of our knowledge, this is the first attempt to extract source-agnostic knowledge from scholarly databases, as detailed in the next section. 3.2
Active and Passive Roles in Citations
To better understand the advantages of our proposal, one can think at the related work section of a scientific article, which usually expresses definitions, facts and comparative analyses of existing works in the literature. Such section is indeed an extremely rich source of information to model knowledge related to external articles. Usually, semantic analyses of scholarly articles are focused on the modeling of their direct content, whereas they usually contain knowledge about (mentioned) existing works. A part from the citation class, we further model citational sentences through active and passive roles. The first case includes a relation of a certain class/intent between a source paper A and a referenced paper B, with a focus on some research objects in B. In the second case, the relationship lies between a referenced paper B (mentioned by the citing paper A) and some research object presented by an unknown third-party paper. In this second situation, it is B that covers the role of subject, proposing, adding or using the object. In other words, the source paper A does not cover any semantic role of interest (while it simply functions as a container for the mentioned citation). Please note that, in the previous Example (b), it would be a mistake to classify the A-B relation with the “use” class as currently done by current approaches, since it is not A that uses the mentioned research object. To the best of our knowledge, this represents the first attempt to model structured semantics behind citations, as well as such subject-oriented role. Hereafter we distinguish the two roles by calling them A-subject and B-subject depending on who holds the role of subject. In Fig. 1 we illustrate a comparison between current models and our proposal. In particular, CiTelling embodies information about roles and relationships that involve fine-grained objects rather than the whole papers. Notice that, while existing state-of-the-art computational models face the problem as a simple short-text classification task, we consider the citation semantics under a semantically richer and structured view. This creates a knowledge graph instead of a simpler (labeled) network of articles.
Structured Semantic Modeling of Scientific Citation Intents
465
Fig. 1. Comparison of existing models (on the left) with our proposal (right). While the relations of current models involve two papers as a whole (associating an intent with each citation), CiTelling is able to highlight particular topics of the cited text (objects marked in red), separating the active from the passive role cases. (Color figure online)
4
Semantic Structuring of Citation Intents
Since the scaffold network model proposed in [6] represents the state of the art on citation classification using the ACL-ARC dataset (developed in [7]), we used its classes as starting point. The original labels were the following: background, extends, uses, motivation, compare/contrast, and future work. Then, we integrated other two classes from the results of [12]: propose and analyze. Finally, we added the more formal (and rare) CiTo proposals: critiques and data source. After a careful analysis of their labeling and meaning, we ended up with the five intents (or classes) we thought to be more informative, as shown in Table 1. For example, we decided to exclude the intent background as it is often used as a generic “relatedness-based” container. Table 1. Proposed model of citation intents, integrating features from existing models. *Analyze is derived from the most specific Report label presented in [12]. Intent
Optional subclass CiTo [22] SciSite [6] CitExp [12]
Proposes Uses
x [dataset]
Extends Analyzes
x
x
x
x
[critiques]
Compares [contrasts]
x* x
Taking inspiration from the CiTo ontology, which contains more specific categories such as “usesDataFrom” and “usesConclusionsFrom”, we decided to also consider differences within the intents uses, compares and analyzes. We have therefore added subcategories to highlight the use of datasets or results in the use class and to distinguish dissimilarity (i.e. contrast) in compare. In the same
466
R. Ferrod et al.
way, it is useful to capture the negative analyses, which highlight critical issues related to the citation in the analyze class; this latter case is extremely rare but very informative, thus we finally opted for its inclusion in our model. 4.1
Object and Context Fields
Another innovative point of our contribution, compared to previous works, is the introduction of two semantic fields object and context for further modeling the citational semantics, as illustrated in Fig. 2. In this section, we present definitions and examples for these two fields.
Fig. 2. General overview of the proposed semantic model.
With object, we mean a mandatory concept taken into consideration by the citation, whose meaning changes according to the class. For context, we mean an optional additional background information, or constraints, which can be useful to disambiguate the object. For example, in the sentence: “Adaptive modulation techniques over Nakagami-m fading channels were also investigated in [CIT] for mobile wireless channel.” the object would be “adaptive modulation techniques”, which is contextualized by “for mobile wireless channel ”. More in detail, the object can be defined as the minimal span of text to which the quotation refers (e.g. the extended or analyzed concept). Consequently, it contains the smallest amount of information able to identify the concept of interest. The context is instead represented by a usually larger text surrounding the object helping disambiguate or specify it. A direct application of this model could be within a semantic search engine, where the context may accompany the object through a tool-tip or other visualization tools, providing additional information on the purpose of the object (e.g., “for matrix factorization”) rather than on
Structured Semantic Modeling of Scientific Citation Intents
467
the domain of application (e.g., “in elliptic curve cryptography”). Additionally, the context can be used for integrating additional features into the encoding of object meanings (for example, through the employment of recent BERT-like context-dependent embeddings [8]). Note that we modeled the object and the context fields in a purely semantic way, avoiding to create lexical-semantic interfaces based on part-of-speech tags, patterns or syntactic structures. While this choice leaves higher margin to subjective evaluations, our aim was twofold: i ) to deeply evaluate the model through inter-annotation agreements in absence of physical/narrow lexical constraints; and ii ) to leave room for future automated labeling technologies (e.g. Ontology Learning, Transformer-based Machine Learning, etc.). 4.2
Definition of the Citation Intents
In this section, we provide definitions and examples for the chosen set of intents (or classes) used in our model. With the exceptions of propose 1 and compare, all the other classes may be associated with the two roles previously described in Sect. 3.2. For this reason, the formalization that follows will consider both cases. It is possible to generalize the relationships in the following way: [A-subject] class-label
proposes
A −−−−−−→ object ←−−−−− B [B-subject] class-label
B −−−−−−→ object Hereafter we indicate with A the citing paper (i.e. the paper under analysis) and with B the cited paper. Please note that the propose relation is implicit in the A-subject representation, since the role of B is that of containing object. Propose Class. This class models a particular contribution (i.e. object) of a paper. More formally: proposes
∃ B, object | B −−−−−→ object In words, there exists an article B and one contained concept object such that B proposes object. Different examples of propose citations are shown below: (example 1) “The relational model was first introduced in the work by object
Codd [CIT].” 1
propose cannot have a relation of type A-subject since if the paper A simply proposes object, then there is no reason to quote another paper B. Different is the case in which the authors of a paper A propose an object referring to a paper B, but in that case the correct relationship is of type B-subject.
468
R. Ferrod et al.
(example 2)
“Anisotropic diffusion
was
proposed
object
in the context of scale space [CIT].” context
Use Class. This class models the simple use of some object, citing an external article B. More formally: [A-subject] uses ∃ A, B, object | A −−→ B.object In words, there exists an article B cited within article A where B.object is used in A. [B-subject] uses ∃ B, object | B −−→ object In this case, there exists an article B cited within article A such that B uses some object (thus, A plays only the role of article-container). Different examples of use citations are shown below: (A-subject example - dataset)
“For faces, we used FaceScrub dataset context
object
from [CIT].” (B-subject example) “This MMSE representation was used in [CIT], object
to prove the EPI.” context
Extend Class. This citation intent models the natural process of scientific evolution, that is the possibility of a paper to modify (adapting or enriching) another work. More formally: [A-subject] extends
∃ A, B, object | A −−−−−→ B.object In words, there exists an article B cited within article A where B.object is extended in A. [B-subject] extends
∃ B, object | B −−−−−→ object In this case, there exists an article B cited within article A such that B extends some object. For example: (A-subject) “This algorithm is a generalization of the famous min-norm point algorithm [CIT].” object
Structured Semantic Modeling of Scientific Citation Intents
469
(B-subject) “Ernst et al. [CIT] tackle the static ASP by using a specialized simplex algorithm for the single runway case and object
extend it to the multiple runway case.” context
It is important to notice the difference between extend and use. In particular, extending a work means its use after the application of some changes. This is why cases such as “Our work is based on CIT ” and “Following the work of CIT we [...] ” can be also considered instances of the extend class. Analyze Class. This citation type identifies processes of analysis and discussion on specific topics. More formally: [A-subject] analyzes
∃ A, B, object | A −−−−−→ B.object [B-subject] analyzes
∃ B, object | B −−−−−→ object Examples of analyze citations are shown below: (A-subject example) “We have conducted a survey to discuss Big Data Frameworks [CIT].” object
(B-subject example - critique) “Refer to CIT for a discussion on the optical design problem of HMDs.” context
object
Compare Class. This class identifies similarities or contrasts between articles over a specific research object. More formally: compares ∃ A, B, object | A.object ←−−−−→ B.object This particular relationship is symmetric since the object can be either in A or B. Examples of this type of citations are shown below: (example 1) “For VGG, our latency is longer than [CIT] due to 45% object
frequency gap.” (example 2) “This approach is similar to the strategy defined in [CIT] object
as gap recovery.” context
Notice that, in the first case, latency is shared between A and B, meanwhile in the second example there are two different words (approach belonging to A, and strategy to B) referring to the same concept.
470
4.3
R. Ferrod et al.
Data Selection and Annotation
On such modeling basis, we built a balanced dataset with 276 instances for each class, for a total of 1380 instances. As already mentioned, in contrast with the state of the art baselines, we avoided to consider a background label since it usually represents a generic class that collects all citations “escaped” from any meaningful classification. We have randomly sampled 10K papers from the Semantic Scholar corpus2 obtaining, through ParsCit [15], more than 200K citations. For simplicity, we filtered out the sentences longer than 40 words; however in this way we captured most of the cases. Then, the selection of the candidate citational sentences has been carried out through a first phase of random sampling over such extracted citations, for each class. This process was based on different techniques: for classes such as use and extend we made use of the classifier provided in [6], while for others (analyze and propose) we employed a keyword-based random search. The candidate citational sentences were then cleaned out of the noise with a manual validation. The second phase regarded the annotation of the sentences with the proposed structured semantic model. Three different annotators (the authors of the present paper) separately validated the class label and annotated the A-Subject vs B-Subject role, the object and the context fields for each instance. At the same time, the sub-classification operations were carried out, highlighting the sub-types of the classes (e.g. use:data/use:other and analyze:analyze/analyze:critique). The results of the inter-annotation agreement, calculated through the use of the Bleu score [19], are shown in Fig. 4. In performing this operation we found that there may exist some overlap among the classes and therefore it was useful to set up a disambiguation mechanism. For example, the type extend is considered more informative than propose. More in detail, we defined an ordered list of the classes to guide the disambiguation of ambiguous cases: extend > analyze > compare > use > propose In this way, it is possible to disambiguate sentences like: “We use an extension of [CIT] ” (classified as extend instead of use) and “We propose a comparative analysis beetween SVC [CIT] and NuSVC ” (labeled with analyze).
5
Evaluation
In this section we first report an analysis of the annotation task together with an evaluation of the impact of intent roles (active/passive), intent subclasses (see Table 1), and the obtained inter-annotation agreement. Secondly, we employed the model (through the annotated dataset) in a downstream task, i.e., intent classification, to be able to make comparisons with the current state of the art. 2
https://www.semanticscholar.org/.
Structured Semantic Modeling of Scientific Citation Intents
5.1
471
Roles, Subclasses and Inter-annotation Agreement
After the annotation phase, we have identified a clear diversification in the distribution of roles, as shown in Fig. 3. The subclasses are distributed as follows: 10.14% of the instances in the use class are further labeled as “use data/results”, meanwhile 15.22% of the compare class instances were better specified as “contrast”. Finally, the rarest, 6.16% of the analyze instances are of subtype “critique/error ”. These statistics suggest the utility of sub-classifying the intents, in order to preserve useful information which can be further processed, analyzed and exploited for automatic classification and reasoning purposes. Another interesting consideration concerns the nature of the object in the various citation intents: classes such as extend and compare are mostly associated with very generic objects like method, approach, work or study (respectively 39% and 31% of the total number of objects), meanwhile use and analyze mention very specific objects (a kind of named entities) such as LSTM, Vertex-II Pro or CPLEX 12.6 (respectively 39% and 15% of the total).
Fig. 3. Predominance of roles types (A-subject/B-subject) in the classes distribution. As described in Sect. 4.2, role types are not defined for the Compare class.
To calculate the overall agreement on the three annotations of intents {A1, A2, A3 }, we averaged the scores obtained from the three pairs , , and . More in detail, for each pair we counted a +1 contribution if both annotators labeled the sentence with the same intent. Then, by dividing this value by the number of annotated citations we obtained a global averaged score which was particularly high (0.88). Then, for the in-text semantic annotations, we computed Bleu scores [19] on object and context, reaching the scores of 0.78 and 0.55 respectively. These results are in line with our initial expectations: since context has a less constrained definition with respect to object, it is more susceptible to lexical variations and
472
R. Ferrod et al.
different textual span interpretations. Moreover, context has an average length which is greater than that of object (5.77 words vs 2.40 words). The object field reached instead high agreement levels. The whole result set broken down by class is reported in Fig. 4. We omitted the results of the agreement on roles as they correspond to an average score of 1.0 (the same considerations hold for the intent subclasses).
Fig. 4. Averaged inter-rater agreement among the three annotators for each citation intent. The object and context bars represent averaged inter-annotation Bleu scores.
Among the different citation intents, propose resulted to be very easy to classify by the annotators, with an agreement of 0.95. The object field goes from an average Bleu score of 0.68 for the extend intent to 0.89 for use. Then, the context field, as already stated, reached values between 0.48 and 0.59. 5.2
Downstream Task Evaluation
We evaluated our model by building a simple classifier on the annotated data, comparing the results with the existing state of the art. In particular, we have focused on the outcomes reported by [6]. Unlike the ACL-ARC (used by [7] and [6]) and SciCite [6] datasets, our dataset is balanced and does not include generic labels such as background. The distribution of the classes is shown in Table 2. Moreover while the SciCite dataset contains more than 11k elements, ACLARC [7] has a number of instances (1941) comparable to our dataset (1380) and a similar number of classes, albeit with a completely different distribution. In contrast with the state-of-the-art classifiers under comparison in this section, ours is based on an extremely simple architecture. This choice comes from the aim of evaluating the semantic coherence and power of the proposed CiTelling model by comparing it with the results of complex neural architectures applied on state-of-the-art citational representation models. In particular, we adopted a single biLSTM layer densely connected to a softmax function,
Structured Semantic Modeling of Scientific Citation Intents
473
Table 2. Classes distribution and overlap among datasets. Intent
ACL-ARC SciCite CiTelling (# 1941) (# 11020) (# 1380)
Method
–
29%
–
Result comparison –
13%
–
Background
51%
58%
–
Future work
4%
–
–
Motivation
5%
–
–
Extend
4%
–
20%
Use
19%
–
20%
Compare
18%
–
20%
Propose
–
–
20%
Analyze
–
–
20%
using the citational sentence as unique input. For the initial word representation layer, we employed pretrained fastText word embeddings [14]. Despite the simplicity of the classifier, the results are in line with other more sophisticated existing architectures, in particular with the outcomes reported in [6]. Notice that these methods cannot be directly evaluated on our data since they require further input features and metadata such as section titles and citation markers. Contrariwise, it was possible to apply a simple neural architecture (biLSTM with optimized hyper-parameters3 ) on the existing ACL-ARC data, which reached a significantly low F1 score (38.0%) compared to what obtained by the same neural model on our CiTelling data (65.8%). Furthermore, we noticed more balanced values of Precision and Recall with respect to the compared approaches. An overview of the results is reported in Table 3. Table 3. Intent classification results on CiTelling and ACL-ARC data. CiTelling data
F1 score Precision Recall
biLSTM
65.8
ACL-ARC data
F1 score Precision Recall
biLSTM 38.0 51.5 biLSTM + attention 54.2 biLSTM + attention + elmo 54.6 [Jurgens et al. 2018] biLSTM + attention + scaffolds 63.1 67.9 SciCite classifier 3
66.2 44.0 53.7 59.2 64.9 71.7 81.3
66.1 37.0 50.6 51.6 49.9 58.2 62.5
50 input dim, 12 (x2) hidden units, dropout 0.7, L2 penalty 1e-06.
474
R. Ferrod et al.
Since our model also integrates directional information (i.e., active and passive roles), we further carried out an additional experimentation by training a neural network performing role classification. By using a biGRU architecture [5] with standard settings4 , we obtained a F1-score of 77.6%, with Precision and Recall of 80.6% and 74.8% respectively.
6
Conclusions and Future Work
In this paper, we proposed a new semantic representation for modeling citations within a corpus of scholarly articles. In particular, we took inspiration form both theoretical bases and current computational approaches to both propose a novel semantic model and to create a publicly-available annotated resource. In contrast with the existing approaches aiming at labeling citations with some predefined classes, we put forward a structured model integrating an ontological view of the referenced objects within the literature. Future developments of this work may include the integration of further articles metadata (e.g., sections, timestamps, etc.) and the management of sentences with multiple types of citations. For example, in the sentence “CIT used an extension of X but the results are not satisfactory” the citation plays two roles: it uses an extension of the object (therefore categorizable as extend with B-subj role) while the results of this operation are criticized (analyze with A-subj role). Furthermore, in the first case the object is X while in the second case the object is CIT ; thus they are two distinct citation intents that can be extracted separately, enriching in this way the knowledge model. In order to build a knowledge model capable of integrating and exploiting all the captured concepts, further effort may be spent in the generalization of the objects. This operation could be facilitated by the presence of the context field. The objects automatically extracted from the text can then be aligned with existing ontologies such as [21], a large-scale ontology of research mainly in the field of Computer Science. Our contribution will also enable the construction of a directed citation semantic graph which can be used for advanced analyses (e.g., graph embeddings) rather than semantic web search applications. For example, we can hypothesize the analysis of the knowledge graph with centrality measures, community detection algorithms or temporal analysis, in order to trace the evolution of communities and topics within specific citational paths.
References 1. Akujuobi, U., Zhang, X.: Delve: a dataset-driven scholarly search and analysis system. SIGKDD Explor. Newsl. 19(2), 36–46 (2017) 2. Alexander, E., Kohlmann, J., Valenza, R., Witmore, M., Gleicher, M.: Serendip: topic model-driven visual exploration of text corpora. In: 2014 IEEE Conference on Visual Analytics Science and Technology (VAST), pp. 173–182. IEEE (2014) 4
50 input dim, 25 (x2) hidden units, dropout 0.8, L2 penalty 1e-05.
Structured Semantic Modeling of Scientific Citation Intents
475
3. Bai, H., Chen, Z., Lyu, M.R., King, I., Xu, Z.: Neural relational topic models for scientific article analysis. In: Proceedings of the 27th ACM International Conference on Information and Knowledge Management, pp. 27–36 (2018) 4. Breitinger, C., Kolcu, B., Meuschke, M., Meuschke, N., Gipp, B.: Supporting the exploration of semantic features in academic literature using graph-based visualizations. In: Proceedings of the ACM/IEEE Joint Conference on Digital Libraries in 2020, pp. 377–380 (2020) 5. Cho, K., et al.: Learning phrase representations using RNN encoder-decoder for statistical machine translation. In: Proceedings of the 2014 Conference on Empirical Methods in Natural Language Processing (EMNLP), Doha, Qatar, pp. 1724–1734. Association for Computational Linguistics, October 2014 6. Cohan, A., Ammar, W., van Zuylen, M., Cady, F.: Structural scaffolds for citation intent classification in scientific publications. In: Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, NAACL-HLT 2019, Minneapolis, MN, USA, 2–7 June 2019, Volume 1 (Long and Short Papers), pp. 3586–3596 (2019) 7. Jurgens, D., Kumar, S., Hoover, R., McFarland, D., Jurafsky, D.: Measuring the evolution of a scientific field through citation frames. Trans. Assoc. Comput. Linguist. 6, 391–406 (2018) 8. Devlin, J., Chang, M.W., Lee, K., Toutanova, K.: BERT: pre-training of deep bidirectional transformers for language understanding. In: Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers), Minneapolis, Minnesota, pp. 4171–4186. Association for Computational Linguistics, June 2019 ˇ 9. Subelj, L., van Eck, N.J., Waltman, L.: Clustering scientific publications based on citation relations: a systematic comparison of different methods. PLoS ONE 11(4), e0154404 (2016) 10. van Eck, N.J., Waltman, L.: VOS: a new method for visualizing similarities between objects. In: Decker, R., Lenz, H.-J. (eds.) Advances in Data Analysis. SCDAKO, pp. 299–306. Springer, Heidelberg (2007). https://doi.org/10.1007/9783-540-70981-7 34 11. van Eck, N.J., Waltman, L.: CitNetExplorer: a new software tool for analyzing and visualizing citation networks. J. Informetrics 8(4), 802–823 (2014) 12. Ferrod, R., Schifanella, C., Di Caro, L., Cataldi, M.: Disclosing citation meanings for augmented research retrieval and exploration. In: Hitzler, P., et al. (eds.) ESWC 2019. LNCS, vol. 11503, pp. 101–115. Springer, Cham (2019). https://doi.org/10. 1007/978-3-030-21348-0 7 13. Giosa, D., Di Caro, L.: What2Cite: unveiling topics and citations dependencies for scientific literature exploration and recommendation. In: Keet, C.M., Dumontier, M. (eds.) EKAW 2020. LNCS (LNAI), vol. 12387, pp. 147–157. Springer, Cham (2020). https://doi.org/10.1007/978-3-030-61244-3 10 14. Joulin, A., Grave, E., Bojanowski, P., Mikolov, T.: Bag of tricks for efficient text classification. In: Proceedings of the 15th Conference of the European Chapter of the Association for Computational Linguistics: Volume 2, Short Papers, Valencia, Spain, pp. 427–431. Association for Computational Linguistics, April 2017 15. Councill, I.G., Lee Giles, C., Kan, M.-Y.: ParsCit: an open-source CRF reference string parsing package. In: Proceedings of the Language Resources and Evaluation Conference (LREC 2008), Marrakesh, Morrocco, May 2008 16. Kim, J., Kim, D., Oh, A.H.: Joint modeling of topics, citations, and topical authority in academic corpora. Trans. Assoc. Comput. Linguist. 5, 191–204 (2017)
476
R. Ferrod et al.
17. Lo, K., Wang, L.L., Neumann, M., Kinney, R., Weld, D.S.: S2ORC: the semantic scholar open research corpus. In: Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, pp. 4969–4983 (2020) 18. Nagwani, N.: Summarizing large text collection using topic modeling and clustering based on MapReduce framework. J. Big Data 2(1), 6 (2015) 19. Papineni, K., Roukos, S., Ward, T., Zhu, W.J.: BLEU: a method for automatic evaluation of machine translation. In: Proceedings of the 40th Annual Meeting on Association for Computational Linguistics, pp. 311–318. Association for Computational Linguistics (2002) 20. Popescul, A., Ungar, L.H., Flake, G.W., Lawrence, S., Giles, C.L.: Clustering and identifying temporal trends in document databases. In: ADL, p. 173. IEEE (2000) 21. Salatino, A.A., Thanapalasingam, T., Mannocci, A., Osborne, F., Motta, E.: (October) 22. Shotton, S.P.D.: FaBiO and CiTO: ontologies for describing bibliographic resources and citations. In: Web Semantics: Science, Services and Agents on the World Wide Web, vol. 17, pp. 33–43 (2012) 23. Mihalcea, R., Corley, C., Strapparava, C.: Corpus-based and knowledge-based measures of text semantic similarity. In: AAAI 2006 Proceedings of the 21st National Conference on Artificial Intelligence, vol. 1, pp. 775–780 (2006) 24. Swayamdipta, S., Thomson, S., Lee, K., Zettlemoyer, L., Dyer, C., Smith, N.A.: Syntactic scaffolds for semantic structures. In: Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing, Brussels, Belgium, 31 October–4 November 2018, pp. 3772–3782 (2018) 25. Yasunaga, M., et al.: ScisummNet: a large annotated corpus and content-impact models for scientific paper summarization with citation networks. In: Proceedings of the AAAI Conference on Artificial Intelligence, vol. 33, pp. 7386–7393 (2019)
Discovering Research Hypotheses in Social Science Using Knowledge Graph Embeddings Rosaline de Haan1 , Ilaria Tiddi2(B) , and Wouter Beek1
2
1 Triply, Amsterdam, The Netherlands {rosaline.de.haan,wouter}@triply.cc Vrije Universiteit Amsterdam, Amsterdam, The Netherlands [email protected]
Abstract. In an era of ever-increasing scientific publications available, scientists struggle to keep pace with the literature, interpret research results and identify new research hypotheses to falsify. This is particularly in fields such as the social sciences, where automated support for scientific discovery is still widely unavailable and unimplemented. In this work, we introduce an automated system that supports social scientists in identifying new research hypotheses. With the idea that knowledge graphs help modeling domain-specific information, and that machine learning can be used to identify the most relevant facts therein, we frame the problem of hypothesis discovery as a link prediction task, where the ComplEx model is used to predict new relationships between entities of a knowledge graph representing scientific papers and their experimental details. The final output consists in fully formulated hypotheses including the newly discovered triples (hypothesis statement), along with supporting statements from the knowledge graph (hypothesis evidence and hypothesis history). A quantitative and qualitative evaluation is carried using experts in the field. Encouraging results show that a simple combination of machine learning and knowledge graph methods can serve as a basis for automated scientific discovery.
Keywords: Scientific discovery Social science
1
· Knowledge graphs · Link prediction ·
Introduction
Scientific research usually starts with asking a question, followed by doing background research, and then formulating a testable hypothesis. Doing background research to properly substantiate a hypothesis can be a difficult and timeconsuming task for scientists. It is estimated that over 3 million scientific articles are published annually, a number that keeps growing of 4% each year [25]. The fast rate at which new publications appear, as well as the inefficient way in which scientific information is communicated (e.g. PDF documents), calls for c Springer Nature Switzerland AG 2021 R. Verborgh et al. (Eds.): ESWC 2021, LNCS 12731, pp. 477–494, 2021. https://doi.org/10.1007/978-3-030-77385-4_28
478
R. de Haan et al.
more efficient data analysis and synthesis, in a way that scientists formulating new research hypotheses can be supported rather than overloaded. The task of significantly speeding up the steps in the scientific process is generally called automated scientific discovery [15]. The latest years have seen Artificial Intelligence approaches for automated scientific discovery in various scientific fields, either relying on symbolic knowledge representation or machinedriven methods. Knowledge graphs such as the Gene Ontology1 and the ontology collection of the Open Biological and Biomedical Ontology Foundry2 have been used to encode domain-specific information, such as representing biological systems from the molecular to the organism level. Machine Learning and particularly link prediction methods, that help predicting which missing edges in a graph are most likely to exist, have also been used, e.g. to support medical scientists by showing them new associations between drugs and diseases [15,19]. There is currently not much automated support for social scientists when it comes to getting new insights from scientific information. This is partly due to the more qualitative and uncertain nature of social science data, making it hard to represent, and consequently less machine-interpretable [3]. One effort in this direction is the COoperation DAtabank (CODA), where an international team of social scientists published a structured, open-access repository of research on human cooperation using social dilemmas. The dataset represents about 3,000 research publications with their experimental settings, variables of observation, and quantitative results. Given the large amount of structured information available, and the success of predictive methods seen in other disciplines, it is natural to think that a hybrid method could be designed, to automatically suggest social scientists new hypotheses to be tested. Here, we study the problem of automatic hypothesis discovery in the field of social sciences. Following approaches in the biomedical field, we propose to frame our problem as a link prediction task, and particularly to exploit the structured representation of the domain to learn research hypotheses in the form of unseen triples over a knowledge graph describing research papers and their experimental settings. Using knowledge graph embeddings, we predict the likelihood of new possible relationships between entities, consisting in the variables studied social science research. These relationships are then used to provide the experts with new research hypotheses structured in a statement (the newly predicted associations), evidence and history (both triples existing in the graph). We quantitatively and qualitatively assess this approach using experts in the field, which helps us evaluating the accuracy and meaningfulness of the discovered hypotheses. Our novelty is not a the prediction algorithm for automated hypothesis discovery, but rather the hybrid method based on link prediction over knowledge graph data. More specifically, we show: (i) how a thorough structured representation of scientific knowledge helps the automatic discovery of research hypotheses, (ii) how our hybrid method can support experts in formulating new research hypotheses and (iii) a practical application in the field of social science. 1 2
http://geneontology.org/. http://www.obofoundry.org/.
Discovering Research Hypotheses in Social Science Using KG Embeddings
2
479
Related Work
Our work relates to three areas, namely (i) existing methods for representing and mining scientific knowledge, (ii) approaches for automated hypothesis discovery in science and (iii) knowledge graph embedding methods and applications. Representing and Mining Scientific Knowledge. Several methods have been developed to represent scientific knowledge and foster interoperability and reproducibility. Micro- and nanopublications [4,8] have been introduced in the last decade as standardised formats for the publication of minimal scientific claims, i.e. minipublications. Such models allow to describe evidence and nuanced scientific assertions expressing a relationship between two predicates (e.g. a gene relates to a disease), together with provenance information describing both the methods used to derive the assertion and publication metadata. The DISK hypothesis ontology [7] was introduced to capture the evolution of research hypotheses in the neuroscience field, including the provenance and revisions. More precisely, a DISK hypothesis consists of structured assertions (hypothesis statement), some numerical confidence level (hypothesis qualifier), the information of the analysis that were carried out (hypothesis evidence), and prior hypotheses revised to generate the current one (hypothesis history). In the field of medical science, the different elements to be included in a hypothesis can be described with the PICO ontology3 , describing Patients, the Condition or disease of interest and its alternative (Intervention), and the Outcome of the study. Repositories for storing scientific publications at large scale in the form of knowledge graphs include both domain-specific initiatives (e.g. the AI-KG [5] for Computer Science and the Cooperation Databank [22] for the social sciences), and domain-independent projects such as the Open Research Knowledge Graph (ORKG) project4 . These initiatives focus on representing research outputs in terms of their content, i.e. describing approach, evaluation methods, results etc., rather than publication context such as year, authors and publication venues. This type of novel representations allows to automatise not only the search for new research, but also to compare it at large scale. Some work has focused on developing systems that aid with mining claims in the existing literature. The AKminer (Academic Knowledge Miner) system [9] was introduced to automatically mine useful concepts and relationships from scientific literature and visually present them in the form of a knowledge graph. Similarly, [17] uses text-mining to automatically extract claims and contributions from scientific literature and enrich them through entity linking methods. Supervised distant learning was used by [14,24] to extract PICO sentences from clinical trial reports and support evidence-based medicine. Machine-Supported Hypothesis Discovery. Automated hypothesis discovery using intelligent systems has been interest of study for a long time. Earliest work include the ARROWSMITH discovery support system [21] to help scientists in finding complementary literature for their studies and formulate a 3 4
https://linkeddata.cochrane.org/pico-ontology. https://www.orkg.org/orkg/.
480
R. de Haan et al.
testable hypothesis based on the two sets, and the work of [1], which used various machine learning techniques to discover patterns, co-occurrences and correlations in biological data. These approaches inspired the work of [20], which relies on a scientific text collection to discover hypotheses, via Medical Subject Headings (MeSH)-term based text-mining. Biomedical literature was also used by [10] to develop a link discovery method based on classification, where concepts are learnt and used as a basis for hypothesis generation. An Inductive Matrix Completion method was presented by [12], where the discovered gene-disease associations where supported by different types of evidence learnt as latent factors. The Knowledge Integration Toolkit (KnIT) [11] used methods such matrix factorization and graph diffusion to reason over a network of scientific publications in the biomedical field to generate new and testable hypotheses. The work of [15] shows how scientific insights can be generated using machine support also in the field of astronomy and geosciences. Their model allows to create multiple variants of hypothesised phenomena and their corresponding physical properties; these are matched in the existing empirical data, and scientists can both refine them and use them to justify a stated research hypothesis. The DISK ontology was also used in the field of neuroscience for automated hypothesis assessment [6]. Knowledge Graph Embeddings for Link Prediction. Machine learning methods for knowledge graph completion (or link prediction) use inductive techniques, mostly based on knowledge graph embeddings or rule/axiom mining, to locally and logically predict the likelihood of certain link between two nodes to exist [13]. Currently, the tensor decomposition ComplEx method [23] has proven to be the most stable in terms of performance and scalability [2]. Link prediction methods have been previously used for hypothesis discovery. Authors of [16] first create a knowledge graph from biomedical data and then convert it to a lower dimensional space using graph embeddings. The learnt embeddings are then used to train a recurrent neural network model to predict new drug therapies against diseases. A similar approach is the one of [19] to generate hypotheses on re-purposing drugs for rare diseases; the method relies on graph embeddings learnt over a large knowledge graph including information from the literature of pharmacology, genetics and pathology.
3
Background and Motivating Scenario
The COoperation DAtabank Knowledge Graph. The COoperation DAtabank consists in ∼3,000 studies from the social and behavioural sciences published in 3 languages and annotated with more than 300 cooperation-related features, including characteristics of the sample participating in the study (e.g. sample size, average age of sample, percentage of males, country of participants), characteristics of the experimental paradigm (structure of the social dilemma, incentives, repeated trial data), and quantitative results of the experiment (e.g. mean levels of cooperation, variance in cooperation, and effect sizes). The dataset was designed to be fully compliant with the F.A.I.R. principles, and has been
Discovering Research Hypotheses in Social Science Using KG Embeddings
481
published as an openly available knowledge graph5 to allow domain experts to perform their analyses in minutes, instead of many months of painstaking work [22]. Before continuing with the knowledge graph structure, we need to familiarise the reader with the basic concepts of experimental science. Studies using this methodology may observe a relation between two (one independent, one dependent) variables, which can be quantified as an effect size (representing the quantitative result). The goal of the single experiments carried within in a study is to test whether the dependent variable (DV) changes for when modifying the value of the Independent Variable (IV), which indicates there is a relationship between the two variables. In the case of the Databank, one could imagine an experiment aimed at studying the impact (effect size) of a person’s social values (independent variable) over her willingness to cooperate (dependent variable). With this in mind, the CODA knowledge graph includes publications consisting of a cdo:Paper class that links to an arbitrary set of cdo:Study, i.e. experiments performed in different settings and with different goals. Additional metadata about the paper such as publication date, authors etc. are included as properties of a cdo:DOI class. Each cdo:Study links to one or more conditions tested, represented by the class cdo:Observation, that are in turn modelled as comparisons of one or two different cdo:Treatment.
Fig. 1. Example of an observation comparing prosocial vs. proself behaviour.
In a practical example, Fig. 1 shows the paper :CHI00001 including the study :CHI00001 1, which in turns reports the observation :CHI00001 1.1.1.2.d comparing treatment :CHI00001 1.1.1 and :CHI00001 1.1.2 (we call them T1 and T2 for simplicity). Treatments consist in the experimental settings that the experimenter modifies with the goal of testing how and if the cooperation between 5
http://data.cooperationdatabank.org/.
482
R. de Haan et al.
participants of a game varies significantly. In our example, the experimenter manipulated the property cdp:svoType which, recalling what stated above, consists then in the independent variable observed. This is confirmed by the fact that T1 and T2 have a different value for the property (:prosocial and :proself respectively). Similar to cdp:svoType, any RDF property whose domain is the class cdo:Treatment is organised in a domain-specific taxonomy of independent variables, representing information relative to cooperation in social dilemmas. Finally, in order to represent how and how much the cooperation varies during an observation/experiment, we use the class cdo:DependentVariable for the DV and the datatype property cdp:esEstimate for the effect size measurement, e.g. CHI00001 1.1.1.2.d measures the DV :contributions and its effect size has a value of 0.776 . The positive effect size reported by the experimental observation means that T1 scored higher on cooperation than T2, indicating that participants with a pro-social value orientation showed a more cooperative behaviour than participants who had a pro-self value orientation. Challenge, Solution and Novelty. In the scenario above, it is natural to see how the CODA knowledge graph intrinsically represents research hypotheses that were tested in the human cooperation literature. In other words, one can consider each cdo:Observation subgraph as a research hypothesis that aims at testing whether there exists a relation between the cdo:IndependentVariable and cdo:DependentVariable. The effect size value of each observation then tells us the strength of such relation, identified by the experiment performed to validate the hypothesis. The research question we ask is therefore: is it possible to learn new, plausible observations starting for the representations recorded in CODA? More generally, how to support domain experts in producing new research hypotheses through a more automated method? The solution we propose is to frame the problem of learning research hypotheses as a link prediction task, where we exploit the existing cdo:Observation subgraph structures to learn new unseen triples involving a cdo:IndependentVariable and cdo:DependentVariable. Our hypothesis is that entities and relationships neighbouring the predicted links can help completing the new research hypotheses. Our work main novelty is applying a hybrid method to automatically support social scientists for the first time, following similar approaches in the biomedical field. We train a knowledge graph embedding model to predict the likelihood of a new possible association between an IV and a DV. We then develop a system that suggests new possible research hypotheses including both triples existing in CODA and new predicted triples according to a predefined structure. Accuracy and meaningfulness of the discovered hypotheses are assessed quantitatively and qualitatively in a userstudy based on the domain expertise of social scientists from the field.
6
CODA contains two types of effect size measures, i.e. the correlation coefficient ρ and the standardized mean difference d, which can be easily converted to one another. For simplicity, we will only refer to Cohen’s d values from now on.
Discovering Research Hypotheses in Social Science Using KG Embeddings
4
483
Approach
The proposed approach includes three steps: a pre-processing phase for data selection and generation of the model input (Sect. 4.1), a learning phase including parameter tuning, model training, and link prediction (Sect. 4.2), and a last phase for the automated generation of hypotheses (Sect. 4.3). 4.1
Pre-processing
The first step is to choose the right amount of CODA information to retrieve, and create an input for the embedding model to be able to predict new triples. Observation Selection. First, we define a set of criteria to select the CODA observations, namely: 1. 2. 3. 4.
instances of the class cdo:Observation; observations reporting using Cohen’s d as effect size measure; observations comparing two treatments; observations linking to an instance of a cdo:DependentVariable.
The SPARQL query used to get the observations can be found online7 , and results in 4,721 observations, the study, paper and DOI that reported them, the effect size with confidence levels, the experimental design, and sample size and standard deviation per treatment pair. A further refinement is performed by analysing the independent variables of each observation. We identify the properties-values for which the two treatments compared by an observation differ on, e.g. cdp:svoType/:prosocial vs. cdp:svoType/:proself in the example of the previous section. To prevent noise and reduce complexity, we dropped observations that had no differing predicates (errors attributed to the large sparsity of the data and to human annotation), or that might differ for more than one property. This left 2,444 observations to train the model, coming from 632 papers and 858 studies, and including 128 unique IVs and 2 unique DVs. Data Permutation. Since KG embedding methods are generally not capable of learning continuous variables, we learn effect sizes as categorical instead of continuous information. This is also motivated by the fact that Cohen’s d is in fact a measure that can be interpreted categorically [18]. To this end, we created a new RDF property cdp:esType and a set of 5 instances of the class cdo:ESType that a cdo:Observation might point to, representing the 5 bins mapping the continuous effect size values to Cohen’s categories8 . Table 1 shows the ranges for each bin/instance, and their respective effect size types.
7 8
https://data.cooperationdatabank.org/coda/-/queries/link-prediction-selectionquery. Due to the relatively small sets, medium and large effects were grouped together.
484
R. de Haan et al.
Table 1. Effect size ranges, their interpretation and the respective instance created. Effect size range Intepretation
Instance
–Infinity, –0.5
Large/medium negative correlation :largeMediumNegativeES
–0.5, –0.2
Small negative correlation
–0.2, 0.2
No correlation
:nullFinding
0.2, 0.5
Small positive correlation
:smallPositiveES
0.5, infinity
Large/medium positive correlation :largeMediumPositiveES
:smallNegativeES
As also explained in Sect. 3, an effect size is an indication of the size of the correlation between an independent and a dependent variable, measured based on the different IV values that two treatments take during an experimentation. This means that, in order to predict a new correlation between IV and DV, one would have to predict multiple triples, i.e. at least one per treatment (and their respective IV values). In order to simplify the task, we summarise the factor that influences the effect size into a single node, by considering IV values pairs as single hypotheses. We therefore combine all possible values for a given IV property into pairs, assigning a hypothesis number to each pair, and create a new node that is linked to the original T1/T2 values through the property cdp:hypothesis. The new nodes, shown e.g. in Table 2, are then used for the hypothesis generation. For continuous properties reporting many different values in the object position, four different ranges were automatically created to prevent the generation of an excessive amount of hypotheses. Similarly, pairs with the same IV values in a different order were considered as the same hypothesis (e.g. T1 = proself/T2 = prosocial and T1 = prosocial/T2 = proself were both linked to :SVOtypeH2), but the effect size node of the observation was switched (positive to negative, or vice versa) to maintain the direction of the correlation coherent. Table 2. Hypothesis nodes based on combinations of IV values for T1 and T2. IV
T1 value
T2 value Hypothesis node
SVO type Individualist Prosocial :SVOtype H1 SVO type Prosocial
Proself
SVO type Individualist Altruist
:SVOtype H2 :SVOtype H3
We then link the created hypothesis nodes to the dependent variable nodes using three new predicates, related to the type of correlation that is observed: cdp:hasPositiveEffectOn, cdp:hasNoEffectOn, cdp:hasNegativeEffectOn. These properties are based on the statistical significance of the observation, computed using the 95% confidence interval for the effect size. A confidence interval measures the imprecision of the computed effect size in an experiment. When the interval does not include 0, it can be inferred that the association is statistically
Discovering Research Hypotheses in Social Science Using KG Embeddings
485
significant (p < 0.05). In other words, the confidence interval tells us how trustworthy is the observation we are analysing, in terms of effect size, population estimate, and direction of the effect. Depending on the confidence interval, we use :hasNoEffectOn if the effect size is not significant, while :hasNegativeEffectOn and :hasPositiveEffectOn are used with observations indicating a significant negative and positive correlation between IV and DV, respectively. When no confidence interval was given in the data, we derive the direction of the correlation using the rule of thumb as reported of [18]: observations with an effect size below −0.2 got a negative effect property, observations that reported effect sizes above 0.2 got a positive effect property, and observations with an effect size between –0.2 and 0.2 got a no effect property. This led us to a total of 751 positive effect triples, 1,017 no effect triples and 676 negative effect triples. Dataset Creation. The last step of the pre-processing task consists in the conversion into learnable subgraphs, i.e. sets of triples. To do this, we use part of the information already in the data, namely observation ID, the independent and dependent variables, the IV values for the two treatments, and combine them with the computed effect size type, the hypothesis number, and relationship to the dependent variable. A construct query9 was used to generate subgraphs as depicted in Fig. 2 for 2,444 observations. This led to a dataset of 29,339 triples, that served as input for the link prediction model.
Fig. 2. New graph for the observation CHI00001 1.1.1.2.d used as input for the link prediction task. In red, the nodes and edges created. In bold, the link to be predicted. (Color figure online)
9
https://data.cooperationdatabank.org/coda/-/queries/Rosaline-Construct-LinkPrediction.
486
R. de Haan et al. Table 3. Final parameter configuration.
4.2
Parameter
Value
Batches count
555
Epochs
100
k (dimensionality)
200
eta (# neg. samples generated per each pos.)
15
Loss
multiclass nll
Embedding model params
{‘negative corruption entities’: ‘all’}
LP regulariser params
{‘p’:1, ‘lambda’:1e-5}
Xavier initialiser params
{‘uniform’: False}
Adam optimizer params
{‘lr’: 0.0005}
Learning and Predicting Triples
Training and Testing. We use the created dataset to learn a model predicting unseen triples to be used in new hypotheses. Strictly speaking, the prediction consists in identifying triples including a hypothesis number, an effect size predicate and a dependent variable, e.g. :SVOtype H2 cdp:hasPositiveEffectOn :contributions. To do this, all triples reporting a negative or a positive effect were gathered. We decided not to make predictions for the no-effect triples, as experts might be less interested in non-interesting relations between variables to frame their hypotheses. Investigating this for future work could be interesting. From the total 1,427 effect triples, the 243 unique hypotheses in subject position, the 2 unique predicates and the 2 unique dependent variables in object position were used to learn how to generate new combinations. This yielded to 243 ∗ 2 ∗ 2 = 972 total triples, of which 412 were already in the dataset and marked as “seen”, while the other 560 were denoted as “unseen”. We used the ComplEx model to learn the likelihood of each triple. We first split the dataset into a training set of 24,539 triples, a test set of 2,400 triples, and a validation set of 2,400 triples. A corruption strategy is then used to generate negative statements. Parameter tuning was finally performed to explore impact on the model performance, see Table 3 for the final configuration. Standard metrics such as mean reciprocal rank, hits@N and mean rank were used to evaluate the trained model. Link Prediction. The learnt model was used to compute ranks and scores for unseen triples. Ranks indicate the position at which the test set triple was found when performing link prediction, while scores are the returned raw scores generated by the model. Probabilities of unseen triples are also calculated by calibrating the model. We set a positive base rate of 0.5 (50%) to indicate the ratio between positive vs. negative triples. After calibration, a probability for each
Discovering Research Hypotheses in Social Science Using KG Embeddings
487
unseen triple was predicted. We then obtained their ranks, score and probabilities for the 560 unseen triples, to be later used during the hypotheses generation step. A sample of these is in Table 4 below. Table 4. Prediction example of unseen triples. Statement
Rank Score Prob.
:iteratedStrategy H6 cdp:hasPositiveEffectOn :cooperation
1
7.38
0.98
:iteratedStrategy H9 cdp:hasPositiveEffectOn :cooperation
2
7.32
0.98
...
4.3
:uncertaintyTarget H1 cdp:hasPositiveEffectOn :cooperation
3816
0.10
:exitOption H1 cdp:hasNegativeEffectOn :contributions
4659
−0.03 0.17
0.19
Hypotheses Generation
The final step is to automatically generate human-interpretable hypotheses, based on the unseen triples predicted by the model. Each statement from Table 4 was converted into a readable text using a prefixed structure following the DISK ontology. A hypothesis statement was created by disassembling the triples into respectively the independent variable (the predicted subject), the type of effect (the predicted predicate) and dependent variable (the predicted object). The hypothesis evidence was created by querying the CODA knowledge graph for labels of both IVs and DVs, and by converting the effect type property into decapitalised words with spacing. We also retrieve the description of both the IV class and the relevant IV values. The hypothesis history was built by retrieving the DOIs of papers that studied that combination of IV values. An example of a generated hypothesis is shown below.
488
R. de Haan et al. Hypothesis Statement Partner’s group membership has negative effect on contributions Hypothesis Evidence Dependent Variable (DV): dependentvariable/contributions
https://data.cooperationdatabank.org/id/
Independent Variable (IV): https://data.cooperationdatabank.org/vocab/ prop/targetMembership Whether the participant is interacting with a partner identified as ingroup, outgroup, or stranger. The IV values to compare in the treatments (T1, T2) are : Description Treatment IV value T1 ingroup Partner(s) is a member of the participant’s group ingroup and When an experimental treatment explicitly proT2 outgroup vides information that a partner or group belongs to both an ingroup and an outgroup Hypothesis History http://dx.doi.org/10.1016/j.joep.2013.06.005 http://dx.doi.org/10.1177/0146167205282149 http://dx.doi.org/10.1016/j.ijintrel.2011.02.017
Implementation. The current approach was implemented using Python 3.7.7. The ComplEx model was implemented using the Ampligraph10 library. All the code and results can be found on GitHub11 . The queries were made using the SPARQL API service of the CODA knowledge graph, hosted by TriplyDB12 .
5
Evaluation
We first quantitatively and qualitatively evaluate the model performance through known metrics and inspection of the independent variable embeddings. We then evaluate the generated hypotheses through domain experts. 5.1
Model Performance
We compare our model to the TransE, ComplEx and DistMult models trained with their default parameters. The resulting performance metrics are shown in Table 5. We used three different types of metrics as indication of how well the models were capable of predicting the triples in the test set: mean reciprocal rank (MRR), hits@N, and mean rank (MR). Reciprocal rank measures the correctness |Q| 1 1 of a ranked triple, and mean RR is defined as M RR = |Q| i=1 ranki , where Q 10 11 12
https://github.com/Accenture/AmpliGraph. https://github.com/roosyay/CoDa Hypotheses. https://coda.triply.cc/.
Discovering Research Hypotheses in Social Science Using KG Embeddings
489
is the number of triples and ranki the rank of the i th triple predicted by the model. Hits@N indicates how many triples are ranked in the top N positions when 1 ranked against corruptions, i.e.: Hits@N = |Q| (s,p,o)∈Q ind(rank(s, p, o) ≤ N) where Q is the triples in the test set, (s, p, o) is a triple ∈ Q, and ind (·) is an indicator function returning 1 if the positive triple is in the top N triples, 0 otherwise. We use three values for N , namely 1, 3 and 10. Finally, the MR score is the sum of the true ranks divided by the total amount of ranks, defined as |Q| 1 M R = |Q| i=1 rank(s,p,o)i . Note that the MR score is not robust to outliers, and is therefore only taken into account together with the other metrics. Overall, these scores indicate a reasonable performance of ComplEx, and confirm our idea that link prediction methods in general can be used for hypothesis discovery. Some room for improvement is left for future work, namely applying our method to other datasets, and fine-tuning additional machine learning techniques. Table 5. Model comparison. MRR Hits@10 Hits@3 Hits@1 MR
5.2
ComplEx
0.60
0.66
0.62
0.56
736.77
DistMult
0.48
0.62
0.57
0.38
683.31
TransE
0.30
0.46
0.35
0.20
330.42
Tuned ComplEx 0.68
0.75
0.69
0.64
279.91
Qualitative Analysis
To get insight into how the model effectively learnt the data, we created a visualisation of the main independent variables (see Fig. 3). To do this, the 400dimensional embeddings of 128 unique independent variables were retrieved from the trained model and transformed into an array of (128, 400). We used a UMAP reduction to reduce the 400 dimensions to 2 only, allowing then to display the embeddings in a 2-dimensional space. In order to find the optimal number of clusters in this space, we used an elbow method measuring the Within-Cluster Sums of Squares (WCSS) without finding any significant distinction. We therefore used a silhouette analysis, revealing that 23 clusters was the best balance between the number of clusters and a relatively high silhouette score (silhouette score = 0.49). Clusters were obtained using scikit-learn’s KMeans (K = 23) and the visualisation was obtained using the Matplotlib package. As shown in Fig. 3, most clusters are groups of variables that are rdfs:subClassOf the same class. For example, in clusters 3, 11 and 15, all the variables related to respectively punishment, emotion and leadership are clustered together. Clusters such as 2 and 13 seem to have less cohesion, as no overarching topics can be found that group IVs together. This can be due by a larger variety of the studies that analysed these IV, and potentially a lack of more data. Both clusters also include variables related to reward, showing that studies with reward-related IV are more heterogeneous and were not grouped together.
490
R. de Haan et al.
Fig. 3. Independent variables grouped in 23 clusters. Please cfr. Visualisation.ipynb on Github for better quality.
5.3
Domain Expert Evaluation
In order to qualitatively evaluate the generated hypotheses, 5 domain experts from the CODA team were asked to fill out a user-study. A Google form was created where the experts, after receiving information about the background and the goal of the study, were shown the 10 most likely and 10 most unlikely hypotheses predicted by the model. The 20 hypotheses were shown in a random order using the structure presented in Sect. 4.3. The experts were asked to indicate which 10 hypotheses they considered likely, and which 10 unlikely. A final part for remarks was also included. Table 6 shows how the experts rated the likelihood of the hypotheses. These can be easily read as “[Hypothesis Statement] when comparing [T1 value] vs. [T2 value]”, e.g. “SVO type has negative effect on cooperation when comparing a group of individualists vs. a group of competitors”. Two hypotheses including miscellaneous IV values did not make sense according to the experts and were omitted. Overall, the majority of the experts rated 12 out of 18 hypotheses as
Discovering Research Hypotheses in Social Science Using KG Embeddings
491
Table 6. Expert evaluation. #L and #UL refer to the number of experts scoring a hypothesis as likely and unlikely, respectively. Pred. indicates the model prediction.
1 2
3
4
5 6 7 8
9 10 11 12 13 14
15
16
17
18
Hypothesis statement
T1 value
T2 value
#L #UL Pred.
MPCR has positive effect on contributions Partner’s group membership has negative effect on contributions Intergroup competition has positive effect on contributions Anonymity manipulation has positive effect on cooperation Time pressure has negative effect on contributions SVO type has negative effect on cooperation Ethnicity (us) has positive effect on cooperation Iterated strategy has positive effect on cooperation Nationality has negative effect on contributions Exit option has negative effect on contributions Exit option has positive effect on contributions Emotion has negative effect on cooperation Emotion has positive effect on cooperation Preference for conditional cooperation has negative effect on cooperation Uncertainty target has positive effect on cooperation Iterated strategy has positive effect on contributions Preference for conditional cooperation has positive effect on cooperation Uncertainty target has negative effect on cooperation
(−0.401, 0.3)
(0.3, 0.5)
3
2
Likely
Ingroup
Ingroup and outgroup
0
5
Likely
Individual group
Intergroup competition
4
1
Likely
High
Low
3
2
Likely
Time-pressure
Time delay
2
3
Likely
Individualist
Competitor
3
2
likely
White
Black or African American Other
1
4
Likely
4
1
Likely
JPN
AUS
3
2
Unlikely
0
1
2
3
Unlikely
0
1
1
4
Unlikely
Neutral
Disappointment
2
3
Unlikely
Neutral
Disappointment
2
3
Unlikely
Freeriders
Hump-shaped contributors
4
1
Unlikely
Loss
Threshold
4
1
Unlikely
Tit-for-tat
Tit-for-tat+1
1
4
Unlikely
Freeriders
Hump-shapedcontributors
1
4
Unlikely
Loss
Threshold
0
5
Unlikely
Predominantly cooperative
the model did, while only 6 hypotheses were rated opposite of the model. Out of 5 experts, 2 rated more than 9 hypotheses the same as the model, which is higher than chance level, while the other 3 experts scored exactly on chance level. No experts scored below chance level. It should be noted that some experts took more time to fill the evaluation form, as they provided more details in the open-ended questions, and some variety could be seen in how experts rated the hypotheses. We relate this to the complexity of social science data, causing
492
R. de Haan et al.
different perspectives to reach different conclusions. Looking at the overall average however, the experts rated 10 hypotheses the same as the model did. This shows that the model output is not random, and that similarities between the expert opinions and the model were found. More in general, we consider our results encouraging enough to confirm the idea that a link prediction-based approach is a valuable method to predict hypotheses over structured data.
6
Conclusions
We have introduced a hybrid approach to automatically support domain experts to identify new research hypotheses. Our novel solution is based on a link prediction task over a knowledge graph in the social science domain, where new edges between nodes are predicted in order to create fully formulated hypotheses in the form of a hypothesis statement, a hypothesis evidence and a hypothesis history. The quantitative and qualitative evaluation carried using experts in the field has shown encouraging results, namely that a simple combination of machine learning and knowledge graphs methods can support designing more complex systems for the automated scientific discovery. Improvements of our approach could be made as future work, namely by optimising the data modelling and the machine learning approach for social science data. Such type of data has in fact an uncertain nature, and missing information can create an inner bias in the model and have implications for the results. Solutions to cope with such bias should be investigated. As mentioned, the approach should be also tested on datasets of different domains to see how it could perform. Some information from the data was lost due to binning continuous variables (including effect size values), and the learning task could be improved on this aspect. An end-to-end task could be envisioned to learn the subgraphs directly, instead of pre-processing them and reducing the task to predicting one link between two entities. Finally, our model generally predicted only links with the highest probabilities based on statistical frequency learnt from the data structure. An interesting avenue would be to investigate what makes an hypothesis interesting other than popularity, and how to learn them.
References 1. Bahler, D., Stone, B., Wellington, C., Bristol, D.W.: Symbolic, neural, and Bayesian machine learning models for predicting carcinogenicity of chemical compounds. J. Chem. Inf. Comput. Sci. 40(4), 906–914 (2000). https://doi.org/10. 1021/ci990116i 2. Bianchi, F., Rossiello, G., Costabello, L., Palmonari, M., Minervini, P.: Knowledge graph embeddings and explainable AI (April 2020). https://doi.org/10.3233/ SSW200011 3. Chen, N.C., Drouhard, M., Kocielnik, R., Suh, J., Aragon, C.R.: Using machine learning to support qualitative coding in social science: shifting the focus to ambiguity. ACM Trans. Interact. Intell. Syst. 8(2), 1–3 (2018). https://doi.org/10.1145/ 3185515
Discovering Research Hypotheses in Social Science Using KG Embeddings
493
4. Clark, T., Ciccarese, P.N., Goble, C.A.: Micropublications: a semantic model for claims, evidence, arguments and annotations in biomedical communications. J. Biomed. Semant. 5(1), 1–33 (2014). https://doi.org/10.1186/2041-1480-5-28 5. Dess`ı, D., Osborne, F., Reforgiato Recupero, D., Buscaldi, D., Motta, E., Sack, H.: AI-KG: an automatically generated knowledge graph of artificial intelligence. In: Pan, J.Z., et al. (eds.) ISWC 2020. LNCS, vol. 12507, pp. 127–143. Springer, Cham (2020). https://doi.org/10.1007/978-3-030-62466-8 9 6. Garijo, D., et al.: Towards automated hypothesis testing in neuroscience. In: Gadepally, V., et al. (eds.) DMAH/Poly -2019. LNCS, vol. 11721, pp. 249–257. Springer, Cham (2019). https://doi.org/10.1007/978-3-030-33752-0 18 7. Garijo, D., Gil, Y., Ratnakar, V.: The DISK hypothesis ontology: capturing hypothesis evolution for automated discovery. CEUR Workshop Proc. 2065, 40–46 (2017) 8. Groth, P., Gibson, A., Velterop, J.: The anatomy of a nanopublication. Inf. Serv. Use 30(1–2), 51–56 (2010). https://doi.org/10.3233/ISU-2010-0613 9. Huang, S., Wan, X.: AKMiner: domain-specific knowledge graph mining from academic literatures. In: Lin, X., Manolopoulos, Y., Srivastava, D., Huang, G. (eds.) WISE 2013. LNCS, vol. 8181, pp. 241–255. Springer, Heidelberg (2013). https:// doi.org/10.1007/978-3-642-41154-0 18 10. Katukuri, J.R., Xie, Y., Raghavan, V.V., Gupta, A.: Hypotheses generation as supervised link discovery with automated class labeling on large-scale biomedical concept networks. BMC Genomics 13(Suppl 3), 12–15 (2012). https://doi.org/10. 1186/1471-2164-13-s3-s5 11. Nagarajan, M., et al.: Predicting future scientific discoveries based on a networked analysis of the past literature. In: Proceedings of the 21th ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, pp. 2019–2028 (2015) 12. Natarajan, N., Dhillon, I.S.: Inductive matrix completion for predicting genedisease associations. Bioinf. 30(12), 60–68 (2014). https://doi.org/10.1093/ bioinformatics/btu269 13. Nickel, M., Murphy, K., Tresp, V., Gabrilovich, E.: A review of relational machine learning for knowledge graphs (2016). https://doi.org/10.1109/JPROC. 2015.2483592 14. Nye, B., et al.: A corpus with multi-level annotations of patients, interventions and outcomes to support language processing for medical literature. In: ACL 2018, vol. 1, pp. 197–207 (2018). https://doi.org/10.18653/v1/p18-1019 15. Pankratius, V., et al.: Computer-aided discovery: toward scientific insight generation with machine support why scientists need machine support for discovery search. IEEE Intell. Syst. 31(4), 3–10 (2016). https://doi.org/10.1109/MIS.2016. 60 16. Sang, S., et al.: GrEDeL: a knowledge graph embedding based method for drug discovery from biomedical literatures. IEEE Access 7(2016), 8404–8415 (2019). https://doi.org/10.1109/ACCESS.2018.2886311 17. Sateli, B., Witte, R.: Semantic representation of scientific literature: bringing claims, contributions and named entities onto the Linked Open Data cloud. PeerJ Comput. Sci. 2015(12), 1-e37 (2015). https://doi.org/10.7717/peerj-cs.37 18. Sawilowsky, S.S.: New Effect Size Rules of Thumb. J. Mod. Appl. Stat. Methods 8(2), 597–599 (2009). https://doi.org/10.22237/jmasm/1257035100
494
R. de Haan et al.
19. Sosa, D.N., Derry, A., Guo, M., Wei, E., Brinton, C., Altman, R.B.: A literaturebased knowledge graph embedding method for identifying drug repurposing opportunities in rare diseases. Pacific Symposium on Biocomputing 25, 463–474 (2020). https://doi.org/10.1142/9789811215636 0041 20. Srinivasan, P.: Text mining: generating hypotheses from MEDLINE. J. Am. Soc. Inf. Sci. Technol. 55(5), 396–413 (2004). https://doi.org/10.1002/asi.10389 21. Swanson, D.R., Smalheiser, N.R.: An interactive system for finding complementary literatures: a stimulus to scientific discovery. Artif. Intell. 91(2), 183–203 (1997). https://doi.org/10.1016/S0004-3702(97)00008-8 22. Tiddi, I., Balliet, D., ten Teije, A.: Fostering scientific meta-analyses with knowledge graphs: a case-study. In: Harth, A., et al. (eds.) ESWC 2020. LNCS, vol. 12123, pp. 287–303. Springer, Cham (2020). https://doi.org/10.1007/978-3-03049461-2 17 23. Trouillon, T., Welbl, J., Riedel, S., Ciaussier, E., Bouchard, G.: Complex embeddings for simple link prediction. In: 33rd International Conference on Machine Learning, ICML 2016, vol. 5, pp. 3021–3032 (2016) 24. Wallace, B.C., Kuiper, J., Sharma, A., Zhu, M., Marshall, I.J.: Extracting PICO sentences from clinical trial reports using supervised distant supervision (2016) 25. Ware, M., Mabe, M.: The STM report: an overview of scientific and scholarly journal publishing (2015)
Problems to Solve Before You Die
Towards a Linked Open Code Ahmed El Amine Djebri1 , Antonia Ettorre1 , and Johann Mortara2(B) 1
Universit´e Cˆ ote d’Azur, Inria, CNRS, I3S, Sophia Antipolis, France {ahmed-elamine.djebri,antonia.ettorre}@univ-cotedazur.fr 2 Universit´e Cˆ ote d’Azur, CNRS, I3S, Sophia Antipolis, France [email protected]
Abstract. In the last two decades, the Linked Open Data paradigm has been experiencing exponential growth. Regularly, new datasets and ontologies are made publicly available, and novel projects are initiated to stimulate their continuous development and reuse, pushing more and more actors to adhere to the Semantic Web principles. The guidelines provided by the Semantic Web community allow to (i) homogeneously represent, (ii) uniquely identify, and (iii) uniformly reference any piece of information. However, the same standards do not allow defining and referencing the methods to exploit it: functions, procedures, algorithms, and code in general, are left out of this interconnected world. In this paper, we present our vision for a Web with Linked Open Code in which functionscould be accessed and used as Linked Data, allowing logic harnessing the latter to be semantically described and FAIR-ly accessible. Hereafter, we describe the challenges presented by the implementation of our vision. We propose first insights on how to concretize it, and we provide a non-exhaustive list of communities that could benefit from such an ideal. Keywords: Semantic Web · Ontologies Linked data · Linked open code
1
· Feature identification ·
Introduction
The Web is growing stronger semantically. More ready-to-consume data, services, and AI-based systems relying on Semantic Web are regularly published. We witness the emergence of the Semantic Web in different unrelated fields such as AI, IoT, networking, medicine, or biology. Within each, papers are being published, wikis are being created, and code is made available. All these different fields share their data through a unique structure, reaching the vision of Tim Berners-Lee who mentioned: “Semantic Web promotes this synergy: even agents that were not expressly designed to work together can transfer data among themselves when the data come with semantics.” [1]. While Semantic Web offers ways to store metadata to reuse them semantically, code is not used on the Semantic Web to its full potential. Hence, the c Springer Nature Switzerland AG 2021 R. Verborgh et al. (Eds.): ESWC 2021, LNCS 12731, pp. 497–505, 2021. https://doi.org/10.1007/978-3-030-77385-4_29
498
A. E. A. Djebri et al.
problem we seek to tackle is: how to take advantage of code as a pre-existing, structured, and functional type of data in Semantic Web? Code for data manipulation is actually either (i ) not needed for simple operations as existing standards offer sufficient functionalities (e.g. functions in SPARQL [2]) or (ii ) used at a higher level in the Semantic Web stack, where users download and build code from open repositories provided to them by the data provider. However, these two approaches exhibit some limitations: in (i ), the capacities of SPARQL functions are limited and in (ii ), despite the availability of the code on the Web, the possibility to have a link between the semantics of data and the semantics of code is not fully harnessed. We believe that code should be treated as a special type of data. The use of functions or methods on Semantic Web is usually studied for limited use-cases, such as schema validation (i.e. sh:JSFunction representing JavaScript functions to be used in SHACL engines). We think that the link between code and Semantic Web remains superficial. Functions are not semantically shared as and with data. We argue that functions, as parts of code, are easily referenceable and can be identified by a defined set of metadata. However, defining their semantics is challenging as functions can be seen from different levels of granularity. Finally, although source code can already be browsed and referenced online at multiple levels of granularity by platforms such as Software Heritage [3] or GitHub’s permalinks, they do not provide any description of the functionality implemented by the code, thus limiting the code reusability.
2
Code on Semantic Web
Data published on the Semantic Web are often followed by instructions on how to access, read, manipulate, and query them. Ontologies are documented in scientific literature and wikis, offering insights on their semantics, and tools for data manipulation are being provided. An increasing number of developers give open access to public source code repositories hosted on data providers such as GitHub. Academics can publish code directly alongside their paper1 for frameworks they developed, encouraged by new policies from editors to foster reproduction and reuse of research results2 . In contrast with Linked Data, code files are often seen as single documents on the Web as the transition between the document-based view and the data-based one has not affected them on a fine-grained level. Hence, the link between data and the code artifacts directly involved with it remains limited. We believe that since both resources (data and code artifacts related to them) are available on the Web, an effort should be made to provide code in the same format as and alongside data.
1 2
https://blog.arxiv.org/2020/10/08/new-arxivlabs-feature-provides-instant-accessto-code/. https://www.acm.org/publications/policies/artifact-review-and-badging-current.
Towards a Linked Open Code
2.1
499
Adapting Code to Semantic Web
According to the Web Service Modeling Ontology Primer (WSMO) [4], a function is not only a syntactical entity but also has defined semantics that allows evaluating the function if concrete input values for the parameters are given. However, the structure of functions defined in most programming languages is more complex than in the definition provided by the WSMO as their computation may rely on data other than the values specified as its parameters such as (i ) results of other functions defined in the same project or an external library, or (ii ) attributes of an object for object-oriented methods. These values are provided to the functions by their execution environment, as the Java Virtual Machine (JVM) for Java-based systems. For a function to be compliant with our case, it should (i ) depend on the standard libraries of a language-version, either directly or transitively through other referenceable functions, and (ii ) not rely on out-of-scope variables. Property (i ) applies recursively to any function call inside the function itself. If a code is to be written in an inline mode, any other function call within the same function must be replaced by a set of instructions depending only on the standard libraries of a defined language-version. Achieving (ii ) requires binding out-of-scope variables to their values. Many challenges arise from this new definition, starting with the fact that the existing code repositories do not provide a “function-based” view. As a consequence, we should figure out how to turn those into referenceable, reusable resources. The following challenges, presented in Fig. 1, are to be addressed.
Fig. 1. Challenges to achieve a first working prototype of Linked Open Code
Referencing Functions. Function structure and signature in code make it easily recognizable. The signatures usually contain information such as the function’s name and its typed arguments (cf. Fig. 2). Such information can be represented as linked data while attributing a unique identifier for function definitions. The idea is to allow Linked Data providers to publish, following the Semantic Web principles, the code of functions, and their metadata. Furthermore, one may include an additional level of granularity to existing IRIs referencing code entities (repositories, folders, files, fragment), helping to reference functions and keep track of their provenance. For example, a code file archived on Software
500
A. E. A. Djebri et al.
Fig. 2. Comparison of metadata provided function signature in Python and C++
Heritage with the IRI swh:codeFile helps addressing the function fn using the IRI swh:codeFile fn 1 (instead of referencing fragments of code with no defined semantics). An Ontology for Functions. A crucial step to bring functions to the Semantic Web is the definition of an ontology to represent them. Such ontology must describe four aspects: 1. 2. 3. 4.
Versioning: the version of the function, programming language, provenance. Relational: relations between functions (inclusion, dependencies, etc.). Technical: code, arguments, typing, etc. Licensing: although all open source licenses imply free-use and sharing of code3 , some may impose restrictions on the reuse (e.g. crediting the original author), hence this information needs to be provided to the user.
Annotating Functions Semantically. During this step, the defined functions are mapped each with their signature and feature metadata. An Abstract Syntax Tree (AST) analysis is applied on each to identify the components constituting the signature of the function (name, parameters, ...) that will then be used as values for the properties defined in the ontology. As a result, the user will be able to query the knowledge base to retrieve the function matching the given constraints. In parallel, a feature identification process is executed to identify the functionalities implemented by each function and annotate them accordingly. The whole process is depicted as in Fig. 3. Multiple techniques for the identification of features have already been proposed [5] and need to be adapted to our context. Linking Functions. After having identified the features provided by the functions, we can use this information to semantically link functions fulfilling similar goals. Indeed, two functions being annotated with the same feature can be considered as different implementations for the same functionality as perceived by the user. Therefore, we can link them with standard predicates such as owl:sameAs, skos:exactMatch, skos:closeMatch or custom predicates offered by other existing ontologies. Alongside semantics, the dependency 3
https://opensource.org/licenses.
Towards a Linked Open Code
501
Fig. 3. Overview of the process for semantic annotation of functions
must be taken into account to link related functions together. Based on this criterion, functions relying on the results provided by other functions (including the function itself in the case of recursive calls) will be semantically connected. Ranking Functions. The same functionality can be implemented in different ways and using different programming languages. To provide the most efficient implementation, there is a need to rank functions according to several parameters. One example can be the feedback of the community, as a repository where usage statistics for functions are being kept for ranking purposes, alongside other information such as the number of times a function was starred, forked, or upvoted by users. It is also possible to signal issues related to security flaws. Performance evaluation can also be used as a ranking criterion. A Semantic Web Engine like Corese 4 , coded in Java, would use functionality implemented in Java. However, the same functionality, implemented in Python, can deliver better performance for the same tool if used with a Python wrapper. This aspect is meant to link code with experience. We can imagine users sharing their execution log, which may contain elements about hardware specification, operating system, language version, etc. Negotiating Functions. Users may take advantage of the implemented content negotiation to get suitable function definitions for their use-cases. This is done by using HTTP headers, or non-HTTP methods like Query String Arguments (QSA). Users negotiate functions that suit their current environment to access and manipulate Linked Data. For instance, a user working with Corese may send a request to the function catalog, asking for the Java implementation of functions alongside their query for data. Negotiation can rely on the previous step, by proposing the best function to the users according to their specifications. 4
https://github.com/Wimmics/corese.
502
A. E. A. Djebri et al.
The realization of this vision would be a framework through which the user would use SPARQL to query a catalog of functions (Sect. 2.1) for the implementations of needed functionalities meeting architectural and user-defined requirements. The fetched code artifacts can then be composed to build a tailored software system. However, the automatic composition of software artifacts is a whole challenge in itself [6] and is out of the scope of this vision. Concretizing the vision raises other challenges (e.g. scalability) that will need to be addressed when designing the actual solution. 2.2
First Approaches Towards Linked Open Code
The scientific community started taking promising steps to tackle the aforementioned points and make code semantically and uniformly accessible on the Web. Initial works such as [7–9] focused on remote execution, through SPARQL queries, of code explicitly written for the Semantic Web. While [7] and [8] deal with SPARQL functions, [9] defines a new scripting language, LDScript, but its expressiveness is limited when compared to conventional programming languages. However, none of these approaches enables users to discover, download, and locally execute the best implementation of a given functionality in a required programming language. More recent works aim to make code written in any language uniformly accessible through semantic queries. Ontologies are defined to describe code either for a specific language, like the R ontology [10]; a specific paradigm, such as objectoriented languages with CodeOntology [11]; or independently of the used technology as done by [12]. While [10] does not discuss the link between functions and data and lacks a way to capture the semantics of the functions, [11] and [12] have been extended respectively in [13] and [14–17] to tackle these limitations. The work presented in [13] relies on CodeOntology for the implementation of a query answering system. The user’s queries are translated into SPARQL queries and evaluated against a repository containing the RDF definitions of functions. Those functions are discovered and annotated using CodeOntology to describe their structure and DBpedia for semantics. Though this approach is similar to our vision for what concerns the discovery and semantic annotations of the functions, it differs as it remotely executes functions to answer the user’s query while our goal is to find and return the best implementation of the requested functionality. Moreover, we aim to be able to deal with every kind of function despite the paradigm of the language in which they are implemented. In [14–17], De Meester et al. broaden the vision presented in [12] by introducing new concepts, e.g. content negotiation. These approaches are very similar to our vision, with the main difference (which is also one of the main challenges of our approach) that we aim to automatically discover, identify and annotate the source code, while these previous works foresee the manual publication of description and implementations by developers. The works discuss briefly ranking the functions, but do not mention what metrics are to be used.
Towards a Linked Open Code
503
The last very recent initiative is Wikilambda [18] by the Wikimedia foundation. Its aim is to abstract Wikipedia by offering several implementations of functions allowing, firstly, to render the content of Wikidata in natural language using predefined templates and, as a final goal, to make the referenceable functions available on the Web. The main limitation of such an initiative is that the repository needs to be manually populated with functions written by the community, meaning that the success of the approach depends on the expertise and the will of the community, and code already present on the Web cannot be exploited.
3
Long-Term Perspectives
Transitioning from open code to Linked Open Code is challenging, yet it represents tremendous opportunities for diverse communities. Linking data and code in a standard way would open perspectives to fully open and link libraries of programming languages and tools. This promising step enables to auto-construct, from scratch, small utilities computing data. Initiatives like DeepCode 5 for code completion can use this work to improve their models. Later on, frameworks such as GPT-3 can be trained on such data. One can also imagine shareable Deep Learning models in the same way, alongside their data, and in a ready-to-use negotiable format. Another important aspect granted by this transition is datasets of cross-language linked functions, ready to use as a base for code translation projects. We believe that syntactical code translation of code artifacts is not enough to achieve the same performance level obtained by experts of each language. Visual Programming Languages (VPLs) started emerging in the last decades and allow users to create programs and algorithms by assembling visual blocks instead of writing actual code. By providing a consistent organization of the information, they allow better performance in design and problem-solving [19] and bring programming to non-specialists. Visual programming environments are not only developed for teaching purposes6 but also to support the design of real-world applications [20] and workflows such as the Node-RED7 language, widely use in the context of the Internet of Things. Providing a structure allowing to reuse code assets as black-boxes would allow the emergence of a global VPL to build software relying on functions available on the Linked Open Code. We think that the FAIR code vision is not FAIR enough when applied to the Semantic Web. Multiple resources openly available on the Web are not used to their full potential.
5 6 7
https://www.deepcode.ai/. https://scratch.mit.edu/. https://nodered.org/.
504
A. E. A. Djebri et al.
References 1. Berners-Lee, T., Hendler, J., Lassila, O.: The semantic Web. Sci. Am. 284(5), 34–43 (2001) 2. The W3C SPARQL Working Group. Sparql 1.1 overview. Technical report, World Wide Web Consortium (2013) 3. Di Cosmo, R., Gruenpeter, M., Zacchiroli, S.: Identifiers for digital objects: the case of software source code preservation. In: iPRES 2018–15th International Conference on Digital Preservation, pp. 1–9, Boston, United States, September 2018 4. Arroyo, S., et al.: Web service modeling ontology primer. W3C Member Submission (2005) 5. Dit, B., Meghan, R., Malcom, G., Denys, P.: Feature location in source code: a taxonomy and survey. J. Softw. Evol. Process 25(1), 53–95 (2013) 6. Benni, B., Mosser, S., Acher, M., Paillart, M.: Characterizing Black-box composition operators via generated tailored benchmarks. J. Object Technol. 19(2), 1–20 (2020) 7. Atzori, M.: Call: a nucleus for a web of open functions. In: International Semantic Web Conference (Posters & Demos), pp. 17–20 (2014) 8. Atzori, M.: Toward the Web of functions: interoperable higher-order functions in SPARQL. In: Mika, P., et al. (eds.) ISWC 2014. LNCS, vol. 8797, pp. 406–421. Springer, Cham (2014). https://doi.org/10.1007/978-3-319-11915-1 26 9. Corby, O., Faron-Zucker, C., Gandon, F.: LDScript: a linked data script language. In: d’Amato, C., et al. (eds.) ISWC 2017. LNCS, vol. 10587, pp. 208–224. Springer, Cham (2017). https://doi.org/10.1007/978-3-319-68288-4 13 10. Neveu, P., et al.: Using ontologies of software: example of R functions management. In: Lacroix, Z., Vidal, M.E. (eds.) RED 2010. LNCS, vol. 6799, pp. 43–56. Springer, Heidelberg (2012). https://doi.org/10.1007/978-3-642-27392-6 4 11. Atzeni, M., Atzori, M.: CodeOntology: RDF-ization of source code. In: d’Amato, C., et al. (eds.) ISWC 2017. LNCS, vol. 10588, pp. 20–28. Springer, Cham (2017). https://doi.org/10.1007/978-3-319-68204-4 2 12. De Meester, B., Dimou, A., Verborgh, R., Mannens, E.: An Ontology to Semantically Declare and Describe Functions. In: Sack, H., Rizzo, G., Steinmetz, N., Mladeni´c, D., Auer, S., Lange, C. (eds.) ESWC 2016. LNCS, vol. 9989, pp. 46–49. Springer, Cham (2016). https://doi.org/10.1007/978-3-319-47602-5 10 13. Atzeni, M., Atzori, M.: What Is the Cube Root of 27? question answering over CodeOntology. In: Vrandeˇci´c, D., et al. (eds.) ISWC 2018. LNCS, vol. 11136, pp. 285–300. Springer, Cham (2018). https://doi.org/10.1007/978-3-030-00671-6 17 14. De Meester, B., Dimou, A., Verborgh, R., Mannens, E., Van de Walle, R.: Discovering and using functions via content negotiation. In: Proceedings of the 15th International Semantic Web Conference: Posters and Demos, pp. 1–4. CEUR-WS (2016) 15. Noterman, L.: Discovering and Using Functions via Semantic Querying. Master’s thesis, Ghent University (2018 16. De Meester, B., Noterman, L., Verborgh, R., Dimou, A.: The function hub: an implementation-independent read/write function description repository. In: Hitzler, P., et al. (eds.) ESWC 2019. LNCS, vol. 11762, pp. 33–37. Springer, Cham (2019). https://doi.org/10.1007/978-3-030-32327-1 7 17. Meester, D., B., Seymoens, T., Dimou, A., Verborgh, R.: Implementationindependent function reuse. Futur. Gener. Comput. Syst. 110, 946–959 (2020)
Towards a Linked Open Code
505
18. Vrandeˇci´c, D.: Architecture for a multilingual Wikipedia. arXiv preprint arXiv:2004.04733 (2020) 19. Whitley, K.N.: Visual programming languages and the empirical evidence for and against. J. Vis. Lang. Comput. 8(1), 109–142 (1997) 20. Jost, B., Ketterl, M., Budde, R., Leimbach, T.: Graphical programming environments for educational robots: open roberta-yet another one? In: 2014 IEEE International Symposium on Multimedia, pp. 381–386. IEEE (2014)
A Polyvocal and Contextualised Semantic Web Marieke van Erp1(B) 1 2
and Victor de Boer2
KNAW Humanities Cluster, Amsterdam, The Netherlands [email protected] Vrije Universiteit Amsterdam, Amsterdam, The Netherlands [email protected] https://mariekevanerp.com
Abstract. Current AI technologies and data representations often reflect the popular or majority vote. This is an inherent artefact of the frequency bias of many statistical analysis methods that are used to create for example knowledge graphs, resulting in simplified representations of the world in which diverse perspectives are underrepresented. With the use of AI-infused tools ever increasing, as well as the diverse audiences using these tools, this bias needs to be addressed in both the algorithms analysing data, as well as in the resulting representations. In this problems to solve before you die submission, we explain the implications of the lack of polyvocality and contextual knowledge in the semantic web. We identify three challenges for the Semantic Web community on dealing with various voices and perspectives as well as our vision for addressing it. Keywords: Culturally aware AI Bias
1
· Polyvocality · Contextualisation ·
Introduction
Biases in data can be both explicit and implicit. Explicitly, ‘The Dutch Seventeenth Century’ and ‘The Dutch Golden Age’ are pseudo-synonymous and refer to a particular era of Dutch history. Implicitly, the ‘Golden Age’ moniker is contested due to the fact that the geopolitical and economic expansion came at a great cost, such as the slave trade. A simple two-word phrase can carry strong contestations, and entire research fields, such as post-colonial studies, are devoted to them. However, these sometimes subtle (and sometimes not so subtle) differences in voice are as yet not often found in knowledge graphs. One of the reasons is that much of the knowledge found in knowledge graphs is mined automatically and current AI technologies (and their ensuing data representations) often reflect the popular or majority vote. This is an inherent artefact of the frequency bias of many statistical analysis methods that are used to create for example knowledge graphs, resulting in simplified representations Supported by cultural-ai.nl. c Springer Nature Switzerland AG 2021 R. Verborgh et al. (Eds.): ESWC 2021, LNCS 12731, pp. 506–512, 2021. https://doi.org/10.1007/978-3-030-77385-4_30
A Polyvocal and Contextualised Semantic Web
507
of the world in which diverse perspectives are underrepresented. With the use of AI-infused tools ever increasing, as well as the diverse audiences using these tools, this bias needs to be addressed in both the algorithms analysing data, as well as in the resulting representations. Conversations around data bias and polyvocality are taking place in for example the cultural heritage domain (cf. [14,15]) and computational linguistics communities (cf. [8,11]), but do not yet seem mainstream in the Semantic Web discourse. In 2010, Hendler and Berners-Lee already recognised that current knowledge mining mechanisms can bias results and recommend ‘Making the different ontological commitments of competing interpretations explicit, and linked together’, as this ‘can permit different views of data to be simultaneously developed and explored.’ [9]. Veltman noted in her 2004 paper that ’[Dynamic knowledge will] allow us to trace changes of interpretation over time, have new insights and help us to discover new patterns in knowledge’ [20]. Context was also flagged as the next frontier in knowledge representation at the ‘Knowledge graphs: New directions for knowledge representation on the semantic web’ Dagstuhl seminar in 2018 [5]. While it is known that large knowledge graphs are not always balanced (cf. [12]), that links between linked data resources contain biases (cf. [19]), and that research based on such resources might favour a Western perspective (cf. [6]), the creation of contextualised and polyvocal knowledge graphs has only gained modest traction. As data-driven applications are permeating everyday life, it is necessary that these applications can serve as many and as diverse audiences as possible. A Dutch visitor to the Rijksmuseum in Amsterdam could recognise the Christian context of a painting depicting Saint Christopher even if s/he does not know that he is the patron saint of travellers. For a Japanese visitor, this might not be immediately apparent, and s/he needs more context to connect this to her/his cultural context, to for example recognise the parallels to Jiz¯ o, protector of travellers in some Buddhist traditions. For most other applications (e.g. in the domains of food, health, policy and transportation) a greater awareness of cultural and contextual frameworks of users would be crucial to increase engagement and understanding. Thus far, one of the ways machine learning driven approaches have dealt with this, is to add more data, at the risk of flattening nuances. At times, this has led to painful situations, for example when a Twitter trained chatbot started publishing racist, sexist and anti-semitic Tweets within a day of being released [23]. We argue that addressing this by more intelligently organised datasets to identify bias, and multiple perpectives and contexts is needed. Many of the puzzle pieces for a polyvocal and contextualised Semantic Web are already in place. The different local Wikipedias for example present different perspectives [4,24] with varying levels of in- and between group biases [1] but this is often still expressed implicitly. In this problems to solve before you die submission, we explain the implications of the lack of polyvocality and contextual knowledge in the semantic web, as well as our vision for addressing it. The examples we use come from cultural heritage datasets as we work with those and some of the bias issues are amplified
508
M. van Erp and V. de Boer
in there due to their longue dur´ee,1 but these issues and our proposed approach also apply to other domains.
2
What Is a Voice?
Data is not objective, but rather created from a particular perspective or view, representing a voice. These perspectives can be informed by cultural, historical or social conventions or a combination of those. Often, these different perspectives are contiguous, rather than disjoint. A cultural view on for example the ‘The Dutch Golden Age’ is that it was an era in which the Dutch economy and scientific advancements were among the most acclaimed in the world, laying the foundations for the first global multinational corporation and shaping Dutch architecture. A historical view could be that it was an era of unbridled opportunity and wealth for many in the Dutch Republic. A social view could focus on the pride associated with the achievements of this era. However, none of these views tells the entire story. The Dutch Republic maintained several colonies in Africa and Asia and was heavily involved in slave trading; the other side of the coin of wealth and pride. These different views often come to us through objects in cultural heritage collections which can often be different things throughout their life. For example, many cult figures and other objects were taken and brought back home by missionaries -in some cases to learn about ‘the other’ from a euro-centric view. Such items were often (dis)qualified as “fetishes” or “idols” and Christian converts were expected to stay away converted from them. Later, these objects were removed from their original ritual settings and became part of ethnographic collections in missionary exhibitions or were sold as works of art. These reframings represent new perspectives on the same object and depend on time, culture and the object provenance. Data models that are perspective-aware should be able to trace the various changes that objects undergo in their trajectory from their original uses in indigenous religious practices into museum collections [13]. A polyvocal Semantic Web provides opportunities, models and tools to identify, represent and show users different perspectives on an event, organisation, opinion or object. Furthermore, identified individual perspectives need to be connected and clustered to be lifted from an individual perspective to a (representative) voice of a group. Identifying, representing and using such groups with fuzzy boundaries that change over time is one of the core challenges.
3
How Can the Semantic Web Deal with Multiple Perspectives and Interpretations?
We identify three main challenges to support polyvocality on the Semantic Web: identification, representation and usage. We describe these challenges below, along with the current state of the art and promising research directions for addressing them. 1
Some collections we work with have been gathered over a span of over 200 years, and the objects they describe go back even longer.
A Polyvocal and Contextualised Semantic Web
3.1
509
Identifying Polyvocality in Data Sources
Data sources of various modalities can represent a singular ‘voice’, and provide a specific perspective on the world. However, within and across data sources, there can also be multiple voices present. Moreover, when aggregating datasets, such voices can become lost in the process. The challenge here is to identify such voices. For natural language data sources, as well as for methods that extract information from structured sources, this requires Information Extraction methods that are ‘bias’ or ‘voice’-aware. In cases where datasets are the result of aggregations, such methods should be able to (re-)identify the separate voices in the combined source. In cases where human data providers are involved, the voices of the individual users should be maintained. These persons can also represent cultural or societal groups and this information should be available for subsequent representations. As an example, consider a crowdsourcing effort to annotate a Polynesian object in a European museum. Here, annotations provided by the European public on the one hand and annotations provided by members of the source community on the other hand will represent various perspectives. Methods that aggregate such annotations should retain these voices. An example of a method that does this for individual annotators is CrowdTruth [2], which maintains so-called ‘disagreement’ between annotators. Such methods can be expanded to retain this disagreement to the extent to which it represents a ‘voice’. What holds for these non-professional annotators, also holds for professionals involved in metadating or interpreting information. Different perspectives provided by such professionals should also be maintained in the information processing pipeline. Again, in the cultural heritage domain, with movements towards a diversification of the museum professionals gaining traction [18,22], the different perspectives that such professionals provide should be maintained in the object metadata. 3.2
Representation of Polyvocality: Datamodels and Formalisms
Identifying, extracting and retaining polyvocal information in data sources is one aspect, but this is meaningless if the various voices cannot be represented in the data structures used. Luckily, the Knowledge Graph as a data model and the Semantic Web as an information architecture provide excellent opportunities for maintaining various viewpoints on one subject. Its network structure and distributed nature is well-equipped to deal with such viewpoints. One example is found in Europeana, where the Europeana Data Model [10] allows for multiple publishers to provide information about one cultural heritage object. Building on the OAI-ORE model2 , each data provider provides a “Proxy” resource that represents that object in the context of that provider and all metadata is attached to that Proxy resource, rather than the object representation itself. This allows to have multiple perspectives on a single real-world object. This model has 2
http://www.openarchives.org/ore/1.0/datamodel.
510
M. van Erp and V. de Boer
also been applied to represent multiple and potentially disagreeing biographical descriptions of persons [16]. In the NewsReader project,3 information on events was mined from newspaper articles. Multiple reports on the same event were identified via in- and cross-document coreference resolution and presented using named graphs to group statements about a particular event. Provenance information is then attached to these named graphs to represent the viewpoints of various providers [7,17]. Where a voice corresponds to the view of a data publishers, such models appear adequate. At the other end of the spectrum, we see provenance at the level of the individual annotator or even the individual statement. WikiData for example, represents each statement as a tuple which includes the metainformation about that statement [21]. This allows for the recording of very precise provenance of statements, to the individual level. The view of a data provider and the view of the individual annotator represent two points on the spectrum that can inform how to represent the more collective and elusive social-cultural voice. Here, we need models and design patterns on how voices can be represented. This means that not only “what is expressed” should be represented, but also “which worldview does this represent”. One direction is that of “data lenses” as deployed for example in the OpenPhacts project [3]. Here sets of statements are annotated with provenance information, which in turn represent the scientific worldview of different types of end-users. In our case, we would like such lenses to correspond to various voices regardless of the end-user. 3.3
Usage of Polyvocal Knowledge
Representing and maintaining polyvocal knowledge is meaningless if it cannot be used in end-user facing applications. With the voices being represented in the knowledge graphs, different viewpoints are available for such applications. How to provide access to this more complex information in a meaningful way is a third major research challenge. The Europeana, Wikidata and GRaSP data models are already complex to query, even for Semantic Web experts. Adding another layer, that of the voice or lenses, potentially further complicates this. Personalisation can be supported by these different views. Developers of enduser applications should take care that such personalisation does not lead to ‘filter bubbles’. Effective communication of the various views that exist on specific resources is crucial. One example is objects that are assigned to different categories depending on the cultural context. Many objects in ethnography museums are currently categorised based on older (colonial) classification schemes, that might not represent currently held views, and moreover, such views are likely to differ per culture. If such polyvocal information about the object is maintained, it can be shown to the users in digital interfaces as well as in physical locations. What is needed are design guidelines and patterns for visualisation of polyvocal Knowledge as well as reusable tools and methods. 3
https://newsreader-project.eu.
A Polyvocal and Contextualised Semantic Web
4
511
Discussion
Creating a polyvocal and contextualised Semantic Web will be a community effort driven by interdisciplinary teams. Whilst the Cultural AI consortium is embedded in different cultural heritage institutions in the Netherlands that represent different voices, we have to be aware of the danger that this remains a singular (Western/Northern) voice. To create globally relevant and culturally aware semantic web resources, diversity and inclusivity is key, and for this we can for example take cues from Black in AI4 and Widening NLP.5 The Semantic Web community is a diverse one, as our conference attendants, organising and programme committees, editorial boards and mailing lists show. Different voices are present, so let us make our resources, models and projects reflect that. Acknowledgements. This paper builds upon the core concepts and research agenda of the Cultural AI Lab (https://www.cultural-ai.nl/), the authors would like to thank the co-creators of this research agenda: Antal van den Bosch, Laura Hollink, Martijn Kleppe, Johan Oomen, Jacco van Ossenbruggen, Stephan Raaijmakers, Saskia Scheltjens, Rosemarie van der Veen-Oei, and Lotte Wilms. We also want to thank our colleagues of the “Culturally Aware AI” project funded by the Dutch Research Council’s Responsible use of AI programme, from the SABIO project, funded by the Dutch Digital Heritage Network, and from “Pressing Matter: Ownership, Value and the Question of Colonial Heritage in Museums”, funded through the National Science Agenda of the Dutch Research Council.
References ´ 1. Alvarez, G., Oeberst, A., Cress, U., Ferrari, L.: Linguistic evidence of in-group bias in English and Spanish Wikipedia articles about international conflicts. Discourse Context Media 35, 100391 (2020) 2. Aroyo, L., Welty, C.: Truth is a lie: crowd truth and the seven myths of human annotation. AI Mag. 36(1), 15–24 (2015) 3. Batchelor, C., et al.: Scientific lenses to support multiple views over linked Chemistry data. In: Mika, P., et al. (eds.) ISWC 2014. LNCS, vol. 8796, pp. 98–113. Springer, Cham (2014). https://doi.org/10.1007/978-3-319-11964-9 7 4. Beyt´ıa, P.: The positioning matters: estimating geographical bias in the multilingual record of biographies on Wikipedia. In: Companion Proceedings of the Web Conference 2020, pp. 806–810 (2020) 5. Bonatti, P.A., Decker, S., Polleres, A., Presutti, V.: Knowledge graphs: new directions for knowledge representation on the semantic web (dagstuhl seminar 18371). In: Dagstuhl Reports, vol. 8. Schloss Dagstuhl-Leibniz-Zentrum fuer Informatik (2019) 6. Farda-Sarbas, M., Mueller-Birn, C.: Wikidata from a research perspective-a systematic mapping study of wikidata. arXiv preprint arXiv:1908.11153 (2019)
4 5
https://blackinai2020.vercel.app/. http://www.winlp.org/.
512
M. van Erp and V. de Boer
7. Fokkens, A., Vossen, P., Rospocher, M., Hoekstra, R., van Hage, W.R.: GRaSP: grounded representation and source perspective. In: Proceedings of the Workshop Knowledge Resources for the Socio-Economic Sciences and Humanities associated with RANLP 2017, pp. 19–25. INCOMA Inc., Varna, September 2017. https:// doi.org/10.26615/978-954-452-040-3 003 8. Gebru, T., Morgenstern, J., Vecchione, B., Vaughan, J.W., Wallach, H., Daum´e III, H., Crawford, K.: Datasheets for datasets. arXiv preprint arXiv:1803.09010 (2018) 9. Hendler, J., Berners-Lee, T.: From the semantic web to social machines: a research challenge for AI on the world wide web. Artif. Intell. 174(2), 156–161 (2010) 10. Isaac, A.: Europeana data model primer (2013) 11. Jo, E.S., Gebru, T.: Lessons from archives: strategies for collecting sociocultural data in machine learning. In: Proceedings of the 2020 Conference on Fairness, Accountability, and Transparency, pp. 306–316 (2020) 12. Konieczny, P., Klein, M.: Gender gap through time and space: a journey through Wikipedia biographies via the Wikidata human gender indicator. New Media Society 20(12), 4608–4633 (2018) 13. Meyer, B.: Idolatry Beyond the Second Commandment: Conflicting Figurations and Sensations of the Unseen. Bloomsbury, London (2019) 14. Miles, R.S., Tzialli, A.O.E., Captain, E. (eds.): Inward Outward, Critical Archival Engagements with Sounds and Films of Coloniality - A Publication of the 2020 Inward Outward Symposium (2020). https://doi.org/10.18146/inout2020 15. National Museum for World Cultures: Words matter: An unfinished guide to word choice in the cultural sector. https://www.tropenmuseum.nl/nl/over-hettropenmuseum/words-matter-publicatie (2018) 16. Ockeloen, N., et al.: BiographyNet: managing provenance at multiple levels and from different perspectives. In: LISC@ ISWC, pp. 59–71. Citeseer (2013) 17. Rospocher, M., et al.: Building event-centric knowledge graphs from news. Journal of Web Semantics 37, 132–151 (2016) 18. Smith, C.E.: Decolonising the museum: The national museum of the American Indian in Washington, D.C. (2005) 19. Tiddi, I., d’Aquin, M., Motta, E.: Quantifying the bias in data links. In: Janowicz, K., Schlobach, S., Lambrix, P., Hyv¨ onen, E. (eds.) EKAW 2014. LNCS (LNAI), vol. 8876, pp. 531–546. Springer, Cham (2014). https://doi.org/10.1007/978-3-31913704-9 40 20. Veltman, K.H.: Towards a semantic web for culture. J. Digital Inf. 4(4) (2004) 21. Vrandeˇci´c, D., Kr¨ otzsch, M.: Wikidata: a free collaborative knowledgebase. Commun. ACM 57(10), 78–85 (2014) 22. Wei, L.: Crossing the ethnic boundaries: diversity promotion effort of museum professionals in the United Kingdom. In: Proceedings of the Papers, CAAS 7th Conference at TUFS, October 2016 23. Wolf, M.J., Miller, K.W., Grodzinsky, F.S.: Why we should have seen that coming: comments on Microsoft’s Tay “Experiment”, and wider implications. ORBIT J. 1(2), 1–12 (2017) 24. Zhou, Y., Demidova, E., Cristea, A.I.: Who likes me more? Analysing entity-centric language-specific bias in multilingual Wikipedia. In: Proceedings of the 31st Annual ACM Symposium on Applied Computing, pp. 750–757 (2016)
Resources
The WASABI Dataset: Cultural, Lyrics and Audio Analysis Metadata About 2 Million Popular Commercially Released Songs Michel Buffa1(B) , Elena Cabrio1 , Michael Fell2 , Fabien Gandon1 , Alain Giboin1 , Romain Hennequin5 , Franck Michel1 , Johan Pauwels3 , Guillaume Pellerin4 , Maroua Tikat1 , and Marco Winckler1 1
University Cˆ ote d’Azur, Inria, CNRS, I3S, Nice, France {michel.buffa,elena.cabrio,maroua.tikat,winckler}@univ-cotedazur.fr, {fabien.gandon,alain.giboin}@inria.fr, [email protected] 2 Universit` a degli Studi di Torino, Turin, Italy [email protected] 3 Queen Mary University of London, London, England [email protected] 4 IRCAM, Paris, France [email protected] 5 Deezer Research, Paris, France [email protected]
Abstract. Since 2017, the goal of the two-million song WASABI database has been to build a knowledge graph linking collected metadata (artists, discography, producers, dates, etc.) with metadata generated by the analysis of both the songs’ lyrics (topics, places, emotions, structure, etc.) and audio signal (chords, sound, etc.). It relies on natural language processing and machine learning methods for extraction, and semantic Web frameworks forrepresentation and integration. It describes more than 2 millions commercial songs, 200K albums and 77K artists. It can be exploited by music search engines, music professionals (e.g. journalists, radio presenters, music teachers) or scientists willing to analyze popular music published since 1950. It is available under an open license, in multiple formats and with online and open source services including an interactive navigator, a REST API and a SPARQL endpoint. Keywords: Music metadata Linked data
1
· Lyrics analysis · Named entities ·
Introduction
Today, many music streaming services (such as Deezer, Spotify or Apple Music) leverage richmetadata (artist’s biography, genre, lyrics, etc.) to enrich listening experience and perform recommendations. Likewise, journalists or archivists c Springer Nature Switzerland AG 2021 R. Verborgh et al. (Eds.): ESWC 2021, LNCS 12731, pp. 515–531, 2021. https://doi.org/10.1007/978-3-030-77385-4_31
516
M. Buffa et al.
exploit various data sources to prepare TV/radio shows or music-related articles. Music and sound engineering schools use these same data to illustrate and explain the audio production techniques and the history or music theory behind a song. Finally, musicologists may look for hidden relationships between artists (e.g. influences, indirect collaborations) to support a claim. All these scenarios have in common that theyshow the need for more accurate, larger and better linked music knowledge bases, along with tools to explore and exploit them. Since 2017, the WASABI research project1 has built a dataset covering more than 2 M songs (mainly pop/rock and dub) in different languages, 200K albums and 77K artists. Musicologists, archivists from Radio-France, music schools and music composers also collaborated. While cultural data were collected from a large number of data sources, we also processed the song lyrics and performed audio analyses, enriching the corpus with various computed metadata addressing questions such as: What do the lyrics talk about? Which emotions do they convey? What is their structure? What chords are present in the song? What is the tempo, average volume, etc.? We partnered with the Queen Mary University of London (QMUL) and the FAST project2 for extracting chords from the song audio, and linked to IRCAM’s TimeSide3 audio analysis API which for audio processings (beat detection, loudness, etc.). We deployed REST and SPARQL endpoints for requests and a GUI for exploring the dataset [6]. The dataset, Machine Learning models and processing pipeline are described and available4 under an open license.5 Section 2 presents the context of the WASABI project and related works. In Sect. 3, we explain the way we collected and processed data to build the corpus. Section 4 focuses on the formalization, generation and publication of the RDF knowledge graph. Section 5 presents several tools and visualizations built on top of the dataset and services. Finally, Sect. 6 discusses quality assessment concerns while Sects. 7 and 8 discuss future applications and potential impact of the dataset and conclude with some perspectives.
2
State of the Art and Related Work
There are large datasets of royalty-free music such as Jamendo (often used [5,26]) or others found in the DBTunes link directory, but we focus on the ones that cover commercial popular music (see Table 1) and we will see that few propose metadata on cultural aspects, lyrics and audio altogether. MusicBrainz offers a large set of cultural metadata but nothing about lyrics, for example. The Last.fm dataset contains tags that were used by some researchers for computing moods 1 2 3 4 5
Web Audio Semantic Aggregated in the Browser for Indexation, (Universit´e Cˆ ote d’Azur, IRCAM, Deezer and Parisson) http://wasabihome.i3s.unice.fr/. QMUL and the FAST project http://www.semanticaudio.ac.uk/. TimeSide https://github.com/Parisson/TimeSide. https://github.com/micbuffa/WasabiDataset. Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA).
WASABI Dataset
517
and emotions [7,13]. AcousticBrainz, a public, crowd-sourced dataset, contains metadata about audio and has been used by projects such as MusicWeb [2] and MusicLynx [3] to compute similarity models based on musical tonality, rhythm and timbre features. The Centre for Digital Music of QMUL collaborated with the BBC on the use of Semantic Web technologies, and proposed music ontologies in several fields including audio effects and organology. MusicLynx [3] provides an application to browse through music artists by exploiting connections between them, either extra-musical or tangential to music. It integrates open linked semantic metadata from various music recommendation and social media data sources as well as content-derived information. This project shares some ideas with the WASABI project but does not address the same scale of data, nor does it perform analysis on audio and lyrics content. The Million Song Dataset project (MSD) processed a large set of commercial songs to extract metadata using audio content analysis [4], but did not take advantage of structured data (e.g. from DBpedia) to address uncertainties. Information such as group composition or orchestration can be very relevant to informing Music Information Retrieval (MIR) algorithms, but is only available in certain data sources (BBC, MusicBrainz, ...), and for many little-known artists this information is not available. It is here that the combination of audio and semantics finds its purpose, one reinforcing the other. The WASABI project provides a wider scope than the Million Song Dataset: it started as a challenge to build a datataset that would be twice as big with public domain development of open source tools and a richer cultural and lyric-related set of metadata. The DOREMUS project [16] overlaps with WASABI but in a rather different context (classical and traditional music). DOREMUS performs the integration of MIDI resources (instead of MIR analysis), recommendation and automatic playlists generation. The WASABI ontology extends the Music Ontology (MO), yet the Performed Music Ontology6 (part of LD4L) or DOREMUS ontology (based on FRBR) may be considered if future works need to model more accurately the differences between works, performances or expressions. The Listening Experience Database (LED) collects people’s music listening experiences as they are reported in documents like diaries or letters [1]. It mostly relates to legacy music that has little overlap with WASABI. The MELD framework [21] supports the publication of musicology articles with multi-modal user interfaces that connect different forms of digital resources. Some development could be undertaken to allow musicologists publish articles that would leverage musical data from the WASABI RDF knowledge graph. The MIDI Linked Data project [17] publishes a large set of MIDI files in RDF. Linked to DBpedia and relying on the Music Ontology, it could complement WASABI to jointly exploit MIDI files and audio and text analyses. Some MIDI content was used in WASABI during the evaluation of the chord extraction.
6
https://wiki.lyrasis.org/display/LD4P/Performed+Music+Ontology.
518
M. Buffa et al. Table 1. Comparison with other datasets. Nb songs Linked data
Audio analysis
Lyrics analysis
Cultural metadata
Type of music
WASABI
2M
Yes
Yes
Yes
Yes
Commercial
MSD
1M
No
Yes
Bag of words
Partial
Commercial
DOREMUS
24k
Yes
No, Midi Not relevant
Yes
Classical
MusicBrainz
33 M
Commercial
Yes
No
No
Yes
AcousticBrainz 4 M
Yes
Yes
No
MusicBrainz Commercial
Jamendo
No
Chords
No
Yes
3 3.1
200 k+
Royalty free
Building the WASABI Dataset Assembling Cultural Data from Multiple Sources
One of the original goals of the WASABI project was to build a dataset comprising metadata produced by natural language processing applied to the lyrics. As shown in Fig. 1, we therefore started from LyricsWikia, a wiki-based, crowdsourced website gathering a large number of commercial song lyrics, metadata concerning the discography of thousands of artists (name, genre, labels, locations, duration, album release dates etc.). We collected data of 2 M songs, 77K artists and 200K albums, including links and ids to songs, artists and albums on other platforms: Wikipedia, YouTube, MusicBrainz, Last.fm, Discogs, etc.
Fig. 1. WASABI pipeline from datasets and corpora to applications and end-users.
Subsequently, we used the links and ids to gather metadata from these multiple platforms. For instance, from several DBpedia language editions we
WASABI Dataset
519
Table 2. Ratios between external and those in our seed dataset LyricsWikia. Dataset
Songs Artists Albums Comment
MusicBrainz 57%
78%
45%
DBpedia
52%
24%
3.8%
Deezer
57%
64%
63%
87% of the songs if we consider English songs only
Discogs
N/A
69%
41%
Only artists and discographies
Equipboard N/A
8.4%
N/A
Only famous artists/members had metadata
Final
78%
69%
Entries matched at least once in external sources
72%
retrieved music genres, awards and albums durations; from MusicBrainz: artist type (group, person, etc.), gender, life span, group members, albums’ bar code, release date, language; from Discogs: name variations (different ways to call the same song, album or artist) and artist real names that proved to be very relevant for consolidating the dataset; from EquipBoard: content about music gear used by artists (instrument type, brand, model, etc.); from Deezer: songs’ popularity rank, flag for explicit song lyrics, tempo, gain, song duration. Merging was necessary when different properties of the same meaning coming from different data sources provided different, possibly complementary results (e.g. using owl:sameAs from DBpedia). The disambiguation properties of Discogs and the availability of multiple URIs from different data sources for the same song/artist/album also made it possible to detect gross errors. Conflict detectors were set up (e.g. for dates) and manual arbitration occasionally took place. We organized “WASABI Marathons” along the project lifetime where participants used the Wasabi Explorer [6] to identify errors. These marathons helped set up scripts to detect and fix errors ranging from spelling errors/variations (e.g. “Omega Man” by The Police is sometimes spelled “Ω Man”), to rules (e.g. several producers for the same song by the same artist generally indicate an anomaly). Table 2 shows the contribution of each data source in the final dataset e.g. we found in MusicBrainz 1,197,540 songs (57% of the 2,099,287 songs retrieved from LyricsWikia, our initial seed). The tools used to collect these metadata are available on the GitHub repository of the WASABI dataset. 3.2
Generating Lyrics Metadata
Lyrics encode an important part of the semantics of a song. We proposed natural language processing methods to extract relevant information, such as: – structural segmentation: we trained a Convolutional Neural Network to predict segment borders in lyrics from self-similarity matrices (SSM) encoding their repetitive structure. Songs are therefore associated to labeled text segments corresponding to verse, chorus, intro, etc. [14]. We showed that combining text and audio modalities improves lyrics segmentation [15]. – topics: we built a topic model on the lyrics of our corpus using Latent Dirichlet Allocation (LDA). These topics can be visualized as word clouds of the most characteristic words per topic [10,13];
520
M. Buffa et al.
– explicitness of the lyrical content: we compared automated methods ranging from dictionary-based lookup to state-of-the-art deep neural networks to automatically detect explicit content in English lyrics [11]; – salient passages of a song: we introduced a method for extractive summarization of lyrics that relies on the intimate relationship between the audio and the lyrics (audio thumbnailing approach) [12]; – emotions conveyed : we trained an emotion regression model using BERT to classify emotions in lyrics based on the valence-arousal model [13]. Table 3 gives an overview of the annotations we published relating to the song lyrics. Some of those annotation layers are provided for all the 1.73 M songs with lyrics included in the WASABI corpus, while some others apply to subsets of the corpus, due to various constraints of the applied methods [13]. Table 3. Song-wise annotations - ♣ indicates predictions of our models. Annotation
Labels Description
Annotation
Lyrics
1.73 M Segments of lines of text
Languages
Labels Description 1.73 M 36 different ones
Genre
1.06 M 528 different ones
Last FM id
326k
UID
Structure
1.73 M SSM ∈ Rn×n (n: length)
Social tags
276k
S = {rock, joyful, 90s, ...}
♣
Emotion tags 87k
E ⊂ S = {joyful, tragic, ...} Explicitness
715k
True (52k), False (663k)
Explicitness
455k
True (85k), False (370k)
Summary♣
50k
Four lines of song text
Emotion
16k
(valence, arousal) ∈ R2
Emotion♣
1.73 M (valence, arousal) ∈ R2
Topics
♣
Total tracks
1.05 M Prob. distrib. ∈ R
60
2.10 M Diverse metadata
The annotated corpus and the proposed methods are available on the project GitHub repository. As for structure segmentation, for each song text we make available an SSM based on a normalized character-based edit distance on two levels of granularity to enable other researchers to work with these structural representations: line-wise similarity and segment-wise similarity. As for lyrics summarization, the four-line summaries of 50k English lyrics is freely available within the WASABI Song Corpus, as well as the Python code of the applied summarization methods.7 Concerning the explicitness of the lyrics content, we provide both the predicted labels in the WASABI Song Corpus (715k lyrics, 52k tagged as explicit) and the trained classifier to apply it to unseen text. As for emotion, the dataset integrates Deezer’s valence-arousal annotations for 18,000 English tracks8 [8], as well as the valence-arousal predictions for the 1.73 M tracks with lyrics. We also make available the Last.fm social tags (276k) and emotion tags (87k) to allow researchers to build variants of emotion recognition models. Finally, we provide the topic distribution of our LDA topic model for each song and the trained topic model for future research. 7 8
https://github.com/TuringTrain/lyrics thumbnailing. https://github.com/deezer/deezer mood detection dataset.
WASABI Dataset
3.3
521
Extracting Chords Through Automatic Audio Content Analysis
We enriched the dataset with automatic chord recognition [23] for reasons of consistency, formatting and coverage. Even though automatic transcriptions are not flawless, at least they are consistent and well-structured. Chord extraction can also be applied to each song for which audio is available, and therefore avoids the popularity bias that would follow from scraping crowd-sourced resources. In order to mitigate algorithmic imperfections, we used a chord recognition algorithm that additionally returns a song-wide measure of confidence in the quality of transcription [22]. Weighing by this measure makes dataset aggregations more reliable, although it obviously is of limited use when an individual song of interest has a particularly low confidence associated with it. A chord vocabulary consisting of sixty chords was imposed: all combinations of twelve possible root notes with five chord types (major, minor, dominant 7th, major 7th, minor 7th). The Deezer song identifiers provided a link to audio recordings. The actual analysis required access to the raw, unprotected audio and was therefore run by Deezer on their servers. 1.2 million songs in the WASABI dataset have an associated Deezer identifier, so can potentially be enriched with a chord transcription. This process is still ongoing, currently 513K songs have been processed. The chord symbols (without timing due to copyright restrictions) and their confidence measures can be obtained along with the rest of the dataset through the REST API and SPARQL endpoint. Other musical properties based on automatic content analysis can be integrated as future work. 3.4
IRCAM Tools for On-Demand Audio/MIR Analysis
Timeside is an an open, scalable, audio processing framework in Python, enabling low and high level audio analysis, visualization, transcoding, streaming and labelling. Its API supports reproducible and extensible processing on large datasets of any audio or video format. For WASABI, some parts have been created or extended: a secured and documented API with JWT access capabilities, a Provider module to handle automatic extraction of YouTube’s and Deezer’s tracks or 30 s extracts, an SDK for the development of client applications and a new web front-end prototype. A hosted instance has been connected to the main WASABI API so that every available tracks can be dynamically processed and played back through the multi-track analyzer web player.
4
Formalizing, Generating and Publishing the RDF Knowledge Graph
The WASABI dataset essentially consists of two parts: the initial dataset produced over the last 3 years by integrating and processing multiple data sources, as explained in Sect. 3, and the RDF dataset derived thereof, namely the WASABI RDF Knowledge Graph that we describe hereafter. The latter provides an RDF representation of songs, artists and albums, together with the information automatically extracted from lyrics and audio content.
522
4.1
M. Buffa et al.
The WASABI Ontology
The WASABI vocabulary is an OWL ontology to formalize the metadata. It primarily relies on the Music Ontology [24] that defines a rich vocabulary for describing and linking music information, and extends it with terms about some specific entities and properties. It also reuses terms from the Dublin Core, FOAF, Schema.org and the DBpedia ontologies, as well as the Audio Features Ontology9 and the OMRAS2 Chord Ontology.10 The current version of the ontology comprises of 8 classes and 50 properties to describe songs, albums and artists. The number of properties is due to the quite specific features represented in the metadata, for instance multi-track files, audio gain, names and titles without accent, or lyrics-related features such as the detected language or explicitness. Furthermore, no less that 22 properties represent links to the web pages of social networks, either mainstream or specialized in the music domain. Whenever possible, we linked these properties with equivalent or related properties from other vocabularies. The Music Ontology comes with three terms to represent music performers: mo:SoloMusicArtist and mo:MusicGroup that are both subsumed by class mo:MusicArtist. To distinguish between a music group, an orchestra and a choir, we defined the wsb:Artist Person and wsb:Artist Group classes, respectively equivalent to mo:SoloMusicArtist and mo:MusicGroup, and two subclasses of mo:MusicArtist namely wsb:Orchestra and wsb:Choir. wsb:Song is the class of musical tracks performed by artists. It’s a subclass of mo:Track, itself a subclass of mo:MusicalManifestation. wsb:Album is the class of collections of one or more songs released together. It is a subclass of mo:Record which itself is a subclass of mo:MusicalManifestation. The ontology namespace11 (prefix wsb:) is also its URI. The ontology can be dereferenced with content negotiation, as well as all the terms of the ontology. It can be downloaded from the repository12 where graphical visualizations are also available. 4.2
Representing Songs, Artists and Albums in RDF
Beyond the terms of WASABI ontology, the resource descriptions use terms from multiple vocabularies. The namespaces and prefixes are given in Listing 1.1 and the diagram in Fig. 2 is the representation of a song from the WASABI database. This song is linked to its album through the schema:album property, and both the album and song are linked to the artist using the mo:performer Music Ontology property. Only a small subset of songs’ metadata is depicted here: title (dcterms:title), audio gain (wsb:gain), chords (chord:chord )13 given 9 10 11 12 13
Audio Features Ontology: http://purl.org/ontology/af/. OMRAS2 Chord Ontology: http://purl.org/ontology/chord/. http://ns.inria.fr/wasabi/ontology/. https://github.com/micbuffa/WasabiDataset/tree/master/ontology. Due to copyright concerns, the chords ordered sequence and timing were computed but are not provided.
WASABI Dataset @prefix @prefix @prefix @prefix @prefix @prefix @prefix @prefix @prefix @prefix
af : chord : dcterms : foaf : mo : rdf : rdfs : schema : wsb : xsd :
523
< http :// purl . org / ontology / af / >. < http :// purl . org / ontology / chord / >. < http :// purl . org / dc / terms / > . < http :// xmlns . com / foaf /0.1/ >. < http :// purl . org / ontology / mo / >. < http :// www . w3 . org /1999/02/22 - rdf - syntax - ns # >. < http :// www . w3 . org /2000/01/ rdf - schema # >. < http :// schema . org / >. < http :// ns . inria . fr / wasabi / ontology / >. < http :// www . w3 . org /2001/ XMLSchema # >.
Listing 1.1. Namespaces used in the RDF representation of the entities.
Fig. 2. RDF representation of a song, some properties and its artist and album.
by their URI in the OMRAS2 chord ontology, and number of explicit lyrics (wsb:explicit lyrics count). 4.3
The RDF Knowledge Graph Generation Pipeline
The dataset described in Sect. 3 consists of a MongoDB database comprising three main collections: songs, artists and albums. The song collection provides not only the metadata, but also a representation of the chords extracted by the audio analysis, and the information extracted from the lyrics. In a first stage, each JSON document of MongoDB was pre-processed so as to facilitate its translation to RDF, then translated to an RDF representation as described in Sect. 4.2. The translation was carried out by Morph-xR2RML,14 an implementation of the xR2RML mapping language [19] for MongoDB databases. All files involved in this pipeline are provided under the Apache License 2.0.
14
https://github.com/frmichel/morph-xr2rml/.
524
M. Buffa et al. Table 4. Statistics of the WASABI dataset.
Songs
No. entities
JSON data
No. RDF triples
2.08 M
8.8 GB
49.9 M
Artists, groups, choirs and orchestras 77K
378 MB
2.76 M
Albums
208K
424 MB
3.29 M
Total
2.38 M
9.57 GB
55.5 M
Table 5. Selected statistics on typical properties and classes. Property URI
nb of instances
Comment
http://purl.org/ontology/chord/chord
7595765
Chords of a song
http://purl.org/dc/terms/title
2308022
Song or album title
http://schema.org/album
2099283
Song-to-album relation
http://purl.org/ontology/mo/performer
1953416
Performing artist
http://www.w3.org/2002/07/owl#sameAs
204771
DBpedia/Wikidata links
http://purl.org/ontology/mo/genre
86190
Musical genre
http://purl.org/ontology/mo/producer
75703
Song/album producer
http://schema.org/members
74907
Group members
http://dbpedia.org/ontology/genre
52047
DBpedia musical genre
Class URI
nb of instances
http://ns.inria.fr/wasabi/ontology/Song
2099287
http://ns.inria.fr/wasabi/ontology/Album
208743
http://ns.inria.fr/wasabi/ontology/Artist Group 29806
Group or band
http://ns.inria.fr/wasabi/ontology/Artist Person 24264
Single artist
http://purl.org/ontology/mo/MusicArtist
23323
http://ns.inria.fr/wasabi/ontology/Classic Song
10864
http://ns.inria.fr/wasabi/ontology/Choir
44
http://ns.inria.fr/wasabi/ontology/Orchestra
30
4.4
Classic of pop/rock music
Publishing and Querying the WASABI RDF Knowledge Graph
Table 4 synthesizes the amount of data processed to produce the WASABI RDF Knowledge Graph, and reports the number of triples produced. Table 5 reports some statistics about the instances. Dataset Description and Accessibility. In line with data publication best practices [9], the WASABI RDF Knowledge Graph comes with rich metadata regarding licensing, authorship and provenance information, linksets, vocabularies and access information. These can be visualized by looking up the dataset URI15 . The dataset is available as a DOI-identified downloadable RDF dump and a public SPARQL endpoint (see Table 6). All URIs can be dereferenced with content negotiation. Further information (modeling, named graphs, third-party vocabularies) are documented in the GitHub repository. 15
WASABI RDF dataset URI: http://ns.inria.fr/wasabi/wasabi-1-0.
WASABI Dataset
525
Table 6. Dataset accessibility. RDF dump
https://doi.org/10.5281/zenodo.4312641
Public SPARQL endpoint http://wasabi.inria.fr/sparql Documentation
https://github.com/micbuffa/WasabiDataset
Ontology namespace
http://ns.inria.fr/wasabi/ontology/
Data namespace
http://ns.inria.fr/wasabi/
Dataset URI
http://ns.inria.fr/wasabi/wasabi-1-0
Dataset Licensing. Like the rest of the WASABI dataset, the WASABI RDF Knowledge Graph is published under the Creative Commons AttributionNonCommercial-ShareAlike 4.0 International License. Copyrighted data such as the full text content of the song lyrics and audio are not included but URLs of original source material are given. Sustainability Plan. We plan several research lines that will exploit and extend the dataset and improve its resilience. We intend to add more audio-related computed metadata from our collaborators at IRCAM and QMUL e.g. links from the song ids to the TimeSide API will ensure that the audio based analyses can be provided or re-triggered even if new songs are added or of the audio data change or vary from the external providers. We also deployed a SPARQL endpoint that benefits from a high-availability infrastructure and 24/7 support.
5
Visualization and Current Usage of the Dataset
The size and the complexity of the dataset require appropriate tools to allow users to explore and navigate through it. This multidimensional dataset contains a large variety of multimedia attributes (lyrics, sounds, chords, musical instruments, etc.) that are interlinked, thus featuring a large and rich knowledge graph. To assist users, we investigate various visualization techniques. Our goal is to help users explore the dataset by providing answers to common visualization questions such as to get an overview of itemsets fitting some userdefined criteria, exploring details of particular itemsets, identify relationships (such as patterns, trends, and clusters) between itemsets, etc. These common tasks are defined in the information-seeking mantra introduced by Schneidermann [25] which guides the design of all visualization tools. We designed and implemented a large set of visualization techniques using the D3.js library and made these techniques available to the user in a gallery. Figure 3 illustrates some of the visualization techniques currently available and all are interactive so that user can select an itemset and apply zoom and filtering to explore the dataset. The creation process for the gallery of information visualization techniques is rather opportunistic and incremental. It allows us to explore different alternatives for showing information to the users but also to combine different attributes. The visualization is driven by the type and inner structure of the
526
M. Buffa et al.
data that results from the queries embedded into the visualization tools. Whilst visualization tools created this way are not generic, they remove part of the inner complexity of creating (SPARQL) queries, making the tools easier to use and particularly suitable to communicating results to a broad audience. It is worthy of notice that some of the visualization techniques includes multimedia content, for example the Fig. 4 includes images that refer to cover of albums of an artist. So far, beyond the interactive graphics, only text and images are used in multimedia visualization, we are working to enrich the information visualization gallery with techniques that include audio contents.
Fig. 3. Selected visualization techniques from the WASABI gallery: a) map view showing artists per country; b) barplot showing a comparison of the popularity of two genres along years; c) pie chart showing total genre popularity; d) heatmap showing the number of new artists of a genre per year; e) bifocaltree showing collaborators of Metallica.
6
Evaluating the Quality of the Dataset, Future Updates
Assessing and ensuring the quality of a large dataset built by aggregating multiple data sources is challenging and continuous process. It is common that metadata coming from various sources be erroneous or conflicting. The multiple hackathons helped in spotting many errors, conflicts and recurring problems, and we wrote a set of scripts (available in the Github repository) to fix some of them. The dataset is meant to be maintained over at least the next three years as we have new ongoing projects that will exploit and extend it. More metadata will be added (in particular from MIR audio analysis of songs, linking songs to existing midi transcriptions or online scores), and we are developing new metadata quality assessment tools (based on visualisations and inferences rules) that
WASABI Dataset
527
Fig. 4. Example of information visualization including multimedia contents: Eminem collaborations (co-writing of songs) by albums (see cover of albums).
shall allow the community to better detect and report erroneous, conflicting or missing metadata. On the other hand, the quality of extracted metadata about lyrics have been validated using different methods described in the papers cited in Sect. 3.2.
7
Potential Impact and Reusability
To the best of our knowledge, the WASABI dataset is the first one integrating cultural and MIR data at this scale into a single, coherent knowledge graph that makes it possible to initiate new research. The wide range of metadata resulting from the analysis of song lyrics is one of the remarkable points. Many recommendation systems are based on cultural information and user profiles, sometimes taking into account data from the audio analysis, but few rely on the content of the lyrics or their analysis. Furthermore, mixing the emotions extracted from the textual analysis with results on the analysis of emotions extracted from the audio from other datasets (e.g. AcousticBrainz) provides new prospects for recommendation systems [20]. In addition to being interoperable with central knowledge graphs used within the Semantic Web community, the visualizations show the potential of these technologies in other fields. The availability of this rich resource can also attract researchers from the NLP community.16 Interest of Communities in Using the Dataset and Services. The openness of the data and code allow contributors to advance the current state of 16
1st Workshop on NLP for Music and Audio in 2020 https://sites.google.com/view/ nlp4musa.
528
M. Buffa et al.
knowledge on the popular music domain. We initiated collaborations with other groups and, in particular, researchers from the FAST project already used and contributed to the dataset. IRCAM researchers also started cross-domain analyses on songs (i.e. structure and emotion detection using both audio and text [18]). Collaboration with IRCAM will continue as the integration of additional audio data is a priority for us in the coming months and will trigger updates. Application Scenarios, Targeted Users, and Typical Queries. Following a user-oriented requirement analysis, we designed a set of motivating scenarios: Scenario 1: research of artists and songs related to current events, set with the help of archivists from Radio-France. E.g. during the “yellow jackets” protest in France, animators of music radio programs repeatedly requested songs about protests, rebellion, anti-government movements, revolution. Scenario 2: analysis of a particular artist, set with the help of musicologists. To look for an artist’s influences, collaborations and themes, and study variations in the compositions (complexity of the songs, recording locations). Scenario 3: disambiguation of homonyms (artists with the same name) and duplicates (single artist with multiple names or various name spellings), set with the help of Deezer. The goal is to highlight suspicious artist profiles and the sources involved (e.g. homonyms may have different record labels, languages etc.), to display, group and prioritize alerts (e.g. using artists’ popularity). Scenario 4: search for songs of a particular style, in a given key, or containing specific chords, with lyrics with given topics, set with the help of music schools and professional composers. E.g.: look for a blues in E with a tempo of 120 bpm, then get similar songs but with chords outside the key; show artists who wrote a type of songs, sorted by popularity; search for songs with given themes and emotions in the lyrics or with certain types of orchestrations (e.g. guitar and clarinet). Like in scenario 1, these queries involve searches through the dataset, yet they are meant for very different users with different needs that require specific user interfaces: journalists vs. music schools and composers. Whilst some questions might be answered by showing the correlation between components (e.g., types of collaborations between artists), others might require reasoning (e.g., compute the possible keys from the list of chords), and mix cultural, audio or lyrics related content (e.g., orchestration mixes audio and metadata collected about artists/members’ instruments). Answering these complex queries might also require an exploration of the WASABI corpus, and for that we offer a variety of analysis, exploration and visualization tools [6].
8
Conclusion and Future Work
In this paper, we described the data and software resources provided by the WASABI project to make it easier for researchers to access, query and make
WASABI Dataset
529
sense of a large corpus of commercial music information. Applications meant for different types of users (composers, music schools, archivists, streaming services) can be built upon this corpus, such as the WASABI explorer that includes a chord search engine and an augmented audio player [6]. We generated and published an RDF knowledge graph providing a rich set of metadata about popular commercial songs from the last six decades. These metadata cover cultural aspects of songs/albums/artists, lyrics content as well as audio features extracted using Music Information Retrieval techniques. The RDF representation currently uses some free text values coming from the original sources. To be more in line with Linked Data practices, in the future we intend to improve this by reusing, extending or defining thesauruses with respect to musical genres, music instrument types (currently 220 distinct values among which 16 different types of guitar) and equipment types (e.g. microphone, amplifier). We also published the pipeline we set up to generate this knowledge graph, in order to (1) continue enriching it and (2) spur and facilitate reuse and adaptation of both the dataset and the pipeline. It is important to note that during the project we had access to copyrighted content (song lyrics, audio files) that we are not allowed to include in the published dataset. Nevertheless, a lot of work has been done on the analysis of song lyrics and the results are available on the GitHub of the project (metadata, ML templates, Python scripts and Jupyter notebooks). It is still possible for researchers to get the lyrics (e.g. via the commercial MusixMatch API17 ) or the audio (via Deezer’s public API which offers 30-s clips, or via the YouTube API for example) to reproduce our results. Some computed metadata related to the synchronized chord sequences (used by the augmented audio player in the WASABI online explorer) were published only partially to avoid copyright infringement (as they are too close to music scores). Nevertheless, in collaboration with Deezer and IRCAM, we plan to carry out further audio analyses, mainly for scenarios of interest to music schools, musicologists, archivists and broadcast services. Results from the lyric processing are provided in the original dataset in different forms (json, csv, etc.). At the time of writing, only the explicitness metadata are included in the RDF knowledge graph, and we are working on a future update that will include other metadata. However, all the components are connected through the WASABI ids, shared by all versions of the dataset.
References 1. Adamou, A., Brown, S., Barlow, H., Allocca, C., d’Aquin, M.: Crowdsourcing linked data on listening experiences through reuse and enhancement of library data. Int. J. Digit. Libr. 20(1), 61–79 (2019) 2. Allik, A., Mora-Mcginity, M., Fazekas, G., Sandler, M.: MusicWeb: an open linked semantic platform for music metadata. In: Proceedings of the 15th International Semantic Web Conference (2016) 17
https://developer.musixmatch.com/, ex: of lyrics retrieval at https://jsbin.com/ janafox/edit.
530
M. Buffa et al.
3. Allik, A., Thalmann, F., Sandler, M.: MusicLynx: exploring music through artist similarity graphs. In: Companion Proceedings of the Web Conference (2018) 4. Bertin-Mahieux, T., Ellis, D.P., Whitman, B., Lamere, P.: The million song dataset. In: Proceedings of the ISMIR Conference (2011) 5. Bogdanov, D., Won, M., Tovstogan, P., Porter, A., Serra, X.: The MTG-Jamendo dataset for automatic music tagging. In: Proceedings of ICML (2019) 6. Buffa, M., Lebrun, J., Pauwels, J., Pellerin, G.: A 2 Million commercial song interactive navigator. In: WAC - 5th WebAudio Conference, December 2019 7. C ¸ ano, E., Morisio, M., et al.: Music mood dataset creation based on last. fm tags. In: 2017 International Conference on Artificial Intelligence and Applications (2017) 8. Delbouys, R., Hennequin, R., Piccoli, F., Royo-Letelier, J., Moussallam, M.: Music mood detection based on audio and lyrics with deep neural net. arXiv preprint arXiv:1809.07276 (2018) 9. Farias L´ oscio, B., Burle, C., Calegari, N.: Data on the Web Best Practices. W3C Recommandation (2017) 10. Fell, M.: Natural language processing for music information retrieval: deep analysis of lyrics structure and content. Universit´e Cˆ ote d’Azur, Theses (2020) 11. Fell, M., Cabrio, E., Corazza, M., Gandon, F.: Comparing automated methods to detect explicit content in song lyrics. In: RANLP - Recent Advances in Natural Language Processing, September 2019 12. Fell, M., Cabrio, E., Gandon, F., Giboin, A.: Song lyrics summarization inspired by audio thumb nailing. In: RANLP - Recent Advances in Natural Language Processing (RANLP), September 2019 13. Fell, M., Cabrio, E., Korfed, E., Buffa, M., Gandon, F.: Love me, love me, say (and write!) that you love me: enriching the WASABI song corpus with lyrics annotations. In: Proceedings of the 12th LREC Conference, pp. 2138–2147, May 2020 14. Fell, M., Nechaev, Y., Cabrio, E., Gandon, F.: Lyrics segmentation: textual macrostructure detection using convolutions. In: Conference on Computational Linguistics (COLING), pp. 2044–2054, August 2018 15. Fell, M., Nechaev, Y., Meseguer-Brocal, G., Cabrio, E., Gandon, F., Peeters, G.: Lyrics segmentation via bimodal text-audio representation. Nat. Lang. Eng. (to appear) 16. Lisena, P., et al.: Improving (re-) usability of musical datasets: an overview of the doremus project. Bibliothek Forschung und Praxis 42(2), 194–205 (2018) 17. Mero˜ no-Pe˜ nuela, A., et al.: The MIDI linked data cloud. In: d’Amato, C., et al. (eds.) ISWC 2017. LNCS, vol. 10588, pp. 156–164. Springer, Cham (2017). https:// doi.org/10.1007/978-3-319-68204-4 16 18. Meseguer-Brocal, G., Cohen-Hadria, A., Peeters, G.: Dali: a large dataset of synchronized audio, lyrics and notes, automatically created using teacher-student machine learning paradigm. In: Proceedings of the ISMIR Conference (2018) 19. Michel, F., Djimenou, L., Faron-Zucker, C., Montagnat, J.: Translation of relational and non-relational databases into RDF with xR2RML. In: Proceedings of the 11th WebIST Conference, pp. 443–454 (2015) 20. Monti, D., et al.: An ensemble approach of recurrent neural networks using pretrained embeddings for playlist completion. In: Proceedings of the ACM Recommender Systems Challenge, RecSys Challenge, pp. 13:1–13:6 (2018) 21. Page, K.R., Lewis, D., Weigl, D.M.: MELD: a linked data framework for multimedia access to music digital libraries. In: 2019 ACM/IEEE Joint Conference on Digital Libraries (JCDL), pp. 434–435. IEEE (2019)
WASABI Dataset
531
22. Pauwels, J., O’Hanlon, K., Fazekas, G., Sandler, M.B.: Confidence measures and their applications in music labelling systems based on hidden Markov models. In: Proceedings of the 18th ISMIR Conference, pp. 279–285 (2017) 23. Pauwels, J., O’Hanlon, K., G´ omez, E., Sandler, M.B.: 20 years of automatic chord recognition from audio. In: Proceedings of the 20th ISMIR Conference (2019) 24. Raimond, Y., Abdallah, S., Sandler, M., Giasson, F.: The music ontology. In: Proceedings of the 8th ISMIR Conference, pp. 417–422 (2007) 25. Shneiderman, B.: The eyes have it: a task by data type taxonomy for information visualizations. In: Proceedings 1996 IEEE Symposium on Visual Languages, pp. 336–343. IEEE (1996) 26. Xamb´ o, A., Pauwels, J., Roma, G., Barthet, M., Fazekas, G.: Jam with Jamendo: querying a large music collection by chords from a learner’s perspective. In: Proceedings of Audio Mostly, pp. 1–7 (2018)
RuBQ 2.0: An Innovated Russian Question Answering Dataset Ivan Rybin1 , Vladislav Korablinov1 , Pavel Efimov1 , and Pavel Braslavski2,3(B) 1 2
ITMO University, Saint Petersburg, Russia Ural Federal University, Yekaterinburg, Russia 3 HSE University, Moscow, Russia
Abstract. The paper describes the second version of RuBQ, a Russian dataset for knowledge base question answering (KBQA) over Wikidata. Whereas the first version builds on Q&A pairs harvested online, the extension is based on questions obtained through search engine query suggestion services. The questions underwent crowdsourced and in-house annotation in a quite different fashion compared to the first edition. The dataset doubled in size: RuBQ 2.0 contains 2,910 questions along with the answers and SPARQL queries. The dataset also incorporates answer-bearing paragraphs from Wikipedia for the majority of questions. The dataset is suitable for the evaluation of KBQA, machine reading comprehension (MRC), hybrid questions answering, as well as semantic parsing. We provide the analysis of the dataset and report several KBQA and MRC baseline results. The dataset is freely available under the CCBY-4.0 license. Keywords: Knowledge base question answering · Multilingual question answering · Machine reading comprehension · Evaluation resources · Russian language resources
1
Introduction
Question Answering (QA) is an important scientific and applied problem that aims at building a system that can answer questions in a natural language. Two main directions within QA are Open-Domain Question Answering (ODQA) and Knowledge Base Question Answering (KBQA) (also referred to as Knowledge Graph Question Answering, KGQA). ODQA searches for the answer in a large collection of text documents; the process is often divided into two stages: 1) retrieval of documents/paragraphs potentially containing the answer and 2) spotting an answer span within a given document/paragraph (referred to as machine reading comprehension, MRC ). In contrast, KBQA searches an answer Ivan Rybin—work done as an intern at JetBrains Research. Resource location: https://doi.org/10.5281/zenodo.4345696. Project page: https://github.com/vladislavneon/RuBQ. c Springer Nature Switzerland AG 2021 R. Verborgh et al. (Eds.): ESWC 2021, LNCS 12731, pp. 532–547, 2021. https://doi.org/10.1007/978-3-030-77385-4_32
RuBQ 2.0: An Innovated Russian Question Answering Dataset
533
in a knowledge base that is commonly structured as a collection of (subject, predicate, object) triples, e.g. (Yuri Gagarin, occupation, astronaut). The KBQA task can be formulated as a translation from a natural language question into a formal semantic representation, e.g. a SPARQL query. In many real-life applications, like in Jeopardy! winning IBM Watson [12] and major search engines, hybrid QA systems are employed – they rely on both text document collections and structured knowledge bases. As is typical for all machine learning applications, freely available annotated data for model training and testing is crucial for measurable progress in solving QA tasks. Since the inception of the SQuAD dataset [20], we have seen an avalanche of the available question answering datasets; the most recent trend is non-English and multilingual MRC datasets [5,17,18]. Available KBQA datasets are much scarcer; there are very few non-English datasets among them (see Sect. 2 for details). Russian is among top-10 languages by its L1 and L2 speakers;1 it has a Cyrillic script and a number of grammar features that make it quite different from English – the language most frequently used in NLP and Semantic Web research. In this paper, we describe an expansion of RuBQ (pronounced [‘rubik]) – Russian Knowledge Base Questions, the first Russian KBQA dataset [15]. The first version of the dataset is based on the pairs of questions and answers from online quizzes and contains 1,500 questions along with Wikidata answers, corresponding SPARQL queries, and English machine-translated questions. The dataset is accompanied with a Wikidata snapshot RuWikidata8M containing about 212M triples that include 8.1M unique items with Russian labels. The motivation behind RuBQ 2.0 was larger size, higher diversity of questions, as well as the MRC part. To expand the dataset, we obtained questions from Yandex and Google query suggestion services. A potential advantage of such questions from a search log is that they reflect realistic users’ information needs and their wordings. A possible disadvantage of query suggestion services as a source of questions is that we have very little control over the questions’ selection criteria, as well as a limited number of returned suggestions for each input. In addition, the services rank the returned queries by their popularity, which may result in shorter, simpler, and less varied questions. As a seed, we used a set of manually crafted question prefixes corresponding to the most popular Wikidata properties, as well as properties with numeric values. To annotate the questions, we employed a pipeline quite different from the version one. We used crowdsourcing to find the answers to the questions and generated SPARQL queries based on automatically extracted question entities and the corresponding properties. We retained those items that produced correct answers. Using this routine, we were able to almost double the dataset: the extended version reached 2,910 questions. In addition, using automatic methods and subsequent crowdsourced verification, we coupled most of the questions in the dataset with Wikipedia paragraphs containing the answer. Thus, the dataset can be used for testing MRC models, as 1
https://en.wikipedia.org/wiki/List_of_languages_by_total_number_of_speakers.
534
I. Rybin et al.
well as for research on hybrid question answering. We provide several baselines both for KBQA and MRC that demonstrate that there is an ample room for improving QA methods. In the reminder of the paper we will refer to the add-on to the initial dataset as Query Suggestion Questions (QSQ), and the merging of RuBQ 1.0 and QSQ as RuBQ 2.0. Taking into account RuBQ’s modest size, we propose to use the dataset primarily for testing rule-based systems, models based on few/zero-shot and transfer learning, as well as models trained on automatically generated examples, similarly to recent MRC datasets [1,17]. We believe that rich and versatile annotation of the dataset will attract researchers from different communities – Semantic Web, Information Retrieval, and NLP. RuBQ 2.0 is freely available under the CC-BY-4.0 license in JSON format.2
2
Related Work
For a comprehensive survey of KBQA datasets, including the first edition of RuBQ, see our paper [15]. The majority of KBQA datasets are in English. Few exceptions are Chinese MSParS [8], multilingual (machine-translated to a large extent) QALD [25], and the newly introduced Russian RuBQ. A recently published Multilingual Knowledge Questions and Answers (MKQA) dataset [18] contains human translations of 10,000 English questions from the Natural Questions (NQ) dataset [16] into 25 languages, including Russian. MKQA refrains from using the existing NQ answers and obtains the answers anew for each language variant via crowdsourcing. The answers are divided into several types: entity, long answer, unanswerable, date, number, number with unit, short phrase, as well as yes/no. Entity answers (4,221 in the English subset, for other languages the number may slightly differ) are linked to Wikidata. However, the dataset does not contain annotations of the question entities nor corresponding formal representations such as SPARQL queries. Our approach uses search engine query suggestion services to obtain new questions and is similar to the approach behind the WebQuestions dataset containing 5.8K questions [2]. Later, 81% of WebQuestions were provided with SPARQL queries and formed the WebQuestionsSP dataset [26]. In contrast to WebQuestions that started with a single question and iteratively expanded the pool of questions, we started with a manually crafted list of question prefixes presumably corresponding to the most frequent Wikidata properties and properties with literal values. Since the advent of SQuAD [20], a large number of MRC datasets have been published. In the context of our study, the most relevant datasets are those built in a semi-automatic manner using existing Q&A pairs. TriviaQA [14] builds on a collection of 95K trivia and quiz question-answers pairs collected on the Web. The dataset is enriched with documents from Web search results and Wikipedia articles for entities identified in the questions, 650K documents in total. SearchQA dataset [10] exploits a similar approach: it starts from a collection of 140K question-answer pairs from Jeopardy! archive and is augmented 2
https://github.com/vladislavneon/RuBQ.
RuBQ 2.0: An Innovated Russian Question Answering Dataset
535
with Google search snippets containing the answer. Each SearchQA Q&A pair is aligned with about 50 such snippets on average. In contrast to these datasets, we conducted an exhaustive crowdsourced annotation of the evidence paragraphs. Built in 2017 with 50K question-paragraph-answer triples and using SQuAD as a reference, SberQUAD is the largest Russian MRC dataset. A post-hoc analysis revealed that the dataset is quite noisy [11]. Multilingual XQuAD [1] and TyDi QA [5] datasets contain around 1K and 7K Russian items, respectively; summary statistics and comparison of these three resources can be found in our recent paper [11]. Hybrid QA studies start usually with an existing KBQA dataset and complement it with textual evidence using NER and IR techniques [21,22]. A drawback of this approach is that results can be hardly reproduced and compared in absence of a standard dataset. QALD-4 dataset addresses this issues, but is rather small: it contains relevant textual abstracts along with SPARQL queries for 25 questions [24]. Grau and Ligozat [13] built a hybrid QA dataset by recycling questions and answers from TREC and CLEF QA campaigns and augmented them with DBpedia IDs. The resulting dataset contains around 2.2K KBannotated Q&A pairs, but is not freely available currently. Chen et al. [4] introduced recently the HybridQA dataset that comprises of 13K English Wikipedia tables associated with text passages, as well as 70K questions generated by crowd workers.
Fig. 1. RuBQ 2.0 KBQA creation pipeline.
3
Data Acquisition and Annotation
The data processing pipeline is presented in Fig. 1. To obtain new questions, we used query suggestion services by Google and Yandex search engines. Firstly,
536
I. Rybin et al.
Table 1. Examples of prefixes for three Wikidata properties and suggested queries; continuations are in bold.
we consulted a list of the most popular Wikidata properties,3 removed crosslinking properties such as PubMed ID and DOI, and manually crafted question prefixes for the remaining top-200 properties, 2,077 in total. To generate prefixes, we started from the Wikidata property aliases and tried to ensure diversity and coverage, see examples in Table 1. Many prefixes for the same property are almost identical – they differ only in the verb tense/form. Note that the prefixes can be ambiguous and do not uniquely define the property. In addition, we manually compiled 546 question prefixes that imply numerical and date answers, for example: What is the melting point... Search engine suggestion services return up to 10 items for each input. Sometimes the beginnings of returned items do not match the initial prefixes, which is likely due to semantic rather than lexical matching methods. Given a lim3
https://www.wikidata.org/wiki/Wikidata:Database_reports/List_of_properties/ all.
RuBQ 2.0: An Innovated Russian Question Answering Dataset
537
ited number of returned queries, the simultaneous use of two services allowed to slightly increase the variety of questions. In total, we collected 18,262 queries for prefixes corresponding to popular properties, and 3,700 queries for prefixes with expected numerical answers. These queries have been filtered semi-automatically: we removed duplicates, queries without question words, and questions that cannot be answered using solely a knowledge base, e.g. What holiday is it today? After such cleaning, 4,069 unique questions remained, corresponding to 146 properties from the top-200 Wikidata properties, and 1,685 questions with expected numerical answers. We refer to these question samples as TopProperties and LiteralValues, respectively. To obtain answers to the questions, we posted a project on the Toloka crowdsourcing platform.4 The crowd workers’ task was to find one or several answers to a question on the Web or indicate that they cannot find any. The interface contained a link to the Google search results for the question, but the workers were instructed that they are free to modify the search query and use other information sources on the Web. Each question was shown to three workers; we kept all the questions where at least two answers matched.5 In total, we obtained answers for 4,771 questions; Table 2 summarizes the statistics. In addition, we asked the crowd workers to indicate whether the answer was found as a Google instant answer (also called ‘features snippet’). The share of such answers among TopProperties questions was 65.3%, i.e. the search engine answers about 2/3 of the questions using question answering capabilities. The share of instant answers for LiteralValues group was higher – 87.8%. Note that here we only wanted to get some insight into the search engine answering capabilities and did not use the observed estimates in dataset preparation. Table 2. Crowdsourced answers’ statistics: initial number of questions; questions for which no answers are found; number of questions, where two out of three or all three crowd workers agreed on the answers. Sample
Q noA
2/3
3/3 Total
TopProperties 4,069
300 1,278
1,956 3,234
LiteralValues
148
1,685
384
1,153 1,537 Total: 4,771
To complement questions with SPARQL queries, we firstly applied an IRbased entity linker developed for RuBQ 1.0. For each input string, the linker generates several phrase and free-form queries to a search index of all Russian labels and aliases from Wikidata (about 5.4M items). Returned Wikidata entity candidates are ranked based on a combination of confidence value from 4 5
https://toloka.ai/. In case of multiple answers majority voting was applied to individual answers, not the whole list.
538
I. Rybin et al.
the search engine and the popularity of the corresponding Wikipedia pages. The linker proved to be efficient and of high quality, details can be found in the RuBQ 1.0 paper [15]. For the current step, we retained top-5 candidates for each question and answer. Secondly, using the question’s anticipated property, we checked whether a triple (Q_entity, property, A_entity) with any combination of candidate question/answer entities was present in Wikidata.6 This fully automatic procedure resulted in 746 questions linked to Wikidata (407 in TopProperties and 339 in LiteralValues). This approach is quite different from the one of RuBQ 1.0, where entity linking in answers was performed by crowd workers. To increase the number of annotated questions and answers, we manually corrected some questions’ properties and entities. This selective in-house annotation allowed us to reach 1,200 annotated questions to double the size of RuBQ compared to the first version. Since their introduction in SQuAD 2.0 [19], unanswerable questions are featured in many MRC datasets. In the context of an MRC task, such question cannot be answered based on a given paragraph. RuBQ 1.0 and the aforementioned MKQA dataset also contain unanswerable questions. In case of RuBQ, unanswerable questions cannot be answered using the provided Wikidata snapshot. In case of MKQA, this category encompasses ill-formed questions and questions for which no clear answer can be found. We also enriched QSQ with questions, for which the majority of crowd workers agreed on the answer, but the question could not be answered with the current state of Wikidata graph. While many unanswerable quiz questions from the first version of RuBQ can be hardly expressed with Wikidata properties (e.g. How many noses do snails have? )7 , unanswerable QSQs are quite common in their form and cannot be answered rather due to KB incompleteness, e.g. Who is the inventor of streptomycin? As can be seen from the Table 3, using the process described above, we were able to almost double the size of the dataset: the number of questions that can be answered using the current version of Wikidata has doubled, while we added slightly fewer unanswerable questions compared to the first version (210 vs. 300). Questions from search engine suggestion services are significantly shorter than quiz questions. Due to the procedure of matching the answers to the Wikidata entities in the first version of the dataset, there were very few questions with numerical and date answers. When working on the extension, we specifically addressed this problem – half of the added answerable questions have a literal answer. Following RuBQ 1.0, we annotated the questions based on the structure of corresponding SPARQL-queries. As in the previous version of the dataset, the majority of questions (911) are simple, i.e. they are one-hop questions without aggregation.8 While the share of simple questions is about the same as in the first 6 7 8
Note that prefixes sent to the query suggestion service do not guarantee that the returned question expresses the intended property. The answer is four; Google returns an instant answer with a supporting piece of text. Our approach resulted in a slightly lower share of simple questions in QSQ compared to WebQuestions: 76% vs. 85%. It can be attributed to the source of questions and the collection process, as well as to differences in Freebase vs. Wikidata structure.
RuBQ 2.0: An Innovated Russian Question Answering Dataset
539
Table 3. Dataset statistics. RuBQ 1.0 QSQ RuBQ 2.0 Questions
1,500 1,410
2,910
KB-answerable questions
1,200 1,200
2,400
KB-unanswerable questions
300
210
510
Avg. question length (words)
7.9
5.4
6.7
Simple questions (1-hop w/o aggregation)
921
911
1,832
Questions with multiple answers
131
244
375
46
600
646
242
139
294
Unique entities in questions
1,218 1,126
2,114
Unique entities in answers
1,250 1,983
3,166
Questions with literals as answers Unique properties
version, the number of questions with list answers increased significantly. Even though the number of questions doubled, this led to only a moderate increase in unique properties in the dataset – from 242 in the first version to 294 in the second. At the same time, the number of unique entities in questions has almost doubled; the increase in the number of unique answer entities was even more significant. We divided QSQ into dev (280) and test (1,130) subsets maintaining similar ratios of questions types in the subsets. Thus, RuBQ 2.0 contains 580 and 2,330 questions in dev and test sets, respectively. The dataset is available in JSON format; sample entries are shown in Table 4. Table 4. Sample RuBQ 2.0 entries. Questions are originally in Russian; not all dataset fields are shown. Question
How many wives did Henry VIII have?
Answer
6
Answer aliases
six
SPARQL query
SELECT (COUNT(?x) as ?answer) WHERE { wd:Q38370 wdt:P26 ?x. } count, 1-hop
Tags Paragraphs with answers
51089, 51086
Related paragraphs
51086, 51087, 51088, 51089...
Question
Where is Kutuzov buried?
Answer
Q656 (Saint Petersburg)
Answer aliases
Leningrad, Petersburg, St. Petersburg, Petrograd, Sankt-Peterburg
SPARQL query
SELECT ?answer WHERE { wd:Q185801 wdt:P119 ?answer } 1-hop
Tags Paragraphs with answers
416
Related paragraphs
416, 417, 418, 419, 420...
540
I. Rybin et al.
Fig. 2. RuBQ 2.0 MRC creation pipeline.
4
Adding Machine Reading Capabilities
The pipeline of this stage is presented in Fig. 2. To enrich the dataset with machine reading capabilities, we collected all Russian Wikipedia articles corresponding to question and answer entities and split them into paragraphs. For unanswerable questions with no entities linked, we took the top-5 Wikipedia search API results9 using the question as a query. Further, we represented questions and answers as bag of words with stopwords removed and entity name synonyms added. The synonyms included Russian and English labels and aliases (“alternate names”) from Wikidata, as well as the Wikipedia anchor texts pointing to the entity page. In most cases, the anchor text was an inflectional variant of the entity name (e.g. Alexandra Pushkina ru – genitive case of Alexander Pushkin), a short form (Pushkin for Alexander Pushkin), or a cross-POS relationship (for example, Russian adj pointing to Russia noun ). The paragraphs were ranked in descending order of word occurrences from the answer representation; within equal number of occurrences the paragraphs were ranked according to the word occurrences from the question. Further, the top-4 paragraphs containing at least an answer evidence were annotated on the Toloka crowdsourcing platform. These paragraphs correspond to 2,505 questions out of total 2,910; for 405 questions missing supporting para9
https://ru.wikipedia.org/w/api.php.
RuBQ 2.0: An Innovated Russian Question Answering Dataset
541
graphs the answer was often present not in the article body, but in its infobox. The paragraphs were presented to the crowd workers along with the original question, but without the answer. The workers’ task was to mark all paragraphs that provide enough information to answer the question. Each question was initially presented to three workers. If the workers disagreed on at least one of the paragraphs, the task was assigned to two more workers. After that, if the difference between positive and negative label counts is three or higher, the corresponding paragraph is considered relevant. Following this procedure, 8,393 paragraphs were annotated in total. Krippendorf’s alpha for annotation with three choices (yes/no/not sure) is 0.83, which can be considered as a high level of agreement. Crowd workers marked at least one paragraph as providing the answer in case of for 2,138 questions; on average, there are 1.45 supporting paragraphs per question; 367 questions are not provided with an answer-bearing paragraph. Note that 186 (out of 510) KB-unanswerable questions are provided with answer-bearing paragraphs, which can be seen as a potential for hybrid QA. To be able to use the dataset not only to assess machine reading comprehension, but also paragraph retrieval, we added related paragraphs for each answer. For each question, we added up to 25 paragraphs from top-5 Wikipedia search results using question as a query, ranked by the occurrence of words from the answer and question representations in a similar way to how we ranked paragraphs before crowdsourced annotation. In total, we provide 56,952 unique Wikipedia paragraphs as a part of the dataset; the average length of a paragraph is 62 tokens. The data preparation process described above has several advantages. Firstly, the annotation process is simpler and faster compared to SQuAD and similar datasets: crowd workers do not need to select a span within a paragraph – only mark a paragraph as sufficient to answer the question. Secondly, the questions are generated independently from the paragraph, which leads to a more natural and realistic task. When questions are generated by crowd workers based on presented paragraphs like in SQuAD or SberQuAD, they tend to be lexically and structurally similar to sentences containing answers and easier to answer as such, see [16]. In contrast to MRC datasets produced fully automatically based on Q&A pairs and search, relevant paragraphs in RuBQ 2.0 are verified manually.
5 5.1
Baselines KBQA Baselines
Most KBQA research prototypes work with English and Freebase as a target KB. QAnswer and DeepPavlov are only two available KBQA systems for Russian working with Wikidata. We also employed English version of QAnswer along with machine-translated questions, as well implemented a simple rule-based baseline. Thus, the four baseline models reflect a spectrum of approaches to KBQA.
542
I. Rybin et al.
DeepPavlov is an open library featuring models for variety of NLP tasks, including Russian language models [3]. We tested the previous DeepPavlov KBQA system that coped only with simple questions, on RuBQ 1.0 [15]. An improved KBQA model was released by DeepPavlov in summer of 2020.10 The new release has several components and addresses not only simple questions, but also ranking and counting questions, as well as questions requiring reasoning on numerical values and dates. According to its description, the system sequentially performs query type prediction, entity extraction and linking, relation extraction and path ranking, and finally issues an online SPARQL query to Wikidata. QAnswer is a rule-based KBQA system that answers questions in several languages using Wikidata [7]. QAnswer returns a (possibly empty) ranked list of Wikidata item IDs along with a corresponding SPARQL query. Since recently, QAnswer accepts Russian questions. We obtained QAnswer’s results by sending either original Russian or English machine-translated questions to its API.11 We also provide our own rule-based baseline SimBa addressing simple questions.12 The method consists of three components: 1) entity linker based on syntax parsing and a search index, 2) rule-based relation extraction, and 3) SPARQL query generator. The question is parsed with the DeepPavlov parser;13 interrogative word/phrase is identified using a dictionary, and remaining subtrees from the root are candidate entity mentions. These candidates are mapped to Wikidata entities using a search index. Relation extraction method is quite straightforward: we compiled a list of 100 most frequent Wikidata properties and manually generated regular expressions for them.14 A question can match regular expressions corresponding to different properties, all of them are added as candidates. Based on the obtained lists of candidate entities and properties, 1-hop SPARQL queries are constructed for all entity–relation pairs. Once the query returns a non-empty answer from Wikidata, the process terminates and the answer is returned. We calculated the number of correctly answered questions in respective test sets by each of the system. If QAnswer returned a ranked list of answers, only the top answer was considered. In case of multiple correct answers, a system’s answer was counted if it matched any of the reference answers. In case of unanswerable questions, an answer was deemed correct if the systems returned either an empty or “no answer/not found” response. DeepPavlov returns an answer as a string rather than a Wikidata item ID, or not found, so we compared its answers with the correct answer’s label if the correct answer was an entity or with its value if the correct answer was a literal.
10 11 12 13 14
http://docs.deeppavlov.ai/en/master/features/models/kbqa.html. https://qanswer-frontend.univ-st-etienne.fr/. https://github.com/vladislavneon/kbqa-tools/rubq-baseline. http://docs.deeppavlov.ai/en/master/features/models/syntaxparser.html. Although these regular expressions and prefixes for collecting QSQs were developed independently and for different sets of properties, this approach can introduce bias in results.
RuBQ 2.0: An Innovated Russian Question Answering Dataset
543
Table 5. Baselines’ performance: percent of correct answers on the tests subsets. DP – DeepPavlov; QA-Ru and QA-En – Russian and English versions of QAnswer, respectively; SimBa – our simple baseline. Detailed tag descriptions can be found in RuBQ 1.0 paper [15]. Note that some question types in the lower part of the table are too few to make a reliable comparison. DP
QA-Ru
QA-En
SimBa
RuBQ 1.0 Answerable (960) Unanswerable (240) Total (1,200)
28.9 64.2 35.9
23.1 3.8 19.3
22.0 8.3 19.3
26.9 91.3 39.8
19.8 36.5 22.3
30.7 8.8 27.4
34.4 5.3 30.0
23.6 80.6 32.2
24.3 30.5 0.0 0.0 0.0 4.9 3.6 18.2 52.7 29.3
26.9 30.8 0.0 33.3 5.9 19.7 10.9 0.0 5.9 23.2
28.2 32.3 10.0 66.7 5.9 20.4 5.5 0.0 7.1 24.5
25.3 32.3 0.0 0.0 0.0 3.6 1.8 4.5 86.8 36.1
QSQ Answerable (960) Unanswerable (170) Total (1,130) RuBQ 2.0 Answerable (1,920) 1-hop (1,460) 1-hop + reverse (10) 1-hop + count (3) 1-hop + exclusion (17) Multi-constraint (304) Multi-hop (55) Qualifier-constraint (22) Unanswerable (410) Total (2,330)
As one can see from the Table 5, the models behave quite differently on answerable questions of the two parts of the dataset. The quality of both versions of QAnswer improves significantly on QSQ compared to RuBQ 1.0, with the improvement of the English version and machine-translated questions being the most striking (from 22.0% to 34.4%). The accuracy of our simple baseline drops from 26.9% to 23.6%; DeepPavlov’s drop in quality is more significant – from 28.6% to 19.8%. These results indirectly confirm that expanding the dataset is useful – it allows to get more reliable evaluation results. It is interesting to note that machine translated questions sent to the English version of QAnswer show a better result on QSQ than the original questions on the Russian-language QAnswer (English QAnswer outperforms its Russian counterpart on the whole dataset, but the difference is less pronounced). Perhaps this is due to a more advanced English-language system, or to the fact that shorter and more frequent questions from QSQ get better machine translations.
544
I. Rybin et al.
All systems are expectedly better at handling simple (1-hop) questions that make up the bulk of the dataset. Even the proposed simple baseline copes with simple questions on par with more sophisticated systems. However, the approach explicitly assumes the structure of the query and can only handle questions that correspond to a limited set of popular Wikidata properties. Both versions of QAnswer perform best on complex questions. DeepPavlov’s mediocre performance on complex questions can be explained by the fact that the eight patterns that the system operates on are poorly represented among the limited number of RuBQ’s complex questions. Few correct answers returned by a simple baseline to complex questions can be considered an artifact. English QAnswer with machine-translated questions achieved the best score on the answerable questions: 28.2% of correct answers. The result suggests that there is an ample room for improvements in multilingual KBQA methods. The performance of the systems on unanswerable questions sheds some light on their strategies. All the systems in the experiment seem to build a SPARQL query from a question without analyzing the local Wikidata graph or postprocessing the returned results. Due to its cautious strategy, our simple baseline does not return an answer to most of the unanswerable questions. In contrast, QAnswer seems to be a recall-oriented system and returns an answer to almost all questions in both English and Russian versions. 5.2
MRC Baselines
We opted for Multiligual BERT (mBERT) model fine-tuned on MRC task as a baseline. mBERT is a Transformer-based language model pre-trained on the top-100 languages from Wikipedia [6]. Fine-tuned BERT models demonstrated state-of-the-art performance in many downstream NLP tasks, including MRC. Interestingly, BERT-based models show competitive performance in zero-shot cross-lingual setting, when a model is trained on the English data and then applied to the data in another language. Artetxe et al. analyze this phenomenon on multilingual classification and question answering tasks [1]. For our experiments, we fine-tune BERTBASE Multilingual Cased model15 on three training sets: English SQuAD [20], Russian SberQuAD [11], and a Russian subset of TyDi QA Gold Passage [5]. The number of training question-paragraph-answer triples is 87,599, 45,328, and 6,490, respectively. MRC model returns a continuous span as an answer for a given paragraph and question. The answer is evaluated against gold answer spans provided by crowd workers. Traditionally, token-based F1 measure of the best match (in case of multiple gold answers) averaged over all questions is used as evaluation metrics. In our case we do not have explicitly marked answer spans within paragraphs, but have a list of correct answer’s labels and aliases. Note that considering the way the MRC collection was created, the relevant paragraph must contain an answer in one form or another (see Sect. 4 for details). Since Russian is a highly inflectional language, the surface form of the answer in the paragraph may differ 15
https://huggingface.co/bert-base-multilingual-cased.
RuBQ 2.0: An Innovated Russian Question Answering Dataset
545
from a normalized form in the list. We experimented with three approaches to quantify the match between gold answers and model responses: token-based F1, lemmatized token-based F1, and character-based F1. Token-based metrics treat gold and system answers as bags of words, while the character-based metrics calculate the longest common subsequence (LCS) between the gold and the system answers. In case of the lemmatized version, both gold answers and system responses are processed with mystem lemmatizer.16 We consider the lemmatized token-based F1 as the most reliable metrics; however, its disadvantage is the overhead of lemmatization. Table 6. MRC baseline results: F1 based either on word overlap (Tokens and Lemmas), or best longest common subsequence (LCS) between gold and system answers. The second column cites the number of training items. Training set
# items Tokens Lemmas LCS
SQuAD (En, 0-shot) 87,599
0.54
0.70
0.76
SberQuAD (Ru)
45,328
0.48
0.62
0.70
6,490
0.51
0.67
0.73
TyDi QA (Ru)
We applied the models to all 3,638 pairs of questions and relevant paragraphs in the dataset (several relevant paragraphs can be associated with a question). Table 6 reports the performance of the three models. Note that the relative performance of the models is consistent across all metrics. Surprisingly, the model trained on English SQuAD scores the best, while the model trained on a small Russian collection TyDi QA is quite competitive. Although SberQuAD is seven times larger than Russian TyDi QA, it performs worse, probably due to a high level of noise in the annotations as we mentioned in Sect. 2. Although these scores do not account for the paragraph retrieval step and cannot be compared directly with KBQA scores in Table 5, we believe that hybrid KB/text approach to QA can substantially improve the overall results on the dataset.
6
Conclusions
In this work, we described the extension of RuBQ, the Russian dataset for question answering over Wikidata. The first version of the dataset was based on quiz questions and answer pairs harvested on the web. After exhausting this source of questions, we turned to search query suggestion services. This approach proved to be quite efficient: it required manual preparation of question prefixes and a later limited in-house verification; most of the annotation was carried out using crowdsourcing and automated routines. We managed to double the size of the dataset – from 1,500 to 2,910 questions. In addition to questions and Wikidata answers, the dataset contains SPARQL queries, tags indicating query type, 16
https://yandex.ru/dev/mystem/ (in Russian).
546
I. Rybin et al.
English machine translations of the questions, entities in the question, answer aliases, etc. The dataset is accompanied by a Wikidata snapshot containing approximately 8M entities and 212M triples, which ensures the reproducibility of the results. We evaluated three third-party and an own KBQA system on RuBQ. All systems are built on different principles and reflect well the range of approaches to KBQA. Based on the experimental results, we can conclude that the expanded dataset allows for a more reliable evaluation of KBQA systems. We also expanded the dataset with machine reading comprehension capabilities: most questions are provided with Wikipedia paragraphs containing answers. Thus, the dataset can be used to evaluate machine reading comprehension, paragraph retrieval, and end-to-end open-domain question answering. The dataset can be also used for experiments in hybrid QA, where KBQA and text-based QA can enrich and complement each other. We have implemented three simple MRC baselines that demonstrate the feasibility of this approach. The main disadvantage of the dataset is a small number of complex questions. In the future, we plan to address this problem and explore different approaches to complex questions generation [9,23]. The dataset is freely distributed under the CC-BY-4.0 license and will be of interest to a wide range of researchers from various fields – Semantic Web, Information Retrieval, and Natural Language Processing. Acknowledgments. We thank Yaroslav Golubev, Dmitry Ustalov, and anonymous reviewers for their valuable comments that helped improve the paper. We are grateful to Toloka for their data annotation grant. PB acknowledges support from the Ministry of Science and Higher Education of the Russian Federation (the project of the development of the regional scientific and educational mathematical center “Ural Mathematical Center”).
References 1. Artetxe, M., Ruder, S., Yogatama, D.: On the cross-lingual transferability of monolingual representations. In: ACL, pp. 4623–4637 (2020) 2. Berant, J., Chou, A., Frostig, R., Liang, P.: Semantic parsing on Freebase from question-answer pairs. In: EMNLP, pp. 1533–1544 (2013) 3. Burtsev, M., et al.: DeepPavlov: open-source library for dialogue systems. In: ACL (System Demonstrations), pp. 122–127 (2018) 4. Chen, W., et al.: HybridQA: a dataset of multi-hop question answering over tabular and textual data. arXiv preprint arXiv:2004.07347 (2020) 5. Clark, J.H., et al.: TyDi QA: a benchmark for information-seeking question answering in typologically diverse languages. TACL 8, 454–470 (2020) 6. Devlin, J., Chang, M.W., Lee, K., Toutanova, K.: BERT: pre-training of deep bidirectional transformers for language understanding. In: NAACL-HLT, pp. 4171– 4186 (2019) 7. Diefenbach, D., Gim´enez-Garc´ıa, J., Both, A., Singh, K., Maret, P.: QAnswer KG: designing a portable question answering system over rdf data. In: ESWC, pp. 429– 445 (2020)
RuBQ 2.0: An Innovated Russian Question Answering Dataset
547
8. Duan, N.: Overview of the NLPCC 2019 shared task: open domain semantic parsing. In: Tang, J., Kan, M.-Y., Zhao, D., Li, S., Zan, H. (eds.) NLPCC 2019. LNCS (LNAI), vol. 11839, pp. 811–817. Springer, Cham (2019). https://doi.org/10.1007/ 978-3-030-32236-6_74 9. Dubey, M., Banerjee, D., Abdelkawi, A., Lehmann, J.: LC-QuAD 2.0: a large dataset for complex question answering over Wikidata and DBpedia. In: ISWC, pp. 69–78 (2019) 10. Dunn, M., et al.: SearchQA: a new Q&A dataset augmented with context from a search engine. arXiv preprint arXiv:1704.05179 (2017) 11. Efimov, P., Chertok, A., Boytsov, L., Braslavski, P.: SberQuAD-Russian reading comprehension dataset: description and analysis. In: CLEF, pp. 3–15 (2020) 12. Ferrucci, D., et al.: Building Watson: an overview of the DeepQA project. AI Mag. 31(3), 59–79 (2010) 13. Grau, B., Ligozat, A.L.: A corpus for hybrid question answering systems. In: Companion Proceedings of the The Web Conference 2018, pp. 1081–1086 (2018) 14. Joshi, M., Choi, E., Weld, D.S., Zettlemoyer, L.: TriviaQA: a large scale distantly supervised challenge dataset for reading comprehension. In: ACL. pp, 1601–1611 (2017) 15. Korablinov, V., Braslavski, P.: RuBQ: a Russian dataset for question answering over Wikidata. In: ISWC, pp. 97–110 (2020) 16. Kwiatkowski, T., et al.: Natural questions: a benchmark for question answering research. TACL 7, 453–466 (2019) 17. Lewis, P., O˘ guz, B., Rinott, R., Riedel, S., Schwenk, H.: MLQA: evaluating crosslingual extractive question answering. In: ACL, pp. 7315–7330 (2020) 18. Longpre, S., Lu, Y., Daiber, J.: MKQA: a linguistically diverse benchmark for multilingual open domain question answering. arXiv preprint arXiv:2007.15207 (2020) 19. Rajpurkar, P., Jia, R., Liang, P.: Know what you don’t know: unanswerable questions for SQuAD. In: ACL, pp. 784–789 (2018) 20. Rajpurkar, P., Zhang, J., Lopyrev, K., Liang, P.: SQuAD: 100,000+ questions for machine comprehension of text. In: EMNLP, pp. 2383–2392 (2016) 21. Savenkov, D., Agichtein, E.: When a knowledge base is not enough: question answering over knowledge bases with external text data. In: SIGIR, pp. 235–244 (2016) 22. Sun, H., Bedrax-Weiss, T., Cohen, W.W.: PullNet: open domain question answering with iterative retrieval on knowledge bases and text. arXiv preprint arXiv:1904.09537 (2019) 23. Talmor, A., Berant, J.: The web as a knowledge base for answering complex questions. In: NAACL, pp. 641–651 (2018) 24. Unger, C., et al.: Question answering over linked data (QALD-4). In: Working Notes for CLEF 2014 Conference, pp. 1172–1180 (2014) 25. Usbeck, R., et al.: 9th challenge on question answering over linked data (QALD-9). In: SemDeep-4, NLIWoD4, and QALD-9 Joint Proceedings, pp. 58–64 (2018) 26. Yih, W., Richardson, M., Meek, C., Chang, M.W., Suh, J.: The value of semantic parse labeling for knowledge base question answering. In: ACL, pp. 201–206 (2016)
A Knowledge Organization System for the United Nations Sustainable Development Goals Amit Joshi1(B) , Luis Gonzalez Morales1 , Szymon Klarman2 , Armando Stellato3 , Aaron Helton4 , Sean Lovell1 , and Artur Haczek2 1
United Nations, Department of Economic and Social Affairs, New York, NY, USA {joshi6,gonzalezmorales,lovells}@un.org 2 Epistemik, Warsaw, Poland {szymon.klarman,artur.haczek}@epistemik.co 3 Department of Enterprise Engineering, University of Rome Tor Vergata, Via del Politecnico 1, 00133 Rome, Italy [email protected] 4 United Nations, Dag Hammarskj¨ old Library, New York, NY, USA [email protected]
Abstract. This paper presents a formal knowledge organization system (KOS) to represent the United Nations Sustainable Development Goals (SDGs). The SDGs are a set of objectives adopted by all United Nations member states in 2015 to achieve a better and sustainable future. The developed KOS consists of an ontology that models the core elements of the Global SDG indicator framework, which currently includes 17 Goals, 169 Targets and 231 unique indicators, as well as more than 450 related statistical data series maintained by the global statistical community to monitor progress towards the SDGs, and of a dataset containing these elements. In addition to formalizing and establishing unique identifiers for the components of the SDGs and their indicator framework, the ontology includes mappings of each goal, target, indicator and data series to relevant terms and subjects in the United Nations Bibliographic Information System (UNBIS) and the EuroVoc vocabularies, thus facilitating multilingual semantic search and content linking. Keywords: United Nations · Sustainable Development Goals · SDGs Ontology · Linked data · Knowledge organization systems · Metadata
1
·
Introduction
On 25 September 2015, all members of the United Nations adopted the 2030 Agenda for Sustainable Development [11], centred around a set of 17 Sustainable Development Goals (SDGs) and 169 related Targets, which constitutes a global call for concerted action towards building an inclusive, prosperous world for present and future generations. This ambitious agenda is the world’s roadmap c Springer Nature Switzerland AG 2021 R. Verborgh et al. (Eds.): ESWC 2021, LNCS 12731, pp. 548–564, 2021. https://doi.org/10.1007/978-3-030-77385-4_33
A KOS for UN SDGs
549
to address, in an integrated manner, complex global challenges such as poverty, inequality, climate change, environmental degradation, and the achievement of peace and justice for all. To follow-up and review the implementation of the 2030 Agenda, the United Nations General Assembly also adopted in 2017 a Global SDG indicator framework [12], developed by the Inter-Agency and Expert Group on SDG Indicators (IAEG-SDGs), as agreed earlier that year by the United Nations Statistical Commission1 , and entrusted the UN Secretariat with maintaining a Global SDG indicator database of statistical data series reported through various international agencies to track global progress towards the SDGs2 . After its most recent comprehensive review, approved by the Statistical Commission in March 2020, the current version of the Global SDG indicator framework consists of 231 unique indicators specifically designed for monitoring each of the 169 targets of the 2030 Agenda using data produced by national statistical systems and compiled together for global reporting by various international custodian agencies. While data availability is still a challenge for some of these indicators, there are already more than 450 statistical data series linked to most of these indicators in the Global SDG Indicator database, many of which are further disaggregated by sex, age, and other important dimensions. Data from the Global SDG database is made openly available to the public through various platforms, including an Open SDG Data Hub3 that provides web services with geo-referenced SDG indicator dataset, as well as an SDG API4 that can support third-party applications such as dashboards and data visualizations. In this paper, we describe the formal knowledge organization system (KOS) that has been developed for representing the United Nations Sustainable Development Goals (SDGs). In the following section, we provide the background and related linked data initiatives for the SDGs. Section 3 explains the key SDG terminologies and the ontology depicting the relationship between various SDG elements and concepts, as well as the mapping of terms and concepts in SDGs to external vocabulary and ontology. We evaluate and assess the impact of the SDG KOS in Sect. 4 and provide a brief explanation of LinkedSDG application in Sect. 5 that showcases the importance of such KOS for analysis and visualization of SDG documents. Finally, we provide the concluding remarks in Sect. 6.
1
2 3 4
This global SDG indicator framework is annually refined and subject to periodic comprehensive reviews by the UN Statistical Commission, which is the intergovernmental body where Chief Statisticians from member states oversee international statistical activities and the development and implementation of statistical standards. https://unstats.un.org/sdgs/indicators/database/. https://unstats-undesa.opendata.arcgis.com/. https://unstats.un.org/SDGAPI/swagger/.
550
2
A. Joshi et al.
Towards a Linked Open Data Representation of the SDGs and Their Indicator Framework
The multilingual United Nations Bibliographic Information System (UNBIS) Thesaurus [10], created by the Dag Hammarskj¨ old Library, contains the terminology used in subject analysis of documents and other materials relevant to United Nations programme and activities. It is used as the subject authority and has been incorporated as the subject lexicon of the United Nations Official Document System. In December 2019, the Dag Hammarskj¨old launched a platform for linked data services (http://metadata.un.org) to provide both human and machine access to the UNBIS. At the second meeting of the Inter-Agency Expert Group on Sustainable Development Goals (IAEG-SDGs) held in Bangkok on October 2015, the UN Environment Programme (UNEP) proposed to develop an SDG Interface Ontology (SDGIO) [3], focused on the formal specification and representation of the various meanings and usages of SDG-related terms and their interrelations5 . Subsequently, UNEP led a working group to develop the SDGIO, which either created new content or coordinated the re-use of content from existing ontologies, applying best practices in ontology development from mature work of the Open Biological and Biomedical Ontology (OBO) Foundry and Library. Currently, the SDGIO includes more than 100 terms specifying the key entities involved in the SDG process and linking them with the goals, targets, and indicators. At its thirty-third Session held in Budapest between 30–31 March 2017, the High-level Committee on Management (HLCM) of the United Nations System’s Chiefs Executives Board for Coordination adopted the UN Semantic Interoperability Framework (UNSIF) for normative and parliamentary documents, which includes Akoma Ntoso for the United Nations System (AKN4UN)6 . Akoma Ntoso was originally developed in the context of an initiative by the UN Department of Economic and Social Affairs (UN DESA) to support the interchange and citation of documents among African parliaments and institutions and was subsequently formalized as an official OASIS standard7 . In 2017, technical experts from across the UN System with backgrounds in library science, information architecture, semantic web, statistics and SDG indicators, agreed to initiate informal working group to develop a proposal for an “SDG Data ontology”, based on the global SDG Indicator Framework adopted by the Statistical Commission8 . The main objective of this effort was to contribute to the implementation of a linked open data approach and allow data users to more easily discover and integrate different sources of SDG-related information 5 6 7 8
This includes terms such as ‘access’, which occurs 31 times in the SDG Global Indicator Framework. https://www.w3id.org/un/schema/akn4un/. https://www.oasis-open.org/. The group includes representatives from UNSD and other UN offices, including from UN DESA and the UN Library, as well as experts involved in the development of the UN Semantic Interoperability Framework adopted by the High-Level Committee on Management (HLCM) of the CEB.
A KOS for UN SDGs
551
from across the UN System into end-user applications. The group concluded a first draft of an SDG ontology as part of the SDG Knowledge Organization System (SDG KOS), consisting of a set of permanent Uniform Resource Identifiers (URIs) for the Goals, Targets and Indicators of the 2030 Agenda and their related statistical data series based on the SKOS model. In order to ensure their fullest possible use, the Identifiers and a formal Statement of Adoption were presented at the second regular session of the UN System Chief Executives Board for Coordination (CEB) in November 2019. At the CEB session, the Secretary-General invited all UN organizations to use them for mapping their SDG-related resources and sign the Statement. Subsequently, at its 51st session held in March 2020, the United Nations Statistical Commission took note of this common Internationalized Resource Identifiers for Sustainable Development Goals, targets, indicators and related data series, and encouraged the dissemination of data in linked open data format9 .
3
SDG Knowledge Organization System
3.1
SDG Terminologies
A sustainable development goal expresses an ambitious, but specific, commitment, and always starts with a verb/action. Each goal is related to a number of targets, which are quantifiable outcomes that contribute in major ways to the achievement of the corresponding goal. An indicator, in turn, is a precise metric to assess whether a target is being met. There may be more than one indicator associated with each target. In rare cases, the same indicator can belong to multiple targets. The global indicator framework lists 247 indicators but has only 231 unique indicators10 . Finally, a series is a set of observations on a quantitative characteristic that provides concrete measurements for an indicator. Each series contains multiple records of data points organized over time, geographic areas, and/or other dimensions of interest (such as sex, age group, etc.). To facilitate the implementation of the global indicator framework, all indicators are classified into three tiers based on their level of methodological development and the availability of data at the global level, as follows: – Tier I: Indicator is conceptually clear, has an internationally established methodology and standards are available, and data are regularly produced by countries. – Tier II: Indicator is conceptually clear, but data are not regularly produced by countries. 9
10
See https://www.undocs.org/en/E/CN.3/2020/37 - United Nations Statistical Commission, Decision 51/102 (g) on Data and indicators for the 2030 Agenda for Sustainable Development. See https://unstats.un.org/sdgs/indicators/indicators-list for the updated list of indicators that repeat under two or three targets.
552
A. Joshi et al.
– Tier III: No internationally established methodology or standards are yet available for the indicator. The updated tier classification contains 130 Tier I indicators, 97 Tier II indicators and 4 indicators that have multiple tiers (different components of the indicator are classified into different tiers)11 . 3.2
Namespaces
The namespace for SDG ontology is http://metadata.un.org/sdg/. The ontology extends and reuses terms from several other vocabularies in addition to UNBIS and EuroVoc. A full set of namespaces and prefixes used in this ontology is shown in Table 1. Table 1. Namespaces used in SDG ontology Prefix Namespace sdgo:
http://metadata.un.org/sdg/ontology
dc:
http://purl.org/dc/elements/1.1/
owl:
http://www.w3.org/2002/07/owl#
rdf:
http://www.w3.org/1999/02/22-rdf-syntax-ns#
rdfs:
http://www.w3.org/2000/01/rdf-schema#
xsd:
http://www.w3.org/2001/XMLSchema#
skos:
http://www.w3.org/2004/02/skos/core#
wd:
http://www.wikidata.org/entity/
sdgio: http://purl.unep.org/sdg/ unbis: http://metadata.un.org/thesaurus/
3.3
ev:
http://eurovoc.europa.eu/
dct:
http://purl.org/dc/terms/
Schema
The SDG ontology formalizes the core schema of SDG goal-target-indicatorseries hierarchy, consisting of four main classes namely sdgo:Goal, sdgo:Target, sdgo:Indicator and sdgo:Series, which correspond to the four levels of the SDG hierarchy, and three matching pairs of inverse properties – one per each level, as shown in Fig. 1. The properties are further constrained by standard domain and range restrictions. While logically shallow, such axiomatization avoids unnecessary overcommitment and guarantees good interoperability across different ontology management tools. 11
List is regularly updated and available at https://www.undocs.org/en/E/CN.3/2020 /37.
A KOS for UN SDGs
553
skos: Concept
rdfs: subClassOf
sdgo: Goal
rdfs: subClassOf
sdgo: Target
rdfs: subClassOf
sd g sk o:h os a :n sT a ar sd ro rge go t w sk :is e r T os :b arg ro e ad tO f er
Furthermore, the SDG ontology is aligned with (by extending it) the SKOS Core Vocabulary12 , a lightweight W3C standard RDF for representing taxonomies, thesauri and other types of controlled vocabulary [8]. This alignment rests upon the set of sub-class and sub-property axioms as shown in Fig. 1, which additionally emphasizes the strictly hierarchical structure of the SDG entities. The top concepts in the resulting SKOS concept scheme are the SDG goals, while the narrower concepts, organized into three subsequent levels, include targets, indicators, and series, respectively. The choice of SKOS is not restrictive on the nature of SDG items: SKOS and specific OWL constructs can be intertwined into elaborated ontologies that guarantee both strict adherence to a domain (through the definition of domainoriented properties, such as the aforementioned properties linking the strict 4layered architecture of the SDGs) and interoperability on a coarser level. For instance, the use of skos:narrower and skos:broader allows any SKOS-compliant consumer to properly interpret the various levels of the SDG as a hierarchy and to show it accordingly.
sd
go sk :ha sI os n :n sd ar dica go ro w tor : er sk isIn os di :b ca ro t ad orO er f rdfs: subClassOf
f
O
es
S
is
sd
: go
i er
er
ad
o br
:
os sk
s
ie
er
er ow r r
S as
h o:
g
sdgo: Series
sdgo: Indicator
sd
a
:n
os sk
Fig. 1. Core structure of the SDG ontology modelled using SKOS vocabulary
Following from the SKOS specifications, the skos:broader/narrower relation is not meant to imply any sort of “subclassification” (e.g. according to the set12
https://www.w3.org/2009/08/skos-reference/skos.html.
554
A. Joshi et al.
oriented semantics of OWL) and indeed it should not for two reasons: a) extensionally, each object in the SDG, be it a goal, target or indicator, is not a class of objects, but rather a specific object itself; b) the SKOS hierarchy does not suggest any sort of specialization, as the relations among the various levels are closer to different nuances of a dependency relation. SKOS properties skos:broader/narrower (their name could be misleading) represent a relation meant exclusively for depicting hierarchies, with no assumption on their semantics (see, for instance, the possibility to address a part-of relation as indicated in the SKOS-primer13 ). This is perfectly fitting for the SDG representation, as SDGs are always disseminated as a taxonomy. Finally, the SDG ontology also covers a three-level Tier classification for Global SDG Indicators, which supports additional qualification of the indicators in terms of their implementation maturity. 3.4
SDG Data
The SDG data, analogously to the schema-level, is represented in terms of two terminologies: the native SDG ontology and the SKOS vocabulary. Every instance is described as a corresponding SDG element and a SKOS concept. As an example, Table 2 presents data pertaining to the SDG Target 1 of Goal 1. Table 2. RDF Description of SDG Target 1.1 Subject = http://metadata.un.org/sdg/1.1 Predicate rdf:type
Object skos:Concept
rdf:type
sdgo:Target
skos:inScheme
http://metadata.un.org/sdg
skos:broader
:1
sdgo:isTargetOf
:1
skos:narrower
:C010101
sdgo:hasIndicator :C010101
13
skos:prefLabel
“By 2030, eradicate extreme poverty for all people everywhere, currently measured as people living on less than $1.25 a day” @en
skos:prefLabel
“D’ici ` a 2030, ´ eliminer compl` etement l’extrˆ eme pauvret´ e dans le monde entier (s’entend actuellement du fait de vivre avec moins de 1,25 dollar ´ des Etats’Unis par jour)” @fr
skos:prefLabel
“De aqu´ı a 2030, erradicar para todas las personas y en todo el mundo la pobreza extrema (actualmente se considera que sufren pobreza extrema las personas que viven con menos de 1,25 d´ olares de los Estados Unidos al d´ıa)”@es
skos:notation
“1.1” ˆˆsdgo:SDGCodeCompact
skos:notation
“01.01” ˆˆsdgo:SDGCode
skos:note
“Target 1.1” @en
skos:note
“Cible 1.1” @fr
skos:note
“Meta 1.1” @es
https://www.w3.org/TR/skos-primer/#sechierarchy.
A KOS for UN SDGs
555
The labels and values of skos:notation property reflect the official naming and classification codes of each element. The codes are represented in two notational variants catering for different presentation and data reconciliation requirements. In several cases the indicators and series have more than one broader concept in the hierarchy, as defined in the Global indicator framework. For instance, the indicator sdg:C200303 appears as narrower concept (sdgo:isIndicatorOf ) of targets 1.5, 11.5 and 13.1, and is consequently equipped with three different sets of codes: “01.05.01”, “1.5.1”, “11.05.01”, “11.5.1”, “13.01.01”, “13.1.1”. Due to this poly-hierarchy, the indicators are equipped with an additional set of unique identifier codes of the form “Cxxxxxx ” . Table 3 shows the partial RDF description of this indicator C200303. The unique identifiers of the SDG series, reflected in their URIs and in the values of the skos:notation property, follow the official coding system of the UN Statistics Division14 . As the list of relevant SDG series is subject to recurrent updates, their most recent version captured in the published SDG ontology is represented under the skos:historyNote property (“2019.Q2.G.01” at the time of writing). Table 3. RDF description of SDG indicator C200303 depicting poly-hierarchy Subject = http://metadata.un.org/sdg/C200303 Predicate
Object
rdf:type
skos:Concept sdgo:Indicator
skos:inScheme
http://metadata.un.org/sdg
skos:broader
:1.5 :11.5 :13.1
sdgo:isIndicatorOf
:1.5 :11.5 :13.1
skos:narrower
sdg:VC DSR AFFCT sdg:VC DSR DAFF sdg:VC DSR DDHN
sdgo:hasSeries
sdg:VC DSR AFFCT sdg:VC DSR DAFF sdg:VC DSR DDHN
sdgo:tier
sdgo#tier II
skos:prefLabel
“Number of deaths, missing persons and directly affected persons attributed to disasters per 100,000 population” @en
skos:notation
“1.5.1” ˆˆsdgo:SDGCodeCompact “01.05.01” ˆˆsdgo:SDGCode “11.5.1” ˆˆsdgo:SDGCodeCompact “11.05.01” ˆˆsdgo:SDGCode “13.1.1” ˆˆsdgo:SDGCodeCompact “13.01.01” ˆˆsdgo:SDGCode “C200303” ˆˆsdgo:SDGPerm
skos:exactMatch
http://purl.unep.org/sdg/SDGIO 00020006
skos:custodianAgency “UNDRR” 14
https://unstats.un.org/sdgs/indicators/database/.
556
3.5
A. Joshi et al.
Linking the SDG Ontology
The SDG ontology has been enriched with additional mappings to existing vocabularies and ontologies in order to facilitate content cataloguing, semantic search, and content linking. Specifically, each goal, target and indicator has been mapped with topics and concepts defined in UNBIS and EuroVoc15 thesauri. Identifiers have also been mapped to external ontologies like SDGIO and Wikidata16 . Wikidata is a free and open structured knowledge base that can be read and edited by both humans and machines [4]. Figure 2 depicts association of sdg:1 to wikidata and SDGIO via skos:exactMatch, as well as concept mappings to UNBIS and EuroVoc via dct:subject. Mapping the SDG elements to both UNBIS and EuroVoc thesauri enables knowledge discovery as both contain large number of concepts across many domains. The UNBIS Thesaurus contains more than 7000 concepts across 18 domains and 143 micro-thesauri with lexicalizations in the six official languages of the UN, providing one of the most complete multilingual resources in the organization. EuroVoc is European Union’s multilingual and multidisciplinary thesaurus that contains more than 7000 terms, organized in 21 domains and 127 sub-domains. Section 5 provides further details on the importance of linking to external vocabulary for extracting relevant SDGs.
End poverty in all forms in sustainability”@en
end poverty in all its forms everywhere” @en
at M xa
ct
skos:prefLabel ev:2281
:e sk os sdg:1
rdfs:label
ch
rdfs:lab el
sdgio: SDGIO 00000035
sub
:
dct
dct:subject
dct
Poverty”@en
t jec
unbis:1005064
skos:prefLabel
poverty”@en
sk os
:su
b je
ct
:e
xa
skos:prefLabel
ct
unbis:1005065
M
at
Poverty: mitigation”@en
ch
wd: Q50214636
rdfs:label
Sustainable Development Goal 1 No Poverty”@en
Fig. 2. SDG Goal#1 linked to other vocabularies including UNBIS and EuroVoc. 15 16
https://op.europa.eu/en/web/eu-vocabularies. https://www.wikidata.org/.
A KOS for UN SDGs
4
557
Evaluation and Impact of the SDG
In this section we evaluate and assess the impact of the SDG KOS under several dimensions, including usability, logical consistency and support of multilingualism. 4.1
Usability
The resource is mainly modelled as a SKOS concept scheme, for ease of consumption and interpretation of the SDG taxonomy by SKOS-compliant tools. As a complement to that, the ontology vocabulary provides different subclasses of the skos:Concept (adopted in the KOS) for clearly distinguishing the nature of Goals, Targets, Indicators and Series, and subproperties of skos:broader and skos:narrower. OWL axioms constrain the hierarchical relationships among them (for example, Targets can only be under Goals and have Indicators as narrower concepts). Both the ontology and the SKOS content are served through multilingual descriptors (see Sect. 4.4), thus facilitating interpretation of the content across various idioms and annotation of textual content with respect to these global indicators. skos:notations are provided in three different formats (according to various ways in which the global indicators codes have been rendered). For each format, a different datatype has been coined and adopted, so that platforms with advanced rendering mechanisms (e.g. VocBench [9]) can select the proper one and use it as a prefix in the rendering of each global indicator (e.g. notation and description). 4.2
Resource Availability
The SDGs are available on the site of the statistical division of the UN through a web interface17 , allowing for the exploration of their content, and as Excel and PDF files. The Linked Open Data (LOD) version of the dataset is available on the metadata portal of the UN, with separate entries for the ontology18 and the taxonomy of global indicators19 . The namespace of SDG ontology and KOS have been introduced in Sect. 3. As a large organization with a solid management of its domain, the LOD version of the dataset does not rely on an external persistent URI service (e.g. PURL, DOI, W3ID) as the metadata.un.org URIs can be considered persistent and reliable. All URIs resolve through content negotiation. The ontology offers a web page for human consumption describing its content, resolving to the ontology file20 in case of requests for RDF data. The KOS provides an explorable taxonomy on a web interface at the URI of the concept scheme and human-readable descriptions (generated after the RDF data) 17 18 19 20
https://unstats.un.org/sdgs/indicators/database/. http://metadata.un.org/sdg/ontology. http://metadata.un.org/sdg/. e.g. http://metadata.un.org/sdg/static/sdgs-ontology.ttl for Turtle format.
558
A. Joshi et al.
of each single global indicator at their URIs. All of them http-resolve to RDF in several serialization formats (currently Turtle, RDF/XML, NT and JSON-LD). The project related to the development of the SDG data and the data itself (available as download dumps) are available under a public GitHub repository21 . Sustainability. SDGs are a long-term vision of the United Nations with an end date of year 2030. As such, the SDG KOS and associated tools and libraries will be actively maintained and updated over the years and are expected to be reachable even in case the SDG mission is considered concluded. Licensing: The SDG Knowledge Organization System is made available free of charge and may be copied freely, duplicated and further distributed provided that a proper citation is provided. License information is also available on its VoID descriptors. 4.3
VoID/LIME Description
Metadata about the linked open dataset has been reported in a machineaccessible VoID [1] and LIME [5] files at UN Metadata site22 . The VoID file also contains entries linking the download dumps. VoID is an RDF vocabulary for describing linked datasets, which has become a W3C Interest Group Note23 . VoID provides the policies for its publication and linking to the data [6] and also defines a protocol to publish dataset metadata alongside the actual data, making it possible for consumers to discover the dataset description just after encountering a resource in a dataset. Developed within the scope of the OntoLex W3C Community Group24 , LIME is an extension of VoID for linguistic metadata. While being initially developed as the metadata module of the OntoLex-Lemon model25 [7], LIME intentionally provides descriptors that can be adapted to different scenarios (e.g. ontologies or thesauri being lexicalized, resources being onomasiologically or semasiologically conceived) and models adopted for the lexicalization work (rdfs:labels, SKOS or SKOS-XL terminological labels or Ontolex lexical entries). The VoID description is organized by first providing general information about the dataset through the usual Dublin core [2] properties, such as description, creator, date of publication, etc. Of particular notice is the dct:conformsTo property, pointing in this case to the SKOS namespace and which can be adopted by metadata consumers in order to understand the core modelling vocabularies being adopted representing the dataset. The description is followed by a few void:classPartitions providing statistics about the types of resource characterizing the type of dataset (as informed by the aforementioned dct:conformsTo). In the case of SDG, the template for SKOS has therefore been applied, providing statistics for skos:Concepts, skos:Collections and skos:ConceptSchemes, 21 22 23 24 25
https://github.com/UNStats/LOD4Stats/wiki. http://metadata.un.org/sdg/void.ttl. http://www.w3.org/TR/void/. https://www.w3.org/community/ontolex/. https://www.w3.org/2016/05/ontolex/.
A KOS for UN SDGs
559
reporting a total of 812 concepts, 1 concept scheme and 1 collection. The description continues with typical void information, such as statistics about the number of distinct subjects (1002), objects (6842), triples (14645), availability of a SPARQL endpoint and downloadable data dump (void:dataDump), which we provided for the full dump as well as for some partitioned versions of the dataset (e.g. ontology only, Goal, Target, Indicator only, etc.). Finally, a list of subsets are then described in detail in the rest of the file. This list is mainly composed of void:Linksets, which are datasets consisting of a series of alignment triples between the described dataset and other target datasets, and of lime:Lexicalizations, the portions of the described dataset containing all the triples related to the (possibly multiple, as in this case) lexicalizations that are available for it. Each lexicalization is described in terms of its lexicalization model (which in the case of the SDGs is SKOS), of the natural language covered by the lexicalization, expressed in terms of ISO639-1 2-digit code as a literal (through property lime:language), and of ISO639-1 2-digit code and ISO639-3 3-digit code in the form of URIs using the vocabulary of languages26 of the Library of Congress27 . It also includes information about the lexicalized dataset (lime:referenceDataset) and void-like statistical information such as the total number of lexicalized references, the number of lexicalizations, the average number of lexicalizations per reference and the percentage of lexicalized references. More details about the available lexicalizations will be provided in Sect. 4.4 on multilingualism. 4.4
Multilingualism
As the SDGs are a United Nations resource, multilingualism is an important factor and a goal to be achieved. Currently, the resource is available in three languages: English, French and Spanish. As reported in the LIME metadata within the VoID file, English is currently the most represented language (being the one natively used for redacting the SDGs), with 99.9% of resources (813 out of 814) covered by at least a lexicalization (which means it includes the Series linked to the SDGs as well) and an average number of 1,021 lexicalizations per resource, thus allowing for some cases of synonymy. French and Spanish follow almost equally with 422 and 420 lexicalizations respectively covered (roughly 51.4% of the resources). This is approximately equal to the total number of Goals, Targets and Indicators combined, and excludes the Series which still have to be translated to these languages. Other languages are being planned to be added to the list of lexicalizations. 4.5
A Comparison with the SDGIO Ontology
The SDGIO claims to be an Interface Ontology (IO) for SDGs, providing “a semantic bridge between 1) the Sustainable Development Goals, their targets, 26 27
http://id.loc.gov/vocabulary/. https://loc.gov/.
560
A. Joshi et al.
and indicators and 2) the large array of entities they refer to” . To achieve this objective, it “imports classes from numerous existing ontologies and maps to vocabularies such as GEMET to promote interoperability” . Among various connections, SDGIO strongly builds on multiple OBO Foundry ontologies “to help link data products to the SDGs” . The SDGIO offers a very specific interpretation, where the various Goals, Targets and Indicators are instances of their respective classes and then Indicators have also a “sustainable development goal indicator value” class (which contains, as subclasses, the various indicators) to contain values for these indicators. The SDGIO does not include any information about the Series. Differently from the objectives of SDGIO, which is focused on its interfacing aspect and is based on a strong commitment to OBO ontologies, our mission was to build the official representation of SDGs and to place it under a largely interoperable, yet neutral, perspective. To this end, we represented SDG elements as ground objects, providing an ontology for describing their nature and mutual relationships, which builds in turn on top of the SKOS vocabulary, for purposes of visualization in SKOS-compliant consumers.
5
Knowledge Discovery and Linking SDGs
The SDG ontology is part of an emerging system of SDG-related ontologies that aim to provide data inter-operability and a flexible interface for querying linkages across independent information systems. Mapping the identifiers described in these ontologies to each other and to external vocabularies allows SDG data to be clearly identified and found by semantic web agents for establishing further links and connections thereby facilitating knowledge discovery. A pilot application, LinkedSDG28 , has been built to showcase the usefulness of adopting SDG KOS for extracting SDG related metadata from documents and establishing the connections among various SDGs. The application automatically extracts relevant SDG concepts mentioned in a given document using SDG KOS and provides their unified overview. All SDGs related to the identified concepts are displayed in an interactive wheel chart that users can further explore by drilling into associated goals, targets, indicators and series. Figures 3 and 4 depicts different components of application including concept extraction, map, SDG wheel chart and associated data series for one of the Voluntary National Reviews (VNRs)29 . The application can process documents written in any one of the six UN official languages. The two key analytical techniques employed in LinkedSDG are taxonomybased term extraction and knowledge graph traversal. The term extraction mechanism, implemented using the spaCy library30 , scans the submitted document for all literal mentions of the relevant UNBIS and EuroVoc concept labels, based on the initially detected language of the document, and associates them with their 28 29 30
http://linkedsdg.apps.officialstatistics.org/, source code for the application available at: https://github.com/UNGlobalPlatform/linkedsdg. See https://sustainabledevelopment.un.org/ for VNR documents. https://spacy.io/.
A KOS for UN SDGs
561
Fig. 3. Application displaying extracted concepts and corresponding tag cloud, and a map highlighted with geographic regions mentioned in a document.
respective concept identifiers. The traversal, performed using SPARQL via the underlying Apache Jena RDF store31 , starts from these extracted concept identifiers, following to broader ones, to finally reach those connected directly to the elements of the SDG system via the dct:subject and skos:exactMatch predicates. Then, the algorithm traces the paths to broader SDG entities in the SDG KOS hierarchy. For instance: – text: “[...] beaches, estuaries, dune systems, mangroves, marshes lagoons, swamps, reefs, etc. are [...]” – extracted concept: WETLANDS (unbis:1007000) via the matched synonym “marshes” – traversed path: WETLANDS - (broader) → SURFACE WATERS (unbis:1006307) - (broader) → WATER (unbis:030500) – connected target: 6.5 By 2030, implement integrated water resources management at all levels, including through transboundary cooperation as appropriate – connected goal: 6. Clean water and sanitation The computation of the final relevance scores for specific goals, targets and indicators relies on their exact positioning in the SDG hierarchy, which is reflected by the SKOS representation of the system, and on their types, asserted 31
https://jena.apache.org/.
562
A. Joshi et al.
Fig. 4. Application showing the most relevant SDG keywords corresponding to Target 3.3, an interactive SDG wheel corresponding to a document and related data series for one of the Indicators
in the SDG ontology. Intuitively, the broader the terms (i.e., the higher in the hierarchy) the higher score they receive, as they aggregate the scores in the lower parts of the hierarchy. The application also provides access to the statistical data of the specific SDG series, which is represented as linked open statistical data using the RDF Data Cube vocabulary32 . The relevant SDG series identifiers are referenced from the extraction results delivered by the application and independently served by the platform’s dedicated GraphQL API33 . Consequently, SDG KOS fueling the LinkedSDG platform supports the user in the entire journey from a text document to the relevant statistics, helping put the originally unstructured, thirdparty information, in the context of narrowly focused, UN-owned structured data.
6
Conclusion
The integration of multiple sources and types of data and information is fundamental to guide policies aimed to achieve the 2030 Agenda for Sustainable Development. The complexity and scale of the global challenges require solutions that 32 33
https://www.w3.org/TR/vocab-data-cube/. http://linkedsdg.apps.officialstatistics.org/graphql/.
A KOS for UN SDGs
563
take into account trade-offs and synergies across the social and economic dimensions of sustainable development. In order to foster a holistic approach through coordinated policies and actions that bring together different levels of government and actors from all sectors of society, it is crucial to develop tools that facilitate the discovery and analysis of interlinkage across various global SDG indicators, as well as across other sources of data, information and knowledge maintained by different stakeholder groups. The SDG KOS is an attempt to provide stakeholders a means to publish the data using common terminologies and URIs centred around the SDG concepts, thus helping break information silos, promote synergies among communities, and enhance the semantic interoperability of different SDG-related data and information assets made available by various sectors of society. Acknowledgements. Much of the work towards developing the SDG KOS and the LinkedSDG pilot application was conducted in the context of a UN DESA project funded through the EU grant entitled “SD2015: Delivering on the promise of the SDGs”. The authors would like to acknowledge the invaluable contributions and guidance from Naiara Garcia Da Costa Chaves, Susan Hussein, Flavio Zeni, as well as from many other colleagues from UN DESA, the Dag Hammarskj¨ old Library, and the Secretariat of the High Level Committee on Management of the UN Chief Executive Board for Coordination.
References 1. Alexander, K., Cyganiak, R., Hausenblas, M., Zhao, J.: Describing linked datasets on the design and usage of void, the vocabulary of interlinked datasets. In: Linked Data on the Web (LDOW) Workshop, in Conjunction with 18th International World Wide Web Conference (2009) 2. Bird, S., Simons, G.: Extending Dublin Core metadata to support the description and discovery of language resources. Comput. Humanit. 37(4), 375–388 (2003) 3. Buttigieg, P.L., Jensen, M., Walls, R.L., Mungall, C.J.: Environmental semantics for sustainable development in an interconnected biosphere. In: ICBO/BioCreative (2016) 4. Erxleben, F., G¨ unther, M., Kr¨ otzsch, M., Mendez, J., Vrandeˇci´c, D.: Introducing Wikidata to the linked data Web. In: Mika, P., et al. (eds.) ISWC 2014. LNCS, vol. 8796, pp. 50–65. Springer, Cham (2014). https://doi.org/10.1007/978-3-31911964-9 4 5. Fiorelli, M., Stellato, A., McCrae, J.P., Cimiano, P., Pazienza, M.T.: LIME: the metadata module for OntoLex. In: Gandon, F., Sabou, M., Sack, H., d’Amato, C., Cudr´e-Mauroux, P., Zimmermann, A. (eds.) ESWC 2015. LNCS, vol. 9088, pp. 321–336. Springer, Cham (2015). https://doi.org/10.1007/978-3-319-18818-8 20 6. Gandon, F., Sabou, M., Sack, H., d’Amato, C., Cudr´e-Mauroux, P., Zimmermann, A.: The semantic web. latest advances and new domains. In: ESWC 2015-European Semantic Web Conference, vol. 9088, p. 830. Springer (2015). https://doi.org/10. 1007/978-3-319-18818-8 7. McCrae, J.P., Bosque-Gil, J., Gracia, J., Buitelaar, P., Cimiano, P.: The OntoLexLemon model: development and applications. In: Proceedings of eLex 2017 Conference, pp. 19–21 (2017)
564
A. Joshi et al.
8. Miles, A., Matthews, B., Wilson, M., Brickley, D.: SKOS Core: simple knowledge organisation for the Web. In: International Conference on Dublin Core and Metadata Applications, pp. 3–10 (2005) 9. Stellato, A., Fiorelli, M., Turbati, A., Lorenzetti, T., van Gemert, W., Dechandon, D., Laaboudi-Spoiden, C., Gerencs´er, A., Waniart, A., Costetchib, E., Keizer, J.: VocBench 3: a collaborative semantic web editor for ontologies, thesauri and lexicons. Semantic Web 11(5), 855–881 (2020) 10. Dag Hammarskjold Library of United Nations, N.Y.: UNBIS Thesaurus, English Edition http://metadata.un.org/thesaurus/about?lang=en 11. United Nations General Assembly: Transforming our world: the 2030 Agenda for Sustainable Development, A/RES/70/1 (2015). http://undocs.org/A/RES/70/1 12. United Nations General Assembly: Work of the Statistical Commission pertaining to the 2030 Agenda for Sustainable Development, A/RES/71/313 (2017). https:// undocs.org/A/RES/71/313
RSP4J: An API for RDF Stream Processing Riccardo Tommasini1(B) , Pieter Bonte3 , Femke Ongenae3 , and Emanuele Della Valle2 1
Data System Group, University of Tartu, Tartu, Estonia 2
[email protected]
DEIB, Politecnico di Milano, Milan, Italy
3
[email protected]
Ghent University - imec, Ghent, Belgium
{Pieter.Bonte,Femke.Ongenae}@ugent.be
Abstract. The RDF Stream Processing (RSP) community has proposed several models and languages for continuously querying and reasoning over RDF streams over the last decade. They each have their semantics, making them hard to compare. The variety of approaches has fostered both empirical and theoretical research and led to the design of RSPQL, i.e., a unifying model for RSP. However, an RSP API for the development under RSPQL semantics was still missing. RSP community would benefit from an RSP API because it can foster comparable and reproducible research by providing programming abstractions based on RSPQL semantics. Moreover, it can encourage further development and in-use research. Finally, it can stimulate practical activities such as tutorials, lectures, and challenges, e.g., during the Stream Reasoning Workshop. In this paper, we present RSP4J, a flexible API for the development of RSP engines and applications under RSPQL semantics. RSP4J offers all the necessary abstractions required for fast-prototyping of RSP engines under the proposed RSPQL semantics. Users can configure it to reproduce the variety of RSP engine behaviors in a comparable software environment. To promote systematic and comparative research, RSP4J is open-source, provides canonical citation, permanent web identifiers, and a comprehensive user guide for developers.
1
Introduction
The advent of the Internet of Things and social media has unveiled the streaming nature of information [9]. Data analysis should not only consider huge amounts of data from various complex domains, it should also be executed rapidly, before the data are no longer valuable or representative. Stream Reasoning (SR) is the research area that combines Stream Processing and Semantic Web technologies to make sense, in real-time, of vast, heterogeneous and noisy data streams [13]. Since 2008, the SR community’s contributions include data models, query languages, and algorithms, and benchmarks for RDF Stream Processing (RSP). As an extension of the Semantic Web stack, the value of RSP emerges in c Springer Nature Switzerland AG 2021 R. Verborgh et al. (Eds.): ESWC 2021, LNCS 12731, pp. 565–581, 2021. https://doi.org/10.1007/978-3-030-77385-4_34
566
R. Tommasini et al.
application domains where Data Variety and Data Velocity appear together [10], e.g., Smart Cities, e-Health and news analysis. RSP approaches extend RDF and SPARQL to represent and process data streams. The community rapidly reached consensus around the use of RDF Streams as the data model. On the other hand, a variety of RSP languages emerged over time, e.g., C-SPARQL, CQELS-QL, SPARQLstream , and StriderQL. Such languages are extensions of SPARQL that support some form of continuous semantics. RSP languages are usually paired with working prototypes that helped proving the feasibility of the approach as well as studying its efficiency. Such variety of languages and systems enriches the state-of-the-art, but it may be hindering adoption and, thus, slow down the technological progress. Indeed, the diversity in the literature often opposes the identification of a clear winner, the establishment of best practices, and calls for comparative research. Like other communities, e.g., OWL reasoning [20] and Big Data Systems [1], comparative research on and benchmarking of RSP engines is extremely hard. In fact, the semantics of different RSP languages do not completely overlap [12]. Moreover, the development of RSP engines, which are time-based systems, implies a number of design decisions that are often hidden in the code [7]. Such decisions, which fall into the notion of execution semantics 1 , hamper the performance comparison, making it hard to reproduce the same behavior in two different systems and, thus, generalise the conclusions. In summary, the lack of standardization and shared design principles are obstructing the growth of the communities. Indeed, as prototyping efforts remain isolated, the costs of development and maintenance of prototypes remain on the shoulder of individual researchers. Nevertheless, the problem did not remain unnoticed. The OWL reasoning community worked on shared APIs to standardise the evaluation of OWL reasoners [16], fostering a number of initiative like the OWL Reasoning Evaluation (ORE) challenges [20]. The Big Data Systems community witnessed the publication of a number of surveys and unification projects. In particular, Apache Beam is an attempt to uniform the APIs for stream and batch Big Data processing [17]. The RSP community is also working actively on solving this issue, focusing on (i) designing best practices [24,27] (ii) disseminating the approaches [15], and (ii) developing benchmarks that take correctness and execution semantics into account [3,18]. A recent important result is RSPQL [14], a reference model that unifies existing RSP dialects and the execution semantics of existing RSP engines. Although RSPQL is a first step towards a community standard, existing prototypes still do not follow shared design principles. In line with the OWL APIs and Apache Beam initiative, an API based on RSPQL would reduce the maintenance cost of existing engines, foster adoption of RSP engines, open new research opportunities in Stream Reasoning. In this paper, we present RSP4J, a configurable RSPQL API and engine, that builds on the lessons learned by developing the existing prototypes, and bringing RSP research to the next level. We believe RSP4J can foster fast-prototyping, 1
also known as execution semantics.
RSP4J: An API for RSP
567
empirical and comparative research, as well as easing the dissemination of RSP via teaching. To this extent, RSP4J includes (i) all the necessary abstractions to develop RSP engines under the proposed RSPQL semantics and (ii) an implementation, i.e. YASPER, based on Apache Commons RDF2 , with the goal of showcasing the API’s potential. Moreover, RSP4J can reproduce the variety of RSP engines in a comparable software environment. In summary, the goals of RSP4J are (i) fostering the design and development of RSP engines under fixed RSPQL semantics, (ii) unifying the existing prototypes and their results, (iii) providing a framework for fair comparison of results and (iv) presenting a high-level API for easy adoption for RSP developers. RSP4J is open-source and is maintained on Github3 . It has a canonical citation and permanent URL4 . Moreover, it comes with an actively maintained documentation and a Ready2GoPack for increased availability to new members of the RSP community. RSP4J was already used in a number of tutorials and lectures, i.e. ISWC17, ICWE18, ESWC19, TheWebConf19, RW18/20. The remainder of the paper is organized as follows: Sect. 2 discusses the potential impact of RSP4J in terms of use-cases, and afterwards presents the requirement analysis. Section 3 presents the background, concepts and definitions used throughout the rest of the paper, while Sect. 4 outlines architecture of RSP4J, its modules, and shows how it satisfies the requirements. In Sect. 5, we presents the related work. Finally, Sect. 6 concludes the paper and summarizes the most important contributions for RSP4J as a resource.
2
Impact: Use Cases and Requirements for an RSPQL API
In this section, we discuss the potential impact of RSP4J as a resource. To this extent, we present different use cases that concern state-of-the-art prototypes for Stream Reasoning and RDF Stream Processing. We highlight the challenges that such use cases unveil, and we elicit a set of requirements for RSP4J in order to address such challenges. Table 1 summarizes the relationship between the challenges (Ci ) and requirements (Rj ). 2.1
Use Cases
Fast Prototyping. In 2008, the first Stream Reasoner prototype came out [31]. Since then, the SR community has designed a number of working prototypes [5,8,19,23], with the intent of proving the feasibility of the vision. E-health, smart cities, and financial transaction are examples of use cases where such prototypes were successfully used. Nevertheless, the effort of designing and engineering good prototypes is extremely high, and often their maintenance is unsustainable. In fact, prototypes are often designed with a minimal set of requirements and 2 3 4
http://commons.apache.org/proper/commons-rdf/. https://github.com/streamreasoning/rsp4j. https://w3id.org/rsp4j.
568
R. Tommasini et al.
without shared design principles. In such scenarios (C1) adding new operators, (C2) new types of data sources to consume, or (C3) experimenting with new optimisations techniques requires huge manual efforts or is almost impossible. Comparable Research and Benchmarking. Aside developing proof-ofconcepts, the SR/RSP communities have focused a lot on Comparative Research (CR) [24,27] and benchmarking [3,18,22,26,32]. CR studies the differences and similarities across SR/RSP approaches. Stream Reasoners and RSP engines can only be compared when they employ the same semantics. Thus, a fair comparison demands a deep theoretical comprehension of the approaches, a proper formulation of the task to solve, and an adequate experimentation environment [28]. Consequently, it is currently hard to (C4) reproduce the behavior of existing approaches in a comparable way. Moreover, experimentation is limited by (C5) the lack of parametric solutions, i.e. the configurability of the operators allowing to match engine behavior. On the other hand, research on benchmarking aims at pushing the technological progress by guaranteeing a fair assessment. While some of the challenges are shared with CR [27,28], benchmarking is empirical research. To this extent, (C6) monitoring both the execution of continuous queries, as well as (C7) the engine behavior at run-time are of paramount importance. Unfortunately, not all the existing prototypes provide such entry points, and only black-box analysis is possible, e.g. it is impossible to measure the performance of each of the engine’s internal operators. Dissemination. Although SR research is at its infancy, a lot has been done on the teaching side. As prototypes and approaches reach maturity, several tutorials and lectures were delivered at major venues, including ICWE, ESWC, ISWC, RW, and TheWebConf [10,11,15]. These tutorials were often practical and aimed at engaging with their audience using simple yet meaningful applications. Nevertheless, existing prototypes were not designed for teaching purposes. Thus, they lack important features like the possibility to (C8) inspect the engine behaviors and (C9) they are not designed to ease the understanding at various levels of abstraction. Indeed, prototypes often (C10) neglect their full compliance to the underlying theoretical framework for practical reasons. Although this approach often benefits performance, it makes the learning curve more steep. 2.2
Requirements
Table 1. Challenges vs Requirements Now we present the requirements that an RSPQL API should satReq C1 C2 C3 C4 C5 C6 C7 C8 C9 C10 isfy. We elicit the requirements R1 from the challenges presented R2 above. Although the requirements R3 could be generalized for any RSP engine and Stream Reasoner, we R4 R 5 restrict our focus to Windowbased RDF Stream Processing Engines, i.e., those covered by the RSPQL specification.
RSP4J: An API for RSP
569
R1 Extensible Architecture. An RSP API should allow the easy addition of data sources (C2) and operators (C1), and the design of optimization techniques (C3). Moreover, An RSP API should allow experimentation by allowing the addition of execution parameters (C5), and should ease the extension of engine capabilities (C7). R2 Declarative Access. An RSP API should be accessible in a declarative and configurable manner (C4). It should allow querying according to a formal semantics, e.g., RSPQL (C10), and should allow controlling the engine and the query lifecycles (C8). R3 Programming Abstractions. An RSP API should provide programming abstractions that allow interacting with the engine at various levels of abstractions (C9), abstractions that are based on a theoretical framework (C10), and that provide a blueprint to make sense of the engine behavior (C8). R4 Experimentation. An RSP API should be suitable for experimentation and, thus, should foster comparative research. To this extent, it should allow experimentation with optimizations techniques (C3), enabling to execute experiments using alternative configurations (C5). Last but not least, the reproducibility of state-of-the-art solutions should be a priority to enable replication studies (C4). R5 Observability. An RSP API should be observable by design, enabling the collection of metrics at different levels, i.e., stream level, operator level, query level (C6), and engine level (C7). Observability should be independent from architectural changes (C1 and C2), and ease study of optimizations (C3).
3
Background
In this section, we summarize the knowledge necessary to understand the main concepts of RSP4J. RSP4J is based on RSPQL, which in turn relies on the Continuous Query Language (CQL) [4] for its operation structure, SPARQL 1.1 semantics for RDF querying, and the SECRET model [7] for its operational semantics. Notably, we assume some knowledge on RDF and SPARQL semantics5 . Definition 1. A data stream S is an infinite sequence of tuples di , te , tp where, di is a data item, and te /tp are respectively the event time and the processing time timestamps. An RDF Stream is a stream where the data item di is an RDF object and te /tp are timestamps indicating event time and processing time, respectively. In the literature, there are many definitions of data stream, with a general agreement on considering them as unbounded sequences of time-ordered data. Different notions of time are relevant for different applications. The most important ones are the time at which a data item reaches the data system (processing time), and the time at which a data item was produced (event time) [2]. In RSP, streams are represented as RDF objects, as stated by Definition 1 [14]. 5
For a comprehensive analysis we suggest [21].
570
R. Tommasini et al.
Operationally, stream processing requires a special class of queries that run under continuous semantics (vid. Definition 2). In practice, continuous queries consume one or more infinite inputs and produces an infinite output [25]. Arasu et al. [4] proposed a query model for processing Fig. 1. The CQL query model, i.e., the relational streams based on three fam- S2R, R2R, and R2S operators. ilies of operators, as depicted in Fig. 1. RSPQL extends these operators families to work on RDF Streams. Definition 2. Under continuous semantics, the result of a query is the set of results that would be returned if the query were executed at every instant in time. Stream-to-Relation (S2R) (vid. Fig. 1 a), i.e., is a family of operators that bridges the world of streams with the world of relational data processing. These operators chunk the streams into finite portions. A typical operator of this kind is a Time Window operator. In RSPQL, a time-based window operator is defined as in Definition 3. Definition 3. The time-based window operator W is a triple (α, β, t0 ) that defines a series of windows of width (α) and that slide of (β) starting at t0 . Relation-to-Relation (R2R) (Fig. 1 b), i.e., is a family of operators that can be executed over the finite stream portions. In the context of RSPQL, R2R operators are SPARQL 1.1 operators evaluated under continuous semantics. To clarify this intuition, Dell’Aglio et al. introduce the notion of a TimeVarying Graph and RSPQL dataset [14]. A Time-Varying Graph is the result of applying a window operator W to an RDF Stream S (vid. Definition 4), while the RSPQL dataset (SDS) is a an extension of the SPARQL dataset for continuous querying (vid. Definition 5). Definition 4. A Time-Varying Graph is a function that takes a time instant as input and produces as output an RDF Graph, which is called instantaneous. Given a window operator W and an RDF Stream S, the Time-Varying Graph TVGW,S is defined where the W is defined. In practice, for any given time instant t, W identified a subportion of the RDF Stream S containing various RDF Graphs. The Time-Varying Graph function returns the union (coalescing) of all the RDF Graphs in the current window6 . Definition 5. An RSPQL dataset SDS extends the SPARQL dataset7 as follows: an optional default graph A0 , n (n ≥ 0) named Time-Varying Graphs, and m (m ≥ 0) named sliding windows over k (k ≤ m) data streams. 6 7
The current window identified by W with the oldest closing time instant at t. https://www.w3.org/TR/rdf-sparql-query/#specifyingDataset.
RSP4J: An API for RSP
571
An RSPQL query is continuously evaluated against an SDS by an RSP engine. The evaluation of a RSPQL query outputs an instantaneous multiset of solution mappings for each evaluation time instant. The RSP engine’s operational semantics determines the set ET of evaluation time instants. Finally, Relation-to-Stream (R2S) is a family of operators that returns to the world a set of infinite data from the finite ones, i.e., Fig. 1 (c). RSPQL includes three R2S operators: (i) the RStream that emits the current solution mappings; (ii) the IStream that emits the difference between the current solution mappings and previous ones, and; (iii) the DStream that emits the difference between the previous solution mappings and the current ones. When developing Stream Processing Engines to evaluate continuous queries there are a number of design decisions that might impact the query correctness. Such decisions, which are usually hidden in the query engine implementation, define the so called operational semantics (also known as execution semantics). Botan et al. [7], with their SECRET model, identified a set of four primitives that formalise the operational semantics of window-based stream processing engines. RSPQL incorporates these primitive and applied them on existing RSPQL engines: (i) Scope is a function that maps an event-time instant te to the temporal interval where the computation occurs. (ii) Content is a function that maps a processing-time instant tp to the subset of stream elements included in the interval identified by the scope function. (iii) Report is a dimension that characterizes under which conditions the stream processors emit the window content. SECRET defines four reporting dimensions: (CC) Content Change: the engine reports when the content of the current window changes. (WC) Window Close: the engine reports when the current window closes. (NC) Non-empty Content: the engine reports when the current window is not empty. (P) Periodic the engine reports periodically. (iv) Tick is a dimension that explains what triggers the report evaluations. Possible Ticks are: time-driven, tuple-driven, or batchdriven.
Fig. 2. RSP4J’s Modules: (a) Querying (b) Streams, (c) Operators, (d) the SDS, and (e) Engine and Execution Semantics
572
4
R. Tommasini et al.
RSP4J
In this section, we present RSP4J’s architecture, its components, and we show it satisfies the requirements (cf Sect. 2). Figure 2 shows RSP4J core modules, i.e., (a) Querying, (b) Streams, (c) Operators, (d) the SDS, and (e) the Engine with Execution Semantics. To provide concrete examples of RSP4J, we will use Yet Another Stream Processing Engine for RDF (YASPER). YASPER is a strawman proposal8 designed for teaching purposes in the context of [15]. 4.1
Querying
PREFIX : REGISTER RSTREAM AS SELECT AVG(?v) as ?avgTemp FROM NAMED WINDOW :w1 ON STREAM :stream1 [RANGE PT5S STEP PT2S] WHERE { WINDOW :w1 { ?sensor :value ?v ; :measurement: ?m } FILTER (?m == ’temperature’) }
Listing 1.1. An example of RSPQL query.
The query module contains the elements for writing RSPQL programs in a declarative way (R2 ). The syntax is based on the proposal by the RSP community. At this stage of development, RSP4J accepts SELECT and CONSTRUCT queries written in RSPQL syntax (e.g. Listing 1.1)9 . Although RSPQL [14] does not discuss how to handle multi-streams, RSP4J does, allowing its users to fully replicate the behavior of existing systems (cf R4 ). Moreover, RSP4J includes the ContinuousQuery interface that aims at making the syntax extensible (cf R1 ). Indeed, RSP4J users can bypass the syntax module and programmatically define extensions in the query language. 4.2
Streams
The Streams module allows providing your own implementation of a data stream. It consists of two interfaces inspired by VoCaLS [30]: the WebStream and WebDataStream. WebStream, represents the stream as a Web resource, while WebDataStream, represents the stream as a data source. Figure 3 provides an overview of the relationships across these classes and interfaces. The WebStream does not include any particular logic. It is identified by an HTTP URI so it 8 9
Fig. 3. Streams interface. https://en.wikipedia.org/wiki/Straw_man_proposal. The RSP W3C Community group has started working towards a common syntax and semantics for RSP (https://github.com/streamreasoning/RSP-QL).
RSP4J: An API for RSP
573
can be de-referenced and then consumed through an available endpoint [30]. Listings 1.11 shows the implementation of the WebDataStream interface, which exposes two methods: put and addConsumer. The former allows injection of timestamped data items of type E by producers; the latter connects the stream to interested consumers, e.g., window operators, or super-streams. The interface is generic, and it allows RSP4J’s users to utilize multiple RDF Stream representation, i.e., either RDF Graphs or Triples, or even non-RDF Web Streams. A WebDataStream might also include some metadata relevant for the processing, i.e., links to ontologies, SHACL schemas, or alternative endpoints. RDFStream implements WebDataStream { protected List cs = new ArrayList(); @Override public void addConsumer(Consumer consumer) { cs.add(consumer);} @Override public void put(Graph g,long ts) { cs.forEach(c -> c.notify(g, ts)); } }
Listing 1.2. YASPER’s WebDataStream implementation.
4.3
Operators
RSP4J core includes separate interfaces for all the RSPQL families of operators: StreamToRelation, RelationToRelation, and RelationToStream. These abstractions act both as lower level APIs for RSP4J’s users (cf R3 ) as well as a suitable entrypoint for extensions and optimizations (cf R1 ). Moreover, each operator lifecycle could be monitored independently (cf R5 ).
Fig. 4. UML class diagram for the S2R package as used by C-SPARQL.
The Stream To Relation operator family bridges the world of RDF Streams to the world of finite RDF Data. RSPQL defines a Time-Based Sliding Window operators for processing RDF Streams. When applied to an RDF stream, RSPQL’s S2R operator returns a function called Time-Varying Graph, that given a time instant t, materializes an Instantaneous (finite) RDF Graph.
574
R. Tommasini et al.
public interface StreamToRelationOperator extends Consumer { String iri(); Report report(); Tick tick(); Content materialise(long now); List materialise(long now); TimeVarying addConsumer(SDS content); Content compute(long t_e, Window w); }
Listing 1.3. RSP4J S2R operator interface. public interface StreamToRelationOperatorFactory { String iri(); TimeVarying apply(WebDataStream stream); default boolean named() { return iri() != null;} }
Listing 1.4. RSP4J S2R operator factory interface.
To represent such behavior, RSP4J includes two interfaces, i.e., the StreamToRelationFactory interface and the StreamToRelation (S2R) operator. The former, exemplified in Listing 1.4, is used to instantiate the latter. It exposes the apply method that takes a generic WebDataStream as input, and returns a Time-Varying object TimeVarying, decoupling the Type of the input stream content from the output Time-Varying Object. Listing 1.5 shows part of an implementation of the StreamToRelationOperatorFactory that instantiates C-SPARQL’s Time-Based Sliding Window. public class CSPARQLS2RFactory implements S2R { private final long a, b, t0; private final ContinuousQueryExecution context; @Override public TimeVarying apply(WebDataStream s) { CSPARQLS2ROp op = new CSPARQLS2ROp(iri,a,b,scope,tick,report); s.addConsumer(op); return op.set(context); } }
Listing 1.5. The CSPARQL’s time-based window operator in YASPER.
The StreamToRelation operator is responsible for applying the windowing algorithm. In RSP4J, it is a special kind of Consumer that receives the data from the streams, cf Listing 1.3. Listing 1.5 shows that the factory instantiates a CSPARQLS2ROp, which is a StreamToRelationOperator, and registers it as stream consumer. Then, it obtains a TimeVarying from the ContinuousQueryExecution context. We explain the details about the TimeVarying when discussing the RSPQL Dataset SDS. Figure 4 shows the UML class diagram of the S2R package. CSPARQLWindowOperator is a StreamToRelation operator, which creates a TimeVarying if applied to a WebDataStream.
RSP4J: An API for RSP
575
In RSPQL, the Relation To Relation operator family corresponds to SPARQL 1.1 algebraic expressions evaluated over a given time instant. The evaluation of the Basic Graph Pattern produces a time-varying sequence of solution mappings, which can be consumed by SPARQL 1.1 operators. public interface RelationToRelationOperator { Collection eval(long ts); }
Listing 1.6. RSP4J R2R operator interface.
Listings 1.6 shows the RSP4J interface that covers this functionality. Similarly to the S2R operators, the interface is generic to let the RSP4J’s users decide the internal representation of the query solution, e.g., the bindings. The RelationToStream operator family allows going back from the world of Solution Mappings to RDF Streams. According to RSPQL the evaluation of an R2S operator takes as input a sequence of time-varying solution mappings. In RSP4J, we generalized this idea as shown in Listing 1.7, i.e., we allow the user to also provide the solution mapping incrementally as soon as they are produced. public interface RelationToStreamOperator { T eval(SolutionMapping sm, long ts); default Collection eval(Collection s, long t){ return s.stream().map(sm -> eval(sm, t)).collect(Collectors.toList() ); } }
Listing 1.7. RSP4J R2S operator interface.
4.4
SDS and Time-Varying Graphs
Like in SPARQL, the query specification and the SDS creation are closely related. An RSPQL dataset SDS is an extension of the SPARQL dataset to support the continuous semantics. As indicated in Sect. 3, the SDS is time-dependent as it contains Time-Varying Graphs. RSP4J includes both the abstractions, i.e., the SDS and the TimeVarying Graphs (cf R3 ). Listing 1.8 shows RSP4J’s SDS interface. The generic parameter is inherited by the generic nature of RSP4J’s Time-Varying objects. The consolidate method consolidates the SDS content by recursively consolidating every TimeVarying Object it contains. public interface SDS { default void consolidate(long t) { asTimeVaryingEs().forEach(tvg -> tvg.consolidate(ts)); } ... }
Listing 1.8. RSP4J’s SDS Interface.
576
R. Tommasini et al.
Listing 1.9 shows a Time-Varying Graph that is the result of the application of the Window Operator to an RDF Streams. The method materialize consolidates the content at a given time instant ts. To this extent, it exploits the StreamToRelationOperator interfaces, freezing and polling the active window content. The coalesce method ensure only one graph, among those selected during the windowing operation, is returned. According to RSPQL such graph corresponds to the union of the RDF graphs in the window. public class TimeVaryingGraph implements TimeVarying { private IRI name; private StreamToRelationOperator op; @Override public void materialize(long ts) { graph = op.getContent(ts).coalesce(); }... }
Listing 1.9. YASPER’s Time Varying Graph Implementation.
As time progresses, the SDS is reactively consolidated into a set of (named) Instantaneous Graphs10 at the time t at which a Time-Varying Graph is updated. Therefore, RSP4J includes the SDSManager and SDSConfiguration interfaces. The former controls the creations, detection, and the interactions with the SDS; ideally this represents a starting point for federated query answering and/or multi-query optimisation. The latter makes the execution parametric e.g., for enabling different approaches for window management, or alternative output serializations, e.g., JSON-LD or Turtle. 4.5
Engine, Query Execution, and Execution Semantics
This module includes the abstractions to control and monitor the engine and the query lifecycle (cf R4 and R5 ). Moreover, we explain RSP4J’s parametric execution semantics (R4 ). The Engine interface allows controlling RSP4J’s capabilities, e.g., query registration and cancellation. It is based on the VoCaLS service feature idea [30]. Each engine can implement different interfaces, each of which correspond to a particular feature. By querying the implemented interfaces it is possible to list all the features exposed by the engine of choice, e.g., stream registration, RSPQL support, or formatting the results in JSON-LD format. RSP4J can reproduce the execution semantics of common RSP engines by configuring SECRET’s primitives: Tick is represented as an enumeration, i.e., tuple-based, time-based, and batch. Scope is a parameter accessible through the Time interface. Time controls the time progress w.r.t. the stream consumption. It is initialized with the system initial timestamp at configuration time. It keeps track of the evaluation timestamps ET , and exposes the time-progress to the user
10
Slowly evolving RDF graph are represented as a (named) Time-Varying Graph too.
RSP4J: An API for RSP
577
both for event-time and processing-time11 . Report is represented as a collection of ReportingStrategies. RSP4J core includes RSPQL’s reporting policies, i.e., On-Content-Change, Non-Empty-Content, Periodic, and On-Window-Close. Last but not least, the Content interface represents the data items in the active window. It is generic and exposes the coalesce allows alternative implementations of the Time-Varying Graph functions. public interface Time { long getScope(); long getAppTime(); void setAppTime(long now); ET getEvaluationTimeInstants(); void addEvaluationTimeInstants(TimeInstant i); default long getSystemTime() { return System.currentTimeMillis();} }
Listing 1.10. RSP4J’s Time Interface.
The ContinuousQueryExecution interface represents the ever-lasting computation required by continuous queries. It allows monitoring and controlling the query life-cycle. Moreover, in order to make observable (R5 ) the SDS and the operators involved in querying, the interface includes getters. public interface ContinuousQueryExecution { WebDataStream outstream(); ContinuousQuery getContinuousQuery(); SDS sds(); StreamToRelationOperator[] getS2R(); RelationToRelationOperator getR2R(); RelationToStreamOperator getR2S();... }
Listing 1.11. An example of RSP-QL Query.
5
Related Work
In this section, we present the work related to RSP4J. We present the most popular RSP engines, and how they differ in terms of RSPQL semantics, complicating fair comparison. The C-SPARQL Engine [5] is an RSP engine that adopts a black box approach by pipelining a DSMS system with a SPARQL enige. The DSMS is used to execute the S2R operators and the execution semantics, while the SPARQL engine performs the evaluation of the queries implemented as the R2R operator. C-SPARQL supports the Window Close and Non-empty content reporting policies while employing RStreams as R2S operators. 11
RSPQL determines the evaluation time instant set ET wrt the reporting policy and the input data. Instead, RSP4J serves time as it receives data, i.e., by consuming the streams. Thus, RSP4J’s ET is built progressively. While the RSPQL’s ET is deterministic, RSP4J ET might not be deterministic in case of distributed computations.
578
R. Tommasini et al.
The CQELS Engine [19] takes a white box approach, such that it has access to all the available operators, allowing it to optimize query evaluation. Compared to C-SPARQL, it supports the Content Change reporting strategy. Furthermore, CQELS supports the IStream R2S operator instead of the RStream. Morphstream [8] focuses on querying virtual RDF streams with SPARQLstream . Thus, compared to C-SPARQL and CQELS, it uses Ontology Based Data Access to virtually map raw data to RDF data. Similar to C-SPARQL it supports the Window Close and Non-empty content reporting policies. Morphstream is the only engine that supports all R2S operators. Strider [23] is a hybrid adaptive distributed RSP engine that optimizes the logical query plan according to the state of the data streams. It is built upon Spark Streaming and borrows most of its operators directly from Spark. Strider translates Strider-SQL queries to Spark Streaming’s internal operators. It inherits the Window Close reporting policy from Spark Streaming, and supports the RStream as R2S operator. In addition to the rigid yet explicit characteristics that each engine has, they also have inherent subtle differences. For example, none of them allows to define the starting timestamp t0 as part of the time-based sliding window operators definition. This means that the starting time is supplied by the engine itself and in case of processing time engines are bound to produce different results. Differences like the t0 make impossible to correctly compare the results produced by the various engines. RSP4J allows to customize the inner wiring of the engines, in order to align their semantics and allowing them to produce comparable results.
6
Conclusion, Discussion, and Roadmap
In this paper, we presented RSP4J, a flexible API for RSP development, adhering to the semantics of RSPQL, and YASPER, i.e., a strawman RSP engine implementation designed for teaching purposes in the context of RW [15]. RSP4J aims at solving three use case: fast prototyping, benchmarking comparative research, and dissemination via teaching. Thus, we designed it to fulfill, i.e., a set of requirements: (I) an extensible architecture, (II) declarative access through a uniform query language according to the RSPQL semantics; (III) the necessary programming abstractions; (IV) enable experimentation and fair comparison and (V) observability by design. In Sect. 4, we explained how each RSP4J module solves a subset of requirements. Differently than the state-of-the-art RSP prototypes which only solve requirement R2 by providing a declarative access, RSP4J fulfills all the set requirements (cf Sect. 4). Moreover, two RSP engines already bind to RSP4J: (i) YASPER12 , which is a strawman implementation based on Apache RDF Commons2 , and C-SPARQL 2.013 a new version of the C-SPARQL engine [5]. 12 13
https://github.com/streamreasoning/rsp4j/tree/master/yasper. https://github.com/streamreasoning/csparql2.
RSP4J: An API for RSP
579
Roadmap. RSP4J’s future work includes a number of initiatives. We plan to bind even more engines, i.e., Morphstream and CQELS and run a reproducibility challenge in the context of the upcoming stream reasoning workshop. In the mid term, we would like to abstract RSP4J specification and provide access in other languages, e.g., Python. In the long-term, we would like to include abstraction to control the stream publication lifecycle [29]. Moreover, we would like to investigate how to combine RSP4J with other stream reasoning framework [6]. Acknowledgment. Dr. Tommasini acknowledges support from the European Social Fund via IT Academy program, and from the European Regional Development Funds via the Mobilitas Plus programme (grant MOBTT75). Moreover, the authors would like to acknowledge the support of Robin Keskisärkkä and Daniele Dell’Aglio in earlier versions of this work.
References 1. Affetti, L., Tommasini, R., Margara, A., Cugola, G., Della Valle, E.: Defining the execution semantics of stream processing engines. J. Big Data 4, 12 (2017) 2. Akidau, T., et al.: The dataflow model: a practical approach to balancing correctness, latency, and cost in massive-scale, unbounded, out-of-order data processing (2015) 3. Ali, M.I., Gao, F., Mileo, A.: CityBench: a configurable benchmark to evaluate RSP engines using smart city datasets. In: Arenas, M., et al. (eds.) ISWC 2015, Part II. LNCS, vol. 9367, pp. 374–389. Springer, Cham (2015). https://doi.org/10. 1007/978-3-319-25010-6_25 4. Arasu, A., Babu, S., Widom, J.: The CQL continuous query language: semantic foundations and query execution. VLDB J. 15(2), 121–142(2006) 5. Barbieri, D.F., Braga, D., Ceri, S., Della Valle, E., Grossniklaus, M.: C-SPARQL: a continuous query language for RDF data streams. Int. J. Semant. Comput. 4(1), 3–25 (2010) 6. Beck, H., Dao-Tran, M., Eiter, T., Fink, M.: LARS: a logic-based framework for analyzing reasoning over streams. In: Bonet, B., Koenig, S. (eds.) Proceedings of the Twenty-Ninth AAAI Conference on Artificial Intelligence, 25–30 Jan 2015, Austin, Texas, USA, pp. 1431–1438. AAAI Press (2015) 7. Botan, I., Derakhshan, R., Dindar, N., Haas, L.M., Miller, R.J., Tatbul, N.: SECRET: a model for analysis of the execution semantics of stream processing systems. PVLDB 3(1), 232–243 (2010) 8. Calbimonte, J.P., Jeung, H., Corcho, O., Aberer, K.: Enabling query technologies for the semantic sensor web. Int. J. Semant. Web Inf. Syst. (IJSWIS) 8(1), 43–63 (2012) 9. Della Valle, E., Ceri, S., van Harmelen, F., Fensel, D.: It’s a streaming world! reasoning upon rapidly changing information. IEEE Intell. Syst. 24(6), 83–89 (2009) 10. Della Valle, E., Dell’Aglio, D., Margara, A.: Taming velocity and variety simultaneously in big data with stream reasoning. In: DEBS, pp. 394–401. ACM (2016) 11. Della Valle, E., Tommasini, R., Balduini, M.: Engineering of web stream processing applications. In: d’Amato, C., Theobald, M. (eds.) Reasoning Web 2018. LNCS, vol. 11078, pp. 223–226. Springer, Cham (2018). https://doi.org/10.1007/978-3030-00338-8_8
580
R. Tommasini et al.
12. Dell’Aglio, D., Calbimonte, J.-P., Balduini, M., Corcho, O., Della Valle, E.: On correctness in RDF stream processor benchmarking. In: Alani, H., et al. (eds.) ISWC 2013, Part II. LNCS, vol. 8219, pp. 326–342. Springer, Heidelberg (2013). https://doi.org/10.1007/978-3-642-41338-4_21 13. Dell’Aglio, D., Della Valle, E., van Harmelen, F., Bernstein, A.: Stream reasoning: a survey and outlook. Data Sci. 1(1–2), 59–83 (2017) 14. Dell’Aglio, D., Della Valle, E., Calbimonte, J., Corcho, Ó.: RSP-QL semantics: a unifying query model to explain heterogeneity of RDF stream processing systems. Int. J. Semant. Web Inf. Syst. 10(4), 17–44 (2014) 15. Falzone, E., Tommasini, R., Della Valle, E.: Stream reasoning: from theory to practice. In: Manna, M., Pieris, A. (eds.) Reasoning Web 2020. LNCS, vol. 12258, pp. 85–108. Springer, Cham (2020). https://doi.org/10.1007/978-3-030-60067-9_4 16. Horridge, M., Bechhofer, S.: The OWL API: a Java API for OWL ontologies. Semant. Web 2(1), 11–21 (2011) 17. Karau, H.: Unifying the open big data world: the possibilities∗ of apache BEAM. In: 2017 IEEE International Conference on Big Data, BigData 2017, Boston, MA, USA, 11–14 Dec 2017, p. 3981. IEEE Computer Society (2017) 18. Kolchin, M., Wetz, P., Kiesling, E., Tjoa, A.M.: YABench: a comprehensive framework for RDF stream processor correctness and performance assessment. In: Bozzon, A., Cudre-Maroux, P., Pautasso, C. (eds.) ICWE 2016. LNCS, vol. 9671, pp. 280–298. Springer, Cham (2016). https://doi.org/10.1007/978-3-319-38791-8_16 19. Le-Phuoc, D., Dao-Tran, M., Xavier Parreira, J., Hauswirth, M.: A native and adaptive approach for unified processing of linked streams and linked data. In: Aroyo, L., et al. (eds.) ISWC 2011, Part I. LNCS, vol. 7031, pp. 370–388. Springer, Heidelberg (2011). https://doi.org/10.1007/978-3-642-25073-6_24 20. Parsia, B., Matentzoglu, N., Gonçalves, R.S., Glimm, B., Steigmiller, A.: The OWL reasoner evaluation (ORE) 2015 competition report. J. Autom. Reasoning 59(4), 455–482 (2017) 21. Pérez, J., Arenas, M., Gutierrez, C.: Semantics and complexity of SPARQL. ACM Trans. Database Syst. (TODS) 34(3), 1–45 (2009) 22. Le-Phuoc, D., Dao-Tran, M., Pham, M.-D., Boncz, P., Eiter, T., Fink, M.: Linked stream data processing engines: facts and figures. In: Cudré-Mauroux, P., et al. (eds.) ISWC 2012, Part II. LNCS, vol. 7650, pp. 300–312. Springer, Heidelberg (2012). https://doi.org/10.1007/978-3-642-35173-0_20 23. Ren, X., Curé, O.: Strider: a hybrid adaptive distributed RDF stream processing engine. In: d’Amato, C., et al. (eds.) ISWC 2017, Part I. LNCS, vol. 10587, pp. 559–576. Springer, Cham (2017). https://doi.org/10.1007/978-3-319-68288-4_33 24. Scharrenbach, T., Urbani, J., Margara, A., Della Valle, E., Bernstein, A.: Seven commandments for benchmarking semantic flow processing systems. In: Cimiano, P., Corcho, O., Presutti, V., Hollink, L., Rudolph, S. (eds.) ESWC 2013. LNCS, vol. 7882, pp. 305–319. Springer, Heidelberg (2013). https://doi.org/10.1007/9783-642-38288-8_21 25. Terry, D.B., Goldberg, D., Nichols, D.A., Oki, B.M.: Continuous queries over append-only databases. In: Proceedings of the 1992 ACM SIGMOD International Conference on Management of Data, San Diego, California, USA, 2–5 June 1992, pp. 321–330. ACM Press (1992) 26. Tommasini, R., Balduini, M., Della Valle, E.: Towards a benchmark for expressive stream reasoning. In: Joint Proceedings of RSP and QuWeDa Workshops co-located with 14th ESWC 2017, vol. 1870, pp. 26–36 (2017)
RSP4J: An API for RSP
581
27. Tommasini, R., Della Valle, E., Balduini, M., Dell’Aglio, D.: Heaven: a framework for systematic comparative research approach for RSP engines. In: Sack, H., Blomqvist, E., d’Aquin, M., Ghidini, C., Ponzetto, S.P., Lange, C. (eds.) ESWC 2016. LNCS, vol. 9678, pp. 250–265. Springer, Cham (2016). https://doi.org/10. 1007/978-3-319-34129-3_16 28. Tommasini, R., Della Valle, E., Mauri, A., Brambilla, M.: RSPLab: RDF stream processing benchmarking made easy. In: d’Amato, C., et al. (eds.) ISWC 2017, Part II. LNCS, vol. 10588, pp. 202–209. Springer, Cham (2017). https://doi.org/ 10.1007/978-3-319-68204-4_21 29. Tommasini, R., Ragab, M., Falcetta, A., Valle, E.D., Sakr, S.: A first step towards a streaming linked data life-cycle. In: Pan, J.Z., Pan, J.Z., et al. (eds.) ISWC 2020, Part II. LNCS, vol. 12507, pp. 634–650. Springer, Cham (2020). https://doi.org/ 10.1007/978-3-030-62466-8_39 30. Tommasini, R., et al.: VoCaLS: vocabulary and catalog of linked streams. In: Vrandečić, D., et al. (eds.) ISWC 2018, Part II. LNCS, vol. 11137, pp. 256–272. Springer, Cham (2018). https://doi.org/10.1007/978-3-030-00668-6_16 31. Walavalkar, O., Joshi, A., Finin, T., Yesha, Y., et al.: Streaming knowledge bases. In: Proceedings of the Fourth International Workshop on Scalable Semantic Web knowledge Base Systems (2008) 32. Zhang, Y., Duc, P.M., Corcho, O., Calbimonte, J.-P.: SRBench: a streaming RDF/SPARQL benchmark. In: Cudré-Mauroux, P., et al. (eds.) ISWC 2012, Part I. LNCS, vol. 7649, pp. 641–657. Springer, Heidelberg (2012). https://doi.org/10. 1007/978-3-642-35176-1_40
WasmTree: Web Assembly for the Semantic Web Julian Bruyat1(B) , Pierre-Antoine Champin1,2 , Lionel Médini1 , and Frédérique Laforest1 1
Université de Lyon, INSALyon, UCBL, LIRIS CNRS UMR 5205, Lyon, France {julian.bruyat,pierre-antoine.champin,lionel.medini, frederique.laforest}@liris.cnrs.fr 2 W3C/ERCIM, Valbonne, France
Abstract. Today, Javascript runtimes intend to process data both at server and client levels. In this paper, we study how Rust and Web Assembly can contribute to implement efficient Semantic Web libraries for the Javascript ecosystem. We propose WasmTree, a new implementation of the RDFJS Store and Dataset interfaces in which the processing is carefully split between the Web Assembly and Javascript layers. Experiments show that our best setup outperforms state-of-the-art implementations for fine-grained data access and SPARQL queries.
Keywords: Semantic Web
1
· Web assembly · RDFJS · Indexing
Introduction
Nowadays a large number of RDF libraries help application developers take advantage of Linked Data and the Semantic Web. On the server side, when high performance is needed, it is usual to use compiled languages, such as C or Rust. But until recently, in browsers, only libraries written in Javascript (JS) could be used, such as N3.js [16] or Graphy [13]. With the development of Web Assembly [14] (WASM), browsers and other JS runtimes are able to run compiled and highly optimized libraries with near-native performance. Our aim is to build an efficient RDF library for JS runtimes. We propose WasmTree12 , a fast in-memory implementation of the RDFJS API in which the processing is carefully split between the WASM and JS layers. Section 2 presents the state of the art of RDF libraries for JS environments. Section 3 presents several attempts to implement efficient Semantic Web libraries using Rust and WASM, the last being WasmTree. Section 4 evaluates these approaches in comparison with other libraries. Finally, we conclude with open issues.
1 2
https://www.npmjs.com/package/@bruju/wasm-tree. https://github.com/BruJu/WasmTreeDataset/tree/master/wasm-tree-frontend.
c Springer Nature Switzerland AG 2021 R. Verborgh et al. (Eds.): ESWC 2021, LNCS 12731, pp. 582–597, 2021. https://doi.org/10.1007/978-3-030-77385-4_35
WasmTree
2
583
State of the Art
RDF Dataset: RDF [9] is the core data model of the Semantic Web. The building block of RDF data is a triple composed of a subject (an IRI or a blank node), a predicate (an IRI) and an object (an IRI, blank node, or literal). A set of triples is an RDF graph. As graphs are rarely used in isolation, the RDF recommendation defines the notion of RDF dataset, composed of one default graph and zero or more named graphs. A dataset can therefore be seen as a set of quads, composed of a subject, a predicate, an object, and a graph name (the latter being an IRI, a blank node, or a special marker for the default graph). Indexing: The most straightforward data structure for representing an RDF graph or dataset is to store triples or quads with their constituting terms directly in the data structure, like in Graphy [13]. Another approach is to store, on one side, a mapping between RDF terms (IRIs, literals, blank nodes) and short identifiers (usually integers), and on the other side, a set of triples or quads where the constituting terms are referred to by their identifiers. This is the approach chosen by HDT [10]. This approach is more memory-efficient and makes it easier to use sorted data structures. On the other hand, it requires an additional step to map identifiers and terms when quads are ingested or retrieved. RDF in JS Runtime Environments: In order to foster interoperability in Semantic Web developments on JS runtimes (browsers, Node.js, Deno3 ...), the RDFJS W3C Community Group4 was formed in 2013. It has proposed three specifications [3–5] defining APIs for RDF building blocks, datasets and streams. In the two latter, a Dataset interface and a Store interface are defined, a store being a dataset usable in an asynchronous fashion. The most prominent implementations of these APIs are Graphy for Dataset which uses 1 indexing tree (by Graph then Subject then Predicate then Object, or GSPO) and N3.js for Store which stores the data in 3 different indexes (SPO, POS and OSP) for each graph. Another notable project using the RDFJS interfaces is Comunica [15], a highly modular framework allowing, in particular, to execute SPARQL [11] queries against any Store implementation. Web Assembly: Most JS runtimes nowadays make use of Just In Time (JIT) compilation, which largely increases the performance of JS code. However, since 2015, another approach has been explored, which lead to the standardization of Web Assembly (WASM) in 2019. WASM is a low-level binary language which, alongside JS, is executable in most JS runtimes. WASM files are much smaller than equivalent JS files, and are compiled ahead of time, saving time at execution and opening the way to more aggressive optimizations. WASM is executed in a 3 4
https://deno.land/. https://www.w3.org/community/rdfjs/.
584
J. Bruyat et al.
virtual machine in order to be portable, but at the same time is very close to machine code, in order to achieve near-native performance. For security and portability reasons, WASM code can only work on a linear memory. More precisely, this linear memory is allocated by JS code as an array of bytes, and provided to the WASM code. Communication between JS code and WASM code is only possible through function calls returning integers or floating point numbers and modifications in this array. At the time of writing, a dozen languages can be compiled to WASM5 , Rust being one of them. Rust: [12] is a programming language created by Graydon Hoare, first released in July 2010 and supported until 2020 by Mozilla. Rust emphasizes performance, reliability and productivity. Performance is ensured by the fact that everything in Rust is explicit; for example, Rust has no exception mechanism nor garbage collector. Reliability is ensured by an original ownership model, guaranteeing memory-safety and thread-safety. Yet, productivity is made possible by powerful abstractions, carefully designed to have minimal or zero cost at runtime. A few RDF libraries exist in Rust. Sophia [8] provides generic interfaces for graphs and datasets, aiming to play the same role as RDFJS in the JS ecosystem. Oxigraph6 provides a persistent dataset storage and SPARQL query engine. Rust was one of the first languages that could be compiled to WASM. What sets Rust apart from other WASM-enabled languages is the wasm-bindgen tool. We have described above how the WASM virtual machine can only work on and communicate through its linear memory, which is seen by JS code as an array of numbers. Communicating other data types to JS code requires an additional layer of JS “glue code” to re-interpret the content of the linear memory into the corresponding abstraction. Such glue code is automatically generated by wasmbindgen, requiring only that the Rust code be annotated using a set of dedicated keywords. To the best of our knowledge, Rust and C++ (with Emscripten) are the only languages equipped with such tools.
3
Towards an Efficient Implementation of RDFJS
We have developed a fast in-memory implementation of the RDFJS Dataset interface usable in any JS runtime. To ensure efficiency, we have developed a new dataset structure in the Rust language. Based on the WASM principles, it is compiled and exported to JS runtimes using the wasm-bindgen tool, so that JS runtime developers can use it from their JS code. We first present two approaches that are more straightforward ways to implement a RDFJS library using WASM, but underperform. Then based on these observations, we present WasmTree.
5 6
https://webassembly.org/getting-started/developers-guide/. https://github.com/oxigraph/oxigraph.
WasmTree
3.1
585
General View of Our Approach
Our Dataset structure implementation is separated into two parts: – A bidirectional term mapping to store the correspondence between terms and their integer identifiers. – A forest of B-Trees [2]. Each B-Tree sorts quads of identifiers in a given order e.g. SPOG, GPOS. Details are provided hereafter. The term mapping is used to convert quads of terms into quads of identifiers and conversely. To provide constant lookup time, this mapping is implemented as a hashmap to map terms to identifiers, and a vector to map identifiers to terms (identifiers are assigned in sequence). Details about how this mapping is implemented and used are provided in the following subsections. The quads of identifiers are stored in several B-Trees. The reasons are the followings: – If we classify search patterns according to which positions (Subject, Predicate, Object or Graph name) are fixed (as opposed to a wildcard), there are 15 classes of patterns (the “all-wildcards” pattern is not interesting). For each class of patterns, we need a B-Tree sorted by the fixed positions, so that all matching quads can be efficiently located and iterated over. – While up to 16 different sort orders are possible (SPOG, OSPG, OPSG . . . ), 6 sort orders are sufficient to optimally answer any pattern. Indeed, when a pattern is queried, any sort order starting with the fixed positions of the pattern is appropriate; for example if the subject (S) and the object (O) are fixed (which we will refer to as a S?O? in this paper, using ? as a wildcard), any of the following trees could be used: SOPG, SOGP, OSPG and OSGP. Note that this is possible because the order of the resulting quads can not be specified using the RDFJS APIs. – As all classes of patterns will not necessarily be used in practice, we initialize our structure with only one B-Tree. The other five B-Trees are built lazily when a pattern is queried for which the available trees are not suited. This enables to speed up the initial dataset load. For example a tree that starts with SO will only be required when the pattern S?O? is queried. – B-Trees are preferred over binary trees to benefit from the principle of locality of reference7 : by using B-Trees, up to 2B-1 quads can be stored in the same node, which is more cache friendly. This choice is also reinforced by the fact that the Rust standard library offers functions to directly extract a range from a B-Tree, which helps code maintainability. This B-Tree structure is common among all our implementations and implemented in Rust. On the other hand, the management of the term mapping, and more generally the way to retrieve the stored quads from WASM memory to the JS code, comes in three different propositions: 7
https://en.wikipedia.org/wiki/Locality_of_reference.
586
J. Bruyat et al.
– The naive TreeDataset approach is a full-Rust implementation of the dataset, which is compiled in WASM and exposes individual quads to JS. – The all-at-once TreeDataset approach also uses a full-Rust implementation of the dataset compiled in WASM, but reduces the number of exchanges between WASM and JS code by transmitting all quads as one single string serialized using the N-Quads format [7]. – The WasmTree approach implements only the B-Trees in Rust, while the term mapping is managed by JS code. 3.2
Naive TreeDataset Approach
In this first approach, we have implemented both the B-Trees and the term mapping in Rust, in a structure called TreeDataset. More precisely, TreeDataset complies with the Sophia API [8]. The Sophia and the RDFJS APIs are quite similar. In particular, both provide methods to retrieve a subset of quads matching a given pattern. The main difference is the return value of pattern matching methods: Sophia returns a stream of quads that can be lazily evaluated, while the Dataset interface returns a new dataset containing all the match quads. To hash a term, we use the default Rust hasher implementation. Every part of the term is hashed successively and then the hash code is produced with the SipHash algorithm. For example, if the term is an IRI, the Rust hasher is used on that IRI. If the term is a non language literal, the hasher is used on both the IRI and the datatype. By writing an adapter annotated with wasm-bindgen, the dataset structure is compiled in WASM. Thanks to the generated JS glue code, this implementation can be used in a JS code like any other RDFJS Dataset implementation. Figure 1 shows the process to iterate on all quads. An iterator object is first constructed from the list of all quads stored in the output dataset. This iterator is then exported to the JS user. When the user code requests the next quad, the returned quad is produced by Rust code.
Fig. 1. Process to retrieve quads from a TreeDataset - naive TreeDataset approach. The left blue part is in JS, while the right red part is a WASM built from Rust
WasmTree
587
As shown later in Sect. 4, naively adapting through WASM a Rust API to a JS API, however similar, leads to bad performance. Indeed, there is a cost for every individual exchange between the JS code and the WASM code, meaning it is better if data is sent in bulk8 . Another drawback of this approach is related to memory leaks. Unlike JS, WASM does not have a garbage collector. While the WASM memory is implicitly allocated by classes generated by the JS glue code when the constructor is used, the user has to explicitly free it using the free method. This means that the whole datastructure representing the dataset in WASM needs to be explicitly deallocated, which is uncommon for JS developers and is not part of the RDFJS specification. Recent versions of JS introduce the FinalizationRegistry, which can be used as a destructor: this is used by recent versions of wasm-bindgen. So when the JS object that owns a part of the WASM memory is destroyed, the memory is freed. In our implementation, we prefer to rely as little as possible on allocated objects to ensure compatibility with older versions of JS runtimes, but also provide a library that conforms to JS developers current idioms. To solve these performance issues, the next sections present two other approaches aiming at mutualizing exchange costs and reducing the number of WASM allocated objects. 3.3
All-at-Once TreeDataset Approach
We tried a different strategy for iterating over quads: rather than retrieving a single quad from the WASM dataset at each iteration, we export all quads at once, using a textual serialization format.
Fig. 2. Process to retrieve quads from a TreeDataset - All-at-once approach. The left blue part is in JS, while the right red part is a WASM built from Rust 8
As a side experiment, we tried to send 1,000,000 integers from WASM to JS: sending in bulk the whole array was 8 times faster than sending the integers one by one.
588
J. Bruyat et al.
Figure 2 presents the different steps of this approach: we first serialize all the quads in the N-Quads format [7] into a big string. JS retrieves this string by calling the toNQuads function, which first takes care of transcoding it from UTF-16 to UTF-8, then uses the N-Quads parser of N3.js to get a list of quads. Unfortunately, our experiments described in Sect. 4.2 show that this approach is slower than the previous one. This is mainly due to the high cost of interpreting the N-Quads formatted string received by the JS code, even though N-Quads are a very simple and straightforward format. 3.4
WasmTree: A Hybrid Implementation
Our last implementation, which is the main contribution of this work, consists in splitting wisely the work between WASM code and JS code. Previous approaches fail because of the cost of exchanging and reinterpreting complex data (in our case objects and strings), as they are not trivially copyable9 from the WASM memory to the JS memory. So we decided to do computation-intensive integer manipulation (i.e. the construction, storage and manipulation of the B-Trees structure) in WASM, and to handle strings (i.e. the mapping between identifiers and terms) in JS. Thus, only integers need to be exchanged across the WASM-JS boundary. More precisely, the JS part implements the RDFJS Dataset interface with three main components: – The term mapping, implemented with an array and a standard JS dictionary; as the array only accepts simple strings as keys, we use the notion of concise term10 to unambiguously encode RDF terms into strings. – A handle to the WASM structure that contains the forest of B-Trees. – An identifier list representing the quads in the dataset. Elements of this list are read four at a time (subject, predicate, object, graph name). The role of this list is to serve as a cache to limit exchanges with the WASM memory. When a new WasmTree instance is created by the user, it is created with no forest and no identifier list. Iterating over the quads of the dataset is performed using the identifier list, as illustrated in Fig. 3. If the list is absent, it is first recomputed from the forest. If there is no forest, an empty identifier list is used instead. When methods modify the content of the dataset (add, addAll, delete. . . ), the terms received as parameters are converted to identifiers, the changes are applied to the forest, and the identifier list is deleted as its content no longer reflects the content of the forest. The match method takes a quad pattern and builds a new dataset containing only the matching quads. First, the terms in the pattern are converted to identifiers, and the forest is requested for matching quads (it is more efficient than 9
10
By “trivially copyable”, like in C++, we mean that to copy the data, the underlying bytes can be copied from one location to another. An array of 32 bits integers is trivially copyable from WASM to JS with the Int32Array object type. A string is not trivially copyable because of the different encodings. https://graphy.link/concise.
WasmTree
589
Fig. 3. Process to retrieve quads from a TreeDataset - WasmTree approach. The left blue part is in JS, while the right red part is a WASM built from Rust
browsing the identifier list). This produces a new identifier list, which is used to build a new dataset containing that list, but no forest. The identifier list returned by the forest in WASM is a plain Uint32Array Javascript object, meaning that the garbage collector is able to manage it. It is also cheap to produce, as it only requires to copy a segment of the WASM linear memory. The mapping of terms is not duplicated, but shared with the original dataset. The benefit of this design is that, once an identifier list has been retrieved, and as long as that dataset is not modified, no exchange is required with WASM. Furthermore, while the match method is required by the RDFJS API to return a full-fledged dataset, in most cases, this dataset will be iterated over and dismissed, therefore spending time indexing its quads into B-Trees would be useless. However, the indexing (forest reconstruction) will happen lazily if the dataset was to be modified or queried again with match. Our Dataset interface also provides a free method which is not part of the RDFJS API. It removes the forest and the identifier list, and frees the WASM memory segment allocated to the former. From the the end-user’s point-of-view, it has the effect of emptying the dataset. By using a similar split between WASM and JS code, we also developed an implementation of the RDFJS Store interface. The main differences between Dataset and Store are that Store methods are asynchronous and the match method in Store returns a stream of quads instead of a new dataset. Our implementation is based on an asynchronous call on a function which starts with retrieving the identifier list corresponding to the pattern, and then rebuilds a quad by using the identifier list and the JS dictionary every time a data message is emitted.
4
Evaluation
In this section, we evaluate the performance of WasmTree in three different situations: first, we study the amounts of time and memory required to initialize
590
J. Bruyat et al.
a dataset from an N-Quad file, second we evaluate its performance on a simple task of pattern matching, third we evaluate it in the case of a SPARQL query. All these evaluations have been performed using the following setup. Compilation tasks have been performed using Rust Compiler 1.43.0, and wasm-bindgen 0.2.63. Benchmarks have been coded and run on the NodeJS 10.19.0 platform. API tests have been performed on a PC equipped with an Intel(R) Core(TM) i5-1035G1 processor, 16 GB of DDR4 RAM, and the Ubuntu 20.04 LTS OS. SPARQL tests have been performed on a virtual machine with 4 VCPUs (based on 2600 MHz Intel Xeon Skylake processors) and 8 GB of RAM. The two first experiments (dataset initialization and simple pattern matching) were conducted under the following conditions: the datasets we used are extracts of various sizes (up to 1 million quads) from the Person data dataset of the 2016-10 dump11 of DBpedia [1] in N-Triples format, considered as an RDF dataset containing one default graph. All measures were performed 50 times and the average was computed. Both experiments were performed using the RDFJS API and the N3.js parser to read the dataset. A step by step guide to reproduce the experiments can be found at https://github.com/BruJu/wasm_rdf_ benchmark/tree/eswc2021. 4.1
Evaluation of Dataset Initialization
We herein evaluate the cost, in time and memory, of initializing a dataset from an N-Quads file containing 1 million quads, in different implementations. By initializing, we mean here all the operations required to make the dataset available to the JS application: reading and parsing the data, and populating data structures. For the TreeDataset approaches and WasmTree, we tested a lazy configuration, where only one of the six B-Trees is constructed (default), and a greedy configuration immediately building all six B-Trees. Time: Fig. 4b shows initialization speed for several RDFJS Dataset implementations. We also compare N3.js using its synchronous addQuad function. With only one index, WasmTree is 1.30 times faster than N3.js, and is 1.06 times faster than Graphy, which doesn’t resort to a dictionary and directly stores quads in its hashtree. When building greedily its 6 indexes, WasmTree is 1.32 times slower than Graphy, and 1.06 times slower than N3.js. The table in Fig. 4a shows that the difference between filling one and six indexes is the same (2.1 s) for our two implementations. This is not surprising as they use the same data structures for indexes. This corroborates our hypothesis that the poor performance of TreeDataset are related to storing strings in the term mapping in the WASM memory. The lost time is more impacting in terms of initialization speed for WasmTree as a 2.1 s difference represents a higher ratio of the total time. In real world applications, the lazy indexing strategy will ensure the users benefit from the fastest initialization time, amortizing the cost of creating the missing indexes over the use of the dataset. 11
https://wiki.dbpedia.org/develop/datasets/downloads-2016-10.
WasmTree
591
Fig. 4. Time and memory used to initialize a 1 M quad dataset in various RDFJS implementations.
Memory: The table in Fig. 4a also exhibits an estimation of the memory used to store the different benchmarked RDFJS implementations. These estimations are based on the peak virtual memory usage, as provided in Linux by the VmPeak field of the file /proc/self/status. This introduces a bias because JS may allocate memory before the garbage collector has freed memory blocks that are not used anymore. Actually, we see that this method is not precise enough to measure the difference between one and six indexes within the same implementation, therefore the most relevant information from these measures is the order of magnitude. We can see that implementations relying on WASM are more compact than pure JS implementations. TreeDataset, used by the naive approach and the allat-once approach, entirely based on Rust data structures stored in the WASM memory, is by orders of magnitude the most memory-efficient. However, its initialization time and its poor query performance (as shown in Sect. 4.2) make it non satisfying. The hybrid approach (WasmTree) still consumes less memory than the best pure JS implementation in our study (Graphy). The difference between pure Rust implementations (TreeDataset), those using fewer JS structure (WasmTree, Graphy) and those using many JS structures (N3.js), demonstrates that Rust structures compiled into WASM are much more compact than comparable JS structures. Additionally, we already remarked that the memory used by WASM B-Trees is negligible compared to the term mapping and the noise induced by the garbage collector. This motivates our choice to store several indexes in WASM memory in order to improve speed. 4.2
Evaluation of Simple Pattern Matching
We now proceed to evaluate the performance of extracting quads matching a given pattern. This corresponds to simple queries such as “find all quads about person X” or “find all resources of type Person”.
592
J. Bruyat et al.
For each measure, we load a dataset and call the method match twice with the given pattern, measuring the time taken by the second call. The first method call ensures that lazily built indexes and caches are computed. The cost of these operations is considered irrelevant here as 1) it will be amortized on multiple calls, and 2) different implementations will trigger them at different times or for different queries, making comparisons less meaningful. We then measure the time it takes to iterate over all the quads of the Dataset returned by the second call to match.
Fig. 5. Time (in seconds) to iterate over quads matching a given pattern.
Performance with Different Patterns: The first set of measures we ran is for querying the dataset for quads having a given subject. We chose that subject in such a way that the number of matching quads was the same (seven) regardless of the dataset size. TreeDataset and WasmTree use their SPOG index to answer this query. The unique index used by Graphy is also optimal in this case (GSPO, with only one graph in the dataset). The results are shown in Fig. 5a. TreeDataset is slower than Graphy, a pure JS implementation. This can be explained by the fact that the time saved by using WASM is lost in the translation process with JS. The all-at-once approach is the worst, being twice as slow as the naive approach. The reason for these poor performance will be explored later with Fig. 6a. On the other hand, WasmTree reduces the number of exchanges (one array describing all the quads instead of individual quads) and the complexity of the exchanged data (integers rather than strings). This reaches the best trade-off, where the manipulations of numbers are most efficiently handled by WASM code, while string manipulations are left to JS. We see that the size of the input dataset has only a minimal impact on all implementations. This shows that the choice of B-Trees, that have a O(log n)
WasmTree
593
Fig. 6. Workload distribution when matching over a certain pattern.
complexity for searching quads, is a viable alternative to hashmaps with O(1) complexity (as used by Graphy). Figure 5b shows the result of a second set of measures, where we are now looking for every resource of type Person in the default graph. For every dataset size, the retrieved quads represent about 13% of the total dataset size. In other words, the output size in this benchmark is linear with the dataset size. For this query pattern (?POG), Graphy’s GSPO index is not theoretically optimal, which would make the comparison unfair, as our implementation always uses an optimal index. However, in this particular dataset, all the subjects are of type Person, so they all match the pattern. Graphy is therefore not sanctioned for having to loop on all the subjects. We can see that the order remains the same: WasmTree is still the most efficient solution, followed by Graphy and then TreeDataset. The gap between different options is bigger, and increases with the size of the output: instead of being 1.5 times faster than Graphy as in Fig. 5a, WasmTree is now 4 to 35 times faster than Graphy, scaling better as the output size grows. We also benchmarked our implementation of the Store interface using WasmTree and compared it to N3.js in similar conditions. We found that WasmTree also outperforms N3.js. For example, when looking for every person in the dataset, WasmTree is on par with N3.js for small datasets, but becomes increasingly faster (up to 13.671 times) when the input dataset grows. Using the Store interface of WasmTree makes the iteration over all quads 2.73 to 8.22 times slower than using its Dataset interface; it means that in practice, consuming an asynchronous stream of quads is more time consuming than populating an intermediate dataset. Workload Distribution: In Fig. 6, we focus on the Dataset interface, to study how the overall time measured previously is distributed between finding the
594
J. Bruyat et al.
matching triples (match), and iterating over them (loop)12 . While Fig. 6a shows measures for the same query as Fig. 5a, using a S??? pattern, Fig. 6b shows measures for the same query as Fig. 5b, using a ?POG pattern. In both figures, we use the biggest version of our test dataset (1M quads). In TreeDataset, the all-at-once approach is very inefficient: the looping part is up to 11 times slower than the naive approach, especially when the returned dataset is small (Fig. 6a). Profiling the code reveals that 22% of the time spent is used by the garbage collector. Compared to the naive approach, the all-at-once approach aimed at reducing the number of exchanges, but that is at the expense of a more complex processing to retrieve all quads. Indeed the implementation has to change the encoding of the string from UTF-8 to UTF-16, and then parse the string to build the quads. TreeDataset is always slower to loop on all quads than Graphy. The total time for the latter is even lower than the match time for TreeDataset. The match operation has limited exchange with WASM: it consists in only one function call. We can deduce that the cost of interpretation of the WASM code and our code are not efficient enough to beat Graphy, both for small and big results. It can be explained because Graphy does not build a whole new dataset when the match method is called: the returned dataset shares data structures with the source dataset, unlike TreeDataset that copies the quads and creates a new independent dataset. WasmTree, on the other hand, is faster than all the other approaches, especially during the loop, and when the output dataset is big (Fig. 6b). This confirms that the computation intensive part of the processing is mostly handled by WASM code (in the match method), making quick and easy the remaining task of the JS code handling the loop. Thanks to the compactness of the B-Trees stored in the WASM memory, we can afford to store indexes for all possible patterns, while Graphy is bound, with a unique index, to be less efficient for some patterns. Ablation Study: WasmTree uses two different strategies to be fast. The first one consists in caching the list of identifiers in an array, as described at the end of Sect. 3.4. The second one consists in sharing the term mapping between a dataset and the (sub-)datasets returned by the match method. In Figs. 6a and 6b, we studied the impact of these optimizations by removing the first one (“Always Forest”), removing the second one (“Duplicated Map”) and removing both. The sharing of term mappings is what saves most time, dividing by 2 the total time for the S??? benchmark. Producing an independent dataset when the match method is called is expensive, as it requires to produce and populate a new term mapping, and this operation has to be done in JS. It results in similar to slightly worse performance as compared to Graphy. When producing a dataset that shares the term mapping, WasmTree is 1.4 to 19 times faster than Graphy, which shares its index and has no mapping. 12
This distinction is not relevant for the Store interface, where the iteration is performed in an asynchronous fashion.
WasmTree
595
The caching of the identifier list has a bigger impact when the output dataset is large (?POG benchmark). Indeed, when there are few elements, the identifier list memory representation in JS and the B-Tree one in WASM are close. In the S??? benchmark, as there are only 7 quads to return, both representations are an array of 28 integers. In the default WasmTree implementation, the identifier list is already in the JS environment, so it does not call a WASM function to retrieve it. The “WasmTree Always Forest” implementation retrieves the identifier list from the WASM environment. When there are less than 2B elements, it consists in simply copying the root element of the B-Tree. This is the only difference between the two, and explains the small measured difference in time, as shown in Fig. 6a. In every benchmark but memory consumption, WasmTree, the implementation that splits works between WASM and JS is better than TreeDataset: having faster initialization time, faster quad retrieval and being less error prone, as users do not have to care about freeing memory except for the datasets. Moreover, the identifier list permits users to forget about freeing the datasets produced by match, as they do not actually allocate WASM memory. 4.3
Evaluation of SPARQL Queries
To get a broader insight on performance, our third set of experiments evaluates performance on SPARQL [11] queries. SPARQL allows to express complex queries, contrarily to the simple query patterns studied in the previous section. We used the Berlin SPARQL Benchmark [6] (BSBM), a benchmarking framework for SPARQL. It can generate synthetic datasets about products, vendors and consumers, and realistic queries over these datasets. It provides a driver that can submit a set of queries (a query mix ) to a SPARQL endpoint and measure its performance. We are interested here in information retrieval: the driver sends a query mix made of 25 queries, generated from 12 query templates from the “Explore” use-case of BSBM. For example, in the first template “Find the name of all products having [two specific features]”, the driver randomly chooses the two features for each query. As described in Sect. 2, Comunica can be used to setup a SPARQL endpoint above any implementation of the RDFJS Store interface. We use Comunica v1.13.1 to expose a SPARQL endpoint above our RDFJS implementation. In this section, we will compare the default configuration (using N3.js) with a Comunica SPARQL endpoint backed by WasmTree. Oxigraph, which we also described in Sect. 2 is a Rust library implementing a dataset and a SPARQL engine. It can be compiled to WASM, providing its own API which only partially complies with RDFJS, but exposes SPARQL functionalities. It was therefore straightforward to use it to build a Node.js-based SPARQL endpoint, where the whole query processing is done in WASM. Performance. Table 1 shows that, when it comes to executing SPARQL queries, replacing N3.js with WasmTree as Comunica’s store allows to execute almost 7
596
J. Bruyat et al.
Table 1. Performance of three SPARQL endpoints, with a dataset of 2000 products (725305 quads). Measured from 100 executions after a warmup of 20 executions. Query mixes per hour
Acceleration compared to Oxigraph
Oxigraph Comunica + WasmTree Comunica + N3.js
446.22 65.64
Comunica +WasmTree ×19.90
8877.66 ×0.05 ×0.007
Comunica +N3.js ×135.25 ×6.80
×0.15
times more queries in the same time. WASM increases performance even when used only for a part (finding quads) of a more complex operation (executing a query plan and computing joints). Oxigraph is itself 20 times faster than Comunica with WasmTree. The difference can be explain both by the efficiency of WASM for complex processing paying off compared to the cost of transferring the results, but also the fact that Oxigraph is not limited by the RDFJS API, which enables it to use better query plans. Memory Limitations. We initially tried to run the BSBM driver with a scale factor of 10,000 (corresponding to a dataset of 4 M quads), but we ran into memory shortage. For Comunica-based approaches, this was solved by increasing the memory allocated to JS. However, for Oxigraph, the limitation was due to WASM itself, which uses 32bit addresses, and is therefore structurally limited to handling 4 GB of linear memory. This limit is easily reached with big RDF datasets. The strict limitation is less impacting on WasmTree, because it only uses WASM memory for BTrees.
5
Conclusion and Perspectives
In this work, we studied how we can use Rust and WASM to build efficient RDF libraries for JS runtimes. Our experiments show that using WASM naively does not improve performance. In an effort to reduce the costs related to exchanging information between WASM and JS, we have proposed WasmTree, a hybrid implementation providing an efficient distribution of tasks between the two languages. On simple pattern matching queries, it outperforms two state-of-the-art JS libraries: Graphy and N3.js. In the context of SPARQL query evaluation, the fastest approach by far is the one relying entirely on WASM (Oxigraph). However, the WASM intrinsic memory limitations hinder the scalability of this approach. WasmTree, on the other hand, improves the performance of the Comunica framework while being much less affected by this scalability issue. However, the forest structure, which is the only part implemented in Rust for WasmTree, has no access to the actual terms in the graph. Thus, semantic processing such as inferences, which could benefit from the performance gain of WASM, can not directly be implemented on the WASM side. To tackle this problem, we should refine the hybridization between the two sides of our implementation. Some clues are the following: we could fix once and for all the identifier of
WasmTree
597
semantically loaded IRIs (such as rdfs:subClassOf), or enable the term mapping to share some specific identifiers with the index, depending on the inference ruleset. These ideas will be for further work. Acknowledgment. This work was partly supported by the Fédération Informatique de Lyon within the Repid project, and by the EC within the H2020 Program under grant agreement 825333 (MOSAICrOWN).
References 1. Auer, S., Bizer, C., Kobilarov, G., Lehmann, J., Cyganiak, R., Ives, Z.: DBpedia: a nucleus for a web of open data. In: Aberer, K., et al. (eds.) ASWC/ISWC -2007. LNCS, vol. 4825, pp. 722–735. Springer, Heidelberg (2007). https://doi.org/10. 1007/978-3-540-76298-0_52 2. Bayer, R., McCreight, E.: Organization and maintenance of large ordered indices. In: Proceedings of the 1970 ACM SIGFIDET (Now SIGMOD) Workshop on Data Description, Access and Control, pp. 107–141. SIGFIDET 1970. ACM, New York, NY, USA (1970). https://doi.org/10.1145/1734663.1734671 3. Bergwinkl, T.: RDF/JS: Dataset specification. W3C Community Group Final Report, W3C, March 2019. https://rdf.js.org/dataset-spec/. Accessed 15 Dec 2020 4. Bergwinkl, T., Verborgh, R.: RDF/JS: Stream interfaces. W3C Community Group Draft Report, W3C, May 2019. http://rdf.js.org/stream-spec/. Accessed 15 Dec 2020 5. Bergwinkl, T., Verborgh, R.: RDF/JS: Data model specification. W3C Community Group Draft Report, W3C, July 2020. http://rdf.js.org/data-model-spec/. Accessed 15 Dec 2020 6. Bizer, C., Schultz, A.: The Berlin SPARQL benchmark. Int. J. Semant. Web Inf. Syst. (IJSWIS) 5(2), 1–24 (2009) 7. Carothers, G.: RDF 1.1 n-quads. W3C recommendation, W3C, February 2014. http://www.w3.org/TR/n-quads/ 8. Champin, P.A.: Sophia: a linked data and semantic web toolkit for rust. In: The Web Conference 2020: Developers Track, April 2020. https://www2020devtrack.github. io/site/schedule 9. Cyganiak, R., Wood, D., Lanthaler, M.: RDF 1.1 Concepts and Abstract Syntax. W3C Recommendation, W3C, February 2014. https://www.w3.org/TR/rdf11concepts/ 10. Fernández, J.D., Martínez-Prieto, M.A., Gutiérrez, C., Polleres, A., Arias, M.: Binary RDF representation for publication and exchange (HDT). J. Web Semant. 19, 22–41 (2013) 11. Harris, S., Seaborne, A.: SPARQL 1.1 Query Language. W3C Recommendation, W3C, March 2013. http://www.w3.org/TR/sparql11-query/ 12. Matsakis, N.D., Klock, F.S.: The Rust language. ACM SIGAda Ada Lett. 34(3), 103–104 (2014) 13. Regalia, B.: Graphy.js homepage. https://graphy.link/. Accessed 15 Dec 2020 14. Rossberg, A.: WebAssembly Core Specification. W3C Recommendation, W3C, December 2019. https://www.w3.org/TR/wasm-core-1/ 15. Taelman, R., Van Herwegen, J., Vander Sande, M., Verborgh, R.: Comunica: A Modular SPARQL Query Engine for the Web. In: Vrandečić, D., et al. (eds.) ISWC 2018. LNCS, vol. 11137, pp. 239–255. Springer, Cham (2018). https://doi.org/10. 1007/978-3-030-00668-6_15 16. Verborgh, R.: N3.js homepage. https://github.com/rdfjs/N3.js/. Accessed 15 Dec 2020
ParaQA: A Question Answering Dataset with Paraphrase Responses for Single-Turn Conversation Endri Kacupaj1(B) , Barshana Banerjee1 , Kuldeep Singh2 , and Jens Lehmann1,3 1 University of Bonn, Bonn, Germany {kacupaj,jens.lehmann}@cs.uni-bonn.de, [email protected] 2 Zerotha Research and Cerence GmbH, Aachen, Germany [email protected] 3 Fraunhofer IAIS, Dresden, Germany [email protected]
Abstract. This paper presents ParaQA, a question answering (QA) dataset with multiple paraphrased responses for single-turn conversation over knowledge graphs (KG). The dataset was created using a semiautomated framework for generating diverse paraphrasing of the answers using techniques such as back-translation. The existing datasets for conversational question answering over KGs (single-turn/multi-turn) focus on question paraphrasing and provide only up to one answer verbalization. However, ParaQA contains 5000 question-answer pairs with a minimum of two and a maximum of eight unique paraphrased responses for each question. We complement the dataset with baseline models and illustrate the advantage of having multiple paraphrased answers through commonly used metrics such as BLEU and METEOR. The ParaQA dataset is publicly available on a persistent URI for broader usage and adaptation in the research community. Keywords: Question answering · Paraphrase responses conversation · Knowledge graph · Dataset
· Single-turn
Resource Type: Dataset License: Attribution 4.0 International (CC BY 4.0) Permanent URL: https://figshare.com/projects/ParaQA/94010.
1
Introduction
In recent years, publicly available knowledge graphs (e.g., DBpedia [21], Wikidata [40]) and Yago [36]) have been widely used as a source of knowledge in several tasks such as entity linking, relation extraction, and question answering [22]. Question answering (QA) over knowledge graphs, in particular, is an essential task that maps a user’s utterance to a query over a knowledge graph (KG) to retrieve the correct answer [34]. With the increasing popularity of c Springer Nature Switzerland AG 2021 R. Verborgh et al. (Eds.): ESWC 2021, LNCS 12731, pp. 598–613, 2021. https://doi.org/10.1007/978-3-030-77385-4_36
ParaQA
599
Table 1. Comparison of ParaQA with existing QA datasets over various dimensions. Lack of paraphrased utterances of answers remains a key gap in literature. Dataset
Large scale (>= 5K) Complex questions SPARQL Verbalized answer Paraphrased answer
ParaQA (This paper)
✓
✓
✓
✓
✓
Free917 [8] ✗ ✓ WebQuestions [4] ✓ SimpleQuestions [6] ✗ QALD (1–9)a ✓ LC-QuAD 1.0 [38] ✓ LC-QuAD 2.0 [10] ✗ ComplexQuestions [3] ✓ ComQA [1] ✓ GraphQuestions [35] ComplexWebQuestions [37] ✓ ✓ VQuAnDa [20] ✓ CSQA [31] ✓ ConvQuestions [9]
✓ ✗ ✗ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓
✗ ✗ ✓ ✓ ✓ ✓ ✗ ✗ ✓ ✓ ✓ ✗ ✗
✗ ✗ ✗ ✗ ✗ ✗ ✗ ✗ ✗ ✗ ✓ ✗ ✗
✗ ✗ ✗ ✗ ✗ ✗ ✗ ✗ ✗ ✗ ✗ ✗ ✗
intelligent personal assistants (e.g., Alexa, Siri), the research focus has been shifted to conversational question answering over KGs that involves singleturn/multi-turn dialogues [33]. To support wider research in knowledge graph question answering (KGQA) and conversational question answering over KGs (ConvQA), several publicly available datasets have been released [4,31,38]. Motivation and Contributions. In dialog systems research, we can distinguish between single-turn and multi-turn conversations [7,19]. In single-turn conversations, a user provides all the required information (e.g., slots/values) at once, in one utterance. Conversely, a multi-turn conversation involves anaphora and ellipses to fetch more information from the user as an additional conversation context. The existing ConvQA [9,31] datasets provide multi-turn dialogues for question answering. In a real-world setting, user will not always require multiturn dialogues. Therefore, single-turn conversation is a common phenomenon in voice assistants1 . Some public datasets focus on paraphrasing the questions to provide real-world settings, such as LC-QuAD2.0 [10] and ComQA [1]. The existing ConvQA datasets provide only up to one verbalization of the response (c.f. Table 1). In both dataset categories (KGQA or ConvQA), we are not aware of any dataset providing paraphrases of the various answer utterances. For instance, given the question “How many shows does HBO have?”, on a KGQA dataset (LC-QuAD [38]), we only find the entity as an answer (e.g. “38”). While on a verbalized KGQA dataset [20], the answer is verbalized as “There are 38 television shows owned by HBO.” Given this context, the user can better verify that the system is indeed retrieving the total number of shows owned by HBO. However, the answer can be formulated differently using various paraphrases such as “There are 38 TV shows whose owner is HBO.”, “There are 38 television 1
https://docs.microsoft.com/en-us/cortana/skills/mva31-understandingconversations.
600
E. Kacupaj et al.
programs owned by that organization” with the same semantic meaning. Hence, paraphrasing the answers can introduce more flexibility and intuitiveness in the conversations. In this paper, we argue that answer paraphrasing improves the machine learning models’ performance for single-turn conversations (involving question answering over KG) on standard empirical metrics. Therefore, we introduce ParaQA, a question answering dataset with multiple paraphrase responses for single-turn conversation over KGs. The ParaQA dataset was built using a semi-automated framework that employs advanced paraphrasing techniques such as back-translation. The dataset contains a minimum of two and a maximum of eight unique paraphrased responses per question. To supplement the dataset, we provide several evaluation settings to measure the effectiveness of having multiple paraphrased answers. The following are key contributions of this work: – We provide a semi-automated framework for generating multiple paraphrase responses for each question using techniques such as back-translation. – We present ParaQA - The first single-turn conversational question answering dataset with multiple paraphrased responses. In particular, ParaQA consists of up to eight unique paraphrased responses for each dataset question that can be answered using DBpedia as underlying KG. – We also provide evaluation baselines that serve to determine our dataset’s quality and define a benchmark for future research. The rest of the paper is structured as follows. In the next section, we describe the related work. We introduce the details of our dataset and the generation workflow in Sect. 3. Section 4 describes the availability of the dataset, followed by the experiments in Sect. 5. The reusability study and potential impact is described in Sect. 6. Finally, Sect. 7 provides conclusions.
2
Related Work
Our work lies at the intersection of KGQA and conversational QA datasets. We describe previous efforts and refer to different dataset construction techniques. KGQA Datasets. The datasets such as SimpleQuestions [6], WebQuestions [42], and the QALD challenge2 have been inspirational for the evolution of the field. SimpleQuestions [6] dataset is one of the most commonly used largescale benchmarks for studying single-relation factoid questions over Freebase [5]. LC-QuAD 1.0 [38] was the first large-scale dataset providing complex questions and their SPARQL queries over DBpedia. The dataset has been created using pre-defined templates and a peer-reviewed process to rectify those templates. Other datasets such as ComQA [1] and LC-QuAD 2.0 [10] are large-scale QA datasets with complex paraphrased questions without verbalized answers. It is important to note that the answers of most KGQA datasets are non-verbalized. VQuAnDa [20] is the only QA dataset with complex questions containing a single verbalized answer for each question. 2
http://qald.aksw.org/.
ParaQA
601
Conversational QA. There has been extensive research for single-turn and multi-turn conversations for open-domain [7,23,43]. The research community has recently shifted focus to provide multi-turn conversation datasets for question answering over KGs. CSQA [31] is a large-scale dataset consisting of multiturn conversations over linked QA pairs. The dataset contained 200K dialogues with 1.6M turns and was collected through a manually intensive semi-automated process. The dataset comprises complex questions that require logical, quantitative, and comparative reasoning over a Wikidata KG. ConvQuestions [9] is a crowdsourced benchmark with 11K distinct multi-turn conversations from five different domains (“Books”, “Movies”, “Soccer”, “Music”, and “TV Series”). While both datasets cover multi-turn conversations, none of them contains verbalized answers. Hence, there is a clear gap in the literature for the datasets focusing on single-turn conversations involving question answering over KGs. In this paper, our work combines KGQA capabilities with the conversational phenomenon. We focus on single-turn conversations to provide ParaQA with multiple paraphrased answers for more expressive conversations. Dataset Construction Techniques. While some KGQA datasets are automatically generated [32], most of them are manually created either by (i) using in-house workers [38] or crowd-sourcing [10], (ii) or extract questions from online question answering platforms such as search engines, online forum, etc. [4]. Most (single-turn/multi-turn) conversational QA datasets are generated using semiautomated approaches [9,31]. First, conversations are created through predefined templates. Second, the automatically generated conversations are polished by inhouse workers or crowd-sourcing techniques. CSQA [31] dataset contains a series of linked QA pairs forming a coherent conversation. Further, these questions are answerable from a KG using logical, comparative, and quantitative reasoning. For generating the dataset, authors first asked pairs of in-house workers to converse with each other. One annotator in a pair acted as a user whose job was to ask questions, and the other annotator worked as the system whose job was to answer the questions or ask for clarifications if required. The annotators’ results were abstracted to templates and used to instantiate more questions involving different relations, subjects, and objects. The same process was repeated for different question types such as co-references and ellipses. ConvQuestions[9] dataset was created by posing the conversation generation task on Amazon Mechanical Turk (AMT)3 . Each crowd worker was asked to build a conversation by asking five sequential questions starting from any seed entity of his/her choice. Humans may have an intuitive model when satisfying their real information needs via their search assistants. Crowd workers were also asked to provide paraphrases for each question. Similar to [31], the crowd workers’ results were abstracted to templates and used to create more examples. While both conversational QA datasets use a relatively similar construction approach, none of them considers verbalizing the answers and providing paraphrases for them. 3
https://www.mturk.com/.
602
E. Kacupaj et al. Table 2. Examples from ParaQA.
Question What is the television show whose judges is Randy Jackson? Answer verbalizations 1) American Idol is the television show with judge Randy Jackson 2) The television show whose judge Randy Jackson is American Idol 3) The TV show he’s a judge on is American Idol Question How many shows does HBO have? Answer verbalizations 1) There are 38 television shows owned by HBO 2) There are 38 TV shows whose owner is HBO 3) There are 38 television shows whose owner is that organisation 4) There are 38 television programs owned by that organization Question From which country is Lawrence Okoye’s nationality? Answer verbalizations 1) Great Britain is the nationality of Lawrence Okoye 2) Great Britain is Lawrence Okoye’s citizenship 3) The nationality of Lawrence Okoye is Great Britain 4) Lawrence Okoye is a Great British citizen 5) Lawrence Okoye’s nationality is Great Britain Question
Does Sonny Bill Williams belong in the Canterbury Bankstown Bulldogs club? Answer verbalizations 1) Yes, Canterbury-Bankstown Bulldogs is the club of Sonny Bill Williams 2) Yes, the Canterbury-Bankstown Bulldogs is Bill Williams’s club 3) Yes, the Canterbury-Bankstown Bulldogs is his club 4) Yes, Canterbury-Bankstown Bulldogs is the club of the person 5) Yes, the club of Sonny Bill Williams is Canterbury-Bankstown Bulldogs 6) Yes, Bill Williams’s club is the Canterbury-Bankstone Bulldogs
Paraphrasing. In the early years, various traditional techniques have been developed to solve the paraphrase generation problem. McKeown [25] makes use of manually defined rules. Quirk et al. [30] train Statistical Machine Translation (SMT) tools on a large number of sentence pairs collected from newspapers. Wubben et al. [41] propose a phrase-based SMT model trained on aligned news headlines. Recent approaches perform neural paraphrase generation, which is often formalized as a sequence-to-sequence (Seq2Seq) learning. Prakash et al. [29] employ a stacked residual LSTM network in the Seq2Seq model to enlarge the model capacity. Hasan et al. [17] incorporate the attention mechanism to generate paraphrases. Work in [12] integrates the transformer model and recurrent neural network to learn long-range dependencies in the input sequence.
3
ParaQA: Question Answering with Paraphrase Responses for Single-Turn Conversation
The inspiration for generating paraphrased answers originates from the need to provide a context of the question to assure that the query was correctly understood. In that way, the user would verify that the received answer correlates with the question. For illustration, in our dataset, the question “What is the commonplace of study for jack McGregor and Philip W. Pillsbury?” is translated to the corresponding SPARQL query, which retrieves the result “Yale University” from the KG. In this case, a full natural language response of the result is “Yale
ParaQA
603
Fig. 1. Overview of dataset generation workflow. Our proposed generation workflow consists of 6 modules in total. The first module is “Input & Initial Verbalization”, which is responsible for producing the initial verbalized results for each input question. The next three modules (“Entity-Type Identification though Named Entity Recognition”, “Gender Identification”, and “New Verification Template”) are applied simultaneously and provide new verbalized sentences based on the initial ones. Subsequently, the paraphrasing module, named “Paraphrase through Back-Translation”, applies back translation to generated answers. Finally, in the last step (“Rectify Verbalization”), we rectify all the paraphrased results through a peer-review process.
University is the study place of Jack McGregor and Philip W. Pillsbury.”. As can be seen, this form of answer provides us the query result and details about the query’s intention. At the same time, we also provide alternative paraphrased responses such as, “Yale University is the place where both Jack McGregor and Philip W. Pillsbury studied.”, “Yale is where both of them studied.”. All those answers clarify to the user that the question answering system completely understood the question context and the answer is correct. They can also verify that the system retrieves a place where “Jack McGregor” and “Philip W. Pillsbury” went for their studies. Table 2 illustrates examples from our dataset. 3.1
Generation Workflow
For generating ParaQA, we decided not to reinvent the wheel to create new questions. Hence, we inherit questions from LC-QuAD [38] and single answer verbalization of these question provided by VQuAnDa [20]. We followed a semiautomated approach to generate the dataset. The overall architecture of the approach is depicted in Fig. 1.
604
E. Kacupaj et al.
Table 3. Examples generated from each automatic step/module of our proposed generation framework. The presented responses are the outputs from the corresponding modules before they undergo the final peer-review step. The bold text of the initial answer indicates the part of the sentence where the corresponding module is focusing. The underlined text on the generated results reveals the changes made from the module. Entity-type Question Initial Generated Gender
Count the key people of the Clinton Foundation? There are 8 key people in the Clinton Foundation There are 8 key people in the organisation
Question Which planet was first discovered by Johann Gottfried Galle? Verbalized answer The planet discovered by Johann Gottfried Galle is Neptune Generated The planet he discovered is Neptune
Verification Question Initial Generated
Does the River Shannon originate from Dowra? Yes, Dowra is the source mountain of River Shannon Yes, River Shannon starts from Dowra
Paraphrase Question Who first ascended a mountain of Cathedral Peak (California)? Initial The person that first ascended Cathedral Peak (California) is John Muir Generated (en-de) The first person to climb Cathedral Peak (California) is John Muir Generated (en-ru) The person who first climbed Mount Katty Peak (California) is John Muir
Input & Initial Verbalization Our framework requires at least one available verbalized answer per question to build upon it and extend it into multiple diverse paraphrased responses. Therefore, the generation workflow from [20] is adopted as a first step and used to generate the initial responses. This step’s inputs are the questions, the SPARQL queries, and the hand-crafted natural language answer templates. Entity-Type Identification Though Named Entity Recognition Named Entity Recognition (NER) step recognizes and classifies named entities into predefined categories, for instance, persons, organizations, locations, etc. Our aim here is to identify the entity category (or entity-type) and span and replace it with a predefined value in the response. This stage allows us to accomplish more general verbalization since question entities are swapped with their type categories. The whole process is performed in 2 steps: 1) A pre-trained NER [18] model is employed to locate entities in the initial generated responses. Discovered entities are replaced with their type category such as “ORG, PRODUCT, LOC, PERSON, GPE”. 2) A predefined dictionary is used to substitute the type categories with different words such as “the organization, the person, the country”. Table 3 presents a generated example from the entity-type identification step. Gender Identification In this step, we create new responses by replacing the question entities with their corresponding pronouns, e.g. “he, she, him, her”. This is done by identifying the entity’s gender. In particular, we query the KG with a predefined SPARQL query
ParaQA
605
that extracts the gender of the given entity. Based on the position of the entity in the answer, we replace it with the appropriate pronoun. Table 3 illustrates a generated example from the gender identification step. In peer-review process, we verify the dataset to avoid any bias in the genders considering we extract gender information from DBpedia and sometime KG data quality is not perfect. New Verification Template Considering that, on verification questions, all triple data is given (head, relation, tail). We introduce a verbalization template that interchanges the head and tail triple information and generate more diverse responses. Table 3 provides a generated example from this process. Paraphrase Through Back-Translation After having assembled sufficient answers for each question, we employ a paraphrasing strategy through a back-translation approach. In general, backtranslation is when a translator (or team of translators) interprets or re-translate a document that was previously translated into another language back to the original language. In our case, the two translators are independent models, and the second model has no knowledge or contact with the original text. In particular, inspired by [11,14], our initial responses alongside the new proposed answer templates are paraphrased using transformer-based models [39] as translators. The model is evaluated successfully on the WMT’184 dataset that includes translations between different languages. In our case, we perform back-translation with two different sets of languages: 1) Two transformer models are used to translate the responses between English and German language (en→de→en). 2) Another two models are used to translate between English and Russian language (en→ru→en). Here it is worth mentioning that we also forwarded output responses from one translation stack into the other (e.g., en→de→en→ru→en). In this way, we generate as many as possible different paraphrased responses. Please note that the selection of languages for back translation was done considering our inherited underlying model’s accuracy in machine translation tasks on WMT’18. Table 3 illustrates some examples from our backtranslation approach. Rectify Verbalization After collecting multiple paraphrased versions of the initial responses, the last step is to rectify and rephrase them to sound more natural and fluent. The rectification step of our framework is done through a peer-review process to ensure the answers’ grammatical correctness. Finally, by the end of this step, we will have at least two and at most eight diverse paraphrased responses per question, including the initial answer.
4
http://www.statmt.org/wmt18/translation-task.html.
606
E. Kacupaj et al.
Fig. 2. Total paraphrased responses per question.
3.2
Dataset Statistics
We provide dataset insights regarding its total paraphrased results for each question and the percentage of generated answers from each module on our framework. Figure 2 illustrates the distribution of 5000 questions of ParaQA based on a total number of paraphrased responses per question. As seen from the figure, more than 2500 questions contain at most two paraphrased results. A bit less than 2000 questions include at most four answers, while around 500 have no less than six paraphrased answers. Finally, less than 100 examples contain at most eight paraphrased results. Figure 3 depicts the percentage of generated answers for each step from our generation workflow. The first step (input and initial verbalization) provides approximately 30% of our total results, while the next three steps (entity type identification, gender identification, and new verification templates) produce roughly 20% of responses. Finally, the back-translation module generates no less than 50% of the complete paraphrased answers in ParaQA.
4
Availability and Sustainability
Availability. The dataset is available at a GitHub repository5 under the Attribution 4.0 International (CC BY 4.0)6 license. As a permanent URL, we also provide our dataset through figshare at https://figshare.com/projects/ParaQA/ 94010. The generation framework is also available at a GitHub repository7 under the MIT License8 . Please note, the dataset and the experiments reported in the paper are in two different repositories due to the free distributed license agreement. 5 6 7 8
https://github.com/barshana-banerjee/ParaQA. https://creativecommons.org/licenses/by/4.0/. https://github.com/barshana-banerjee/ParaQA Experiments. https://opensource.org/licenses/MIT.
ParaQA
607
Fig. 3. Percentage of generated results from each step.
Sustainability. The maintenance is ensured through the CLEOPATRA9 project till 2022. After that, the maintenance of the resource will be handled by the question and answering team of the Smart Data Analytics (SDA)10 research group at the University of Bonn and at Fraunhofer IAIS11 .
5
Experiments
To assure the quality of the dataset and the advantage of having multiple paraphrased responses, we perform experiments and provide baseline models, which researchers can use as a reference point for future research. 5.1
Experimental Setup
Baseline Models For the baselines, we employ three sequence to sequence models. Sequence to sequence is a family of machine learning approaches used for language processing, and used often for natural language generation tasks. The first model consists of an RNN [24] based architecture, the second uses a convolutional network [15], while the third employs a transformer network [39]. Evaluation Metrics BLEU (Bilingual Evaluation Understudy). BLEU score introduced by [28] is so far the most popularly used machine translation metric to evaluate the quality of the model generated text compared to human translation. It aims to count the n-gram overlaps in the reference by taking the maximum count of 9 10 11
http://cleopatra-project.eu/. https://sda.tech/. https://www.iais.fraunhofer.de/.
608
E. Kacupaj et al.
each n-gram, and it clips the count of the n-grams in the candidate translation to the maximum count in the reference. Essentially, BLEU is a modified version of precision to compare a candidate with a reference. However, candidates with a shorter length than the reference tend to give a higher score, while the modified n-gram precision already penalizes longer candidates. Brevity penalty (BP) was introduced to rectify this issue and defined as: 1, c≥r (1) BP = r exp(1 − c ), c < r Where it gets the value of 1 if the candidate length c is larger or equal to the reference length r. Otherwise, is set to exp(1 − r/c). Finally, a set of positive weights {w1 , ..., wN } is determined to compute the geometric mean of the modified n-gram precision. The BLEU score is calculated by: BLEU = BP · exp(
N
wn log(Pn )),
(2)
n=1
where N is the number of different n-grams. In our experiments, we employ N = 4 (which is a default value) and uniform weights wn = 1/N . METEOR (Metric for Evaluation of Translation with Explicit ORdering). METEOR score, introduced by [2], is a metric for the evaluation of machine-translation output. METEOR is based on the harmonic mean of unigram precision and recall, with recall weighted higher than precision. BLEU score suffers from the issue that the BP value uses lengths that are averaged over the entire corpus level, leading to having individual sentences a hit. In contrast, METEOR modifies the precision at sentence or segment level, replacing them with a weighted F-score based on mapping uni-grams and a penalty function that solves the existing problem. Similar to BLEU, METEOR score can be in the range of 0.0 and 1.0, with 1.0 being the best score. Formally we define it as: P ·R , Fmean = α · P + (1 − α) · R β ch (3) P en = γ · , m M ET EOR = (1 − P en) · Fmean where P and R are the uni-gram precision and recall respectively, and are used to compute the parametrized harmonic mean Fmean . P en is the penalty value and is calculated using the counts of chunks ch and the matches m. α, β and γ are free parameters used to calculate the final score. For our experiments we employ the common values of α = 0.9, β = 3.0 and γ = 0.5.
ParaQA
609
Table 4. BLEU score experiment results.
Model
Input
One response Two responses Multiple paraphrased
RNN [24]
Question 15.43 SPARQL 20.1
18.8 21.33
22.4 26.3
Transformer [39]
Question 18.3 SPARQL 23.1
21.2 24.7
23.6 28.0
25.1 28.4
25.9 31.8
Convolutional [15] Question 21.3 SPARQL 26.02
Training and Configurations The experiments are performed to test how easy it is for a standard sequence to sequence model to generate the verbalized response using as input only the question or the SPARQL query. Inspired by [20], during our experiments, we prefer to hide the query answer from the responses by replacing it with a general answer token. In this way, we simplify the model task to predict only the query answer’s position in the final verbalized response. Furthermore, we perform experiments with three different dataset settings. We intend to illustrate the advantage of having multiple paraphrased responses compared to one or even two. Therefore, we run individual experiments by using one response, two responses, and finally, multiple paraphrased responses per question. To conduct the experiments for the last two settings, we forward the responses associated with their question into our model. We calculate the scores for each generated response by comparing them with all the existing references. For the sake of simplicity, and as done by [16], the final score is the maximum value achieved for each generated response. For fair comparison across the models, we employ similar hyperparameters for all. We utilize an embeddings dimension of 512, and all models consist of 2 layers. We apply dropout with probability 0.1. We use a batch size of 128, and we train for 50 epochs. Across all experiments, we use Adam optimizer and crossentropy as a loss function. To facilitate reproducibility and reuse, our baseline implementations and results are publicly available12 . 5.2
Results
Table 4 and Table 5 illustrate the experiment results for BLEU and METEOR scores, respectively. For both metrics, the convolutional model performs the best. It outperforms the RNN and transformer models in different inputs and responses. Here, it is more interesting to notice that all models perform better with multiple paraphrased answers than one or two responses. At the same time, the scores with two answers are better than those with a single response. Hence, we can assume that the more paraphrased responses we have, the better the 12
https://github.com/barshana-banerjee/ParaQA Experiments.
610
E. Kacupaj et al. Table 5. METEOR score experiment results.
Model
Input
One response Two responses Multiple paraphrased
RNN [24]
Question 53.1 SPARQL 57.0
56.2 59.3
58.4 61.8
Transformer [39]
Question 56.8 SPARQL 60.1
58.8 63.0
59.6 63.7
Convolutional [15] Question 57.5 SPARQL 64.3
58.4 65.1
60.8 65.8
model performance. Concerning the experiment inputs (Question, SPARQL), as indicated by both metrics, we obtain improved results with SPARQL on all models and responses. As expected, this is due to the constant input pattern templates that the SPARQL queries have. While with questions, we end up having a different reworded version for the same template. We expect the research community to use these models as baselines to develop more advanced approaches targeting either single-turn conversations for QA or answer verbalization.
6
Reusability and Impact
ParaQA dataset can fit in different research areas. Undoubtedly, the most suitable one is in the single-turn conversational question answering over KGs for supporting a more expressive QA experience. The dataset offers the opportunity to build end-to-end machine learning frameworks to handle both tasks of query construction and natural language response generation. Simultaneously, the dataset remains useful for any QA sub-task, such as entity/relation recognition, linking, and disambiguation. Besides the QA research area, the dataset is also suitable for Natural Language Generation (NLG) tasks. As we accomplish in our experiments, using as input the question or the query, the NLG task will generate the best possible response. We also find ParaQA suitable for the NLP area of paraphrasing. Since we provide more than one paraphrased example for each answer, researchers can experiment with the dataset for building paraphrasing systems for short texts. Furthermore, our dataset can also be used for the research involving SPARQL verbalization, which has been a long-studied topic in the Semantic Web community [13,26,27].
7
Conclusion and Future Work
We introduce ParaQA – the first single-turn conversational question answering dataset with multiple paraphrased responses. Alongside the dataset, we provide a semi-automated framework for generating various paraphrase responses using back-translation techniques. Finally, we also share a set of evaluation baselines
ParaQA
611
and illustrate the advantage of multiple paraphrased answers through commonly used metrics such as BLEU and METEOR. The dataset offers a worthwhile contribution to the community, providing the foundation for numerous research lines in the single-turn conversational QA domain and others. As part of future work, we look to work on improving and expanding ParaQA. For instance, supporting multi-turn conversations together with paraphrased questions is also in our future work scope. Acknowledgments. The project leading to this publication has received funding from the European Union’s Horizon 2020 research and innovation program under the Marie Sklodowska-Curie grant agreement No. 812997 (Cleopatra).
References 1. Abujabal, A., Roy, R.S., Yahya, M., Weikum, G.: Comqa: a community-sourced dataset for complex factoid question answering with paraphrase clusters. In: NAACL (Long and Short Papers), pp. 307–317 (2019) 2. Banerjee, S., Lavie, A.: METEOR: An automatic metric for MT evaluation with improved correlation with human judgments. In: Proceedings of the ACL Workshop on Intrinsic and Extrinsic Evaluation Measures for Machine Translation and/or Summarization, pp. 65–72. Association for Computational Linguistics (2005) 3. Bao, J., Duan, N., Yan, Z., Zhou, M., Zhao, T.: Constraint-based question answering with knowledge graph. In: COLING, pp. 2503–2514 (2016) 4. Berant, J., Chou, A., Frostig, R., Liang, P.: Semantic parsing on freebase from question-answer pairs. In: EMNLP, pp. 1533–1544 (2013) 5. Bollacker, K., Evans, C., Paritosh, P., Sturge, T., Taylor, J.: Freebase: A collaboratively created graph database for structuring human knowledge. In: SIGMOD, pp. 1247–1250. ACM (2008) 6. Bordes, A., Usunier, N., Chopra, S., Weston, J.: Large-scale simple question answering with memory networks. arXiv preprint arXiv:1506.02075 (2015) 7. Boussaha, B.E.A., Hernandez, N., Jacquin, C., Morin, E.: Deep retrieval-based dialogue systems: A short review. arXiv preprint arXiv:1907.12878 (2019) 8. Cai, Q., Yates, A.: Large-scale semantic parsing via schema matching and lexicon extension. In: ACL (2013) 9. Christmann, P., Saha Roy, R., Abujabal, A., Singh, J., Weikum, G.: Look before you hop: Conversational question answering over knowledge graphs using judicious context expansion. In: CIKM, pp. 729–738 (2019) 10. Dubey, M., Banerjee, D., Abdelkawi, A., Lehmann, J.: LC-QuAD 2.0: a large dataset for complex question answering over Wikidata and DBpedia. In: Ghidini, C., et al. (eds.) ISWC 2019, Part II. LNCS, vol. 11779, pp. 69–78. Springer, Cham (2019). https://doi.org/10.1007/978-3-030-30796-7 5 11. Edunov, S., Ott, M., Auli, M., Grangier, D.: Understanding back-translation at scale. In: ACL (2018) 12. Egonmwan, E., Chali, Y.: Transformer and seq2seq model for paraphrase generation. In: Proceedings of the 3rd Workshop on Neural Generation and Translation, pp. 249–255. ACL, Hong Kong (Nov 2019) 13. Ell, B., Harth, A., Simperl, E.: SPARQL query verbalization for explaining semantic search engine queries. In: Presutti, V., d’Amato, C., Gandon, F., d’Aquin, M., Staab, S., Tordai, A. (eds.) ESWC 2014. LNCS, vol. 8465, pp. 426–441. Springer, Cham (2014). https://doi.org/10.1007/978-3-319-07443-6 29
612
E. Kacupaj et al.
14. Federmann, C., Elachqar, O., Quirk, C.: Multilingual whispers: generating paraphrases with translation. In: Proceedings of the 5th Workshop on Noisy UserGenerated Text (W-NUT 2019), pp. 17–26. ACL (2019) 15. Gehring, J., Auli, M., Grangier, D., Yarats, D., Dauphin, Y.N.: Convolutional Sequence to Sequence Learning. arXiv e-prints arXiv:1705.03122 (May 2017) 16. Gupta, P., Mehri, S., Zhao, T., Pavel, A., Eskenazi, M., Bigham, J.: Investigating evaluation of open-domain dialogue systems with human generated multiple references. In: SIGdial, pp. 379–391. ACL (2019) 17. Hasan, S.A., et al.: Neural clinical paraphrase generation with attention. In: Clinical Natural Language Processing Workshop (ClinicalNLP), pp. 42–53 (Dec 2016) 18. Honnibal, M., Montani, I.: spaCy 2: Natural language understanding with Bloom embeddings, convolutional neural networks and incremental parsing (2017) 19. Huang, M., Zhu, X., Gao, J.: Challenges in building intelligent open-domain dialog systems. ACM Trans. Inf. Syst. (TOIS) 38(3), 1–32 (2020) 20. Kacupaj, E., Zafar, H., Lehmann, J., Maleshkova, M.: VQuAnDa: verbalization question answering dataset. In: Harth, A., et al. (eds.) ESWC 2020. LNCS, vol. 12123, pp. 531–547. Springer, Cham (2020). https://doi.org/10.1007/978-3-03049461-2 31 21. Lehmann, J., et al.: Dbpedia - a large-scale, multilingual knowledge base extracted from Wikipedia. Semant. Web 6, 167–195 (2015) 22. Liu, K., Feng, Y.: Deep learning in question answering. In: Deng, L., Liu, Y. (eds.) Deep Learning in Natural Language Processing, pp. 185–217. Springer, Singapore (2018). https://doi.org/10.1007/978-981-10-5209-5 7 23. Lowe, R., Pow, N., Serban, I., Pineau, J.: The Ubuntu dialogue corpus: a large dataset for research in unstructured multi-turn dialogue systems. In: SigDial, pp. 285–294. Association for Computational Linguistics (2015) 24. Luong, M.T., Pham, H., Manning, C.D.: Effective Approaches to Attention-based Neural Machine Translation. arXiv e-prints arXiv:1508.04025 (Aug 2015) 25. McKeown, K.R.: Paraphrasing questions using given and new information. Am. J. Comput. Linguist. 9(1), 1–10 (1983) 26. Ngonga Ngomo, A.C., B¨ uhmann, L., Unger, C., Lehmann, J., Gerber, D.: Sorry, i don’t speak SPARQL: translating SPARQL queries into natural language. In: Proceedings of the 22nd International Conference on World Wide Web, pp. 977– 988 (2013) 27. Ngonga Ngomo, A.C., B¨ uhmann, L., Unger, C., Lehmann, J., Gerber, D.: SPARQL2NL: verbalizing SPARQL queries. In: Proceedings of the 22nd International Conference on World Wide Web, pp. 329–332. ACM (2013) 28. Papineni, K., Roukos, S., Ward, T., Zhu, W.J.: Bleu: a method for automatic evaluation of machine translation. In: Proceedings of the 40th Annual Meeting of the Association for Computational Linguistics (2002) 29. Prakash, A., et al.: Neural paraphrase generation with stacked residual LSTM networks. In: COLING (Dec 2016) 30. Quirk, C., Brockett, C., Dolan, W.: Monolingual machine translation for paraphrase generation. In: Proceedings of the 2004 Conference on Empirical Methods in Natural Language Processing, pp. 142–149. Association for Computational Linguistics (Jul 2004) 31. Saha, A., Pahuja, V., Khapra, M.M., Sankaranarayanan, K., Chandar, S.: Complex sequential question answering: Towards learning to converse over linked question answer pairs with a knowledge graph. In: Thirty-Second AAAI Conference (2018) 32. Serban, I.V., et al.: Generating factoid questions with recurrent neural networks: the 30 m factoid question-answer corpus. arXiv preprint arXiv:1603.06807 (2016)
ParaQA
613
33. Shen, T., et al.: Multi-task learning for conversational question answering over a large-scale knowledge base. In: Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing (EMNLP-IJCNLP), pp. 2442–2451. Association for Computational Linguistics (2019) 34. Singh, K., et al.: Why reinvent the wheel: let’s build question answering systems together. In: Proceedings of the 2018 World Wide Web Conference, pp. 1247–1256 (2018) 35. Su, Y., et al.: On generating characteristic-rich question sets for QA evaluation. In: Proceedings of the 2016 Conference on Empirical Methods in Natural Language Processing (2016) 36. Suchanek, F.M., Kasneci, G., Weikum, G.: Yago: a core of semantic knowledge. In: Proceedings of the 16th International Conference on World Wide Web, pp. 697–706 (2007) 37. Talmor, A., Berant, J.: The web as a knowledge-base for answering complex questions. arXiv preprint arXiv:1803.06643 (2018) 38. Trivedi, P., Maheshwari, G., Dubey, M., Lehmann, J.: LC-QuAD: a corpus for complex question answering over knowledge graphs. In: d’Amato, C., et al. (eds.) ISWC 2017, Part II. LNCS, vol. 10588, pp. 210–218. Springer, Cham (2017). https://doi. org/10.1007/978-3-319-68204-4 22 39. Vaswani, A., et al.: Attention is all you need. In: Advances in Neural Information Processing Systems 30: Annual Conference on Neural Information Processing Systems, pp. 5998–6008 (2017) 40. Vrandeˇci´c, D., Kr¨ otzsch, M.: Wikidata: a free collaborative knowledgebase. Commun. ACM 57(10), 78–85 (2014) 41. Wubben, S., van den Bosch, A., Krahmer, E.: Paraphrase generation as monolingual translation: data and evaluation. In: Proceedings of the 6th International Natural Language Generation Conference (2010) 42. Yih, W.T., Richardson, M., Meek, C., Chang, M.W., Suh, J.: The value of semantic parse labeling for knowledge base question answering. In: Proceedings of the 54th Annual Meeting of the Association for Computational Linguistics (2016) 43. Zamanirad, S., Benatallah, B., Rodriguez, C., Yaghoubzadehfard, M., Bouguelia, S., Brabra, H.: State machine based human-bot conversation model and services. In: Dustdar, S., Yu, E., Salinesi, C., Rieu, D., Pant, V. (eds.) CAiSE 2020. LNCS, vol. 12127, pp. 199–214. Springer, Cham (2020). https://doi.org/10.1007/978-3030-49435-3 13
kgbench: A Collection of Knowledge Graph Datasets for Evaluating Relational and Multimodal Machine Learning Peter Bloem(B) , Xander Wilcke , Lucas van Berkel , and Victor de Boer Informatics Institute, Vrije Universiteit Amsterdam, Amsterdam, The Netherlands {p.bloem,w.x.wilcke,v.de.boer}@vu.nl, [email protected]
Abstract. Graph neural networks and other machine learning models offer a promising direction for machine learning on relational and multimodal data. Until now, however, progress in this area is difficult to gauge. This is primarily due to a limited number of datasets with (a) a high enough number of labeled nodes in the test set for precise measurement of performance, and (b) a rich enough variety of multimodal information to learn from. We introduce a set of new benchmark tasks for node classification on RDF-encoded knowledge graphs. We focus primarily on node classification, since this setting cannot be solved purely by node embedding models. For each dataset, we provide test and validation sets of at least 1 000 instances, with some over 10 000. Each task can be performed in a purely relational manner, or with multimodal information. All datasets are packaged in a CSV format that is easily consumable in any machine learning environment, together with the original source data in RDF and pre-processing code for full provenance. We provide code for loading the data into numpy and pytorch. We compute performance for several baseline models.
Keywords: Knowledge graphs models · Multimodal learning
1
· Machine learning · Message passing
Introduction
The combination of knowledge graphs and machine learning is a promising direction of research. In particular, the class of machine learning models known as message passing models offer an interesting set of abilities [1,35]. These models operate by propagating information along the structure of the graph and are trained end-to-end, meaning all information in the graph can potentially be used if it benefits the task. Even the contents of the literals may be used by attaching encoder networks to learn how literals should be read, leading to an end-to-end model for multimodal learning on knowledge graphs. The message P. Bloem, X. Wilcke and L. van Berkel—Contributed equally to this paper. c Springer Nature Switzerland AG 2021 R. Verborgh et al. (Eds.): ESWC 2021, LNCS 12731, pp. 614–630, 2021. https://doi.org/10.1007/978-3-030-77385-4_37
kgbench: Datasets for Relational Learning
615
passing framework is also a promising direction for interpretable machine learning, as the computation of the model can be directly related to the relational structure of the data [9]. Unfortunately, the progress of message passing models and related machine learning approaches has been difficult to gauge due to the lack of high quality datasets. Machine learning on knowledge graphs is commonly evaluated with two abstract tasks: link prediction and node labeling. In the latter, the model is given the whole graph during training, together with labels for a subset of its nodes. The task is to label a set of withheld nodes with a target label: a class for node classification or a number for node regression. While link prediction is probably more popular in recent literature, node labeling is more promising for developing message passing models. In link prediction, it is not clear whether message passing models offer an advantage over embedding models on currently popular benchmarks, without a considerable increase in computational requirements. In node labeling, however, the task cannot be solved from node embeddings alone. In some way, the deeper structure of the graph needs to be taken into account, making it a better testing ground for message-passing algorithms such as R-GCNs [28] and R-GATs [6]. In this work, we specifically focus on knowledge graphs that are built on top of the Resource Description Framework (RDF). The most common datasets used in node classification on such knowledge graphs are the AIFB, MUTAG, BGS and AM datasets, which were first collected and published for this purpose in [22]. Their details are given in Table 1. These datasets are well suited to message passing methods since they are relatively small, allowing a message passing model to be trained full-batch so that we can gauge the performance of the model independent of the influence of minibatching schemes. However, this small size of the graphs also means a small number of labeled instances, and, in particular, a small test set, sometimes with less than 50 instances. While limited training data is often a cause for concern in machine learning, limited test data is usually the greater evil. With limited training data, we may have a model that fails to perform well, but with limited test data we cannot even tell how well our model is performing. In statistical terms: a performance metric like accuracy is an estimate of a true value, the expected accuracy under the data distribution, based on a sample from that distribution; the test set. The larger that sample, the more accurate our estimate, and the smaller our Table 1. The currently most commonly used benchmark datasets for node classification. Dataset
AIFB MUTAG BGS*
AM*
Entities
8 285
87 688
246 728
70
122
Relations 45
23 644 23
Edges
29 043 74 227
230 698 875 946
Labeled
176
340
146
1 000
Classes
4
2
2
11
616
P. Bloem et al.
Fig. 1. The size of a 95% confidence interval around an estimate of accuracy for a two-class problem, with test sets of 100, 1 000 and 10 000 instances. Note that 10 000 instances are required before we can tell apart all estimates that differ by 0.01.
uncertainty about that estimate. Figure 1 shows the size of the 95% confidence intervals for different test set sizes on a balanced binary classification problem. We see that only at 10 000 instances do we have sufficient certainty to say that a model with a measured accuracy of 0.94 is most likely better than one with a measured accuracy of 0.93. The test set sizes in Table 1 do not allow for anything but the most rudimentary discrimination. Additionally, while these datasets provide some multimodal data in the form of literals, these literals are usually not annotated with datatypes, whereas their modalities remain restricted to simple strings containing natural language, or structured information like numerical values and dates. Richer multimodal information like images, audio, or even video would present a more exciting challenge for the possibility of integrating such data in a single end-to-end machine learning model. To overcome these problems, we introduce kgbench: a collection of evaluation datasets for node labeling on knowledge graphs. Each dataset comes with a test set of between 2 000 and 20 000 labeled nodes, allowing for precise estimates of performance. Each dataset can be used in two different ways. In the relational setting, each node is treated as an atomic object, with literals considered equal if their lexical content is equal. This mode can be used to evaluate relational machine learning models, as in [6,23,28]. In the multimodal setting, the content of literal nodes is taken into account as well, as described in [34,35]. In addition, each dataset can also be used to evaluate link prediction models with by ignoring the node labels (see Sect. 2.3 for details). The datasets are offered as RDF, with each dataset packaged both in NTriples and in HDT [10] format. Additionally, since loading RDF into machine learning environments can be non-trivial, we offer pre-processed versions of each dataset, which contain integer indices for all nodes and relations in the graph. These are stored as a set of CSV files, to ensure that they can be directly read by a large number of machine learning libraries. We also provide explicit dataloading code for Numpy and Pytorch, as well as scripts to converts any RDF-encoded knowledge graph to this format.
kgbench: Datasets for Relational Learning
617
All data and code is hosted on Github.1 To ensure long term availability and to provide a permanent identifier, snapshots are also hosted on Zenodo.2 Each dataset is licensed under the most permissive conditions allowed by the licenses on the source datasets. 1.1
Related Work
Similar efforts to ours include: CoDEx [25], a link prediction benchmark including multilingual literals, and RichPedia [32], a large-scale multimodal knowledge graph with no specific machine learning task attached. Other link prediction research has included new benchmark data [15,30]. Our datasets are, to the best of our knowledge, the first node labelling benchmarks that focus on large test set size and multimodal learning. In [22], node labeling tasks on large knowledge graphs are included, but the number of total instances in the dataset never exceeds 2 000, and canonical snapshots of the knowledge graphs are not provided. The field of knowledge graph modeling by machine learning methods can be divided into two main camps: pure embedding methods, which learn node embeddings directly, and message passing approaches, which learn from the graph structure more explicitly. For pure embedding methods, [24] serves as a good overview of the state of the art. Message passing methods are popular [1], but in the specific domain of knowledge graphs there has been less progress, with R-GCNs [28] and R-GATs [6] as the main approaches. Other approaches include kernel methods [7] and feature-extraction approaches [23].
2
Method
In this section we detail the main design choices made in constructing the tasks and datasets in kgbench. Our data model in all cases follows RDF. That is, a knowledge graph is defined as a tuple G = (V, R, E), with a finite set of nodes V , a finite set of relations R and a finite set of edges (also known as triples) E ⊆ V × R × V . The nodes in V can be atomic entities,3 or literals, defined by a string which is optionally tagged with a datatype annotation (an IRI expressing the type of data) or a language tag. 2.1
Desiderata
A good machine learning benchmark must satisfy a large number of constraints. We have focused primarily on the following. Large test sets. A large test set is essential for accurate performance estimates. This is our primary concern. 1 2 3
https://github.com/pbloem/kgbench. Details, including DOIs, under the following references amplus [3], dmgfull and dmg777k [36], dblp [4], mdgenre and mdgender [2]. Entities may be resources, identified by an IRI, or blank nodes.
618
P. Bloem et al.
Manageable graph size. A small benchmark dataset allows for quick evaluation of hypotheses and quick iteration of model designs, and keeps machine learning research accessible. Small training sets. Keeping the number of training instances relatively low has several benefits: it leaves more instances for the validation and test sets, and it makes the task more difficult. If the instances are more sparsely labeled, models are forced to use the graph structure to generalize. It is common practice, once hyperparameter tuning is finished, to combine the training and validation sets into a larger training set for the final run. Normally this conveys only a very small extra advantage. In our case, adding the validation data often has a very large effect on how easy the task becomes, and which structure can be used to solve. For this reason, in our tasks, practitioners should only ever train on the training data, no matter what set is being evaluated on. Multimodal literals. Where possible we offer literals of multiple modalities. We annotate existing strings with datatypes and language tags, and add images and spatial geometries. These are placed into the graph as literals rather than as hyperlinks, making the dataset self-contained. 2.2
Data Splitting and Layout
Each dataset provides a canonical training/validation/test split. We also split off a meta-test set if the data allows. This is an additional set of withheld data. It serves as an additional test set for review studies over multiple already-published models. This provides the possibility to test for overfitting on the test set if the dataset becomes popular. Any practitioner introducing a single new model or approach, should ignore the meta-test set.4 Each dataset is provided as an RDF graph, with the target labels kept in separate files. We emphatically choose not to include the target labels in the dataset, as this would then require practitioners to manually remove them prior to training, which creates a considerable risk of data leakage. Preprocessing. The most common preprocessing step for relational machine learning is to map all relations and nodes to integer indices. We have preprocessed all datasets in this manner and provided them as a set of CSV files (in addition to the original RDF). While a collection of CSV files may not be in keeping with the spirit of the Semantic Web, this format greatly facilitates reading the data into any data science or machine learning software, without the need to parse RDF or load the data into a triple store. This format also allows practitoners to choose between the relational and multimodal setting in a simple manner. If only the integer indices are read, then the data is viewed purely from a relational setting. The mappings from the 4
It is common practice to not publish the meta-test set to ensure that it is not used by practitioners until it is necessary. In our case this makes little sense, since the meta-test set could easily be derived from the available raw data manually.
kgbench: Datasets for Relational Learning 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
619
@prefix : . @prefix rdfs: . @prefix xsd: . :base64Image a rdfs:Datatype ; rdfs:subClassOf xsd:base64Binary ; rdfs:label "Base64-encoded image"@en ; rdfs:comment "An image encoded as a base64 string"@en . :base64Video a rdfs:Datatype ; rdfs:subClassOf xsd:base64Binary ; rdfs:label "Base64-encoded video"@en ; rdfs:comment "A video encoded as a base64 string"@en . :base64Audio a rdfs:Datatype ; rdfs:subClassOf xsd:base64Binary ; rdfs:label "Base64-encoded audio"@en ; rdfs:comment "An audio sequence encoded as a base64 string"@en .
Listing 1.1. A small ontology (kgbench.info/dt.ttl) for base64-encoded image, audio, and video.
integer indices to the string representations of the nodes provide the multimodal layer on top of the relational setting. 2.3
Link Prediction
Our focus is node labeling, but since link prediction is an unsupervised task, each of our datasets can also be used in link prediction, both for purely relational settings and for multimodal settings. In such cases, we suggest that the following guidelines should be followed: – The triples should be shuffled before splitting. The validation, test, and metatest set should each contain 20 000 triples, with the remainder used for training. We include such a split for every dataset. – In contrast to the node labeling setting, we do not enforce limited training data. The final training may be performed on the combined training and validation sets, and tested on the test set. – Practitioners should state that the data is being adapted for link prediction, and whether the dataset is being used in relational or in multimodal setting. 2.4
Expressing Binary Large Objects
No convention currently exists for encoding images, videos, or audio in literals. A convention in the realm of relational databases is to store complex datatypes as Binary Large OBjects (BLOBs). Here, we chose to adopt this convention by encoding binary data in base64 encoded string literals. The conversion to and from binary data is well supported by many popular programming languages. To express that a certain string literal encodes a complex type it should be annotated as such using a suitable datatype. The straightforward choice for this datatype would be xsd:base64Binary. However, this does little to convey the
620
P. Bloem et al.
Table 2. Statistics for all datasets. We consider a dataset “GPU friendly” if the RGCN baseline can be trained on it with under 12 GB of memory and “CPU-friendly” if this can be done with under 64 GB. mdgender is not meant for evaluation (see Sect. 5). Dataset
amplus
Triples
2 521 046 1 850 451 777 124
21 985 048 1 252 247 1 203 789
Relations
33
60
68
154
154
Nodes
1 153 679 842 550
341 270
4 470 778
349 344
349 347
Entities 1 026 162 262 494
148 127
4 231 513
191 135
191 138
Literals Density Degree
62
dmg777k dblp
mdgenre
mdgender*
127 517
580 056
192 143
239 265
158 209
158 209
2·10−6
3·10−6
7·10−6
1·10−6
1·10−5
1·10−5
Avg
4.37
4.47
4.53
9.83
7.17
6.89
Min
1
1
1
1
1
1
Max
154 828
121 217
65 576
3 364 084
57 363
57 363
8
14
5
2
12
9
Classes Labeled
dmgfull
Total
73 423
63 565
8 399
86 535
8 863
57 323
Train
13 423
23 566
5 394
26 535
3 846
27 308 10 005
Valid
20 000
10 001
1 001
20 000
1 006
Test
20 000
20 001
2 001
20 000
3 005
10 003
Meta
20 000
10 001
20 000
1 006
10 007
Source
[5]
see text
GPU friendly
CPU friendly
Numerical
8 418
64 184
8 891
1 387
1 387
Temporal
6 676
463
290
37 442
37 442
[21, 29, 31] [12, 31]
[12, 31]
Datatypesa
Textual
56 202
340 396
117 062
Visual
56 130
58 791
46 061
239 265
51 852
51 852
67 528
67 528
Spatial 116 220 20 837 Numerical includes all subsets of real numbers, as well as booleans, whereas date, years, and other similar types are listed under temporal information. Textual includes the set of strings (possibly without datatype, its subsets, and raw URIs (e.g. links). Images and geometries are listed under visual and spatial information, respectively a
type of information which it encodes, which makes it difficult to build machine learning models that distinguish between these types. To accommodate this distinction, we instead introduce a small collection of datatype classes to annotate binary-encoded strings in accordance with their information type (Listing 1.1).5
3
Datasets
Table 2 lists the datasets contained in kgbench and their basic statistics, as well as an overview of the distribution of modalities per dataset. All datasets were created by combining publicly available data sources, with no manual annotation. Enrichment was limited to combining data sources, and annotating literals. 5
The same may be achieved with additional triples. While this would remove the need for new datatypes, it would render the isolated literal meaningless. This contrasts with most other datatypes, which still convey their meaning in isolation.
kgbench: Datasets for Relational Learning
621
Table 3. The class mapping for the amplus data. The original categories are translated from their original Dutch names. Original
Class
Furniture, Glass, Textile, Ceramics, Sculpture, Arts & crafts
Decorative art
Frequency 25 782
Prints
Prints
22 048
Coins & tokens, Archaeological artifacts, Measures & weights Historical artifacts
7 558
Drawings
Drawings
5 455 4 333
Non-noble metals art, Noble metal art
Metallic art
Books, Documents
Books & documents 4 012
Paintings
Paintings
2 672
Photographs
Photographs
1 563
3.1
The Amsterdam Museum Dataset (amplus)
The Amsterdam Museum is dedicated to the history of Amsterdam. Its catalog has been translated to linked open data [5]. The AM dataset, as described in Table 1, is already established as a benchmark for node classification: the task is to predict the type of a given collection item. In the original version, the number of labeled instances is arbitrarily limited to 1000, resulting in small test set sizes. We return to the original data and make the following changes: we collect all collection items as instances, annotate a large number of literals with the correct datatype, and insert images as base64 encoded literals. We also include only a subset of the relations of the original data to make the dataset both small and challenging. Finally, we remap the categories to a smaller set of classes to create a more balanced class distribution. The mapping is given in Table 3. The amplus data is provided under a Creative Commons CC-BY license. 3.2
The Dutch Monument Graph (dmgfull, dmg777k)
Like amplus, the Dutch Monument Graph (DMG) is a dataset from the Digital Humanities. Encompassing knowledge from several organizations, the DMG contains information about 63 566 registered monuments in the Netherlands. Engineered with the goal of creating a highly multimodal dataset, the DMG contains information in six modalities, five of which are encoded as literals. This includes the often common numerical, temporal, and textual information, but also visual information in the form of images, and, more uniquely, several different kinds of spatial information. Taken all together, these modalities provide the monuments with a diverse multimodal context which includes, amongst other things, a short title, a longer description, a construction date, the city and municipality it lies in, several images from different directions, a set of geo-referenced coordinates, and a polygon describing its footprint.
622
P. Bloem et al.
Five different knowledge graphs from four different organizations,6 were combined to form the DMG. The information from these organizations was combined using entity resolution based on string comparison, matching municipality and city names, as well as multi-part addresses. Once merged, the information was cleaned and provided with accurate class and datatype declarations where missing. The 777k -variant is a subset encompassing 8 399 monuments created by sampling monuments from the top-5 monument classes that have no missing values. Both datasets are published under the CC-BY license. 3.3
The Movie Dataset (mdgenre, mdgender)
The Movie datasets are subsets of Wikidata [31] in the movie domain. We select any movies that are recorded as ever having won or been nominated for an award. Every person affiliated with any of these movies is also selected if the relation between the movie and the person is in a whitelist. This whitelist consists of relations that satisfy the conditions that 1) every relation needs to have a Wikidata prefix, and 2) the relations do not direct to an identifier tag outside of Wikidata. Every triple that contains a movie or individual on their respective lists and a relation on the whitelist is extracted. This creates a graph that is centred around movie-related data with a longest path of 4 hops. The main objective of this dataset is to predict the genre of the movies. Movies can have multiple genres, which is not practical when creating a single-label classification problem. Therefore, movies are assigned a genre based on a solution to the Set Cover Problem, which was derived using [38]. Each movie is assigned a single genre of which it already was part. This simplifies the multi-label classification objective to a multiclass classification objective. Additionally, the Movie Datasets also contain a gender objective, which we include as a sanity check as the objective is considered easier compared to the genre objective (see Sect. 5 for a discussion). As the classification in the Wikidata knowledge base is already suitable for multiclass classification, no further constraining as with the genres is necessary. We download thumbnail images from URLs in Wikidata and include these as base64-encoded string literals. We also include thumbnails of images in the Internet Movie Database (IMDb) by matching the IMDb-identifier in Wikidata. The relational data in these datasets is taken from Wikidata, and provided under the same CC0/Public domain license that applies to Wikidata. For 40 449 out of the 68 247 images in this dataset, we extracted thumbnails from larger images published by IMDb. The copyright of the original images resides with their producers. We assert no rights on this part of the data for redistribution or use outside non-commercial research settings. The remainder of the thumbnails is taken from the Wikimedia repository, and distributed under the individual license of each image. 6
(1) the Dutch Cultural Heritage Agency, www.cultureelerfgoed.nl, (2) the Dutch Cadastre, Land Registry and Mapping Agency, www.kadaster.nl, (3) Statistics Netherlands, www.cbs.nl, and (4) Geonames, www.geonames.org.
kgbench: Datasets for Relational Learning
3.4
623
The DBLP Dataset (dblp)
The DBLP repository [29] is a large bibliographic database of publications in the domain of computer science. This was converted to RDF under the name L3S DBLP, of which we used the HDT dump7 . To provide a classification task on this data we extracted citation counts from the OpenCitations project [21] using the REST API. We checked all DOIs of papers in the DBLP dump, giving us a set of 86 535 DOIs that are present in both databases. These are our instances. We also extract information from Wikidata about researchers. We use the XML dump of DBLP [29] to extract ORCiDs, which allows us to link 62 774 people to Wikidata. For each person linked, we extract triples from the one-hop neighborhood in Wikidata. We use 24 relations from the DBLP data and 44 relations from Wikidata. Since we are focusing on classification tasks, we turn the prediction of the citation count into two classes: those papers which received one citation, and those which received more (due to the skewed distribution this the closest to a median-split). We have also preserved the original citation counts in the data, so the task can also be treated as a node regression task. This dataset is provided under a CC0/Public domain license.
4
Code and Baselines
In addition to the datasets in their RDF and CSV formats, we also provide scripts to convert any arbitrary RDF-encoded graph to our CSV format. To import these datasets into a machine learning workflow, we further provide a small Python library that loads any dataset that makes use of our CSV format into a object containing Pytorch [20] or Numpy [19] tensors, together with mappings to the string representations of the nodes. This provides both a utility sufficient for the majority of current machine learning practice, and a reference implementation for any setting where such a dataloader does not suffice. In addition to the new datasets of Table 2, the repository also includes legacy datasets aifb and the original Amsterdam Museum data, named am1k here. These are useful for debugging purposes. The dataloader allows the data to be loaded in a single function call. It also provides utility functions for pruning the dataset to a fixed distance around the instance nodes, and for re-ordering the nodes so that the datatypes are ordered together (which may reduce expensive tensor indexing operation in implementing multimodal models). We also provide three baseline models as reference for how to use the data in practice: Features. This model extracts binary graph features about the set of triples incident to the instance node, which are then used by a logistic regression classifier. Over the whole set of training instances, all of the following binary features are considered: (a) whether a particular predicate p is present or 7
Available at https://www.rdfhdt.org/datasets/.
624
P. Bloem et al.
Table 4. Performance of baselines on the datasets in the collection. The R-GCNs could not be trained on dblp in under 64 Gb of memory. Setting
Baseline
amplus dmgfull dmg777k dblp mdgenre
Relational
Features R-GCN
0.72 0.77
0.73 0.71
0.42 0.70
0.72 0.66 0.63
Multimodal MR-GCN 0.86
0.76
0.57
-
0.62
not, (b) whether a particular predicate is present in a specific direction, i.e. outgoing or incoming, and (c) whether a particular predicate, in a particular direction, connects the instance node to a specific node n. For all collected features, the information gain is computed for splitting the training instances on that feature. The k features with the highest information gain are kept and used to train a classifier. R-GCN. The default classification R-GCN model [28]. It contains two R-GCN layers that are fed with a one-hot encoding of the nodes, which is mapped, via a hidden layer, to class probabilities. By default, a hidden size of 16 is used, with a basis decomposition of 40 bases. This baseline is purely relational, and ignores multimodal information. MR-GCN. We provide a stripped-down version of the MR-GCN model [34]. Unlike the original, this model does not train its feature extractors end-to-end, which means that no backpropagation is needed beyond the R-GCN layer, saving memory. The literal features are extracted by pretrained models: a Mobilenet-v2 [26] for the images and DistilBERT [27] for literals. After feature extraction, the features are scaled down to a uniform input dimension d by principal component analysis. 4.1
Baseline Performance
Table 4 shows the accuracies of the three baseline models on the datasets in kgbench. The R-GCN models were trained for 50 epochs with default hyperparameters. That is, a two-layer model, with ReLU activation and a hidden size of 16. Training was done full-batch for 50 epochs with the Adam optimizer with default parameters and a learning rate of 0.01. A 0.5·10−3 L2 penalty was applied to the weights of the first layer. The features baseline was run with k = 2 000 and a logistic regression classifier with no regularization. These numbers should be taken as broad baselines for how default models perform on these datasets, and not as the last word of the performance of, for instance, the R-GCN. It may well be possible to achieve better performance with more extensive hyperparameter tuning, a different architecture, or more training epochs. In particular, the MR-GCN used here is likely considerably less performant than the fully end-to-end version.
kgbench: Datasets for Relational Learning
5
625
Discussion
While only a small proportion of benchmarks datasets that are published achieve broad community-wide uptake, those that do ultimately have a profound impact on the direction in which technology is developed. A dataset like ImageNet [8] was developed in a time when no models were available that could solve the task, but it is now commonly used to pretrain computer vision models that are widely distributed and used in production systems. Even a dataset like FFHQ [13], which was specifically compiled with diversity and representation in mind has led to pre-trained models that contain bias, which is ultimately exposed in downstream applications [17]. For this reason we consider it wise to discuss both the biases present in the data and the implications of setting certain labels as training targets. 5.1
Bias in Training Data
A common source of discussion in AI Ethics is the bias present in training data, especially where the representation of people is concerned [16]. A case in point are the mdgenre and dblp datasets, which both contain the “Sex or Gender” property of Wikidata.8 In the former, a disproportionate number of the actors in the data are men. While this may be an accurate reflection of a bias in the world,9 it means that actions taken based on the predictions of a production model trained on this data, may end up amplifying the data biases. We have chosen not to de-bias the data for various reasons. First, we can only correct for the biases for which we have attributes (such as sex, gender, race, or religion). Second, even if we resample in this way, the biases may still manifest, for instance in the completeness of the data for men and women. Finally, debiasing the data ourselves, by a fixed strategy removes the possibility of investigating the debiasing method itself. In short, we take it as a given that the data is biased. Since the data was largely retrieved completely as found in the wild, with only crude filtering based on node neighborhoods and relation whitelists, we may assume that these biases are reflective of the biases in real-world data. This may be used to study data bias in knowledge graphs, but any model trained on these datasets should not be put into production without careful consideration. 5.2
Choice of Target Relations
In all cases, our primary reasons for setting a particular target relation are technical. It is challenging to find a set of classes that are well-balanced, offer a large amount of instances, and provide a challenging task. Moreover, in the multimodal setting, a variety of literals with different modalities must be available, all of which can be shown to contribute to the task. 8 9
https://www.wikidata.org/wiki/Property:P21. Even this is not a given. In many cases, the models themselves also amplify the biases present in the data [37].
626
P. Bloem et al.
This narrow range of requirements can lead difficult choices: in our search for suitable targets, we noted that the category “Sex or gender” in Wikidata, satisfied our technical requirements very well. However, training a model to predict this relation is to train (in part) a gender classifier, which is a controversial subject [11]. The following reasons have been posed for why such classifiers would be undesirable: – Both sex and gender are not well captured by binary categories. Even the range of 36 categories offered by Wikidata (of which 8 are present in the Movie data) is unlikely to capture the spectrum of possibilities. – People with gender identities outside the male/female categorization are at risk of oppression or discrimination. An oppressive regime may abuse gender and sex classifiers for large scale detention or prosecution. While there are currently no such systems employed to our knowledge, such practices do already exist in the related cases of race and ethnicity classification [18]. – The possibility of gender classification from external features may falsely imply a strong or causal relationship. Here, a comparable case is [14,33], where a classifier was built to predict sexual orientation. Besides the possibilities for abuse noted previously, such classifiers are often misinterpreted as showing strong causal links, for instance between physical features and the target class. In fact, all that can really be inferred is a weak correlation, which may well be based on incidental features, such as lighting, or personal choices such as clothing and make-up. On the other hand, the inclusion of sex and gender as features in the data is important for the study of algorithmic bias. Simply removing the sex or gender attribute as a target class, but not as a feature of the data, also does not circumvent these issues. In a link prediction setting rather than a node labeling setting, every relation in the data becomes both feature and target. In such settings the two cannot be separated, and the problem remains. Ultimately, we have chosen to include the dataset, with the “Sex or gender” attribute in place. We urge that practitioners use these datasets with care. For the gender-prediction task mdgender itself, we recommend strongly that this dataset be used only as a test case in development,10 and not to report model performance in general settings, unless the task at hand is specifically relevant to the issue of sex or gender bias.
6
Conclusion
In this work, we have introduced a collection of multimodal datasets for the precise evaluation of node classification tasks on RDF-encoded knowledge graphs. 10
The task in its current setup is too easy to serve as a good benchmark (which we have deliberately refrained from fixing). However, it is unique among these datasets in offering a strong guarantee that the images can be used to predict the target label with good accuracy. This property may be useful in debugging models, which can then be evaluated on the other tasks.
kgbench: Datasets for Relational Learning
627
All datasets are available on GitHub and Zenodo in N-Triples and HDT format. Also provided are CSVs with an integer-to-label mapping, which can be loaded into Numpy and Pytorch by using the provided dataloader code. To support images, videos, and audio sequences, we also introduced a modest ontology to express these datatypes as binary-encoded string literals. For all datasets, we demonstrated their performance using several baseline models. 6.1
Limitations
To add extra modalities to our data, we have relied primarily on images. Other modalities are available: for instance Wikidata contains a rich collection of audio clips which provide an additional modality. Even small videos might be suitable. An important consideration in constructing our graphs was to keep the total size of the graph relatively small. This means that the graphs presented here paint a slightly simplified image of real-world knowledge graphs. A model that performs well on these graphs can most likely not be applied directly to knowledge graphs found in the wild, as these will have magnitudes more relations, and relevant information stored more steps away from the instance nodes. 6.2
Outlook
To stimulate adoption of the benchmark, we have aimed to offer a simple and unambiguous way to load the data (including baseline implementations for reference) and to host the data in multiple, redundant places (Zenodo and Github). As the data is used, we will offer a leader board on the Github page to track top performance and collect papers making use of the data. The ultimate test of a benchmark task is whether it can be solved. In cases like speech-to-text, we can use human performance as an upper bound, but in a relational learning setting this is difficult to measure. Our baseline tests show that simple baselines reach low, but above-chance performance, with plenty of room for growth. It is difficult to establish what the performance ceiling is, but we hope that by providing a good number of datasets, we increase the probability that one of them will turn out to contain that particular trade-off between difficulty and simplicity that typifies the most enduring benchmark tasks. Our ultimate hope is that these benchmarks stimulate more principled research towards models that learn end-to-end from relational and multimodal data, and that such models help to bridge the gap between statistical and symbolic forms of knowledge representation. Acknowledgements. We thank Emma Beauxis-Aussalet for illuminating discussions on the broader impact statement. We thank Rein van ’t Veer for invaluable assistance with the geometry modalities in the DMG dataset.
628
P. Bloem et al.
References 1. Battaglia, P.W., et al.: Relational inductive biases, deep learning, and graph networks. arXiv preprint arXiv:1806.01261 (2018) 2. van Berkel, L., Bloem, P., Wilcke, X., de Boer, V.: kgbench: mdgenre and mdgender, December 2020. https://doi.org/10.5281/zenodo.4361795 3. Bloem, P., Wilcke, X., van Berkel, L., de Boer, V.: kgbench: amplus, December 2020. https://doi.org/10.5281/zenodo.4361762 4. Bloem, P., Wilcke, X., van Berkel, L., de Boer, V.: kgbench: dblp, December 2020. https://doi.org/10.5281/zenodo.4361787 5. de Boer, V., et al.: Amsterdam museum linked open data. Semantic Web 4(3), 237–243 (2013) 6. Busbridge, D., Sherburn, D., Cavallo, P., Hammerla, N.Y.: Relational graph attention networks. arXiv preprint arXiv:1904.05811 (2019) 7. De Vries, G.K.D., De Rooij, S., et al.: A fast and simple graph kernel for rdf. DMoLD 1082 (2013) 8. Deng, J., Dong, W., Socher, R., Li, L.J., Li, K., Fei-Fei, L.: Imagenet: a large-scale hierarchical image database. In: 2009 IEEE Conference on Computer Vision and Pattern Recognition, pp. 248–255. IEEE (2009) 9. Feng, Y., Chen, X., Lin, B.Y., Wang, P., Yan, J., Ren, X.: Scalable multihop relational reasoning for knowledge-aware question answering. arXiv preprint arXiv:2005.00646 (2020) 10. Fern´ andez, J.D., Mart´ınez-Prieto, M.A., Guti´errez, C., Polleres, A., Arias, M.: Binary RDF representation for publication and exchange (HDT). J. Web Semantics 19, 22–41 (2013) 11. Hamidi, F., Scheuerman, M.K., Branham, S.M.: Gender recognition or gender reductionism? the social implications of embedded gender recognition systems. In: Proceedings of the 2018 CHI Conference on Human Factors in Computing Systems, pp. 1–13 (2018) 12. IMDB: The Internet Movie Database, accessed October 2020. http://imdb.com 13. Karras, T., Laine, S., Aila, T.: A style-based generator architecture for generative adversarial networks. In: Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 4401–4410 (2019) 14. Levin, S.: New AI can guess whether you’re gay or straight from a photograph. The Guardian (2017). https://www.theguardian.com/technology/2017/sep/07/newartificial-intelligence-can-tell-whether-youre-gay-or-straight-from-a-photograph 15. Liu, Y., Li, H., Garcia-Duran, A., Niepert, M., Onoro-Rubio, D., Rosenblum, D.S.: MMKG: multi-modal knowledge graphs. In: Hitzler, P., et al. (eds.) ESWC 2019. LNCS, vol. 11503, pp. 459–474. Springer, Cham (2019). https://doi.org/10.1007/ 978-3-030-21348-0 30 16. Mehrabi, N., Morstatter, F., Saxena, N., Lerman, K., Galstyan, A.: A survey on bias and fairness in machine learning. arXiv preprint arXiv:1908.09635 (2019) 17. Menon, S., Damian, A., Hu, S., Ravi, N., Rudin, C.: Pulse: self-supervised photo upsampling via latent space exploration of generative models. In: Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 2437–2445 (2020) 18. Mozur, P.: One month, 500,000 face scans: How china is using a.i. to profile a minority. The New York Times (2019). https://www.nytimes.com/2019/04/14/ technology/china-surveillance-artificial-intelligence-racial-profiling.html 19. Oliphant, T.E.: A guide to NumPy, vol. 1. Trelgol Publishing USA (2006)
kgbench: Datasets for Relational Learning
629
20. Paszke, A., et al.: Pytorch: An imperative style, high-performance deep learning library. In: Advances in Neural Information Processing Systems, pp. 8026–8037 (2019) 21. Peroni, S., Shotton, D.: Opencitations, an infrastructure organization for open scholarship. Quant. Sci. Stud. 1(1), 428–444 (2020) 22. Ristoski, P., de Vries, G.K.D., Paulheim, H.: A collection of benchmark datasets for systematic evaluations of machine learning on the semantic web. In: Groth, P., et al. (eds.) ISWC 2016. LNCS, vol. 9982, pp. 186–194. Springer, Cham (2016). https://doi.org/10.1007/978-3-319-46547-0 20 23. Ristoski, P., Paulheim, H.: RDF2Vec: RDF graph embeddings for data mining. In: Groth, P., et al. (eds.) ISWC 2016. LNCS, vol. 9981, pp. 498–514. Springer, Cham (2016). https://doi.org/10.1007/978-3-319-46523-4 30 24. Ruffinelli, D., Broscheit, S., Gemulla, R.: You can teach an old dog new tricks! on training knowledge graph embeddings. In: International Conference on Learning Representations (2019) 25. Safavi, T., Koutra, D.: CoDEx: a comprehensive knowledge graph completion benchmark. In: Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP). pp. 8328–8350. Association for Computational Linguistics, Online, November 2020. https://doi.org/10.18653/v1/2020. emnlp-main.669. https://www.aclweb.org/anthology/2020.emnlp-main.669 26. Sandler, M., Howard, A., Zhu, M., Zhmoginov, A., Chen, L.C.: Mobilenetv 2: inverted residuals and linear bottlenecks. In: Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 4510–4520 (2018) 27. Sanh, V., Debut, L., Chaumond, J., Wolf, T.: Distilbert, a distilled version of bert: smaller, faster, cheaper and lighter. arXiv preprint arXiv:1910.01108 (2019) 28. Schlichtkrull, M., Kipf, T.N., Bloem, P., Berg, R.v.d., Titov, I., Welling, M.: Modeling relational data with graph convolutional networks. arXiv preprint arXiv:1703.06103 (2017) 29. dblp team, T.: dblp computer science bibliography, converted by l3s (2017). http:// downloads.linkeddatafragments.org/hdt/dblp-20170124.hdt 30. Tiwari, A.K., Nadimpalli, S.V.: Learning semantic image attributes using image recognition and knowledge graph embeddings. I.J. Image, Graphics and Signal Processing (2020). https://doi.org/10.5815/ijigsp.2020.05.05 31. Vrandeˇci´c, D., Kr¨ otzsch, M.: Wikidata: a free collaborative knowledgebase. Commun. ACM 57(10), 78–85 (2014) 32. Wang, M., Wang, H., Qi, G., Zheng, Q.: Richpedia: a large-scale, comprehensive multi-modal knowledge graph. Big Data Research 22, 100159 (2020). https://doi. org/10.1016/j.bdr.2020.100159. https://www.sciencedirect.com/science/article/ pii/S2214579620300277 33. Wang, Y., Kosinski, M.: Deep neural networks are more accurate than humans at detecting sexual orientation from facial images. J. Pers. Soc. Psychol. 114(2), 246 (2018) 34. Wilcke, W., Bloem, P., de Boer, V., van t Veer, R., van Harmelen, F.: End-to-end entity classification on multimodal knowledge graphs. arXiv p. arXiv-2003 (2020) 35. Wilcke, W., Bloem, P., De Boer, V.: The knowledge graph as the default data model for learning on heterogeneous knowledge. Data Sci. 1(1–2), 39–57 (2017) 36. Wilcke, X., Bloem, P., van Berkel, L., de Boer, V.: kgbench: dmgfull and dmg777k, December 2020. https://doi.org/10.5281/zenodo.4361779
630
P. Bloem et al.
37. Zhao, J., Wang, T., Yatskar, M., Ordonez, V., Chang, K.W.: Men also like shopping: Reducing gender bias amplification using corpus-level constraints. arXiv preprint arXiv:1707.09457 (2017) 38. Zhu, G.: A new view of classification in astronomy with the archetype technique: an astronomical case of the NP-complete set cover problem. arXiv preprint arXiv:1606.07156 (2016)
The SLOGERT Framework for Automated Log Knowledge Graph Construction Andreas Ekelhart1(B) , Fajar J. Ekaputra2 , and Elmar Kiesling1 1
WU (Vienna University of Economics and Business), Welthandelsplatz 1, 1020 Vienna, Austria {andreas.ekelhart,elmar.kiesling}@wu.ac.at 2 TU Wien (Vienna University of Technology), Favoritenstraße 9-11/194, 1040 Vienna, Austria [email protected]
Abstract. Log files are a vital source of information for keeping systems running and healthy. However, analyzing raw log data, i.e., textual records of system events, typically involves tedious searching for and inspecting clues, as well as tracing and correlating them across log sources. Existing log management solutions ease this process with efficient data collection, storage, and normalization mechanisms, but identifying and linking entities across log sources and enriching them with background knowledge is largely an unresolved challenge. To facilitate a knowledge-based approach to log analysis, this paper introduces SLOGERT, a flexible framework and workflow for automated construction of knowledge graphs from arbitrary raw log messages. At its core, it automatically identifies rich RDF graph modelling patterns to represent types of events and extracted parameters that appear in a log stream. We present the workflow, the developed vocabularies for log integration, and our prototypical implementation. To demonstrate the viability of this approach, we conduct a performance analysis and illustrate its application on a large public log dataset in the security domain. Keywords: Knowledge graphs Graph modelling patterns
1
· Log analysis · Log vocabularies ·
Introduction
Log analysis is a technique to deepen an understanding of an operational environment, pinpoint root causes, and identify behavioral patterns based on emitted event records. Nearly all software systems (operating systems, applications, network devices, etc.) produce their own time-sequenced log files to capture relevant This work was sponsored by the Austrian Science Fund (FWF) and netidee SCIENCE under grant P30437-N31 and the Austrian Research Promotion Agency FFG under grant 877389 (OBARIS). The authors thank the funders for their generous support. c Springer Nature Switzerland AG 2021 R. Verborgh et al. (Eds.): ESWC 2021, LNCS 12731, pp. 631–646, 2021. https://doi.org/10.1007/978-3-030-77385-4_38
632
A. Ekelhart et al.
events. These logs can be used, e.g., by system administrators, security analysts, and software developers to identify and diagnose problems and conduct investigations. Typical tasks include security monitoring and forensics [23,38], anomaly detection [11,16,28], compliance auditing [25,39], and error diagnosis [6,44]. Log analysis is also a common issue more generally in other domains such as power systems security [35], predictive maintenance [40], workflow mining [3,4], and business/web intelligence [17,30]. To address these varied applications, numerous log management solutions have been developed that assist in the process of storing, indexing, and searching log data. However, investigations across multiple heterogeneous log sources with unknown content and message structures is a challenging and time-consuming task [22,41]. It typically involves a combination of manual inspection and regular expressions to locate specific messages or patterns [34]. The need for a paradigm shift towards a more structured approach and uniform log representations has been highlighted in the literature for a long time [19,21,34], but although various standardization initiatives for event representation were launched (e.g., [8,9,18,29]), none of them has seen widespread adoption. As a result, log analysis requires the interpretation of many different types of events, expressed with different terminologies, and represented in a multitude of formats [29], particularly in large-scale systems composed of heterogeneous components. As a consequence, the analyst has to manually investigate and connect this information, which is time consuming, error prone and potentially leads to an incomplete picture. In this paper, we tackle these challenges and propose Semantic LOG ExtRaction Templating (SLOGERT), a framework for automated Knowledge Graph (KG) construction from unstructured, heterogeneous, and (potentially) fragmented log sources, building on and extending initial ideas [12]. The resulting KGs enable analysts to navigate and query an integrated, enriched view of the events and thereby facilitate a novel approach for log analysis. This opens up a wealth of new (log-structured) data sources for KG building. Our main contributions are:(i) a novel paradigm for semantic log analytics that leverages knowledge-graphs to link and integrate heterogeneous log data; (ii) a framework to generate RDF from arbitrary unstructured log data through automatically generated extraction and graph modelling templates; (iii) a set of base mappings, extraction templates, and a high-level general conceptualization of the log domain derived from an existing standard as well as vocabularies for describing extraction templates; (iv) a prototypical implementation of the proposed approach, including detailed documentation to facilitate its reuse, and (v) an evaluation based on a realistic, multi-day log dataset [27]. All referenced resources, including the developed vocabularies1 , source code2 , data, and examples, are available from the project website3 .
1 2 3
https://w3id.org/sepses/ns/log#. https://github.com/sepses/slogert/. https://sepses.ifs.tuwien.ac.at/.
SLOGERT: Automated Log Knowledge Graph Construction
633
The remainder of this paper is organized as follows: we introduce our log KG building approach in Sect. 2 and evaluate it in Sect. 3 by means of example use cases. We then contrast the approach against the state of practice (Sect. 4) and review various strands of related work (Sect. 5); finally, we conclude in Sect. 6 with an outlook on future work.
2
Building Knowledge Graphs from Log Files
In this section, we introduce the SLOGERT (Semantic LOG ExtRaction Templating) log KG generation framework and discuss its architecture, components, and their implementation. The associated workflow, illustrated in Fig. 1, transforms and integrates arbitrary log files provided as input. It consists of two major phases: (1) template extraction, which results in an RDF pattern for each type of log message that appears in the sources; and (2) graph building, which – based on these patterns – transforms raw log data into RDF.4
Logfile n (Source Y)
Knowledge Engineer
Background Knowledge
Analyst
Logfile 1 (Source X)
Template Store
1. Template ExtracƟon
2. Graph Building
Integrated KG
ExploraƟon
Fig. 1. SLOGERT workflow
In the Template Extraction phase, SLOGERT will automatically generate event templates from unstructured log data by identifying the different types of log messages and their variable parts (i.e., parameters) in the raw log messages. For this, we rely on a well-established log parser toolkit [46] that generates extraction templates, which at this stage do not provide any clues about the semantics of the log message or the contained parameters. To enrich these extraction templates with semantics, we next annotate the parameters (variable parts) according to their type as well as extract relevant keywords from the log messages, which are used to link each log template with relevant CEE [29] annotations. We then use this information to associate each log extraction template with a corresponding RDF graph modelling template (represented as Reasonable Ontology Templates (OTTRs)). The resulting graph modelling templates can be annotated, adapted, extended and reused, i.e., they only have to be generated (and optionally extended) once from raw log data in which unknown log events appear. 4
A more detailed documentation and pseudocode specification of the process is available at https://github.com/sepses/slogert/.
634
A. Ekelhart et al.
Fig. 2. SLOGERT components and processing of a single example log line
In the Graph Building phase, SLOGERT then parses each line in a log file and applies the matching extraction and RDF modelling templates to transform them into RDF. Thereby, we generate entities from textual parameters in the log stream and represent them in our log vocabulary. Combining the generated RDF from multiple, potentially heterogeneous log files and log sources results in a single integrated log KG. This graph can contextualize the log data by linking it to existing background knowledge – such as internal information on assets and users or external information, e.g., on software, services, threats etc. Finally, analysts can explore, query, analyze, and visualize the resulting log KG seamlessly across log sources. 2.1
SLOGERT Components
Following this high-level outline of the SLOGERT workflow, this section describes each component in more detail. For a dynamic illustration of the overall process by way of an example log line, cf. Fig. 2. Phase 1: Template Extraction Template & Parameter Extraction (A1), i.e., the first step in the process from raw log lines to RDF, relies on LogPAI5 [46], a log parsing toolkit that identifies constant strings and variable values in the free-text message content. This step results in two files, i.e., (i) a list of log templates discovered in the log file, each including markings of the position of variable parts (parameters), and (ii) the 5
https://github.com/logpai/logparser.
SLOGERT: Automated Log Knowledge Graph Construction
635
actual instance content of the logs, with each log line linked to one of the log template ids, and the extracted instance parameters as an ordered list. This process is fully automated and applicable to any log source, but depending on the structure of the log messages, it may not necessarily result in clearly separated parameters. As an example, consider that a user name next to an IP address will be identified as a single string parameter, as they usually change together in each log line. To achieve better results, LogPAI therefore accepts regular expression specifications of patterns that should be extracted as parameters, if detected. We take advantage of this capability by defining general regex patterns for common elements and including them in the configuration. At the end of this stage, we have extraction templates and the associated extracted instance data, but their semantic meaning is yet undefined. Semantic Annotation (A2) takes the log templates and the instance data with the extracted parameters as input and (i) generates RDF rewriting templates that conform to an ontology and persists the templates in RDF for later reuse (A2-1), (ii) detects (where possible) the semantic types of the extracted parameters (A2-2), (iii) enriches the templates with extracted keywords (A2-3), and (iv) annotate the templates with CEE terms (A2-4). For the parameter type detection (A2-1), we first select a set of log lines for each template (default: 3) and then apply rule-based Named Entity Recognition (NER) techniques. Specifically, we use TokensRegex from Stanford CoreNLP [5] to define patterns over text (sequences of tokens), and map them to semantic objects. CoreNLP can detect words in combination with (POS) tags and named entity labels as part of the patterns. Such token-based extraction works well for finding patterns in natural language texts, but log messages often do not follow the grammatical rules of typical natural language expressions and contain “unusual” entities such as URLs, identifiers, and configurations. For those cases, we additionally apply standard regex patterns on the complete message. For each identified parameter, we also define a type and a property from a log vocabulary to use for the detected entities. In case a parameter does not result in any matches, we mark it as unknown. In our prototype, we collect all parameter extraction patterns in a YAML configuration file and model a set of generic patterns that cover various applications, including the illustrative use cases in Sect. 3. These patterns are reusable across heterogeneous log sources and can be easily extended, e.g., with existing regex log patterns such as, e.g., Grok6 . For the semantic representation necessary to allow for a consistent representation over heterogeneous log files, we followed the Ontology 101 methodology [33], extended a prior log vocabulary [26] and mapped it to the Common Event Expression (CEE) [29] taxonomy. Furthermore, we persist our ontology with a W3ID namespace (i.e., https://w3id.org/ sepses/ns/log#) and use Widoco [14] for the ontology documentation. Our vocabulary core represents log events (log:Event) with a set of fields (sub-properties of the log:hasParameter object property and log:parameter 6
https://github.com/elastic/logstash/blob/v1.4.2/patterns/grok-patterns.
636
A. Ekelhart et al.
datatype properties). Each log event originates from a specific host (log: hasSourceHost) and exists in a specific log source (log:hasLogSource, e.g., an FTP log file). The underlying source type (e.g., ftp) is expressed by log: SourceType, and the log format is represented as log:Format (e.g., syslog). Furthermore, a log event template is tagged with its underlying action (e.g., login, access), domain (e.g., app, device, host), object (e.g., email, app), service (e.g., auth, audit), status (e.g., failure, error), and a subject (e.g., user) based on the CEE specification7 . Once we have identified extraction templates for events and parameters, we can generate corresponding RDF generation templates for each of them. This step expresses the patterns that determine how KGs are built from the log data as reusable OTTR [1] templates, i.e., in a language for ontology modeling patterns. As all the generated templates are reusable and should not have to be regenerated for each individual instance of a log file, we persist them in RDF with their associated hash (based on the static parts of the log messages) as identifier. Finally, as a prerequisite to generate the actual KG from these OTTR templates, we transform all log line instances of the input into the stOTTR format, a custom file format similar to Turtle, which references the generated OTTR templates. Phase 2: Graph Building. In this step, we generate a KG based on the OTTR templates and stOTTR instance files generated in the extraction component. RDFization (A3). For the conversion of OTTR templates and instance files, we rely on Lutra8 , the reference implementation for the OTTR language. Thereby, we expand the log instance data into an RDF graph that conforms to the log vocabulary and contains the entities and log events of a single log file. Background KG Building (A4). Linking log data to background knowledge through the use of appropriate identifiers is a key step that facilitates enrichment with both local context information and external knowledge. The former represents information that is created and maintained inside the organization and not intended for public release. Examples include, e.g., the network architecture, users, organizational structures, devices, servers, installed software, and documents. This knowledge can either be maintained manually by knowledge engineers or automatically by importing, e.g., DHCP leases, user directories with metadata, or software asset information. The dynamic nature of such information (e.g., a user switches department, a computer is assigned a new IP address, software is uninstalled) necessitates a mechanism to capture temporal aspects. To this end, RDF-Star can be used to historize the contained knowledge. The second category, external knowledge, links to any publicly available (RDF) data sources, such as, e.g., IT product and service inventories, vulnerability databases, and threat intelligence information (e.g., collected in [24]). 7 8
https://cee.mitre.org/language/1.0-beta1/core-profile.html. https://ottr.xyz/#Lutra.
SLOGERT: Automated Log Knowledge Graph Construction
637
Knowledge Graph Integration (A5) combines the KGs from the previously isolated log files and sources into a single, linked representation. Key concepts and identifiers in the computer log domain follow a standardized structure (e.g., IP and MAC addresses, URLs) and hence can be merged using the same vocabulary. In case external knowledge does not align with the generated graphs (e.g., entity identifiers differ), an additional mapping step has to be conducted before merging. Existing approaches, such as the Linked Data Integration Framework Silk9 can be used for this purpose.
3
Use Cases and Performance
We illustrate the presented approach and its applicability to real-world log data based on a systematically generated, publicly available data set that was collected from testbeds over the course of six days [27]. Furthermore, we report on the performance of the developed prototype (cf. Sect. 3.3). 3.1
Data Source
The AIT log dataset (V1.1)10 contains six days of log data that was automatically generated in testbeds following a well-defined approach described in [27]. It is a rare example of a readily available realistic dataset that contains related log data from multiple systems in a network. In addition, information on the setup is provided, which can be used as background knowledge in our approach. As detailed information on the context of the scenario was not available, we complemented it with synthetic example background knowledge on the environment that the data was generated in for demonstration purposes. Each of the web servers runs Debian and a set of installed services such as Apache2, PHP7, Exim4, Horde, and Suricata. Furthermore, the data includes logs from 11 Ubuntu hosts on which user behavior was simulated. On each web server, the collected log sources include Apache access and error logs, syscall logs from the Linux audit daemon, suricata logs, exim logs, auth logs, daemon logs, mail logs, syslogs, and user logs. The logs capture mostly normal user behavior; on the fifth day of the log collection (2020-03-04), however, two attacks were launched against each of the four web servers. In total, the data set amounts to 51.1 GB of raw log files. 3.2
Use Cases
In this scenario, we assume that activities have raised suspicion and an analyst wants to conduct a forensic analysis based on the available log data. We will illustrate how our proposed framework can assist in this process. To this end, we first processed all raw logs11 with SLOGERT and stored them together with 9 10 11
http://silkframework.org/. https://zenodo.org/record/4264796. From the audit logs, we only extracted the time frame relevant for the investigation.
638
A. Ekelhart et al. Table 1. Query result for activities of a given user in the network (excerpt) Template Timestamp
Host
SourceType Annotations
108cf6f8 ... 108cf6f8 108cf6f8 c9f3df73
mail.cup.com ... mail.cup.com mail.cup.com mail.cup.com
messages ... messages messages syslog
2020-03-04T19:26:00 ... 2020-03-04T19:28:59 2020-03-04T19:29:00 2020-03-04T19:29:07
failure,login failure,login failure,login login,success
the background knowledge in a triple store12 . Overall, we collected 838.19MB of raw log files, resulting in 84,827,361 triples for this scenario.
Listing 1 demonstrates how an analyst can query the activities associated with a given username (i.e., daryl). The query illustrates the ability to access integrated log data and the flexibility of SPARQL as a query language for log data analytics. Table 1 shows an excerpt of the query results, with the template name, timestamp of the event, host, type of log, and automatically extracted CEE [29] annotation labels. The template associated with each log event makes it possible to easily identify events of the same type; human-readable labels can optionally be assigned in the template library. As a simple illustrative example, the query makes use of only a small subset of the available extracted properties. To explore the context and increase an analyst’s understanding of the situation in the course of an investigation, other 12
GraphDB 9.5, https://graphdb.ontotext.com.
SLOGERT: Automated Log Knowledge Graph Construction
639
Fig. 3. Graph exploration: context information for User daryl
extracted properties such as IP addresses, processes, commands, files, URLs, and email addresses can be added. These extracted entities establish links among log events and connect them to background knowledge, allowing the analyst to explore the log data from multiple perspectives in order to “connect the dots”, e.g., in the context of attacks. As an example, consider that the sequence of login failures in a short time period evident in Table 1 suggests a possible brute force attack, and the successful login shortly thereafter is alarming. To explore this further, the analyst can construct an enriched view on the available log events by visualizing the data (e.g., using GraphDB) and interactively following links of interest. The graph structure makes it possible to navigate the contextualized log data with interlinked background knowledge that otherwise is typically stored in external documentation or only exists in analysts’ heads. In the example in Fig. 3, the analyst started from the username daryl and navigated to the Person associated with the account; from there, she can obtain additional information about the person, such as the role in the company, contact information, assigned devices, and additional usernames (e.g., User page). In a similar manner, the analyst could integrate and explore external RDF data sources. We can also see how events are connected to the user in the selected time frame, and how the templates are annotated with detected CEE terms. 3.3
Performance
For each log source in the AIT log dataset – collected from four servers in a testbed environment – we ingest the raw log files13 and execute all steps in 13
Note that we only used a relevant subset of the high-volume audit logs, but the full time range for all other logs.
640
A. Ekelhart et al.
Table 2. Log sources and graph output. The run-time for the following phases is measured in seconds: template extraction (P1) and graph building (P2) Source
Raw (MB) TTL (MB) HDT (MB) P1 (s) P2 (s)
Access Audit Auth Daemon Error Fast Mail Main Messages Sys
131.80 525.41 0.48 0.58 0.17 3.15 58.27 1.96 28.60 87.78
526.08 2026.38 3.35 3.94 0.69 15.89 295.36 13.81 108.10 408.50
87.57 305.45 0.34 0.63 0.15 2.34 39.52 3.02 12.55 53.05
336 6652 3 5 3 5 146 6 34 297
1398 6799 5 6 2 34 690 20 199 909
Total/Merged 838.19
3402.11
498.36
7486
10062
the workflow according to Fig. 2. As the graph generation is split into multiple processing steps, we measure the execution time for each phase (i.e., template extraction and graph building) on a single machine with a Ryzen 7 3700X processor (64 GB RAM). Table 2 shows the input log sources with their total file sizes over all four servers. Furthermore, it lists the sizes of the generated (intermediate) KGs in Turtle format (TTL), as well as in compressed format (HDT). At the end of the SLOGERT process, all intermediate graphs are merged into a single KG. In our illustrative scenario, we processed 838.19 MB of raw log data in total and generated a KG from it that is 498.36 MB in HDT format. Note that whereas the resulting TTL graph files were approx. four times the raw input size, the compressed HDT data, which can also easily be queried with SPARQL, is about 40% smaller than the original log file. The size of the generated graphs could further be reduced by (i) not including the full original raw input message (currently we keep it as message literal), and/or (ii) discarding unknown parameters, and/or (iii) extracting only the specific classes and properties necessary for a given set of analytic tasks. In terms of processing time graph building (P2) is the most time consuming phase (approx. 168 min)14 . We see that run-time scales linearly with file size; it can easily be reduced by parallelizing the semantic annotation and graph generation phases. Our prototype converts the log events into batches – the number of log lines per batch (200k in our experiments) can be configured. Although we executed the process on a single machine in sequence, each batch file could easily be processed in parallel. Taking the audit log as example, all audit log event lines were split into 200k batches (13 files), taking approx. 17 min each to build the KG. 14
The Lutra team is working on performance according to their release notes.
SLOGERT: Automated Log Knowledge Graph Construction
641
Table 3. Comparison of SLOGERT with existing LMSs
4
Aspect
Existing LMSs SLOGERT
Mode
Online & Offline
(Currently) offline
Storage
Proprietary databases
RDF & HDT compression
Extraction
Regex filters
Template-based
Normalization
Fields
Entity hierarchies and links
Background knowledge
-
RDF linking
Data insights
Dashboards and reports
Graph queries and navigation
State of the Practice
Commercially available Log Management Systems (LMSs) – such as Splunk15 , Graylog16 , or Logstash17 – prioritize aggregation, normalization, and storage over integration, contextualization, linking, enrichment, and rich querying capabilities. They are typically designed to allow scalable retention of large log data and focus on reporting and alerting based on relatively simple rules. Table 3 compares and contrasts SLOGERT with such existing LMSs. Whereas some tasks, such as log collection from raw logs, can rely on available standard mechanisms, the approach differs fundamentally in terms of event and parameter detection, normalization, background knowledge linking, and the way that insights can be gained. In particular, SLOGERT (i) automatically classifies events and assigns types from a taxonomy based on the static parts of the messages and (ii) identifies and annotates variable parts of the messages. Although existing LMSs often also include a predefined and limited set of extractors to identify relevant patterns (e.g., IP address, date/time, protocol), they do not capture entities, their relationships, and the nature of these relationships in a graph structure. Furthermore, they are limited in their representational flexibility by the structure of the underlying, typically relational, storage. The graph-based approach makes it possible to link assets to concepts and instances defined in background knowledge in order to enrich log events with additional internal or external knowledge. For instance, multiple usernames can be linked to the same person they belong to or software assets can be linked to public sources such as the Cyber-security Knowledge Graph (CSKG) [24] to include information about their vulnerabilities. Finally, whereas existing LMSs typically provide relatively static dashboards and reports, SLOGERT opens up possibilities for exploration through graph 15 16 17
https://splunk.com. https://www.graylog.org/. https://logstash.net.
642
A. Ekelhart et al.
queries and visual navigation, providing a new flexible perspective on events, their context, and their relationships. Overall, no comparable graph-based semantic systems exist – current stateof-the-art message-centric log management systems focus on aggregation, management, storage, and manual step-by-step textual search and interpretation with implicit background knowledge. SLOGERT makes it possible to automatically contextualize, link and interpret log events. It complements, but does not replace established log management solutions with additional techniques to extract, enrich, and explore log event data. Specifically, our current focus is facilitating deeper inspection of subsets of log data from selected log sources, e.g., in a relevant time frame. To this end, we have developed flexible mechanisms for fully automated ad-hoc extraction and integration.
5
Related Work
Log parsing and extraction Logs, i.e., records of the events occurring within an organization’s systems and networks [21], are composed of log entries, each of which provides information related to a specific event that has occurred. These log entries typically consist of a structured part with fields such as a timestamp, severity level etc., and an unstructured message field. Whereas conventions for the structured parts are somewhat standardized (e.g., in [2])), there is little uniformity on the content of the message field, despite numerous standardization attempts (e.g., IDMEF [18], CEE [29], CIM [9] and CADF [8]). Because log messages are produced from statements inserted into the code, they often do not follow typical natural language grammar and expression, but are shaped according to the code that generates them. Specifically, each log message can be divided into two parts: a constant part (i.e., fixed text that remains the same for every event instance) and a variable part that carries the runtime information of interest, such as parameter values (e.g., IP addresses and ports). Traditional manual methods for analyzing such heterogeneous log data have become exceedingly labor-intensive and error-prone [15]. Furthermore, the heavy reliance on regular expressions in log management results in complex configurations with customized rules that are difficult to maintain as systems evolve [15]. These limitations of regex-based event extraction motivated the development of data-driven approaches for automated log parsing (e.g., [42]) that leverage historical log messages to train statistical models for event extraction. [15] provides a systematic evaluation of the state-of-the-art of such automated event extraction methods. We leverage these methods as the first step in our automated KG construction workflow. Specifically, our template extraction is based on the LogPAI logparser toolkit [46], which provides implementations of various automated event extraction methods. Log representation in Knowledge Graphs has attracted recent research interest because graph-based models provide a concise and intuitive abstraction for the log domain that can represent various types of relations flexibly. Therefore, a variety of approaches that apply graph-based models and graph-theoretical
SLOGERT: Automated Log Knowledge Graph Construction
643
analysis techniques to log data have been proposed in the literature, covering applications such as query log analysis [10,45], network traffic and forensic analysis [7,43], and security [36]. Whereas these contributions are focused on graph-theoretical metrics and methods, another stream of knowledge-graphcentric literature has emerged more recently. CyGraph [32], e.g., develops a property graph-based cybersecurity model and a domain-specific query language for expressing graph patterns of interest. It correlates intrusion alerts to vulnerability paths, but compared to our approach, it does not aim for semantic lifting of general log data. In terms of semantic KGs, existing approaches have focused either on structured log data only [31], or on tasks such as entity [20] and relation [37] extraction in unstructured log data. Whereas some of the extraction methods introduced in this context are similar to our approach, their focus is less on log representation, but on cybersecurity information more general (e.g., textual descriptions of attacks). Other contributions have focused on a conceptualization of the log domain and the development of appropriate vocabularies for log representation in KGs [13]. Another recent, more narrowly focused approach [26] that does not cover general extraction introduces a vocabulary and architecture to collect, extract, and link heterogeneous low-level file access events from Linux and Windows event logs. Finally, [24] provides a continuously updated resource that links and integrates cybersecurity information, e.g., on vulnerabilities, weaknesses, and attack patterns, providing a useful linking target in the context of this log extraction framework.
6
Conclusions and Future Work
This paper introduced SLOGERT, a flexible framework and workflow for automated KG construction from unstructured log data. The proposed workflow can be applied to arbitrary log data with unstructured messages and consists of a template extraction and a graph building phase. Our prototype demonstrated the viability of the approach, particularly if the messages in the log sources do not require frequent relearning of the extraction templates. Configurability and extensibility were key design goals in the development of SLOGERT. For arbitrary log data with unstructured messages in a given log domain, the framework generates a keyword-annotated RDF representation. The demonstrated configuration covers standard concepts for various log sources relevant in a cybersecurity context, however, they can easily be adapted for different log domains. An inherent limitation evident from our experiments was a sensitivity to the training data set during template extraction; specifically, entities can not be properly identified if there is too little variation in the variable parts of a given log message. This limitation can be tackled through larger log collections, ideally through a community effort towards creating a shared library of extraction templates for standard log data sources.18 More broadly, we also envisage a community-based effort to develop mappings, extensions for specific log sources, 18
Note that the template representation in RDF simplifies sharing.
644
A. Ekelhart et al.
and shared domain knowledge such as vulnerability information and threat intelligence. Due to the widespread use of unstructured log data in numerous domains and the limitations of existing analytic processes, we expect strong adoption potential for SLOGERT, which in turn could also drive adoption of Semantic Web technologies in log analytics more generally. Furthermore, we also expect impulses for KG research and takeup by KG builders that need to integrate log data into their graphs. In our own research, we will apply the proposed approach in the context of semantic security analytics19 . Our immediate future work will focus on the integration into logging infrastructures, e.g., by supporting additional formats and protocols. Furthermore, we will focus on graph management for template evolution and incremental updating of log KGs. Conceptually, our bottom-up extraction approach provides a foundation for future work on linking it to higher-level conceptualizations of specific log domains (e.g., based on DMTF’s CIM [9] or the CADF [8] event model). Potentially, this can also provide a foundation for research into event abstraction, i.e., automatically transforming a sequence of individual log events into higher-level composite events or log-based anomaly detection, e.g., through combinations of rule-based methods and relational learning and KG embedding techniques.
References 1. pOTTR: Reasonable Ontology Templates Primer. https://primer.ottr.xyz/ 2. Textual Conv. for Syslog Management. https://tools.ietf.org/html/rfc5427 3. van der Aalst, W.M.P.: Process Mining. Springer, Heidelberg (2011). https://doi. org/10.1007/978-3-642-19345-3 4. Bao, L., Busany, N., Lo, D., Maoz, S.: Statistical log differencing. In: 34th IEEE/ACM International Conference on Automated Software Engineering, pp. 851–862 (2019) 5. Chang, A.X., Manning, C.D.: TokensRegex: defining cascaded regular expressions over tokens. Technical report, CSTR 2014–02, Dep. of CS, Stanford University (2014) 6. Cui, W., et al.: REPT: reverse debugging of failures in deployed software. In: 12th USENIX Conference on OS Design and Implementation, pp. 17–32. USENIX Association (2018) 7. Djidjev, H., Sandine, G., Storlie, C.: Graph based statistical analysis of network traffic. In: 9th Workshop on Mining and Learning with Graphs, p. 8 (2011) 8. DMTF: Cloud Audit. Data Federation. https://www.dmtf.org/standards/cadf 9. DMTF: Common Information Model. https://www.dmtf.org/standards/cim 10. Donato, D.: Graph structures and algorithms for query-log analysis. In: Ferreira, F., L¨ owe, B., Mayordomo, E., Mendes Gomes, L. (eds.) CiE 2010. LNCS, vol. 6158, pp. 126–131. Springer, Heidelberg (2010). https://doi.org/10.1007/978-3642-13962-8 14 11. Du, M., Li, F., Zheng, G., Srikumar, V.: DeepLog: anomaly detection and diagnosis from system logs through deep learning. In: 2017 ACM SIGSAC Conference on Computer and Communications Security, pp. 1285–1298. ACM (2017) 19
https://w3id.org/sepses.
SLOGERT: Automated Log Knowledge Graph Construction
645
12. Ekelhart, A., Ekaputra, F.J., Kiesling, E.: Automated knowledge graph construction from raw log data. In: Proceedings of the ISWC 2020 Demos and Industry Tracks, vol. 2721, p. 5. CEUR (2020). http://ceur-ws.org/Vol-2721/paper552.pdf 13. Ekelhart, A., Kiesling, E., Kurniawan, K.: Taming the logs - vocabularies for semantic security analysis. Procedia Comp. Sci. 137, 109–119 (2018) 14. Garijo, D.: WIDOCO: a wizard for documenting ontologies. In: d’Amato, C., et al. (eds.) ISWC 2017. LNCS, vol. 10588, pp. 94–102. Springer, Cham (2017). https:// doi.org/10.1007/978-3-319-68204-4 9 15. He, P., Zhu, J., He, S., Li, J., Lyu, M.R.: An evaluation study on log parsing and its use in log mining. In: 2016 46th Annual IEEE/IFIP International Conference on Dependable Systems and Networks (DSN), pp. 654–661. IEEE (2016) 16. He, S., Zhu, J., He, P., Lyu, M.R.: Experience report: system log analysis for anomaly detection. In: 2016 IEEE 27th International Symposium on Software Reliability Engineering (ISSRE), pp. 207–218. IEEE (2016) 17. Hussain, T., Asghar, S., Masood, N.: Web usage mining: a survey on preprocessing of web log file. In: 2010 Internationl Conference on Information and Emerging Technologies, pp. 1–6. IEEE (2010) 18. IETF: RFC4765. https://www.ietf.org/rfc/rfc4765.txt 19. Jayathilake, D.: Towards structured log analysis. In: 2012 9th International Conference on Computer Science and Software Engineering (JCSSE), pp. 259–264. IEEE (2012) 20. Jia, Y., Qi, Y., Shang, H., Jiang, R., Li, A.: A practical approach to constructing a knowledge graph for cybersecurity. Engineering 4(1), 53–60 (2018) 21. Kent, K., Souppaya, M.P.: Guide to comp. security log management. Technical report. NIST SP 800–92, National Institute of Standards and Technology (2006) 22. Kent, K., Souppaya, M.P.: Sp 800–92. guide to computer security log management. Technical report, Gaithersburg, MD, USA (2006) 23. Khan, S., et al.: Cloud log forensics: foundations, state of the art, and future directions. ACM Comput. Surv. 49(1), 1–42 (2016) 24. Kiesling, E., Ekelhart, A., Kurniawan, K., Ekaputra, F.: The SEPSES knowledge graph: an integrated resource for cybersecurity. In: Ghidini, C., et al. (eds.) ISWC 2019. LNCS, vol. 11779, pp. 198–214. Springer, Cham (2019). https://doi.org/10. 1007/978-3-030-30796-7 13 25. Kirrane, S., et al.: A scalable consent, transparency and compliance architecture. In: Gangemi, A., et al. (eds.) ESWC 2018. LNCS, vol. 11155, pp. 131–136. Springer, Cham (2018). https://doi.org/10.1007/978-3-319-98192-5 25 26. Kurniawan, K., Ekelhart, A., Kiesling, E., Froschl, A., Ekaputra, F.: Semantic integration and monitoring of file system activity. In: 2019 SEMANTiCS Conference, p. 5 (2019) 27. Landauer, M., Skopik, F., Wurzenberger, M., Hotwagner, W., Rauber, A.: AIT log data set v1.1 (November 2020). https://doi.org/10.5281/zenodo.4264796 28. Meng, W., et al.: LogAnomaly: unsupervised detection of sequential and quantitative anomalies in unstructured logs. In: 28th International Joint Conference on Artificial Intelligence, pp. 4739–4745 (2019) 29. MITRE: Common Event Expression. https://cee.mitre.org 30. Neelima, G., Rodda, S.: Predicting user behavior through sessions using the web log mining. In: 2016 International Conference on Advances in Human Machine Interaction (HMI), pp. 1–5. IEEE (2016) 31. Nimbalkar, P., Mulwad, V., Puranik, N., Joshi, A., Finin, T.: Semantic interpretation of structured log files. In: 2016 IEEE 17th International Conference on Information Reuse and Integration (IRI), pp. 549–555. IEEE (2016)
646
A. Ekelhart et al.
32. Noel, S., Harley, E., Tam, K., Limiero, M., Share, M.: CyGraph. In: Handbook of Statistics, vol. 35, pp. 117–167. Elsevier (2016) 33. Noy, N.F., McGuinness, D.L., et al.: Ontology development 101: a guide to creating your first ontology (2001) 34. Oliner, A., Ganapathi, A., Xu, W.: Advances and challenges in log analysis. Commun. ACM 55(2), 55–61 (2012) 35. Pan, S., Morris, T., Adhikari, U.: Developing a hybrid intrusion detection system using data mining for power systems. IEEE Transa. Smart Grid 6(6), 3104–3113 (2015) 36. Pei, K., et al.: HERCULE: attack story reconstruction via community discovery on correlated log graph. In: 32nd Annual Conference on Computer Security Applications, ACSAC 2016, pp. 583–595. ACM Press (2016) 37. Pingle, A., Piplai, A., Mittal, S., Joshi, A., Holt, J., Zak, R.: RelExt: relation extraction using deep learning approaches for cybersecurity knowledge graph improvement. arXiv:1905.02497 [cs] (2019) 38. Raftopoulos, E., Egli, M., Dimitropoulos, X.: Shedding light on log correlation in network forensics analysis. In: Flegel, U., Markatos, E., Robertson, W. (eds.) DIMVA 2012. LNCS, vol. 7591, pp. 232–241. Springer, Heidelberg (2013). https:// doi.org/10.1007/978-3-642-37300-8 14 39. Reuben, J., Martucci, L.A., Fischer-H¨ ubner, S.: Automated log audits for privacy compliance validation: a literature survey. In: Aspinall, D., Camenisch, J., Hansen, M., Fischer-H¨ ubner, S., Raab, C. (eds.) Privacy and Identity 2015. IAICT, vol. 476, pp. 312–326. Springer, Cham (2016). https://doi.org/10.1007/978-3-31941763-9 21 40. Sipos, R., Fradkin, D., Moerchen, F., Wang, Z.: Log-based predictive maintenance. In: 20th ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, KDD 2014, pp. 1867–1876. ACM Press (2014) 41. Svacina, J., et al.: On vulnerability and security log analysis: a systematic literature review on recent trends. In: Proceedings of the International Conference on Research in Adaptive and Convergent Systems, RACS 2020, pp. 175–180. ACM, New York (2020) 42. Tang, L., Li, T., Perng, C.S.: LogSig: generating system events from raw textual logs. In: 20th ACM International Conference on Information and Knowledge Management, CIKM 2011, p. 785. ACM Press (2011) 43. Wang, W., Daniels, T.E.: A graph based approach toward network forensics analysis. ACM Trans. Inf. Sys. Sec. 12(1), 412–433 (2008) 44. Yuan, D., Mai, H., Xiong, W., Tan, L., Zhou, Y., Pasupathy, S.: SherLog: error diagnosis by connecting clues from run-time logs. ACM SIGPLAN Not. 45(3), 143 (2010) 45. Zhang, J., Jie, L., Rahman, A., Xie, S., Chang, Y., Yu, P.S.: Learning entity types from query logs via graph-based modeling. In: 24th ACM International on Conference on Information and Knowledge Management, CIKM 2015, pp. 603–612. Association for Computing Machinery (2015) 46. Zhu, J., et al.: Tools and benchmarks for automated log parsing. In: 2019 IEEE/ACM 41st International Conference on Software Engineering: Software Engineering in Practice (ICSE-SEIP), pp. 121–130. IEEE (2019)
P2P-O: A Purchase-To-Pay Ontology for Enabling Semantic Invoices Michael Schulze1,2,3(B) , Markus Schr¨ oder1,2 , Christian Jilek1,2 , 3 2 Torsten Albers , Heiko Maus , and Andreas Dengel1,2 1
Department of Computer Science, Technische Universit¨ at Kaiserslautern, Kaiserslautern, Germany {michael.schulze,markus.schroder,christian.jilek,andreas.dengel}@dfki.de 2 Smart Data and Knowledge Services Department, Deutsches Forschungszentrum f¨ ur K¨ unstliche Intelligenz GmbH (DFKI), Kaiserslautern, Germany [email protected] 3 Development Department, b4value.net GmbH, Kaiserslautern, Germany [email protected] Abstract. Small and medium-sized enterprises increasingly adopt electronic invoices and digitized purchase-to-pay processes. A purchase-topay process begins with making a purchase order and ends with completing the payment process. Even when organizations adopt electronic invoices, knowledge work in such processes is characterized by assimilating information distributed over heterogeneous sources among different stages in the process. By integrating such information and enabling a shared understanding of stakeholders in such processes, ontologies and knowledge graphs can serve as an appropriate infrastructure for enabling knowledge services. However, no suitable ontology is available for current electronic invoices and digitized purchase-to-pay processes. Therefore, this paper presents P2P-O, a dedicated purchase-to-pay ontology developed in cooperation with industry domain experts. P2P-O enables organizations to create semantic invoices, which are invoices following linked data principles. The European Standard EN 16931-1:2017 for electronic invoices was the main non-ontological resource for developing P2P-O. The evaluation approach is threefold: (1) to follow ontology engineering best practices, we applied OOPS! (OntOlogy Pitfall Scanner!) and OntoDebug; (2) to evaluate competency questions, we constructed a purchase-to-pay knowledge graph with RML technologies and executed corresponding SPARQL queries; (3) to illustrate a P2P-O-based knowledge service and use case, we implemented an invoicing dashboard within a corporate memory system and thus enabled an entity-centric view on invoice data. Organizations can immediately start experimenting with P2P-O by generating semantic invoices with provided RML mappings. Keywords: Semantic invoice · E-procurement · Purchase-to-pay process · Enterprise knowledge graph · Corporate memory · RML
c Springer Nature Switzerland AG 2021 R. Verborgh et al. (Eds.): ESWC 2021, LNCS 12731, pp. 647–663, 2021. https://doi.org/10.1007/978-3-030-77385-4_39
648
1
M. Schulze et al.
Introduction
Small and medium-sized enterprises (SMEs) increasingly adopt electronic invoices and move towards digitizing their purchase-to-pay processes. A purchase-to-pay or procure-to-pay process begins with making a purchase order and ends with completing the payment process [19]. In such processes, invoice processing is an ubiquitous task [19]. This requires besides information on invoices, also information on other documents, such as delivery notes, credit notes or reports on service provisions. Also frequently needed is background information from various data collections, such as suppliers, product catalogs or purchase-to-pay policies. Therefore, this kind of knowledge work is characterized by searching and assimilating information distributed over heterogeneous sources among different stages in the process. Jain and Woodcock [19] estimate that 21% of tasks in the field of invoice processing will be hard to process automatically. Consequently, even when SMEs adopt electronic invoices, human effort in purchase-to-pay processes will continue to be essential. To assist knowledge workers in such digitized purchase-to-pay processes, knowledge graphs [9] can serve as an appropriate infrastructure for enabling knowledge services by integrating distributed and heterogeneous information from document-based and other data sources. We envision a personal “information butler” [6], who is able to proactively deliver pertinent information depending on a given work context [21]. In purchase-to-pay processes, this context might be a task involving verification of a corrective invoice based on an initial invoice, a purchase order and reports on service provisions. Having a purchaseto-pay knowledge graph also enables the integration into a knowledge description layer of a corporate memory [1]. This provides an appropriate infrastructure for knowledge services embedded into the office environment of daily work [24]. In line with the definition of a knowledge graph suggested by Ehrlinger and W¨ oß [9], we see an ontology as an inherent part of a knowledge graph. However, to the best of our knowledge, there is no purchase-to-pay ontology available suiting our requirements and goals. These are as follows: describing and interrelating information on current electronic invoices, relating invoices to a corresponding purchase-to-pay process and adhering to industry standards. Related and established ontologies in the field, such as the Financial Industry Business Ontology (FIBO) [3] or the GoodRelations Ontology [17], have a different focus and thus do not provide sufficient vocabulary to meet these requirements. Therefore, this paper presents P2P-O, a dedicated purchase-to-pay ontology. P2P-O is developed in cooperation with industry domain experts and aligned with the core invoice model of the European Standard EN 16931-1:2017 (EN16931) [10]. Thus, electronic invoices can be upgraded to semantic invoices, which we define as invoices following linked data principles. Besides enabling knowledge services, semantic invoices also enable new kinds of queries. This is evident in the case of incorporating linked open data1 in federated queries, thus allowing SMEs, for example, to filter which of their products are sold in cities 1
https://www.lod-cloud.net/.
P2P-O: A Purchase-To-Pay Ontology for Enabling Semantic Invoices
649
with more than 50 000 inhabitants. Adoption of e-invoices is also associated with positive social and financial consequences. It is estimated that the adoption saves one million metric tons of CO2 emissions a year2 . Also, it helps with reducing the VAT gap resulted from tax fraud and tax evasion [22]. Financial resources that could be freed up for society. Additionally, it is estimated that in the European Union the adoption can save up to 0.8% of the gross domestic product (GDP) [4,10]. This is in particular due to resulted process efficiency [10]. By providing added value and incentives in form of semantic knowledge services, we also aim to increase adoption rates, especially those from SMEs because their rate is only half the rate of big enterprises (22%) (See Footnote 2). The rest of the paper is structured as follows. The next section introduces purchase-to-pay processes and the European Standard EN16931 [10] as the main non-ontological reused resource. Section 3 presents the ontology and describes the developing and modeling process. Section 4 elaborates on the evaluation approach and on an example use case, and Sect. 5 covers related resources. We conclude with Sect. 6 and provide an outlook on future work.
2
Foundations
2.1
Purchase-To-Pay Processes and Electronic Invoices
The BPMN3 diagram in Fig. 1 depicts a simple instance of a purchase-to-pay process that starts with the sending of a purchase order from the buyer to the seller. After delivering the requested goods or providing the services, the seller sends an electronic invoice to the buyer. In the case of the process in Fig. 1, a dispute is depicted and thus, finally, a credit note sent to the buyer. Because P2P-O’s focus is on electronic documents in such purchase-to-pay processes, Fig. 1 leaves out the actual payments made by the participants as well as the physical exchange of goods. In practice, purchase-to-pay processes can take on more diverse and complex forms. For instance, instead of sporadic purchase orders (Fig. 1), processes can be periodic based on a contract. Also, despatch and receiving advice documents or service provision documents can be part of purchase-to-pay processes. For a more detailed overview, we kindly refer the reader to the European Standard EN-16931 [10]. In addition, with respect to the participants in purchase-to-pay processes, buyer, seller, receiver, payee and the respective taxable persons do not necessarily have to be the same [10]. Summarizing, purchase-to-pay processes are characterized by numerous heterogeneous documents, especially in SMEs where ERP Systems are often missing, as well as by diverging processes.
2 3
https://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=COM:2010:0712:FIN:en: PDF. https://www.omg.org/spec/BPMN/2.0/.
650
M. Schulze et al.
Fig. 1. BPMN diagram of a simplified purchase-to-pay process with a dispute
2.2
The Core Invoice Model in EN 16931-1:2017
In the European Standard EN 16931-1:2017 [10], the CEN-CENELEC Management Centre introduces the core invoice model. We reused this standard because of its general approach: the model specifies 161 core information elements for electronic invoices that are sufficient for most transactions. Examples for information elements are the invoice number or the buyer name. In transactions where the core invoice model is not sufficient, it can be extended. In the core invoice model [10], information elements are organized hierarchically at different levels. On the first level (document level), some elements are not further divided (e.g. the invoice number). Higher levels can group further information elements together. For example, information elements with respect to the seller are grouped at the second level (e.g. seller name) and they can be further divided to a third level (e.g. seller postal address). Information elements in EN16931 are depicted in a tabular form with the following columns: ID: identifier, e.g. BT-1 for the information element “invoice number” Level: level of the information element, e.g. + for the first level Cardinality: cardinality of the information element, e.g. 1..n Business Term: name, e.g. “invoice number” Description: further details about the information element Usage Note: notes about the practical usage of the information element Requirement ID: the particular requirement specified in EN16931 which is addressed by the information element, e.g. R56 Semantic Data Type: data type, e.g. Text, Identifier or Code This list will be referred when the modeling process in Sect. 3.2 is covered. E-invoices cannot be considered in isolation from the respective purchase-to-pay process as its context. Therefore, EN16931 specifies 12 kinds of purchase-to-pay processes that are supported by the invoice model without any extensions. [10]
P2P-O: A Purchase-To-Pay Ontology for Enabling Semantic Invoices
651
Table 1. Excerpt of competency questions for P2P-O. Identifier Competency question C1
What is the reference number of an invoice?
C2
What is the total amount without value added tax of an invoice?
C3
Who is the seller on an invoice?
C4
Who is the buyer on an invoice?
C5
What are items listed on the invoice?
C6
What is the address of the buyer?
C7
To what price and quantity was an item on an invoice purchased?
C8
What are attributes of an item on an invoice?
C9
Which organizations purchased an item?
C10
Which organizations sold an item?
C11
To what sort of purchase-to-pay processes does a document belong to?
C12
What are the documents in a purchase-to-pay process?
C13
Which items on invoices have the colors red and blue?
C14
To which addresses an organization ordered an item?
C15
Which and how many items an organization sold in cities with more than 50 000 inhabitants?
3
P2P-O: The Purchase-To-Pay Ontology
3.1
Methodology of the Developing Process
Because EN16931 [10] was the main non-ontological resource for developing P2PO, we followed the NeOn methodology [32] since it provides established guidelines for this exact scenario. Additionally, we incorporated advice from Gr¨ uninger and Fox [15], Hitzler et al. [18] and McDaniel and Storey [25]. For publishing P2P-O, we followed FAIR principles [33]. The iterative process for developing P2P-O is depicted in Fig. 2. At first, we specified requirements, scope and competency questions together with domain experts from the TRAFFIQX network4 (examples in Table 1). The set of competency questions has been derived from the requirement specification in EN16931 [10] and has been then enriched. Classes and properties for potential use have subsequently been derived from EN16931 [10] until a conceptual model was achieved. Lessons learned from conversations with experts were, for example, which elements on invoices are frequently used and how P2P-O needs to be designed to allow for common extensions. To reuse ontologies and to incorporate them into P2P-O, we applied, in addition to guidelines in the NeOn methodology [32], the validation process for ontologies suggested by McDaniel and Storey [25]. Accordingly, we verified the adequacy of ontologies based on our requirements, and we assessed them by means of OOPS! (OntOlogy Pitfall Scanner!) [29] and OntoDebug [31]. These tools have also been employed for P2P-O’s evaluation. 4
https://www.traffiqx.net/en/about-us.
652
3.2
M. Schulze et al.
General Modeling Process
This section describes the general modeling process with the core invoice model [10] as its basis. More detailed modeling aspects are addressed in the respective ontology modules in Sect. 3.3. Each column of the core invoice model (Sect. 2.2) has been implemented as follows. For the ID of information elements, we introduced the annotation property seeEN16931-1-2017 so that resources in P2P-O are linked to information elements in EN16931 [10]. This way, it is also possible to query these elements to see how they are modeled in P2P-O. As a result, modeling decisions can be traced from the original invoice model to the ontology and backwards. For the “Business Term” in EN16931 [10], rdfs:label is used and for the “Description”-column rdfs:comment. Usage Notes, however, are modeled with the annotation property usage note from FIBO [3]. Cardinality statements were encoded with OWL class restrictions. For the data type Text in EN16931 [10], xsd:string was used. This was also used for the type Code because it only consists of one text field [10]. However, for the identifier datatype in EN16931 also information regarding the identifier scheme and its version is needed [10]. Therefore, we modeled it as a dedicated class Identifier rather than as a property like in Schema.org [16] or DCMI Metadata Terms [5]. 3.3
Ontology Description
P2P-O comprises seven modules, 54 classes, 169 properties and 1438 axioms. Table 2 summarizes reused ontologies and vocabularies. An important requirement for reusing ontologies was that a permissive license has been specified. To not clutter P2P-O, only selected statements are reused instead of importing entire ontologies. This was especially problematic in the case of FIBO [3] due to long import chains. Figure 3 illustrates an excerpt of P2P-O’s schema which will be referred at appropriate places in the following remarks on the various modules. Table 2. Reused ontologies and vocabularies in P2P-O. Prefix
Namespace
Source
vcard
http://www.w3.org/2006/vcard/ns#Address
[42]
fibo-fnd-
https://spec.edmcouncil.org/fibo/ontology/FND/.
[3]
omg
https://www.omg.org/spec/LCC/Countries/CountryRepresentation/ [28]
foaf
http://xmlns.com/foaf/0.1/
[34]
org
http://www.w3.org/ns/org#
[41]
xsd
http://www.w3.org/2001/XMLSchema
[37]
ontodebug http://ainf.aau.at/ontodebug#
[31]
skos
http://www.w3.org/2004/02/skos/core#
[35]
dcterms
http://purl.org/dc/terms
[5]
owl
http://www.w3.org/2002/07/owl#
[36]
rdf
http://www.w3.org/1999/02/22-rdf-syntax-ns#
[39]
rdfs
http://www.w3.org/2000/01/rdf-schema#
[40]
P2P-O: A Purchase-To-Pay Ontology for Enabling Semantic Invoices
Requirements Specification - Purpose and Scope - Use cases - Competeny Questions - Pre-glossary of terms based on EN16931 [10]
Reusing EN16931 - Analyzed standard and identified elements for reuse - Created conceptional model - Implementation in OWL
Reusing Ontologies - Searched ontologies - Evaluated and selected ontologies - Included ontologies
Restructuring P2P-O - Pruned P2P-O - Modularized into 7 modules
653
Evaluating P2P-O -OOPS! [29] -With OntoDebug [31] -Build knowledge graphs and evaluated compe -tency questions - SPARQL [38] queries
Fig. 2. Methodology for developing P2P-O based on the NeOn methodology [32] p2p-o-item:Item
p2p-o-proc:PurchaseToPayProcess
hasIt
0..n
1
0..n
p2p-o-inv:Invoice
sent/received
hasTotalLineNetAmount
fibo-fnd-acc-cur:AmountOfMoney
1
1..n
1
1
1
1
hasSeller
ent
hasBuyer hasLineNetAmount hasNetPriceOfItem
Elem
p2p-o-doc-line:InvoiceLine
o cess
hasInvoiceLine
hasPr
em
p2p-o-item:ItemAttribute
hasPro cessElement1..n
1
hasAttribute
org:FormalOrganization
Fig. 3. Excerpt of classes and their relationships in P2P-O. AmountOfMoney [3] and FormalOrganization [41] are reused.
Module item. The item module allows the description of specific items or products listed on invoices. The term “item” not only refers to a specific traded product, for example a printer, but to anything that can be listed on invoices, for example a working hour. In the purchase-to-pay domain, the term “item” is according to domain experts and EN16931 [10] the preferable one opposed to the term “product”. However, the term “product” is also commonly used interchangeably and therefore included as a synonym for item. According to EN16931 [10], it is only required for an item to have a name, but it can optionally
654
M. Schulze et al.
have attributes as well. To easily enable queries such as “retrieve all leitems on invoices with the colors red and blue” (Table 1), an attribute is modeled as a separate class named ItemAttribute (Fig. 3). If an item does have such an attribute, this attribute must have one name (e.g. color) and one value (e.g. red) [10]. Module price. With the price module, it is not only possible to describe prices of items but also to make statements about monetary amounts on invoices, such as the total amount with value added tax. Consequently, the class AmountOfMoney, which is reused from FIBO [3], is extensively used across P2P-O (Fig. 3). In contrast to EN16931’s implications [10], we have decided not to link the currency-property directly to the Invoice-class but to the AmountOfMoney-class. In our view, this is semantically more appropriate, opens opportunities for reuse and includes the flexibility for stating that the amount of the total value added tax might be in another currency. All other instances of AmountOfMoney in the same invoice must still link to the same currency [10]. Module documentline. The documentline module is responsible for lines or positions on a document. As a core function, it enables to make statements about prices and quantities of items listed on documents. Therefore, it imports the modules item and price. As implied by EN16931 [10], a document line in P2P-O has exactly one item, which is expressed by the hasItem-property (Fig. 3). The assured one-to-one relationship between DocumentLine and Item is essential to relate statements on document line level unambiguously to a corresponding item. Prices about items are made in this module rather than in the item module. This allows the expression of more than one price for an item and the traceability of prices to the context of a transaction. Module organization. The organization module is for describing organizations participating in purchase-to-pay processes. It heavily reuses vocabularies from other ontologies because adequate solutions for our purposes already existed. For instance, this module includes FormalOrganization from The Organization Ontology [41] and Address from the vCard Ontology [42]. The BusinessRelationship-class is intended to describe a dyadic business relationship. Organizations are linked to a business relationship via the hasCustomer - and hasSupplier property. BusinessRelationship is not implied by EN16931 [10] but introduced in P2P-O. It is useful to make statements about typical characteristics of a business relationship, such as customer or supplier numbers. These are indeed specified by EN16931 but on the document level [10]. Module document. The document module provides classes and properties that are essential for purchase-to-pay documents in general. For more granular vocabulary regarding invoices, which are special kinds of documents, we created a separate module. A document could have been sent or received by an organization. In P2P-O this is expressed by the properties sent and received. Because information about organizations is needed, the organization module is imported. Cross-references between documents can be expressed by using the references object property.
P2P-O: A Purchase-To-Pay Ontology for Enabling Semantic Invoices
655
Module invoice. Because of the focus of P2P-O on invoices, the invoice module is the largest sub-module. It imports the modules document and documentline directly and therefore all other previously introduced modules indirectly as well. It extends the taxonomy of the document module and provides more granular vocabulary for kinds of invoices such as E-FinalInvoice and EPartialInvoice. To distinguish credit notes from ordinary invoices, E-CreditNote and E-CommercialInvoice are made disjoint. Therefore, for ordinary invoices, we recommend to use the class E-CommercialInvoice instead of the class E-Invoice. Furthermore, this module implements all constraints an invoice must satisfy according to EN16931 [10]. For instance, it must have exactly one seller and one buyer. Particular total amounts are mandatory, like the amounts with and without value added tax. Not mandatory information, such as the allowance amount, are provided as well. An invoice also needs to have at least one instance of the class InvoiceLine (Fig. 3), which is modeled as a subclass of DocumentLine. In P2P-O this is expressed by the hasInvoiceLine-property. Information on invoice line level can be thus related unambiguously to information on invoice level, such as the seller and buyer. Module process. According to process requirements in EN16931 [10], the process module provides classes for describing specific kinds of purchase-to-pay processes. These are, for instance, a process in which invoiced items are purchased periodically or the payment amount due is paid in advance. These classes are not modeled as disjoint to each other because an instance of a purchase-topay process might fit more than those classes [10]. For example, a process may include both, a paying upfront and a corrective invoicing process. Documents and purchase-to-pay processes are linked via the hasProcessElement-property and the inverse property isProcessElementIn (Fig. 3). With the properties followsDocument and precedesDocument, it is further possible to express that a document precedes or follows another document in a process. 3.4
Availability and Maintenance
P2P-O is available at https://purl.org/p2p-o and its accompanying resources at https://purl.org/p2p-o#res. For publishing and documenting the ontology, we used WIDOCO [12] to stick to open standards and best practices. Also, resources for building knowledge graphs with P2P-O are made available (e.g. RML mappings [7]) as well as an invoice generator for test and evaluation purposes. Because P2P-O should be easily reusable and adoptable by organizations, the ontology is published under a business friendly permissive license. Every module of P2P-O has its own version number. When a module becomes backwards incompatible, which we try to avoid, it will be annotated accordingly. The ontology is maintained by a focus group composed of researchers at DFKI5 and domain experts from the TRAFFIQX6 network. In monthly meetings, P2P-O related topics, issues and applications are discussed. Because of this 5 6
https://comem.ai. https://www.traffiqx.net/en/about-us.
656
M. Schulze et al.
research-industry cooperation, P2P-O and its accompanying resources aim to contribute to the adoption of semantic web technologies, especially the adoption in SMEs by considering their particular challenges. 3.5
Reusability
Because P2P-O is grounded in the core invoice model of EN16931 [10], it is designed to cover the most common purchase-to-pay processes and invoices, and it is also extendable to more specific information needs. This is essential because information needs in the purchase-to-pay domain can vary depending on the concrete application scenario. For instance, in the manufacturing sector, detailed information on invoiced products is valuable, whereas in the service sector, information in supporting documents of an invoice is more important. Whereas in the presented use case in Sect. 4.3 only a small subset of purchaseto-pay documents in the TRAFFIQX network have been lifted up to linked data, the transaction volume alone in this network amounts to 40 million per year. Globally, according to Billentis [22], 55 billion e-invoices have been processed in 2019 and the tendency is rising. Noteworthy, P2P-O not only covers e-invoices but also related documents in respective purchase-to-pay processes. For easier reuse, P2P-O is modularized and documented with WIDOCO [12].
4
Evaluation and Use Case
4.1
Evaluation Based on Ontology Evaluation Tools
To ensure that P2P-O is aligned with current ontology engineering standards, it was iteratively tested against best practices formulated by OOPS! (OntOlogy Pitfall Scanner!) [29]. This tool was in particular valuable for identifying issues concerning modeling inverse relationships and providing a license. To ensure that P2P-O is correct and consistent even when users extend it, the OntoDebug [31] plugin in Prot´eg´e [26] was used to annotate test cases and to debug P2P-O. 4.2
Evaluation by Constructing and Querying a Purchase-To-Pay Knowledge Graph
On the one hand, we evaluated P2P-O with real-world invoices from the TRAFFIQX network (see Sect. 4.3), which may not be published. On the other hand, to provide a publicly available data set, we evaluated P2P-O with generated testinvoices from our invoice-generator. With this generator it is possible to produce invoices and credit notes in different syntaxes, such as UBL v2.17 . These invoices are inspired by the real ones and are in XML.
7
https://www.iso.org/standard/66370.html.
P2P-O: A Purchase-To-Pay Ontology for Enabling Semantic Invoices
657
To construct purchase-to-pay knowledge graphs for evaluating competency questions (Sect. 3.1), we created tailored RML mappings [7] with the use of the CARML extension8 . It was additionally used because of its ability to deal with namespaces. Thus, we transformed heterogeneous XML-based invoices into semantic invoices. With provided RML mappings, organizations can immediately start experimenting with P2P-O and building purchase-to-pay knowledge graphs. Figure 4 illustrates a part of a constructed knowledge graph in GraphDB9 . Shown is an excerpt of two invoices (0815-9923-1-a, 08315-932291-a) and their relations to each other. Our RML mappings only assert that, for instance, an invoice line has an item; but because of enabled inference, the inverse property isItemOf is also available to traverse and query the knowledge graph. To evaluate competency questions (Table 1), we executed respective SPARQL [38] queries. Listing 1.1 illustrates the federated query for retrieving items sold in cities with more than 50 000 inhabitants (competency question C15 in Table 1).
Fig. 4. Screenshot of two synthetic sample invoices in a purchase-to-pay knowledge graph in GraphDB (https://www.ontotext.com/products/graphdb/).
4.3
Use Case: Applying P2P-O in a Corporate Memory System
After applying artificially generated invoices (Sect. 4.2), we employed real-world invoices from the TRAFFIQX network. This network utilizes an internal intermediate format for their invoices which we exploited to convert 2000 of them into semantic invoices. This enabled the use within a knowledge description 8 9
https://github.com/carml/carml. https://www.ontotext.com/products/graphdb/.
658
M. Schulze et al.
Listing 1.1. Federated SPARQL [38] query for items sold in cities with more than 50 000 inhabitants by using P2P-O’s vocabulary and DBpedia [2]. PREFIX p2po−i n v : PREFIX p2po−l i n e : PREFIX p2po−o r g : PREFIX r d f : PREFIX r d f s : PREFIX dbo : s e l e c t ∗ where { p2po−i n v : i s S e l l e r I n ? inv . ? i n v p2po−i n v : h a s B u y e r A d d r e s s ? b u y e r A d d r e s s ; p2po−i n v : h a s I n v o i c e L i n e ? i n v L i n e . ? i n v L i n e p2po−l i n e : h a s I t e m ? i t e m ; p2po−l i n e : l i n e I n v o i c e d Q u a n t i t y ? q t y ; p2po−l i n e : hasLineNetAmount ? lineNetAmount . ? item r d f s : l a b e l ? itemLabel . ? lineNetAmount r d f s : l a b e l ? amountLabel . ? b u y e r A d d r e s s p2po−o r g : h a s C i t y ? c i t y . ? city rdfs : label ? cityLabel . SERVICE { ? dbCity a ?dbO ; rdfs : label ? cityLabel . ? dbCity dbo : p o p u l a t i o n T o t a l ? p o p u l a t i o n . FILTER ( ( ? dbO = dbo : C i t y | | ?dbO = dbo : P o p u l a t e d P l a c e ) && ? p o p u l a t i o n > 5 0 0 0 0 ) }}
layer of a corporate memory such as the DFKI CoMem10 . CoMem is a corporate memory infrastructure realizing knowledge-based services using enterprise and personal knowledge graphs. With the Semantic Desktop ecosystem, it embeds these services into knowledge workers’ working environments [23,24]. Therefore, P2P-O was published in the CoMem ontology server. A converter was added to the CoMem semantification service which then allowed populating knowledge graphs in CoMem’s knowledge base. This enabled the usage of CoMem’s existing knowledge services, such as proactive information delivery, semantic search, or ontology-based named entity recognition [20]. Thus, as a use case for a P2P-O-based knowledge service, we implemented a context-specific dashboard within CoMem. With widgets, the user can now grasp context-specific information of an entity, such as items on an invoice (Fig. 5). From those widgets, a user can browse to other resources to see the knowledge space from those resources with other respective context-specific widgets.
10
https://comem.ai.
P2P-O: A Purchase-To-Pay Ontology for Enabling Semantic Invoices
659
Fig. 5. Excerpt from the context-specific dashboard within CoMem with synthetic sample data.
5
Comparison to Related Resources
Semantic technologies in e-procurement, which includes purchase-to-pay processes, are widely recognized for integrating heterogeneous data [30]. In subdomains of e-procurement such as e-awarding [30], ontologies and knowledge services have been successfully applied. For instance, the LOTED2 ontology [8] for tenders. Neˇcask´ y et al. [27] present an ontology-based knowledge service for filling out contracts. In purchase-to-pay processes, however, although knowledge work is essential [19], ontology-based knowledge services are largely neglected. The work of Escobar-Vega et al. [11] addresses semantic invoices in particular. Their approach is to create an ontology out from Mexican electronic invoices with XSL Transformations. Therefore, this approach is rather document-oriented. Resources for creating semantic invoices and the ontology are not publicly available. FIBO [3] is an established ontology in the field of finance with a broad scope. It provides, for instance, vocabulary for loans and investments but not for invoices or purchase-to-pay processes. Likewise, GoodRelations [17] is an established ontology but in the field of e-commerce. It is well-suited to describe offers, products and prices. However, it also does not cover invoice specific vocabulary such as “item” and “invoice line” or a taxonomy for purchase-to-pay documents because this is not in the scope of GoodRelations. The upcoming e-procurement ontology11 is an endeavor of the European Union towards a uniform vocabulary in the public e-procurement domain. In the current version 2.0.0, the concept of invoice and alike is also missing. Schema.org [16] provides invoiceto related
11
https://github.com/eprocurementontology/eprocurementontology.
660
M. Schulze et al.
vocabulary. P2P-O may be able to extend it with more detailed vocabulary necessary for invoice processing as well as with vocabulary that allows to relate invoices purchase-to-pay processes. Thus, vocabulary is provided that conceives invoices as part of such processes. The Aggregated Invoice Ontology12 , a dedicated invoice ontology, is not accessible and thus not reusable anymore. However, it was constructed for a pharmaceutical case study and shows the merits and the need of shared invoice vocabulary [13,14].
6
Conclusion and Future Work
Owing to the shortcoming of dedicated purchase-to-pay ontologies, P2P-O was presented, a modularized ontology which reuses the core invoice model of the European Standard EN16931 [10]. To evaluate competency questions, a purchaseto-pay knowledge graph with RML [7] technologies has been constructed and corresponding SPARQL [38] queries executed. In contrast to other contributions, we also provided ready-to-use resources to enable organizations to generate semantic invoices. With a context-specific dashboard, a P2P-O-based knowledge service was illustrated. Its assistance allows an entity-centric view on invoice data by browsing a purchase-to-pay knowledge graph. Future research will focus on enhancing this assistance by applying P2P-O in real-time assistance scenarios and by incorporating other purchase-to-pay data such as business e-mails. Acknowledgements. This work was funded by the Investitions- und Strukturbank Rheinland-Pfalz (ISB) (project InnoProm) and the BMBF project SensAI (grantno. 01IW20007).
References 1. Abecker, A., Bernardi, A., Hinkelmann, K., K¨ uhn, O., Sintek, M.: Toward a technology for organizational memories. IEEE Intell. Syste. 13, 40–48 (1998) 2. Auer, S., Bizer, C., Kobilarov, G., Lehmann, J., Cyganiak, R., Ives, Z.: DBpedia: a nucleus for a web of open data. In: Abere, K., et al. (eds.) ASWC/ISWC -2007. LNCS, vol. 4825, pp. 722–735. Springer, Heidelberg (2007). https://doi.org/10. 1007/978-3-540-76298-0 52 3. Bennett, M.: The financial industry business ontology: best practice for big data. J. Bank. Regu. 14(3), 255–268 (2013) 4. Capgemini Consulting: Sepa: potential benefits at stake (2007). https://www. cep.eu/fileadmin/user upload/cep.eu/Analysen KOM/KOM 2009 471 SEPA/ Capgemini-Report on SEPA engl. .pdf. Accessed 18 Dec 2020 5. DCMI Usage Board: DCMI Metadata Terms (2006). https://www.dublincore.org/ specifications/dublin-core/dcmi-terms/2006-12-18/. Accessed 18 Dec 2020 6. Dengel, A., Maus, H.: Personalisierte wissensdienste: das unternehmen denkt mit. IM+io Fachmagazin 3, 46–49 (2018)
12
http://ontologydesignpatterns.org/wiki/Ontology:Aggregated Invoice Ontology.
P2P-O: A Purchase-To-Pay Ontology for Enabling Semantic Invoices
661
7. Dimou, A., Sande, M.V., Colpaert, P., Verborgh, R., Mannens, E., de Walle, R.V.: RML: a generic language for integrated RDF mappings of heterogeneous data. In: Proceedings of the Workshop on Linked Data on the Web Co-located with the 23rd International World Wide Web Conference on CEUR Workshop Proceedings, vol. 1184. CEUR-WS.org (2014) 8. Distinto, I., d’Aquin, M., Motta, E.: Loted2: an ontology of European public procurement notices. Semant. Web 7(3), 267–293 (2016) 9. Ehrlinger, L., W¨ oß, W.: Towards a definition of knowledge graphs. In: Proceedings of the Posters and Demos Track of the 12th International Conference on Semantic Systems - SEMANTiCS2016. CEUR Workshop Proceedings, vol. 1695. CEURWS.org (2016) 10. EN 16931–1:2017: Electronic invoicing - part 1: Semantic data model of the core elements of an electronic invoice. Standard, European Committee for Standardization (2017) 11. Escobar-Vega, L.M., Zaldivar-Carrillo, V., Villalon-Turrubiates, I.: Semantic invoice processing. J. Intell. Fuzzy Syst. 34, 2913–2922 (2018) 12. Garijo, D.: WIDOCO: a wizard for documenting ontologies. In: d’Amato, C., et al. (eds.) Widoco: a wizard for documenting ontologies, Part II. LNCS, vol. 10588, pp. 94–102. Springer, Cham (2017). https://doi.org/10.1007/978-3-319-68204-4 9 13. G´ omez-P´erez, J.M., M´endez, V.: Towards supporting interoperability in e-invoicing based on semantic web technologies. In: Handbook of Research on E-Business Standards and Protocols: Documents, Data and Advanced Web Technologies, pp. 705–724. IGI Global (2012) 14. G´ omez-P´erez, J.M., M´endez, V., Candini, J., Mu˜ noz, J.C.: Electronic invoice management in the pharmaceutical sector: the pharmainnova case. In: Su´ arez-Figueroa, M.C., G´ omez-P´erez, A., Motta, E., Gangemi, A. (eds.) Ontology Engineering in a Networked World, pp. 407–422. Springer, Heidelberg (2012). https://doi.org/10. 1007/978-3-642-24794-1 19 15. Gr¨ uninger, M., Fox, M.S.: The role of competency questions in enterprise engineering. In: Rolstad˚ as, A. (ed.) Benchmarking — Theory and Practice. IAICT, pp. 22–31. Springer, Boston, MA (1995). https://doi.org/10.1007/978-0-387-34847-6 3 16. Guha, R.V., Brickley, D., Macbeth, S.: Schema.org: evolution of structured data on the web. Commun. ACM 59(2), 44–51 (2016) 17. Hepp, M.: GoodRelations: an ontology for describing products and services offers on the web. In: Gangemi, A., Euzenat, J. (eds.) EKAW 2008. LNCS (LNAI), vol. 5268, pp. 329–346. Springer, Heidelberg (2008). https://doi.org/10.1007/9783-540-87696-0 29 18. Hitzler, P., Gangemi, A., Janowicz, K., Krisnadhi, A., Presutti, V. (eds.): Ontology Engineering with Ontology Design Patterns - Foundations and Applications, Studies on the Semantic Web, vol. 25. IOS Press (2016) 19. Jain, K., Woodcock, E.: A road map for digitizing source-to-pay (2017). https:// www.mckinsey.com/business-functions/operations/our-insights/a-road-map-fordigitizing-source-to-pay. Accessed 18 Dec 2020 20. Jilek, C., Schr¨ oder, M., Novik, R., Schwarz, S., Maus, H., Dengel, A.: Inflectiontolerant ontology-based named entity recognition for real-time applications. In: 2nd Conference on Language, Data and Knowledge (LDK 2019), Leipzig, Germany, 20– 23 May 2019. OpenAccess Series in Informatics (OASIcs), vol. 70, pp. 11:1–11:14. Schloss Dagstuhl - Leibniz-Zentrum f¨ ur Informatik (2019)
662
M. Schulze et al.
21. Jilek, C., Schr¨ oder, M., Schwarz, S., Maus, H., Dengel, A.: Context spaces as the cornerstone of a near-transparent and self-reorganizing semantic desktop. In: Gangemi, A., et al. (eds.) ESWC 2018. LNCS, vol. 11155, pp. 89–94. Springer, Cham (2018). https://doi.org/10.1007/978-3-319-98192-5 17 22. Koch, B.: The e-invoicing journey 2019–2025 (2019). https://www.billentis.com/ The einvoicing journey 2019-2025.pdf. Accessed 18 Dec 2020 23. Maus, H., Jilek, C., Schwarz, S.: Remembering and forgetting for personal preservation. In: Mezaris, V., Nieder´ee, C., Logie, R.H. (eds.) Personal Multimedia Preservation. SSCC, pp. 233–277. Springer, Cham (2018). https://doi.org/10.1007/9783-319-73465-1 7 24. Maus, H., Schwarz, S., Dengel, A.: Weaving personal knowledge spaces into office applications. In: Fathi, M. (ed.) Integration of Practice-Oriented Knowledge Technology: Trends and Prospectives, pp. 71–82. Springer, Berlin (2013). https://doi. org/10.1007/978-3-642-34471-8 6 25. McDaniel, M., Storey, V.C.: Evaluating domain ontologies: clarification, classification, and challenges. ACM Comput. Surv. 52(4), 70:1–70:44 (2019) 26. Musen, M.A.: The prot´eg´e project: a look back and a look forward. AI Matters 1(4), 4–12 (2015) 27. Neˇcask´ y, M., Kl´ımek, J., Mynarz, J., Knap, T., Sv´ atek, V., St´ arka, J.: Linked data support for filing public contracts. Comput. Ind. 65(5), 862–877 (2014) 28. Object Management Group (OMG): Languages, Countries And Codes Specification Version 1.1 (2020). https://www.omg.org/spec/LCC/About-LCC/. Accessed 18 Dec 2020 29. Poveda-Villal´ on, M., G´ omez-P´erez, A., Su´ arez-Figueroa, M.C.: Oops! (ontology pitfall scanner!): an on-line tool for ontology evaluation. Int. J. Semant. Web Inf. Syst. (IJSWIS) 10(2), 7–34 (2014) ´ Gayo, J.E.L., de Pablos, P.O.: New trends on e-procurement 30. Rodr´ıguez, J.M.A., applying semantic technologies: current status and future challenges. Comput. Ind. 65(5), 800–820 (2014) 31. Schekotihin, K., Rodler, P., Schmid, W.: OntoDebug: interactive ontology debugging plug-in for prot´eg´e. In: Ferrarotti, F., Woltran, S. (eds.) FoIKS 2018. LNCS, vol. 10833, pp. 340–359. Springer, Cham (2018). https://doi.org/10.1007/978-3319-90050-6 19 32. Su´ arez-Figueroa, M.C., G´ omez-P´erez, A., Fern´ andez-L´ opez, M.: The NeOn methodology for ontology engineering. In: Su´ arez-Figueroa, M.C., G´ omez-P´erez, A., Motta, E., Gangemi, A. (eds.) Ontology Engineering in a Networked World, pp. 9–34. Springer, Heidelberg (2012). https://doi.org/10.1007/978-3-642-2479412 33. Wilkinson, M.D., et al.: The fair guiding principles for scientific data management and stewardship. Sci. Data 3(1), 160018 (2016) 34. World Wide Web Consortium: FOAF Vocabulary Specification 0.99 (2004). http:// xmlns.com/foaf/0.1/. Accessed 18 Dec 2020 35. World Wide Web Consortium: SKOS Simple Knowledge Organization System Reference (2009). http://www.w3.org/TR/skos-reference/. Accessed 18 Dec 2020 36. World Wide Web Consortium: OWL 2 Web Ontology Language Primer (Second Edition) (2012). http://www.w3.org/TR/owl2-overview/. Accessed 18 Dec 2020 37. World Wide Web Consortium: W3C XML Schema Definition Language (XSD) 1.1 Part 1: Structures (2012). https://www.w3.org/TR/2012/REC-xmlschema111-20120405/. Accessed 18 Dec 2020 38. World Wide Web Consortium: SPARQL 1.1 Query Language (2013). https://www. w3.org/TR/sparql11-query/. Accessed 18 Dec 2020
P2P-O: A Purchase-To-Pay Ontology for Enabling Semantic Invoices
663
39. World Wide Web Consortium: RDF 1.1 Primer (2014). http://www.w3.org/TR/ 2014/NOTE-rdf11-primer-20140624/. Accessed 18 Dec 2020 40. World Wide Web Consortium: RDF Schema 1.1 (2014). http://www.w3.org/TR/ 2014/REC-rdf-schema-20140225/. Accessed 18 Dec 2020 41. World Wide Web Consortium: The Organization Ontology (2014). http://www. w3.org/TR/vocab-org/. Accessed 18 Dec 2020 42. World Wide Web Consortium: vCard Ontology - for describing People and Organizations (2014). http://www.w3.org/TR/vcard-rdf/. Accessed 18 Dec 2020
KOBE: Cloud-Native Open Benchmarking Engine for Federated Query Processors Charalampos Kostopoulos, Giannis Mouchakis, Antonis Troumpoukis, Nefeli Prokopaki-Kostopoulou, Angelos Charalambidis , and Stasinos Konstantopoulos(B) Institute and Informatics and Telecommunications, NCSR “Demokritos”, Agia Paraskevi, Greece {b.kostopoulos,gmouchakis,antru,nefelipk, acharal,konstant}@iit.demokritos.gr
Abstract. In the SPARQL query processing community, as well as in the wider databases community, benchmark reproducibility is based on releasing datasets and query workloads. However, this paradigm breaks down for federated query processors, as these systems do not manage the data they serve to their clients but provide a data-integration abstraction over the actual query processors that are in direct contact with the data. As a consequence, benchmark results can be greatly affected by the performance and characteristics of the underlying data services. This is further aggravated when one considers benchmarking in more realistic conditions, where internet latency and throughput between the federator and the federated data sources is also a key factor. In this paper we present KOBE, a benchmarking system that leverages modern containerization and Cloud computing technologies in order to reproduce collections of data sources. In KOBE, data sources are formally described in more detail than what is conventionally provided, covering not only the data served but also the specific software that serves it and its configuration as well as the characteristics of the network that connects them. KOBE provides a specification formalism and a command-line interface that completely hides from the user the mechanics of provisioning and orchestrating the benchmarking process on Kubernetes-based infrastructures; and of simulating network latency. Finally, KOBE automates the process of collecting and comprehending logs, and extracting and visualizing evaluation metrics from these logs. Keywords: Benchmarking Cloud-native
1
· Federated query processing ·
Introduction
Data federation and distributed querying are key technologies for the efficient and scalable consuming of data in the decentralized and dynamic environment c Springer Nature Switzerland AG 2021 R. Verborgh et al. (Eds.): ESWC 2021, LNCS 12731, pp. 664–679, 2021. https://doi.org/10.1007/978-3-030-77385-4_40
KOBE: Cloud-Native Open Benchmarking Engine
665
of the Semantic Web. Several federation systems have been proposed [2,4,10], each with their own characteristics, strengths, and limitations. Naturally, consistent and reproducible benchmarking is a key enabler of the relevant research, as it allows these characteristics, strengths, and limitations to be studied and understood. There are several benchmarks that aim to achieve this, but, similarly to the wider databases community, to release a benchmark amounts to releasing datasets, query workloads, and, at most, a benchmark-specific evaluation engine for executing the query load [5,8,9]. Research articles using these benchmarks need to specify what software has been used to implement the SPARQL endpoints, how it has been configured and distributed among hardware nodes, and the characteristics of these nodes and of the network that connects them to the federation system. Reproducing an experiment from such a description is a challenging and tedious task. Based on our own experience with federated query processing research we have been looking for ways to minimize the effort required and the uncertainty involved in replicating experimental setups from the federated querying literature. Our first step in that direction was to complement a benchmark we previously proposed [11] with Docker images of the populated triple store installations and of the federation systems used for that work. In this paper we present KOBE,1 an open-source2 benchmarking engine that reads benchmark definitions and handles the distributed deployment of the data sources and the actual execution of the experiment. This includes instantiating a data source from dataset files, configuring and initializing the federation engine, connecting them into a virtual network with controlled characteristics, executing the experiment, and collecting the evaluation results. The main objective of KOBE is to provide a generic and controlled benchmarking framework where any combination of datasets, query loads, querying scenarios, and federation engines can be tested. To meet this goal, KOBE leverages modern Cloud-native technologies for the containerization and orchestration of different components. In this paper we will first introduce the core concepts of a federated query processing experiment and the requirements for consistently and reproducibly carrying out such experiments (Sect. 2) and then present KOBE, its system components and how experiments are provisioned and orchestrated (Sect. 3). We then discuss how logs are collected and evaluation metrics visualized (Sect. 4), and how users can extend the library of benchmarks and federation engines to prepare their own experiments (Sect. 5). We close with a comparison to related systems (Sect. 6), conclusions and future work (Sect. 7).
2
Benchmarking Concepts and Requirements
We start by discussing the requirements for a benchmarking experiment of a federated query processor. First, we briefly introduce the main concepts of a federated query processing experiment: 1 2
Previously demonstrated in ISWC 2020, with extended abstract proceedings [6]. See https://github.com/semagrow/kobe.
666
C. Kostopoulos et al.
Data source: An endpoint that processes queries. A data source is characterized by a dataset label, with data sources characterized by the same dataset serving the exact same data. Benchmark: A collection of data sources, the latency and throughput of these data sources, and a list of query strings. Benchmarks are defined independently of the federator that is being benchmarked. Federator: A federated query processor that provides a single endpoint to achieve uniform and integrated access to the data sources. Experiment run: A specific experiment, where (a) a specific federator has been configured to be able to connect to the data sources foreseen by the benchmark; and (b) the query load foreseen by the benchmark has been applied to the federator. Experiment: The repetition of multiple runs of the same benchmark. An experiment is stateful, in the sense that the federator and data source instances are not terminated and maintain their caches and, in general, their state between runs. Having these elements in place allows for the following tests, commonly used to evaluate query processing systems in general and federated query processing systems in particular: – Comparing the first run for a query against subsequent runs; to understand the effect of caching. – Observing if performance degrades for large numbers of runs by comparison to smaller numbers of runs; to understand if there are memory leaks and other instabilities. – Observing if performance degrades for large numbers of experiments executed concurrently; to perform stress-testing. – Comparing the performance of the same federation engine, on the same datasets, over different data sources; to understand the effect of current load, implicit response size limits, allocated memory, and other specifics of the query processing engines that implement the data sources. – Comparing the performance of different federation engines on the same experiment; to evaluate federation engines. Based on the above, we will now proceed to define the requirements for a benchmarking system that supports automating the benchmarking process. 2.1
Data Source Provisioning
In order to reliably reproduce evaluation results, there are several parameters of the data source implementation that need to be controlled as they affect evaluation metrics. These include the software used to implement the SPARQL endpoint and its configuration, the memory, processing power, disk speed of the server where it executes, the quality of the network connection between the data server and the federation engine, etc.
KOBE: Cloud-Native Open Benchmarking Engine
667
Replicating a specific software stack and its configuration can be captured by virtualization and containerization technologies, so we require that a benchmarking engine use recipes (such as a Dockerfile for Docker containers) that prepare each endpoint’s execution environment. The characteristics of the computing infrastructure where the data service executes and of the network connection between the data service and the federation engine can be naturally aggregated as the latency and throughput at which the federation engine receives data from it. So, one requirement from benchmarking engines is that latency and throughput can be throttled to a maximum, although other conditions might make a data service even less responsive than these maxima: e.g., a data source might be processing an extremely demanding query or might be serving many clients in a stress test scenario. Based on this observation, we require that benchmarking engines allow the experiment description to include the latency and throughput between the data sources and the federation. And, in fact, that these parameters are specific to each data source. Technically, this requires that the architecture foresees a configurable proxy between the federator and each data source, so that each experiment can set this parameter to simulate the real behaviour of SPARQL query processors. Naturally, this is in addition to the obvious requirement to control the data served and the way that data is distributed between data services. 2.2
Sequential and Concurrent Application of Query Workload
The benchmarking engine should automate the process of applying a query load to the federation engine. The queries that make up the query load should be applied either sequentially to evaluate performance on different queries or concurrently to stress-test the system. Technically, a benchmarking system should include an orchestrator that can read such operational parameters from the experiment definition and apply them when serving as a client application for the federation engine. 2.3
Logs Collection and Analysis
One important requirement of a benchmarking system is that the experimenter can have easy access on several statistics and key performance indicators of each conducted experiment. An effective presentation of such indicators can offer to the experimenter the ability to compare the performance of different setups of the same benchmark (e.g., different federators or data sources) and to draw conclusions for a specific setup by examining time measurements for each phase of the query processing and several other metrics. Metrics that are important for the experimenter to analyze the effectiveness of a federator in a specific benchmark, include the following: – The number of returned results can be used to validate the correctness of the query processing by verifying that the federator returns the expected number
668
C. Kostopoulos et al.
of results. Naturally, this validation is incomplete as the results might have the correct cardinality and still be different from the correct ones. However, many errors can be very efficiently caught by simply comparing cardinalities before proceeding to the detailed comparison. – The total time to receive the complete result set indicates how the engine performs overall from the perspective of the client. This is the most common key indicator that most benchmarks consider. – Although different federated query processing architectures have been proposed, there is some convergence on source selection, query planning, and query execution as beeing the main query processing phases. Regardless of whether these phases execute sequentially or are adaptive and their execution is interwined, the breakdown of the query processing time into phases provides the experimenter with insights regarding the efficiency of the federation engine and how it can be improved. – The number of sources accessed during processing a specific query can be used to evaluate the effectiveness of source selection in terms of excluding redundant sources from the execution plan. The aforementioned key performance indicators can be computed by different pieces of software during an experiment execution. For instance, the first two metrics of the above list should be computed by the evaluator (i.e., the software that poses the queries to the federator), while the last two metrics can be computed only by the federation engine itself. In order for these metrics to be available to the experimenter, the benchmarking system must collect and process the log lines emitted by the federation engine and the other components. This will produce an additional requirement on the compatible format of the log lines of the systems under test.
3
The KOBE System
The KOBE Benchmarking Engine (KOBE) is a system that aims to provide an extensible platform to facilitate benchmarking on federated query processing. It was designed with the following objectives in mind: 1. to ease the deployment of complex benchmarking experiments by automating the tedious tasks of initialization and execution; 2. to allow for benchmark and experiment specifications to be reproduced in different environments and be able to produce comparable and reliable results; 3. to provide to the experimenter the reporting that is identified by the requirements in Sect. 2. In the following sections we will present the architecture and components of KOBE and its key features.
KOBE: Cloud-Native Open Benchmarking Engine
3.1
669
Deployment Automation
One of the major tasks that KOBE undertakes is the deployment, distribution and resource allocation of the various systems (i.e., the database systems, the federator and others) that participate on a specific experiment. In order to achieve this task, KOBE employs Cloud-native technologies to facilitate the deployment on cloud infrastructures. Each system is deployed in an isolated environment with user-defined computational resources and network bandwidth. In particular, KOBE leverages containerization technologies to support the deployment of systems with different environments and installation requirements. An immediate consequence of employing those technologies is that KOBE is open and can be extended with arbitrary federators and database systems. KOBE consists of three main subsystems that control three aspects of the benchmarking process: – The deployment subsystem that is responsible for deploying and initializing the components required by an experiment. This subsystem handles the allocation of computational resources for each component. – The networking subsystem that is responsible for connecting the different components of an experiment and imposes the throughput and latency limitations described by the benchmark. – The logging subsystem that manages the logs produced by the several components (i.e., the data sources, federators and evaluators) and produces meaningful diagrams and graphs about the benchmarking process. KOBE relies on Kubernetes3 to allocate cluster resources for the benchmark execution. It deploys ephemeral containers with the individual components of a benchmarking experiment. The orchestration of that deployment and the communication with the underlying Kubernetes cluster is performed by the KOBE operator. The KOBE operator runs as a daemon and continuously monitors the progress of each running experiment in the cluster. This controller is also responsible for the interpretation of the experiment specifications (see Subsect. 3.2) to complete deployment commands of the components of the experiment. The network subsystem is controlled by Istio4 , a Cloud-native controller that tightly integrates with Kubernetes to provide a service mesh layer. The KOBE operator utilizes the functionality of Istio to setup the network connections between the data sources and the federating engine. The quality of those network connections can be controlled by the KOBE operator to provide the simulated behavior specified by the specific experiment. It is worth noting that those network links are established in the service mesh layer of the cluster and as a result one can have multiple experiments with different networking topologies running at the same time in the cluster. The logging subsystem of KOBE is implemented as an EFK stack, a popular solution for a centralized, cluster-level logging environment in a Kubernetes 3 4
cf. https://kubernetes.io. cf. https://istio.io.
670
C. Kostopoulos et al.
Fig. 1. Information flow through a KOBE deployment: The user edits configuration files and uses kobectl (the KOBE command-line client) to deploy and execute the benchmarking experiments, at a level that abstracts away from Kubernetes specifics. Experimental results are automatically collected and visualized using the EFK stack.
cluster. EFK stack consists of (a) Elasticsearch5 , an object store where all logs are stored in a structured form, used for log searching, (b) Fluentd6 , a data collector which gathers logs from all containers in the cluster and feeds them into Elasticsearch, and (c) Kibana7 , a web UI for Elasticsearch, used for log visualization. Since the metrics of our interest are produced from the federator and the evaluator, and, as we will see in Sect. 4, these logs are of a specific form, Fluentd is configured to parse and to keep only the logs of these containers using a set of regular expression patterns for each type of KOBE-specific logs. Figure 1 illustrates the relationships between the individual components and the information flow through this architecture. In a typical workflow, the user uses kobectl (the KOBE command-line client) to send commands to the KOBE operator. The operator, itself deployed as a container in the Kubernetes cluster, communicates with the Kubernetes API and with Istio in order to deploy the corresponding containers and establish the network between them. Moreover, a Fluentd logging agent is attached to each related container in order to collect the respective log output. The user also uses kobectl to provide a query load to the evaluator. The query evaluator is also deployed as a containerized application and is responsible for applying the query load to the federator and for measuring the latter’s response. 5 6 7
cf. https://www.elastic.co/elasticsearch. cf. https://www.fluentd.org. cf. https://www.elastic.co/kibana.
KOBE: Cloud-Native Open Benchmarking Engine
671
During the execution of the experiment, Fluentd collects the log output from the evaluator, and parses it to extract evaluation metrics which are stored in Elasticsearch. If the federation engine is KOBE-aware, then it also produces log lines following the syntax understood by Fluentd so that fine-grained metrics about the different stages of the overall query processing are also computed and stored in Elasticsearch. The user connects to Kibana to see visualizations of these metrics, where we have prepared a variety of panels specifically relevant to benchmarking federated query processors. 3.2
Benchmark and Experiment Specifications
An important aspect of benchmarking is the ability to reproduce the experimental results of a benchmark. KOBE tackles this important issue by defining declarative specifications of the benchmarks and the experiments. Those descriptions can be serialized in a human-readable format (we use YAML as the markup language) and shared and distributed as artifacts. These specifications are grouped around the various components of an experiment including the benchmark, the evaluator, the data source systems, the data federator and the network topology. Typically, those specifications are partitioned in a series of files; each file includes informations about different elements of the experiment. For example, one specification describes a specific federator and a different specification includes information about the set of datasets and querysets. The main idea of this organization is that each specification can be provided by a different role. For example, the federator (resp. dataset server) specification should be provided by the implementor of the federator (resp. dataset server ). These specifications include, for example, details about the correct initialization of a federation engine. Moreover, the benchmark specification should be provided by the benchmark designer and the more specific details such as the computational resources and the network topology by the experimenter. The relevant pages of the online KOBE manual8 give details about these parameters. It is worth noting that the specifications are declarative in the sense that they describe the desired outcome rather than the actual steps one needs to follow to reproduce the experiment. The KOBE operator interprets these specifications as the necessary interactions with Kubernetes and Istio to deploy an experiment. 3.3
Experiment Orchestration
The KOBE operator is continuously monitoring for new experiment specifications that are submitted to KOBE by the user via a command-line client application. Upon a new experiment submission, the KOBE operator compiles new deployments for the data sources. The data sources consists of a list of dataset files, that is the serializable content of the dataset, and specifications about the database system that will serve this dataset. The deployment of a data source 8
https://semagrow.github.io/kobe/references/api.
672
C. Kostopoulos et al.
is performed in two phases: in the first phase the data files are downloaded and imported into the database system and in the second phase the system is configured and started for serving. When all data sources are ready for serving, the federating engine is started. Similarly, the federating engine is deployed in two phases. In the first phase, the federation of the specific instances of data sources is established. This includes the specific initialization process that a federation engine might need. For example, some engines need the generation of a set of metadata that depend on the specific datasets that they federate. The second phase start the actual federation service. After that, the network connections are established and the network quality characteristics are configured. In that stage the experiment is ready to proceed with querying the federation. This is accomplished by an evaluator component that reads the query set from the benchmark specification and starts sending the queries to the endpoint of the federator. The evaluator is just another container that is deployed in the cluster. During the query evaluation, potential logs that are produced by the federation engine and the evaluator are collected and visualized to the user. The experiment completes when the evaluator finished with all the queries.
4
Collecting and Analysing Evaluation Metrics
In Sect. 2.3 we stipulated that benchmarking engines should include a mechanism that collects and analyzes the logs from multiple containers in order to compute evaluation metrics, and to present them to the experimenter in an intuitive way. 4.1
Collecting the Evaluation Metrics
In KOBE, the following benchmarking metrics are treated: the duration of the query processing phases (source selection, planning, and execution); the number of sources accessed during a query evaluation from the federator; the total time to receive the complete result set of a query; and the number of the returned results of a query. We assume that the federator and the evaluator calculate these metrics and produce a corresponding log message for each metric. Notice, though, that many executions of several experiments can result in multiple query evaluations. As a result, many log messages that contain the same metric can appear. In order to differentiate between these query evaluations and to collect all logs that refer to the same query that belongs to a specific run of an experiment, each log message should also provide the following information: Experiment name: This information is used to identify in which experiment the given query evaluation belongs. Start time of the experiment: Since one experiment can be executed several times, this information is used to link to the given query evaluation with a specific experiment execution. Query name: Each query has a unique identification name in an experiment. This information is used to refer to the name of the query in the experiment.
KOBE: Cloud-Native Open Benchmarking Engine
673
Run: Each experiment has several runs, meaning that the evaluation of a query happens multiple times in a specific experiment execution. This information identifies in which run of the experiment the given query evaluation belongs. An important problem that arises is that this information is only available to the evaluator and cannot be accessed by the federator directly. Any heuristic workarounds that try to connect the evaluator log to the federator log using, for instance, the query strings would not work, as query strings are not unique. Especially in stress-testing scenarios, the exact same query string might be simultaneously executed multiple times, so that a combination of query strings and timestamps would not be guaranteed to work either. To work around this problem, the KOBE evaluator uses SPARQL comments to pass the query experiment id to the federator, and the latter includes those in its logs. Then, the federator can retrieve this information by parsing this comment. This approach has the advantage that even if a federation engine has not been modified to produce log lines that provide this information, the query string is still in a valid, standard syntax and the comment is ignored. The fine-grained time to complete each step in the typical federated query processing pipeline cannot be retrieved, but the experiment can proceed with the end-to-end query processing measurements provided by the evaluator. 4.2
Visualizing the Evaluation Metrics
In this subsection, we describe the visualization component of KOBE. In particular, we present the three available dashboards. For every dashboard we provide some screenshots of the graphs produced for some experiment runs. Details of a Specific Experiment Execution. The dashboard of Fig. 2 focuses on a specific experiment execution. It comprises: 1. 2. 3. 4.
Time of each phase of the query processing for each query of the experiment. Total time to receive the complete result set for each query of the experiment. Number of sources accessed for each query of the experiment. Number of returned results for each query of the experiment.
The first and the third visualizations are obtained from the logs of the federator engine, if available. The second and the fourth visualizations are obtained from the logs of the evaluator, so they are available even for federators that do not provide KOBE-specific logs. The values in each visualization can be also exported in a CSV file for further processing. As an example, we consider an experiment execution for the life-science (ls) query set of the FedBench benchmark for a development version of the Semagrow federation engine. This visualization can help us, for instance, to observe that the query execution phase of the federation engine dominates the overall query processing time in all queries of the benchmark except ls4.
674
C. Kostopoulos et al.
Fig. 2. Details of a specific experiment execution
Comparisons of Experiment Runs. The dashboards depicted in Fig. 3 and Fig. 4 can be used to draw comparisons between several runs in order to directly compare different configurations of a benchmark. The dashboard of Fig. 3 can be used for comparing several experiment executions. It consists of two visualizations: 1. Total time to receive the complete result set for each experiment execution. 2. Number of returned results for each specified experiment execution. These visualizations are obtained from the logs of the evaluator. Each bar refers to a single query of the experiments presented. The dashboard of Fig. 4 displays the same metrics. The main difference is that it focuses on a specific query and compare all runs of this query for several experiment executions. Contrary to the visualizations of the other two dashboards, each bar refers to a single experiment run, and all runs are grouped according to the experiment execution they belong to. Continuing the previous example, we consider three experiment executions that refer to for the life-science queryset of FedBench; one for the FedX federator and two for the Semagrow federator. In Fig. 3 we can observe that all executions return the same number of results for each query, and that the processing times are similar, with the exception of the ls6 query for the FedX experiment. Moreover, we can observe that all runs return same number of results, and that the processing times for each run are similar; therefore any caching used by the federators does not play any significant role in speeding up this query.
KOBE: Cloud-Native Open Benchmarking Engine
675
Fig. 3. Comparison of three experiment executions
Fig. 4. Comparison of all runs of the ls3 query for three experiment executions
5
KOBE Extensibility
It is apparent that a well-designed and well-executed benchmarking experiment needs contributions from different actors. For example, a benchmark designer may provide a benchmark that is designed to compare a particular aspect of different federators. On the other hand, the specifications of each federator should ideally be provided by their respective implementors. KOBE provides various extensibility opportunities and by design welcomes contributions from the community. In particular, KOBE can be extended with respect to the database systems, federators, query evaluators and benchmarks that comprise an experiment. We currently provide specifications for two database systems, namely for Virtuoso9 and Strabon10 and for two federators, FedX [10] and Semagrow [2]. These systems have very different requirements in terms of deployment, providing strong evidence that extending the list of supported RDF stores will be straightforwrd. We also provide a range of benchmark and experiment specifications for existing federated SPARQL benchmarks. Currently, the benchmarks that are already 9 10
cf. https://virtuoso.openlinksw.com. cf. http://strabon.di.uoa.gr.
676
C. Kostopoulos et al.
bundled with KOBE include the most widely used LUBM [5] and FedBench [9] benchmark. Moreover, we also include big RDF data benchmarks BigRDFBench [8] and OPFBench [11] and geospatial benchmarks GeoFedBench [12] and Geographica [3]. In the following, we briefly discuss the process of defining these specifications and give links to the more detailed walk-throughs provided in the online KOBE documentation. 5.1
Benchmarks and Experiments
Benchmarks are defined independently of the federator and comprise a set of datasets and a list of queries. Datasets are described in terms of the data and the system that should serve them. Data can be provided as a data dump to be imported in the database systems. For example, RDF data can be redistributed in the N-Triples format. Each dataset is characterized by its name and is parameterized by the URL where the data dump can be accessed. Queries of the benchmark are typically described as strings and annotated with the query language in which they are expressed; supporting heterogeneous benchmarks where not all data is served by SPARQL endpoints. A benchmark specification can also include network parameters, such as a fixed delay, or a percentage on which delay will be introduced as part of fault injection. The online KOBE manual provides walk-throughs for defining a new benchmark11 and for tuning network parameters.12 An experiment that evaluates the performance of a federator over a given benchmark is defined using a strategy for applying the query load to the federator and the number of runs for each query of the experiment. The experimenter specifies an experiment by providing a new unique name for the experiment, the unique name of the benchmark and the federator specification. Moreover, an experiment includes a specific query evaluator, and the number of runs of the experiment. The query evaluator applies the query load to the federator. The one currently bundled with KOBE performs sequential querying, meaning that the queries of the benchmark are evaluated in a sequential manner. The online KOBE manual provides walk-throughs for defining a new experiment13 and for extending KOBE with a new evaluator.14 Furthermore, the manual also provides a walk-through for defining and visualizing new metrics.15
11 12 13 14 15
https://semagrow.github.io/kobe/use/create benchmark. https://semagrow.github.io/kobe/use/tune network. https://semagrow.github.io/kobe/use/create experiment. https://semagrow.github.io/kobe/extend/add evaluator. https://semagrow.github.io/kobe/extend/add metrics.
KOBE: Cloud-Native Open Benchmarking Engine
5.2
677
Dataset Servers and Federators
Dataset servers can be also integrated in KOBE. The dataset server specification contains a set of initialization scripts and a Docker image for the actual dataset server. The initialization scripts are also wrapped on isolated Docker containers and are used for properly initializing the database system. Typically, it includes the import of the data dump and indexing of the database. The dataset server specification may also include other parameters for network connectivity such as the port and the path to the listening SPARQL endpoint. A walk-through for adding a new dataset server is provided in the online KOBE manual.16 Federators can also be added to the KOBE system by providing the appropriate specification. That specification resembles the specification of a ordinary dataset server. The main difference is on the initialization phase of a federator. Typically, the initialization of a federator may involve the creation of histograms from the underlying datasets. Thus, in KOBE, the federator initialization is performed in two steps: the first step extracts needed information from each dataset and the second step consolidates that information and properly initializes the federator. As in the dataset server, the initialization processes are provided as containerized Docker images by the implementor of the federator. A walk-through for adding a federator is provided in the online KOBE manual.17 Federator implementors should also consider a tighter integration in order to benefit from the detailed log collection features for reporting measurements that can only be extracted by collecting information internal to the federator (Sect. 4). Therefore, a log line from a federator should be enhanced to include the evaluation metrics and the query parameters discussed in Sect. 2.3. More details about how a federator should be extended to provide detailed logs are given in the online KOBE manual.18 This tighter integration is not a requirement, in the sense that the overall end-to-end time to evaluate the query and the number of returned results are provided without modifying the source code of the federation engine (as we have done in the case of FedX).
6
Comparison to Related Systems
To the best of our knowledge, the only benchmark orchestrator that directly targets federated query processors is the orchestrator distributed with the FedBench suite [9]. As also stated in the introduction, it is in fact the limitations of the FedBench orchestrator that originally motivated the work described here. Specifically, FedBench does not support the user with either container-based deployment or collecting federator logs to compute detailed metrics. HOBBIT [7], on the other hand, is a Docker-based system aiming at benchmarking the complete lifecycle of Linked Data generation and consumption. 16 17 18
https://semagrow.github.io/kobe/extend/add dataset server. https://semagrow.github.io/kobe/extend/add federator. Specifically, see the first step of the walk-through for adding a new federator. See also details about collecting logs to compute evaluation metrics https://semagrow. github.io/kobe/extend/support metrics.
678
C. Kostopoulos et al.
Although HOBBIT tooling can support with collecting logs and visualizing metrics, HOBBIT as a whole is not directly comparable to KOBE. In the HOBBIT architecture, the benchmarked system is perceived as an opaque container that the system tasks and measures. KOBE exploits the premise that the benchmarked system comprises multiple containers one of which (the federator) is tasked and that this one container communicates with the rest (the data sources). By exploiting these premises, KOBE goes further than HOBBIT could have gone to automate the deployment of the modules of an experiment and the control of their connectivity. In other words, KOBE aims at the federated query processing niche and trades off generality of purpose for increased support for its particular purpose. A similar conclusion is also reached when comparing KOBE with scientific workflow orchestrators. Although (unlike HOBBIT and like KOBE) scientific workflow orchestrators are designed to orchestrate complex systems of containers, they focus on the results of the processing rather on benchmarking the processors. As such, they lack features such as controlling network latency. Finally, another unique KOBE feature is the mechanism described in Sect. 4.1 for separating the logs of the different runs of an experiment. This especially useful in stress-testing scenarios where the same query is executed multiple times, so that the query string alone would not be sufficient to separate log lines of the different runs.
7
Conclusions
We have presented the architecture and implementation of the KOBE open benchmarking engine for federation systems. KOBE is both open-source software and an open architecture, leveraging containerization to allow the future inclusion of any federation engine. KOBE also uses Elasticsearch as a log server and Kibana as the visualization layer for presenting evaluation metrics extracted from these logs, again emphasizing openness by supporting user-defined ingestion patterns to allow flexibility in how evaluation metrics are to be extracted from each federator’s log format. Deployment depends on Kubernetes, which is ubiquitous among the currently prevalent Cloud infrastructures. These features allow experiment publishers the flexibility needed for sharing federated query processing experiments that can be consistently reproduced with minimal effort by the experiment consumers. Although originally developed for our own experiments, we feel that the federated querying community can extract great value from the abstractions it offers, as it allows releasing a benchmark as a complete, fully configured, automatically deployable testing environment. As a next step, we are planning to expand the library of federators bundled with the KOBE distribution, and especially with systems that will verify that KOBE operates at the appropriate level of abstraction away from the specifics of particular federators. For instance, adding Triple Pattern Fragments [13] will verify that adaptive source selection and planning can operate within the KOBE framework.
KOBE: Cloud-Native Open Benchmarking Engine
679
Another interesting future extension would be support for the detailed evaluation of systems that stream results before the complete result set has been obtained. This requires adding support for calculating the relevant metrics, such as the diefficiency metric [1]. Acknowledgments. This project has received funding from the European Union’s Horizon 2020 research and innovation programme under grant agreement No 825258. Please see http://earthanalytics.eu for more details.
References 1. Acosta, M., Vidal, M.-E., Sure-Vetter, Y.: Diefficiency metrics: measuring the continuous efficiency of query processing approaches. In: d’Amato, C., et al. (eds.) ISWC 2017, Part II. LNCS, vol. 10588, pp. 3–19. Springer, Cham (2017). https:// doi.org/10.1007/978-3-319-68204-4 1 2. Charalambidis, A., Troumpoukis, A., Konstantopoulos, S.: SemaGrow: optimizing federated SPARQL queries. In: Proceedings of the 11th International Conference on Semantic Systems (SEMANTiCS 2015), Vienna, Austria, Sept 2015 (2015) 3. Garbis, G., Kyzirakos, K., Koubarakis, M.: Geographica: a benchmark for geospatial RDF stores (long version). In: Alani, H., et al. (eds.) ISWC 2013, Part II. LNCS, vol. 8219, pp. 343–359. Springer, Heidelberg (2013). https://doi.org/10. 1007/978-3-642-41338-4 22 4. G¨ orlitz, O., Staab, S.: SPLENDID: SPARQL endpoint federation exploiting VOID descriptions. In: Proceedings of the 2nd International Workshop on Consuming Linked Data (COLD 2011), vol. 782, Bonn, Germany, Oct 2011. CEUR (2011) 5. Guo, Y., Pan, Z., Heflin, J.: LUBM: a benchmark for OWL knowledge base systems. Web Semant. 3(2) (2005). https://doi.org/10.1016/j.websem.2005.06.005 6. Kostopoulos, C., Mouchakis, G., Prokopaki-Kostopoulou, N., Troumpoukis, A., Charalambidis, A., Konstantopoulos, S.: KOBE: Cloud-native open benchmarking engine for federated query processors. Posters & Demos Session, ISWC 2020 (2020) 7. Ngonga Ngomo, A.C., R¨ oder, M.: HOBBIT: Holistic benchmarking for big linked data. In: Processings of the ESWC 2016 EU Networking Session (2016) 8. Saleem, M., Hasnain, A., Ngonga Ngomo, A.C.: BigRDFBench: A billion triples benchmark for SPARQL endpoint federation 9. Schmidt, M., G¨ orlitz, O., Haase, P., Ladwig, G., Schwarte, A., Tran, T.: FedBench: a benchmark suite for federated semantic data query processing. In: Aroyo, L., et al. (eds.) ISWC 2011, Part I. LNCS, vol. 7031, pp. 585–600. Springer, Heidelberg (2011). https://doi.org/10.1007/978-3-642-25073-6 37 10. Schwarte, A., Haase, P., Hose, K., Schenkel, R., Schmidt, M.: FedX: a federation layer for distributed query processing on linked open data. In: Antoniou, G., et al. (eds.) ESWC 2011, Part II. LNCS, vol. 6644, pp. 481–486. Springer, Heidelberg (2011). https://doi.org/10.1007/978-3-642-21064-8 39 11. Troumpoukis, A., et al.: Developing a benchmark suite for semantic web data from existing workflows. In: Proceedings of the Benchmarking Linked Data Workshop (BLINK), (ISWC 2016), Kobe, Japan, Oct 2016 (2016) 12. Troumpoukis, A., et al.: GeoFedBench: a benchmark for federated GeoSPARQL query processors. In: Proceedings Posters & Demos Session of ISWC 2020 (2020) 13. Verborgh, R., et al.: Triple pattern fragments: a low-cost knowledge graph interface for the web. J. Web Semant. 37–38, 184–206 (2016)
CSKG: The CommonSense Knowledge Graph Filip Ilievski(B) , Pedro Szekely, and Bin Zhang Information Sciences Institute, University of Southern California, Los Angeles, USA {ilievski,pszekely,binzhang}@isi.edu Abstract. Sources of commonsense knowledge support applications in natural language understanding, computer vision, and knowledge graphs. Given their complementarity, their integration is desired. Yet, their different foci, modeling approaches, and sparse overlap make integration difficult. In this paper, we consolidate commonsense knowledge by following five principles, which we apply to combine seven key sources into a first integrated CommonSense Knowledge Graph (CSKG). We analyze CSKG and its various text and graph embeddings, showing that CSKG is well-connected and that its embeddings provide a useful entry point to the graph. We demonstrate how CSKG can provide evidence for generalizable downstream reasoning and for pre-training of language models. CSKG and all its embeddings are made publicly available to support further research on commonsense knowledge integration and reasoning. Keywords: Commonsense knowledge Embeddings
· Knowledge graph ·
Resource type: Knowledge graph License: CC BY-SA 4.0 DOI: https://doi.org/10.5281/zenodo.4331372 Repository: https://github.com/usc-isi-i2/cskg
1
Introduction
Recent commonsense reasoning benchmarks [3,27] and neural advancements [16, 17] shed a new light on the longstanding task of capturing, representing, and reasoning over commonsense knowledge. While state-of-the-art language models [8,17] capture linguistic patterns that allow them to perform well on commonsense reasoning tasks after fine-tuning, their robustness and explainability could benefit from integration with structured knowledge, as shown by KagNet [16] and HyKAS [18]. Let us consider an example task question from the SWAG dataset [38],1 which describes a woman that takes a sit at the piano: 1
The multiple-choice task of choosing an intuitive follow-up scene is customary called question answering [19, 38], despite the absence of a formal question.
c Springer Nature Switzerland AG 2021 R. Verborgh et al. (Eds.): ESWC 2021, LNCS 12731, pp. 680–696, 2021. https://doi.org/10.1007/978-3-030-77385-4_41
CSKG: The CommonSense Knowledge Graph Q: 1. 2. 3. ->
681
On stage, a woman takes a seat at the piano. She: sits on a bench as her sister plays with the doll. smiles with someone as the music plays. is in the crowd, watching the dancers. 4. nervously sets her fingers on the keys.
Answering this question requires knowledge that humans possess and apply, but machines cannot distill directly in communication. Luckily, graphs of (commonsense) knowledge contain such knowledge. ConceptNet’s [29] triples state that pianos have keys and are used to perform music, which supports the correct option and discourages answer 2. WordNet [21] states specifically, though in natural language, that pianos are played by pressing keys. According to an image description in Visual Genome, a person could play piano while sitting and having their hands on the keyboard. In natural language, ATOMIC [26] indicates that before a person plays piano, they need to sit at it, be on stage, and reach for the keys. ATOMIC also lists strong feelings associated with playing piano. FrameNet’s [1] frame of a performance contains two separate roles for the performer and the audience, meaning that these two are distinct entities, which can be seen as evidence against answer 3. While these sources clearly provide complementary knowledge that can help commonsense reasoning, their different foci, representation formats, and sparse overlap makes integration difficult. Taxonomies, like WordNet, organize conceptual knowledge into a hierarchy of classes. An independent ontology, coupled with rich instance-level knowledge, is provided by Wikidata [34], a structured counterpart to Wikipedia. FrameNet, on the other hand, defines an orthogonal structure of frames and roles; each of which can be filled with a WordNet/Wikidata class or instance. Sources like ConceptNet or WebChild [31], provide more ‘episodic’ commonsense knowledge, whereas ATOMIC captures pre- and post-situations for an event. Image description datasets, like Visual Genome [14], contain visual commonsense knowledge. While links between these sources exist (mostly through WordNet synsets), the majority of their nodes and edges are disjoint. In this paper, we propose an approach for integrating these (and more sources) into a single Common Sense Knowledge Graph (CSKG). We suvey existing sources of commonsense knowledge to understand their particularities and we summarize the key challenges on the road to their integration (Sect. 2). Next, we devise five principles and a representation model for a consolidated CSKG (Sect. 3). We apply our approach to build the first version of CSKG, by combining seven complementary, yet disjoint, sources. We compute several graph and text embeddings to facilitate reasoning over the graph. In Sect. 4, we analyze the content of the graph and the generated embeddings. We provide insights into the utility of CSKG for downstream reasoning on commonsense Question Answering (QA) tasks in Sect. 5. In Sect. 6 we reflect on the learned lessons and list the next steps for CSKG. We conclude in Sect. 7.
682
F. Ilievski et al. Table 1. Survey of existing sources of commonsense knowledge. Describes
Creation
Size
Mappings
Examples
Concept net
Everyday objects, actions, states, relations (multilingual)
Crowdsourcing
36 relations, 8M nodes, 21M edges
WordNet, DBpedia, OpenCyc, Wiktionary
/c/en/piano /c/en/piano/n /c/en/piano/n/wn /r/relatedTo
Web child
Everyday objects, actions, states, relations
Curated automatic extraction
4 relation groups, 2M WordNet nodes, 18M edges
hasTaste fasterThan
ATOMIC
Event Crowdpre/post-conditions sourcing
9 relations, 300k nodes, 877k edges
ConceptNet, Cyc
wanted-to impressed
Wikidata
Instances, concepts, Crowdrelations sourcing
1.2k relations, 75M objects, 900M edges
various
wd:Q1234 wdt:P31
WordNet
Words, concepts, relations
Manual
10 relations, 155k words, 176k synsets
dog.n.01 hypernymy
Roget
Words, relations
Manual
2 relations, 72k words, 1.4M edges
truncate antonym
VerbNet
Verbs, relations
Manual
273 top classes 23 roles, 5.3k senses
FrameNet
Frames, roles, relations
Manual
1.9k edges, 1.2k frames, 12k roles, 13k lexical units
Visual genome
Image objects, Crowdrelations, attributes sourcing
42k relations, 3.8M nodes, 2.3M edges, 2.8M attributes
WordNet
fire hydrant white dog
ImageNet
Image objects
14M images, 22k synsets
WordNet
dog.n.01
2 2.1
Crowdsourcing
FrameNet, WordNet
perform-v performance-26.7-1 Activity Change of leadership New leader
Problem Statement Sources of Common Sense Knowledge
Table 1 summarizes the content, creation method, size, external mappings, and example resources for representative public commonsense sources: ConceptNet [29], WebChild [31], ATOMIC [26], Wikidata [34], WordNet [21], Roget [13], VerbNet [28], FrameNet [1], Visual Genome [14], and ImageNet [7]. Primarily, we observe that the commonsense knowledge is spread over a number of sources with different focus: commonsense knowledge graphs (e.g., ConceptNet), generaldomain knowledge graphs (e.g., Wikidata), lexical resources (e.g., WordNet, FrameNet), taxonomies (e.g., Wikidata, WordNet), and visual datasets (e.g., Visual Genome) [11]. Therefore, these sources together cover a rich spectrum of knowledge, ranging from everyday knowledge, through event-centric knowledge and taxonomies, to visual knowledge. While the taxonomies have been created manually by experts, most of the commonsense and visual sources have been created by crowdsourcing or curated automatic extraction. Commonsense and common knowledge graphs (KGs) tend to be relatively large, with millions of nodes and edges; whereas the taxonomies and the lexical sources are notably smaller. Despite the diverse nature of these sources, we note that many contain mappings to WordNet, as well as a number of other sources. These mappings might be incomplete, e.g., only a small portion of ATOMIC can be mapped to ConceptNet. Nevertheless, these high-quality mappings provide an opening for consolidation of commonsense knowledge, a goal we pursue in this paper.
CSKG: The CommonSense Knowledge Graph
2.2
683
Challenges
Combining these sources in a single KG faces three key challenges: 1. The sources follow different knowledge modeling approaches. One such difference concerns the relation set: there are very few relations in ConceptNet and WordNet, but (tens of) thousands of them in Wikidata and Visual Genome. Consolidation requires a global decision on how to model the relations. The granularity of knowledge is another factor of variance. While regular RDF triples fit some sources (e.g., ConceptNet), representing entire frames (e.g., in FrameNet), event conditions (e.g., in ATOMIC), or compositional image data (e.g., Visual Genome) might benefit from a more open format. An ideal representation would support the entire granularity spectrum. 2. As a number of these sources have been created to support natural language applications, they often contain imprecise descriptions. Natural language phrases are often the main node types in the provided knowledge sources, which provides the benefit of easier access for natural language algorithms, but it introduces ambiguity which might be undesired from a formal semantics perspective. An ideal representation would harmonize various phrasings of a concept, while retaining easy and efficient linguistic access to these concepts via their labels. 3. Although these sources contain links to existing ones, we observe sparse overlap. As these external links are typically to WordNet, and vary in terms of their version (3.0 or 3.1) or target (lemma or synset), the sources are still disjoint and establishing (identity) connections is difficult. Bridging these gaps, through optimally leveraging existing links, or extending them with additional ones automatically, is a modeling and integration challenge.
2.3
Prior Consolidation Efforts
Prior efforts that combine pairs or small sets of (mostly lexical) commonsense sources exist. A unidirectional manual mapping from VerbNet classes to WordNet and FrameNet is provided by the Unified Verb Index [33]. The Predicate Matrix [6] has a full automatic mapping between lexical resources, including FrameNet, WordNet, and VerbNet. PreMOn [5] formalizes these in RDF. In [20], the authors produce partial mappings between WordNet and Wikipedia/DBpedia. Zareian et al. [37] combine edges from Visual Genome, WordNet, and ConceptNet to improve scene graph generation from an image. None of these efforts aspires to build a consolidated KG of commonsense knowledge. Most similar to our effort, BabelNet [22] integrates many sources, covers a wide range of 284 languages, and primarily focuses on lexical and generalpurpose resources, like WordNet, VerbNet, and Wiktionary. While we share the goal of integrating valuable sources for downstream reasoning, and some of
684
F. Ilievski et al.
these sources (e.g., WordNet) overlap with BabelNet, our ambition is to support commonsense reasoning applications. For this reason, we focus on commonsense knowledge graphs, like ConceptNet and ATOMIC, or even visual sources, like Visual Genome, none of which are found in BabelNet.
3 3.1
The Common Sense Knowledge Graph Principles
Question answering and natural language inference tasks require knowledge from heterogeneous sources (Sect. 2). To enable their joint usage, the sources need to be harmonized in a way that will allow straightforward access by linguistic tools [16,18], easy splitting into arbitrary subsets, and computation of common operations, like (graph and word) embeddings or KG paths. For this purpose, we devise five principles for consolidatation of sources into a single commonsense KG (CSKG), driven by pragmatic goals of simplicity, modularity, and utility: P1. Embrace heterogeneity of nodes One should preserve the natural node diversity inherent to the variety of sources considered, which entails blurring the distinction between objects (such as those in Visual Genome or Wikidata), classes (such as those in WordNet or ConceptNet), words (in Roget), actions (in ATOMIC or ConceptNet), frames (in FrameNet), and states (as in ATOMIC). It also allows formal nodes, describing unique objects, to co-exist with fuzzy nodes describing ambiguous lexical expressions. P2. Reuse edge types across resources To support reasoning algorithms like KagNet [16], the set of edge types should be kept to minimum and reused across resources wherever possible. For instance, the ConceptNet edge type /r/LocatedNear could be reused to express spatial proximity in Visual Genome. P3. Leverage external links The individual graphs are mostly disjoint according to their formal knowledge. However, high-quality links may exist or may be easily inferred, in order to connect these KGs and enable path finding. For instance, while ConceptNet and Visual Genome do not have direct connections, they can be partially aligned, as both have links to WordNet synsets. P4. Generate high-quality probabilistic links Inclusion of additional probabilistic links, either with off-the-shelf link prediction algorithms or with specialized algorithms (e.g., see Sect. 3.3), would improve the connectedness of CSKG and help path finding algorithms reason over it. Given the heterogeneity of nodes (cf. P1), a ‘one-method-fits-all’ node resolution might not be suitable. P5. Enable access to labels The CSKG format should support easy and efficient natural language access. Labels and aliases associated with KG nodes provide application-friendly and human-readable access to the CSKG, and can help us unify descriptions of the same/similar concept across sources.
CSKG: The CommonSense Knowledge Graph
3.2
685
Representation
We model CSKG as a hyper-relational graph, describing edges in a tabular KGTK [10] format. We opted for this representation rather than the traditional RDF/OWL2 because it allows us to fulfill our goals (of simplicity and utility) and follow our principles more directly, without compromising on the format. For instance, natural language access (principle P5) to RDF/OWL2 nodes requires graph traversal over its rdfs:label relations. Including both reliable and probabilistic nodes (P3 and P4) would require a mechanism to easily indicate edge weights, which in RDF/OWL2 entails inclusion of blank nodes, and a number of additional edges. Moreover, the simplicity of our tabular format allows us to use standard off-the-shelf functionalities and mature tooling, like the pandas2 and graph-tool3 libraries in Python, or graph embedding tools like [15], which have been conveniently wrapped by the KGTK [10] toolkit.4 The edges in CSKG are described by ten columns. Following KGTK, the primary information about an edge consists of its id, node1, relation, and node2. Next, we include four “lifted” edge columns, using KGTK’s abbreviated way of representing triples about the primary elements, such as node1;label or relation;label (label of node1 and of relation). Each edge is completed by two qualifiers: source, which specifies the source(s) of the edge (e.g., “CN” for ConceptNet), and sentence, containing the linguistic lexicalization of a triple, if given by the original source. Auxiliary KGTK files can be added to describe additional knowledge about some edges, such as their weight, through the corresponding edge ids. We provide further documentation at: https://cskg.readthedocs.io/. 3.3
Consolidation
Currently, CSKG integrates seven sources, selected based on their popularity in existing QA work: a commonsense knowledge graph ConceptNet, a visual commonsense source Visual Genome, a procedural source ATOMIC, a general-domain source Wikidata, and three lexical sources, WordNet, Roget, and FrameNet. Here, we briefly present our design decisions per source, the mappings that facilitate their integration, and further refinements on CSKG. 3.3.1 Individual Sources We keep the original edges of ConceptNet 5.7 expressed with 47 relations in total. We also include the entire ATOMIC KG, preserving the original nodes and its nine relations. To enhance lexical matching between ATOMIC and other sources, we add normalized labels of its nodes, e.g., adding a second label “accepts invitation” to the original one “personX accepts personY’s invitation”. We import four node types from FrameNet: frames, frame elements (FEs), lexical units (LUs), and semantic types (STs), and we 2 3 4
https://pandas.pydata.org/. https://graph-tool.skewed.de/. CSKG can be transformed to RDF with kgtk generate-wikidata-triples.
686
F. Ilievski et al.
reuse 5 categories of FrameNet edges: frame-frame (13 edge types), frame-FE (1 edge type), frame-LU (1 edge type), FE-ST (1 edge type), and ST-ST (3 edge types). Following principle P2 on edge type reuse, we map these 19 edge types to 9 relations in ConceptNet, e.g., is causative of is converted to /r/Causes. Roget We include all synonyms and antonyms between words in Roget, by reusing the ConceptNet relations /r/Synonym and /r/Antonym (P2). We represent Visual Genome as a KG, by representing its image objects as WordNet synsets (e.g., wn:shoe.n.01). We express relationships between objects via ConceptNet’s /r/LocatedNear edge type. Object attributes are represented by different edge types, conditioned on their part-of-speech: we reuse ConceptNet’s /r/CapableOf for verbs, while we introduce a new relation mw:MayHaveProperty for adjective attributes. We include the Wikidata-CS subset of Wikidata, extracted in [12]. Its 101k statements have been manually mapped to 15 ConceptNet relations. We include four relations from WordNet v3.0 by mapping them to three ConceptNet relations: hypernymy (using /r/IsA), part and member holonymy (through /r/PartOf), and substance meronymy (with /r/MadeOf). 3.3.2 Mappings We perform node resolution by applying existing identity mappings (P3) and generating probabilistic mappings automatically (P4). We introduce a dedicated relation, mw:SameAs, to indicate identity between two nodes. WordNet-WordNet. The WordNet v3.1 identifiers in ConceptNet and the WordNet v3.0 synsets from Visual Genome are aligned by leveraging ILI: the WordNet InterLingual Index,5 which generates 117,097 mw:SameAs mappings. WordNet-Wikidata. We generate links between WordNet synsets and Wikidata nodes as follows. For each synset, we retrieve 50 candidate nodes from a customized index of Wikidata. Then, we compute sentence embeddings of the descriptions of the synset and each of the Wikidata candidates by using a pretrained XLNet model [36]. We create a mw:SameAs edge between the synset and the Wikidata candidate with highest cosine similarity of their embeddings. Each mapping is validated by one student. In total, 17 students took part in this validation. Out of the 112k edges produced by the algorithm, the manual validation marked 57,145 as correct. We keep these in CSKG and discard the rest. FrameNet-ConceptNet. We link FrameNet nodes to ConceptNet in two ways. FrameNet LUs are mapped to ConceptNet nodes through the Predicate Matrix [6] with 3, 016 mw:SameAs edges. Then, we use 200k hand-labeled sentences from the FrameNet corpus, each annotated with a target frame, a set of FEs, and their associated words. We treat these words as LUs of the corresponding FE, and ground them to ConceptNet with the rule-based method of [16]. Lexical matching. We establish 74,259 mw:SameAs links between nodes in ATOMIC, ConceptNet, and Roget by exact lexical match of their labels. We restrict this matching to lexical nodes (e.g., /c/en/cat and not /c/en/cat/n/wn/animal). 5
https://github.com/globalwordnet/ili.
CSKG: The CommonSense Knowledge Graph
687
Fig. 1. Snippet of CSKG for the example task of Sect. 1. CSKG combines: 1) lexical nodes (piano, keys, music; in blue), 2) synsets like piano (artifact), seat (dramaturgy) (in green), and 3) frames (fn:noise makers) and frame elements (fn:fe:use) (in purple). The link between piano and piano (artifact) is missing, but trivial to infer. (Color figure online)
3.3.3 Refinement We consolidate the seven sources and their interlinks as follows. After transforming them to the representation described in the past two sections, we concatenate them in a single graph. We deduplicate this graph and append all mappings, resulting in CSKG*. Finally, we apply the mappings to merge identical nodes (connected with mw:SameAs) and perform a final deduplication of the edges, resulting in our consolidated CSKG graph. The entire procedure of importing the individual sources and consolidating them into CSKG is implemented with KGTK operations [10], and can be found on our GitHub.6 3.4
Embeddings
Embeddings provide a convenient entry point to KGs and enable reasoning on both intrinsic and downstream tasks. For instance, many reasoning applications (cf. [16,18]) of ConceptNet leverage their NumberBatch embeddings [29]. Motivated by these observations, we aspire to produce high-quality embeddings of the CSKG graph. We experiment with two families of embedding algorithms. On the one hand, we produce variants of popular graph embeddings: TransE [4], DistMult [35], ComplEx [32], and RESCAL [24]. On the other hand, we produce various text (Transformer-based) embeddings based on BERT-large [8]. For BERT, we first create a sentence for each node, based on a template that encompasses its neighborhood, which is then encoded with BERT’s sentence transformer model. All embeddings are computed with the KGTK operations graph-embeddings and text-embeddings. We analyze them in Sect. 4.2. The CSKG embeddings are publicly available at http://shorturl.at/pAGX8.
6
https://github.com/usc-isi-i2/cskg/blob/master/consolidation/create cskg.sh.
688
4
F. Ilievski et al.
Analysis
Figure 1 shows a snippet of CSKG that corresponds to the task in Sect. 1. Following P1, CSKG combines: 1) lexical nodes (piano, keys, music), 2) synsets like piano (artifact), seat (dramaturgy) (in green), and 3) frames (fn:noise makers) and frame elements (fn:fe:use). According to P2, we reuse edge types where applicable: for instance, we use ConceptNet’s LocatedNear relation to formalize Visual Genome’s proximity information between a woman and a piano. We leverage external links to WordNet to consolidate synsets across sources (P3). We generate further links (P4) to connect FrameNet frames and frame elements to ConceptNet nodes, and to consolidate the representation of piano (artifact) between Wikidata and WordNet. In the remainder of this section, we perform qualitative analysis of CSKG and its embeddings. 4.1
Statistics
Basic statistics. of CSKG are shown in Table 2. In total, our mappings produce 251,517 mw:SameAs links and 45,659 fn:HasLexicalUnit links. After refinement, i.e., removal of the duplicates and merging of the identical nodes, CSKG consists of 2.2 million nodes and 6 million edges. In terms of edges, its largest subgraph is ConceptNet (3.4 million), whereas ATOMIC comes second with 733 thousand edges. These two graphs also contribute the largest number of nodes to CSKG. The three most common relations in CSKG are: /r/RelatedTo (1.7 million), /r/Synonym (1.2 million), and /r/Antonym (401 thousand edges). Connectivity and centrality. The mean degree of CSKG grows by 5.5% (from 5.26 to 5.55) after merging identical nodes. Compared to ConceptNet, its degree is 45% higher, due to its increased number of edges while keeping the number of nodes nearly constant. The best connected subgraphs are Visual Genome and Roget. CSKG’s high connectivity is owed largely to these two sources and our mappings, as the other five sources have degrees below that of CSKG. The abnormally large node degrees and variance of Visual Genome are due to its annotation guidelines that dictate all concept-to-concept information to be annotated, and our modeling choice to represent its nodes through their synsets. We report that the in-degree and out-degree distributions of CSKG have Zipfian shapes, a notable difference being that the maximal in degree is nearly double compared to its maximal out degree (11k vs 6.4k). To understand better the central nodes in CSKG, we compute PageRank and HITS metrics. The top-5 results are shown in Table 3. We observe that the node with highest PageRank has label “chromatic”, while all dominant HITS hubs and authorities are colors, revealing that knowledge on colors of real-world object is common in CSKG. PageRank also reveals that knowledge on natural and chemical processes is well-represented in CSKG. Finally, we note that the top-centrality nodes are generally described by multiple subgraphs, e.g., c/en/natural science/n/wn/cognition is found in ConceptNet and WordNet, whereas the color nodes (e.g., /c/en/red) are shared between Roget and ConceptNet.
CSKG: The CommonSense Knowledge Graph
689
Table 2. CSKG statistics. Abbreviations: CN = ConceptNet, VG = Visual Genome, WN = WordNet, RG = Roget, WD = Wikidata, FN = FrameNet, AT = ATOMIC. Relation numbers in brackets are before consolidating to ConceptNet. AT
CN
FN
RG
VG
WD
11,264
91,294 71,243 2,414,813 2,160,968
WN
CSKG*
CSKG
#nodes
304,909 1,787,373 15,652 71,804
#edges
732,723 3,423,004 29,873 1,403,955 2,587,623 111,276 101,771 6,349,731 6,001,531
#relations
9
58
47
9 (23) 2
3 (42k)
3
15 (45) 59
Avg. degree 4.81
3.83
3.82
39.1
459.45
2.44
2.86
5.26
5.55
Std. degree 0.07
0.02
0.13
0.34
35.81
0.02
0.05
0.02
0.03
Table 3. Nodes with highest centrality score according to PageRank and HITS. Node labels indicated in bold. PageRank
HITS hubs
HITS authorities
/c/en/chromatic/a/wn
/c/en/red
/c/en/blue
/c/en/organic compound
/c/en/yellow
/c/en/chemical compound/n
/c/en/green
/c/en/silver
/c/en/change/n/wn/artifact
/c/en/silver
/c/en/green
/c/en/natural science/n/wn/cognition /c/en/blue
4.2
/c/en/red
/c/en/gold
Analysis of the CSKG Embeddings
We randomly sample 5,000 nodes from CSKG and visualize their embeddings computed with an algorithm from each family: TransE and BERT. The results are shown in Fig. 2. We observe that graph embeddings group nodes from the same source together. This is because graph embeddings tend to focus on the graph structure, and because most links in CSKG are still within sources. We observe that the sources are more intertwined in the case of the BERT embeddings, because of the emphasis on lexical over structural similarity. Moreover, in both plots Roget is dispersed around the ConceptNet nodes, which is likely due to its broad coverage of concepts, that maps both structurally and lexically to ConceptNet. At the same time, while ATOMIC overlaps with a subset of ConceptNet [26], the two sources mostly cover different areas of the space. Table 4 shows the top-5 most similar neighbors for /c/en/turtle/n/ wn/animal and /c/en/happy according to TransE and BERT. We note that while graph embeddings favor nodes that are structurally similar (e.g., /c/en/turtle/n/wn/animal and /c/en/chelonian/n/wn/animal are both animals in WordNet), text embeddings give much higher importance to lexical similarity of nodes or their neighbors, even when the nodes are disconnected in CSKG (e.g., /c/en/happy and at:happy that they went to the party). These results are expected considering the approach behind each algorithm.
690
F. Ilievski et al.
Table 4. Top-5 most similar nodes for /c/en/turtle/n/wn/animal (E1) and /c/en/happy (E2) according to TransE and BERT. TransE E1 /c/en/chelonian/n/wn/animal
BERT /c/en/glyptemys/n
/c/en/mud turtle/n/wn/animal
/c/en/pelocomastes/n
/c/en/cooter/n/wn/animal
/c/en/staurotypus/n
/c/en/common snapping turtle/n/wn/animal /c/en/parahydraspis/n /c/en/sea turtle/n/wn/animal E2 /c/en/excited
/c/en/trachemys/n /c/en/bring happiness
/c/en/satisfied
/c/en/new happiness
/c/en/smile mood
at:like a party is a good way to ...
/c/en/pleased
/c/en/encouraging person’s talent
/c/en/joyful
at:happy that they went to the party
Fig. 2. UMAP visualization of 5,000 randomly sampled nodes from CSKG, represented by TransE (left) and BERT (right) embeddings. Colors signify node sources. (Color figure online)
Word Association with Embeddings. To quantify the utility of different embeddings, we evaluate them on the USF-FAN [23] benchmark, which contains crowdsourced common sense associations for 5,019 “stimulus” concepts in English. For instance, the associations provided for day are: night, light, sun, time, week, and break. The associations are ordered descendingly based on their frequency. With each algorithm, we produce a top-K most similar neighbors list based on the embedding of the stimulus concept. Here, K is the number of associations for a concept, which varies across stimuli. If CSKG has multiple nodes for the stimulus label, we average their embeddings. For the graph embeddings, we use logistic loss function, using a dot comparator, a learning rate of 0.1, and dimension 100. The BERT text embeddings have dimension 1024, which is the native dimension of this language model. As the text embedding models often favor surface form similarity (e.g., associations like daily for day), we devise variants of this method that excludes associations with Levenshtein similarity higher than a threshold t.
CSKG: The CommonSense Knowledge Graph
691
We evaluate by comparing the embedding-based list to the benchmark one, through customary ranking metrics, like Mean Average Precision (MAP) and Normalized Discounted Cumulative Gain (NDCG). Our investigations show that TransE is the best-performing algorithm overall, with MAP of 0.207 and NDCG of 0.530. The optimal BERT variant uses threshold of t = 0.9, scoring with MAP of 0.209 and NDCG of 0.268. The obtained MAP scores indicate that the embeddings capture relevant signals, yet, a principled solution to USF-FAN requires a more sophisticated embedding search method that can capture various forms of both relatedness and similarity. In the future, we aim to investigate embedding techniques that integrate structural and content information like RDF2Vec [25], and evaluate on popular word similarity datasets like WordSim-353 [9].
5
Applications
As the creation of CSKG is largely driven by downstream reasoning needs, we now investigate its relevance for commonsense question answering: 1) we measure its ability to contribute novel evidence to support reasoning, and 2) we measure its role in pre-training language models for zero-shot downstream reasoning. 5.1
Retrieving Evidence from CSKG
We measure the relevance of CSKG for commonsense question answering tasks, by comparing the number of retrieved triples that connect keywords in the question and in the answers. For this purpose, we adapt the lexical grounding in HyKAS [18] to retrieve triples from CSKG instead of its default knowledge source, ConceptNet. We expect that CSKG can provide much more evidence than ConceptNet, both in terms of number of triples and their diversity. We experiment with four commonsense datasets: CommonSense QA (CSQA) [30], Social IQA (SIQA) [27], Physical IQA (PIQA) [3], and abductive NLI (aNLI) [2]. As shown in Table 5, CSKG significantly increases the number of evidence triples that connect terms in questions with terms in answers, in comparison to ConceptNet. We note that the increase is on average 2–3 times, the expected exception being CSQA, which was inferred from ConceptNet. We inspect a sample of questions to gain insight into whether the additional triples are relevant and could benefit reasoning. For instance, let us consider the CSQA question “Bob the lizard lives in a warm place with lots of water. Where does he probably live?”, whose correct answer is “tropical rainforest”. In addition to the ConceptNet triple /c/en/lizard /c/en/AtLocation /c/en/tropical rainforest, CSKG provides two additional triples, stating that tropical is an instance of place and that water may have property tropical. The first additional edge stems from our mappings from FrameNet to ConceptNet, whereas the second comes from Visual Genome. We note that, while CSKG increases the coverage with respect to available commonsense knowledge, it is also incomplete: in the above example, useful information such as warm temperatures being typical for tropical rainforests is still absent.
692
F. Ilievski et al.
Table 5. Number of triples retrieved with ConceptNet and CSKG on different datasets. Train #Questions ConceptNet CSKG
Dev #Questions ConceptNet CSKG
CSQA 9,741
78,729
125,552 1,221
9,758
15,662
SIQA
126,596
266,937 1,954
7,850
16,149
33,410
PIQA 16,113
18,549
59,684
1,838
2,170
6,840
aNLI
257,163
638,841 1,532
5,603
13,582
169,654
Table 6. Zero-shot evaluation results with different combinations of models and knowledge sources, across five commonsense tasks, as reported in [19]. CWWV combines ConceptNet, Wikidata, WordNet, and Visual Genome. CSKG is a union of ATOMIC and CWWV. We report mean accuracy over three runs, with 95% confidence interval. Model
KG
aNLI
CSQA
PIQA
SIQA
WG
GPT2-L
ATOMIC 59.2(±0.3) 48.0(±0.9) 67.5(±0.7) 53.5(±0.4) 54.7(±0.6)
GPT2-L
CWWV
58.3(±0.4) 46.2(±1.0) 68.6(±0.7) 48.0(±0.7) 52.8(±0.9)
GPT2-L
CSKG
59.0(±0.5) 48.6(±1.0) 68.6(±0.9) 53.3(±0.5) 54.1(±0.5)
RoBERTa-L ATOMIC 70.8(±1.2) 64.2(±0.7) 72.1(±0.5) 63.1(±1.5) 59.6(±0.3)
5.2
RoBERTa-L CWWV
70.0(±0.3) 67.9(±0.8) 72.0(±0.7) 54.8(±1.2) 59.4(±0.5)
RoBERTa-L CSKG
70.5(±0.2) 67.4(±0.8) 72.4(±0.4) 63.2(±0.7) 60.9(±0.8)
Human
91.4
−
88.9
94.9
86.9
94.1
Pre-training Language Models with CSKG
We have studied the role of various subsets of CSKG for downstream QA reasoning extensively in [19]. Here, CSKG or its subsets were transformed into artificial commonsense question answering tasks. These tasks were then used instead of training data to pre-train language models, like RoBERTa and GPT-2. Such a CSKG-based per-trained language model was then ‘frozen’ and evaluated in a zero-shot manner across a wide variety of commonsense tasks, ranging from question answering through pronoun resolution and natural language inference. We select key results from these experiments in Table 6. The results demonstrate that no single knowledge source suffices for all benchmarks and that using CSKG is overall beneficial compared to using its subgraphs, thus directly showing the benefit of commonsense knowledge consolidation. In a follow-up study [11], we further exploit the consolidation in CSKG to pre-train the language models with one dimension (knowledge type) at a time, noting that certain dimensions of knowledge (e.g., temporal knowledge) are much more useful for reasoning than others, like lexical knowledge. In both cases, the kind of knowledge that benefits each task is ultimately conditioned on the alignment between this knowledge and the targeted task, indicating that subsequent work should further investigate how to dynamically align knowledge with the task at hand.
CSKG: The CommonSense Knowledge Graph
6
693
Discussion
Our analysis in Sect. 4 revealed that the connectivity in CSKG is higher than merely concatenation of the individual sources, due to our mappings across sources and the merge of identical nodes. Its KGTK format allowed us to seamlessly compute and evaluate a series of embeddings, observing that TransE and BERT with additional filtering are the two best-performing and complementary algorithms. The novel evidence brought by CSKG on downstream QA tasks (Sect. 5) is a signal that can be exploited by reasoning systems to enhance their performance and robustness, as shown in [19]. Yet, the quest to a rich, highcoverage CSKG is far from completed. We briefly discuss two key challenges, while broader discussion can be found in [11]. Node resolution. As large part of CSKG consists of lexical nodes, it suffers from the standard challenges of linguistic ambiguity and variance. For instance, there are 18 nodes in CSKG that have the label ‘scene’, which includes WordNet or OpenCyc synsets, Wikidata Qnodes, frame elements, and a lexical node. Variance is another challenge, as /c/en/caffeine, /c/en/caffine, and /c/en/the active ingredient caffeine are all separate nodes in ConceptNet (and in CSKG). We are currently investigating techniques for node resolution applicable to the heterogeneity of commonsense knowledge in CSKG. Semantic enrichment. We have normalized the edge types across sources to a single, ConceptNet-centric, set of 58 relations. In [11], we classify all CSKG’s relations into 13 dimensions, enabling us to consolidate the edge types further. At the same time, some of these relations hide fine-grained distinctions, for example, WebChild [31] defines 19 specific property relations, including temperature, shape, and color, all of which correspond to ConceptNet’s /r/HasProperty. A novel future direction is to produce hierarchy for each of the relations, and refine existing triples by using a more specific relation (e.g., use the predicate ‘temperature’ instead of ‘property’ when the object of the triple is ‘cold’).
7
Conclusions and Future Work
While current commonsense knowledge sources contain complementary knowledge that would be beneficial as a whole for downstream tasks, such usage is prevented by different modeling approaches, foci, and sparsity of available mappings. Optimizing for simplicity, modularity, and utility, we proposed a hyperrelational graph representation that describes many nodes with a few edge types, maximizes the high-quality links across subgraphs, and enables natural language access. We applied this representation approach to consolidate a commonsense knowledge graph (CSKG) from seven very diverse and disjoint sources: a textbased commonsense knowledge graph ConceptNet, a general-purpose taxonomy Wikidata, an image description dataset Visual Genome, a procedural knowledge source ATOMIC, and three lexical sources: WordNet, Roget, and FrameNet. CSKG describes 2.2 million nodes with 6 million statements. Our analysis showed
694
F. Ilievski et al.
that CSKG is a well-connected graph and more than ‘a simple sum of its parts’. Together with CSKG, we also publicly release a series of graph and text embeddings of the CSKG nodes, to facilitate future usage of the graph. Our analysis showed that graph and text embeddings of CSKG have complementary notions of similarity, as the former focus on structural patterns, while the latter on lexical features of the node’s label and of its neighborhood. Applying CSKG on downstream commonsense reasoning tasks, like QA, showed an increased recall as well as an advantage when pre-training a language model to reason across datasets in a zero-shot fashion. Key standing challenges for CSKG include semantic consolidation of its nodes and refinement of its property hierarchy. Notebooks for analyzing these resources can be found on our public GitHub page: https:// github.com/usc-isi-i2/cskg/tree/master/ESWC2021. Acknowledgements. This work is sponsored by the DARPA MCS program under Contract No. N660011924033 with the United States Office Of Naval Research, and by the Air Force Research Laboratory under agreement number FA8750-20-2-10002.
References 1. Baker, C.F., Fillmore, C.J., Lowe, J.B.: The berkeley framenet project. In: Proceedings of the 17th international conference on Computational linguistics (1998) 2. Bhagavatula, C., et al.: Abductive commonsense reasoning. arXiv preprint arXiv:1908.05739 (2019) 3. Bisk, Y., Zellers, R., Bras, R.L., Gao, J., Choi, Y.: Piqa: Reasoning about physical commonsense in natural language. arXiv preprint arXiv:1911.11641 (2019) 4. Bordes, A., Usunier, N., Garcia-Duran, A., Weston, J., Yakhnenko, O.: Translating embeddings for modeling multi-relational data. Adv. Neural Inf. Process. Syst. 26, 2787–2795 (2013) 5. Corcoglioniti, F., Rospocher, M., Aprosio, A.P., Tonelli, S.: Premon: a lemon extension for exposing predicate models as linked data. In: Proceedings of the Tenth International Conference on Language Resources and Evaluation (LREC 2016) (2016) 6. De Lacalle, M.L., Laparra, E., Aldabe, I., Rigau, G.: Predicate matrix: automatically extending the semantic interoperability between predicate resources. Lang. Resour. Eval. 50(2), 263–289 (2016) 7. Deng, J., Dong, W., Socher, R., Li, L.J., Li, K., Fei-Fei, L.: ImageNet: a large-scale hierarchical image database. In: 2009 IEEE Conference on Computer Vision and Pattern Recognition, pp. 248–255. IEEE (2009) 8. Devlin, J., Chang, M.W., Lee, K., Toutanova, K.: Bert: Pre-training of deep bidirectional transformers for language understanding. arXiv preprint arXiv:1810.04805 (2018) 9. Finkelstein, L., et al.: Placing search in context: The concept revisited. In: Proceedings of the 10th International Conference on World Wide Web, pp. 406–414 (2001) 10. Ilievski, F., et al.: KGTK: a toolkit for large knowledge graph manipulation and analysis. In: Pan, J.Z., et al. (eds.) ISWC 2020, Part II. LNCS, vol. 12507, pp. 278–293. Springer, Cham (2020). https://doi.org/10.1007/978-3-030-62466-8 18
CSKG: The CommonSense Knowledge Graph
695
11. Ilievski, F., Oltramari, A., Ma, K., Zhang, B., McGuinness, D.L., Szekely, P.: Dimensions of commonsense knowledge. arXiv preprint arXiv:2101.04640 (2021) 12. Ilievski, F., Szekely, P., Schwabe, D.: Commonsense knowledge in WikiData. In: Proceedings of the WikiData Workshop, ISWC (2020) 13. Kipfer, B.: Roget’s 21st century thesaurus in dictionary form (´ed. 3) (2005) 14. Krishna, R., et al.: Visual genome: connecting language and vision using crowdsourced dense image annotations. Int. J. Comput. Vis. 123(1), 32–73 (2017) 15. Lerer, A., et al.: Pytorch-biggraph: A large-scale graph embedding system. arXiv preprint arXiv:1903.12287 (2019) 16. Lin, B.Y., Chen, X., Chen, J., Ren, X.: KagNet: Knowledge-aware graph networks for commonsense reasoning. arXiv preprint arXiv:1909.02151 (2019) 17. Liu, Y., et al.: Roberta: A robustly optimized BERT pretraining approach. arXiv preprint arXiv:1907.11692 (2019) 18. Ma, K., Francis, J., Lu, Q., Nyberg, E., Oltramari, A.: Towards generalizable neurosymbolic systems for commonsense question answering. In: EMNLP-COIN (2019) 19. Ma, K., Ilievski, F., Francis, J., Bisk, Y., Nyberg, E., Oltramari, A.: Knowledgedriven data construction for zero-shot evaluation in commonsense question answering. In: 35th AAAI Conference on Artificial Intelligence (2021) 20. McCrae, J.P.: Mapping wordnet instances to Wikipedia. In: Proceedings of the 9th Global WordNet Conference (GWC 2018), pp. 62–69 (2018) 21. Miller, G.A.: Wordnet: a lexical database for English. Commun. ACM 38(11), 39–41 (1995) 22. Navigli, R., Ponzetto, S.P.: BabelNet: building a very large multilingual semantic network. In: Proceedings of ACL (2010) 23. Nelson, D.L., McEvoy, C.L., Schreiber, T.A.: The university of South Florida free association, rhyme, and word fragment norms. Behav. Res. Methods Instrum. Comput. 36(3), 402–407 (2004). https://doi.org/10.3758/BF03195588 24. Nickel, M., Tresp, V., Kriegel, H.P.: A three-way model for collective learning on multi-relational data. ICML 11, 809–816 (2011) 25. Ristoski, P., Paulheim, H.: RDF2Vec: RDF graph embeddings for data mining. In: Groth, P., et al. (eds.) ISWC 2016, Part I. LNCS, vol. 9981, pp. 498–514. Springer, Cham (2016). https://doi.org/10.1007/978-3-319-46523-4 30 26. Sap, M., et al.: Atomic: an atlas of machine commonsense for if-then reasoning. In: Proceedings of the AAAI Conference on Artificial Intelligence (2019) 27. Sap, M., Rashkin, H., Chen, D., LeBras, R., Choi, Y.: Socialiqa: Commonsense reasoning about social interactions. arXiv preprint arXiv:1904.09728 (2019) 28. Schuler, K.K.: VerbNet: A broad-coverage, comprehensive verb lexicon (2005) 29. Speer, R., Chin, J., Havasi, C.: Conceptnet 5.5: an open multilingual graph of general knowledge. In: Thirty-First AAAI Conference on Artificial Intelligence (2017) 30. Talmor, A., Herzig, J., Lourie, N., Berant, J.: Commonsenseqa: A question answering challenge targeting commonsense knowledge. arXiv preprint arXiv:1811.00937 (2018) 31. Tandon, N., De Melo, G., Weikum, G.: Webchild 2.0: fine-grained commonsense knowledge distillation. In: ACL 2017, System Demonstrations (2017) ´ Bouchard, G.: Complex embed32. Trouillon, T., Welbl, J., Riedel, S., Gaussier, E., dings for simple link prediction. In: ICML (2016) 33. Trumbo, D.: Increasing the usability of research lexica. Ph.D. thesis, University of Colorado at Boulder (2006) 34. Vrandeˇci´c, D., Kr¨ otzsch, M.: WikiData: a free collaborative knowledgebase. Commun. ACM 57(10), 78–85 (2014)
696
F. Ilievski et al.
35. Yang, B., Yih, W.T., He, X., Gao, J., Deng, L.: Embedding entities and relations for learning and inference in knowledge bases. arXiv preprint arXiv:1412.6575 (2014) 36. Yang, Z., Dai, Z., Yang, Y., Carbonell, J., Salakhutdinov, R.R., Le, Q.V.: XLNet: generalized autoregressive pretraining for language understanding. In: Advances in Neural Information Processing Systems, pp. 5754–5764 (2019) 37. Zareian, A., Karaman, S., Chang, S.F.: Bridging knowledge graphs to generate scene graphs. arXiv preprint arXiv:2001.02314 (2020) 38. Zellers, R., Bisk, Y., Schwartz, R., Choi, Y.: Swag: A large-scale adversarial dataset for grounded commonsense inference. arXiv preprint arXiv:1808.05326 (2018)
In-Use Track
A Knowledge Graph-Based Approach for Situation Comprehension in Driving Scenarios Lavdim Halilaj1(B) , Ishan Dindorkar2 , J¨ urgen L¨ uttin1 , and Susanne Rothermel1 1 Bosch Corporate Research, Renningen, Germany {lavdim.halilaj,juergen.luettin,susanne.rothermel}@de.bosch.com 2 Robert Bosch Engineering and Business SPL, Bengaluru, India [email protected]
Abstract. Making an informed and right decision poses huge challenges for drivers in day-to-day traffic situations. This task vastly depends on many subjective and objective factors, including the current driver state, her destination, personal preferences and abilities as well as surrounding environment. In this paper, we present CoSI (Context and Situation Intelligence), a Knowledge Graph (KG)-based approach for fusing and organizing heterogeneous types and sources of information. The KG serves as a coherence layer representing information in the form of entities and their inter-relationships augmented with additional semantic axioms. Harnessing the power of axiomatic rules and reasoning capabilities enables inferring additional knowledge from what is already encoded. Thus, dedicated components exploit and consume the semantically enriched information to perform tasks such as situation classification, difficulty assessment, and trajectory prediction. Further, we generated a synthetic dataset to simulate real driving scenarios with a large range of driving styles and vehicle configurations. We use KG embedding techniques based on a Graph Neural Network (GNN) architecture for a classification task of driving situations and achieve over 95% accuracy whereas vector-based approaches achieve only 75% accuracy for the same task. The results suggest that the KG-based information representation combined with GNN are well suited for situation understanding tasks as required in driver assistance and automated driving systems. Keywords: Situation comprehension · Knowledge graph graph embedding · Graph neural network
1
· Knowledge
Introduction
Safe driving requires an understanding of the current driving situation which includes perceiving the current traffic situation, comprehending their meaning and predicting what could happen in the near future. Situation Awareness c Springer Nature Switzerland AG 2021 R. Verborgh et al. (Eds.): ESWC 2021, LNCS 12731, pp. 699–716, 2021. https://doi.org/10.1007/978-3-030-77385-4_42
700
L. Halilaj et al.
(SA) is a concept that attempts to describe and integrate these cognitive processes [12]. SA is the driver’s useful moment-to-moment knowledge and understanding of the driving environment but does not include the decision making. SA by machine could assist the driver and reduce accidents by warning about difficult driving situations. However, the behaviour of the driver in the vast range of situations is not well understood [7]. Vehicles with driver assistance systems (DAS) [4] aim to take some work-load off the driver to improve comfort and efficiency and to enhance driving safety. These systems are aware of the driving situation and benefit from the concept of SA at different task levels of perception, decision making and action [33]. A shared control driver assistance system based on driver intention identification and situation assessment has been proposed in [28]. The application of driver safety warning, particularly collision warning has been described in [25]. Automated Driving Systems (ADS) require the system rather than the driver to maintain high safety performance. A number of metrics to define the driving safety performance of ADS and compare it to that of human driven vehicles have been proposed in [42]. Currently, in many highly automated driving scenarios, the driver is required to take-over the driving task in cases where the system is not capable to handle the situation safely [1]. This requires machine perception to assess the current driving situation followed by scene understanding and decision making. Whereas much progress has been made in machine perception, scene understanding and prediction of the next actions of the traffic participants is still subject to extensive research [10]. In this paper, we propose CoSI, a Knowledge Graph (KG)-based approach for representing numerous information sources relevant for traffic situations. It includes information about driver, vehicle, road infrastructure, driving situation and interacting traffic participants. We built an ontology to encapsulate the core concepts crucial for the driving context. Concepts from external ontologies are reused, enabling an easy extension and interlinking with different data sources as well as facilitating data extraction. We describe how the knowledge in the KG is utilized via an embedding method such as Graph Neural Networks (GNN) to implement typical classification and prediction tasks used in DAS and ADS. Our approach is evaluated on a synthetically generated dataset comprising a large number of traffic situations and driving styles. We also compare the performance of our proposed approach with classic vector-based feature representations.
2
Related Work
Some key tasks in DAS and ADS are the detection and tracking of the relevant traffic participants, prediction of their possible actions, understanding of the traffic situation and planning of the next movement based on the actual context. According to [26] approaches for vehicle motion prediction can be grouped into Physics-based, Maneuver-based and Interaction-based. Classical Rule-based decision-making systems in automated driving are limited in terms of generalization to unseen situations. Deep reinforcement learning
A Knowledge Graph-Based Approach for Situation Comprehension
701
Fig. 1. Driving Dimensions. Categories of driving dimensions: 1) Objective Dimensions, further divided in Out-Cabin and In-Cabin; and 2) Subjective Dimensions, grouped in Personal, Driving, and Plans.
(DRL) is therefore used to learn decision policies from data and has shown to improve rule-based systems [29]. Different deep neural approaches and feature combinations for trajectory prediction are described in [27] in which surrounding vehicles and their features are extracted from fixed grid cells. Convolutional neural networks (CNN) that use fixed occupancy grids are limited by the grid size and the number of vehicles considered [30]. Recurrent neural networks (RNN) are able to model temporal information and variable input size, but are not well suited to handle a variable number of objects permutation-invariant w.r.t. the input elements [20]. When RNNs are combined with an Attention mechanism, they can be used to create a representation which is permutation invariant w.r.t. the input objects [38]. Deep Sets provide a more flexible architecture that can process inputs of varying size [43] and are used for DRL in Automated Driving [20]. One limiting factor of these approaches is the implicit and informal representation of entities and relational information between entities. Ontologies on the other hand encompass the formal definition of entities and their relations. Authors in [6] present an approach that uses ontologies to represent knowledge for driver assistance systems. A traffic intersection description ontology for DAS is described in [21]. It also uses logic inference to check and extend the situation description and to interpret the situation e.g. by reasoning about traffic rules. An ontology-based driving scene modeling, situation assessment, and decision making for ADS is proposed in [19].
702
L. Halilaj et al.
Graph Neural Networks (GNN) have been applied to model traffic participant interaction [8,11]. VectorNet, a hierarchical graph neural network is used for behaviour prediction in traffic situations [15]. A behaviour interaction network that captures vehicle interactions has been described in [13]. Our approach in comparison is overarching, consisting of phases for perception, knowledge ingestion, and situation comprehension. It exploits relationships between the ego and foe vehicles from a graph-based representation. Personal and subjective aspects of the driver and other involved participants are covered as well. Our motivation is that explicit encoding of information might lead to improved modelling of interactions between vehicles. We use multi-relational graph convolution networks [41] that are able to encode multi-modal node features.
3
Driving Dimensions
Assisting the driver with fully-informed decisions about steering, acceleration, breaking, or more complex tasks like lane changing requires a high level of situation understanding. Figure 1 illustrates an overview of dimensions divided in two main groups, namely Objective Dimensions and Subjective Dimensions. Objective Dimensions. There exist a number of dimensions that can be explicitly perceived from sensors or derived via specific methods. This group comprises dimensions presented in [16], which are related to dynamics, complexity and uncertainty impacting the drivability of a driving scene irrelevant of the driver personality. The ability to scrutinize them in a right manner directly influences the comprehension of the occurring events. Potential hazardous situations can only be identified by further investigating the interactions and the intent of road participants [36]. This information is rather implicit and has to be inferred by combining observations with additional algorithmic procedures. Considering the origin of these dimensions, they are divided into two categories: 1) Out-Cabin; and 2) In-Cabin. The Out-Cabin category comprises information happening outside the vehicle boundaries. Such information include the actual traffic, road and weather conditions, static objects, illumination, and others. All kind of information pertaining to what is happening inside the vehicle belongs to the In-Cabin category. It consists of information related to driver status, occupant behavior, vehicle status, and others. An exhaustive list of the objective dimensions including their categorization and further details which impact the drivability of a scene are presented in [16]. Subjective Dimensions. Objective dimensions alone are not sufficient for a personalized situation assessment. It heavily depends on the individuality of the driver itself. Not each explicitly perceived situation occurring in a given driving scenario is considered the same or has the equal level of difficulty. Therefore, a number of subjective dimensions are crucial in determining correct situation classification or difficulty level. The subjective subcategories cover information pertaining to personal, driving, and current plans.
A Knowledge Graph-Based Approach for Situation Comprehension
703
In general, each subcategory belonging to the outer circle can have tens of signals coming from sensors through different transmission channels like Controller Area Network (CAN) bus. These signals include information such as gaze direction, drowsiness, inside- and outside-temperature, fuel consumption, number of occupants. Next, special processing units consume and manage retrieved signals to generate appropriate notifications to the driver or actions to the vehicle.
4
Approach
Achieving a high level of intelligence is possible by fusing and enriching collected data from different sources such as connected sensors. This enables autonomous vehicles to react according to the situation within a driving environment [9]. With the aim of covering the entire process, we designed a flow-oriented architecture composed of three main phases, namely: 1) Contextual Observation; 2) Knowledge Ingestion; and 3) Situation Comprehension. Each phase comprises a number of components dedicated to perform specific tasks as shown in Fig. 2. 4.1
Contextual Observation
Intelligent vehicles are equipped with a number of sophisticated sensors that sense the surrounding of the vehicle. Typically, the average number of sensors in a smart vehicle is ranging from 70 up to 100 [18], monitoring various types of events as well as stationary and mobile objects. This includes observing the driver and occupant(s), engine status, and the road network. Spatial and temporal information is obtained for each observed object. A wide range of sensors, e.g. light and rain sensors, internal and external cameras, Radar and Lidar are used for perception tasks. Each sensor may be built via a specific technology and standard, thus generating data in various formats with a different granularity. 4.2
Knowledge Ingestion
Situation comprehension requires integrating and structuring the abundance of information from various sources. Raw signals from sensors are transformed and enriched with additional semantics. Further, contextual information and user characteristics are injected to support a personalized situation assessment. Knowledge Graph. The KG serves as a coherence component comprising fundamental ontologies to capture information about entities and their relationships. We see a KG as a set of triples G = H, R, T , where H is a set of entities, T ⊆ E × L, a set of entities E or literal L values and R, a set of relationships connecting H and T . These triples are represented using Resource Definition Framework (RDF) as a modeling language. Encoding additional formal axioms enables inferring new facts out of given ones via automated reasoning techniques. Once the transformation process is realized, i.e. converting input data of any format to triples, the output is stored in a knowledge graph. Information in the
704
L. Halilaj et al.
Fig. 2. CoSI Pipeline. The pipeline is comprised of three consecutive phases: 1) Contextual Observation - capture information about the surroundings and the user; 2) Knowledge Ingestion - transform, enrich and ingest information on the KG; and 3) Situation Classification - assess the situation type considering the contextual knowledge.
KG is aggregated and organized in an intuitive and hierarchical way, making it easy to exploit and understand by humans. An excerpt of the CoSI KG (CKG) is given in Fig. 3, showing how scenery information is represented via instances (assertional box ) of ontological concepts (terminological box ). Apart from sensor data, it captures the information related to the driver such as preferences and abilities modeled according to the CoSI ontology as described in the following. Ontology. We developed the CoSI ontology based on the dimensions and their respective categories described in Sect. 3. It captures relevant information coming from sensors mounted in a given vehicle. The human description of crucial concepts: Scene, Situation and Scenario given in [37] are used as a basis to create formal definitions using ontological axioms. Additionally, the ontology models different user characteristics such as preferences (e.g., preferred driving style or safety measures), experience and (dis)abilities. In the following, the respective definitions of core concepts of the CoSI ontology are given: – Scene: A scene describes a snapshot of the environment including the scenery and dynamic elements, as well as all actors’ and observers’ selfrepresentations, and the relationships among those entities [37]. – Situation: A situation is the entirety of circumstances considered for the selection of an appropriate behavior pattern at a particular point of time. It entails all relevant conditions, options and determinants for behavior [37]. – Scenario: A scenario describes the temporal development between several scenes in a sequence of scenes. Actions, events and goals may be specified to characterize this temporal development in a scenario [37]. – Observation: Act of carrying out an (Observation) Procedure to estimate or calculate a value of a property of a FeatureOfInterest [17]. – Driver : A driver is a specific type of user. It encapsulates all relevant attributes associated to a driving context where driver is the main subject. – Profile: A user profile is a structured data representation that is used to capture certain characteristics about an individual user1 . 1
https://en.wikipedia.org/wiki/User profile.
A Knowledge Graph-Based Approach for Situation Comprehension
705
Fig. 3. CoSI Knowledge Graph. An excerpt of the CoSI KG representing respective situations occurring in two consecutive scenes: 1) the bottom layer depicts scenery information among participants; 2) the top layer includes concepts such as classes and relationships representing the domain knowledge; and 3) the middle layer contains concrete instances capturing the scenery information based on the ontological concepts.
– Preference: A preference is a technical term in psychology, economics and philosophy usually used in relation to choosing between alternatives. For example, someone prefers A over B if they would rather choose A than B2 . The CoSI ontology is built on principles for an easy extension and exploration. Concepts from external ontologies such as Schema.org and SOSA ontology3 , are reused to enable interlinking with different data sources. Currently, it contains 51 classes, 57 object datatype properties and 3 annotation properties. Transformation and Enrichment. This component performs a semiautomatic conversion of sensor data to the RDF representation via both declarative and imperative approaches. Using the declarative approach, a number of mappings of sensor data to the ontological concepts are defined. The imperative approach is realized in cases when it is necessary to perform complex transformations. In these cases, additional queries are executed on-the-fly to enrich sensor data with new relationships. For instance, raw data generated from sensors are augmented with additional semantic information in order to establish new type definitions or missing relationships between scenes, e.g. occursAfter.
2 3
https://en.wikipedia.org/wiki/Preference. https://schema.org/, https://www.w3.org/TR/vocab-ssn/.
706
L. Halilaj et al.
Knowledge Extraction. Performing tasks such as knowledge graph completion, link prediction, classification, or other types of downstream tasks requires knowledge to be consumed based on various perspectives. This component allows for execution of complex queries and traversing the graph to retrieve relevant information. Various views of the information can be created on the fly while the underlying knowledge structure remains unchanged. For instance, while originally the information is organized from the perspective of a Scene, i.e. participants, their position, speed as well as the type of situation happening in it; by traversing the graph through specific queries, another view from the ego vehicle perspective can easily be generated as illustrated in Fig. 4. As a result, embedding techniques that operate on graph level, can efficiently learn the vector representation of symbolic knowledge from the “new perspective”. 4.3
Situation Comprehension
A number of specialized components perform dedicated tasks related to situation comprehension, such as Situation Classification, Difficulty Assessment, and Trajectory Prediction. These components can be built on different paradigms, namely 1) Rule-based; and 2) Learning-based classification. – Rule-based Classification Components following this paradigm rely on a number of declarative rules to perform logic-based classification tasks. They harness the expressive power of the knowledge graph structure which in combination with reasoning techniques provide interpretable results. – Learning-based Classification Components employ a number of techniques that learn common patterns from a large number of observations. Therefore, it is possible to make predictions or classifications based on a given sample data used for training without pre-defining explicit rules.
(a) Ego View
(b) Construct Query
Fig. 4. Ego Vehicle Perspective. a) A traffic situation from the ego vehicle (green) perspective in the center and eight foe vehicles in its vicinity. b) A SPARQL query constructing a graph-based view on the fly from ego perspective. (Color figure online)
A Knowledge Graph-Based Approach for Situation Comprehension
707
Table 1. Simulation Parameters. Simulation parameters of the driver and vehicle that were varied to generate a large range of driving situations. Parameter
Description
lcSpeedGain
Driver’s eagerness for speed gain by overtaking
lcCooperative Driver’s cooperativeness in reducing speed for other vehicles
5
σ (sigma)
Driver’s imperfection in realizing desired speed
τ (tau)
Driver’s reaction time in seconds
minGap
Driver’s target gap between ego and foe vehicle
maxSpeed
Vehicle’s maximum speed
maxAccel
Vehicle’s maximum acceleration
Implementation
Our objective is to evaluate how well our KG-model can represent traffic situations. Particularly, we focus on situations with interacting vehicles, where vehicles base their behaviour on current and predicted behaviour of other nearby vehicles, considered a notoriously challenging task. We thus define driving situation classification as our evaluation task. To validate the benefit of our model with as little influence from other factors, we deliberately define the task on single scenes. Models that exploit temporal information are very likely to lead to better results, since some situations such as merging or overtaking are manifested via a gradual change of the lane ID over time. However, here we only validate the underlying static knowledge and exclude effects of temporal information. 5.1
Dataset Generation
Experimental Setup. Experiments on recorded test drives is prohibitive [22] as it would require huge amounts of test data without assurance that enough examples of critical driving situations are included. We therefore use simulated data for our experiments. An advantage of this approach is that it allows to specifically generate critical driving scenes which we are interested in, both in terms of driving behaviour and situation criticality. We use Simulations of Urban Mobility (SUMO)4 , an open source, highly portable, microscopic and continuous multi-modal traffic simulation package to generate driving data. We generated a dataset5 comprising more than 50 000 driving examples on a 40 km long highway section around the Gothenburg city as shown in Fig. 5a. It is circular in shape with three lanes in each direction. Scenarios. We varied simulation parameters such as time-to-collision (TTC) (i.e. the time until a collision between two entities would occur if both continue with the present velocities) of drivers and vehicles to simulate different driving styles 4 5
https://www.eclipse.org/sumo/. https://github.com/siwer/Retra.
708
L. Halilaj et al.
(a) Gothenburg’s Highway
(b) Lane change situation
(c) Collision situation
Fig. 5. Sumo traffic simulations. Examples of traffic simulations using SUMO: a) A snapshot of a highway around the city of Gothenburg; b) A situation where ego vehicle is switching the most left lane; and c) An example with a collision situation happening.
and vehicle types as listed in Table 1. This leads to the generation of various driving scenarios as described in Table 2. Car Following Model. The standard car following model in SUMO is described in [24]. It is based on the assumption that the speed of the ego vehicle is adapted according to the speed of the preceding vehicle. Further, a desired gap between the ego and the leading vehicle as well as reaction and braking time are taken into account to ensure that no collision will occur. Figure 5c depicts a situation where a collision between the ego and the foe is happening. Lane Change Model. The lane change model considers different motivations of the driver (route, speed gain, rule-following, cooperativeness and other factors) for lane changes on multi-lane roads and related speed adjustments [14]. Figure 5b shows an example where the ego vehicle is performing a lane change. 5.2
CoSI Knowledge Graph
Data generated from SUMO are provided in XML format which are then transformed and enriched on-the-fly to RDF representation. As a result, the CoSI Knowledge Graph (CKG) is created with over 915 million triples. There are more than 84K Conflict Scenarios containing millions of instances of different types of situations, such as Following Leader, Following Follower, Crossing, Merge etc. These instances consist of information about the conflict points, speed of ego and foe vehicle, and the direction of movement, respectively. Further, CKG has more than 10K Lane Change Scenarios, which also contains millions of instances of different lane change situations, categorized in respective ontological classes, such as Speed Gain, Keep Right, or Sublane. 5.3
KG-Based Situation Classification
This component is implemented according to the principles of the learning-based paradigm. It uses a Relational Graph Convolutional Network [34] (R-GCN), an
A Knowledge Graph-Based Approach for Situation Comprehension
709
Table 2. Driving Scenarios. Different driving scenarios are simulated by varying simulation parameters of vehicle and the driving style. Driving scenario Description 1
Successful lane change
2
Abandoned lane change
3
Dangerous lane change (small gap, small TTC values)
4
Dangerous close car following (small gap, small TTC values)
5
Unexpected stopping of leading vehicle
6
Unexpected pedestrians on road
7
Collision between ego and foe vehicle
extension of Graph Convolutional Network (GCN) [23], to directly operate on a graph and learn its embeddings. Each layer l of the R-GCN calculates: Aˆr H (l) W (l) ) (1) H (l+1) = σ( r∈R
ˆr
where A is the normalized adjacency matrix of the graph G, W (l) is the weight matrix for layer (l) and σ the activation function, such as ReLU . H (l) ∈ RN ×D is the matrix of activation’s in the lth layer and H 0 the N × D matrix of D-dimensional node embeddings for nodes N in the graph. Similar as in [41], we extend the matrix of node embeddings H with feature embeddings for each node forming a Multimodal Relational Graph Convolutional Network (MRGCN): (l) (l) (l) (l) Aˆr HI WI + Aˆr HF WF ) (2) H (l+1) = σ( r∈R
(l)
(l)
where WI and WF are the learnable weights for the structural and feature components, respectively. 5.4
Vector-Based Situation Classification
To compare the performance of the KG-based classification with traditional feature based classifiers we implemented three methods described below. The features are extracted from our KG to represent vector-based features. To deal with a varying number of foe vehicles, we formed samples with tuples of the ego vehicle, a foe vehicle and their relational information such as TTC and distance. – Support Vector Machine (SVM) SVMs are a set of supervised learning methods that use a subset of the training samples, the so-called support vectors, in the decision function. – Decision-Tree Classifier (DTC) The fact that we have both, numerical and categorical features representing driving situations, the application of decision tree fits well to our classification task.
710
L. Halilaj et al.
– Multi-Layer Perceptron (MLP) Finally, we use a multi-layer perceptron neural network and train in with back-propagation for the classification task.
6
Evaluation
We empirically study the accuracy of our knowledge graph-based approach in a situation classification task. In this section, we describe in detail the experiment configuration for both, the KG-based as well as for the vector-based approaches, as well as the achieved results. To evaluate the performance of our KG-model, we compare classification results with vector-based feature representation in combination with different classifiers. 6.1
Experiment Configuration
For our experiments, we used a sub-set of the CKG with 6.4 million triples, representing around 226K Conflict Situations, each described with 28 triples on average. This is further divided in 134K for training, 46K for validation and 46K for testing. To investigate the relative importance of different features, we performed experiments with single features and combined features as shown in Table 3. The 5 most important features were selected based on heuristics. For each vehicle we have about 10 features on average (e.g., position, speed, acceleration, steering angle). The number of other features (e.g., minTTC, velocity difference, etc.) depends on the number of vehicles in the vicinity (50 m radius) around ego. The numeric features are normalized before further processing by the classifiers. MRGCN is implemented using one hidden layer with 40 nodes6 , trained in full batch mode with an ADAM optimizer. MLP uses 2 hidden layers with 40 hidden neurons per layer trained in full batch mode with an ADAM optimizer. SVM is implemented with radial basis function kernels and DTC uses the Classification And Regression Trees algorithm. 6.2
Results and Discussion
Results for the different methods and different number of features are shown in Table 3. The overall best results are obtained by the MRGCN method using the 5 most important features. For MRGCN, the performance using all features is slightly lower than for the 5 most important ones. For the vector-based methods SVM and DTC, best results are obtained using all features. When only one feature is used, DTC and MLP achieve the best performance. The experiments show that our KG-based classifier achieves considerably better results than all vector-based classifiers, in case when 5 most important or all features are used, respectively. This suggests that the graph-based representation provides more discriminating information compared to the classic feature vector-based representation. 6
https://gitlab.com/wxwilcke/mrgcn.
A Knowledge Graph-Based Approach for Situation Comprehension
711
Table 3. Classification accuracy. Accuracy for different features and different algorithms for the task of situation classification. MRGCN SVM DTC
MLP
0.468 0.501 0.607 0.673 0.883
0.511 0.569 0.510 0.542 0.514
Single features Vehicle signal Longitudinal lane position Steering angle Distance between vehicles Lane ID
0.510 0.566 0.524 0.529 0.520
0.511 0.507 0.641 0.491 0.890
Combined features ALL 36 features 0.938 5 most important features 0.953
0.708 0.750 0.648 0.746
0.733 0.742
Classification experiments with single features show that vector-based methods are superior to KG-based classifier for all features except Distance between vehicles. This suggests that KG-based methods have no clear advantage in simple situations but outperform vector-based methods in complex situations where multiple relationships and interactions exist between participants. It indicates that KG-based methods could also perform well in more complex tasks that consider much rich context as well as domain knowledge about the driver. We did not consider temporal information for our classification experiment. We believe that a superior performance of the KG-based method in learning relational information suggests that the method will also be able to learn temporal relations between nodes. The conducted experiments were the first attempts to prove the advantage of our CoSI approach and further experiments for tasks in automated driving will be the subject of future research.
7 7.1
Usage and Lessons Learned Usage
Bosch has been pushing research in automated driving for many years and as a result, many technologies are ready for highly automated driving today [5]. For example, Bosch has developed automated valet parking, the first fully automated system (SAE level 4). Therefore, the approach described here is one of the many ongoing activities to address the challenges in automated driving [3]. It represents one component of the overall architecture for an autonomous driving system [2]. The behavior of highly automated driving (HAD) systems especially in critical driving situations is crucial for their validation [39]. However, the validation based on recorded test drives would require millions or billions of test kilometers which makes it unfeasible [22]. Thus, alternate methods of validation including simulation are a common practice [44]. We therefore used simulated data to validate our approach. On the other hand, HAD vehicles will contain sensors
712
L. Halilaj et al.
and perception units providing information about the driving scene surrounding the ego-vehicle, similar to the information provided by the simulation tool (e.g. position, speed, and driving direction of nearby vehicles). We therefore expect that our approach is generic enough and will also perform well on real-world data. 7.2
Lessons Learned
Maturity of Semantic Technologies. For many years now, semantic technologies are widely used in specific domains e.g. education, life sciences and cultural heritage [31]. Recent advances of vendors such as Stardog, OntoText, and Cambridge Semantics7 on their respective solutions offer support for many use cases with different requirements and scenarios. Their primary function as triple stores is improved considerably, being now able to manage and query knowledge graphs with trillions of triples without experiencing significant degradation in performance. Other features such as knowledge exploration, visualization, or validation techniques are now inseparable and fully integrated in many triple stores. A wide range of industry related solutions can be implemented and fully operate in production, instead of a prototypical level. Therefore, we also consider their application in the automotive domain to be promising. Integration with Existing Data Sources. Typically, the sophisticated triple stores provide support for the Ontology-Based Data Access (OBDA) principles [32]. OBDA enables accessing heterogeneous data sources via ontologies and a set of mappings, that interlink this data with the ontological concepts. There are two main forms for realizing a data integration scenario: 1) virtual data access - data are kept in the original format but are transformed on-the-fly and accessed as RDF triples; 2) materialization of triples - data from relational tables are materialized in RDF triples to special named graphs. We followed a hybrid approach using both forms depending on the requirements and constraints: – Virtual data access is seen as a preferred solution in cases when it is crucial to avoid: 1) synchronization issues with data frequently changing; 2) replicating resources; and 3) issues with migrating legacy systems. – Materialization of triples is applied to prevent from: 1) performance degradation of running systems while executing complex queries; 2) safety and security issues with read/write permissions; and 3) issues with heavyweight reasoning for non-RDF data.
7
https://www.stardog.com, semantics.com.
https://www.ontotext.com,
https://www.cambridge
A Knowledge Graph-Based Approach for Situation Comprehension
713
Applicability of Knowledge Graph Embeddings. Knowledge graphs are powerful in encapsulating and representing prior knowledge, leveraging rich semantics and ontological structures. Additional rules and axioms encoded manually support the reasoning process where new facts are inferred from the existing ones. On the other hand, a number of knowledge graph embedding (KGE) methods are presented for learning latent information in a KG using low dimensional vectors [40]. They perform tasks such as knowledge graph completion, entity recognition and classification as well as downstream tasks like recommendation systems, question answering and natural language processing. Despite the fact that from their intrinsic nature, knowledge graphs are very flexible, we faced a number of challenges while preparing the data to be optimally processed by KGE methods. In particular, we had to define special queries each time when the information is scattered in n-ary relationships more than one hop away from the main node. A number of slightly different views are created on the fly comprising additional information encapsulated in main nodes. As a result, the KGE methods performed better in terms of achieving a higher accuracy.
8
Conclusions
This article presents CoSI, an approach for enabling situation comprehension using knowledge graphs. The CoSI ontology as the skeleton of CKG provides a semantic representation of core concepts in a driving context. Thus, our approach is able to effectively integrate data from heterogeneous sources and structures it into a common knowledge graph. To demonstrate the applicability of our approach, we performed a number of empirical evaluations with different machine learning methods. Results show that our approach achieves higher accuracy in the task of situation classification compared to traditional methods. This indicates that CKG can well represent complex information of the driving domain and when combined with graph-based neural networks leads to superior performance, achieving over 95% accuracy. As future work, we plan to further expand the CoSI ontology with more finegrained entities covering additional objective and subjective dimensions. Next, we will complement our approach via implementing the classification based on axiomatic rules described in [35]. Therefore, tasks such as difficulty assessment and trajectory prediction can be performed following rule- and learning-based paradigms, respectively. In order to improve tasks related to situation comprehension, we will further exploit objective dimensions, i.e. related to the context and time. Another goal is to include subjective dimensions in KGE methods for achieving a more personalized situation comprehension.
References 1. Bazilinskyy, P., Petermeijer, S.M., Petrovych, V., Dodou, D., Winter, J.D.: Takeover requests in highly automated driving: a crowdsourcing survey on auditory, vibrotactile, and visual displays. Transp. Res. Part F-Traffic Psychol. Behav. 56, 82–98 (2018)
714
L. Halilaj et al.
2. Becker, J., Helmle, M., Pink, O.: System architecture and safety requirements for automated driving (2017) 3. Becker, J., Kammel, S., Pink, O., Fausten, M.: Bosch’s approach toward automated driving. at - Automatisierungstechnik 63, 180–190 (2015) 4. Bengler, K., Dietmayer, K., F¨ arber, B., Maurer, M., Stiller, C., Winner, H.: Three decades of driver assistance systems: review and future perspectives. IEEE Intell. Transp. Syst. Mag. 6, 6–22 (2014) 5. Bolle, M., Knoop, S., Niewels, F., Schamm, T.: Early level 4/5 automation by restriction of the use-case. In: Internationales Stuttgarter Symposium (2017) 6. Buechel, M., Hinz, G., Ruehl, F., Schroth, H., Gyoeri, C., Knoll, A.: Ontologybased traffic scene modeling, traffic regulations dependent situational awareness and decision-making for automated vehicles. In: IEEE IV, pp. 1471–1476 (2017) 7. Campbell, K.: The shrp 2 naturalistic driving study: Addressing driver performance and behavior in traffic safety (2012) 8. Chen, C., et al.: Gated residual recurrent graph neural networks for traffic prediction. In: AAAI (2019) 9. Datta, S.K., Costa, R.P.F.D., H¨ arri, J., Bonnet, C.: Integrating connected vehicles in internet of things ecosystems: challenges and solutions. In: 17th International Symposium on WoWMoM, Portugal, pp. 1–6. IEEE Computer Society (2016) 10. Di, S., Zhang, H., Li, C.G., Mei, X., Prokhorov, D., Ling, H.: Cross-domain traffic scene understanding: a dense correspondence-based transfer learning approach. IEEE Trans. Intell. Transp. Syst. 19, 745–757 (2018) 11. Diehl, F., Brunner, T., Truong-Le, M., Knoll, A.: Graph neural networks for modelling traffic participant interaction. In: IEEE IV, pp. 695–701 (2019) 12. Ding, C., Mao, Y., Wang, W., Baumann, M.: Driving situation awareness in transport operations. In: Computational Intelligence for Traffic and Mobilit (2013). https://doi.org/10.2991/978-94-91216-80-0 3 13. Ding, W., Chen, J., Shen, S.: Predicting vehicle behaviors over an extended horizon using behavior interaction network. In: ICRA, pp. 8634–8640 (2019) 14. Erdmann, J.: Lane-changing model in sumo. In: SUMO2014. Reports of the DLRInstitute of Transportation Systems Proceedings, vol. 24, pp. 77–88. Deutsches Zentrum f¨ ur Luft- und Raumfahrt e.V., May 2014. https://elib.dlr.de/89233/ 15. Gao, J., et al.: VectorNet: encoding HD maps and agent dynamics from vectorized representation. In: IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pp. 11522–11530 (2020) 16. Guo, J., Kurup, U., Shah, M.: Is it safe to drive? An overview of factors, metrics, and datasets for driveability assessment in autonomous driving. IEEE Trans. Intell. Transp. Syst. 21(8), 3135–3151 (2020) 17. Haller, A., et al.: The modular SSN ontology: a joint W3C and OGC standard specifying the semantics of sensors, observations, sampling, and actuation. Semant. Web 10(1), 9–32 (2019) 18. Hamid, S.A., Hassanein, H.S., Takahara, G.: Vehicle as a resource (VAAR). IEEE Netw. 29(1), 12–17 (2015) 19. Huang, L., Liang, H., Yu, B., Li, B., Zhu, H.: Ontology-based driving scene modeling, situation assessment and decision making for autonomous vehicles. In: 2019 4th Asia-Pacific Conference on Intelligent Robot Systems (ACIRS), pp. 57–62 (2019) 20. H¨ ugle, M., Kalweit, G., Mirchevska, B., Werling, M., Boedecker, J.: Dynamic input for deep reinforcement learning in autonomous driving. In: IEEE/RSJ International Conference on Intelligent Robots and Systems (IROS), pp. 7566–7573 (2019) 21. H¨ ulsen, M., Z¨ ollner, J.M., Weiss, C.: Traffic intersection situation description ontology for advanced driver assistance. In: IEEE IV Symposium, pp. 993–999 (2011)
A Knowledge Graph-Based Approach for Situation Comprehension
715
22. Kalra, N., Paddock, S.: Driving to safety: how many miles of driving would it take to demonstrate autonomous vehicle reliability? Transp. Res. Part A-Policy Pract. 94, 182–193 (2016) 23. Kipf, T.N., Welling, M.: Semi-supervised classification with graph convolutional networks. In: 5th ICLR (2017). https://openreview.net/forum?id=SJU4ayYgl 24. Krauss, S., Wagner, P., Gawron, C.: Metastable states in a microscopic model of traffic flow. Phys. Rev. E 55, 5597–5602 (1997) 25. Kusano, K., Gabler, H.C.: Safety benefits of forward collision warning, brake assist, and autonomous braking systems in rear-end collisions. IEEE Trans. Intell. Transp. Syst. 13, 1546–1555 (2012) 26. Lef`evre, S., Vasquez, D., Laugier, C.: A survey on motion prediction and risk assessment for intelligent vehicles. ROBOMECH J. 1, 1–14 (2014) 27. Lenz, D., Diehl, F., Truong-Le, M., Knoll, A.C.: Deep neural networks for Markovian interactive scene prediction in highway scenarios. In: IEEE Intelligent Vehicles Symposium, IV 2017, pp. 685–692. IEEE (2017) 28. Li, M., Cao, H., Song, X., Huang, Y., Wang, J., Huang, Z.: Shared control driver assistance system based on driving intention and situation assessment. IEEE Trans. Industr. Inf. 14, 4982–4994 (2018) 29. Mirchevska, B., Pek, C., Werling, M., Althoff, M., Boedecker, J.: High-level decision making for safe and reasonable autonomous lane changing using reinforcement learning. In: 21st ITSC, pp. 2156–2162 (2018) 30. Mukadam, M., Cosgun, A., Nakhaei, A., Fujimura, K.: Tactical decision making for lane changing with deep reinforcement learning (2017) 31. Petersen, N., Halilaj, L., Grangel-Gonz´ alez, I., Lohmann, S., Lange, C., Auer, S.: Realizing an RDF-based information model for a manufacturing company – a case study. In: d’Amato, C., et al. (eds.) ISWC 2017. LNCS, vol. 10588, pp. 350–366. Springer, Cham (2017). https://doi.org/10.1007/978-3-319-68204-4 31 32. Poggi, A., Lembo, D., Calvanese, D., Giacomo, G.D., Lenzerini, M., Rosati, R.: Linking data to ontologies. J. Data Semant. 10, 133–173 (2008) 33. R¨ ockl, M., Robertson, P., Frank, K., Strang, T.: An architecture for situationaware driver assistance systems. In: IEEE 65th Vehicular Technology Conference - VTC-Spring, pp. 2555–2559 (2007) 34. Schlichtkrull, M., Kipf, T.N., Bloem, P., van den Berg, R., Titov, I., Welling, M.: Modeling relational data with graph convolutional networks. In: Gangemi, A., et al. (eds.) ESWC 2018. LNCS, vol. 10843, pp. 593–607. Springer, Cham (2018). https://doi.org/10.1007/978-3-319-93417-4 38 35. Schukraft, M., Rothermel, S., Luettin, J., Halilaj, L.: Towards a rule-based approach for estimating the situation difficulty in driving scenarios. In: 7th International Conference on Vehicle Technology and Intelligent Transport System (VEHITS) (2021, to appear) 36. Takahashi, R., Naoya Inoue, Y.K., Kobayashi, S., Inui, K.: Explaining potential risks in traffic scenes by combining logical inference and physical simulation, vol. 6, pp. 248–255 (2016) 37. Ulbrich, S., Menzel, T., Reschka, A., Schuldt, F., Maurer, M.: Defining and substantiating the terms scene, situation, and scenario for automated driving. In: 18th ITSC, Gran Canaria, Spain, pp. 982–988. IEEE (2015) 38. Vinyals, O., Bengio, S., Kudlur, M.: Order matters: sequence to sequence for sets. In: Bengio, Y., LeCun, Y. (eds.) 4th International Conference on Learning Representations, ICLR 2016 (2016) 39. Wang, C., Winner, H.: Overcoming challenges of validation automated driving and identification of critical scenarios. In: IEEE ITSC, pp. 2639–2644 (2019)
716
L. Halilaj et al.
40. Wang, Q., Mao, Z., Wang, B., Guo, L.: Knowledge graph embedding: a survey of approaches and applications. IEEE Trans. Knowl. Data Eng. 29, 2724–2743 (2017) 41. Wilcke, W.X., Bloem, P., de Boer, V., t Veer, R., van Harmelen, F.: End-to-end entity classification on multimodal knowledge graphs abs/2003.12383 (2020) 42. Wishart, J., et al.: Driving safety performance assessment metrics for ads-equipped vehicles (2020) 43. Zaheer, M., Kottur, S., Ravanbakhsh, S., Poczos, B., Salakhutdinov, R.R., Smola, A.J.: Deep sets. In: Advances in Neural Information Processing System, vol. 30 (2017) 44. Zofka, M.R., Klemm, S., Kuhnt, F., Schamm, T., Z¨ ollner, J.M.: Testing and validating high level components for automated driving: simulation framework for traffic scenarios. In: 2016 IEEE Intelligent Vehicles Symposium (IV), pp. 144–150 (2016)
Pay-as-you-go Population of an Automotive Signal Knowledge Graph Yulia Svetashova1(B) , Lars Heling2(B) , Stefan Schmid1 , and Maribel Acosta3 1
Bosch Corporate Research, Robert Bosch GmbH, Renningen, Germany [email protected] 2 Institute AIFB, Karlsruhe Institute of Technology, Karlsruhe, Germany [email protected] 3 Center of Computer Science, Ruhr University Bochum, Bochum, Germany [email protected]
Abstract. Nowadays, cars are equipped with hundreds of sensors that support a variety of features ranging from basic functionalities to advanced driver assistance systems. The communication protocol of automotive signals is defined in DBC files, yet, signal descriptions are typically ambiguous and vary across manufacturers. In this work, we address the problem of extracting the semantic data from DBC files, which is then managed in an Automotive Signal Knowledge Graph (ASKG). We developed a semi-automatic tool that automatically extracts signals from DBC files and computes candidate links to the ontology. These candidates can then be revised by experts who can also extend the ontology to accommodate new signal types in a pay-as-you-go manner. The knowledge provided by the experts is stored in the ASKG and exploited by the tool thereafter. We conducted an evaluation of the tool based on a targeted experiment with automotive experts and report on the first lessons learned from the usage of the tool in the context of the Bosch automotive data lake. The results show that our solution can correctly populate the ASKG and that the expert effort is reduced over time.
1
Introduction
In automotive engineering, signal processing technologies enable the communication between electronic control units (ECUs) in the car. The ECUs and sensors involved in the communication over the Controller Area Network (CAN) of a car are defined in DBC files1 A variety of applications rely on logs of the messages transmitted on the CAN bus to analyze and improve the interaction of the ECUs. Therefore, understanding the meaning of the data from DBC files is crucial for 1
Vector Informatik GmbH. DBC Communication Database for CAN,
https://www.
vector.com/.
Electronic supplementary material The online version of this chapter (https:// doi.org/10.1007/978-3-030-77385-4 43) contains supplementary material, which is available to authorized users. c Springer Nature Switzerland AG 2021 R. Verborgh et al. (Eds.): ESWC 2021, LNCS 12731, pp. 717–735, 2021. https://doi.org/10.1007/978-3-030-77385-4_43
718
Y. Svetashova et al.
subsequent analyses over this data. Moreover, a machine-processable representation of the data semantics facilitates data integration and process automation, which are key requirements for Bosch [14]. Nonetheless, the effective processing of DBC files is not straightforward. The first challenge is associated with the type of identifiers used in DBC files. These identifiers are usually composed of short, abbreviated terms that are difficult to disambiguate. An example of such identifiers is ACC Status, which could refer to the status of the Adaptive Cruise Control or the Automatic Climate Control component. In turn, the process of extracting the semantics from these identifiers is a challenging task. The second challenge is associated with the heterogeneity of the identifiers. Typically, manufacturers use different identifiers to represent the same signals, which makes it difficult to generalize the techniques developed for a specific DBC file. In this work, we present a novel tool, called CANnotator, which implements a pay-as-you-go approach that combines automatic techniques with human interaction to represent automotive signals defined in DBC files in an Automotive Signal Knowledge Graph (ASKG). At the core of the ASKG is the Vehicle Signal Specification Ontology [8] (VSSo), which is populated and extended with the signals captured in DBC files. CANnotator implements an entity extraction component, that expands the signal identifiers and computes candidate links to the signal classes defined in the ontology. These candidates may be revised by automotive experts before they are added to the ASKG. The goal of ASKG is to establish a Knowledge Base of automotive signals that supports a variety of processes and tools at Bosch in the future. These use cases range from semantic search of datasets in our automotive data lake to entity recognition and linking for NLP in requirements management tools. CANnotator is currently used and evaluated in two pilot projects in different business divisions: Bosch Powertrain and Chassis Systems Control Solutions, prior to a widespread rollout at Bosch. In this paper, we evaluate CANnotator in the context of the Bosch automotive data lake [14], where we manage in the order of 105 automotive sensor signals from many different projects and test scenarios at Bosch. With CANnotator, experts are able to expand their domain ontology in a pay-as-you-go manner as the need for new concepts arises – without the need of consulting one of the scarce ontology experts. The tool automatically learns from the interactions with the experts and captures their domain knowledge. This continuously improves the tool in being able to process more signals automatically and in assisting experts by providing better recommendations. Our results show that CANnotator effectively assists engineers to expand both the ontology model and the instance data (i.e., signals) in the ASKG.
Pay-as-you-go Population of an Automotive Signal Knowledge Graph
719
Listing 1.1. Example: Message description for steering sensor from a DBC file. 1 2 3 4 5 6 7 8
BO_ 380 POWERTRAIN_DATA: 8 PCM SG_ PEDAL_GAS : 7|8@0+ (1,0) [0|255] "" EON SG_ ENGINE_RPM : 23|16@0+ (1,0) [0|15000] "rpm" EON SG_ GAS_PRESSED : 39|1@0+ (1,0) [0|1] "" EON SG_ ACC_STATUS : 38|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_SWITCH : 32|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_PRESSED : 53|1@0+ (1,0) [0|1] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON
The remainder of the paper is organized as follows. Section 2 introduces the preliminaries. Our approach is presented in Sect. 3 and evaluated in Sect. 42 . Section 5 discusses related work and we conclude in Sect. 6 with an outlook to future work.
2
Preliminaries
First, we describe the automotive signal data used as input to construct the ASKG. Then, we present the Vehicle Signal Specification Ontology as the schema of the ASKG. Automotive Signal Data. The Controller Area Network (CAN) is a vehicle bus system used in the majority of today’s cars to enable communication between electronic control units (ECUs) that support a variety of features in the car. For the development of complex CAN networks, car manufacturers and their suppliers commonly use the DBC File Format to describe CAN messages. The central object types in a DBC file are nodes (i.e., the ECUs), message, and signals. Listing 1.1 shows an example CAN bus message definition. A message definition starts with the keyword BO and is followed by the message identifier (380), message name (POWERTRAIN DATA), message size (8 bytes) and the node emitting this message (PCM). In the following lines (Line 2 to Line 8 ), the signals that constitute the message are defined. The signal definition starts with the keyword SG and is followed by details about the signal. For example, on Line 3 the signal name (ENGINE RPM) is defined which is followed by additional information, including the starting bit (23) in the message, signal size 16, byte order (0), value type (+), value range ([0|15000]), the unit (rpm) and the intended receiver (EON). The example reveals some of the syntactic and semantic challenges when trying to automatically match the natural language names to a corresponding semantic model. Engineers use different syntax to delimit words, such as underscores (ENGINE RPM), hyphens (ENGINE-RPM) or camel-casing (EngineRpm, or EngineRPM). Moreover, they apply different abbreviation methods, such as disemvoweling (PWR = power), acronyms (PCM = powertrain control module) or shortenings (Req = request). 2
Developed semantic artifacts, the detailed setup of the evaluation experiment and its results are available at https://github.com/YuliaS/cannotator.
720
Y. Svetashova et al.
Fig. 1. Overview of the CANnotator architecture
Vehicle Signal Specification Ontology. We use the Vehicle Signal Specification Ontology (VSSo) [8] for modeling the ASKG. This ontology is an extension to the Vehicle Signal Specification (VSS),3 modelled with constructs from the Web Ontology Language (OWL) [11] to express relationships and restrictions. VSSo relies on the SOSA ontology4 to represent sensors and observations. In this work, we distinguish three main concepts in the VSSo ontology: Branch. In this context, a branch corresponds to a car part. Branches may be structured in hierarchies using rdfs:subClassOf. Examples of top branches in VSSo are Body, ADAS, and Cabin. Branches are associated with signals. These associations are modelled with owl:Restriction on the branch property vsso:hasSignal. Signal. VSSo classifies signals into observable and actuable signals. According to the VSSo specification, the choice of making a signal observable or actuable is based on the existence of the sensor and actuator entries of each VSS signal. In VSSo, signals may be annotated with an abstract definition of the unit using the QUDT5 ontology, e.g., Length Unit. In addition, VSSo includes human-readable descriptions with the predicates rdfs:label and rdfs:comment. Also, the URIs defined in the VSSo ontology are created with camel case strings for the term at the end. Sensor or Actuator. A sensor is a car component that measures a physical variable. An actuator consumes the outcome of sensors to perform actions in the car. In VSSo, the classes sensor and actuator are not necessarily disjoint. Sensors and actuators are associated with signals through restrictions on the signal property sosa:isObservedBy.
3
Automotive Signal Knowledge Graph Population
Given the VSSo as initial schema and a set of DBC files, the problem addressed in this work is to extract the semantics from the signal descriptions provided 3 4 5
https://github.com/GENIVI/vehicle signal specification. http://www.w3.org/ns/sosa/. https://qudt.org.
Pay-as-you-go Population of an Automotive Signal Knowledge Graph
721
in the DBC files to populate a knowledge graph (i.e., ASKG) of classes and instances of automotive signals. The ASKG population comprises (i) extending the schema by creating new classes and linking them to existing concepts in the KG, and (ii) creating instances for signals from the DBC file descriptions according to the schema. We propose a novel semi-automatic tool called CANnotator (cf. Fig. 1), which combines automatic techniques with domain expert input to accurately populate an ASKG from the data encoded in DBC files. Our tool processes automotive signal descriptions with the following three main components: 1. Automatic Entity Construction: Extracts information from the signal description texts and predicts the signal class of the entity to be added to the ASKG. 2. Interactive Entity Construction: Consults experts to create a new signal entity, in the case that a reliable signal class candidate could not be determined automatically. 3. Interactive Schema Construction: Extends the ASKG schema with the help of a domain expert, assisted by an adequate Graphical User Interface (GUI). The central goal of our approach is to minimize the interactions with the domain experts during the ASKG population process. For this, CANnotator operates in a pay-as-you-go fashion such that information provided by the experts is learned by the tool and considered when processing signal descriptions subsequently. 3.1
Automatic Entity Construction
This component aims at automatically populating the ASKG by constructing new signal entities from signal description using the existing schema. For a given signal, the metadata for constructing a new entity is obtained from the descriptions in the DBC File. The component first implements lightweight NLP techniques to the signal name and its unit text to obtain a set of potential expansions, which then map to concepts in the ASKG. Finally, the component uses a complete signal description to identify the corresponding signal class in the KG. During this process, existing information from the KG as well as external data sources are used to aid automatic signal class identification. Expanding Signal Names. The signal names in the DBC files are often composed of several abbreviations or acronyms, which are concatenated using different separators such as camel casing, underscores, or hyphens. Therefore, our tool first splits a given signal name string s into a set of tokens Ts . For example, s = “ENGINE RPM” is split into Ts = {ENGINE, RPM}. For each of the resulting tokens, this component expands the original signal names into full words which can then be matched to identifiers in the ASKG. The expansion relies on knowledge acquired from external sources and that is encoded in the ASKG. Formally, an expanded token is defined as follows.
722
Y. Svetashova et al.
Definition 1 (Expanded Token). Given a token t, an expanded token e for token t is a 3-tuple e := (t, exp, u) with a token string t, an expansion of the token string exp, and the IRI of the source for the expansion u. To obtain expanded tokens, CANnotator leverages the KG which contains mappings from abbreviations to expansions that have been created or confirmed by domain experts before. Each mapping in the ASKG is annotated with the IRI of the source. We scraped data on common automotive abbreviations from the Web as the initial abbreviation expansions for the KG. For example, we processed abbreviations provided in Wikipedia6 and added the expansions to the ASKG. In our example, we obtain the mapping RPM to “revolutions per minute” from Wikipedia and, therefore, we have an expanded token e1 = (RPM, revolutions per minute, ). Since not all tokens are abbreviations but potentially regular words, e.g. ENGINE, we also leverage the WordNet KG7 to determine whether a token is a word, i.e., exp = t. When querying WordNet, we apply lowercasing, lemmatization, and stemming to the token, to increase the chances of finding a correct match. Since there might be several expansions in the ASKG for an abbreviation, the tool keeps all options for a given token t in a set of expanded tokens Et . For example, a second expansion for RPM might be provided by another source as e2 = (RPM, rotations per minute, ) and hence, Et = {e1 , e2 }. Note that, keeping several possible expansions may increase the chances of finding the corresponding signal class in the KG in the later processing steps. However, if the number of possible expansions is large, it can also become overwhelming and time consuming for domain experts if their input is required. To overcome this, the sources are annotated with trust scores. Formally, we define the trust score as a partial function τ : I → [0, 1] that maps an IRI to a trust score value. A higher trust score value indicates higher trustworthiness of the source associated with the IRI and reflects the likelihood of an expansion to be correct. The domain experts can provide feedback on the correctness of these expansions to improve the trustworthiness of the expansions. In this case, the source provenance information is updated to the IRI identifying the domain expert which will have a higher trust score than the Web sources. The experts can also add new expansions to the KG that will be considered when processing future signal names. Lastly, if no expansion could be found, the token itself is considered the expansion and no source is associated with this information, i.e., Et = {(t, t, null)}. For example, signal names frequently contain numeric identifiers, which do not need to be expanded. Once this process has been applied to all tokens of a signal name, we construct complete expansions for the entire signal name. Definition 2 (Expanded Signal Name). Given a signal name s, an expanded signal name S = {e | e ∈ Et , ∀t ∈ Ts } is a set of token expansions for all tokens of the signal name Ts . Further, we denote the set of all possible signal name expansions that can be obtained for a signal as S = {S1 , . . . , Sn }. 6 7
From the article:
https://en.wikipedia.org/wiki/Automotive acronyms and abbreviations. http://wordnet-rdf.princeton.edu/.
Pay-as-you-go Population of an Automotive Signal Knowledge Graph
723
Algorithm 1: Signal Class Linking 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Input: Expanded Signal Names S , Similarity Threshold θ M =∅ for S ∈ S do D = empty dictionary for (t, exp, u) ∈ S do C = candidatesFromKG(exp) for (U, L) ∈ C do δU = similarity(U, exp) δL = similarity(L, exp) δ = max{δU , δL } if δ > θ then D[U ] = D[U ] ∪ {(exp, δ)} for (key U , value V ) ∈ D do if |V | > 1 then δ¯ = |V1 | (exp,δ)∈V δ ¯ T(S))} M = M ∪ {(S, U, δ, return M
In other words, an expanded signal name S is a combination of expansions for each token in the signal name. The set of all possible such combinations for a given signal name is given by S . For our previous example the expansions are8 S ={ S1 = {(ENGINE, engine, ), (RPM, revolutions per minute, ))}, S2 = {(ENGINE, engine, ), (RPM, rotations per minute, ))}}
Furthermore, the trust score of an expanded signal name can be defined as the average trust score values of the sources that contributed to the token expansions. Definition 3 (Expanded Signal Name Trust Score). Given an expanded signal name S, the trust score T for S is given as T(S) := 1 (t,exp,u)∈S∧u=null τ (u). |S| Unit Linking. After processing the name of the signal, the tool aims at matching the unit of the signal description to the corresponding unit instance in the QUDT ontology. This allows for a better candidate selection later when trying to map the signal to an existing signal class in the KG, as the unit information can help to select the corresponding class. Moreover, in the case that no automatic mapping can be found, this additional information is passed to the experts. Since a variety of unit texts can be encountered and the units in the QUDT ontology typically only have one label (e.g., “Kilometer per Hour” for qudt:KiloM-PER-HR), the tool resorts to the Wikidata SPARQL endpoint9 to retrieve more candidate units. This is possible, since Wikidata links most of the unit instances to QUDT with the “QUDT Unit ID” property (wd:P2968) and provides several labels for a single unit (e.g., “km/h”,“kmh”, “kph”, “Kilometer per Hour”, etc.). 8
9
wn, wp, ex stand for the IRIs of WordNet, Wikipedia, and the example source, respectively. https://query.wikidata.org/.
724
Y. Svetashova et al.
Signal Class Linking. Given a set of expanded signal names and links to QUDT unit instances, the approach computes matches for the corresponding signal class in the ASKG schema. This process is detailed in Algorithm 1. The input is a set of signal name expansions S and a similarity threshold θ. The algorithm iterates over all expanded signal names in S (Lines 2–15); for each expanded token in a given expanded signal name, a set of candidates from the KG is computed (Line 5). This candidate selection uses a SPARQL query to retrieve the URI (U ) and the text label (L) of all signal classes where the expanded to token exp is either a sub-string of the URI or text label (rdfs:label or rdfs:comment) from the KG schema. For example, for the expanded signal name S2 = {(ENGINE, engine, ), (RPM, rotations per minute, )}, we would obtain several candidates for the token “engine” such as vsso:EngineLoad, vsso:EngineOilTemperatur, vsso:RotationSpeed, etc. For each candidate, we then determine a normalized string similarity (δ ∈ [0, 1]) based on the iterative Levenshtein distance between exp and the candidate URI10 δU (Line 7) and the text label δL (Line 8). If the maximum of the similarity values (δ) exceeds the predefined similarity threshold (θ), we consider the candidate an option for the token and add it to a dictionary D that maps the candidate URI to the expanded token and the similarity value (Line 11). After all tokens of an expanded signal name have been processed, we determine whether the same candidate URI has been selected for more than one token (Lines 13–15). The idea is as follows: if several tokens of an expanded signal name map to the same signal class and the computed similarity is high, then it is very likely that this is a correct match. The output of the algorithm is a set M of signal class from the ASKG schema that matches one signal name expansion S ∈ S . Each match consists of the expanded signal name S, the URI of the candidate instance U , the confidence of the match δ¯ and the trust score of the signal name expansion T(S). In our example, both tokens “engine” and “rotations per minute” map to vsso:RotationSpeed due to the match with the rdfs:comment “Engine speed measured as rotations per minute”. Thus, the signal class vsso:RotationSpeed is considered a match and is added to M . After all possible classes have been determined for a signal, they are ordered ¯ We use the trust score as a tie-breaker if two by decreasing similarity δ. matches yield the same similarity. If the similarity exceeds a predefined threshold, we automatically add an instance to the signal class in the KG. Otherwise, the information is passed to the Interactive Entity Construction component. In our example, ENGINE RPM is automatically added to the ASKG using the vsso:RotationSpeed class as shown in Listing 1.2.
10
For hash-URIs/slash-URIs we consider the text after the hash/last slash.
Pay-as-you-go Population of an Automotive Signal Knowledge Graph
725
Listing 1.2. Instance for vsso:RotationSpeed and resulting axioms. vsso-ext are annotations by the CANnotator to represent the signal in the ASKG 1 2 3 4 5 6 7 8 9 10
@prefix askg: . @prefix vsso-ext: . askg:s002 a vsso:RotationSpeed ; rdfs:label "Engine Revolutions Per Minute"; qudt:unit unit:RevolutionsPerMinute; vsso-ext:dbcFileName "bmw_i8kk09.dbc"; vsso-ext:originalSignalName "ENGINE_RPM"; vsso-ext:expandedSignalName "Engine Revolutions Per Minute"@en; vsso-ext:messageName "380Powertrain Data"@en.
Fig. 2. CANnotator GUIs: 1) Interactive Entity Construction. 2) Interactive Schema Construction generated from Template User Interface (TUI) ontology descriptions
3.2
Interactive Entity Construction
The domain experts are only involved to process signals for which no corresponding signal class could be identified automatically. In this case, the experts provide structured input that is added to ASKG through a GUI (cf. Fig. 2 (1)). At the top, the original signal name and corresponding message name are displayed as well as the suggested expanded signal name. Below, if there are signal class candidates that match the given expanded signal name (i.e., |M | > 0), they are displayed with the corresponding VSSo signal class name and mapping’s similarity score. If a correct signal class has not been automatically added due to a similarity score below the threshold θ, the domain expert can directly create the new signal instance by pressing the “Add Signal Instance” button. Further below, there are three expandable sections that can be used by the domain experts to enrich the information about a signal by (i) adding links between tokens of the signal name and other types of classes in the schema (such as branches), (ii) providing expansions for abbreviations, and (iii) providing the correct tokenization of a signal name. With the “Submit” button, the experts can add this additional information to the KG which triggers a re-processing of the current signal description. As a result, new signal class candidates might be generated, so that the signal can be either added automatically to the KG or displayed to the domain expert for further manual processing.
726
Y. Svetashova et al. Listing 1.4. Class vsso:RotationSpeed
Listing 1.3. Pattern Observable Signal 1 2 3 4 5 6 7 8 9 10
?classIRI rdf:type owl:Class; rdfs:label ?label ; rdfs:comment ?comment ; rdfs:subClassOf vsso:ObservableSignal, [rdf:type owl:Restriction; owl:onProperty qudt:unit; owl:allValuesFrom ?unit ], [rdf:type owl:Restriction; owl:onProperty sosa:isObservedBy; owl:allValuesFrom ?sensor ].
1 2 3 4 5 6 7 8 9 10
vsso:RotationSpeed rdf:type owl:Class; rdfs:label "Speed"@en; rdfs:comment "Rotations per minute."@en; rdfs:subClassOf vsso:ObservableSignal, [rdf:type owl:Restriction; owl:onProperty qudt:unit; owl:allValuesFrom qudt:AngularVelocityUnit], [rdf:type owl:Restriction; owl:onProperty sosa:isObservedBy; owl:allValuesFrom vsso:RotationalSpeedSensor].
Listing 1.5. OTTR Template for Observable Signal 1 2 3 4 5 6 7 8 9
vsso-template:ObservableSignal [owl:Class ?classIRI , rdf:Literal ?label , rdf:Literal ?comment , owl:Class ?unit , owl:Class ?sensor ] :: { ottr:Triple(?classIRI, rdfs:label, ?label), ottr:Triple(?classIRI, rdfs:comment, ?comment), o-owl:SubClassOf(?classIRI, vsso:ObservableSignal), o-owl:SubObjectAllValuesFrom(?classIRI,qudt:unit,?unit), o-owl:SubObjectAllValuesFrom(?classIRI, sosa:isObservedBy, ?sensor) }.
3.3
1 2 3 4 5 6 7
Listing 1.6. OTTR Instance vsso-template:ObservableSignal ( vsso:RotationSpeed, "Rotation Speed"@en, "Rotations per minute."@en, qudt:AngularVelocityUnit, vsso:RotationalSpeedSensor ).
8 9
Interactive Schema Construction
If no candidate classes are found in the schema, domain experts can create a new signal class. The Interactive Schema Construction component allows for extending the VSSo through a Graphical User Interface (GUI) with new classes, which are immediately accessible for annotating new instances. The GUIs are generated automatically with an ontology-driven process: Ontology Patterns → Reasonable Ontology Templates (OTTR) → Template User Interface (TUI) ontology → GUI with Input Validation. Ontology Patterns. This component is based on ontology design patterns, defined as “modelling solutions to solve a recurrent ontology design problem” [5]. We use an extended notion of patterns to indicate recurring patterns of axioms in an ontology [9]. The VSSo is both, pattern-inspired and densely interlinked by several recurrent axiom patterns. Firstly, it relies on patterns from the SOSA ontology for modeling sensors, actuators, and observations [8]. Secondly, VSSo was auto-generated from the Vehicle Signal Specification through instantiations of the repetitive axiom structures to define certain types of information (signals, branches, sensors). For example, all signals are defined as subclasses of vsso:ObservableSignal and value restrictions on properties sosa:isObservedBy and qudt:unit. Listing 1.3 shows the pattern for observable signals; leading question marks denote variable elements in the patterns. In our example, vsso:RotationSpeed can be instantiated by this pattern as shown in Listing 1.4. Repetitive structures in VSSo can be captured by seven patterns: Observable Signal, Actuable Signal, Observable and Actuable Signal, Branch, Sensor, Actuator,
Pay-as-you-go Population of an Automotive Signal Knowledge Graph
727
Fig. 3. Template to add new signal classes and instances (indicated in gray) to VSSo
and Unit. We derived these patterns by abstracting from how various classes with the same frequent super-classes are defined in VSSo. To guarantee uniformity and consistency of schema construction, new classes should also become the instantiations of patterns. CANnotator enables that by exposing patterns as templates. OTTR Templates. A template is an abstraction over the underlying pattern. Users of templates create instances from templates by providing values to the parameters. These values can be named classes, object and datatype properties, individuals, and plain literals. A template is instantiated by the replacement of its parameters by the provided values. For CANnotator, we used the OTTR [15] OWL vocabulary to record templates and their instances and the instance expansion tool Lutra12 . Listing 1.5 shows the OTTR template for the Observable Signal pattern and the instance of this template for our example class vsso:RotationSpeed. Each argument in the instance corresponds to a parameter in a template (e.g., ?classIRI ← vsso:RotationSpeed). The replacement of parameters in a template by instance arguments will generate the class definition given above in the Listing 1.4. In total, we constructed eight templates: seven – to create classes in the schema according to the mentioned patterns in VSSo and one template to instantiate DBC signal entities (see Fig. 3). For the latter template, the automated entity linking component provides the values for its parameters. For the interactive schema construction, we actively involve the domain experts. Addressing this, we developed a new module of CANnotator with a graphical user interface that assists the users in completing the templates in a user-friendly and intuitive way based on their domain expertise. Template User Interface Ontology and GUI Generation. Figure 2 (2) shows the graphical user interface of CANnotator with an example of the form for the Observable Signal template. Each form element corresponds to a parameter of an OTTR template. The schema-construction process is straightforward: the expert fills in the form, either providing values into text fields or selecting the values from the drop-down menus.
728
Y. Svetashova et al. Listing 1.7. Template UI description for Observable Signal template
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
@prefix ui: . @prefix tui: . @prefix vsso-tui: . vsso-tui:ObservableSignalIRI a tui:HiddenParameter ; tui:processingDirective [vsso-tui:ObservableSignalName, func:mintIRI] . vsso-tui:ObservableSignalName a tui:FreeParameter ; tui:validationFunction func:notEmpty ; tui:parameterGuiFormType ui:TextField ; tui:parameterGuiFormLabel "Provide a name for this observable signal" . vsso-tui:ObservableSignalDescription a tui:FreeParameter . vsso-tui:ObservableSignalUnit a tui:BoundParameter ; tui:validationFunction func:notNull ; tui:parameterGuiFormType tui:SingleDropDown ; tui:parameterGuiFormLabel "Select unit of measurement for this signal" ; tui:parameterFormFillerQuery "SELECT * WHERE {?s rdfs:subClassOf qudt:Unit .}". vsso-tui:ObservableSignalSensor a tui:BoundParameter ; tui:dependsOn vsso-tui:ObservableSignalUnit . vsso-tui:ObservableSignal a tui:Template; tui:parameters ( vsso-tui:ObservableSignalIRI, vsso-tui:ObservableSignalName, vsso-tui:ObservableSignalDescription, vsso-tui:ObservableSignalUnit, vsso-tui:ObservableSignalSensor ) ; tui:ottrTemplate vsso-template:ObservableSignal.
CANnotator implements an ontology-driven generation of this graphical user interface. To this extent, we propose the Template UI (TUI) ontology which maps the elements of the GUI to elements of the OTTR templates. We distinguish three main types of parameters depending on how users interact with them. For FreeParameters, users can freely provide values. For BoundParameters, a user selects values from a list. HiddenParameters are not shown to users and their values are derived from other parameter values. In Fig. 3, we denote bound parameters with circles and variables Xi , and free parameters with rectangles and variables Yj . Listing 1.7 shows a fragment of the Observable Signal UI template: Line 5 represents a hidden parameter for a signal URI, whose value is derived from the class label parameter defined in Line 7. Parameter in Line 12 will be used to select a unit of measurement for this signal from a list. The parameter descriptions are used to render the GUI form for a template. A field can be either a ui:TextField for Free parameters or a ui:Classifier. For the fields of type ui:Classifier, TUI defines the specializations tui:SingleDropDown and tui:MultipleDropDown, which provide a list of options generated dynamically by evaluating SPARQL queries over the ASKG (e.g., see Line 16 in Listing 1.7). To minimize the effort of domain experts, CANnotator automatically fills in some of the form fields by exploiting the dependencies between parameters specified by the property tui:dependsOn (see, e.g., Line 18 in Listing 1.7). Thus, if a unit of measurement was selected, the system re-runs a SPARQL query for sensors and pre-selects a corresponding sensor in a drop-down list based on the query evaluation result. Lastly, CANnotator can change the type of a parameter defined in the TUI descriptions of templates. It happens, for example, if the automated entity
Pay-as-you-go Population of an Automotive Signal Knowledge Graph
729
generation component obtains a similarity score that exceeds a threshold for the linked sensor or unit entities. Then the parameter’s type is set to Hidden and its form field is not rendered. Expert Input Validation and Triple Generation. CANnotator validates the expert input based on the validation functions specified in the TUI templates. These validations can check for empty mandatory fields (e.g., Line 8, Listing 1.7), formatting (date, number, etc.), and potential inconsistencies generated from the data provided by the experts. If the validation fails, CANnotator communicates the reason to the user and asks for correct input. After validation, the tool checks for duplicate concepts by evaluating SPARQL queries against the ASKG. If there exist classes with identical names, labels, or values of restrictions on properties in their class definitions, the user is asked to either (1) confirm that the existing class can fully suit the purpose of signal description (and discard the new class), or (2) change the name or definition of the new class. For tui:HiddenParameters, CANnotator generates their values by applying processing functions to their source parameters. In our example, it passes the value of the parameter vsso-tui:ObservableSignalName to a function func:mintIRI (see Line 6 in Listing 1.7), which outputs the IRI. Finally, CANnotator constructs an OTTR instance and runs Lutra to generate triples that are added to the ASKG. In this step, the tool will also extend the ASKG by adding the corresponding signal entity associated with the newly created signal class. The updated ASKG is immediately available to other users or other components. Learning from Expert Input. CANnotator is designed to learn from the input provided by experts with the interactive components. The VSSo extension and the addition of signal instances to the ASKG, as well as recorded interactions of domain experts with the tool, lead to a continuous improvement of the Automatic Entity Construction component. After each feedback iteration, we say that CANnotator has been trained, as more linguistic cues for finding matching signal instances and class candidates become available. In consequence, the manual steps that require a domain expert’s attention are naturally reduced over time. In the following section, we will evaluate the usage of CANnotator and focus specifically on the learning aspect.
4
Evaluation
We evaluate CANnotator in a controlled setting to empirically study its performance. In a user study, we investigated the usability with 12 experts at Bosch: 5 software engineers with a background in Semantic Technologies and 7 domain experts with a background in automotive engineering. We focused on the following core questions: Q1 How well does the template-based schema construction support experts? Q2 What percentage of signal names can be handled in a fully automated manner?
730
Y. Svetashova et al.
Q3 How does the performance of the system improve over time by learning? Input Data. We randomly selected 200 English signal descriptions out of the 31017 signals from the 82 DBC of different car manufacturers provided by opendbc 11 . We excluded object detection data and metadata signals, such as checksums or counters. Two domain experts annotated these 200 signals using our system. Then we selected the 150 signals with the highest inter-rater agreement score as the ground truth. The agreement meant the selection of the same VSSo term for a signal name by both experts or the usage of the same options (superclass, sensor, unit) in the template when the term was missing in VSSo. Initial vs. Trained System. We prepared two CANnotator instances to evaluate the improvement of a Trained System over an Initial System. The Initial System, contained only default knowledge sources in the automated entity construction component and the initial knowledge graph with the VSSo and the QUDT Unit ontology. The Trained System contained the input provided by the domain expert from annotating 100 signals of the ground truth dataset. During the annotation process, the KG was extended with the expansions, token relations, alignments, signal instances, and 132 new classes provided by the experts. The KG statistics for both CANnotator systems are shown below. System Triples Classes Instances Initial
20569
304
0
Trained 32155
436
100
For the experiments with the users, we created 24 DBC files with 5 signals in each file. The signals for the 12 files to be annotated with the Initial System were randomly sampled from the ground truth set of 150 signals. The signals to be annotated with the Trained System were sampled at random from the subset of 50 signals not used for training. Expert Annotations. Each participant of the experiment was provided with a short introduction to the concept of ontologies, the structure of VSSo, the specifics of the data, and the tool itself. Thereafter, the participants used CANnotator to annotate two DBC files with 5 signal names each. For the first file, they used the Initial System, and for the second the Trained System. After assessing the candidates provided by the tool, the participants annotate the signals by (1) picking a candidate to align the signal, or (2) creating a class to extend the ontology using the interactive schema construction component. Note that the input was different for all users because we randomly sampled signals from the subset of the ground truth, which was not used for training the system. Evaluation Metrics. We measured correctness, calculated as the percentage of successfully completed tasks, as the metric for the effectiveness of our approach. 11
https://github.com/commaai/opendbc, retrieved on Jul 27, 2020.
Pay-as-you-go Population of an Automotive Signal Knowledge Graph
731
Absolute correctness for our tasks is not attainable due to the complexity of the automotive domain and the diversity of CAN-bus data. As the metric for efficiency, we used the time users spent on a task. We report the results for the annotation and the extension separately because the time needed to perform these tasks is different. In summary, we report on the following metrics: (1) TimeAlign, mean time a user needed to annotate a signal where the decision was to accept the suggested alignment; (2) TimeExt, mean time a user needed to annotate a signal where the decision was to create a new signal class; (3) TimeAnnot, mean time a user needed to annotate a signal; (4) CorrAlign, percentage of correctly aligned signals (w.r.t. the ground truth); (5) CorrExt, percentage of correctly chosen options in the schema construction form; (6) CorrAnnot, percentage of correctly annotated signals (aligned or constructed). We compute these metrics separately for the annotations obtained by the Initial System and the Trained System. 4.1
Performance Results
As a result of our evaluation, we obtained 10 annotations from each participant. An annotation could either be an alignment when the user pointed to a VSSo class corresponding to a DBC signal name or a schema extension when the user created a new schema element. The submitted input was compared with the ground truth. Figure 4 and Table 1 show the performance results for all metrics. As expected, the time for alignment annotations (TimeAlign) is considerably lower than for extensions (TimeExt). For the Initial System state, the mean time (in seconds) needed for the alignments was 51 s; extensions took 183.5 s. These averaged into 107 s per annotation. The mean correctness was 97% for the aligned signals. Schema extensions resulted in 92% correct choices; the correctness of decisions on the level of the signal set was also 92%. In the Trained System, the majority of the annotations corresponded to alignments; the mean time per alignment was 43 s (TimeAlign) as well as per annotation in general (TimeAnnot). Only in one case, the user decided to extend the schema, which took 75 s (left out from Fig. 4); this is considerably faster than the average reported for the Initial System state. Correctness was 100% for aligned signals in the Trained System. Note that we could not compute this metric for the extensions as the ground truth since for the single extensions provided by the domain expert was modeled as an alignment in the ground truth. Yet, this decreased the overall correctness for the annotations to 97%. The time spent on schema extensions and their correctness provide insights into Q1: in the case that a signal class was not yet present in our ASKG, the experts provided correct template-based schema extensions in a time-efficient manner. Moreover, our experiment showed that CANnotator effectively learns with expert input: on average, the Initial System found alignment candidates for 68% of the signals (for the rest, the users created schema extensions) and the Trained System for 100% of the signals. With respect to Q2, 28% of the candidates
732
Y. Svetashova et al. Initial: TimeAlign
Initial: TimeExt
Initial: TimeAnnot
Trained: TimeAlign
Trained: TimeAnnot
Table 1. Summary of results
250
Time [s]
200
System state 150
Metric
Initial Trained
100
50
0
User 2
User 5
User 6
User 10
User 12
User 1
Semantics experts
User 3
User 4
User 7
User 8
User 9
User 11
Domain experts
Fig. 4. Time spent by each user in the annotations
TimeAlign
[s]
50.92
TimeExt
[s]
183.50 75.00
42.75
TimeAnnot [s]
107.25 43.33
CorrAlign
[%] 97.25
CorrExt
[%] 91.67
100.00 NA
CorrAnnot
[%] 91.67
97.25
generated by the Initial System had similarity scores above 90%, which could potentially be handled fully automatically. In comparison, candidates provided by the Trained System had higher average similarity scores with 69% above 90% similarity. Yet, human involvement was needed as the tool generated multiple candidates with a high similarity score; in this case, expert input ensures that correct signal instances are added to the ASKG. Regarding Q3, our experiments showed that CANnotator provided more automated alignments in the trained state and, therefore, fewer schema extensions were needed. Overall, the users were two times faster and provided more accurate results using the Trained System instead of the Initial System.
5
Related Work
Data and Metadata Management Solutions. Various solutions have been proposed for the large-scale data management of the enterprise data, which offer such functionalities as metadata management and mapping-based data integration (Karma [6], Sansa [10], Ontop [1], or Silk [16]). To the best of our knowledge, none of the existing systems implement schema extension by non-experts combined with the automated mapping candidate generation. These aspects were addressed by several standalone tools and frameworks, which CANnotator builds on. Abbreviation Expansion. The automatic expansion of abbreviations and acronyms has been studied by a variety of works [2,13,19]. Such approaches typically rely on either large corpora to discover abbreviations or leverage the abbreviation’s context to determine its expansion. Since the textual data of signal descriptions in DBC files is limited in size and barely provides context, we rely on predefined acronyms and abbreviations which can be extended by the domain experts such that our system improves over time. Template-Based Ontology Extension Tools and GUIs. Our system adopts ontology templates to involve domain experts in the schema and entity construction process. Frameworks and software tools relevant for our approach were developed in the biomedical domain [3,7,12,18]. We could reuse none of the tools directly due to their high domain specificity and limited interaction capabilities.
Pay-as-you-go Population of an Automotive Signal Knowledge Graph
733
Therefore, we rely on a general template framework called Reasonable Ontology Templates (OTTR) [15] and the tool Lutra12 for axiom generation. We build template-based GUIs, which is similar to recent works on Web form generation for the interaction with knowledge graphs such as [17] or Shex Form13 . In contrast to these works that focus on instance data, CANnotator allows for consistently extending the schema of the ASKG. Automotive Ontologies. A variety of ontologies have been developed for the automotive domain. Feld and M¨ uller [4] propose a high-level ontology to describe users, vehicles, and the current driving situation to support Human-Machine Interfaces. Moreover, the W3C Automotive Ontology Community Group14 proposes vocabularies to improve the interoperability of data in the automotive domain on the Web. However, as these ontologies do not allow for describing ECUs and automotive signals, we use the Vehicle Signal and Attribute Ontology (VSSo) [8] as the schema of the ASKG. The VSSo, which is derived from the Vehicle Signal Specification (VSS)3 , provides a formal model of car signals to improve the interoperability for car development applications.
6
Conclusions
We presented a novel tool that assists automotive experts at Bosch in extracting and managing the semantics of CAN signals in an Automotive Signal Knowledge Graph (ASKG). For this, CANnotator implements an entity construction component that automatically extracts signals from DBC files and computes candidate links to the ontology. Experts can then revise these candidates and if necessary extend the schema of the ASKG on-the-fly to accommodate new signal types in a pay-as-you-go manner. As we have demonstrated through our experiment, CANnotator is capable of learning from the interactions with the domain experts and using this knowledge to improve its assistance capabilities. The results showed that the tool, after some usage by the domain experts, is able to process more signals fully automatically, and also provides higher quality recommendations to the experts. Both lead to a significant reduction in the time that is required by the human experts. A key lesson learned while designing the automatic entity construction component was the observation that, at first, few restrictions (low threshold) should be applied to the candidate selection. For example, we started by using SPARQL queries with basic string matching filters to obtain candidates from the VSSo, because we found that too restrictive queries (i.e., queries with more triple patterns and constants) would lead to no matches. As the KG grows, the candidates increased, and therefore, the queries can be more restrictive by taking for instance the unit or the branch of a signal into account. 12 13 14
https://gitlab.com/ottr/lutra/lutra. https://github.com/ericprud/shex-form. https://www.w3.org/community/gao/.
734
Y. Svetashova et al.
Another lesson learned is that existing template frameworks based on simple tabular interfaces to create template instances [7,15] are not suitable for interactive schema extension by domain experts. Firstly, they are not capable of providing assistance to the users and involve the experts interactively in the process (e.g. to validate a system recommendation). Secondly, they do not allow to pre-fill the templates with results from the automatic entity construction component or prior input from experts. Finally, the usage of CANnotator revealed current shortcomings to be addressed in future work: (1) some experts tend to extend the schema instead of spending more time assessing the candidates, and (2) experts sometimes chose inadequate signal classes instead of extending the schema. The key to address these issues is to improve both the ranking of the automatically generated suggestions as well as the usability of the GUIs allowing users to explore the current schema of ASKG during extension.
References 1. Calvanese, D., et al.: Ontop: answering SPARQL queries over relational databases. Semant. Web 8(3), 471–487 (2017) 2. Chopard, D., Spasi´c, I.: A Deep Learning Approach to Self-expansion of Abbreviations Based on Morphology and Context Distance. In: Mart´ın-Vide, C., Purver, M., Pollak, S. (eds.) SLSP 2019. LNCS (LNAI), vol. 11816, pp. 71–82. Springer, Cham (2019). https://doi.org/10.1007/978-3-030-31372-2 6 3. Dietze, H., et al.: TermGenie–a web-application for pattern-based ontology class generation. J. Biomed. Semant. 5(1), 1–13 (2014) 4. Feld, M., M¨ uller, C.A.: The automotive ontology: managing knowledge inside the vehicle and sharing it between cars. In: AutomotiveUI, pp. 79–86. ACM (2011) 5. Gangemi, A., Presutti, V.: Ontology design patterns. In: Handbook on Ontologies (2009) 6. Gupta, S., et al.: Karma: a system for mapping structured sources into the semantic Web. In: ESWC (2012) 7. Jupp, S., et al.: Webulous and the Webulous Google Add-On-a web service and application for ontology building from templates. J. Biomed. Semant. 7(1), 1–8 (2016) 8. Klotz, B., Troncy, R., Wilms, D., Bonnet, C.: VSSo: the vehicle signal and attribute ontology. In: SSN@ ISWC, pp. 56–63 (2018) 9. L awrynowicz, A., Potoniec, J., Robaczyk, M., Tudorache, T.: Discovery of emerging design patterns in ontologies using tree mining. Semant. web 9(4), 517–544 (2018) 10. Mami, M.N., et al.: Semantic data integration for the SMT manufacturing process using SANSA stack. In: ESWC (2020) 11. Motik, B., et al.: Owl 2 web ontology language: structural specification and functional-style syntax. W3C Recommendation 27(65), 159 (2009) 12. O’Connor, M.J., Halaschek-Wiener, C., Musen, M.A.: M2: a language for mapping spreadsheets to owl. In: OWLED, vol. 614 (2010) 13. Pakhomov, S., Pedersen, T., Chute, C.G.: Abbreviation and acronym disambiguation in clinical discourse. In: AMIA (2005) 14. Schmid, S., Henson, C., Tran, T.: Using knowledge graphs to search an enterprise data lake. In: Hitzler, P., et al. (eds.) ESWC 2019. LNCS, vol. 11762, pp. 262–266. Springer, Cham (2019). https://doi.org/10.1007/978-3-030-32327-1 46
Pay-as-you-go Population of an Automotive Signal Knowledge Graph
735
15. Skjæveland, M.G., Lupp, D.P., Karlsen, L.H., Forssell, H.: Practical ontology pattern instantiation, discovery, and maintenance with reasonable ontology templates. In: ISWC 2018 16. Volz, J., et al.: Silk-a link discovery framework for the web of data. In: LDOW, vol. 538 (2009) 17. Wright, J., Rodr´ıguez M´endez, S.J., Haller, A., Taylor, K., Omran, P.G.: Sch´ımatos: a SHACL-based web-form generator for knowledge graph editing. In: Pan, J.Z., et al. (eds.) ISWC 2020. LNCS, vol. 12507, pp. 65–80. Springer, Cham (2020). https://doi.org/10.1007/978-3-030-62466-8 5 18. Xiang, Z., et al.: Ontorat: automatic generation of new ontology terms, annotations, and axioms based on ontology design patterns. J. Biomed. Semant. 6, (2015). https://doi.org/10.1186/2041-1480-6-4 19. Zhang, W., Sim, Y.-C., Su, J., Tan, C.-L.: Entity linking with effective acronym expansion, instance selection and topic modeling. In: IJCAI, Citeseer (2011)
Correction to: A Semantic Framework to Support AI System Accountability and Audit Iman Naja, Milan Markovic, Peter Edwards, and Caitlin Cottrill
Correction to: Chapter “A Semantic Framework to Support AI System Accountability and Audit” in: R. Verborgh et al. (Eds.): The Semantic Web, LNCS 12731, https://doi.org/10.1007/978-3-030-77385-4_10
In the original version of this chapter, figure 3 was incorrect. This has been updated in the chapter as seen below.
Fig. 3. RAInS classes as subclasses of SAO classes (in blue-filled rectangles). Third party classes reused from ML Schema and Dublin Core vocabulary have green borders. (Color figure online)
The updated version of this chapter can be found at https://doi.org/10.1007/978-3-030-77385-4_10 © Springer Nature Switzerland AG 2021 R. Verborgh et al. (Eds.): ESWC 2021, LNCS 12731, p. C1, 2021. https://doi.org/10.1007/978-3-030-77385-4_44
Author Index
Acosta, Maribel 717 Aimonier-Davat, Julien 57 Ajileye, Temitope 3 Albers, Torsten 647 Antonyrajah, Denvar 392 Ayara, Adel 73
Ekaputra, Fajar J. 631 Ekelhart, Andreas 631 Eschauzier, Ruben 340 Ettorre, Antonia 497 Fanizzi, Nicola 441 Fell, Michael 515 Ferrod, Roger 461 Frasincar, Flavius 340 Freitas, André 304 Frerk, Philip 93
Balke, Wolf-Tilo 143 Banerjee, Barshana 598 Beek, Wouter 477 Bloem, Peter 249, 614 Bogatu, Alex 304 Bonte, Pieter 565 Bouhamoum, Redouane 195 Braslavski, Pavel 532 Bruyat, Julian 582 Buffa, Michel 515 Buijs, Daniël 340
Gandon, Fabien 515 Giacometti, Arnaud 179 Giboin, Alain 515 Giese, Martin 126 Gleim, Lars 212, 265 Glimm, Birte 23, 73, 109
Cabrio, Elena 515 Champin, Pierre-Antoine 582 Charalambidis, Angelos 664 Chaudhuri, Debanjan 323 Chen, Jiaoyan 392 Chowdhury, Sulogna 230 Claassen, Christopher 340 Conrads, Felix 93 Cottrill, Caitlin 160
Haczek, Artur 548 Hadian, Ali 392 Halilaj, Lavdim 425, 699 Heling, Lars 717 Helton, Aaron 548 Hennequin, Romain 515 Hildebrandt, Marcel 375 Hitzler, Pascal 230 Horrocks, Ian 3, 392
d’Amato, Claudia 441 de Boer, Victor 506, 614 de Groot, Thomas 40 de Haan, Rosaline 477 Decker, Stefan 212, 265 Della Valle, Emanuele 565 Demir, Caglar 409 Dengel, Andreas 647 Di Caro, Luigi 461 Dindorkar, Ishan 699 Djebri, Ahmed El Amine 497
Ilievski, Filip
Eberhart, Aaron 230 Edwards, Peter 160 Efimov, Pavel 532
680
Jain, Nitisha 143 Jilek, Christian 647 Jiménez-Ruiz, Ernesto 392 Joblin, Mitchell 375 Johnsen, Einar Broch 126 Joshi, Amit 548 Kacupaj, Endri 356, 598 Kalo, Jan-Christoph 143 Kamburjan, Eduard 126 Kedad, Zoubida 195 Kiesling, Elmar 631 Klarman, Szymon 548
738
Author Index
Klungre, Vidar Norstein 126 Konstantopoulos, Stasinos 664 Korablinov, Vladislav 532 Kostopoulos, Charalampos 664 Krestel, Ralf 143
Ringsquandl, Martin 375 Röder, Michael 93 Rony, Md Rashad Al Hasan Rothermel, Susanne 699 Rybin, Ivan 532
Laforest, Frédérique 582 Lee, Jaehun 392 Lehmann, Jens 323, 356, 598 Liebig, Thorsten 109 Liu, Yushan 375 Lopes, Stéphane 195 Lovell, Sean 548 Lüttin, Jürgen 425, 699
Sarker, Md. Kamruzzaman Schifanella, Claudio 461 Schlatte, Rudolf 126 Schlobach, Stefan 40 Schmid, Stefan 717 Schouten, Kim 340 Schröder, Markus 647 Schulze, Michael 647 Shimizu, Cogan 230 Singh, Kuldeep 356, 598 Skaf-Molli, Hala 57 Soulet, Arnaud 179 Steigmiller, Andreas 23 Stellato, Armando 548 Suchanek, Fabian 287 Svetashova, Yulia 717 Szekely, Pedro 680
Mangel, Simon 265 Markhoff, Béatrice 179 Markovic, Milan 160 Maus, Heiko 647 Médini, Lionel 582 Michel, Franck 515 Molli, Pascal 57 Morales, Luis Gonzalez 548 Mortara, Johann 497 Motik, Boris 3 Mouchakis, Giannis 664 Naja, Iman 160 Ngomo, Axel-Cyrille Ngonga Ongenae, Femke
93, 409
565
Paton, Norman W. 304 Pauwels, Johan 515 Pellerin, Guillaume 515 Pellissier Tanon, Thomas 287 Pennekamp, Jan 265 Plepi, Joan 356 Prokopaki-Kostopoulou, Nefeli 664 Qiu, Haonan 73 Quatraro, Nicola Flavio Raad, Joe 40, 249 Raissouni, Rime 375 Ramirez, Mario 304 Rettinger, Achim 425
441
ten Haaf, Fenna 340 Thakkar, Harsh 356 Tiddi, Ilaria 477 Tikat, Maroua 515 Tirpitz, Liam 212 Tjan, Joanne 340 Tommasini, Riccardo 565 Tresp, Volker 375 Troumpoukis, Antonis 664 van Berkel, Lucas 614 van Erp, Marieke 506 van Harmelen, Frank 249 Wang, Shuai 249 Wehrle, Klaus 265 Wenzel, Maximilian 109 Werner, Simon 425 Wilcke, Xander 614 Winckler, Marco 515 Zhang, Bin 680
323
230