VIETNAM NATIONAL UNIVERSITY HO CHI MINH CITY UNIVERSITY OF INFORMATION TECHNOLOGY ADVANCED PROGRAM IN INFORMATION SYSTEMS LE SY THANH — 19522230 CHE NGUYEN MINH TUNG - 19522490 CONSTRUCTING A KNOWLEDGE GRAPH WITH FACT CHECKING ABOUT VIETNAMESE CUISINE BACHELOR OF ENGINEERING IN INFORMATION SYSTEMS THESIS ADVISOR ASSOCIATE PROFESSOR DR. DO PHUC HO CHI MINH CITY, 2023 ASSESSMENT COMMITTEE The Assessment Committee is established under the Decision. by Rector of the University of Information Technology. Nguyén Dinh Thuan - Chairman.
Cao Thi Nhan - Secretary. Lê Kim Hùng - Member ACKNOWLEDGMENTS I extend my deepest gratitude to my mentor, Assoc. Đỗ Phúc, for his invaluable guidance and steadfast support throughout the fruition of my project. His consistent backing has been a beacon of clarity, and I am truly appreciative.
Special acknowledgment goes to M. Nguyén Thi Kim Phung, whose guidance and camaraderie have enriched our collaboration on this project. In the second phase of this academic journey, my interactions with Dr. Cao Thi Nhan as my consultant have been particularly enriching.
Nhan's benevolence extended beyond the scope of academia, fostering a sense of warmth and inclusion among our classmates throughout our university years. Her guidance has not only contributed to the academic aspects of my project but has also left an indelible mark on our collective experience. Moving on to the third expression of gratitude, I find it imperative to recognize the meticulous efforts of the entire Information Systems Department faculty. Their responsiveness to my inquiries demonstrated a commitment to academic excellence that went above and beyond, significantly enhancing my understanding of the subject matter.
The fourth acknowledgment extends beyond the academic sphere, encompassing the support network that has been pivotal to my journey. My gratitude extends to my family, whose unwavering support has been a pillar of strength. Friends and classmates have formed a tapestry of encouragement and camaraderie, providing a backdrop of positivity that has propelled me forward. Their collective support and love serve as a constant reminder of the interconnectedness that makes academic pursuits all the more meaningful.
TABLE OF CONTENTS cs Le ABSTRACT 1 Chapter 1 INTRODUCTION 2 1. Background and Context 2 1.2 Statement of the Problem 3 1. Objectives of the Study 4 1.4 Significance of the Study 5 15 Motivation 6 1.7 Structure of the thesis 8 Chapter2 BACKGROUND AND RELATED WORK 10 2.1 Resource Descriptive Framework 10 2.3 Bidirectional Encoder Representations from Transformers 14 2.2 Multi-head Attention 15 2.4 Pre-training and Fine-Tuning 21 2.4 Softmax, Argmax and Loss functions 22 2.3 Cross-entropy loss 23 2.5 Named Entity Recognition 24 2.1 The transformer architecture 34 2.2 Semantic textual similarity 35 Chapter3 SYSTEM DESIGN 37 3.2 Software and database design 38 3.2 Knowledge graph construction 39 3. Algorithm processing flow 43 3.1 Integrate BERT-NER 44 3.2 System response processing 47 3.
Fact-checking through semantic similarity 48 Chapter4 SYSTEM IMPLEMENTATION 53 4.2 User query processing 53 4. Neo4j query processing 55 4.4 Answer results processing 61 4.5 Experiment and Discussion 66 Chapter5 CONCLUSION & FUTURE WORK 71 5.2 Future work 72 REFERENCES 73 APPENDICES 74 Appendix A: WEB APPLICATION INTERFACE 74 Appendix B: SOME EXAMPLES TYPES OF QUESTIONS TO TEST THE CHATBOT 79 Appendix C: STRUCTURE OF THE VIETNAMESE CUISINE KNOWLEDGE GRAPH 81 Appendix D: TRAIN AND USING BERT-NER 82 LIST OF EIGURES œ2EFlx» Figure 2-1 Triple examples TẢ. 12 Figure 2-2 Example of a graph (Source: video “Introduction to Neo4j and Graph Databases”, 2019) .eceecccscesscsscceseceseceeeesecesecececseceseceaeceeeaeceaeeececseeeseceaeceeecaeeeaeeeaeeeneeaeens 13 Figure 2-3 BERT base and BERT large models (Source: web“BERT base vs BERT Large”, 2019). ee scesesseesecseesecsecsecsceeecsecesesseesecsessecsessecsaseaeeaeeseesesseesessessessessesesseaseaeeaes 15 Figure 2-4 Architecture of Transformer (Source: web “The Transformer Model”).
16 Figure 2-5 BERT input representation (Source: “BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding ”, 2019).-----<cc<x 17 Figure 2-6 Encoder funCfIOTI.---- --- 5 + + 111 1v vn TT TH HH nghệ 19 Figure 2-7 Tensor điTN€TSIOTIS.- - G2 3 1921011811891 911 91 19010191 ng 20 Figure 2-8 Overall pre-training and fine-tuning procedures for BERT (Source: “BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding ”, 2019) ¬. 22 Figure 2-9 NER example .-- --¿- 5E 1951193 911 91H TH HT HH 25 Figure 2-10 NER tagging example .- --- c1 11910 1991012 11 9 1 kg ng ngư, 26 Figure 2-11 Illustration of BERT for NER (Source: “BERT: Pre-trainng of Deep Bidirectional Transformers for Language Understanding ”, 20119).-- ---««++<«+ 27 Figure 2-12 Neo4j ecosystem (Source: web” Welcome to Neo4J””}.‹----«--<«+ 28 Figure 2-13 Example triple store in I€O4|],. - -- -- 5 22+ 332218323 E + EESEEEEeeesreereeserere 29 Figure 2-14 Cosine distance/Similarity (Source: Wikipedia “Cosine similarity”). 33 Figure 3-1 System architecture .-- 2 G119 19v HH Hư, 38 Figure 3-2 Data orgamization Chart.
¿5 + 3118311133383 11 83 11 811 111 g1 1v rưn 41 Figure 3-3 Pipeline of the SÿS(€T.- 5 1E 211 911 1 301 1 1v ng ng ngư43 Figure 3-4 Fact checking pIpeÌIne.-- -- --- + 1+1 kS SH ng ng ướt 49 Figure 4-1 Overview of the system processing flOW .- + cssesereserrerrske 53 Figure 4-2 Output Of Predict .- - -Ă 2 3019210118 1113910119 11 911111 11H HH ng 55 Figure 4-3 Output of final T€SUÍS.- 5 1119101121 911 11911191 ng ng ng tr 55 Figure 4-4 JSON object of Final result for †TIDÏ€.-- <5 + + +*££++EE+eeeeeeeseeereeee 56 Figure 4-5 Execution plan for a Cypher Query. -- --- 55 + 33+ EEseesrseeereerreee 58 Figure 4-6 Result from the DÏ4Tn.-- -- + E33 139111311 91 1 930 1901119 ng ngư 60 Figure 4-7 Result from Neo4j in JSON .- cà HH HH HH Hiệp 61 Figure 4-8 Extraction results of related Sentences .- - -G ng rưn 63 Figure 4-9 Word segmentation T€SUÏÍL.-- - + + + Sx 93 91191 1 1 vn ng rưệt 64 Figure 4-10 Cosine similarity T€SUÏ(.-- ó6 << + 13 E3 91 3E ngư 65 Figure 4-11 Sort by highest similarity from high to ÏOW. c5 SĂcSsSssseseseresee 66 Figure 4-12 Training Loss over EDOCs.-- 6 13 93 91193 2 HH HH ng rưệt 67 Figure 4-13 Result of precision, recall and Ï~SCOT€.-- 5 + + £++eexseexeeereees 68 Figure A-1 NER result after executed query (admin ]).--- -- «<5 s<++s£+seeeeses 74 Figure A-2 Triple result after processing the label from NER (admin Ủ]). 74 Figure A-3 Knowledge graph result from n€O(4 .-- --- -- + + + + k kg tr 75 Figure A-4 Add triple interface.
eee -- (5 + 31 HT TH HH HH 75 Figure A-5 Chatbot user ITI(CTÍAC€. G1 HH HH HH HH 76 Figure A-6 Chatbot response with image and relevant URL reference.- 77 Figure A-7 Some examples of difference QU€TV. -- 5 55 + 13+ +*vEEseeseeeeseeereeee 77 Figure A-8 Example with Vietnamese QU€FV.- --- 5 6 tk HH nh tr 78 Figure C-1 Structure of the Knowledge Graph.- - - --- - -c + t**v vn ngư, 81 LIST OF TABLES œ4EFllx» Table 2-1 RDF triples. 11 Table 2-2 Example softmmax.- G0111 HH HH ng 23 Table 2-3 Example Argmax.- - 5 - 5E 1101193019319 111901 nọ ng 23 Table 3-1 Data organization aïfAÌÏWS1S.
- «xxx vn HH HH ng nh rưệt 42 Table 3-2 List of dependency tags and NER exampÌe.-- -- --+++-s+*++x*s+seexseereees 45 Table 3-3 Our Sample Cat€ØOTIZAfIOTI.- G1 321119111910 19 10 1991119 1H ng ng ngư46 Table 206015 1. 54 LIST OF ABBREVIATIONS NLP Nature Language Processing BERT Bidirectional Encoder Representations from Transformers RDF Resource Descriptive Framework HTTP HyperText Transfer Protocol NER Named Entity Recognition ABSTRACT With today's advanced technology, the use of chatbots is growing in popularity and strength. We want to learn more about this area, conduct further research, and create our own application. Rich data gathered from the Internet was used to create a knowledge graph, which we then used to build a chatbot - a question-answering application - based on the knowledge graph.
Wikipedia content and online source pages are the main places to look for authenticity and dependability. The study presented in this thesis advances applications of knowledge representation and natural language processing. The research also addresses the challenges posed by the intrinsic depth and complexity of natural language, emphasizing the adaptability and flexibility of natural language, which makes it inherently difficult for computational analysis. The thesis aims to bridge this gap by leveraging advanced NLP approaches and innovative technologies to create a chatbot that can effectively engage users and serve as a reliable source of knowledge about Vietnamese culinary traditions.
The subject of our knowledge graph is Vietnamese cuisine in 63 provinces. In this thesis, we present the process of natural language processing of queries from users, as well as the conditions for creating answers from chatbots and using information reference sources to support fact checking. Information reference sources become integral in this endeavor, acting as pillars of support in ensuring the accuracy and credibility of the knowledge imparted by our chatbot.1 Background and Context The swift advancement of digital technology and artificial intelligence has brought about revolutionary shifts in the ways people interact with online platforms and obtain information. Chatbots have become immensely useful tools in this age of rapid technological development, changing the way users engage with one another and providing prompt answers to questions.
Artificial intelligence-powered chatbots are highly effective at mimicking human speech and are widely used to streamline communication and offer prompt support on a variety of online platforms. Furthermore, a new era of intelligent conversation agents has been ushered in by the creation of Knowledge Graphs and advanced Natural Language Processing (NLP) techniques, which have coincided with the emergence of chatbots. A knowledge graph is an advanced data structure that is used to precisely record the complex relationships between concepts and things in a given domain. Cutting-edge models and algorithms are used in advanced NLP approaches to process and understand human language with ease.
This feature greatly enhances the quality of user interactions by enabling chatbots to comprehend and react to user inquiries with increased precision and thoroughness. This thesis explores how these innovative technologies come together to create a cutting- edge web chatbot with a unique emphasis on Vietnamese food. Through the integration of chatbot capabilities with the sophisticated NLP and Knowledge Graph insights, this research aims to open up new avenues for providing a rich and dynamic user experience. The goal is to develop a chatbot that can effectively engage people and act as a reliable source of knowledge about the complex web of Vietnamese culinary traditions by investigating the intersection of various technological frontiers.2 Statement of the Problem Because of the language's intrinsic depth and complexity, texts written in natural language are by nature difficult.
The existence of ambiguity, which allows a statement to transmit wholly different meanings depending on its context, is one of the main causes of this complexity. Natural language is remarkably adaptable, as seen by its capacity to fit in with a variety of contexts with ease. But this very flexibility makes it extremely difficult for computers to understand. Since natural language is inherently flexible, it is not feasible to cover every possible use case with a strict set of rules.
Rather, the method uses algorithms created to take the meaning out of every sentence and extract the most important information. This methodology, which navigates the complex and dynamic nature of natural language and makes it accessible for computational analysis, is essential for enabling computer "comprehension" of languages. Once the core data has been extracted, and all of the extracted data is based on the topic we choose and research, all of the important and related data to the topic has been saved. We spent time gathering information from the internet, particularly Wikipedia, because it is the most trustworthy site available.
Traditional databases are intended to store structured data rather than unstructured data such as text. Because natural language tends to link things together, we decided to store data in a graph database. Our assignment is to provide a brief overview of the problem we hope to solve.