CN117891930B - Book knowledge question-answering method based on knowledge graph enhanced large language model - Google Patents

Book knowledge question-answering method based on knowledge graph enhanced large language model Download PDF

Info

Publication number
CN117891930B
CN117891930B CN202410302941.4A CN202410302941A CN117891930B CN 117891930 B CN117891930 B CN 117891930B CN 202410302941 A CN202410302941 A CN 202410302941A CN 117891930 B CN117891930 B CN 117891930B
Authority
CN
China
Prior art keywords
knowledge
language model
large language
vectors
vector
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202410302941.4A
Other languages
Chinese (zh)
Other versions
CN117891930A (en
Inventor
胡芳槐
丁军
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Haiyizhi Information Technology Nanjing Co ltd
Original Assignee
Haiyizhi Information Technology Nanjing Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Haiyizhi Information Technology Nanjing Co ltd filed Critical Haiyizhi Information Technology Nanjing Co ltd
Priority to CN202410302941.4A priority Critical patent/CN117891930B/en
Publication of CN117891930A publication Critical patent/CN117891930A/en
Application granted granted Critical
Publication of CN117891930B publication Critical patent/CN117891930B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a book knowledge question-answering method based on a knowledge graph enhanced large language model, which comprises the steps of firstly extracting knowledge through the large language model and constructing a knowledge graph; after the original document is obtained, logically dividing the original document by adopting a plurality of dividing methods to obtain fragments, inputting the fragments into a large language model for vectorization to obtain fragment vectors; obtaining a knowledge vector and a complete problem vector after obtaining a user input problem; after the knowledge vector and the complete problem vector are spliced, similarity calculation is carried out on the spliced vector and all the segment vectors, and the segment vector with the highest similarity score is taken as a context; and generating prompt information based on the context and the user input problem, inputting the prompt information into a large language model, and finally generating a problem result. The method solves the problems that a large language model is difficult to combine with a knowledge graph in the prior art, and cannot be applied to a book knowledge question-answering scene better.

Description

Book knowledge question-answering method based on knowledge graph enhanced large language model
Technical Field
The invention relates to the technical field of knowledge graphs, in particular to a book knowledge question-answering method based on a knowledge graph reinforced large language model.
Background
The knowledge map is also called scientific knowledge map, called knowledge domain visualization or knowledge domain mapping map in book emotion, and is a series of different graphs for displaying knowledge development process and structural relationship, and knowledge resources and their carriers are described by using visualization technology, and knowledge and their interrelations are mined, analyzed, constructed, drawn and displayed.
The large language model (Large Language Model, LLM) refers to a deep learning model trained using large amounts of text data that can generate natural language text or understand the meaning of language text. The large language model can process various natural language tasks, such as text classification, question-answering, dialogue and the like, and is an important path to artificial intelligence.
The existing large language model cannot be combined with the knowledge graph, and further cannot be well applied to a book knowledge question-answering scene, and a book knowledge question-answering method based on the knowledge graph enhanced large language model is needed.
Disclosure of Invention
The embodiment of the invention aims to provide a book knowledge question-answering method based on a knowledge graph enhanced large language model, which is used for solving the problem that the large language model cannot be combined with the knowledge graph in the prior art, and further cannot be better applied to book knowledge question-answering scenes.
In order to achieve the above purpose, the embodiment of the present invention provides a book knowledge question-answering method based on a knowledge graph enhanced large language model, which specifically includes:
Extracting knowledge through a large language model and constructing a knowledge graph;
Obtaining an original document, logically dividing the original document by adopting a plurality of dividing methods to obtain fragments, inputting the fragments into a large language model for vectorization to obtain fragment vectors, and storing the fragment vectors into a vector library;
Acquiring a user input problem, carrying out knowledge linking based on the knowledge graph to obtain a plurality of knowledge, and inputting the plurality of knowledge into a large language model one by one to carry out vectorization to obtain a plurality of knowledge vectors;
inputting the user input problem into a large language model for vectorization to obtain a complete problem vector;
Splicing the knowledge vectors and the complete problem vectors to obtain spliced vectors;
Performing similarity calculation on the spliced vectors and all segment vectors in a vector library to obtain similarity scores, and taking a preset number of segment vectors in all segment vectors as contexts according to the similarity scores;
and generating prompt information based on the context and the user input problem, inputting the prompt information into a large language model, and generating a problem result.
Based on the technical scheme, the invention can also be improved as follows:
further, the steps of extracting knowledge through a large language model and constructing a knowledge graph comprise:
the method comprises the steps of constructing a book knowledge representation model, wherein the book knowledge representation model is used for providing knowledge to be extracted for a large language model and comprises a knowledge system, a book model and a domain service model;
And extracting a book knowledge representation model based on the large language model to obtain the knowledge graph.
Further, the logically dividing the original document into segments by using a plurality of dividing methods includes:
fixed window partitioning, sliding window partitioning, page-wise partitioning, paragraph-wise partitioning, chapter-wise structure partitioning, and other logical partitioning are employed.
Further, the splicing the plurality of knowledge vectors and the complete problem vector to obtain a spliced vector includes:
and carrying out weighted splicing on the knowledge vectors and the complete problem vectors to obtain spliced vectors.
Further, the book knowledge question-answering method based on the knowledge graph enhanced large language model further comprises the following steps:
and after the user input problem is acquired, carrying out intention classification on the user input problem based on the large language model to obtain an intention classification result.
Further, the book knowledge question-answering method based on the knowledge graph enhanced large language model further comprises the following steps:
Judging whether the user input problem is a complex problem or not based on the intention classification result, and if so, generating a problem result based on the inline architecture mode and the externally-hung architecture mode of the large language model.
Further, the generating the problem result based on the inline architecture mode and the plug-in architecture mode of the large language model includes:
When generating a problem result based on the inline architecture mode of the large language model, knowledge in the knowledge graph is used for directly enhancing the reasoning capability of the large language model.
Further, the generating the problem result based on the inline architecture mode and the plug-in architecture mode of the large language model further includes:
When a problem result is generated based on the plug-in architecture mode of the large language model, the knowledge graph reasoning engine is connected in a plug-in mode based on the enhanced reasoning capacity of the large language model.
Further, the generating the problem result based on the inline architecture mode and the plug-in architecture mode of the large language model further includes:
in the plug-in architecture mode, decomposing the complex task is completed by the large language model;
And calling the reasoning of the knowledge graph in other modes when complex reasoning calculation needs to be called in the task execution process, wherein the other modes comprise a plug-in mode and an interface mode.
Further, the book knowledge question-answering method based on the knowledge graph enhanced large language model further comprises the following steps:
the large language model is fine-tuned based on zero and/or small sample learning methods.
The invention relates to a book knowledge question-answering method based on a knowledge graph enhanced large language model, which comprises the following steps: extracting knowledge through a large language model and constructing a knowledge graph; obtaining an original document, logically dividing the original document by adopting a plurality of dividing methods to obtain fragments, inputting the fragments into a large language model for vectorization to obtain fragment vectors, and storing the fragment vectors into a vector library; acquiring a user input problem, linking knowledge based on the knowledge graph to obtain a plurality of knowledge, and inputting the plurality of knowledge into a large language model one by one to carry out vectorization to obtain a knowledge vector; inputting the user input problem into a large language model for vectorization to obtain a complete problem vector; splicing the knowledge vector and the complete problem vector to obtain a spliced vector; performing similarity calculation on the spliced vectors and all segment vectors in a vector library to obtain similarity scores, and taking the segment vector with the highest similarity score in all segment vectors as a context; and generating prompt information based on the context and the user input problem, inputting the prompt information into a large language model, and generating a problem result. The method solves the problems that a large language model cannot be combined with a knowledge graph in the prior art, and further cannot be well applied to a book knowledge question-answering scene.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below. It will be apparent to those skilled in the art from this disclosure that the drawings described below are merely exemplary and that other embodiments may be derived from the drawings provided without undue effort.
FIG. 1 is a first flowchart of a book knowledge question-answering method based on a knowledge graph enhanced large language model of the present invention;
fig. 2 is a schematic diagram of an entity structure of an electronic device according to the present invention.
Detailed Description
Other advantages and advantages of the present invention will become apparent to those skilled in the art from the following detailed description, which, by way of illustration, is to be read in connection with certain specific embodiments, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
Fig. 1 is a flowchart of an embodiment of a book knowledge question-answering method based on a knowledge graph enhancement large language model, and as shown in fig. 1, the method for book knowledge question-answering based on the knowledge graph enhancement large language model provided by the embodiment of the invention comprises the following steps:
s101, extracting knowledge through a large language model and constructing a knowledge graph;
specifically, the method comprises the steps of constructing a book knowledge representation model, which is used for providing knowledge to be extracted for a large language model, wherein the book knowledge representation model comprises a knowledge system, a book model and a domain service model; and extracting the book knowledge representation model based on the large language model to obtain a knowledge graph. In addition, the large language model adopted in the embodiment is any existing large model capable of realizing functions required by the scheme, such as a BERT, ELMo, GPT large language model.
Specifically, the knowledge system: the knowledge classification system in the business field is divided, and the field knowledge can be classified and carded from the taxonomy angle;
The book model: for modeling the knowledge carrier, the knowledge carrier comprises meta information such as an author, ISBN and the like and content information such as chapter entries and the like;
The domain business knowledge model: in the embodiment, knowledge modeling is mainly performed on the book related business field, the business objects and the relation between the business objects are described, and fine-grained applications such as complex question-answering are supported. Through the knowledge classification and the data model integrated by the three dimensions, a unified book knowledge representation model can be realized.
In this embodiment, knowledge in the book knowledge representation model is learned and extracted by using the large language model zero and/or small sample to quickly construct a knowledge graph, and tasks such as entity identification, relationship extraction, event extraction, etc. are completed based on the large language model. In the embodiment, the general large language model is finely adjusted, so that the extraction capability of the large language model in the book related service field is improved, and the low-cost construction of the knowledge graph is realized.
S102, obtaining an original document, logically dividing the original document by adopting a plurality of dividing methods to obtain fragments, inputting the fragments into a large language model for vectorization to obtain fragment vectors, and storing the fragment vectors into a vector library;
Specifically, in this step, logically dividing the original document by using multiple dividing methods to obtain segments includes: fixed window partitioning, sliding window partitioning, page-wise partitioning, paragraph-wise partitioning, chapter-wise structure partitioning, and other logical partitioning are employed.
Specifically, fixed window partitioning: the method is the most initial dividing method, and is directly divided according to a fixed length, so that logic fracture of a window boundary is usually caused;
Sliding window division: in order to solve the defect of fixed window division, a determined window is used for sliding, and a certain length of repetition is allowed between the windows; of course, this approach would bring about duplication of partial data between windows;
dividing according to pages: the content of the book is logically divided according to pages, and obviously, the logic splitting between pages is also caused;
Dividing according to paragraphs: dividing the document in a paragraph way, wherein the method can keep the semantics of the original document in paragraph units;
Dividing according to chapter and section structures: the logic structure of the book document is kept, the original semantic structure is theoretically kept, but the disassembly difficulty is high;
Other logical divisions: the graphs, tables, formula codes, etc. in the document are divided as semantic segments.
According to the method, the original document is logically divided by adopting a plurality of dividing methods to obtain fragments, and the books and/or the documents are divided according to the specific conditions of the books and/or the documents by adopting at least 6 dividing methods, so that the books and/or the documents are reasonably disassembled, and a good basis is provided for realizing subsequent questions and answers.
S103, acquiring a user input problem, carrying out knowledge linking based on a knowledge graph to obtain a plurality of knowledge, and inputting the plurality of knowledge into a large language model one by one to carry out vectorization to obtain a plurality of knowledge vectors;
In particular, in machine learning and natural language processing, vectorization (embedding) refers to the process of mapping high-dimensional data (e.g., text, pictures, audio) to a low-dimensional space. The vector obtained by vectorization is typically a vector composed of real numbers, which represents the input data as points in a continuous numerical space. In short, vectorization is a real-valued vector in N dimensions, which can be used to represent almost anything, such as text, music, video, etc. Vectorization of real-valued vectors may represent the semantics of words, mainly because these vectorized vectors are learned according to the pattern of occurrence of the words in the language context. For example, if a word is often presented with another word in some contexts, then the embedded vectors of the two words will have similar locations in the vector space, meaning that they have similar meaning and semantics.
Thus, in vector space, the semantics of words can be represented by their distribution in context, that is, the meaning of a word can be inferred from its surrounding words. The large language models such as BERT, ELMo, GPT and the like can generate the vectorization representation of the context, and the step can better capture the semantics and the context information of specific words in the user input problem through the vectorization representation of the keywords after knowledge linkage.
S104, inputting the user input problem into a large language model for vectorization to obtain a complete problem vector;
Similarly, the user input problem is vectorized as a whole through the step, so that the position of the whole user input problem in a vector space can be obtained, and the whole semantic and the context information of the problem can be obtained.
S105, splicing the knowledge vectors and the complete problem vectors to obtain spliced vectors;
specifically, the method comprises the following steps: performing weighted splicing on the knowledge vectors and the complete problem vectors obtained in the step S103 to obtain spliced vectors; wherein the weighting weights of the weighted splice are typically set as follows: the weighted weight of the complete problem vector is set to be 0.5, the sum of the weights of the knowledge vectors obtained through knowledge linkage and vectorization is set to be 0.5, and specifically, the specific weight of each vector in the knowledge vectors is distributed according to the corresponding proportion of the weights of the knowledge keywords in the knowledge graph after knowledge linkage.
S106, carrying out similarity calculation on the spliced vectors and all the fragment vectors in the vector library to obtain similarity scores, and taking the preset number of fragment vectors in all the fragment vectors as contexts according to the similarity scores;
specifically, in this step, the similarity score of each segment vector in the vector library is the sum of the similarity of each segment vector, all knowledge keywords and the spliced vector, the similarity scores of all segment vectors are arranged in the order from high to low, and finally the top K segment vectors TopK with higher similarity scores are taken as the context of the user input problem, where K is a preset number, and the knowledge keywords refer to the result of the link between the user input problem and knowledge of the knowledge graph.
In the art, topK is the first K number with the highest occurrence frequency found in the mass data, or the first K number with the highest occurrence frequency found in the mass data. For example, in a search engine, the top 10 query terms/the top 10 songs with the highest statistical download in a song library are statistically searched. Aiming at the TopK problem, the general scheme is to divide and treat +Trie tree/Hash +small top heap, namely, firstly, decompose a data set into a plurality of small data sets according to a Hash method, then use Trie tree/Hash to count the query word frequency in each small data set, then use the small top heap to calculate the top K number with the highest occurrence frequency in each data set, finally, collect the TopK of each data set and calculate the final TopK.
S107, generating prompt information based on the context and the user input problem, inputting the prompt information into a large language model, and generating a problem result;
Specifically, in this step, the understanding and generating capability of the large language model is utilized, and the problem result is output according to the prompt information in the form of natural language, so as to provide advice. In addition, for the finally generated problem result, knowledge linking can be carried out on the result and knowledge in the knowledge graph, so that quotation is provided for the problem result, and a user is assisted in verifying the problem result.
Combining S101 to S107, the book knowledge question-answering method based on the knowledge graph enhanced large language model further comprises the following steps:
And before S104 after S103, namely after the user input problem is acquired, carrying out intention classification on the user input problem based on the large language model to obtain an intention classification result.
Specifically, the intention classification is taken as a sub-module of spoken language understanding, and is also a key of the human-computer dialogue system. The intention is the intention of the user, i.e. what the user wants to do. Sometimes in the art, the intent is also referred to as "Dialog behavior" (Dialog Act), i.e., a behavior in which the user's state of information or context that is shared in a Dialog changes and is continually updated.
After the intention classification result is obtained, judging whether the user input problem is a complex problem or not based on the intention classification result, and if so, generating a problem result based on an inline architecture mode and an externally-hung architecture mode of the large language model.
Specifically, the complex questions refer to questions that require complex inference calculations to answer. The knowledge graph enhanced large language model reasoning in the scheme mainly comprises two modes of an inline architecture and an externally-hung architecture:
An inline architecture: knowledge in the knowledge graph is used for directly enhancing the reasoning capability of the strong model, and the knowledge graph also comprises two modes of enhancing the prompt construction of a thinking chain (Clain of Thought, coT) and enhancing the pre-training.
Enhanced thinking chain (Clain of Thought, coT) hint construction: according to the data element knowledge graph and the book knowledge graph, more prompt samples are automatically generated through knowledge substitution, deduction, association and other derivative modes according to given seed prompt samples, so that a large model is stimulated to realize stronger and wider reasoning;
Enhanced pre-training: similarly, according to a given template of a annotation data thinking chain (Clain of Thought, coT), the annotation data is automatically expanded by using knowledge in the knowledge graph, and after fine tuning training, the large model has more reasoning capacity.
Externally hung architecture: based on the thinking chain (Clain of Thought, coT) reasoning ability of the large language model, the knowledge graph reasoning engine is connected in an externally hung mode, so that the reasoning ability is improved. In the plug-in architecture mode, the decomposition of the complex task is completed by a large model (according to the input prompt), and when complex reasoning calculation needs to be called in the task execution process, the reasoning of the knowledge graph is called in the modes of plug-in, interface and the like.
In practical application, the two modes are usually combined, and for the explicit large model, the task of reasoning calculation which is difficult to perform (even through fine tuning training) or has quite high results is realized by directly considering the plug-in mode; meanwhile, in order to excite the emerging capability of the large model in the reasoning task, the annotation data based on the knowledge graph can be automatically generated, so that the fine tuning training of the large model is better completed.
Specifically, the inference computing capability that the knowledge graph can provide includes:
Complex graph analysis mining: the current large model has weaker joint association calculation analysis capability among multiple entities and needs to be realized by combining an external engine;
complex logical reasoning calculation: for complex, multi-entity joint, business process combining and other reasoning calculations, the implementation is usually required under strict semantic constraints, and the large model needs to utilize external capabilities;
Space-time joint reasoning: the capability of combining temporal and spatial information and combined reasoning is not available in a large model at present, and an engine is required to be hung.
The book knowledge question-answering method based on the knowledge graph enhanced large language model extracts knowledge through the large language model and constructs a knowledge graph; obtaining an original document, logically dividing the original document by adopting a plurality of dividing methods to obtain fragments, inputting the fragments into a large language model for vectorization to obtain fragment vectors, and storing the fragment vectors into a vector library; acquiring a user input problem, carrying out knowledge linking based on the knowledge graph to obtain a plurality of knowledge, and inputting the plurality of knowledge into a large language model one by one to carry out vectorization to obtain a plurality of knowledge vectors; inputting the user input problem into a large language model for vectorization to obtain a complete problem vector; splicing the knowledge vectors and the complete problem vectors to obtain spliced vectors; performing similarity calculation on the spliced vectors and all segment vectors in a vector library to obtain similarity scores, and taking a preset number of segment vectors in all segment vectors as contexts according to the similarity scores; and generating prompt information based on the context and the user input problem, inputting the prompt information into a large language model, and generating a problem result. The method solves the problems that a large language model cannot be combined with a knowledge graph in the prior art, and further cannot be well applied to a book knowledge question-answering scene.
The invention relates to a book knowledge question-answering system embodiment flow chart based on a knowledge graph enhanced large language model; the embodiment of the invention provides a book knowledge question-answering system based on a knowledge graph enhanced large language model, which comprises the following modules:
The construction module is used for extracting knowledge through the large language model and constructing a knowledge graph;
The vector storage module is used for obtaining an original document, logically dividing the original document by adopting a plurality of dividing methods to obtain fragments, inputting the fragments into a large language model for vectorization to obtain fragment vectors, and storing the fragment vectors into the vector library;
The knowledge vector acquisition module is used for acquiring a user input problem, carrying out knowledge linking based on the knowledge graph to obtain a plurality of knowledge, and inputting the plurality of knowledge into a large language model one by one to carry out vectorization to obtain a plurality of knowledge vectors;
the complete question vector acquisition module is used for inputting the user input questions into a large language model for vectorization to obtain complete question vectors;
the splicing vector acquisition module is used for splicing the knowledge vectors and the complete problem vectors to obtain splicing vectors;
The context determining module is used for carrying out similarity calculation on the spliced vector and all the fragment vectors in the vector library to obtain a similarity score, and taking a preset number of fragment vectors in all the fragment vectors as contexts according to the similarity score;
and the question result generation module is used for generating prompt information based on the context and the user input questions, inputting the prompt information into the large language model and generating question results.
The building module is also for:
Constructing a book knowledge representation model, wherein the book knowledge representation model comprises a knowledge system, a book model and a domain service model;
And extracting a book knowledge representation model based on the large language model to obtain the knowledge graph.
The splice vector acquisition module is further configured to:
And setting a first splicing threshold value for the knowledge vector, setting a second splicing threshold value for the complete problem vector, and splicing the knowledge vector and the complete problem vector based on the first splicing threshold value and the second splicing threshold value to obtain a splicing vector.
Performing intention classification on the user input problem based on the large language model to obtain an intention classification result;
Judging whether the user input problem is a complex problem or not based on the intention classification result, and if so, generating a problem result based on an inline architecture mode and an externally-hung architecture mode of the large language model.
The book knowledge question-answering system based on the knowledge graph enhanced large language model further comprises a fine tuning module, wherein the fine tuning module is used for:
the large language model is fine-tuned based on zero and/or small sample learning methods.
The invention relates to a book knowledge question-answering system based on a knowledge graph enhanced large language model, wherein a construction module extracts knowledge through the large language model and constructs a knowledge graph; the method comprises the steps of obtaining an original document through a vector storage module, logically dividing the original document by adopting a plurality of dividing methods to obtain fragments, inputting the fragments into a large language model for vectorization to obtain fragment vectors, and storing the fragment vectors into a vector library; acquiring a user input problem through a knowledge vector acquisition module, carrying out knowledge linking based on the knowledge graph to obtain a plurality of knowledge, and inputting the plurality of knowledge into a large language model one by one to carry out vectorization to obtain a knowledge vector; inputting the user input problem into a large language model through a complete problem vector acquisition module to carry out vectorization, so as to obtain a complete problem vector; splicing the knowledge vector and the complete problem vector through a splicing vector acquisition module to obtain a splicing vector; performing similarity calculation on the spliced vector and all segment vectors in a vector library through a context determining module to obtain a similarity score, and taking the segment vector with the highest similarity score in all segment vectors as a context; and generating prompt information based on the context and the user input problem by a problem result generation module, and inputting the prompt information into the large language model to generate a problem result. The book knowledge question-answering method based on the knowledge graph enhanced large language model solves the problems that the large language model cannot be combined with the knowledge graph in the prior art, and further cannot be well applied to book knowledge question-answering scenes.
Fig. 2 is a schematic diagram of an entity structure of an electronic device according to an embodiment of the present invention, as shown in fig. 2, the electronic device 10 includes: a processor 101 (processor), a memory 102 (memory), and a bus 103;
Wherein, the processor 101 and the memory 102 complete communication with each other through the bus 103;
The processor 101 is configured to invoke program instructions in the memory 102 to perform the methods provided by the above-described method embodiments, including, for example: extracting knowledge through a large language model and constructing a knowledge graph; obtaining an original document, logically dividing the original document by adopting a plurality of dividing methods to obtain fragments, inputting the fragments into a large language model for vectorization to obtain fragment vectors, and storing the fragment vectors into a vector library; acquiring a user input problem, linking knowledge based on the knowledge graph to obtain a plurality of knowledge, and inputting the plurality of knowledge into a large language model one by one to carry out vectorization to obtain a knowledge vector; inputting the user input problem into a large language model for vectorization to obtain a complete problem vector; splicing the knowledge vector and the complete problem vector to obtain a spliced vector; performing similarity calculation on the spliced vectors and all segment vectors in a vector library to obtain similarity scores, and taking the segment vector with the highest similarity score in all segment vectors as a context; and generating prompt information based on the context and the user input problem, inputting the prompt information into a large language model, and generating a problem result.
The present embodiment provides a non-transitory computer readable storage medium storing computer instructions that cause a computer to perform the methods provided by the above-described method embodiments, for example, including: extracting knowledge through a large language model and constructing a knowledge graph; obtaining an original document, logically dividing the original document by adopting a plurality of dividing methods to obtain fragments, inputting the fragments into a large language model for vectorization to obtain fragment vectors, and storing the fragment vectors into a vector library; acquiring a user input problem, linking knowledge based on the knowledge graph to obtain a plurality of knowledge, and inputting the plurality of knowledge into a large language model one by one to carry out vectorization to obtain a knowledge vector; inputting the user input problem into a large language model for vectorization to obtain a complete problem vector; splicing the knowledge vector and the complete problem vector to obtain a spliced vector; performing similarity calculation on the spliced vectors and all segment vectors in a vector library to obtain similarity scores, and taking the segment vector with the highest similarity score in all segment vectors as a context; and generating prompt information based on the context and the user input problem, inputting the prompt information into a large language model, and generating a problem result.
Those of ordinary skill in the art will appreciate that: all or part of the steps for implementing the above method embodiments may be implemented by hardware associated with program instructions, where the foregoing program may be stored in a computer readable storage medium, and when executed, the program performs steps including the above method embodiments; and the aforementioned storage medium includes: various storage media such as ROM, RAM, magnetic or optical disks may store program code.
The apparatus embodiments described above are merely illustrative, wherein elements illustrated as separate elements may or may not be physically separate, and elements shown as elements may or may not be physical elements, may be located in one place, or may be distributed over a plurality of network elements. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment. Those of ordinary skill in the art will understand and implement the present invention without undue burden.
From the above description of the embodiments, it will be apparent to those skilled in the art that the embodiments may be implemented by means of software plus necessary general hardware platforms, or of course may be implemented by means of hardware. Based on such understanding, the foregoing technical solution may be embodied essentially or in a part contributing to the prior art in the form of a software product, which may be stored in a computer readable storage medium, such as ROM/RAM, a magnetic disk, an optical disk, etc., including several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the embodiments or the methods of some parts of the embodiments.
While the invention has been described in detail in the foregoing general description and specific examples, it will be apparent to those skilled in the art that modifications and improvements can be made thereto. Accordingly, such modifications or improvements may be made without departing from the spirit of the invention and are intended to be within the scope of the invention as claimed.

Claims (4)

1. The book knowledge question-answering method based on the knowledge graph enhanced large language model is characterized by comprising the following steps of:
Extracting knowledge and constructing a knowledge graph through a large language model, wherein the method comprises the following steps of: the method comprises the steps of constructing a book knowledge representation model, and providing knowledge to be extracted for a large language model, wherein the book knowledge representation model comprises a knowledge system, a book model and a domain service model, and extracting the book knowledge representation model based on the large language model to obtain a knowledge graph;
Fine tuning the large language model based on zero and/or small sample learning methods;
Obtaining an original document, logically dividing the original document by adopting a plurality of dividing methods to obtain fragments, inputting the fragments into a large language model for vectorization to obtain fragment vectors, and storing the fragment vectors into a vector library;
Acquiring a user input problem, carrying out knowledge linking based on the knowledge graph to obtain a plurality of knowledge, and inputting the plurality of knowledge into a large language model one by one to carry out vectorization to obtain a plurality of knowledge vectors;
after the user input problem is acquired, carrying out intention classification on the user input problem based on the large language model to obtain an intention classification result;
Judging whether the user input problem is a complex problem or not based on the intention classification result, if so, generating a problem result based on an inline architecture mode and an externally-hung architecture mode of the large language model;
when generating a problem result based on the inline architecture mode of the large language model, knowledge in the knowledge graph is used for directly enhancing the reasoning capacity of the large language model;
When a problem result is generated based on the plug-in architecture mode of the large language model, the knowledge graph reasoning engine is connected in a plug-in mode based on the enhanced reasoning capacity of the large language model;
inputting the user input problem into a large language model for vectorization to obtain a complete problem vector;
Splicing the knowledge vectors and the complete problem vectors to obtain spliced vectors;
Performing similarity calculation on the spliced vectors and all segment vectors in a vector library to obtain similarity scores, and taking a preset number of segment vectors in all segment vectors as contexts according to the similarity scores;
and generating prompt information based on the context and the user input problem, inputting the prompt information into a large language model, and generating a problem result.
2. The knowledge graph-enhanced large language model-based book knowledge question-answering method according to claim 1, wherein the logically dividing the original document into segments by using a plurality of dividing methods comprises:
fixed window partitioning, sliding window partitioning, page-wise partitioning, paragraph-wise partitioning, chapter-wise structure partitioning, and other logical partitioning are employed.
3. The knowledge graph-enhanced large language model-based book knowledge question answering method according to claim 1, wherein the splicing the plurality of knowledge vectors and the complete question vector to obtain a spliced vector comprises:
and carrying out weighted splicing on the knowledge vectors and the complete problem vectors to obtain spliced vectors.
4. The knowledge graph-enhanced large language model-based book knowledge question-answering method according to claim 1, wherein the generating of question results based on the large language model's inline architecture mode and external architecture mode further comprises:
in the plug-in architecture mode, decomposing the complex task is completed by the large language model;
And calling the reasoning of the knowledge graph in other modes when complex reasoning calculation needs to be called in the task execution process, wherein the other modes comprise a plug-in mode and an interface mode.
CN202410302941.4A 2024-03-18 2024-03-18 Book knowledge question-answering method based on knowledge graph enhanced large language model Active CN117891930B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410302941.4A CN117891930B (en) 2024-03-18 2024-03-18 Book knowledge question-answering method based on knowledge graph enhanced large language model

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410302941.4A CN117891930B (en) 2024-03-18 2024-03-18 Book knowledge question-answering method based on knowledge graph enhanced large language model

Publications (2)

Publication Number Publication Date
CN117891930A CN117891930A (en) 2024-04-16
CN117891930B true CN117891930B (en) 2024-06-11

Family

ID=90652114

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202410302941.4A Active CN117891930B (en) 2024-03-18 2024-03-18 Book knowledge question-answering method based on knowledge graph enhanced large language model

Country Status (1)

Country Link
CN (1) CN117891930B (en)

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117573843A (en) * 2024-01-15 2024-02-20 图灵人工智能研究院(南京)有限公司 Knowledge calibration and retrieval enhancement-based medical auxiliary question-answering method and system

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117573843A (en) * 2024-01-15 2024-02-20 图灵人工智能研究院(南京)有限公司 Knowledge calibration and retrieval enhancement-based medical auxiliary question-answering method and system

Also Published As

Publication number Publication date
CN117891930A (en) 2024-04-16

Similar Documents

Publication Publication Date Title
Zhao et al. Dense text retrieval based on pretrained language models: A survey
CN107679039B (en) Method and device for determining statement intention
US11544474B2 (en) Generation of text from structured data
US20230008897A1 (en) Information search method and device, electronic device, and storage medium
CN113505601A (en) Positive and negative sample pair construction method and device, computer equipment and storage medium
Hassani et al. LVTIA: A new method for keyphrase extraction from scientific video lectures
Aladakatti et al. Exploring natural language processing techniques to extract semantics from unstructured dataset which will aid in effective semantic interlinking
CN111831624A (en) Data table creating method and device, computer equipment and storage medium
US20220222442A1 (en) Parameter learning apparatus, parameter learning method, and computer readable recording medium
CN112686053A (en) Data enhancement method and device, computer equipment and storage medium
CN116955591A (en) Recommendation language generation method, related device and medium for content recommendation
CN114842982B (en) Knowledge expression method, device and system for medical information system
CN117891930B (en) Book knowledge question-answering method based on knowledge graph enhanced large language model
CN117033649A (en) Training method and device for text processing model, electronic equipment and storage medium
CN115358397A (en) Parallel graph rule mining method and device based on data sampling
CN112529743B (en) Contract element extraction method, device, electronic equipment and medium
CN111459959B (en) Method and apparatus for updating event sets
CN111914201B (en) Processing method and device of network page
CN111625623B (en) Text theme extraction method, text theme extraction device, computer equipment, medium and program product
CN117851577B (en) Government service question-answering method based on knowledge graph enhanced large language model
CN117195913B (en) Text processing method, text processing device, electronic equipment, storage medium and program product
CN117909505B (en) Event argument extraction method and related equipment
CN115495541B (en) Corpus database, corpus database maintenance method, apparatus, device and medium
CN116453702B (en) Data processing method, device, system and medium for autism behavior feature set
Kulkarni et al. Deep Reinforcement-Based Conversational AI Agent in Healthcare System

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant