A personalized question-answering method based on a universal large language model and knowledge graph
By combining the general large language model with the knowledge graph to build a transparent and reliable collaborative reasoning system, the unexplainability and misleading problems of the general large language model in smart education are solved, and personalized and efficient question-and-answer services are realized.
Patent Information
- Application Number
- CN202411663394.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-20
- Publication Date
- 2025-02-25
- Estimated Expiration
- 2044-11-20
AI Technical Summary
In the field of smart education, the general large language model as a question-and-answer assistant has uninterpretation and lacks transparency in the reasoning process, which leads to the answers that may be misleading or incorrect, affecting students' learning efficiency and knowledge system construction.
Combining the general large language model and knowledge graph, transparent and reliable collaborative reasoning is achieved through entity recognition, entity matching, knowledge sub-graph construction and large language model optimization, and integrating students' individual characteristics to provide personalized questions and answers.
It improves the accuracy and interpretability of Q&A, provides a transparent reasoning process, enhances students' learning effects, and realizes personalized teaching solutions.
Smart Images

Figure CN119149719B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of smart education technology, and in particular to a personalized question-answering method based on a general large language model and a knowledge graph. Background Art
[0002] The general large language model is an artificial intelligence-based language processing tool that can simulate human language comprehension and generation capabilities through learning from a large amount of text data. In the field of smart education, the general large language model is usually used as a teaching assistant to answer students' questions. This real-time teaching method can not only improve students' learning efficiency, but also stimulate their interest in learning, making education more intelligent.
[0003] However, using a general large language model directly as a question-answering method still has shortcomings in the field of smart education. The general large language model is essentially a black box, which is unexplainable and lacks transparency in its reasoning process. In addition, the general large model will perform output operations regardless of whether it understands the user's needs or not, which will cause the answers generated by the model to appear reasonable, but in fact may be misleading or wrong. Since students generally have difficulty in evaluating whether the information generated by the model is correct, the general large language model is likely to mislead students in the process of questioning and answering with students, which in turn affects their learning efficiency and knowledge system construction.
[0004] As a teaching assistant for students, it is necessary to ensure the accuracy and interpretability of answers to questions as much as possible during the process of asking and answering questions with students. Since the general large language model can only use various implicit information absorbed during the training process when communicating with students, in order to improve the accuracy and interpretability of the model's answers to students' questions, it is possible to consider adding additional reasoning information to it.
[0005] Knowledge graph is a structured form of knowledge expression, which expresses the relationship between entities in the real world in the form of a graph, thereby forming a complex networked knowledge structure. Knowledge graph is structured and interpretable, and can provide knowledge support for fields such as artificial intelligence by providing rich and accurate background knowledge. Therefore, knowledge graph can be selected as a supplement to the general large language model to help it better understand and generate text, improve the accuracy and interpretability of answers, and provide the possibility of handling more complex needs.
[0006] There are currently two main ways to integrate knowledge graphs into large language models. One is to use the knowledge graph as a corpus for training the large language model. However, since the knowledge graph information will be swallowed up by a large amount of other corpus, it is difficult to play the powerful role of the knowledge graph in a targeted manner. Another way is to convert the knowledge graph into prompt words after the large language model is trained for the large language model to understand and learn. This method can make targeted use of the knowledge graph and thus play the powerful role of the knowledge graph. However, as a special form of data, it is often difficult for the large language model to understand the knowledge structure represented by the knowledge graph by directly inputting the triples representing the knowledge graph into the model.
[0007] One of the core elements of smart education is personalized teaching, which emphasizes providing customized teaching plans based on each student's learning style, knowledge background, and interests to improve learning efficiency and interest and promote students' all-round development. After combining the general large language model with the knowledge graph as a question-and-answer assistant for students, the personalization of questions and answers should also be guaranteed. For example, when students have different levels of mastery of various knowledge points, the student learning paths recommended by the large language model should be different. Therefore, it is necessary to effectively integrate personal information such as student learning status into the general large language model so that the model can further understand student needs and provide students with diversified and personalized question-and-answer suggestions.
[0008] When facing the special field of smart education, the technical solutions in the existing technology often directly use the general large language model as a question-answering assistant. This question-answering method lacks accuracy and explainability. To solve this problem, knowledge graphs can be used for auxiliary reasoning. However, how to make the large language model understand the knowledge structure of the knowledge graph and integrate the individual characteristics of students in the process to achieve personalized question-answering is still a challenging task. Summary of the invention
[0009] In order to solve the above technical problems, the present invention provides a personalized question-answering method based on a general large language model and a knowledge graph, which combines the implicit knowledge of the general large language model with the explicit knowledge of the knowledge graph to achieve transparent and reliable collaborative reasoning; in the process of combining, the individual characteristics of students are effectively integrated to achieve personalized question-answering.
[0010] In order to solve the above technical problems, the present invention adopts the following technical solutions:
[0011] A personalized question-answering method based on a general large language model and a knowledge graph includes the following steps:
[0012] Step 1: Use the large language model to perform entity recognition on the obtained student question Q, identify the named entities in the question Q, and construct a named entity set; use the entity matching algorithm to match the named entity set with the knowledge entities in the knowledge graph, and construct the matched knowledge entities into a relevance entity set R;
[0013] Step 2: Take each knowledge entity r in the association entity set R as a core entity, search the knowledge graph with the core entity as the center, and save the knowledge entities that meet the preservation conditions and the relationships between knowledge entities during the search process. The knowledge entity r, the knowledge entities that meet the preservation conditions, and the relationships between knowledge entities constitute a knowledge subgraph and store them in the form of triples to obtain a knowledge subgraph set. ;
[0014] Step 3: Collect the knowledge subgraphs All triples used to represent knowledge subgraphs are placed together to form an aggregate graph B of the knowledge subgraph; the aggregate graph is optimized using a large language model, and the optimized result is used as the knowledge graph ;
[0015] Step 4: Learning the large language model in the prompt and After the structure is constructed, the large language model is required to combine its own multi-round dialogue capabilities, its own existing knowledge and the knowledge obtained from the external knowledge graph to answer students' questions and provide reasoning process.
[0016] Furthermore, step one specifically includes named entity recognition and entity matching;
[0017] Named entity recognition includes: constructing a prompt word 1 for the student's question Q, setting the identity of the teacher for the large language model in the prompt word 1, and allowing the large language model to pay more attention to the knowledge points when searching for the named entities in the question Q, thereby obtaining the named entity set ;in The nth named entity identified by the large language model;
[0018] Entity matching includes: knowledge entity set of knowledge graph ,in is the mth knowledge entity in the knowledge graph, and m is the total number of knowledge entities in the knowledge graph;
[0019] Use the BERT encoder to encode each named entity in the named entity set C into a named entity vector , set the knowledge entity The knowledge entities in are encoded as knowledge entity vectors ;calculate With each The cosine similarity of :
[0020] ;
[0021] in, for and The inner product of and They are and Length;
[0022] If the cosine similarity Greater than the set threshold , then The corresponding knowledge entity e is placed in the set T;
[0023] After performing a deduplication operation on the set T, the associative entity set is obtained. , for The knowledge entity, is the total number of knowledge entities in the associative entity set.
[0024] Furthermore, the step of constructing a prompt word 1 for the student's question Q and setting the identity of the teacher for the large language model in the prompt word 1 specifically includes:
[0025] ;
[0026] Among them, smooth means the operation of splicing using statements. Indicates setting the teacher identity for the large language model. Indicates prompt word one.
[0027] Furthermore, step 2 specifically includes:
[0028] For each knowledge entity r, two search strategies are implemented during the search process, including neighbor search for local information mining and path search for long-distance dependency capture; the neighbor knowledge subgraph set obtained by neighbor search is And the path knowledge subgraph set obtained by path search Perform a merge operation to obtain the knowledge subgraph set ;
[0029] When performing neighbor search, the search path length is always 1, that is, only the neighbor knowledge entities directly connected to the core entity are searched; whether the neighbor knowledge entities of the core entity can be saved depends on the conceptual relevance of the neighbor knowledge entity and the knowledge entity r and the individual characteristics of the students:
[0030] By calculating the cosine similarity between the vectors of the neighbor knowledge entity and the knowledge entity r, the conceptual relevance between the neighbor knowledge entity and the knowledge entity r is judged; if the cosine similarity between the vectors of the neighbor knowledge entity and the knowledge entity r is greater than the threshold , then the concepts between the neighbor knowledge entity and knowledge entity r are related, and the corresponding neighbor knowledge entity meets condition one;
[0031] The individual characteristics of students include students' academic ability and students' interests;
[0032] According to the learning situation, the students' academic ability is divided into different academic ability levels, and the knowledge points are divided into different difficulty levels. If the academic ability level of the student St is greater than or equal to the difficulty level of the knowledge point, then the neighbor knowledge entity of the core entity corresponding to the knowledge point meets the second condition;
[0033] The knowledge entities in which the student St is interested in the knowledge graph are counted. If the neighbor knowledge entity belongs to the knowledge entity in which the student St is interested, then the neighbor knowledge entity meets condition three;
[0034] If the neighbor knowledge entity meets condition one and meets any one of condition two and condition three, then the preservation condition is met, and the neighbor knowledge entity, knowledge entity r, and the relationship between knowledge entity r and the neighbor knowledge entity are saved to form a neighbor knowledge subgraph g stored in the form of triples;
[0035] Perform neighbor search for each knowledge entity in the associated entity set R to obtain a neighbor knowledge subgraph set , for The Neighborhood knowledge subgraphs, is the total number of knowledge entities r in the relational entity set R;
[0036] The difference between path search and neighbor search is that: when performing path search, different search path lengths are set according to the academic level of the student St. The higher the academic level, the longer the search path length. If an entity that does not meet the preservation condition is encountered during the search, the current search path is terminated, and the neighbor knowledge entity that meets the preservation condition, the knowledge entity r, and the relationship between the knowledge entity r and the neighbor knowledge entity constitute a path knowledge subgraph p stored in the form of triples;
[0037] Perform path search for each knowledge entity in the association entity set R to obtain a path knowledge subgraph set ; for The Path knowledge subgraph;
[0038] Merge the neighbor knowledge subgraph set G with the path knowledge subgraph set P to obtain the final knowledge subgraph set .
[0039] Furthermore, step three specifically includes:
[0040] The knowledge subgraph collection All the triples used to represent the knowledge subgraph in are placed together to form an aggregate graph B of the knowledge subgraph; a prompt word 2 is constructed, and the identity of the knowledge graph research expert is set for the large language model in the prompt word 2 to prompt the large language model to optimize the aggregate graph B and obtain the knowledge graph .
[0041] Furthermore, the construction prompt word two , and set the identity of the knowledge graph research expert for the large language model in prompt word 2, including:
[0042] ;
[0043] Among them, smooth means the operation of splicing using statements. Represents setting the knowledge graph research expert identity for the large language model.
[0044] Furthermore, step four specifically includes:
[0045] For question Q, use the LangChain tool to set up three rounds of dialogue to guide the large language model. In the process of using the LangChain tool, set the system message based on the educational scenario, and design the user message of the three rounds of dialogue according to the following content to guide the large language model:
[0046] The user message construction method for the first round of dialogue is: prompting the large language model to use natural language to describe the structure of each knowledge subgraph in the knowledge subgraph set A;
[0047] How to construct user messages in the second round of conversation: prompt the large language model to describe the knowledge graph in natural language , and requires the large language model to generate the reasoning path between nodes in the knowledge graph;
[0048] The third round of user message construction method is to send the student's question to the big language model, and prompt the big language model to think based on its own knowledge and the knowledge obtained from the external knowledge graph, answer the student's question and return the reasoning process;
[0049] The answer of the large language model in the third round of dialogue is returned to the student as the answer to the question Q and the reasoning process is provided to the student.
[0050] Compared with the prior art, the beneficial technical effects of the present invention are:
[0051] The present invention effectively combines the implicit knowledge of a general large language model with the explicit knowledge of a knowledge graph, thereby achieving transparent and reliable collaborative reasoning. This combination not only utilizes the powerful language understanding and generation capabilities of a large language model, but also utilizes the structured knowledge of a knowledge graph, making the answers to questions more accurate and in-depth. At the same time, the present invention effectively incorporates the individual characteristics of students in the process of constructing a knowledge subgraph, making it possible to personalize questions and answers. Finally, in the process of answering questions, the present invention not only provides answers, but also provides a reasoning process, which helps students understand and remember, and can effectively improve students' learning outcomes. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] Figure 1 Flow chart of the personalized question-answering method of the present invention. DETAILED DESCRIPTION
[0053] A preferred embodiment of the present invention is described in detail below with reference to the accompanying drawings.
[0054] The personalized question-answering method based on a universal large language model and a knowledge graph in the smart education scenario of the present invention includes the following steps:
[0055] S1: Student question analysis. After obtaining the questions input by students, we first use the general large language model to perform entity recognition, identify the named entities in the questions, and build a named entity set. Then, we use the entity matching algorithm to match the named entity set with the corresponding knowledge entities in the knowledge graph, and build the matched knowledge entities into a relevance entity set.
[0056] The large language model in the present invention can select the current mainstream commercial large language dialogue model, such as OpenAI's ChatGPT, iFlytek's Spark, Baidu's Wenxin Yiyan, Alibaba's Tongyi Qianwen, etc.
[0057] Step S1 specifically includes two steps, namely named entity recognition and entity matching.
[0058] Named Entity Recognition: The core purpose of this stage is to find the named entities in the questions asked by students. With the powerful language understanding ability of the general large language model, this task can be directly used. For the student's question Q, construct prompt words, set the identity of the teacher for the large language model, and let the large language model pay more attention to the knowledge points in the process of finding named entities in the student's questions, so that the named entity set can be obtained efficiently. The construction formula is as follows:
[0059] ;
[0060] Among them, smooth means the operation of splicing related information using smooth sentences. Denotes the identity set for the large language model, and Q represents the student’s question.
[0061] In a preferred embodiment, the template of prompt word 1 is as follows:
[0062] prompt1 = "You are an experienced teacher, and a student asked you the question [" + Q + "]. Based on your teaching experience, please find the named entities in the student's question. The search criteria are named entities related to teaching knowledge points. Please return the results to me in the form of a set, and no additional description other than the set is required."
[0063] After formatting the collection returned by the large language model, the named entity set is obtained. ,in, The nth entity recognized by the large language model.
[0064] Entity matching: The purpose of this stage is to find matching knowledge entities in the knowledge graph, laying the foundation for the subsequent acquisition of knowledge subgraphs. The knowledge graph for knowledge points needs to be constructed manually, and experts will construct a knowledge graph stored in the form of triples. Knowledge entity set of the knowledge graph ,in is the mth knowledge entity in the knowledge graph, and m is the total number of knowledge entities in the knowledge graph; the BERT encoder is used to encode each named entity in the named entity set C into a named entity vector , set the knowledge entity The knowledge entities in are encoded as knowledge entity vectors ; Calculate each With each The cosine similarity of :
[0065] ;
[0066] in, for and The inner product of and They are and Length.
[0067] If the cosine similarity Greater than the set threshold , then The corresponding knowledge entity e is placed in the set T. Since the knowledge entities in the knowledge graph may be related to multiple named entities in C, it is necessary to perform a deduplication operation on the set T to finally obtain the associated entity set , for The knowledge entity, is the total number of knowledge entities in the associative entity set. Both named entities and knowledge entities are knowledge points.
[0068] S2: Knowledge subgraph acquisition: Take each knowledge entity r in the associative entity set R as a core entity, search the knowledge graph with the core entity as the center, and save the knowledge entities that meet the preservation conditions and the relationships between knowledge entities during the search process. The knowledge entity r, the knowledge entities that meet the preservation conditions, and the relationships between knowledge entities constitute a knowledge subgraph and store them in the form of triples; for each core entity, two search strategies are executed during the search process, including neighbor search for local information mining and path search for long-distance dependency capture; the neighbor knowledge subgraph set obtained by the neighbor search And the path knowledge subgraph set obtained by path search Perform a merge operation to obtain a knowledge subgraph set ;
[0069] Step S2 specifically includes:
[0070] Each knowledge entity r in the associative entity set R is taken as a core entity, and the knowledge graph is searched with it as the center. The preservation conditions are set to save the knowledge entities and relationships in the search process. Finally, the neighbor knowledge entities, knowledge entity r, and the relationship between the neighbor knowledge entity and knowledge entity r that meet the preservation conditions will constitute a knowledge subgraph and be stored in the form of triples. For each knowledge entity r, two search strategies will be executed: neighbor search and path search.
[0071] Neighbor search only searches for the direct neighbors of knowledge entity r, that is, only searches for neighbor knowledge entities that are directly connected to the core entity. Whether the neighbor knowledge entities of the core entity can be saved depends on the conceptual relevance of the neighbor knowledge entities to knowledge entity r and the individual characteristics of the students.
[0072] For concept relevance, the same method as entity matching is used to determine the concept relevance between the neighbor knowledge entity and the knowledge entity r by calculating the cosine similarity between the vectors after entity representation. If the cosine similarity between the vectors of the neighbor knowledge entity and the knowledge entity r is greater than the threshold , then the concepts between the neighbor knowledge entity and knowledge entity r are related, and the corresponding neighbor knowledge entity meets condition one.
[0073] In view of the individual characteristics of students, the main considerations are students' academic ability and interests. Students' academic ability is analyzed, and the number of questions answered and the correct ratio are comprehensively considered. Experts mark the students' academic ability levels and divide the students into three categories: junior scholars, intermediate scholars, and advanced scholars. At the same time, in the process of constructing the knowledge graph, experts set the difficulty level of knowledge points according to the three levels of students' academic ability, which are divided into low, intermediate, and advanced levels. If the student's academic ability level is greater than or equal to the difficulty level of the knowledge point, the neighbor knowledge entity is said to meet condition two. The explanation of the academic ability level being greater than or equal to the difficulty level of the knowledge point is as follows: for junior scholars, their academic ability level is greater than or equal to the low difficulty level; for intermediate scholars, their academic ability level is greater than or equal to the low difficulty level and the intermediate difficulty level; for advanced scholars, their academic ability level is greater than or equal to the low difficulty level, the intermediate difficulty level, and the advanced difficulty level.
[0074] Research students’ interests and count which knowledge entities in the knowledge graph students have a strong interest in. If a neighbor entity is within the students’ interest range, the neighbor knowledge entity is said to meet condition three.
[0075] If the neighbor node meets one of the conditions 2 and 3 under the premise of meeting condition 1, the neighbor knowledge entity, knowledge entity r and the relationship between the two are saved to form a neighbor knowledge subgraph g stored in the form of triples. Perform a neighbor search for each knowledge entity in the association entity set R to obtain the neighbor knowledge subgraph set , for The Neighborhood knowledge subgraphs, is the total number of knowledge entities r in the relational entity set R.
[0076] The path search starts with knowledge entity r, and sets the path length to limit the search depth. If a neighbor knowledge entity that does not meet the preservation conditions is encountered during the search process, the search is terminated in time, and the neighbor knowledge entity that meets the preservation conditions, the knowledge entity r, and the relationship between the knowledge entity r and the neighbor knowledge entity are formed into a path knowledge subgraph p stored in the form of a triple. The preservation conditions of the path search are the same as those of the neighbor search. Both retain those neighbor knowledge entities that match the student's academic level or meet the student's interests under the premise of concept relevance. Unlike the neighbor search, the path search needs to set the search path length to limit the search depth. The search path length of the neighbor search is always 1, while the search path length of the path search is related to the student's academic level. Considering that students with stronger academic levels are more likely to understand deeper entity concepts, the present invention sets different search path lengths according to different academic levels. For junior scholars, the corresponding search path length is set to 2; for intermediate scholars, the corresponding search path length is set to 3; for advanced scholars, the corresponding search path length is set to 4.
[0077] Perform path search for each knowledge entity in the association entity set R to obtain a path knowledge subgraph set ; for The A path knowledge subgraph.
[0078] Merge the neighbor knowledge subgraph set G with the path knowledge subgraph set P to obtain the final knowledge subgraph set .
[0079] S3: Knowledge subgraph aggregation: All triples representing knowledge subgraphs are placed together to form an aggregate graph of knowledge subgraphs; the aggregate graph is optimized using a large language model and the optimized result is used as a knowledge graph .
[0080] Step 3 specifically includes: Since all knowledge subgraphs are obtained from the same knowledge graph, there is no need to perform data cleaning and other operations during the subgraph aggregation process. All the triples used to represent the knowledge subgraph are placed together to form the aggregate graph B of the knowledge subgraph; since the coupling and duplication relationship is not taken into account during the acquisition of the knowledge subgraph, the aggregate graph B needs to be re-optimized. The present invention uses the understanding ability of the general large language model to directly optimize the aggregate graph. Constructing prompt word 2 to prompt the large language model to optimize the aggregate graph B can efficiently obtain the optimized knowledge graph. The construction formula is as follows:
[0081] ;
[0082] Among them, smooth means the operation of splicing using statements. Indicates setting the knowledge graph research expert identity for the large language model,
[0083] Prompt word 2 The template is as follows:
[0084] prompt2 = "You are a knowledge graph research expert. Now you have a knowledge graph in the form of triples: [" + B + "]. The various relationships in this knowledge graph are directly extracted from another large knowledge graph, so there are various problems such as relationship duplication. Please optimize the knowledge graph I gave you and return the optimized knowledge graph to me in the form of triples. No other additional description is required."
[0085] Format the collection returned by the large language model to obtain the knowledge graph .
[0086] S4: Reasoning of large language models: Based on the multi-round dialogue capability of the large language model, guide the large language model to achieve collaborative reasoning; prompt the large language model to learn the knowledge subgraph set With the knowledge graph After the structure is constructed, the large language model is required to combine its own existing knowledge with the knowledge obtained from the external knowledge graph to answer students' questions and provide reasoning process.
[0087] Step S4 specifically includes: The core goal of this step is to utilize the multi-round dialogue capability of the large language model to help the large language model absorb the knowledge graph auxiliary information obtained in the above steps. For each question of the student, the present invention uses the LangChain tool to set up three rounds of dialogue to guide the general large language model. As a tool for building and executing complex dialogue systems, the LangChain tool can effectively guide and manage the interaction with the general large language model through context management and dialogue flow control, and can help generate and maintain consistent dialogue history records to ensure that the large language model maintains coherence and contextual relevance in the dialogue.
[0088] In the process of using the LangChain tool, it is necessary to set the system message (SyStem Message) to preset the basic cognition of the large language model. Taking into account the application scenario of smart education, the system information of the present invention is set to "You are a teacher with rich experience, good at using knowledge graphs to guide students to learn, please perform related tasks according to my requirements next". After this operation, the general large language model has a basic understanding, and then only the user message (Human Message) needs to be set to guide the large language model. In response to the student's question Q, the present invention sets up the following three rounds of dialogue:
[0089] 1) Absorb local information of the knowledge graph: prompt the large language model to use natural language to describe the structure of each knowledge subgraph in the knowledge subgraph set A. The human message is set as: "There is a knowledge subgraph set: {A}. Please use natural language to describe each knowledge subgraph in the knowledge subgraph set. Please think from a teaching perspective and try to explain the rich teaching knowledge contained in the knowledge subgraph in the description process."
[0090] 2) Absorbing global information of the knowledge graph: Prompt the big language to describe the knowledge graph in natural language and ask it to generate the reasoning path between nodes of the knowledge graph. The user message (Human Message) is: "There is a knowledge graph in the form of a triple: { }, please first use natural language to describe this knowledge graph. Then, think step by step and give all possible reasoning paths in this knowledge graph and the paths between nodes.
[0091] 3) Get answers to questions: Send the student's question to the big language model, and prompt the big language model to think based on its own knowledge and the knowledge input from the external knowledge graph, answer the student's question and return the reasoning process. The user message (Human Message) is: "You have a student who asked you the question {Q}. Please think collaboratively based on your own knowledge and the knowledge you have absorbed from the previous two conversations to answer the student's question. At the same time, in order to ensure the accuracy and explainability of the answer, please give the reasoning process of your answer. Please think step by step before answering."
[0092] Through the above dialogue process, the answer of the large language model in the third round of dialogue is returned to the student. The final answer is highly accurate, and there is a reasonable reasoning process to explain the answer.
[0093] It is obvious to those skilled in the art that the present invention is not limited to the details of the exemplary embodiments described above, and that the present invention can be implemented in other specific forms without departing from the spirit or essential features of the present invention. Therefore, from any point of view, the embodiments should be regarded as exemplary and non-limiting, and the scope of the present invention is defined by the appended claims rather than the above description, and it is intended that all changes falling within the meaning and scope of the equivalent elements of the claims are included in the present invention, and any reference numerals in the claims should not be regarded as limiting the claims involved.
[0094] In addition, it should be understood that although this specification is described in terms of implementation methods, not every implementation method contains only one independent technical solution. This narrative method of the specification is only for the sake of clarity. Those skilled in the art should regard the specification as a whole. The technical solutions in each embodiment may also be appropriately combined to form other implementation methods that can be understood by those skilled in the art.
Claims
1. A personalized question-answering method based on a general large language model and a knowledge graph, comprising the following steps: Step 1: Use the large language model to perform entity recognition on the obtained student question Q, identify the named entities in the question Q, and construct a named entity set; use the entity matching algorithm to match the named entity set with the knowledge entities in the knowledge graph, and construct the matched knowledge entities into a relevance entity set R; Step 2: Take each knowledge entity r in the association entity set R as a core entity, search the knowledge graph with the core entity as the center, and save the knowledge entities that meet the preservation conditions and the relationships between knowledge entities during the search process. The knowledge entity r, the knowledge entities that meet the preservation conditions, and the relationships between knowledge entities constitute a knowledge subgraph and store them in the form of triples to obtain a knowledge subgraph set. ; Step 3: Collect the knowledge subgraphs All triples used to represent knowledge subgraphs are placed together to form an aggregate graph B of the knowledge subgraph; the aggregate graph is optimized using a large language model, and the optimized result is used as the knowledge graph ; Step 4: Learning the large language model in the prompt and After the structure is constructed, the large language model is required to combine its own multi-round dialogue capabilities, its own existing knowledge and the knowledge obtained from the external knowledge graph to answer students' questions and provide reasoning process; Step 1 specifically includes named entity recognition and entity matching; Named entity recognition includes: constructing a prompt word 1 for the student's question Q, setting the identity of the teacher for the large language model in the prompt word 1, and allowing the large language model to pay more attention to the knowledge points when searching for the named entities in the question Q, thereby obtaining the named entity set ;in The nth named entity identified by the large language model; Entity matching includes: knowledge entity set of knowledge graph ,in is the mth knowledge entity in the knowledge graph, and m is the total number of knowledge entities in the knowledge graph; Use the BERT encoder to encode each named entity in the named entity set C into a named entity vector , set the knowledge entity The knowledge entities in are encoded as knowledge entity vectors ;calculate With each Cosine similarity of : ; in, for and The inner product of and They are and Length; If the cosine similarity Greater than the set threshold , then The corresponding knowledge entity e is placed in the set T; After performing a deduplication operation on the set T, the associative entity set is obtained. , for The knowledge entity, is the total number of knowledge entities in the associative entity set; Step 2 specifically includes: for each knowledge entity r, two search strategies are executed during the search process, including neighbor search for local information mining and path search for long-distance dependency capture; the neighbor knowledge subgraph set obtained by neighbor search is And the path knowledge subgraph set obtained by path search Perform a merge operation to obtain the knowledge subgraph set ; When performing neighbor search, the search path length is always 1, that is, only the neighbor knowledge entities directly connected to the core entity are searched; whether the neighbor knowledge entities of the core entity can be saved depends on the conceptual relevance of the neighbor knowledge entity and the knowledge entity r and the individual characteristics of the students: By calculating the cosine similarity between the vectors of the neighbor knowledge entity and the knowledge entity r, the conceptual relevance between the neighbor knowledge entity and the knowledge entity r is judged; if the cosine similarity between the vectors of the neighbor knowledge entity and the knowledge entity r is greater than the threshold , then the concepts between the neighbor knowledge entity and knowledge entity r are related, and the corresponding neighbor knowledge entity meets condition one; The individual characteristics of students include students' academic ability and students' interests; According to the learning situation, the students' academic ability is divided into different academic ability levels, and the knowledge points are divided into different difficulty levels. If the academic ability level of the student St is greater than or equal to the difficulty level of the knowledge point, then the neighbor knowledge entity of the core entity corresponding to the knowledge point meets the second condition; The knowledge entities in which the student St is interested in the knowledge graph are counted. If the neighbor knowledge entity belongs to the knowledge entity in which the student St is interested, then the neighbor knowledge entity meets condition three; If the neighbor knowledge entity meets condition one and meets any one of condition two and condition three, then the preservation condition is met, and the neighbor knowledge entity, knowledge entity r, and the relationship between knowledge entity r and the neighbor knowledge entity are saved to form a neighbor knowledge subgraph g stored in the form of triples; Perform neighbor search for each knowledge entity in the associated entity set R to obtain a neighbor knowledge subgraph set , for The Neighborhood knowledge subgraphs, is the total number of knowledge entities r in the relational entity set R; The difference between path search and neighbor search is that: when performing path search, different search path lengths are set according to the academic level of the student St. The higher the academic level, the longer the search path length. If an entity that does not meet the preservation condition is encountered during the search, the current search path is terminated, and the neighbor knowledge entity that meets the preservation condition, the knowledge entity r, and the relationship between the knowledge entity r and the neighbor knowledge entity constitute a path knowledge subgraph p stored in the form of triples; Perform path search for each knowledge entity in the association entity set R to obtain a path knowledge subgraph set ; for The Path knowledge subgraph; Merge the neighbor knowledge subgraph set G with the path knowledge subgraph set P to obtain the final knowledge subgraph set ; Step 3 specifically includes: collecting knowledge subgraphs All the triples used to represent the knowledge subgraph in are placed together to form an aggregate graph B of the knowledge subgraph; a prompt word 2 is constructed, and the identity of the knowledge graph research expert is set for the large language model in the prompt word 2 to prompt the large language model to optimize the aggregate graph B and obtain the knowledge graph ; Step 4 specifically includes: for question Q, use the LangChain tool to set up three rounds of dialogue to guide the large language model; in the process of using the LangChain tool, set the system message based on the educational scenario, and design the user message of the three rounds of dialogue according to the following content to guide the large language model: The user message construction method for the first round of dialogue is: prompting the large language model to use natural language to describe the structure of each knowledge subgraph in the knowledge subgraph set A; How to construct user messages in the second round of conversation: prompt the large language model to describe the knowledge graph in natural language , and requires the large language model to generate the reasoning path between nodes in the knowledge graph; The third round of user message construction method is to send the student's question to the big language model, and prompt the big language model to think based on its own knowledge and the knowledge obtained from the external knowledge graph, answer the student's question and return the reasoning process; The answer of the large language model in the third round of dialogue is returned to the student as the answer to the question Q and the reasoning process is provided to the student.
2. The personalized question-answering method based on a general large language model and a knowledge graph according to claim 1, characterized in that: The step of constructing a prompt word 1 for the student's question Q and setting the identity of the teacher for the large language model in the prompt word 1 specifically includes: ; Among them, smooth means the operation of splicing using statements. Indicates setting the teacher identity for the large language model. Indicates prompt word one.
3. The personalized question-answering method based on a general large language model and a knowledge graph according to claim 1, characterized in that: The construction prompt word 2 , and set the identity of the knowledge graph research expert for the large language model in prompt word 2, including: ; Among them, smooth means the operation of splicing using statements. Represents setting the knowledge graph research expert identity for the large language model.
Citation Information
Patent Citations
Question answering method combining sequence model and knowledge graph
CN116127095A
Abnormality detection model training method, anomaly detection method, anomaly detection device and electronic equipment
CN116403077A