<!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>
      <journal-title-group>
        <journal-title>Baltimore, USA.
* Corresponding author.
†These authors contributed equally.
$ guilherme.santos-sousa@irit.fr (G. Sousa); rinaldo.jose@ufrpe.br (R. Lima); cassia.trojahn@irit.fr (C. Trojahn)</journal-title>
      </journal-title-group>
    </journal-meta>
    <article-meta>
      <title-group>
        <article-title>Towards Generating Complex Alignments with Large Language Models via Prompt Engineering</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Guilherme Sousa</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Rinaldo Lima</string-name>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Cassia Trojahn</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>IRIT: Institut de Recherche en Informatique de Toulouse</institution>
          ,
          <country country="FR">France</country>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>Universidade Federal Rural de Pernambuco</institution>
          ,
          <addr-line>Recife</addr-line>
          ,
          <country country="BR">Brazil</country>
        </aff>
      </contrib-group>
      <pub-date>
        <year>2024</year>
      </pub-date>
      <volume>000</volume>
      <fpage>0</fpage>
      <lpage>0002</lpage>
      <abstract>
        <p>Still few ontology matching approaches focus on generating alignments by a Large Language Model (LLM), especially in the complex matching task. This paper proposes an approach that leverages the capabilities of LLMs to perform complex ontology matching. The method integrates subsets of both source and target ontologies into the prompt and, as a response, the LLM generates alignments in the structured EDOAL format, rather than natural language descriptions. This reduction technique, based on the automatic generation of SPARQL queries, tackles the challenge of large prompt sizes, reduces the search space, and enables eficient processing on consumer-grade hardware. This approach is evaluated on the Conference and Geolink datasets from the OAEI complex track, demonstrating improved scalability and the ability to produce well-formed EDOAL. Key contributions include the development of a SPARQL-based prompt engineering strategy and the application of few-shot learning techniques to complex alignment generation.</p>
      </abstract>
      <kwd-group>
        <kwd>eol&gt;LLM</kwd>
        <kwd>complex matching</kwd>
        <kwd>SPARQL</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1. Introduction</title>
      <p>Ontology matching techniques have predominantly focused on simple alignment tasks that are
insuficient to cover real-world needs. As data complexity and their relationships increase, the challenge of
accurately aligning schemes and ontologies and generating expressive correspondences becomes more
pronounced. Conversely, advancements in the field of Natural Language Processing (NLP) have led to
the development of powerful Large Language Models (LLMs), which have demonstrated remarkable
capabilities in understanding and generating natural language. Although such models have been explored
for simple alignment tasks, there has been a growing interest in their use for complex matching.</p>
      <p>
        A recent work addressing the problem has been proposed in [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ]. Their approach harnessed the
capacity of LLMs to find alignments between GeoLink Modular Ontology (GMO) and GeoLink Base
Ontology (GBO) in the Geolink dataset [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ]. In that work, the whole GMO ontology is loaded in
the prompt, and the modules in GBO are inserted and asked for the related parts in GMO and the
LLM responds in natural language. One of the weaknesses of such approach, however, lies in the
natural language output generated by LLMs, which complicates evaluating and verifying the resulting
alignment. This requires additional steps to convert from natural language to formats that existing
complex evaluation tools can process.
      </p>
      <p>
        A more general problem, however, is how to automatically modularize an ontology so that each
complex entity is defined inside its module. For example, the entity “Paper” may be related to an entity
“Author” that probably is not part of the complex “Paper” entity, and filtering out those relations is still
a dificult task. In [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ], the ontologies are already modularized permitting the search of corresponding
modules by the LLM. However, most of the ontologies do not contain that type of modularization
which limits the generalization of this approach since it will not be able to run in ontologies without
predefined modules.
      </p>
      <p>To address these limitations, this paper proposes an approach that selects subsets of both source
and target ontologies guided by automatically generated SPARQL queries from PageRank graph nodes.
Those subsets are inserted into the prompt and the LLM directly outputs the alignment results in a
structured format such as EDOAL rather than natural language descriptions.</p>
      <p>By incorporating both ontologies subsets into the prompt, an LLM will have more information to
work with since it can combine information from diferent parts of the ontology to produce each
correspondence and produce better alignment results. In addition, the task of delimiting complex
entities, combining them, and finding the complex correspondences between entities is passed to
the LLM. This approach simplifies the evaluation and verification of the results and provides a more
comprehensive and accurate alignment.</p>
      <p>
        A key aspect of our proposal is a technique to reduce the search space by employing the automatic
generation of SPARQL queries, as explored in [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ]1. Loading the whole ontologies can lend to very long
prompt declarations that common consumer hardware can’t execute due to the lack of memory. But
relying on these queries, only the relevant information from the ontologies is retrieved, narrowing
down the number of entities in the ontologies that the LLM needs to process. This enables the LLMs to
generate content using GPUs with lower capacity enhancing the scalability and eficiency of the task
while making it feasible to handle large-scale datasets.
      </p>
      <p>The main contributions of this paper are as follows: (i) an approach to complex ontology matching by
leveraging the capabilities of LLMs to generate complex alignments in structured format via few-shot
prompting and; (ii) a technique based on RAG to reduce the prompt size by creating subsets of the input
ontologies guided by SPARQL queries.</p>
      <p>The rest of the paper is organized as follows. In Section 2 the research motivations are introduced.
