<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>SPARQL-QA enters the QALD challenge</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Manuel Borroto</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Francesco Ricca</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Bernardo Cuteri</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Vito Barbara</string-name>
          <email>barbara.vitog@unical.it</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>University of Calabria</institution>
          ,
          <addr-line>Rende (CS) 87036</addr-line>
          ,
          <country country="IT">Italy</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>The large public knowledge bases available today empower the community with an invaluable amount of information covering multiple domains. Unfortunately, accessing these data sources can be di cult without the proper knowledge of the KB structure and a query language, such as SPARQL. Question Answering over Knowledge Bases (KBQA) proposes to solve this problem by allowing users to pose questions in natural language to extract the desired information from the KBs, abstracting them from any technical complexity. In this context, the QALD challenges propose to evaluate and encourage the development of KBQA systems. In this paper, we describe sparql-qa, a system for question answering over KBs that have been submitted to the QALD-10 challenge. Our method uses Neural Machine Translation and Named Entity Recognition tasks that complement each other to create SPARQL queries. The experiments were performed using the Wikidata QALD-10 benchmark.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>Introduction</title>
    </sec>
    <sec id="sec-2">
      <title>System Architecture</title>
      <p>The potential of exploiting knowledge bases can be increased by allowing any
user to query the ontology by posing questions in natural language. In this paper,
this problem is seen as the following Natural Language Processing task: Given an
RDF knowledge base O and a question Qnat in natural language (to be answered
using O), translate Q into a SPARQL query SQnat such that the answer to Qnat
is obtained by running SQnat on O.</p>
      <p>The starting point is a training set containing a number of pairs hQnat; GQnat i,
where Qnat is a natural language question, and GQnat is a SPARQL query,
called the gold query. The gold query is a SPARQL query that models (i.e.,
allows to retrieve from O) the answers to Qnat. The training set has to be
used to learn how to answer questions posed in natural language using O, so
that, given a question in natural language Qnat, the QA system can generate
a query SQ0nat that is equivalent to the gold query GQnat for Qnat, i.e., such
that answers(SQ0nat ) = answers(GQnat ). Basically, we compare the answers,
and we are not interested in reproducing syntactically the gold query. We
approach this problem as a machine translation task, that is, we compute SQ0nat
as SQ0nat = T ranslate(Qnat), where T ranslate is the translation implemented
by our QA system, called sparql-qa. Most of the solutions proposed up to now
to convert from natural language to SPARQL make use of various techniques,
either using patterns or deep neural networks.</p>
      <p>To reduce the impact of the words out of the vocabulary (WOOV) and
improve the training time of the entire process, we introduce in sparql-qa some
remedies, including a new format to represent an NL to SPARQL dataset. In
particular, sparql-qa implements a neural-network-based architecture (see Figure
1) for question answering that accomplishes the objective by resorting to a novel
combination of tools. The architecture is composed of three main modules:
Input preparation, Translation, and Assembling, as shown in Figure 1 (lef t). Each
module is described in the following.</p>
      <sec id="sec-2-1">
        <title>Input preparation</title>
        <p>
          In this phase, the input sentence is processed in such a way that it is polished to
attenuate linguistic noise (e.g., shifts in spelling, grammar, punctuation, entity
identi cation) and also recast to be used as input for the subsequent phase.
Acronyms normalization. In this step, acronyms are converted to the
corresponding names. For example, the U K acronym becomes United Kingdom. Acronyms
regularly refer to KB resources inside the SPARQL query, and we need to replace
them with the full name, which is more similar to the KB resource name. In our
approach, this is particularly useful for handling acronyms of countries. To
perform this task, we rely on two libraries. The rst one is spaCy [
          <xref ref-type="bibr" rid="ref6">6</xref>
          ], a well-known
tool for NLP tasks. This library helps us to identify the acronyms thanks to
their powerful NER mechanism. Then we use the Country Converter (COCO)
library to obtain the original name.
        </p>
        <p>
          Fixing entities with NEL. We apply this preprocessing step to identify the
