<!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>Using Knowledge Graphs and Agentic LLMs for Factuality Text Assessment and Improvement</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Linda Kwan</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Pouya G. Omran</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Kerry Taylor</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Australian National University</institution>
          ,
          <addr-line>Canberra ACT 2601, AU</addr-line>
        </aff>
      </contrib-group>
      <abstract>
        <p>This paper addresses the challenge of assessing and enhancing the factual accuracy of texts generated by large language models (LLMs). Existing methods often rely on self-reflection or external knowledge sources, validating statements individually and rigidly, thus missing a holistic view. We propose a novel approach utilizing a comprehensive knowledge graph (KG), such as Wikidata, to assess and improve the factuality of generated texts. Our method dynamically retrieves and integrates relevant facts during the assessment process, providing a more interconnected and accurate evaluation. Integrating KG with LLM capabilities enhances the overall factual integrity, leading to more reliable AI-generated content. Our results demonstrate improvements in factual accuracy, highlighting the efectiveness of our approach. Submission type: Poster</p>
      </abstract>
      <kwd-group>
        <kwd>eol&gt;Knowledge Graph</kwd>
        <kwd>Large Language Model</kwd>
        <kwd>Agentic LLM</kwd>
        <kwd>LLM Evaluation</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1. Introduction and Background</title>
      <p>
        The rapid advancements in large language models (LLMs) have transformed natural language
processing, enabling these models to understand and generate human-like text with remarkable
accuracy. Despite their impressive capabilities, assessing and enhancing the factual accuracy
of texts produced by LLMs remains a significant challenge. Texts generated by these models,
including popular applications like ChatGPT, can contain inaccuracies and misinformation,
posing risks to users who might accept generated content as factual without verification. This
problem underscores the need for robust methods to assess and improve the factuality of texts
produced by generative models. Existing approaches to address this issue rely on either LLMs’
self-reflection or external knowledge sources like knowledge graphs (KGs)[
        <xref ref-type="bibr" rid="ref1 ref10 ref2 ref3 ref4 ref5 ref6 ref7 ref8 ref9">1, 2, 3, 4, 5, 6, 7, 8, 9,
10</xref>
        ]. Self-reflection is restrictive as it lacks an ultimate source of truth and depends on the LLMs’
inherent knowledge. External knowledge methods validate individual statements, which limits
their efectiveness due to a local perspective and rigid matching processes during the entity
linking or predicate alignment phase.
      </p>
      <p>
        To overcome these limitations, we propose a novel approach using a comprehensive
knowledge graph, such as Wikidata [
        <xref ref-type="bibr" rid="ref11">11</xref>
        ], to assess and enhance the factual accuracy of texts generated
by LLMs. The enhancer agent integrates a general-purpose KG with LLM capabilities for
named entity recognition and fact extraction, using an LLM encoder and vectorization for soft
alignment between text and KG facts, and then uses the relevant extracted facts to improve
the original text. This process improves the factual accuracy of texts, including human and
LLM-generated texts, ensuring they align with verified facts and real-world knowledge. The key
contributions are: i. Integration of a general-purpose KG with LLMs for enhanced fact-checking.
ii. Use of soft matching mechanisms based on LLM encoder for better text and KG fact
alignment. iii. Development of a dynamic and iterative process for continuous text assessment and
improvement.
      </p>
    </sec>
    <sec id="sec-2">
      <title>2. Factum Graph Enhancer</title>
      <p>
        Our proposed system, Factum Graph Enhancer (Fig. 1), begins its process after the initial
response to a user query is generated by the Gemma LLM [
        <xref ref-type="bibr" rid="ref12">12</xref>
        ]. While the generation of
the initial response is not part of our system, our diagram starts from this point. The initial
response is assessed against a knowledge graph, such as Wikidata, through entity recognition
and relation extraction to identify relevant entities and link them to their corresponding URIs.
Using embedding similarity, we approximate the factual accuracy of these extracted facts by
comparing them with triples retrieved from the KG. Following the assessment, relevant facts
from the KG are selected and used to enrich the original response. This enriched response is
then returned to the user, ensuring improved factual accuracy and relevance through evaluation
and enhancement stages. Fig. 2 demonstrates an example of how an LLM-generated response
can be enriched.
      </p>
      <p>
        Evaluating Text Based on the Knowledge Graph: We leverage Gemma LLM decoder [
        <xref ref-type="bibr" rid="ref12">12</xref>
        ]
