<?xml version="1.0" encoding="UTF-8"?>
<TEI xml:space="preserve" xmlns="http://www.tei-c.org/ns/1.0" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://www.tei-c.org/ns/1.0 https://raw.githubusercontent.com/kermitt2/grobid/master/grobid-home/schemas/xsd/Grobid.xsd"
 xmlns:xlink="http://www.w3.org/1999/xlink">
	<teiHeader xml:lang="en">
		<fileDesc>
			<titleStmt>
				<title level="a" type="main">KGC-RAG: Knowledge Graph Construction from Large Language Model Using Retrieval-Augmented Generation</title>
			</titleStmt>
			<publicationStmt>
				<publisher/>
				<availability status="unknown"><licence/></availability>
			</publicationStmt>
			<sourceDesc>
				<biblStruct>
					<analytic>
						<author>
							<persName><forename type="first">Thin</forename><surname>Prabhong</surname></persName>
							<affiliation key="aff0">
								<orgName type="institution">Chiang Mai University</orgName>
								<address>
									<settlement>Chiang Mai</settlement>
									<country key="TH">Thailand</country>
								</address>
							</affiliation>
						</author>
						<author>
							<persName><forename type="first">Natthawut</forename><surname>Kertkeidkachorn</surname></persName>
							<affiliation key="aff1">
								<orgName type="institution">Japan Advanced Institute of Science and Technology</orgName>
								<address>
									<settlement>Ishikawa</settlement>
									<country key="JP">Japan</country>
								</address>
							</affiliation>
						</author>
						<author>
							<persName><forename type="first">Areerat</forename><surname>Trongratsameethong</surname></persName>
							<affiliation key="aff0">
								<orgName type="institution">Chiang Mai University</orgName>
								<address>
									<settlement>Chiang Mai</settlement>
									<country key="TH">Thailand</country>
								</address>
							</affiliation>
						</author>
						<title level="a" type="main">KGC-RAG: Knowledge Graph Construction from Large Language Model Using Retrieval-Augmented Generation</title>
					</analytic>
					<monogr>
						<idno type="ISSN">1613-0073</idno>
					</monogr>
					<idno type="MD5">6B97C3AD2A6D924476261DE543EB7253</idno>
				</biblStruct>
			</sourceDesc>
		</fileDesc>
		<encodingDesc>
			<appInfo>
				<application version="0.7.2" ident="GROBID" when="2025-04-23T19:21+0000">
					<desc>GROBID - A machine learning software for extracting information from scholarly documents</desc>
					<ref target="https://github.com/kermitt2/grobid"/>
				</application>
			</appInfo>
		</encodingDesc>
		<profileDesc>
			<abstract>
