<!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>Operations for Seamless Querying of Textual and Tabular Data</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Matthias Urban</string-name>
          <email>matthias.urban@cs.tu-darmstadt.de</email>
          <xref ref-type="aff" rid="aff1">1</xref>
          <xref ref-type="aff" rid="aff2">2</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Carsten Binnig</string-name>
          <email>carsten.binnig@cs.tu-darmstadt.de</email>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff1">1</xref>
          <xref ref-type="aff" rid="aff2">2</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>DFKI</institution>
          ,
          <addr-line>64289 Darmstadt</addr-line>
          ,
          <country country="DE">Germany</country>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>LWDA'22: Lernen</institution>
          ,
          <addr-line>Wissen, Daten, Analysen</addr-line>
        </aff>
        <aff id="aff2">
          <label>2</label>
          <institution>Technical University of Darmstadt</institution>
          ,
          <addr-line>Karolinenplatz 5, 64289 Darmstadt</addr-line>
          ,
          <country country="DE">Germany</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>Many real-world applications in medicine, finance or other domains need to combine tabular and textual data. In this paper, we present a new approach called hybrid database operations which is a new class of learned database operations that allows users to seamlessly execute SQL queries over text and tabular data. As a main contribution to enable hybrid database operations, we show how state-of-the-art pre-trained language models such as BERT can be used to implement hybrid database operations such as joins or unions. In our initial evaluation, we report first promising results on real-world data sets which indicate that highly accurate hybrid operations can be realized with minimal training overhead.</p>
      </abstract>
      <kwd-group>
        <kwd>ML for databases</kwd>
        <kwd>hybrid database operations</kwd>
        <kwd>pre-training</kwd>
        <kwd>multimodal</kwd>
        <kwd>language models</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1. Introduction</title>
      <p>
        Relational databases are the predominant approach used today in business and science for
managing tabular data. One of the features contributing to their success is the query language
SQL which allows structured data to be queried in a simple manner. However, today many
applications need to deal with data sources beyond tabular data such as textual sources. While
several extensions for textual data such as full-text search or pattern matching [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ] have been
integrated into relational databases and SQL, it can still not treat textual data sources as first
class citizens and allow them to be queried in the same manner as tabular data.
      </p>
      <p>To illustrate this by an example, think of a hospital database, which stores structured data
of the patients such as age or gender together with medical reports that contain information
about diagnoses and treatments. If all this data would be stored in structured tables, a data
analyst could simply author a SQL query that finds out how many patients are currently in the
hospital with the same diagnosis. Unfortunately, this is not possible if the information about the
diagnoses is only available in textual reports about the patients. In this case, the data analyst
today has to set up a complex data extraction pipeline to retrieve all diagnoses. That quickly
becomes tedious, especially when the data that needs to be extracted changes over time.</p>
      <p>
        In this paper, we thus present a new approach called hybrid database operations which is a
new class of learned database operations that allows users to seamlessly execute SQL queries
over text and tabular data. The basic idea of hybrid database operations is that we build on
the recent breakthroughs of large pre-trained language models in NLP [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ] that have shown to
learn new tasks on textual data with only minimal training overhead. This line of work has
also inspired researchers to use and extend these large language models towards models that
can represent tabular data [
        <xref ref-type="bibr" rid="ref3 ref4">3, 4</xref>
        ]. However, while these models have been successfully used
for NLP-centric tasks, only few papers have been trying to use them for database-related tasks
such as running database queries over text collections [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ].
      </p>
      <p>
        Hence, as a main contribution in this paper, we study how large pre-trained language models
can be used to realize hybrid database operations. To be more precise, we show how hybrid
database operations such as a hybrid JOIN or hybrid UNION can be realized as downstream
tasks based on recent pre-trained language models that can jointly represent text and tabular
data, like TaBERT [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ]. These operations extract queried information from text and combine it
with the rows of a table (JOIN ) or add it as rows to a table (UNION ). For example, as shown in
Figure 1, a hybrid JOIN enables a data analyst to join the patients table with the patient reports
containing information diagnoses without explicitly extracting the required information into a
structured table in the first place. Most similar to our work are recent approaches to transform
texts to tables [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ] which, however, need to be trained from scratch for every new dataset. In
contrast, we provide a large pre-training dataset, which allows our model to be usable on unseen
domains with little to no training data.
      </p>
      <p>
        To summarize, at the core, we present two major contributions to enable hybrid database
operations: (1) We show how hybrid database operations can be realized as downstream tasks on
top of TaBERT [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ].(2) While TaBERT has been pre-trained on corpora that span over text and
tables, the pre-training objectives are not well suited to support SQL operations as downstream
tasks. Hence, as a second contribution we present a new pre-training procedure that is better
suited for enabling SQL over hybrid data.
      </p>
    </sec>
    <sec id="sec-2">
      <title>2. Hybrid Database Operations</title>
      <p>In this paper, we investigate hybrid database operations on a table  and a collection of documents
 . For hybrid JOIN s, each tuple  ∈  is linked to documents   ⊂  with a foreign-key
