/TemplateSystemForNaturalLanguageExplanations

TS4NLE is converts the explanation of an eXplainable AI (XAI) system into natural language utterances comprehensible by humans.

Primary LanguageJavaScript

TS4NLE: a Template System for Natural Language Explanations

TS4NLE is converts the explanation of an eXplainable AI (XAI) system into natural language utterances comprehensible by humans. Moreover, the XAI explanation can be enhanced with a domain and a user model that allow the natural language rendering to be tailored to the particular user. The code has been developed, and manteined, by Radu Loghin

TS4NLE has been tested with real users for providing persuasive explanations for the adherance to the Mediterranean diet, see the main paper here and the SEMEX4ALL tutorial at ISWC2020. An extended version of this Readme can be found in this detailed Colab tutorial

Installation

TS4NLE requires Node.js and Python languages and it is mainly based on RosaeNLG: a Natural Language Generation library for node.js, based on the Pug template engine. Once Node.js, Python, the Graphviz library and the nmp package manager have been installed, TS4NLE can be easily installed with:

git clone https://github.com/radu1690/Explanations.git
cd Explanations
npm install

Run

You can run TS4NLE with:

node explanations.js <template> <graph>

where template is the .pug file of the template and graph the .csv explanation graph file. Here some examples in the repository:

node explanations.js templates/english/argument.pug graphs/exp_graph_1_en.csv

will output "Red meat contains animal protein which can cause the increment of cancer risk!". You can specify the language, English or Italian (the default is English), like in the following example:

node explanations.js templates/italian/feedback.pug graphs/exp_graph_1_it.csv italian

with output "Hai consumato una grande quantitĂ  di carne rossa (3 su un massimo di 2)".

You can also generate a visual reppresentation of a graph with Graphviz with:

python csv2graphviz.py <graph.csv>

This example

python csv2graphviz.py graphs/exp_graph_1_en.csv

will generate a pdf file named exp_graph_1_en.pdf with the reppresentation of the explanation graph.

Citing TS4NLE

If you use TS4NLE in your research, please use the following BibTeX entry.

@article{DragoniDE20,
  author    = {Mauro Dragoni and
               Ivan Donadello and
               Claudio Eccher},
  title     = {Explainable {AI} meets persuasiveness: Translating reasoning results into behavioral change advice},
  journal   = {Artif. Intell. Medicine},
  volume    = {105},
  pages     = {101840},
  year      = {2020}
}