<div xmlns="http://www.tei-c.org/ns/1.0"><p>The construction of Knowledge Graphs (KGs) has become increasingly important due to their ability to integrate and represent complex relationships across various domains, making them essential for applications like information retrieval and semantic search. Recently, Large Language Models (LLMs) have been utilized to enhance KGs creation by leveraging their advanced capabilities in understanding and generating human-like text. The Large Language Models for Knowledge Engineering (LLMKE) pipeline was introduced to combine knowledge probing with Wikidata entity mapping for knowledge engineering. Nevertheless, this approach has a limitation: it primarily relies on retrieval-augmented context drawn from the first paragraph and Wikipedia Infobox of the subject entity's page. This narrow focus can lead to incomplete knowledge representations, as relevant information is often spread throughout the text and linked pages. To address this issue, we propose the Knowledge Graph Construction from Large Language Model using Retrieval-Augmented Generation method (KGC-RAG). This method leverages web scraping to retrieve documents from the subject entity's Wikipedia page and to extend the search to include linked pages, thereby increasing the likelihood of capturing comprehensive and contextually rich information. We further enhance this approach by using LLMs in conjunction with cosine similarity to filter out irrelevant content, ensuring that only the most pertinent data are included in the relevant contexts. We conducted an experiment on datasets from ISWC 2024 LM-KBC Challenge and applied the meta-llama/Meta-Llama-3-8B-Instruct model as our pre-trained large language model along with the all-MiniLM-L6-v2 as our vector embedding model. We set a relevant score threshold of 0.5 to filter Wikipedia URLs. Our approach achieved macro average F1-scores of 0.695 and 0.698 on the validation and test sets, respectively. The implementation is available at https://github.com/jaejeajay/LM-KBC2024.</p></div>
			</abstract>
		</profileDesc>
	</teiHeader>
	<text xml:lang="en">
		<body>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="1.">Introduction</head><p>Knowledge graphs <ref type="bibr" target="#b0">[1]</ref> store information in a Subject-Predicate-Object format, providing more efficient semantic data storage compared to relational database. They are more easily understood by computers, offering flexibility and the ability to integrate diverse information, making them crucial for applications such as question answering and recommendation systems. A notable example of a significant knowledge graph repository is Wikidata <ref type="bibr" target="#b1">[2]</ref>, an open-source platform by the Wikimedia Foundation for storing factual data about the world.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>KBC-LM'24: Knowledge Base Construction from Pre-trained Language Models workshop at ISWC 2024</head><p>Envelope thin.pra2013@gmail.com (T. Prabhong); natt@jaist.ac.jp (N. Kertkeidkachorn); areerat.t@cmu.ac.th (A. Trongratsameethong) GLOBE https://github.com/jaejeajay/LM-KBC2024 (T. Prabhong) Constructing knowledge graphs (KGs) is highly challenging <ref type="bibr" target="#b2">[3]</ref> due to the need for access to vast and diverse information sources. Large Language Models (LLMs) are gaining popularity for their ability to perform a wide range of tasks, such as answering questions, providing information, translating languages, and engaging in conversations. Since LLMs are trained on extensive datasets, they serve as comprehensive repositories of knowledge. Extracting knowledge from LLMs can yield valuable information for various applications, including the construction of knowledge graphs, where LLMs can provide foundational data and relationships needed for building these complex structures.</p><p>However, challenges in extracting knowledge from LLMs <ref type="bibr" target="#b3">[4]</ref> include the generation of fabricated answers and outdated information. Over time, facts can change or be disproven, but the data used to train LLMs remain factual only as of the time of training. Thus, optimizing LLMs for accurate and reliable responses is crucial.</p><p>Retrieval-Augmented Generation (RAG) <ref type="bibr" target="#b4">[5]</ref> offers an effective solution to these challenges. By combining retrieval and generation processes, RAG enhances the accuracy of LLM outputs by retrieving up-to-date information from external databases or sources, thereby providing the necessary context for generating more factual and reliable responses.</p><p>In this study, we explore the construction of knowledge graphs using knowledge extracted from LLMs. We optimize LLM performance with RAG by improving the quality of relevant context through web scraping and web crawling. The relevance score is determined by the path names in the Wikipedia URLs. We utilized datasets from the ISWC 2024 LM-KBC Challenge <ref type="bibr" target="#b5">[6]</ref>, where the task limited LLM parameters to 10B. We selected the Llama-3-8B-Instruct model for our study, and the results demonstrate that our approach outperforms the baseline.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="2.">Related Works</head></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="2.1.">Using Large Language Models for Knowledge Engineering (LLMKE): A Case Study on Wikidata</head><p>In recent research, Zhang et al. <ref type="bibr" target="#b6">[7]</ref> explored the use of LLMs for knowledge engineering tasks within the context of the ISWC 2023 LM-KBC Challenge. They utilized pre-trained LLMs to generate relevant objects in string format from given subject-relation pairs sourced from Wikidata, subsequently linking these objects to their respective Wikidata QIDs. The developed pipeline, known as Large Language Models for Knowledge Engineering (LLMKE), combines knowledge probing with Wikidata entity mapping and incorporates retrieval-augmented context to enhance predictions. This context is derived from external sources, such as Wikipedia, to refine the model's responses by comparing and integrating this information with the model's initial predictions. Nonetheless, LLMKE operates under the assumption that the most relevant documents are primarily found in the first paragraph (Introduction) and the Wikipedia Infobox, which may not always be the case, as related information can be dispersed throughout various sections.</p><p>To address this limitation, we propose a method to enhance content extraction from Wikipedia by employing web scraping techniques to gather information from paragraphs, Infoboxes, and Wikitables on the Wikipedia page of the subject entity. Also, this approach extends the search to other linked Wikipedia pages, thereby capturing more comprehensive and relevant information.</p><p>One challenge of extending the search beyond the subject entity's Wikipedia page is the increased volume of documents, which can slow down the process. To mitigate this, we implemented a solution using LLM and cosine similarity scores to filter and prioritize relevant Wikipedia pages and documents, ensuring efficient and effective information retrieval.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="2.2.">Retrieval-Augmented Generation for Large Language Models</head><p>Yunfan Gao et al. <ref type="bibr" target="#b7">[8]</ref> reviewed the RAG paradigm, categorizing it into three types: Naïve, Advanced, and Modular RAG. Naïve RAG involves a simple two-phase process of retrieving documents and generating responses based on them. Advanced RAG improves this by optimizing query modification and refining the retrieved context for better LLM performance. Modular RAG further breaks down the process into independent modules, allowing easier updates but requiring more resources for development.</p><p>This study focuses on utilizing the Naïve RAG process to explore its application in constructing knowledge graphs through knowledge extraction from LLMs, using the ISWC 2024 LM-KBC Challenge dataset <ref type="bibr" target="#b5">[6]</ref>. The research integrates LLMs into the retrieval stage to aid in filtering relevant documents from web scraping, rather than limiting their role to the generation phase. Given that LLMs are trained on vast knowledge, the hypothesis is that incorporating them in the Retrieval process may outperform using relevance scores alone.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3.">Methods</head><p>The Knowledge Graph Construction from Large Language Model using Retrieval-Augmented Generation method (KBC-RAG) provides an overview as shown in Figure <ref type="figure">1</ref>. This method is composed of two processes: RAG and Entity Mapping. In the RAG process, relevant contexts are identified and used to enhance the LLM's knowledge extraction. In the entity mapping process, the answers from the LLM are used to construct knowledge graphs by mapping through API functions from Wikidata, resulting in completed knowledge tuples. The details of each process are as follows:</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3.1.">Retrieval-Augmented Generation (RAG)</head><p>The overview of RAG process is presented in Figure <ref type="figure">2</ref>. The goal of this process is to extract knowledge from LLM using RAG as an LLM optimization method. The outcome of this process will be LLM-generated answers, which will then be used for subsequent entity mapping process.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3.1.1.">Entity ID Query</head><p>The entity ID query step involves locating the Wikipedia URLs of the subject entities using the provided SubjectEntityID, which is essential for the web scraping process. The SubjectEntityID is used to search for the URLs in Wikidata through an API called SPARQLWrapper<ref type="foot" target="#foot_0">1</ref> , with a preference for English URLs. The outcome of this step is the subject entity's Wikipedia URL, which is used to access the subject entity's Wikipedia page, referred to as the main page in this study. For example, if SubjectEntity is "Uruguay", SubjectEntityID is "Q77", and relation is "countryLandBordersCountry", after using SubjectEntityID to search via SPARQLWrapper, the resulting Wikipedia URL for SubjectEntity would be https://en.wikipedia.org/wiki/Uruguay.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3.1.2.">Web Scraping</head><p>In web scraping step, the focus is on scraping data from the Wikipedia pages. The data targeted for scraping includes three tags: p (Paragraph), Infobox, and Wikitable. The outputs of this step are the scraped data from Wikipedia, which will later be assessed for relevance in the relevant identification step.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>Table 1</head><p>Templates of Prompt for web scraping</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>Relation</head><p>Prompt for web scraping awardWonBy "Who has won " + SubjectEntity + " ?" companyTradesAtStockExchange "Which stock exchange does " + SubjectEntity + " trade on ?" countryLandBordersCountry "Which country share land border with " + SubjectEntity + " ?" personHasCityOfDeath "What is the city of death of " + SubjectEntity + " ?" seriesHasNumberOfEpisodes "How many episodes does series " + SubjectEntity + " has ?"</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3.1.3.">Web Crawling</head><p>The web crawling step is designed to broaden the scope of web scraping by extending the search from the main page to other linked Wikipedia pages, thereby increasing the chances of identifying relevant context. This is achieved by identifying &lt;a&gt; tags within the main page. The result of this step is a collection of linked Wikipedia URLs linked to the main page. For example, from the Wikipedia page of the SubjectEntity "Uruguay" at https://en.wikipedia. org/wiki/Uruguay, examples of linked Wikipedia pages include https://en.wikipedia.org/wiki/ Economy_of_Uruguay, https://en.wikipedia.org/wiki/Religion_in_Uruguay, and so on.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3.1.4.">Relevant Scoring</head><p>The primary aim of relevant scoring step is to filter out unnecessary linked URLs from the web crawling process by using a Relevant score, calculated via cosine similarity. This approach helps streamline the RAG process. The filtering method involves calculating the cosine similarity between the path name of each URL linked to the main page and the Prompt for web scraping, utilizing the vector model all-MiniLM-L6-v2. The templates of the prompt for web scraping are shown in Table <ref type="table">1</ref>. For instance, from the URL https://en.wikipedia.org/wiki/Economy_of_ Uruguay, only the part "Economy of Uruguay" is used to calculate the Relevant Score. URLs with a cosine similarity score above the threshold are selected for web scraping. The outcome of this step is a refined list of linked URLs for web scraping.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3.1.5.">Relevant Identification</head><p>The relevant identification step focuses on filtering scraped data from Wikipedia by leveraging LLM responses to specific questions. The result is a list of relevant documents, which will be used in the subsequent step for determining the relevant score. We begin by filtering each paragraph, Infobox, and Wikitable data using the Meta-Llama-3-8B-Instruct Model through question-based evaluation. The format of question is: Is this information "[Paragraph/Infobox/Wikitable]" able to answer the question: "[Prompt for web scraping]"? Information deemed relevant by the LLM is added to the list of relevant documents. If the LLM determines that it can answer the question, it will return a response of 1; otherwise, it will return 0. The answer from the LLM is 1, meaning that this paragraph will be included in the list of relevant documents. </p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3.1.6.">Relevant Score Ranking</head><p>In relevant score ranking step, the goal is to retrieve the relevant context from the list of relevant documents by applying the same method used in the relevant scoring step, combined with relevant score ranking. Each document is compared to the web scraping prompt by calculating cosine similarity using the vector model all-MiniLM-L6-v2, as in the relevant scoring step, to determine its relevant score. The documents are then ranked from highest to lowest, and the Top 𝐾 documents are selected to form the relevant context, which will be crucial for knowledge extraction. The key difference between this step and the relevant scoring step lies in their objectives. In relevant scoring, the focus is on identifying relevant linked URLs using a threshold-based filtering technique, while this step selects relevant documents to create the relevant context through a Top 𝐾 filtering approach. The Top 𝐾 method is not used in the relevant scoring step to avoid restricting the number of links, thereby allowing broader web scraping and increasing the chances of finding relevant documents.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3.1.7.">Knowledge Extraction</head><p>The purpose of knowledge extraction step is to extract knowledge from LLM by using relevant context. The result of this step will be LLM-generated answers that are ready for entity mapping. For example, for the question "Which countries share land borders with Uruguay with country name only with comma? If None, answer None. " the answer generated by the LLM is "Argentina, Brazil". To ask questions using the prompt for knowledge extraction, as shown in Table <ref type="table" target="#tab_0">2</ref>, and the obtained relevant context, the input message format consists of three parts:</p><p>1. Relevant Context: The first message provides the relevant context to the LLM in the following format:</p><p>{"role": "system", "content": "Using this context to answer the question: " + [Relevant Context]}. </p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="2.">Behavior Setting:</head><p>The second message sets the behavior of the Chatbot of LLM to ensure responses are as required:</p><p>{"role": "system", "content": "You are a chatbot who always responds an answer in english with comma and no explanation. If u don't know the answer, answer None"}.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3.">Question Prompt:</head><p>The third message is used to ask the question and is formatted as:</p><p>{"role": "user", "content": [Prompt for Knowledge Extraction]}.</p><p>This structured approach ensures that the LLM has the necessary context and guidance to provide accurate and concise answers.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3.2.">Entity Mapping</head><p>The goal of entity mapping process is to construct a knowledge graph using the answers from the LLM obtained in the previous session. The result of this process will be completed knowledge tuples based on the given subject entity and relation. For example, after receiving the answer from the question "Which countries share land borders with Uruguay with country name only with comma? If None, answer None. " from the LLM as "Argentina, Brazil", we map the answer using wbsearchentities. The final result is a completed tuple: {"SubjectEntity": "Uruguay", "Relation": "countryLandBordersCountry", "ObjectEntitiesID": ["Q414", "Q155"]}. We begin by mapping the answers to create a knowledge graph using wbsearchentities, an API function provided by the Wikidata Query Service<ref type="foot" target="#foot_1">2</ref> . This function searches for entities in Wikidata using labels or keywords and returns a list of matching entities ranked by relevance. The method used to select entities for linking as objects is "Choose First" for all relations. After selecting an entity, its validity is verified by checking the range of each relation. As shown in Table <ref type="table" target="#tab_1">3</ref>, if the entity's "instance of" is within the same range of relations as the subject, the entity is selected for mapping.</p><p>In cases where responses from LLM exhibit ambiguity, it may be due to the LLM relying too heavily on context. For instance, in the relation companyTradesAtStockExchange, stock exchange information for a company on Wikipedia is often presented in the format "Traded as", such as "West Japan Railway Company traded as TYO: 9021", where TYO is the stock exchange name and 9021 is the stock exchange code. The LLM might provide an answer like "TYO: 9021". To address this ambiguity, we employ hard coding to filter and refine the responses from the LLM, thereby improving the accuracy and clarity of the output.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4.">Experiments and Results</head></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4.1.">Datasets</head><p>The datasets used in this study were obtained from ISWC 2024 LM-KBC Challenge <ref type="bibr" target="#b5">[6]</ref>. Details of the datasets are shown in Table <ref type="table" target="#tab_2">4</ref>. Each dataset consists of 378 unique subject-entities and 5 relations, with object entities referenced from Wikidata. Additionally, each relation has special features that describe the characteristics of the object entities, which vary by relation. For example, the special feature of the relation countryLandBordersCountry is the possibility of Null values. For instance, New Zealand, being an island nation with no land borders, would have a Null value for the object entity corresponding to the given subject entity "New Zealand" and the given relation countryLandBordersCountry.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4.2.">Experiment Settings</head><p>The LLM used in this study is Llama-3-8B-Instruct. Its parameter count also falls within the required limit of the task. Wikipedia was the primary data source, and the vector model chosen for cosine similarity calculations was all-MiniLM-L6-v2. This model was selected for its compact size, speed, and reasonable performance, particularly given the resource-intensive nature of web scraping and crawling, which may involve processing numerous linked URLs and a large volume of documents. It helps efficiently manage this challenge. The relevant score threshold for filtering Wikipedia URLs is set at 0.5 to select URLs similar to the web scraping prompt, which functions as a user query. A cosine similarity of 0.5 reflects a moderate level of similarity, balancing relevance and coverage to avoid overly filtering out pertinent URLs. Each document was divided into segments of 4,500 tokens, and a Top 𝐾 approach, with 𝐾=20, was applied to combine documents into a single context within the relevant score ranking pipeline. In the relevant identification step, we used max_new_tokens=1, temperature=0.1, and top_p=0.9. max_new_tokens=1 was chosen because this step of the pipeline only returns a 0 or 1 for filtering. In the knowledge extraction step, we set max_new_tokens=3000, temperature=0.1, and top_p=0.9, with max_new_tokens=3000 being an estimated value for the maximum length of the LLM's responses. The choice of using 𝐾=20, temperature=0.1, and top_p=0.9 was based on preliminary experiments, which demonstrated better results compared to not setting these values. Moreover, the values of temperature=0.1 and top_p=0.9 are suitable for tasks requiring logical consistency.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4.3.">Baseline</head><p>Our study used the baseline of meta-llama/Meta-Llama-3-8B-Instruct from ISWC 2024 LM-KBC Challenge 1 . The baseline was derived from the use of a Masked Language Model, an Autoregressive Language Model, and Llama-3 chat models.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4.4.">Evaluation Metrics</head><p>In our study, we used three evaluation metrics: Macro-Precision (Macro-P), Macro-Recall (Macro-R), and Macro-F1. Macro-P is the average precision score across all classes, calculated by determining the precision for each class and averaging the values. Macro-R represents the average recall score across all classes, computed similarly by averaging the recall for each class. Finally, Macro-F1 is the average F1 score across all classes, derived by calculating the F1 score for each class and averaging the results.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4.5.">Results</head><p>We conducted experiments on our system using the validation set, with the results presented in Table <ref type="table">5</ref>. The experimental results demonstrated that our approach outperformed the baseline, achieving an average F1-score of 0.695. For the test set, we submitted the results to the ISWC 2024 LM-KBC Challenge. The test results, shown in Table <ref type="table">6</ref>, indicate an average F1-score of 0.698, which is consistent with the performance on the validation set.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="5.">Discussion</head></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="5.1.">Data Source Quality</head><p>The source of context information plays a critical role in determining the coverage score of the context <ref type="bibr" target="#b8">[9]</ref>. If a data source provides limited information, the coverage score will be lower, which subsequently affects the responses generated by the LLM <ref type="bibr" target="#b9">[10]</ref>. ISWC 2024 KM-KBC Challenge this year is represented by five distinctive relations, particularly the awardWonBy and companyTradesAtStockExchange relations. For the awardWonBy relation, some subjects on Wikipedia do not display the award winners on the main award page, but instead on a separate "List of laureates" page. Similarly, for the companyTradesAtStockExchange relation, information about stock exchanges may not be directly provided or may be absent from the Wikipedia page. Therefore, utilizing effective data sources and retrieval methods is crucial.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="5.2.">Knowledge Discrepancy</head><p>While performing the task, we observed that although the responses generated by the LLM were consistent with the context derived from Wikipedia, they did not align with the information </p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="5.3.">Relevant Context</head><p>High-quality context can improve the performance of question-answering in LLMs <ref type="bibr" target="#b10">[11]</ref>. We employed LLMs and relevant scores to filter the quality of documents obtained from web scraping and web crawling. After consolidating documents into a single context, we evaluate the quality of the relevant context using the coverage score. The coverage score indicates how well the relevant context contains substrings that are object entities from the given subject entity and relation. It is calculated by dividing the number of object entity substrings found in the relevant context by the total number of object entities for that given subject entity and relation. The coverage scores for each relation on the validation set are shown in Table <ref type="table" target="#tab_3">7</ref>.</p><p>It was observed that for certain relations, particularly awardWonBy, the coverage score was not high. This may be due to the fact that Wikipedia often presents award winners in tables that include additional information. Although the award winner's name is present, the presence of other noise in the data can impact the relevant score <ref type="bibr" target="#b11">[12]</ref>. When comparing the coverage score with the macro F1 score for each relation in Table <ref type="table">5</ref>, it was found that the macro F1 score is generally lower or similar. This implies that increasing the coverage score of the context could potentially enhance the quality of responses generated by the LLM.</p><p>Additionally, comparing the difference in coverage score between using web crawling and not using it reveals that web crawling generally improves the coverage score for most relations. However, in some cases, it does not. This may be due to the presence of noise in the documents obtained from web scraping. Expanding the scope of web scraping increases the likelihood of encountering noisy data, which can affect the cosine similarity score. As a result, some documents with higher cosine similarity scores may be selected over those that actually contain the correct answers to the query.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="6.">Conclusion</head><p>This study aims to construct KGs from LLM by using RAG to optimize knowledge extraction from LLM and to involve the large language model in finding relevant documents using ISWC 2024 LM-KBC Challenge datasets <ref type="bibr" target="#b5">[6]</ref>. We achieved an F1 score of 0.695 for the validation set and 0.698 for the test set. The results demonstrate that the quality of context is crucial for optimizing LLM performance in answering questions. Additionally, the LLM can effectively assist in screening relevant documents, which is a key factor in constructing an accurate and high-quality knowledge graph. For future investigations, it is recommended to explore the implementation of automatic relevant document retrieval instead of relying solely on questionanswering combined with relevant scores.</p></div><figure xmlns="http://www.tei-c.org/ns/1.0" xml:id="fig_0"><head>Figure 1 :Figure 2 :</head><label>12</label><figDesc>Figure 1: The overview of the KGC-RAG method</figDesc><graphic coords="4,150.55,84.19,291.68,115.58" type="bitmap" /></figure>