entities in Qnat and replace them with the label used in the KB because our approach
heavily relies on the correct spelling of the entities. For example, in the
question: Where was the president Kennedy born?, we look to transform the entity
"Kennedy" to "John F. Kennedy" which is the right label used to identify the
resource. In our implementation, we face this problem by using Named Entity
Linking (NEL), also referred to as Named Entity Disambiguation, which is the
task of linking entities mentioned in the text with their corresponding entities
in a target KB [
          <xref ref-type="bibr" rid="ref10">10</xref>
          ]. To this end, we employed DBpedia Spotlight [
          <xref ref-type="bibr" rid="ref4">4</xref>
          ].
Tokenization. The tokenization process is a fundamental step in almost all NLP
methods. It is the task of chopping a text up into pieces called tokens, which
are usually words. During this process, Qnat is cleaned by ltering out undesired
characters such as punctuation marks and converted into a sequence of words S.
The sequence is converted then into a sequence of word embeddings. To mitigate
the dependency on the input vocabulary (English) and reduce the impact of the
WOOV, we use the pre-trained word embeddings of F astT ext [
          <xref ref-type="bibr" rid="ref2">2</xref>
          ]. The decision
to use F astT ext is because it provides embeddings also for those words outside
the training vocabulary.
2.2
        </p>
      </sec>
      <sec id="sec-2-2">
        <title>Translation</title>
        <p>In this stage, the pre-processed Qnat is analyzed to recognize both its structure
and the named entities that serve to build SQ0nat in the subsequent assembling
phase. To do such recognition, we employ two neural networks performing two
key NLP tasks: (i) a Neural Machine Translation task (NMT), and (ii) a Named
Entity Recognition (NER) task.</p>
        <p>Query
select ?a where f wd:Q12418 wdt:P170 ?a g</p>
        <p>
          In the NMT task, Qnat is translated in a query template. A query template
is the skeleton of a SPARQL query where some of the KB resources are replaced
by placeholders. In general, in an NMT task, given a source X = (x1; x2; :::; xn)
sequence and a target Y = (y1; y2; :::; ym) sequence, the aim is to model the
conditional probability of target words given the source sequence [
          <xref ref-type="bibr" rid="ref1">1</xref>
          ]. In our
approach, an NMT neural network takes as input the preprocessed question and
translates it into a SPARQL query template.
        </p>
        <p>
          In the NER task, the entities present in Qnat are identi ed and classi ed using
a dedicated neural network. In a NER task (also known as Entity Extraction),
named entities present in a text are associated with prede ned categories, such
as individuals, companies, places, etc. This additional semantic knowledge helps
to understand the role of words in a given text [
          <xref ref-type="bibr" rid="ref5">5</xref>
          ]. As in most of the literature,
in our implementation, we also adopt the BIO notation [
          <xref ref-type="bibr" rid="ref9">9</xref>
          ] to tag a text, which
di erentiates the beginning \B" and the interior \I" of the entities while \O" is
used for non-entity tokens. The named entities identi ed by NER are combined
with the output of NMT in the assembling phase to build SQ0nat .
Training set format. The NMT and NER networks are trained together using
the same input, obtained by converting the original training set into a novel
format called QQT format. This pre-processing step has a two-fold objective.
On the one hand, it aligns the inputs of both NMT and NER tasks; and, on the
other hand, it reduces the size of the output vocabulary and helps to mitigate
the impact of the WOOV during the translation. Translating entities to URIs
can be hard to learn from mere examples. A system can fail if the NER task is
not simple and there are a lot of words that are out of the vocabulary of the
training set.
        </p>
        <p>A dataset in QQT is composed of a set of triples in the form hQuestion;
QueryT emplate; T aggingi, where Question is a natural language question,
Tagging marks which parts of Question are entities, and QueryT emplate is a
SPARQL query template modi ed as follows: (i) The KB resources are replaced
by one or more variables; (ii) A new triple is added for each variable in the
form "?var rdfs:label placeholder". P laceholders are meant to be replaced by
substrings of Question depending on T agging.</p>
        <p>
          In Table 1, we show an example of a hQnat; Qsparqli pair, while Table 2 shows