to extract entities from the initial response due to the zero-shot learning prompt. We use prompt
engineering to extract entities from the text in the Python list format to achieve this. Using
the extracted entities, we then leverage Gemma LLM to extract (subject, predicate, object)
triples from the original response in markdown table format. We utilize the Wikidata REST
API [
        <xref ref-type="bibr" rid="ref13">13</xref>
        ] to fetch the URI for each entity that appears as a subject in one of the extracted triples.
Next, we use the Wikidata knowledge base to evaluate the degree of truthfulness of each fact
extracted from the response by a soft matching mechanism. For each triple (, , ) ∈ 
extracted from the text, we perform a SPARQL query to retrieve triples with  in the subject
position. We call this set (). To reduce the complexity of selecting the most relevant triple,
we first take the cosine similarity between the Sentence-BERT [
        <xref ref-type="bibr" rid="ref14">14</xref>
        ] embeddings of  and the
predicate in each triple retrieved from the SPARQL query and select the three predicates from
the retrieved set that produce the highest cosine similarity scores. We filter SPARQL results to
the set of triples containing one of the top three predicates, then calculate the cosine similarity
between the concatenated  and  string and the corresponding predicate and object string
for each retrieved triple (, , ). We take the highest of those cosine similarity values as
the evaluation score of the extracted triple and also take the corresponding retrieved fact to be
used for correction. To calculate the Factuality Degree (FD) for the entire response, we sum the
| |
  =
evaluation scores of the extracted triples and divide them by the number of facts extracted.
∑︀(,,)∈ max(,,)∈() sim(emb(concat(, )), emb(concat(, )))
(1)
      </p>
      <p>Enhancing the LLM output using LLM and relevant facts from the KG: We enhance
the LLM output by considering entities involved in the selected facts from the previous section,
which have the highest similarity, along with other linked entities in the text. We construct
a set of linked entities from Wikidata and use SPARQL to retrieve all facts in Wikidata that
have these entities as their subjects. This extensive set of retrieved facts forms our fetched
KG, which we filter using a two-stage method. First, we consider all predicates in the fetched
KG and find the similarity between each predicate and the vector representation of the entire
original text, selecting the top  predicates. We then prune the KG to keep only the facts with
these selected predicates. In the second stage, we calculate the cosine similarity between the
vector representation of each fact (as a textual statement) and the original text, selecting the top
 facts, in our experiment  = 5 and  = 5. Using cosine similarity to compare each retrieved
KG fact and the original text ensures that less interesting KG facts would produce lower cosine
similarity scores and get filtered out. Finally, we prompt our LLM decoder to use these selected
facts to enrich the original text if they are relevant and helpful.</p>
    </sec>
    <sec id="sec-3">
      <title>3. Experiments and Conclusion</title>
      <p>
        A GitHub repository for this experiment is available1. For our experiments, we used a set of 35
questions from the WikiQA dataset [
        <xref ref-type="bibr" rid="ref15">15</xref>
        ]. We generated initial responses using Gemma LLM,
assessed their factual accuracy, enriched the responses with relevant facts from a knowledge
graph, and then reassessed them. The results showed an improvement in factual accuracy when
using our Factum Graph Enhancer framework, with the FD score increasing from 0.260 with
pure Gemma to 0.326 with Factum.
      </p>
      <p>For example, in Fig. 2, the initial LLM response to the query "Where is Loxahatchee FL at?"
includes the country (United States) and the region (Gulf Coast) Loxahatchee is located in. When
the relevant KG facts were retrieved during the first evaluation stage, a relationship between
Loxahatchee and Palm Beach County was identified. Hence, Palm Beach County was included in
the extended entity set, allowing the triple (Loxahatchee, located in the administrative territorial
entity, Palm Beach County) to be included in the enrichment set. The additional triples and the
original response are then fed to the LLM to generate the enriching response. Consequently, the
enriching LLM response includes the county Loxahatchee is located in (Palm Beach County), in
addition to the existing information from the original response. This process demonstrates the
efectiveness of our framework in enhancing the factual accuracy of LLM-generated text.</p>
      <p>This enhancement underscores the potential of integrating knowledge graphs with LLMs to