<figure xmlns="http://www.tei-c.org/ns/1.0" type="table" xml:id="tab_0"><head>Table 2</head><label>2</label><figDesc>Templates of Prompt for Knowledge Extraction</figDesc><table><row><cell>Relation</cell><cell>Prompt for Knowledge Extraction</cell></row><row><cell>awardWonBy</cell><cell>"Provide a name only list of all award winners in " + SubjectEn-</cell></row><row><cell></cell><cell>tity + " with no explanation and name with comma ?"</cell></row><row><cell cols="2">companyTradesAtStockExchange "Which stock exchange does " + SubjectEntity + " trade on</cell></row><row><cell></cell><cell>? answering with no explanation and name with comma? If</cell></row><row><cell></cell><cell>None, answer None. "</cell></row><row><cell>countryLandBordersCountry</cell><cell>"Which countries share land borders with " + SubjectEntity + "</cell></row><row><cell></cell><cell>with country name only with comma? If None, answer None. "</cell></row><row><cell>personHasCityOfDeath</cell><cell>"What is the city of death of " + SubjectEntity + "? answering</cell></row><row><cell></cell><cell>with one city name only with no explanation. If there is no</cell></row><row><cell></cell><cell>place of death mentioned, answer None"</cell></row><row><cell>seriesHasNumberOfEpisodes</cell><cell>"How many total episodes of series " + SubjectEntity + " ?</cell></row><row><cell></cell><cell>answering with only one number ?"</cell></row></table></figure>
<figure xmlns="http://www.tei-c.org/ns/1.0" type="table" xml:id="tab_1"><head>Table 3</head><label>3</label><figDesc>Domain and Range for Each Relation</figDesc><table><row><cell>Relation</cell><cell>Domain</cell><cell>Range</cell></row><row><cell>awardWonBy</cell><cell>Award</cell><cell>Human</cell></row><row><cell cols="3">companyTradesAtStockExchange Company Stock Exchange</cell></row><row><cell>countryLandBordersCountry</cell><cell>Country</cell><cell>Country</cell></row><row><cell>personHasCityOfDeath</cell><cell>Human</cell><cell>City</cell></row><row><cell>seriesHasNumberOfEpisodes</cell><cell>Series</cell><cell>Number</cell></row></table></figure>
<figure xmlns="http://www.tei-c.org/ns/1.0" type="table" xml:id="tab_2"><head>Table 4</head><label>4</label><figDesc>Number of unique subject-entities in the data splits</figDesc><table><row><cell>Relation</cell><cell cols="3">Train Val Test</cell><cell>Special features</cell></row><row><cell>awardWonBy</cell><cell>10</cell><cell>10</cell><cell>10</cell><cell>Many objects per subject</cell></row><row><cell>companyTradesAtStockExchange</cell><cell>100</cell><cell cols="2">100 100</cell><cell>Null values possible</cell></row><row><cell>countryLandBordersCountry</cell><cell>68</cell><cell>68</cell><cell>68</cell><cell>Null values possible</cell></row><row><cell>personHasCityOfDeath</cell><cell>100</cell><cell cols="2">100 100</cell><cell>Null values possible</cell></row><row><cell>seriesHasNumberOfEpisodes</cell><cell>100</cell><cell cols="2">100 100</cell><cell>Object is numeric</cell></row></table></figure>
<figure xmlns="http://www.tei-c.org/ns/1.0" type="table" xml:id="tab_3"><head>Table 7</head><label>7</label><figDesc>The average coverage scores on validation set</figDesc><table><row><cell>Relation</cell><cell cols="2">Without Web Crawling With Web Crawling</cell></row><row><cell>awardWonBy</cell><cell>0.361</cell><cell>0.137</cell></row><row><cell>companyTradesAtStockExchange</cell><cell>0.213</cell><cell>0.675</cell></row><row><cell>countryLandBordersCountry</cell><cell>0.731</cell><cell>0.967</cell></row><row><cell>personHasCityOfDeath</cell><cell>0.480</cell><cell>0.715</cell></row><row><cell>seriesHasNumberOfEpisodes</cell><cell>0.860</cell><cell>0.790</cell></row><row><cell>All Relations</cell><cell>0.529</cell><cell>0.657</cell></row></table></figure>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" n="1" xml:id="foot_0">https://sparqlwrapper.readthedocs.io/en/latest/main.html</note>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" n="2" xml:id="foot_1">https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service</note>
		</body>
		<back>

			<div type="acknowledgement">