the corresponding hQuestion; QueryT emplate; T aggingi triple in the QQT
format. In Table 2, the term $1 denotes a placeholder where the number index 1
means that $1 has to be replaced by the rst entity occurring in the question,
Mona Lisa in this case, as represented by BIO tagging notation. Note that in
the QQT format, the query template does not contain any KB resource, so the
learning model does not need to understand Mona Lisa stands for a speci c KB
resource identi er. With this representation, the output vocabulary of the NMT
model is reduced, and the network is more tolerant to the WOOV problem.
The networks. As we have seen, the architecture has two important parts that
are NMT and NER. To develop the NMT neural network, we decided to use
the standard Encoder-Decoder approach, with BiLSTM and Luong Attention
[
          <xref ref-type="bibr" rid="ref8">8</xref>
          ], which has shown high performance in the literature. On the other hand, to
develop the NER network, we used the BiLSTM-CRF approach proposed by
[
          <xref ref-type="bibr" rid="ref7">7</xref>
          ], which assigns a tag to each token in the input sequence. The two models
share the fact that they have a BiLSTM-based encoder to obtain the semantic
information from the input sequence. For this reason, we decided to do a joint
training of the two models looking to improve the training times and make the
two networks help each other.
        </p>
        <p>The proposed approach, depicted in Figure 1 (right), has a single encoder
composed of one BiLSTM layer with two branches connected to it. The rst
branch uses a CRF layer responsible for determining p(ljx), which refers to the
probability of calculating a tagging sequence l given an input sequence x. The
second one is an NMT decoder, composed of one LSTM layer and the attention
mechanism followed by a fully connected network calculating the probability
p(yjx) that the sequence y correctly translates x in QueryT emplate.
2.3</p>
      </sec>
      <sec id="sec-2-3">
        <title>Assembling</title>
        <p>The last step of the proposed architecture is the creation of Q0sparql. Here the
placeholders in Q0temp are replaced by the corresponding named entities. For
example, suppose we have the question-query pair:
&lt;Who developed Skype?, SELECT ?uri WHERE { wd:Q40984 wdt:P178 ?uri } &gt;
in the form hQnat; Qsparqli. Our system will translate Qnat to the following query
template:
SELECT ?uri WHERE { ?v wdt:P178 ?uri . ?v rdfs:label $1 }
and the NER task will identify that Skype is the named entity. So the query
instantiation step will produce:
SELECT ?uri WHERE { ?v wdt:P178 ?uri . ?v rdfs:label "Skype"@en }
which is a SPARQL query equivalent to Qsparql.</p>
        <p>At this step, we validate the entities identi ed by the NER model to produce a
more accurate query. The system checks that the rdfs:label -based triples created
with the entities produce a non-empty result and consider them valid. If a triple
does not have a match in the KB, the system attempts to x it using the entities
identi ed with the NEL tool. In this case, we pick the entity identi ed by NEL
whose surface in the question overlaps with the entity we are trying to x. If it
is not possible to x a non-valid triple, the system will probably respond with
an incorrect answer.</p>
        <p>sparql-qa</p>
      </sec>
      <sec id="sec-2-4">
        <title>Conclusion</title>
      </sec>
    </sec>
    <sec id="sec-3">
      <title>Results</title>
      <p>We have implemented our models using Keras, a well-known framework for
machine learning, on top of TensorFlow. The training process was carried out on
Google Colaboratory, a Jupyter notebook environment running entirely in the
cloud. Colaboratory provides an environment with 12 GB of RAM and the
possibility to run the code using a GPU con guration.</p>
      <p>To train and ne-tune the system, we used the dataset released for the tenth
edition of QALD2. Table 3 shows the results obtained by sparql-qa in the
challenge, demonstrating that the system performed very well. The reported scores
were calculated using the GERBIL-QA3 web service. A live demo of the system
is available at: https://www.mat.unical.it/ricca/sparqlqa.</p>
      <p>The paper presents sparql-qa, an approach for querying knowledge bases by
using natural language. The system relies on the combination of Neural Machine
Translation and Named Entity Recognition while focusing on attenuating the
impact of the OOV words. sparql-qa showed to be a valid proposition in the eld
of KBQA, and the results obtained in QALD-10 demonstrate this.</p>
      <p>In future work, we plan to improve our system by integrating other NLP
tools, such as BERT word embeddings, Transformers, and Relation Linking.
2 https://github.com/KGQA/QALD 10
3 https://gerbil-qa.aksw.org/gerbil/experiment?id=202205200035</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <surname>Bahdanau</surname>
            ,
            <given-names>D.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Cho</surname>
            ,
            <given-names>K.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Bengio</surname>
            ,
            <given-names>Y.:</given-names>
          </string-name>
          <article-title>Neural machine translation by jointly learning to align and translate</article-title>
          .
          <source>arXiv preprint arXiv:1409.0473</source>
          (
          <year>2014</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <surname>Bojanowski</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Grave</surname>
            ,
            <given-names>E.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Joulin</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Mikolov</surname>
            ,
            <given-names>T.</given-names>
          </string-name>
          :
          <article-title>Enriching word vectors with subword information</article-title>
          .
          <source>TACL 5</source>
          ,
          <issue>135</issue>
          {
          <fpage>146</fpage>
          (
          <year>2017</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <surname>Borroto</surname>
            ,
            <given-names>M.A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Ricca</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Cuteri</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          :
          <article-title>Reducing the impact of out of vocabulary words in the translation of natural language questions into sparql queries</article-title>
          .
          <source>arXiv preprint arXiv:2111.03000</source>
          (
          <year>2021</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <surname>Daiber</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Jakob</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Hokamp</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Mendes</surname>
            ,
            <given-names>P.N.</given-names>
          </string-name>
          :
          <article-title>Improving e ciency and accuracy in multilingual entity extraction</article-title>
          . In:
          <string-name>
            <surname>ICSS (I-Semantics)</surname>
          </string-name>
          (
          <year>2013</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <surname>Grishman</surname>
            ,
            <given-names>R.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Sundheim</surname>
            ,
            <given-names>B.M.:</given-names>
          </string-name>
          <article-title>Message understanding conference-6: A brief history</article-title>
          .
          <source>In: COLING 1996 Volume 1: The 16th Int. Conf. on Comp. Linguistics</source>
          (
          <year>1996</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <surname>Honnibal</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Montani</surname>
            , I., Van Landeghem,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Boyd</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          : spaCy:
          <string-name>
            <surname>Industrialstrength Natural Language Processing in Python</surname>
          </string-name>
          (
          <year>2020</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7.
          <string-name>
            <surname>Huang</surname>
            ,
            <given-names>Z.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Xu</surname>
            ,
            <given-names>W.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Yu</surname>
            ,
            <given-names>K.</given-names>
          </string-name>
          :
          <article-title>Bidirectional LSTM-CRF models for sequence tagging</article-title>
          .
          <source>CoRR abs/1508</source>
          .
          <year>01991</year>
          (
          <year>2015</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          8.
          <string-name>
            <surname>Luong</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Pham</surname>
            ,
            <given-names>H.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Manning</surname>
          </string-name>
          , C.D.:
          <article-title>E ective approaches to attention-based neural machine translation</article-title>
          .
          <source>arXiv preprint arXiv:1508.04025</source>
          (
          <year>2015</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          9.
          <string-name>
            <surname>Ramshaw</surname>
            ,
            <given-names>L.A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Marcus</surname>
            ,
            <given-names>M.P.</given-names>
          </string-name>
          :
          <article-title>Text chunking using transformation-based learning</article-title>
          .
          <source>In: Nat. lang. proc. using very large corpora</source>
          , pp.
          <volume>157</volume>
          {
          <fpage>176</fpage>
          . Springer (
          <year>1999</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          10.
          <string-name>
            <surname>Shen</surname>
            ,
            <given-names>W.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Wang</surname>
            ,
            <given-names>J</given-names>
            ., Han, J
          </string-name>
          .:
          <article-title>Entity linking with a knowledge base: Issues, techniques, and solutions</article-title>
          .
          <source>IEEE TKDE 27(2)</source>
          ,
          <volume>443</volume>
          {
          <fpage>460</fpage>
          (
          <year>2014</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          11.
          <string-name>
            <surname>Sutskever</surname>
            ,
            <given-names>I.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Vinyals</surname>
            ,
            <given-names>O.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Le</surname>
            ,
            <given-names>Q.V.</given-names>
          </string-name>
          :
          <article-title>Sequence to sequence learning with neural networks</article-title>
          .
          <source>In: NIPS</source>
          . pp.
          <volume>3104</volume>
          {
          <issue>3112</issue>
          (
          <year>2014</year>
          )
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>