relationship. As shown in Figure 1, we assume there is a latent tabular representation   of the
document collection. Performing a hybrid JOIN means joining  with   . A hybrid UNION on
the other hand adds the rows of   to  .</p>
      <p>For this short paper, we want to mention that we introduce a couple of restrictions we aim to
relax in the future: For the hybrid JOIN , we assume there is only one document linked to each
tuple (i.e.   = {  }), the latent tabular representation   is a single table only, and for each tuple
 , only a single row needs to be extracted from the linked document   . For UNION s, we assume
... ... ...
[CLS] Carol was
[CLS] The diagnosis of Alice ... [SEP] name | text | Alice [SEP] diagnosis | text | [MASK] [SEP] date of birth | real | 1995 [SEP] ... [SEP]</p>
      <p>...</p>
      <p>Transformer (TaBERT)
... ... ... ... ... ... ... ...
diagnosed with atopic eczema ... Carol [MASK] 1962
...
...</p>
      <p>O</p>
      <p>O</p>
      <p>O
classifier</p>
      <p>O</p>
      <p>O</p>
      <p>B
classifier</p>
      <p>I</p>
      <p>SELECT p.name, p.date_of_birth, r.diagnosis</p>
      <p>FROM patients p HYBRID JOIN reports r
only a single row per text is added to the table.</p>
    </sec>
    <sec id="sec-3">
      <title>3. Model Design</title>
      <p>
        As the basis of our model we choose TaBERT [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ], a transformer-based model specifically
designed for jointly representing tabular and textual data. In the following, we explain how
hybrid database operations can be realized as a downstream task of TaBERT.
      </p>
      <p>Figure 2 shows an overview of the model as used in a hybrid JOIN . To perform a hybrid
JOIN s with TaBERT, we pair each tuple  with its join partner   . Additionally, we add the
query attributes from the user-provided SQL query to the tuple and add a mask token as the
value. The task of the model is to recover the masked values by extracting them from the text
and thereby computing the join. To perform UNION s with TaBERT, we pair the text with a
tuple, where all values are masked. To realize these hybrid database operations as a downstream
task, we formulate them as a masked-attribute reconstruction problem. As explained before,
the information that needs to be extracted from the textual source is represented as a masked
attribute in the model input. To recover the masked attribute from the text, we extend TaBERT
with a downstream model that can compute the answers spans in the text using so called
in-out-between (IOB) tags. These answer spans are sequences in the text that are a possible
value for the masked cells. This approach allows multiple answers per query and avoids so
called hallucination (i.e., the model can not simply generate answers that are not existing in the
text which is a typical problem of sequence-to-sequence language models).</p>
    </sec>
    <sec id="sec-4">
      <title>4. Pre-training of Model</title>
      <p>
        To be useful in practice, the model should work on new domains even with little to no training
data. Intuitively, the model should learn the essential skills to perform database operations
during pre-training. For both presented hybrid database operations, it is important to use signal
from table context to extract queried information from text. As our main pre-training objective,
we thus pair table rows and texts, mask random cell values and ask the model to reconstruct
them from the text using IOB tags. A secondary objective aligns column embeddings with text
embeddings. Due to the space constraints, we omit the details here. For these pre-training
objectives, we constructed a new dataset using T-REx [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ], a very large alignment of Wikipedia
abstracts with Wikidata triples. We construct the tables by grouping Wikidata entities to tables
and sampling Wikidata properties as columns. For each entity, we use the aligned Wikipedia
abstract as text, and use the alignment as labels for pre-training.
      </p>
      <p>(a) nobel JOIN (b) nobel UNION (c) countries JOIN (d) countries UNION
Figure 3: F1 scores on the JOIN and UNION workloads of the nobel data, and for the countries
workload. We vary the number of training samples for fine-tuning on the unseen domain.</p>
    </sec>
    <sec id="sec-5">
      <title>5. Initial Results</title>
      <p>
        In our initial experiments, we are interested how our model performs in unseen domains. For
the evaluation, we use also data extracted from T-REx [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ] — as for pre-training — but we make
sure that the model has not seen any data from these domains. Specifically, we construct two
evaluation datasets for our experiments: nobel and countries.
      </p>
      <p>
        In our initial results, we fix the model architecture using the new model extensions and