In Section 3, the proposed architecture is detailed while explaining all its substeps. In Section 4.1 the
experiment settings and results are presented. In Section 5 the related work are discussed. Finally, in
Section 6 the conclusion of the paper is presented.</p>
    </sec>
    <sec id="sec-2">
      <title>2. Motivating Example</title>
      <p>Recent LLM advancements have opened new ways to construct matchers for complex ontology matching
tasks. Notably, models like ChatGPT-4o2 and Claude 3.53 have demonstrated the ability to perform
complex alignments in controlled, toy problem settings by leveraging the input of entire ontologies
into the prompt, as exemplified in Figure 1.</p>
      <p>
        After inserting the ontologies in the prompt, the next step consists of providing the instructions and
examples of alignments so the model can learn to write the resulting alignment in the required format
as exemplified in Figure 2. The examples provided and the resulting alignment are in EDOAL [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ].
      </p>
      <p>The output produced by ChatGPT4o is illustrated in Figure 3. The input ontologies were crafted
to contain the concept of AcceptedPaper in the source ontology and the concept of Paper that have
a property hasAcceptance leading to a range Acceptance in the target ontology. The LLM properly
ifnds similar complex entities between source and target ontologies even without examples of complex
correspondences in the prompt. Moreover, the LLM properly combines the entities Paper, hasAcceptance,
and Acceptance to produce the complex correspondence while following the proposed file structure in
the examples.</p>
      <p>
        This case highlights the potential of LLMs to perform complex ontology matching by directly
outputting the alignments in the expected format. However, ChatGPT-4o and Claude 3.5 are private
LLMs that have hardware requirements far beyond those available to most consumers. In this sense,
1In that work, the notion of Competency Question for Alignment (CQA) has been introduced as a way of expressing user
needs in terms of alignments, in the form of SPARQL queries. As it has been also explored in that work, we adopt here an
automatic way of generating such queries, referred to as ‘SPARQL queries’ for short, in this paper.
2https://chatgpt.com/
3https://claude.ai/new
Given the two ontologies below:
enabling open and smaller LLMs to perform this task is a desirable objective. These tests have been
corroborated with Llama-3 4, an open-source LLM available in smaller sizes. It has demonstrated the
ability to find correspondences between entities but produced the output in the wrong format even
if explicitly instructed to output in EDOAL. By giving examples of alignments, a technique named
few-shot learning [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ], causes Llama-3 to produce alignments in the right format. These examples
highlight the importance of prompt engineering in instructing the LLMs to perform complex matching.
      </p>
      <p>Despite these promising capabilities, significant challenges remain when deploying these models
in real-world scenarios. One of the primary obstacles is the substantial size of the prompts due to
the whole input of the source and target ontologies in the prompt that can reach the magnitude of
millions of tokens. This becomes problematic as consumer-grade GPUs, commonly used in many
practical applications, are unable to handle such large inputs eficiently. To deal with these problems,
our proposed approach to automatically construct the prompts with examples and in a reduced size is
described in the next sections.</p>
    </sec>
    <sec id="sec-3">
      <title>3. Proposal</title>
      <p>
        To overcome the challenges of large prompt sizes and limited computational resources, an approach for
reducing the search space is proposed. This reduction is based on using generated SPARQL queries to
select the most promising parts of an ontology and writing smaller prompts that the LLM can process.
Here, the use of automatically generated SPARQL is inspired from [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ], where a Competency Question
for Alignment (CQA) is a competency question that should (in the best case) be covered by two or more
      </p>
      <sec id="sec-3-1">
        <title>4https://huggingface.co/meta-llama/Meta-Llama-3-8B-Instruct</title>
        <p>Write a file in EDOAL format containing the complex alignment between the ontology1 and ontology2. You don't
need to explain yourself. Just give as response the resulting file without saying anything. Here is one example
bellow:
&lt;ontology1&gt;
# prefixes
lib:Book1 a lib:Book ;
dcterms:title "The Catcher in the Rye" ;
dcterms:creator lib:Author1 ;
lib:hasGenre "Fiction" .
lib:Author1 a lib:Author ;
foaf:name "J.D. Salinger" ;
foaf:birthDate "1919-01-01" .
&lt;/ontology1&gt;
&lt;ontology2&gt;
# prefixes
pub:Book1 a pub:Book ;
dcterms:title "To Kill a Mockingbird" ;
dcterms:creator pub:Author1 ;
pub:publicationYear "1960" .
pub:Author1 a pub:Author ;
foaf:name "Harper Lee" ;
pub:hasNationality "American" .</p>
        <p>&lt;/ontology2&gt;
&lt;alignment&gt;
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;rdf:RDF #prefixes&gt;
&lt;Alignment&gt;
&lt;onto1&gt;
&lt;Ontology rdf:about="http://example.org/library#"/&gt;
&lt;/onto1&gt;
&lt;onto2&gt;
&lt;Ontology rdf:about="http://example.org/publishing#"/&gt;
&lt;/onto2&gt;
&lt;map&gt;
&lt;Cell&gt;
&lt;entity1 rdf:resource="http://example.org/library#Book"/&gt;
&lt;entity2 rdf:resource="http://example.org/publishing#Book"/&gt;
&lt;relation&gt;=&lt;/relation&gt;
&lt;measure&gt;1.0&lt;/measure&gt;
&lt;/Cell&gt;
&lt;/map&gt;
&lt;map&gt;
&lt;Cell&gt;
&lt;entity1 rdf:resource="http://example.org/library#Author"/&gt;
&lt;entity2 rdf:resource="http://example.org/publishing#Author"/&gt;
&lt;relation&gt;=&lt;/relation&gt;
&lt;measure&gt;1.0&lt;/measure&gt;
&lt;/Cell&gt;
&lt;/map&gt;
&lt;/Alignment&gt;
&lt;/rdf:RDF&gt;
&lt;/alignment&gt;
ontologies. However, the user manually writes the CQAs to express their needs, and writing CQAs
for each mapping pair is not scalable. In this sense, in this work, the use of automatically generated
SPARQL queries is applied to perform the search space reduction.</p>
        <p>At the end of the generation step of all prompts, the EDOAL output of the LLM of the same pair of
ontologies is later combined. Along with that reduction, a prompt engineering strategy (few-shot) is
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;rdf:RDF #prefix&gt;
&lt;Alignment&gt;</p>
        <p>. . .
applied to enable the LLM to perform the complex matching task. The proposed method is detailed in
the following sections.</p>
        <sec id="sec-3-1-1">
          <title>3.1. Reducing Search Space using Automatically Generated Queries</title>
          <p>
            The reduction of space is composed of three main steps, which are detailed in the following.
3.1.1. Identifying Pertinent Entities using PageRank
The first step involves identifying the most relevant entities within the ontologies. In [
            <xref ref-type="bibr" rid="ref6">6</xref>
            ] a method
to automatically find the most relevant entities and later produce SPARQL queries is proposed and is
based on the number of instances that an entity has. However, not all ontologies contain instances, and
some contain few instances of the most relevant classes in the ontology. To improve in this direction, in
this work is proposed to apply PageRank as it doesn’t need instances to work.
          </p>
          <p>
            The PageRank [
            <xref ref-type="bibr" rid="ref7">7</xref>
            ] algorithm operates on the principle of link analysis, where entities with higher
incoming links from other significant entities are considered more relevant. By applying PageRank to
the graph structure of the ontologies, a score for each node in the ontology graph is computed and those
that have importance over a threshold are selected. These entities are converted to SPARQL queries and
will guide the splitting of the ontologies into smaller sizes. This method is applied only in the source
ontology to generate the queries that are later used to filter both source and target ontologies.
          </p>
          <p>The PageRank computes the rank of a node by iterating  times all  nodes in the ontology and
updating their values in each iteration. The rank of a node is the sum of the ranks of its incoming links
divided by their outgoing links. The rank of a link is computed with the equation 1.
() =  * _−1(()) +
1 − 

(1)</p>
          <p>
            After the final iteration, the rank of all nodes is normalized by dividing the ranks by the maximum
rank value, and the nodes with a rank higher than a threshold will be converted to SPARQL queries. The
conversion template is based on the work [
            <xref ref-type="bibr" rid="ref6">6</xref>
            ] with three cases considered. The classes are injected into
the template SELECT DISTINCT ?x WHERE {?x a &lt;CLASS&gt;.}, the properties into the template SELECT
DISTINCT ?x ?y WHERE {?x &lt;PROPERTY&gt; ?y.}, and instances into the template SELECT DISTINCT ?x
WHERE {?x a &lt;INSTANCE&gt;.}.
3.1.2. Generating Description Documents from Entities
Once the most promising entities are identified, pseudo-documents are generated for each entity in
the input ontology. This approach is inspired by the NLFOA matcher [
            <xref ref-type="bibr" rid="ref8">8</xref>
            ], which suggests creating
textual descriptions of an ontology node’s structure to generate embeddings using language models.
Evaluated in various studies [
            <xref ref-type="bibr" rid="ref10 ref11 ref9">9, 10, 11</xref>
            ], this type of representation of subgraphs are better utilized by
LLMs. While the original method addressed only the representation of simple entities, our work adapts
this technique to represent also complex entities. Each pseudo-document includes the target concept
along with its parents, children, incoming and outgoing relations, and disjoint concepts.
          </p>
          <p>
            The template used to produce the documents is given in Figure 5. The template is the same for both
simple and complex entities. Complex entities are retrieved from BNodes and processed to generate a
text representation. For example, a BNode containing owl:unionOf and a chain of rdf:first and rdf:rest
are traversed and the entities are collected in a list and written in a single line of text. For example, the
union of Conference and Event results in the text UnionOf (Conference, Event) that is inserted into the
ifeld Name of the template. The other fields, Parents, Children, Incoming Properties, Outgoing
Properties, and Disjoint with are also lists of entities retrieved from the graph structure of the
ontology. The number of entities in each field is limited to produce reduced-size documents.
3.1.3. Creating Sub-Ontology Prompts
The next step is inspired by Retrieval Augmented Generation (RAG) [
            <xref ref-type="bibr" rid="ref12">12</xref>
            ] techniques, the final prompts
that the LLM will process are generated by combining a subset of both source and target ontologies by
expanding the most promising entities retrieved from the ontologies based on the selected generated
SPARQL queries. For this step, embeddings of the SPARQL query and the description documents,
generated for all entities in each ontology, are computed using the best language model of the MTEB
[13] leaderboard 5. The similarity between the query embedding and the embeddings of the entities
documents in the ontology is computed, and the top  most similar entities are selected to be included
in the ontology subset. This is a similar process to the retrieval from a vector database [14] where the
SPARQL embedding is the query, the embeddings from the documents are the keys and the values are
the actual entity that generated the description document. Since the same query guides the search for
similar entities in both source and target ontologies, an overlap between the entities is induced by the
semantic search of the embedding similarities.
          </p>
          <p>After retrieving the most promising entities, a new ontology is created by inserting the entities
subgraphs expanded by traversing the ontology and inserting the same relations triples until a certain
depth from the initial entity. This process is applied to source and target ontologies using the same
SPARQL query to ensure that entities semantically related to source and target ontologies are present
for comparison in the prompt. Finally, a turtle serialization of the subset ontology is produced to be
included in the prompt. Serializing the final ontology using turtle format reduces the number of tokens
since turtle is less verbose than RDF/XML. The process is illustrated in the Figure 6.</p>
          <p>With the sub-ontologies prepared, a prompt is generated by filling in the following template:
Given the two ontologies below:
&lt;ontology1&gt;
&lt;ontology2&gt;
Examples of complex alignment between different ontologies:
&lt;ontology1&gt;
&lt;ontology2&gt;
&lt;alignment&gt;
Considering that the input ontologies were filtered to include only the
entities related to the query:
&lt;query&gt;
Write a file in EDOAL format containing the complex alignment between the
ontology1 and ontology2. You don’t need to explain yourself. Just give as
response the resulting alignment file without saying anything else.</p>
          <p>For the experiments, three diferent variations of the prompt template were tested. The first does</p>
        </sec>
      </sec>
      <sec id="sec-3-2">
        <title>5At the time where the experiments were run.</title>
        <p>not include examples, the second includes examples without the SPARQL query used to select the
subontology, and the last includes both examples and the query.</p>
        <sec id="sec-3-2-1">
          <title>3.2. Generation of EDOAL Output</title>
          <p>After the generation of the prompts, they are input into the LLM to generate the alignment results in
EDOAL. The EDOAL format provides a formal representation of the alignments, capturing complex
relationships and correspondences between the entities of the ontologies while facilitating the evaluation
of the performance of the alignments produced since the automatic evaluation system used in this work
processes that format.</p>
          <p>In the generation step, the model is prompted without token sampling, only the most probable token
is always selected, with a maximum generation length of 2048 tokens. The generated EDOAL is then
repaired in the cases where the model doesn’t generate an appropriate file ending (caused by files
that are supposed to be larger than 2048 tokens). Then the EDOAL files for all SPARQL queries in the
same source and target ontology pairs are combined resulting in a single file. The file contains all the
correspondences related to the concepts in all generated SPARQL queries from the same source and
target ontology pair. This is the final output of the architecture that will be later evaluated. That process
is depicted in Figure 7.</p>
        </sec>
      </sec>
    </sec>
    <sec id="sec-4">
      <title>4. Experiments</title>
      <p>To evaluate the quality of the alignments produced by the LLM, an experiment was conducted by
generating several prompts and evaluating their performance using an automated evaluator [15]. The
evaluator assesses the performance of the alignments by comparing the number of similar instances
retrieved in each correspondence. Metrics such as precision, recall, and F1-score are used to quantify
the performance of the alignment process. In addition, no training or fine-tuning was performed in any
model during the experiments, the model’s weights are not changed in any way during the execution.</p>
      <p>The selected datasets are Conference and Geolink from the OAEI6 complex track. The selected model
for retrieval is Salesforce/SFR-Embedding-2_R used in the process of generating the prompts. The LLM
used for the response generation is meta-llama/Meta-Llama-3-8B-Instruct both of them retrieved from
HuggingFace 7. The code used in the experiments can be found in GitLab 8.</p>
      <sec id="sec-4-1">
        <title>4.1. Results and Discussion</title>
        <p>The first step in the execution pipeline is the generation of the queries that will narrow the size of the
prompts to generate the response by the LLM. The PageRank was run with 10 iterations, a damping
factor of 0.8, and a threshold of 0.4 that selects a maximum of 30 entities. The number of entities selected
for each ontology is present in Table 1.</p>
        <p>Ontology
conference/iasted
conference/edas
conference/Cocus
conference/paperdyne</p>
        <p>conference/crs_dr
conference/conference
conference/confious
conference/MyReview
conference/sigkdd
conference/PCS
conference/OpenConf
conference/linklings
conference/cmt
conference/ekaw
conference/MICRO
conference/confOf
geolink/gmo
geolink/gbo</p>
        <p>After that step, prompt generation was performed as described in Section 3.1.3. It runs with 15
max entities for each field that receives a list of entities in the description document generation. The
maximum size of those documents is 4096 characters and the documents are trimmed in case of overflow.
The language model used for the embeddings generation is instruction tunned and the instruction
passed along with the query was “Given the following SPARQL query, retrieve relevant entities that are
related to the query”. The entity inclusion considers the top 2 most similar entities to the SPARQL query
and inflates them by traversing depth 2 following outgoing triples and depth 1 following incoming
triples and adding them into the resulting ontology. A sample of the number of tokens for all prompts</p>
        <sec id="sec-4-1-1">
          <title>6https://oaei.ontologymatching.org/2020/complex/index.html 7https://huggingface.co/models 8https://gitlab.irit.fr/melodi/ontology-matching/complex/llm-complex-matching</title>
          <p>generated from the pair Cmt-Conference, when tokenized using the Llama3 tokenizer, is present in
Table 2. With that strategy, the matching process can run on a 12 GB VRAM GPU.</p>
          <p>query
whole ontologies</p>
          <p>c-person
c-preference
c-programcommittee</p>
          <p>c-bid
c-decision
c-administrator
c-document</p>
          <p>c-paper
c-conference</p>
          <p>For this experiment, three variations were performed in the LLM prompts. The first variation uses a
prompt without examples (LLM, no examples), only containing source and target input ontologies and
instructions to generate the final alignment file. The next variation is the usage of two diferent examples
of alignments between sample ontologies (LLM, no query), one containing only simple correspondences
and the other containing examples of complex correspondences. The last variation includes examples
and instructions explaining what SPARQL query was used to produce the ontologies subsets (LLM,
query+examples).</p>
          <p>In total as illustrated in Figure 8, 4730 correspondences were produced in the no examples variation
while no complex correspondences were produced. In the no query variation 8567 correspondences
were produced while 93 were complex correspondences. And in the query+examples variation 2214
correspondences were produced while 22 were complex. The no query variation is the one that
produces the highest number of correspondences and also the highest number of complex
correspondences. The variation query+examples generates the lowest number of correspondences however
with higher complex entities than the variation no examples. The no examples variation wasn’t able
to generate any complex correspondence while a large amount of them are in natural language or in
the wrong format. This illustrates the importance of few-shot prompting in the generation of complex
correspondences in the right format.</p>
          <p>The merged output was evaluated using the automatic evaluator proposed in [15]. It has a
CQAoriented and a precision-oriented evaluation. The CQA oriented requires CQAs to operate while the
precision-oriented doesn’t require CQAs. The approach was evaluated in the Conference and Geolink
datasets. Due to the requirement for CQAs, the Geolink dataset was evaluated only using the precision
evaluator and the CQAs for the Conference track are present with the dataset. Moreover, since the
evaluator requires instances to work, in the conference dataset, the approach receives as input the
Conference dataset and was evaluated in the Populated Conference dataset as it contains instances.</p>
          <p>The proposed variations were compared with CANARD [16] matcher and the results of the evaluation
are presented in Table 3. The proposed matcher still falls behind the CANARD baseline in most of the
metrics. When compared between the variations, the no query have higher results in the evaluation
mode while the variation query+examples achieves higher precision. The variation without examples
gets zero results in both CQA-based and precision-based evaluations. As can be seen by these results,
providing examples is essential to the model’s performance as it learns from the examples how to write
the alignments in the EDOAL format.</p>
          <p>mode</p>
          <p>CANARD
LLM (no examples)</p>
          <p>LLM (no query)
LLM (query+examples)</p>
          <p>CANARD
LLM (no examples)</p>
          <p>LLM (no query)
LLM (query+examples)</p>
          <p>CANARD
LLM (no examples)</p>
          <p>LLM (no query)</p>
          <p>LLM (query+examples)</p>
          <p>One of the reasons for getting worse results than CANARD is that the proposed matcher generates
the wrong entity ID prefixes in some correspondences. That can cause worse results as the evaluator
uses the correspondences to retrieve the instances and measures the number of the same instances
that the correspondences retrieve, however with the wrong IDs, no instances will be retrieved and that
correspondence will be considered as a miss. However, while the proposed matcher still has lower
performance than CANARD, it can perform the matching even in the absence of instances, contrary to
CANARD which requires the ontologies to be populated to match them.</p>
          <p>In the Geolink dataset, both CANARD and the proposed matcher fail to generate correct
correspondences. In the case of the proposed matcher, the wrong results are caused by not finding any correct
correspondences. Some of the found correspondences, for example, the model generates the
correspondence between the property http://gmo#hasFix and the image path
http://schema.geolink.org/images/gbooverview.svg that is not correct. One possible correspondence found by the proposed matcher is between
http://gmo#InformationObject and rdf:about="http://gbo#DigitalObject but if they fail to share common
instances they won’t be considered as correct correspondence.</p>
        </sec>
      </sec>
    </sec>
    <sec id="sec-5">
      <title>5. Related Work</title>
      <p>Ontology (including knowledge graph) matching is a task where natural language information is crucial
for development. The rise of LLMs has introduced new methods for enhancing the matching process.
While LLMs are being adopted in most pipelines for ontology matching, fewer works deal with directly
generating the full alignment output by the LLM for complex matching. This section reviews the works
in the current state of research on utilizing LLMs to generate correspondences for ontology matching.
Most existing methods rely on closed-source LLMs presenting reproducibility issues.</p>
      <p>OLaLa [17] is a customizable, open-source framework for ontology matching that uses LLM in the
matching pipeline. It extracts matching candidates from input ontologies, which are then analyzed
by an LLM using a user-defined prompt. The approach combines the LLMs with other matchers to
improve the alignments and maintain the requirement of simple alignments (1:1 correspondences).
The correspondence candidates are presented to the LLM for binary or multiple-choice decisions with
confidence scores aiding in selecting the final correspondences. Various text extractors provide single
text outputs for entities, including preferred labels and verbalized RDF triples. While efective in
the simple alignment task, the approach wasn’t explored for the complex matching case. Also, the
decision taken by the LLM considers only entity-level information that can be insuficient to decide the
correspondence between entities.</p>
      <p>
        In [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ] ChatGPT-4 was used to perform complex matching between the ontologies of GMO and GBO of
the Geolink dataset. In that approach, the full GMO ontology was provided as input in the prompt, and
similar entities from GBO were matched. In that work, an advantage is taken from the modularization
of the ontologies as the complex entity boundaries are already defined in those modules. However, this
approach is not accessible in the majority of cases. The first problem is that loading all of the ontologies
can consume a considerable amount of memory in GPUs, which most consumers don’t have access to.
To improve in this direction, divide-and-conquer strategies or compression strategies must be adopted
as applied in our proposal. The other issue is that most of the available ontologies are not modularized
making the application of that approach without modifications.
      </p>
      <p>More recently, in [18] a pattern-based approach for complex ontology matching has bee proposed.
Close to ours, it focuses on the use of SPARQL queries and Large Language Models (LLMs) for detecting
and validating complex correspondences between ontologies. Unlike existing methods, this approach
avoids lexical matching in the detection phase and relies solely on structural aspects, with LLMs
employed only in the final validation step. The approach uses a pattern-based approach to retrieve
verbalized candidate correspondences and input into the LLM for verification. However, the output of
the LLM is in natural language and the evaluation was performed manually while in this work the LLM
output was evaluated automatically.</p>
    </sec>
    <sec id="sec-6">
      <title>6. Conclusion</title>
      <p>This paper presents an approach to complex ontology matching by leveraging the capabilities of LLMs
and optimizing prompt size using a strategy based on automatically generated SPARQL queries. The
technique enhances the scalability and eficiency of ontology matching by reducing the number of
entities considered, making it feasible to handle large-scale datasets on consumer-grade hardware.
Additionally, the proposed method addresses challenges associated with large search spaces in ontology
matching, such as modularization and entity combination, through the use of LLMs. For instance,
by directly integrating ontologies into the prompt and outputting results in a structured format like
EDOAL, the method enables automatic evaluation of alignment results.</p>
      <p>Although a qualitative evaluation is still missing, the initial experiments (fully automated)
demonstrated that including examples in the prompts is crucial for performing complex matching tasks, as
they significantly improve the accuracy and format of alignments generated by LLMs compared to
using the same model without examples. Even with the high amount of data used to train those LLMs
and possible training with data from OAEI, the experiments with the LLMs conducted in this work
demonstrate that the LLMs are not producing the correct EDOAL format without examples in the
prompt, indicating that they haven’t see enough EDOAL data in the training or are not being able
to retain it. While the inclusion of examples notably enhances performance, there remains room for
optimization, especially in real-world scenarios where the complexity and scale of ontologies introduce
additional challenges. Future work will explore advanced prompt engineering techniques, fine-tuning
LLMs specifically for complex ontology matching tasks, and developing models capable of handling
larger prompts without increasing memory consumption.
[13] N. Muennighof, N. Tazi, L. Magne, N. Reimers, MTEB: massive text embedding benchmark, in:
A. Vlachos, I. Augenstein (Eds.), Proceedings of the 17th Conference of the European Chapter of
the Association for Computational Linguistics, EACL 2023, Dubrovnik, Croatia, May 2-6, 2023,
Association for Computational Linguistics, 2023, pp. 2006–2029. URL: https://doi.org/10.18653/v1/
2023.eacl-main.148. doi:10.18653/V1/2023.EACL-MAIN.148.
[14] J. J. Pan, J. Wang, G. Li, Survey of vector database management systems, CoRR
abs/2310.14021 (2023). URL: https://doi.org/10.48550/arXiv.2310.14021. doi:10.48550/ARXIV.
2310.14021. arXiv:2310.14021.
[15] É. Thiéblin, O. Haemmerlé, C. Trojahn, Automatic evaluation of complex alignments: An
instancebased approach, Semantic Web 12 (2021) 767–787. URL: https://doi.org/10.3233/SW-210437. doi:10.
3233/SW-210437.
[16] É. Thiéblin, G. Sousa, O. Haemmerlé, C. Trojahn, CANARD: an approach for generating expressive
correspondences based on competency questions for alignment, Semantic Web 15 (2024) 897–929.</p>
      <p>URL: https://doi.org/10.3233/SW-233521. doi:10.3233/SW-233521.
[17] S. Hertling, H. Paulheim, Olala: Ontology matching with large language models, in: K. B.</p>
      <p>Venable, D. Garijo, B. Jalaian (Eds.), Proceedings of the 12th Knowledge Capture Conference
2023, K-CAP 2023, Pensacola, FL, USA, December 5-7, 2023, ACM, 2023, pp. 131–139. URL: https:
//doi.org/10.1145/3587259.3627571. doi:10.1145/3587259.3627571.
[18] O. Zamazal, Towards pattern-based complex ontology matching using sparql and llm, in:
Proceedings of the 20th International Conference on Semantic Systems (SEMANTiCS 2024), SEMANTiCS,
Amsterdam, Netherlands, 2024. Poster paper.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>R.</given-names>
            <surname>Amini</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S. S.</given-names>
            <surname>Norouzi</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P.</given-names>
            <surname>Hitzler</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Amini</surname>
          </string-name>
          ,
          <article-title>Towards complex ontology alignment using large language models</article-title>
          ,
          <source>CoRR abs/2404</source>
          .10329 (
          <year>2024</year>
          ). URL: https://doi.org/10.48550/arXiv.2404.10329. doi:
          <volume>10</volume>
          .48550/ARXIV.2404.10329. arXiv:
          <volume>2404</volume>
          .
          <fpage>10329</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>L.</given-names>
            <surname>Zhou</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Cheatham</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Krisnadhi</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P.</given-names>
            <surname>Hitzler</surname>
          </string-name>
          ,
          <article-title>A complex alignment benchmark: Geolink dataset</article-title>
          , in: D.
          <string-name>
            <surname>Vrandecic</surname>
            ,
            <given-names>K.</given-names>
          </string-name>
          <string-name>
            <surname>Bontcheva</surname>
            ,
            <given-names>M. C.</given-names>
          </string-name>
          <string-name>
            <surname>Suárez-Figueroa</surname>
            ,
            <given-names>V.</given-names>
          </string-name>
          <string-name>
            <surname>Presutti</surname>
            , I. Celino,
            <given-names>M.</given-names>
          </string-name>
          <string-name>
            <surname>Sabou</surname>
            ,
            <given-names>L.</given-names>
          </string-name>
          <string-name>
            <surname>Kafee</surname>
          </string-name>
          , E. Simperl (Eds.),
          <source>The Semantic Web - ISWC 2018 - 17th International Semantic Web Conference</source>
          , Monterey, CA, USA, October 8-
          <issue>12</issue>
          ,
          <year>2018</year>
          , Proceedings,
          <string-name>
            <surname>Part</surname>
            <given-names>II</given-names>
          </string-name>
          , volume
          <volume>11137</volume>
          of Lecture Notes in Computer Science, Springer,
          <year>2018</year>
          , pp.
          <fpage>273</fpage>
          -
          <lpage>288</lpage>
          . URL: https://doi.org/10.1007/978-3-
          <fpage>030</fpage>
          -00668-6_
          <fpage>17</fpage>
          . doi:
          <volume>10</volume>
          .1007/978-3-
          <fpage>030</fpage>
          -00668-6\_
          <fpage>17</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>É.</given-names>
            <surname>Thiéblin</surname>
          </string-name>
          ,
          <article-title>Do competency questions for alignment help fostering complex correspondences?</article-title>
          , in: L.
          <string-name>
            <surname>Hollink</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          <string-name>
            <surname>Osborne</surname>
          </string-name>
          (Eds.),
          <source>Proceedings of the EKAW Doctoral Consortium</source>
          <year>2018</year>
          co
          <article-title>-located with the 21st International Conference on Knowledge Engineering and Knowledge Management (EKAW</article-title>
          <year>2018</year>
          ), Nancy, France, November
          <volume>13</volume>
          ,
          <year>2018</year>
          , volume
          <volume>2306</volume>
          <source>of CEUR Workshop Proceedings, CEUR-WS.org</source>
          ,
          <year>2018</year>
          . URL: https://ceur-ws.
          <source>org/</source>
          Vol-
          <volume>2306</volume>
          /paper8.pdf.
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>J.</given-names>
            <surname>David</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Euzenat</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F.</given-names>
            <surname>Scharfe</surname>
          </string-name>
          , C. T. dos Santos,
          <source>The alignment API 4</source>
          .0,
          <string-name>
            <surname>Semantic</surname>
            <given-names>Web</given-names>
          </string-name>
          2 (
          <year>2011</year>
          )
          <fpage>3</fpage>
          -
          <lpage>10</lpage>
          . URL: https://doi.org/10.3233/SW-2011-0028. doi:
          <volume>10</volume>
          .3233/SW-2011-0028.
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <surname>T. B. Brown</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          <string-name>
            <surname>Mann</surname>
            ,
            <given-names>N.</given-names>
          </string-name>
          <string-name>
            <surname>Ryder</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          <string-name>
            <surname>Subbiah</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          <string-name>
            <surname>Kaplan</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          <string-name>
            <surname>Dhariwal</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          <string-name>
            <surname>Neelakantan</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          <string-name>
            <surname>Shyam</surname>
            ,
            <given-names>G.</given-names>
          </string-name>
          <string-name>
            <surname>Sastry</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          <string-name>
            <surname>Askell</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          <string-name>
            <surname>Agarwal</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          <string-name>
            <surname>Herbert-Voss</surname>
            , G. Krueger,
            <given-names>T.</given-names>
          </string-name>
          <string-name>
            <surname>Henighan</surname>
            ,
            <given-names>R.</given-names>
          </string-name>
          <string-name>
            <surname>Child</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          <string-name>
            <surname>Ramesh</surname>
            ,
            <given-names>D. M.</given-names>
          </string-name>
          <string-name>
            <surname>Ziegler</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          <string-name>
            <surname>Wu</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          <string-name>
            <surname>Winter</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          <string-name>
            <surname>Hesse</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          <string-name>
            <surname>Chen</surname>
            , E. Sigler,
            <given-names>M.</given-names>
          </string-name>
          <string-name>
            <surname>Litwin</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          <string-name>
            <surname>Gray</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          <string-name>
            <surname>Chess</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          <string-name>
            <surname>Clark</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          <string-name>
            <surname>Berner</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          <string-name>
            <surname>McCandlish</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          <string-name>
            <surname>Radford</surname>
            ,
            <given-names>I.</given-names>
          </string-name>
          <string-name>
            <surname>Sutskever</surname>
            ,
            <given-names>D.</given-names>
          </string-name>
          <string-name>
            <surname>Amodei</surname>
          </string-name>
          ,
          <article-title>Language models are few-shot learners</article-title>
          , in: H.
          <string-name>
            <surname>Larochelle</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          <string-name>
            <surname>Ranzato</surname>
            ,
            <given-names>R.</given-names>
          </string-name>
          <string-name>
            <surname>Hadsell</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          <string-name>
            <surname>Balcan</surname>
          </string-name>
          , H. Lin (Eds.),
          <source>Advances in Neural Information Processing Systems 33: Annual Conference on Neural Information Processing Systems</source>
          <year>2020</year>
          ,
          <article-title>NeurIPS 2020</article-title>
          , December 6-
          <issue>12</issue>
          ,
          <year>2020</year>
          , virtual,
          <year>2020</year>
          . URL: https://proceedings.neurips.cc/paper/ 2020/hash/1457c0d6bfcb4967418bfb8ac142f64a-Abstract.html.
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>É.</given-names>
            <surname>Thiéblin</surname>
          </string-name>
          ,
          <article-title>Automatic Generation of Complex Ontology Alignments. (Génération automatique d'alignements complexes d'ontologies)</article-title>
          ,
          <source>Ph.D. thesis</source>
          , Paul Sabatier University, Toulouse, France,
          <year>2019</year>
          . URL: https://tel.archives-ouvertes.fr/tel-02735724.
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <given-names>M.</given-names>
            <surname>Bianchini</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Gori</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F.</given-names>
            <surname>Scarselli</surname>
          </string-name>
          ,
          <article-title>Inside pagerank</article-title>
          ,
          <source>ACM Trans. Internet Techn</source>
          .
          <volume>5</volume>
          (
          <year>2005</year>
          )
          <fpage>92</fpage>
          -
          <lpage>128</lpage>
          . URL: https://doi.org/10.1145/1052934.1052938. doi:
          <volume>10</volume>
          .1145/1052934.1052938.
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8]
          <string-name>
            <given-names>F.</given-names>
            <surname>Schneider</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Dash</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Bagchi</surname>
          </string-name>
          ,
          <string-name>
            <given-names>N.</given-names>
            <surname>Mihindukulasooriya</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A. M.</given-names>
            <surname>Gliozzo</surname>
          </string-name>
          ,
          <article-title>NLFOA: natural language focused ontology alignment</article-title>
          , in: K. B.
          <string-name>
            <surname>Venable</surname>
            ,
            <given-names>D.</given-names>
          </string-name>
          <string-name>
            <surname>Garijo</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          Jalaian (Eds.),
          <source>Proceedings of the 12th Knowledge Capture Conference</source>
          <year>2023</year>
          ,
          <string-name>
            <surname>K-CAP</surname>
          </string-name>
          <year>2023</year>
          ,
          <article-title>Pensacola</article-title>
          , FL, USA, December 5-
          <issue>7</issue>
          ,
          <year>2023</year>
          , ACM,
          <year>2023</year>
          , pp.
          <fpage>114</fpage>
          -
          <lpage>121</lpage>
          . URL: https://doi.org/10.1145/3587259.3627560. doi:
          <volume>10</volume>
          .1145/3587259. 3627560.
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          [9]
          <string-name>
            <given-names>J.</given-names>
            <surname>Guo</surname>
          </string-name>
          ,
          <string-name>
            <given-names>L.</given-names>
            <surname>Du</surname>
          </string-name>
          , H. Liu, Gpt4graph:
          <article-title>Can large language models understand graph structured data ? an empirical evaluation and benchmarking</article-title>
          ,
          <source>CoRR abs/2305</source>
          .15066 (
          <year>2023</year>
          ). URL: https: //doi.org/10.48550/arXiv.2305.15066. doi:
          <volume>10</volume>
          .48550/ARXIV.2305.15066. arXiv:
          <volume>2305</volume>
          .
          <fpage>15066</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          [10]
          <string-name>
            <given-names>J.</given-names>
            <surname>Zhao</surname>
          </string-name>
          ,
          <string-name>
            <given-names>L.</given-names>
            <surname>Zhuo</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Y.</given-names>
            <surname>Shen</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Qu</surname>
          </string-name>
          , K. Liu,
          <string-name>
            <given-names>M. M.</given-names>
            <surname>Bronstein</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Z.</given-names>
            <surname>Zhu</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Tang</surname>
          </string-name>
          , Graphtext:
          <article-title>Graph reasoning in text space</article-title>
          ,
          <source>CoRR abs/2310</source>
          .01089 (
          <year>2023</year>
          ). URL: https://doi.org/10.48550/arXiv.2310. 01089. doi:
          <volume>10</volume>
          .48550/ARXIV.2310.01089. arXiv:
          <volume>2310</volume>
          .
          <fpage>01089</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          [11]
          <string-name>
            <given-names>B.</given-names>
            <surname>Fatemi</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Halcrow</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B.</given-names>
            <surname>Perozzi</surname>
          </string-name>
          ,
          <article-title>Talk like a graph: Encoding graphs for large language models</article-title>
          ,
          <source>CoRR abs/2310</source>
          .04560 (
          <year>2023</year>
          ). URL: https://doi.org/10.48550/arXiv.2310.04560. doi:
          <volume>10</volume>
          .48550/ ARXIV.2310.04560. arXiv:
          <volume>2310</volume>
          .
          <fpage>04560</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          [12]
          <string-name>
            <given-names>Y.</given-names>
            <surname>Gao</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Y.</given-names>
            <surname>Xiong</surname>
          </string-name>
          ,
          <string-name>
            <given-names>X.</given-names>
            <surname>Gao</surname>
          </string-name>
          ,
          <string-name>
            <given-names>K.</given-names>
            <surname>Jia</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Pan</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Y.</given-names>
            <surname>Bi</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Y.</given-names>
            <surname>Dai</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Sun</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Q.</given-names>
            <surname>Guo</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Wang</surname>
          </string-name>
          ,
          <string-name>
            <given-names>H.</given-names>
            <surname>Wang</surname>
          </string-name>
          ,
          <article-title>Retrieval-augmented generation for large language models: A survey</article-title>
          ,
          <source>CoRR abs/2312</source>
          .10997 (
          <year>2023</year>
          ). URL: https://doi.org/10.48550/arXiv.2312.10997. doi:
          <volume>10</volume>
          .48550/ARXIV. 2312.10997. arXiv:
          <volume>2312</volume>
          .
          <fpage>10997</fpage>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>