<div xmlns="http://www.tei-c.org/ns/1.0"><head>Acknowledgement</head><p>This work was supported by JSPS Grant-in-Aid for Early-Career Scientists (Grant Number 24K20834).</p></div>
			</div>

			<div type="annex">
<div xmlns="http://www.tei-c.org/ns/1.0" />			</div>
			<div type="references">

				<listBibl>

<biblStruct xml:id="b0">
	<analytic>
		<title level="a" type="main">Knowledge graph refinement: A survey of approaches and evaluation methods</title>
		<author>
			<persName><forename type="first">H</forename><surname>Paulheim</surname></persName>
		</author>
	</analytic>
	<monogr>
		<title level="j">Semantic Web</title>
		<imprint>
			<biblScope unit="volume">8</biblScope>
			<biblScope unit="page" from="489" to="508" />
			<date type="published" when="2017">2017</date>
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b1">
	<analytic>
		<title level="a" type="main">Wikidata: A free collaborative knowledge base</title>
		<author>
			<persName><forename type="first">D</forename><surname>Vrandečić</surname></persName>
		</author>
		<author>
			<persName><forename type="first">M</forename><surname>Krötzsch</surname></persName>
		</author>
	</analytic>
	<monogr>
		<title level="j">Communications of the ACM</title>
		<imprint>
			<biblScope unit="volume">57</biblScope>
			<biblScope unit="page" from="78" to="85" />
			<date type="published" when="2014">2014</date>
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b2">
	<analytic>
		<title level="a" type="main">Constructing knowledge graphs from text: A survey of methods and tools</title>
		<author>
			<persName><forename type="first">L</forename><surname>Jansen</surname></persName>
		</author>
		<author>
			<persName><forename type="first">R</forename><surname>Van Hirtum</surname></persName>
		</author>
	</analytic>
	<monogr>
		<title level="j">Journal of Computer Science and Technology</title>
		<imprint>
			<biblScope unit="volume">35</biblScope>
			<biblScope unit="page" from="1001" to="1020" />
			<date type="published" when="2020">2020</date>
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b3">
	<analytic>
		<title level="a" type="main">Evaluating the reliability of large language models for knowledge extraction</title>
		<author>
			<persName><forename type="first">R</forename><surname>Binns</surname></persName>
		</author>
		<author>
			<persName><forename type="first">V</forename><surname>Veitch</surname></persName>
		</author>
		<author>
			<persName><forename type="first">N</forename><surname>Shadbolt</surname></persName>
		</author>
	</analytic>
	<monogr>
		<title level="m">Proceedings of the ACM Conference on Information and Knowledge Management (CIKM)</title>
				<meeting>the ACM Conference on Information and Knowledge Management (CIKM)</meeting>
		<imprint>
			<date type="published" when="2021">2021</date>
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b4">
	<analytic>
		<title level="a" type="main">Retrieval-augmented generation for knowledge-intensive nlp tasks</title>
		<author>
			<persName><forename type="first">P</forename><surname>Lewis</surname></persName>
		</author>
		<author>
			<persName><forename type="first">E</forename><surname>Perez</surname></persName>
		</author>
		<author>
			<persName><forename type="first">A</forename><surname>Piktus</surname></persName>
		</author>
		<author>
			<persName><forename type="first">F</forename><surname>Petroni</surname></persName>
		</author>
		<author>
			<persName><forename type="first">V</forename><surname>Karpukhin</surname></persName>
		</author>
		<author>
			<persName><forename type="first">N</forename><surname>Goyal</surname></persName>
		</author>
		<author>
			<persName><forename type="first">H</forename><surname>Küttler</surname></persName>
		</author>
		<author>
			<persName><forename type="first">M</forename><surname>Lewis</surname></persName>
		</author>
		<author>
			<persName><forename type="first">W</forename><surname>-T. Yih</surname></persName>
		</author>
		<author>
			<persName><forename type="first">T</forename><surname>Rocktäschel</surname></persName>
		</author>
	</analytic>
	<monogr>
		<title level="m">Advances in Neural Information Processing Systems</title>
				<imprint>
			<date type="published" when="2020">2020</date>
			<biblScope unit="volume">33</biblScope>
			<biblScope unit="page" from="9459" to="9474" />
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b5">
	<analytic>
		<title level="a" type="main">Knowledge base construction from pre-trained language models</title>
		<author>
			<persName><forename type="first">J.-C</forename><surname>Kalo</surname></persName>
		</author>
		<author>
			<persName><forename type="first">S</forename><surname>Razniewski</surname></persName>
		</author>
		<author>
			<persName><forename type="first">T.-P</forename><surname>Nguyen</surname></persName>
		</author>
		<author>
			<persName><forename type="first">B</forename><surname>Zhang</surname></persName>
		</author>
	</analytic>
	<monogr>
		<title level="m">Semantic Web Challenge on Knowledge Base Construction from Pre-trained Language Models</title>
				<imprint>
			<publisher>CEUR-WS</publisher>
			<date type="published" when="2022">2022. 2024</date>
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b6">
	<analytic>
		<title level="a" type="main">Using large language models for knowledge engineering (llmke): A case study on wikidata</title>
		<author>
			<persName><forename type="first">B</forename><surname>Zhang</surname></persName>
		</author>
		<author>
			<persName><forename type="first">I</forename><surname>Reklos</surname></persName>
		</author>
		<author>
			<persName><forename type="first">N</forename><surname>Jain</surname></persName>
		</author>
		<author>
			<persName><forename type="first">A</forename><forename type="middle">M</forename><surname>Peñuela</surname></persName>
		</author>
		<author>
			<persName><forename type="first">E</forename><surname>Simperl</surname></persName>
		</author>
	</analytic>
	<monogr>
		<title level="m">Proceedings of the ISWC 2023</title>
				<meeting>the ISWC 2023</meeting>
		<imprint>
			<date type="published" when="2023">2023</date>
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b7">
	<monogr>
		<author>
			<persName><forename type="first">Y</forename><surname>Gao</surname></persName>
		</author>
		<author>
			<persName><forename type="first">Y</forename><surname>Xiong</surname></persName>
		</author>
		<author>
			<persName><forename type="first">X</forename><surname>Gao</surname></persName>
		</author>
		<author>
			<persName><forename type="first">K</forename><surname>Jia</surname></persName>
		</author>
		<author>
			<persName><forename type="first">J</forename><surname>Pan</surname></persName>
		</author>
		<author>
			<persName><forename type="first">Y</forename><surname>Bi</surname></persName>
		</author>
		<author>
			<persName><forename type="first">Y</forename><surname>Dai</surname></persName>
		</author>
		<author>
			<persName><forename type="first">J</forename><surname>Sun</surname></persName>
		</author>
		<author>
			<persName><forename type="first">M</forename><surname>Wang</surname></persName>
		</author>
		<author>
			<persName><forename type="first">H</forename><surname>Wang</surname></persName>
		</author>
		<title level="m">Retrievalaugmented generation for large language models: A survey</title>
				<imprint>
			<date type="published" when="2024">2024</date>
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b8">
	<analytic>
		<title level="a" type="main">Enhancing context coverage for question answering with multiple knowledge sources</title>
		<author>
			<persName><forename type="first">X</forename><surname>Chen</surname></persName>
		</author>
		<author>
			<persName><forename type="first">J</forename><surname>Zhu</surname></persName>
		</author>
	</analytic>
	<monogr>
		<title level="m">Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing</title>
				<meeting>the 2020 Conference on Empirical Methods in Natural Language Processing</meeting>
		<imprint>
			<date type="published" when="2020">2020</date>
			<biblScope unit="page" from="2340" to="2350" />
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b9">
	<analytic>
		<title level="a" type="main">Understanding and mitigating the impact of data source limitations on llm performance</title>
		<author>
			<persName><forename type="first">H</forename><surname>Zhao</surname></persName>
		</author>
		<author>
			<persName><forename type="first">M</forename><surname>Eskenazi</surname></persName>
		</author>
	</analytic>
	<monogr>
		<title level="m">Proceedings of NeurIPS</title>
				<meeting>NeurIPS</meeting>
		<imprint>
			<date type="published" when="2021">2021</date>
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b10">
	<analytic>
		<title level="a" type="main">Natural questions: a benchmark for question answering research</title>
		<author>
			<persName><forename type="first">T</forename><surname>Kwiatkowski</surname></persName>
		</author>
		<author>
			<persName><forename type="first">J</forename><surname>Palomaki</surname></persName>
		</author>
		<author>
			<persName><forename type="first">M</forename><surname>Redfield</surname></persName>
		</author>
		<author>
			<persName><forename type="first">M</forename><surname>Edward</surname></persName>
		</author>
		<author>
			<persName><forename type="first">M</forename><surname>Collins</surname></persName>
		</author>
	</analytic>
	<monogr>
		<title level="j">Transactions of the Association for Computational Linguistics</title>
		<imprint>
			<biblScope unit="volume">7</biblScope>
			<biblScope unit="page" from="453" to="466" />
			<date type="published" when="2019">2019</date>
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b11">
	<analytic>
		<title level="a" type="main">Analyzing the effects of noise on neural network performance in natural language processing</title>
		<author>
			<persName><forename type="first">Y</forename><surname>Jernite</surname></persName>
		</author>
		<author>
			<persName><forename type="first">J</forename><forename type="middle">M</forename></persName>
		</author>
	</analytic>
	<monogr>
		<title level="m">Proceedings of the 2017 Conference on Empirical Methods in Natural Language Processing</title>
				<meeting>the 2017 Conference on Empirical Methods in Natural Language Processing</meeting>
		<imprint>
			<date type="published" when="2017">2017</date>
			<biblScope unit="page" from="2892" to="2900" />
		</imprint>
	</monogr>
</biblStruct>

				</listBibl>
			</div>
		</back>
	</text>
</TEI>