compare our pre-training scheme (green) to using the pre-trained weights of BERT [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ] (blue)
and TaBERT [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ] (orange). The results are shown Figure 3. As we can see, due to our pre-training,
our model is able to achieve impressive zero-shot performance for hybrid JOIN s, outperforming
both baselines. Despite being worse, our pre-training still performs better than baselines for
hybrid UNION s as well.
      </p>
    </sec>
    <sec id="sec-6">
      <title>6. Conclusion</title>
      <p>We show that large language models can be used to perform hybrid database operations having
only limited training data. In future work, we aim to support more complex database operations
and have a more thorough evaluation on non-Wikipedia texts.</p>
    </sec>
    <sec id="sec-7">
      <title>Acknowledgments</title>
      <p>This research was funded by the Hochtief project AICO (AI in Construction). Moreover, we
also want to thank hessian.AI at TU Darmstadt as well as DFKI Darmstadt.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>J. R.</given-names>
            <surname>Hamilton</surname>
          </string-name>
          ,
          <string-name>
            <given-names>T. K.</given-names>
            <surname>Nayak</surname>
          </string-name>
          ,
          <article-title>Microsoft SQL server full-text search</article-title>
          ,
          <source>IEEE Data Eng. Bull</source>
          .
          <volume>24</volume>
          (
          <year>2001</year>
          )
          <fpage>7</fpage>
          -
          <lpage>10</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>J.</given-names>
            <surname>Devlin</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Chang</surname>
          </string-name>
          ,
          <string-name>
            <given-names>K.</given-names>
            <surname>Lee</surname>
          </string-name>
          ,
          <string-name>
            <given-names>K.</given-names>
            <surname>Toutanova</surname>
          </string-name>
          ,
          <article-title>BERT: pre-training of deep bidirectional transformers for language understanding</article-title>
          ,
          <source>in: Proceedings of NAACL-HLT</source>
          <year>2019</year>
          ,
          <article-title>Association for Computational Linguistics</article-title>
          ,
          <year>2019</year>
          , pp.
          <fpage>4171</fpage>
          -
          <lpage>4186</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>P.</given-names>
            <surname>Yin</surname>
          </string-name>
          , G. Neubig,
          <string-name>
            <given-names>W.</given-names>
            <surname>Yih</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Riedel</surname>
          </string-name>
          ,
          <article-title>Tabert: Pretraining for joint understanding of textual and tabular data</article-title>
          ,
          <source>in: Proceedings of ACL</source>
          <year>2020</year>
          ,
          <article-title>Association for Computational Linguistics</article-title>
          ,
          <year>2020</year>
          , pp.
          <fpage>8413</fpage>
          -
          <lpage>8426</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>H.</given-names>
            <surname>Iida</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Thai</surname>
          </string-name>
          ,
          <string-name>
            <given-names>V.</given-names>
            <surname>Manjunatha</surname>
          </string-name>
          ,
          <string-name>
            <surname>M.</surname>
          </string-name>
          <article-title>Iyyer, TABBIE: pretrained representations of tabular data</article-title>
          ,
          <source>in: Proceedings of NAACL-HLT</source>
          <year>2021</year>
          ,
          <article-title>Association for Computational Linguistics</article-title>
          ,
          <year>2021</year>
          , pp.
          <fpage>3446</fpage>
          -
          <lpage>3456</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>J.</given-names>
            <surname>Thorne</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Yazdani</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Saeidi</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F.</given-names>
            <surname>Silvestri</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Riedel</surname>
          </string-name>
          ,
          <string-name>
            <surname>A. Y. Levy</surname>
          </string-name>
          ,
          <article-title>From natural language processing to neural databases</article-title>
          ,
          <source>Proc. VLDB Endow</source>
          .
          <volume>14</volume>
          (
          <year>2021</year>
          )
          <fpage>1033</fpage>
          -
          <lpage>1039</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>X.</given-names>
            <surname>Wu</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Zhang</surname>
          </string-name>
          ,
          <string-name>
            <given-names>H.</given-names>
            <surname>Li</surname>
          </string-name>
          ,
          <article-title>Text-to-table: A new way of information extraction</article-title>
          ,
          <source>in: Proceedings of ACL</source>
          <year>2022</year>
          ,
          <article-title>Association for Computational Linguistics</article-title>
          ,
          <year>2022</year>
          , pp.
          <fpage>2518</fpage>
          -
          <lpage>2533</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <given-names>H.</given-names>
            <surname>ElSahar</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P.</given-names>
            <surname>Vougiouklis</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Remaci</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Gravier</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J. S.</given-names>
            <surname>Hare</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F.</given-names>
            <surname>Laforest</surname>
          </string-name>
          , E. Simperl, T-rex:
          <article-title>A large scale alignment of natural language with knowledge base triples</article-title>
          ,
          <source>in: Proceedings of LREC</source>
          <year>2018</year>
          ,
          <article-title>European Language Resources Association (ELRA</article-title>
          ),
          <year>2018</year>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>