create more reliable and accurate AI-generated content. Future work will focus on expanding
the dataset to include various questions and domains. Additionally, we plan to investigate the
integration of other knowledge bases and vectorization methods, and the application of this
framework in real-world scenarios to validate its efectiveness and scalability.
1https://github.com/lindakwan/factum-graph-enhancer
on Empirical Methods in Natural Language Processing, Association for Computational
Linguistics, Lisbon, Portugal, 2015, pp. 2013–2018. URL: https://aclanthology.org/D15-1237.
doi:10.18653/v1/D15-1237.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>P.</given-names>
            <surname>Pezeshkpour</surname>
          </string-name>
          ,
          <article-title>Measuring and modifying factual knowledge in large language models</article-title>
          ,
          <source>in: 2023 International Conference on Machine Learning and Applications (ICMLA)</source>
          , IEEE,
          <year>2023</year>
          , pp.
          <fpage>831</fpage>
          -
          <lpage>838</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>X.-Y.</given-names>
            <surname>Fu</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M. T. R.</given-names>
            <surname>Laskar</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Chen</surname>
          </string-name>
          ,
          <string-name>
            <surname>S. B. TN</surname>
          </string-name>
          ,
          <article-title>Are large language models reliable judges? a study on the factuality evaluation capabilities of llms</article-title>
          ,
          <source>arXiv preprint arXiv:2311.00681</source>
          (
          <year>2023</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>N.</given-names>
            <surname>Lee</surname>
          </string-name>
          ,
          <string-name>
            <given-names>W.</given-names>
            <surname>Ping</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P.</given-names>
            <surname>Xu</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Patwary</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P. N.</given-names>
            <surname>Fung</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Shoeybi</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B.</given-names>
            <surname>Catanzaro</surname>
          </string-name>
          ,
          <article-title>Factuality enhanced language models for open-ended text generation</article-title>
          ,
          <source>Advances in Neural Information Processing Systems</source>
          <volume>35</volume>
          (
          <year>2022</year>
          )
          <fpage>34586</fpage>
          -
          <lpage>34599</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>F. F.</given-names>
            <surname>Bayat</surname>
          </string-name>
          ,
          <string-name>
            <given-names>K.</given-names>
            <surname>Qian</surname>
          </string-name>
          , B. Han,
          <string-name>
            <given-names>Y.</given-names>
            <surname>Sang</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Belyi</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Khorshidi</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F.</given-names>
            <surname>Wu</surname>
          </string-name>
          ,
          <string-name>
            <given-names>I. F.</given-names>
            <surname>Ilyas</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Y.</given-names>
            <surname>Li</surname>
          </string-name>
          ,
          <article-title>FLEEK: Factual Error Detection and Correction with Evidence Retrieved from External Knowledge</article-title>
          , arXiv
          <string-name>
            <surname>Preprint</surname>
          </string-name>
          (
          <year>2023</year>
          ). URL: https://platform.openai.com/docs/modelshttp: //arxiv.org/abs/2310.17119. arXiv:
          <volume>2310</volume>
          .
          <fpage>17119</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>C.</given-names>
            <surname>Mavromatis</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P.</given-names>
            <surname>Karypis</surname>
          </string-name>
          , G. Karypis, SemPool: Simple, robust, and
          <article-title>interpretable KG pooling for enhancing language models</article-title>
          ,
          <source>arXiv Preprint</source>
          (
          <year>2024</year>
          ). URL: https://arxiv.org/abs/ 2402.02289v1http://arxiv.org/abs/2402.02289. arXiv:
          <volume>2402</volume>
          .
          <fpage>02289</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>E. C.</given-names>
            <surname>Choi</surname>
          </string-name>
          , E. Ferrara, FACT-GPT:
          <article-title>Fact-Checking Augmentation via Claim Matching with LLMs</article-title>
          , in: WebConf, volume
          <volume>1</volume>
          ,
          <year>2024</year>
          . URL: https://arxiv.org/abs/2402.05904v1. doi:XXXXXXX. XXXXXXX. arXiv:
          <volume>2402</volume>
          .
          <fpage>05904</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <given-names>Z.</given-names>
            <surname>Yuan</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Vlachos</surname>
          </string-name>
          ,
          <article-title>Zero-Shot Fact-Checking with Semantic Triples and Knowledge Graphs, arXiv preprint (</article-title>
          <year>2023</year>
          ). arXiv:
          <volume>2312</volume>
          .
          <year>11785v1</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8]
          <string-name>
            <given-names>L.</given-names>
            <surname>Pan</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Saxon</surname>
          </string-name>
          ,
          <string-name>
            <given-names>W.</given-names>
            <surname>Xu</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Nathani</surname>
          </string-name>
          ,
          <string-name>
            <given-names>X.</given-names>
            <surname>Wang</surname>
          </string-name>
          ,
          <string-name>
            <given-names>W. Y.</given-names>
            <surname>Wang</surname>
          </string-name>
          ,
          <article-title>Automatically Correcting Large Language Models: Surveying the landscape of diverse self-correction strategies, arXiv preprint (</article-title>
          <year>2023</year>
          ). arXiv:
          <volume>2308</volume>
          .
          <year>03188v1</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          [9]
          <string-name>
            <given-names>J.</given-names>
            <surname>Liu</surname>
          </string-name>
          ,
          <string-name>
            <given-names>W.</given-names>
            <surname>Wang</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Wang</surname>
          </string-name>
          ,
          <string-name>
            <given-names>N. A.</given-names>
            <surname>Smith</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Y.</given-names>
            <surname>Choi</surname>
          </string-name>
          ,
          <string-name>
            <given-names>H.</given-names>
            <surname>Hajishirzi</surname>
          </string-name>
          ,
          <string-name>
            <surname>P. G.</surname>
          </string-name>
          <article-title>Allen, VERA: A GeneralPurpose Plausibility Estimation Model for Commonsense Statements</article-title>
          , arXiv preprint (
          <year>2023</year>
          ). URL: https://huggingface.co/liujch1998/vera. arXiv:
          <volume>2305</volume>
          .
          <year>03695v1</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          [10]
          <string-name>
            <given-names>R. L.</given-names>
            <surname>Logan</surname>
          </string-name>
          ,
          <string-name>
            <given-names>N. F.</given-names>
            <surname>Liu</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M. E.</given-names>
            <surname>Peters</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Gardner</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Singh</surname>
          </string-name>
          ,
          <article-title>Barack's Wife Hillary: Using Knowledge-Graphs for Fact-Aware Language Modeling</article-title>
          , in: ACL,
          <article-title>Association for Computational Linguistics (ACL</article-title>
          ),
          <year>2019</year>
          , pp.
          <fpage>5962</fpage>
          -
          <lpage>5971</lpage>
          . URL: https://arxiv.org/abs/
          <year>1906</year>
          .07241v2. doi:
          <volume>10</volume>
          .48550/arxiv.
          <year>1906</year>
          .
          <volume>07241</volume>
          . arXiv:
          <year>1906</year>
          .07241.
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          [11]
          <string-name>
            <given-names>D.</given-names>
            <surname>Vrandečić</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Krötzsch</surname>
          </string-name>
          ,
          <article-title>Wikidata: a free collaborative knowledgebase</article-title>
          ,
          <source>Commun. ACM</source>
          <volume>57</volume>
          (
          <year>2014</year>
          )
          <fpage>78</fpage>
          -
          <lpage>85</lpage>
          . URL: https://doi.org/10.1145/2629489. doi:
          <volume>10</volume>
          .1145/2629489.
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          [12]
          <string-name>
            <given-names>T.</given-names>
            <surname>Mesnard</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Hardin</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Dadashi</surname>
          </string-name>
          , et al.,
          <source>Gemma: Open models based on gemini research and technology</source>
          ,
          <year>2024</year>
          . URL: https://arxiv.org/abs/2403.08295. arXiv:
          <volume>2403</volume>
          .
          <fpage>08295</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref13">
        <mixed-citation>
          [13]
          <string-name>
            <surname>Wikidata:REST API - Wikidata</surname>
          </string-name>
          ,
          <year>2024</year>
          . URL: https://www.wikidata.org/wiki/Wikidata:REST_ API.
        </mixed-citation>
      </ref>
      <ref id="ref14">
        <mixed-citation>
          [14]
          <string-name>
            <given-names>N.</given-names>
            <surname>Reimers</surname>
          </string-name>
          ,
          <string-name>
            <surname>I. Gurevych</surname>
          </string-name>
          ,
          <article-title>Sentence-bert: Sentence embeddings using siamese bert-networks</article-title>
          ,
          <source>in: Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing, Association for Computational Linguistics</source>
          ,
          <year>2019</year>
          . URL: https://arxiv.org/abs/
          <year>1908</year>
          .10084.
        </mixed-citation>
      </ref>
      <ref id="ref15">
        <mixed-citation>
          [15]
          <string-name>
            <given-names>Y.</given-names>
            <surname>Yang</surname>
          </string-name>
          , W.-t. Yih, C. Meek,
          <article-title>WikiQA: A challenge dataset for open-domain question answering</article-title>
          , in: L.
          <string-name>
            <surname>Màrquez</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          <string-name>
            <surname>Callison-Burch</surname>
          </string-name>
          , J. Su (Eds.),
          <source>Proceedings of the 2015 Conference</source>
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>