Dialogue generation method and device, electronic equipment, storage medium and computer program product
By setting instruction templates and using a self-encoding LLM to process user input text, and combining knowledge graphs for single-hop retrieval and entity and relation recognition, the most accurate and reliable answer statements are generated. This solves the problems of inconsistent knowledge in large language models and insufficient language capabilities of knowledge graphs, and achieves the authenticity and fluency of knowledge generated in dialogues.
Patent Information
- Application Number
- CN202510020944.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-02
- Publication Date
- 2025-11-07
- Estimated Expiration
- 2045-01-02
AI Technical Summary
Existing language models suffer from inconsistent knowledge and knowledge graphs are unable to generate natural and fluent text in real time, resulting in insufficient knowledge authenticity and language proficiency in dialogue generation.
By setting instruction templates and processing user input text using a self-encoding large language model (LLM), and combining knowledge graphs for single-hop retrieval and entity and relation identification, the most relevant entity and relation types are generated, triple information is constructed, and response statements are generated.
It improves the authenticity of knowledge and the fluency of language in the generated dialogue, solves the problems of knowledge inconsistency and insufficient language ability, and generates the most accurate and credible response statements.
Smart Images

Figure CN120045658B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of artificial intelligence, in particular to a dialogue generation method and device, electronic equipment, storage medium and computer program product. BACKGROUND
[0002] In order to generate a dialogue for a user input text, when a related language large model is used, the authenticity and reliability of the knowledge referenced by the language large model cannot be guaranteed, so there is a problem that the knowledge in the language large model is inconsistent with the knowledge in the real world; and when a knowledge graph is used, the knowledge graph returns static text in the dialogue question and answer, and cannot generate natural and fluent text in real time, so there is a problem of insufficient language ability. SUMMARY
[0003] To solve the related technical problems, the present application provides a dialogue generation method and device, electronic equipment, storage medium and computer program product.
[0004] The technical scheme of the present application embodiment is implemented as follows:
[0005] The present application embodiment provides a dialogue generation method, which comprises:
[0006] Based on a set first instruction template, the first input information is converted into a first language instruction, and a first self-encoding large language model LLM is called to process the first language instruction to obtain first output information; the first input information includes a user input text; the first output information includes one or more first entities and corresponding entity types in the user input text;
[0007] Based on a set second instruction template, the second input information is converted into a second language instruction, and a second self-encoding LLM is called to process the second language instruction to obtain second output information; the second input information includes the user input text, the first output information and candidate information; the candidate information includes one or more second entities and corresponding relationship types obtained by inputting the first output information into a knowledge graph for single-hop retrieval; the second output information includes one or more second entities most relevant to the one or more first entities in the candidate information;
[0008] Based on a set third instruction template, the third input information is converted into a third language instruction, and a third self-encoding LLM is called to process the third language instruction to obtain third output information; the third input information includes the second output information and the candidate information; the third output information includes one or more relationship types most relevant to the one or more second entities in the second output information;
[0009] generate an answer statement about the user input text based on the second output information and the third output information.
[0010] In the above scheme, the first input information further comprises entity type description information; and / or,
[0011] The third input information further comprises the entity type description information and the relationship type description information; wherein,
[0012] The entity type description information and / or the relationship type description information are determined based on prior knowledge of the knowledge graph.
[0013] In the above scheme, the entity type description information and / or the relationship type description information are updated along with the update of the knowledge graph.
[0014] In the above scheme, the generating of the answer statement about the user input text based on the second output information and the third output information comprises:
[0015] calling the knowledge graph to process the second output information and the third output information to obtain triple information;
[0016] constructing a prior knowledge statement based on the triple information;
[0017] generating an answer statement about the user input text based on the prior knowledge statement and the user input text.
[0018] In the above scheme, before the constructing of the prior knowledge statement based on the triple information, the method further comprises:
[0019] inputting the triple information into the knowledge graph for single-hop retrieval to obtain related knowledge information of the triple information; and updating the triple information based on the related knowledge information.
[0020] In the above scheme, the first output information further comprises a first confidence score of each of the first entities; and the first confidence score is used to judge the credibility of the entity type corresponding to the first entity.
[0021] The second output information further comprises a second confidence score of each of the second entities; and the second confidence score is used to judge the relevance between each of the second entities in the candidate information and the corresponding first entity.
[0022] The third output information further comprises a third confidence score; and the third confidence score is used to judge the relevance between each of the second entities and different relationship types.
[0023] In the above scheme, after obtaining the triple information, the method further includes:
[0024] calculating an average value of the second confidence score and the third confidence score corresponding to each triple in the triple information, and sorting all triples in the triple information according to the average value to obtain a sorting result;
[0025] Based on the sorting result, it is determined whether one or more triples in the triple information can be used to construct the priori knowledge sentence.
[0026] In the above scheme, the constructing of the priori knowledge sentence based on the triple information includes:
[0027] processing the triple information based on a set fourth instruction template to obtain a fourth language instruction, and calling a first autoregressive LLM to process the fourth language instruction to obtain the priori knowledge sentence; the priori knowledge sentence represents a fluent natural language sentence based on the triple information.
[0028] In the above scheme, the generating of the answer sentence about the user input text based on the priori knowledge sentence and the user input text includes:
[0029] calling a second autoregressive LLM to generate the answer sentence by taking the priori knowledge sentence and the user input text as input.
[0030] The embodiment of the present application also provides a dialogue generation device, which includes:
[0031] A first processing unit is configured to convert first input information into a first language instruction based on a set first instruction template, and call a first autoregressive large language model (LLM) to process the first language instruction to obtain first output information; the first input information includes a user input text; and the first output information includes one or more first entities and corresponding entity types in the user input text.
[0032] A second processing unit is configured to convert second input information into a second language instruction based on a set second instruction template, and call a second autoregressive LLM to process the second language instruction to obtain second output information; the second input information includes the user input text, the first output information and candidate information; the candidate information includes one or more second entities and corresponding relationship types obtained by inputting the first output information into a knowledge graph for single-hop retrieval; and the second output information includes one or more second entities in the candidate information that are most relevant to the one or more first entities.
[0033] a third processing unit, configured to convert third input information into third language instructions based on a third instruction template, and invoke a third self-encoding LLM to process the third language instructions to obtain third output information; the third input information comprises the second output information and the candidate information; the third output information comprises one or more relationship types most relevant to one or more second entities in the second output information;
[0034] a first generating unit, configured to generate a reply statement about the user input text based on the second output information and the third output information.
[0035] Embodiments of the present application further provide an electronic device, comprising a memory and a processor, the memory storing a computer program capable of running on the processor, and the processor being configured to execute the method for dialogue generation.
[0036] Embodiments of the present application further provide a storage medium having a computer program stored thereon, the computer program being executed by a processor to implement the steps of the method.
[0037] Embodiments of the present application further provide a computer program product comprising a computer program, wherein the computer program is executed by a processor to implement the steps of the method.
[0038] In the dialogue generation method, device, electronic device, storage medium and computer program product provided by the embodiment of the present application, first, based on the set first instruction template, the first input information is converted into a first language instruction, and a first self-encoding large language model LLM is called to process the first language instruction to obtain first output information. The first input information includes user input text, and the first output information includes one or more first entities and corresponding entity types in the user input text. Second, based on the set second instruction template, the second input information is converted into a second language instruction, and a second self-encoding LLM is called to process the second language instruction to obtain second output information. The second input information includes the user input text, the first output information and candidate information. Third, based on the set third instruction template, the third input information is converted into a third language instruction, and a third self-encoding LLM is called to process the third language instruction to obtain third output information. The third input information includes the second output information and the candidate information. Since the candidate information includes one or more second entities and corresponding relationship types obtained by inputting the first output information into a knowledge graph for single-hop retrieval, the one or more second entities most relevant to the one or more first entities in the candidate information can be included in the second output information, and the one or more relationship types most relevant to the one or more second entities in the second output information can be included in the third output information. Therefore, based on the second output information and the third output information, that is, based on the one or more second entities most relevant and the one or more relationship types most relevant, the most accurate and reliable answer statement about the user input text can be generated. By combining the method of knowledge graph retrieval and the method of constructing instruction template into the self-encoding LLM, not only the entity recognition, entity disambiguation and relationship recognition can be completed, the authenticity and reliability of the cited knowledge can be improved, but also the subsequent construction of the triplets for generating fluent dialogue can be facilitated, so that the problems of inconsistent knowledge and insufficient language communication ability in the dialogue generation method can be solved. BRIEF DESCRIPTION OF DRAWINGS
[0039] Figure 1 A flowchart of a dialogue generation method according to an embodiment of the present application;
[0040] Figure 2 A flowchart of another dialogue generation method according to an embodiment of the present application;
[0041] Figure 3 A flowchart of a third dialogue generation method according to an embodiment of the present application;
[0042] Figure 4 A structural diagram of a dialogue generation device according to an embodiment of the present application;
[0043] Figure 5 FIG. 1 is a schematic diagram of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0044] Large language models are neural network models that are pre-trained using large amounts of unlabeled text data in a self-supervised manner, have the ability to understand context and generate text, and can adapt to various natural language tasks after fine-tuning. However, related dialogue large models have the problem of inconsistency with real-world knowledge, resulting in factual errors in the generated text. For example, some dialogue large models introduce search engines or file upload interfaces to introduce more context as prior knowledge when generating answers, but the search engine cannot guarantee the authenticity of the retrieved content information, and the use of synonyms or ambiguities in the text will also lead to uncontrollable search results. Moreover, users need to consult files in advance and guarantee the quality of the knowledge in the documents, and users who are not familiar with the field involved in the document have the problem of untrustworthy knowledge sources.
[0045] A knowledge graph is an information model that describes concepts, entities, and their relationships in the objective world in a structured form. However, the self-encoding pre-training model used by the dialogue system using the knowledge graph cannot perform text generation tasks, and the system pipeline ultimately returns static text stored in the corpus or knowledge graph, which cannot generate natural and fluent text in real time in dialogue question and answer. Further, the application scenario of the dialogue question and answer system based on knowledge retrieval and sorting is limited by the corpus or knowledge graph.
[0046] In summary, related dialogue question and answer systems cannot simultaneously solve the problem of knowledge inconsistency of language large models and the problem of insufficient language ability of knowledge graphs.
[0047] In the dialogue generation method, device, electronic device, storage medium and computer program product provided by the embodiments of the present application, first, based on the set first instruction template, the first input information is converted into a first language instruction, and a first self-encoding large language model LLM is called to process the first language instruction to obtain first output information. The first input information includes user input text, and the first output information includes one or more first entities and corresponding entity types in the user input text. Second, based on the set second instruction template, the second input information is converted into a second language instruction, and a second self-encoding LLM is called to process the second language instruction to obtain second output information. The second input information includes the user input text, the first output information and candidate information. Third, based on the set third instruction template, the third input information is converted into a third language instruction, and a third self-encoding LLM is called to process the third language instruction to obtain third output information. The third input information includes the second output information and the candidate information. Since the candidate information includes one or more second entities and corresponding relationship types obtained by inputting the first output information into a knowledge graph for single-hop retrieval, the second output information can include one or more second entities in the candidate information that are most relevant to the one or more first entities, and the third output information includes one or more relationship types that are most relevant to the one or more second entities in the second output information. Therefore, based on the second output information and the third output information, that is, based on the most relevant one or more second entities and the most relevant one or more relationship types, the most accurate and reliable answer statement about the user input text can be generated. By combining the knowledge graph retrieval method and the method of feeding the constructed instruction template into the self-encoding LLM, not only can entity recognition, entity disambiguation and relationship recognition be completed, the authenticity and reliability of the cited knowledge can be improved, but also it is helpful to subsequently construct a triple for generating a fluent dialogue, so the problem of inconsistent knowledge and insufficient language communication ability in the dialogue generation method can be solved.
[0048] The embodiments of the present application provide a dialogue generation method, referring to Figure 1 The method comprises the following steps.
[0049] Step 101: Based on the set first instruction template, the first input information is converted into a first language instruction, and a first self-encoding LLM is called to process the first language instruction to obtain first output information.
[0050] Here, the first input information includes user input text; and the first output information includes one or more first entities and corresponding entity types in the user input text.
[0051] Step 102: converting the second input information into second language instructions based on a set second instruction template, and calling a second self-encoding LLM to process the second language instructions to obtain second output information.
[0052] Here, the second input information includes the user input text, the first output information, and candidate information; the candidate information includes one or more second entities and corresponding relationship types obtained by inputting the first output information into a knowledge graph for single-hop retrieval; and the second output information includes one or more second entities in the candidate information that are most relevant to the one or more first entities.
[0053] Step 103: converting third input information into third language instructions based on a set third instruction template, and calling a third self-encoding LLM to process the third language instructions to obtain third output information.
[0054] Here, the third input information includes the second output information and the candidate information; and the third output information includes one or more relationship types that are most relevant to the one or more second entities in the second output information.
[0055] Step 104: generating an answer statement about the user input text based on the second output information and the third output information.
[0056] In the embodiments of the present application, the instruction template refers to a natural language sentence that can be preset, and the preset natural language sentence has words or sentences to be filled in. For example, the first instruction template can be "find all named entities that may exist in the $to-be-recognized text", where it can be specified that "$to-be-recognized text = $first input information", that is, the "first input information" can be used to replace the "to-be-recognized text", and "$" is used to mark the position information to be filled.
[0057] In the embodiments of the present application, for example, when the "first input information" is used to replace the "to-be-recognized text" in the first instruction template, the first language instruction can be "find all named entities that may exist in 'Lu Xun and Zhou Shuren are the same person?'".
[0058] In the embodiments of the present application, the first self-encoding LLM, the second self-encoding LLM, and the third self-encoding LLM can be the same language model or different language models, and in actual application, the language model can be selected according to the input concurrency of the language model. Before being put into use, any self-encoding LLM can be trained by parameter fine-tuning based on labeled data.
[0059] In the embodiments of the present application, the first self-encoding LLM can be called to process the first language instruction to obtain first output information, and the first output information includes one or more first entities and corresponding entity types in the user input text. For example, when the first language instruction is "find all named entities that may exist in 'Is Lu Xun the same person as Zhou Shuren?'", calling the first self-encoding LLM to process the first language instruction can obtain the first output information as "Lu Xun-person name; Zhou Shuren-person name", that is, the first entity "Lu Xun" and the first entity "Zhou Shuren" are obtained, and it is obtained that the entity type corresponding to "Lu Xun" is "person name" and the entity type corresponding to "Zhou Shuren" is "person name". Therefore, the purpose of obtaining the first output information is to complete the entity recognition in the user input text.
[0060] In the embodiments of the present application, single-hop retrieval refers to a retrieval method in which a target node (entity) can be found from a starting node (entity) through a single edge (relationship) in a knowledge graph. For example, when the starting node (entity) is "Yao Ming", the relationship is "born in", and the target node (entity) is "Shanghai", that is, starting from the starting node "Yao Ming", through the relationship "born in", the target node "Shanghai" can be directly found, which is a single-hop retrieval process.
[0061] In the embodiments of the present application, during the dialogue generation process, relevant retrieval or processing can also be performed in combination with the knowledge graph. The first output information described above can be input into the knowledge graph to perform single-hop retrieval to obtain candidate information, and the candidate information includes one or more second entities and corresponding relationship types. For example, when the first output information is "Lu Xun-person name; Zhou Shuren-person name", single-hop retrieval of the first output information in the knowledge graph can obtain the candidate information as "1. Lu Xun (original name, hometown, birthplace, occupation); 2. Lu Xun (author, publisher, publication time); 3. Lu Xun (director, leading actor, release time); 4. Zhou Shuren (pen name, original name, hometown, birthplace, occupation)". For the second candidate information, the second entity is "Lu Xun", and the corresponding relationship type is "author, publisher, publication time", that is, the author, publisher and publication time of the book "Lu Xun".
[0062] In the embodiments of the present application, after completing entity recognition, in order to perform entity disambiguation, that is, to find a closest real mapping of each entity in the user input text in the knowledge graph, not only the candidate information retrieved by the knowledge graph can be used, but also a second language instruction can be constructed in combination with the first output information and the user input text. Specifically, based on a set second instruction template, the second input information is converted into a second language instruction, that is, the user input text in the second input information, the first output information and the candidate information can be brought into the second instruction template to obtain the second language instruction.
[0063] In the embodiments of the present application, after obtaining the second language instruction, a second self-encoding LLM is called to process the second language instruction to obtain second output information. The second output information includes one or more second entities most relevant to one or more first entities in the candidate information. For example, when the candidate information is "1. Lu Xun (original name, hometown, birthplace, occupation); 2. Lu Xun (author, publisher, publication time); 3. Lu Xun (director, leading actor, release time); 4. Zhou Shuiren (pen name, original name, hometown, birthplace, occupation)", the second entities most relevant to the first entity "Lu Xun" and the first entity "Zhou Shuiren" are "Lu Xun" in the first item and "Zhou Shuiren" in the fourth item in the candidate information.
[0064] In the embodiments of the present application, in order to complete relationship recognition, that is, to find the relationship type most relevant to the second entity, the third input information can be converted into a third language instruction based on a set third instruction template, and a third self-encoding LLM is called to process the third language instruction to obtain third output information. The third input information includes the second output information and the candidate information. In actual application, the third input information can also include a replaced input text, which can be obtained by replacing the relevant entities of the user input text with the second output information. For example, when the user input text is "Is Lu Xun and Zhou Shuiren the same person?", the replaced input text can be "<Lu Xun-person name> and <Zhou Shuiren-person name> are the same person?".
[0065] In the embodiments of the present application, after obtaining the third language instruction, the third self-encoding LLM is called to process the third language instruction to obtain third output information. The third output information includes one or more relationship types most relevant to one or more second entities in the second output information. For example, when the second output information is the second entities of the first and fourth items of the candidate information "1. Lu Xun (original name, hometown, birthplace, occupation); 2. Lu Xun (author, publisher, publication time); 3. Lu Xun (director, leading actor, release time); 4. Zhou Shurun (pen name, original name, hometown, birthplace, occupation)", the relationship type most relevant to "Lu Xun" in the first item is "original name", and the relationship types most relevant to "Zhou Shurun" in the fourth item are "pen name" and "original name", so the third output information can be "Lu Xun-original name; Zhou Shurun-pen name; Zhou Shurun-original name".
[0066] In the embodiments of the present application, after obtaining the second output information and the third output information, since the second output information includes one or more second entities most relevant to one or more first entities in the candidate information, and the third output information includes one or more relationship types most relevant to one or more second entities in the second output information, the most relevant entity obtained after entity disambiguation and the most relevant relationship type obtained after relationship recognition can be used to generate an answer statement about the user input text based on the second output information and the third output information.
[0067] In an embodiment, the first input information further includes entity type description information; and / or,
[0068] The third input information further includes the entity type description information and the relationship type description information; wherein,
[0069] The entity type description information and / or the relationship type description information are determined based on prior knowledge of the knowledge graph.
[0070] In an embodiment of the present application, the entity type description information and / or the relationship type description information is determined based on prior knowledge of the knowledge graph. The entity type description information refers to detailed description or explanation information of different entities; the relationship type description information refers to detailed description or explanation information of different relationships. For example, the entity type description information can be "person name: name of a person. Place: geographical location in the real world", that is, "person name" can be described as the name of a person, and "place" can be described as a geographical location in the real world; the relationship type description information can be "original name: name of a person entity used before, default Chinese name or translation. Birthplace: birthplace of a person entity", that is, "original name" can be described as the name of a person entity used before, default Chinese name or translation, and "birthplace" can be described as the birthplace of a person entity. The entity type description information and / or the relationship type description information is determined based on the prior knowledge of the knowledge graph.
[0071] In an embodiment of the present application, the entity type description information is also included in the first input information, which can make full use of the prior knowledge of the knowledge graph to facilitate the first self-encoding LLM to better complete the identification of the first entity; the entity type description information and the relationship type description information are also included in the third input information, which can make full use of the prior knowledge of the knowledge graph to facilitate the third self-encoding LLM to more accurately complete the identification or judgment of the relationship type.
[0072] In an embodiment, the entity type description information and / or the relationship type description information is updated along with the update of the knowledge graph.
[0073] In an embodiment of the present application, when the knowledge graph is updated, the entity type description information and / or the relationship type description information obtained based on the prior knowledge of the knowledge graph is also updated, so as to more effectively help the self-encoding model to understand the entity identification or relationship identification task.
[0074] In an embodiment, the generating of the answer statement about the user input text based on the second output information and the third output information comprises:
[0075] calling the knowledge graph to process the second output information and the third output information to obtain triple information;
[0076] constructing a prior knowledge statement based on the triple information;
[0077] generating an answer statement about the user input text based on the prior knowledge statement and the user input text.
[0078] In the embodiments of the present application, in order to more accurately generate the answer statement about the user input text, after obtaining the second output information and the third output information, the knowledge graph can be called, that is, the knowledge graph is called to process the second output information and the third output information to obtain the triple information. In the knowledge graph, the triple is an ordered set of three elements, which are subject, predicate and object. For example, the triple of "Apple is a fruit" can be represented as (Apple, is, Fruit).
[0079] In the embodiments of the present application, since the second output information includes one or more second entities most related to one or more first entities in the candidate information, and the third output information includes one or more relationship types most related to one or more second entities in the second output information, the second output information and the corresponding third output information can be composed into one or more binary tuples. After entity retrieval in the knowledge graph, one or more triples are obtained. For example, after entity retrieval in the knowledge graph, the triple of "Lu Xun-Original Name-{}" can be obtained, where "{}" represents an entity that needs to be retrieved and filled.
[0080] In the embodiments of the present application, based on the triple information, the prior knowledge sentence is constructed, which means that the triple information is converted into natural flow language or sentence as the prior knowledge of the user input text, so as to help generate the answer statement. For example, when the triple is "Lu Xun-Original Name-{Zhou Shurun}", the prior knowledge sentence can be "The original name of Lu Xun is Zhou Shurun". Then, based on the prior knowledge sentence and the user input text, the answer statement about the user input text is generated. For example, the answer statement can be "Yes, they are the same person, because the original name of Lu Xun is Zhou Shurun."
[0081] In the embodiments of the present application, by calling the knowledge graph to process the second output information and the third output information to obtain the triple information, and based on the triple information, the prior knowledge sentence is constructed, and finally based on the prior knowledge sentence and the user input text, the answer statement about the user input text is generated. All structured knowledge involved in the user input text can be processed into fluent unstructured natural language text, that is, unstructured prior knowledge text, which is beneficial to knowledge alignment with the real world when generating the dialogue text.
[0082] In an embodiment, before the step of constructing the prior knowledge sentence based on the triple information, the method further comprises:
[0083] After inputting the triple information into the knowledge graph for single-hop retrieval, the related knowledge information of the triple information is obtained; and the triple information is updated based on the related knowledge information.
[0084] In the embodiments of the present application, after the second output information and the third output information are processed by the knowledge graph to obtain the triple information, the obtained triple information can be input into the knowledge graph again for single-hop retrieval to obtain related knowledge information of the triple information. In actual application, the obtained triple information can also be input into the knowledge graph for two-hop retrieval to obtain related knowledge information of the triple information. The related knowledge information can be one or more related triples. For example, when the triple is "Lu Xun-original name-Zhou Shuren", the related knowledge information obtained by single-hop retrieval can be "Lu Xun-hometown-Henan Province Zhengyang County" and / or "Lu Xun-birth date-September 25, 1881" and / or "Lu Xun-mother-Lu Rui". Based on the related knowledge information, the triple information can be updated, and in actual application, the related knowledge information can be added to the triple information.
[0085] In the embodiments of the present application, after the triple information is input into the knowledge graph for single-hop retrieval to obtain the related knowledge information of the triple information, since the related knowledge information is retrieved from the knowledge graph, the related knowledge information is consistent with the knowledge of the real world, and the source is reliable. Moreover, based on the related knowledge information, the triple information is updated, which can also make the triple information contain more rich information, so as to generate more rich answer sentences.
[0086] In an embodiment, the first output information further includes a first confidence score of each of the first entities; the first confidence score is used to determine the credibility of the entity type corresponding to the first entity;
[0087] The second output information further includes a second confidence score of each of the second entities; the second confidence score is used to determine the relevance between each of the second entities in the candidate information and the corresponding first entity;
[0088] The third output information further includes a third confidence score; the third confidence score is used to determine the relevance between each of the second entities and different relationship types.
[0089] In the embodiments of the present application, the first output information can further include a first confidence score of each first entity. For example, the first output information includes "Lu Xun-person name-1.00", in which "1.00" is a score used to determine the credibility of the entity "Lu Xun" in the user input text corresponding to the entity type "person name". "1.00" can represent 100% credibility.
[0090] In the embodiments of the present application, the second output information further includes a second confidence score of each second entity. For example, when the candidate information is "1. Lu Xun (original name, birthplace, occupation); 2. Lu Xun (author, publisher, publication time); 3. Lu Xun (director, leading actor, release time); 4. Zhou Shurun (pen name, original name, birthplace, occupation)", and the second entity is the entity "Zhou Shurun" in the fourth item, the second output information can include "4. Zhou Shurun-1.00", in which "1.00" is used to judge the relevance between the second entity "4. Zhou Shurun" and the corresponding first entity "Zhou Shurun", and "1.00" can represent 100% relevance. In which, the first entity "Zhou Shurun" is the entity "Zhou Shurun-person name" in the first output information.
[0091] In the embodiments of the present application, the third output information further includes a third confidence score. For example, the third output can include "Zhou Shurun-original name-0.96", in which "0.98" is used to judge the relevance between the second entity "Zhou Shurun" and the relationship type "original name"; the third output can also include "Zhou Shurun-pseudonym-0.97", in which "0.97" is used to judge the relevance between the second entity "Zhou Shurun" and the relationship type "pseudonym". Therefore, the third confidence score is used to judge the relevance between each second entity and different relationship types.
[0092] In the embodiments of the present application, by including the first confidence score of each first entity in the first output information, the second confidence score of each second entity in the second output information, and the third confidence score in the third output information, the most accurate entity corresponding to the entity in the user input text and the most relevant relationship type can be found in the knowledge graph more accurately by calculating the scores.
[0093] In an embodiment, after obtaining the triple information, the method further includes:
[0094] calculating the average value of the second confidence score and the corresponding third confidence score of each triple in the triple information, and sorting all triples in the triple information according to the average value to obtain a sorting result;
[0095] Based on the sorting result, it is determined whether one or more triples in the triple information can be used to construct the priori knowledge sentence.
[0096] In the embodiment of the present application, after obtaining the triple information, each triple in the triple information can be scored. Since the triple information is obtained by calling the knowledge graph to process the second output information and the third output information, and the second output information includes a second confidence score and the third output information includes a third confidence score, the second confidence score corresponding to each triple and the third confidence score corresponding to each triple can be averaged to obtain an average value. For example, the second output information is "Lu Xun-0.99", and the third output information is "Lu Xun-original name-0.98", and the average value of the corresponding second confidence score (0.99) and the corresponding third confidence score (0.98) of the obtained triple "Lu Xun-original name-Zhou Shuren" is 0.985. Then, each triple is also scored in a similar manner. According to the average value calculated for each triple, all triples are sorted to obtain a sorting result.
[0097] In the embodiment of the present application, based on the sorting result of the triple, it can be determined whether one or more triples in the triple information can be used to construct the priori knowledge sentence. In actual application, a set number of triples with the highest average value can be selected to construct the priori knowledge sentence; triples with an average value higher than 0.9 can also be used to construct the priori knowledge sentence, and when the number of triples is insufficient, a batch of triples with an average value not lower than 0.7 can also be supplemented as additional supplements.
[0098] In the embodiment of the present application, by calculating the average value of the second confidence score corresponding to each triple in the triple information and the third confidence score corresponding to each triple, and according to the average value, all triples in the triple information are sorted to obtain a sorting result, and based on the sorting result, it is determined whether one or more triples in the triple information can be used to construct the priori knowledge sentence, the triple information most suitable for constructing the priori knowledge sentence can be screened out, which helps to generate more accurate answer sentences.
[0099] In an embodiment, the constructing a priori knowledge sentence based on the triple information comprises:
[0100] processing the triple information based on a set fourth instruction template to obtain a fourth language instruction, and calling a first self-recurrent LLM to process the fourth language instruction to obtain the priori knowledge sentence; the priori knowledge sentence represents a fluent natural language sentence obtained based on the triple information.
[0101] In the embodiment of the present application, since the triple information is structured knowledge, it needs to be converted into unstructured natural language, i.e., unstructured prior knowledge sentences. Therefore, the triple information can be processed based on the set fourth instruction template, i.e., the triple information is brought into the fourth instruction template to obtain a fourth language instruction, and a first autoregressive LLM is called to process the fourth language instruction. The first autoregressive LLM can perform few-shot or even zero-shot prompt learning to process, and the obtained structured knowledge is spliced into a text instruction to obtain the prior knowledge sentence.
[0102] In the embodiment of the present application, the triple information is processed based on the set fourth instruction template to obtain a fourth language instruction, and a first autoregressive LLM is called to process the fourth language instruction to obtain the prior knowledge sentence. This can better convert structured knowledge into fluent unstructured natural language text. Not only can the first autoregressive LLM be aligned with the real world in knowledge when generating dialogue text, but also the obtained prior knowledge sentence and the input text can be consistent in modal, thereby better generating dialogue.
[0103] In an embodiment, the generating of the answer sentence about the user input text based on the prior knowledge sentence and the user input text comprises:
[0104] The second autoregressive LLM is called to generate the answer sentence by taking the prior knowledge sentence and the user input text as input.
[0105] In the embodiment of the present application, the second autoregressive LLM and the first autoregressive LLM can be the same autoregressive language model or can not be the same autoregressive language model, depending on actual needs. After obtaining the prior knowledge sentence, the second autoregressive LLM can be called to generate the answer sentence by taking the prior knowledge sentence and the user input text as input.
[0106] In the embodiment of the present application, since the prior knowledge sentence and the user input text are consistent in modal and are both natural language sentences, the second autoregressive LLM can be called to generate the answer sentence by taking the prior knowledge sentence and the user input text as input. Through this method, the second autoregressive LLM can better induce and summarize prior knowledge, avoiding semantic loss when directly sending structured knowledge as prompt information to the second autoregressive LLM, and ensuring the dialogue communication ability of the model and the consistency of the related field knowledge of the model with the real world.
[0107] The present application will be further described in detail below in combination with application embodiments.
[0108] The application provides an application embodiment of a dialogue question and answer system based on a knowledge graph and a large-scale language model.
[0109] The system provided by the application embodiment mainly includes three modules, namely, an information extraction module, a knowledge text generation module, and a dialogue generation module based on the knowledge text. The three modules are described below.
[0110] I. Information extraction module
[0111] The purpose of the information extraction module is to extract the head entity and candidate relationship involved in the user input text, mine the tail entity in the knowledge graph, obtain structured knowledge, and send it to the dialogue generation module as background knowledge of the input text. The information extraction module can be divided into an entity recognition submodule, an entity disambiguation submodule, and a relationship recognition submodule, as shown in FIG. 1, which are described in detail below. Figure 2
[0112] (1) Entity recognition submodule
[0113] In this submodule, the user input text is spliced with the entity recognition instruction template and the entity type priori knowledge as the task prompt, and is sent to the self-encoding LLM model to complete the named entity recognition task, and the entity position and type are output. Among them, the user input text can be "Is Lu Xun and Zhou Shuren the same person?"; the first instruction template is "$task name = named entity recognition task; $task description text = please find all the named entities that may exist in the $to be recognized text, according to the $entity type description, judge their entity type, and give the corresponding confidence score; $to be recognized text = $user input text"; the entity type description can be "person name: task name; place: real-world geographical location", and the first output information is "Lu Xun-person name-1.00; Zhou Shuren-person name-1.00". The self-encoding LLM represents the input text combined with the prompt template as a feature vector, and decodes and classifies based on a named entity recognition task-specific downstream sequence labeling model to predict the entity corresponding position and type in the text. The self-encoding LLM needs to be fine-tuned and trained based on labeled data before being put into use. The fine-tuning algorithm uses the P-Tuning V2 algorithm, calculates the loss based on the loss function and the correct labeled data, and optimizes the model parameters corresponding to the position of the prompt text part.
[0114] In the process of prompting instructions of the first instruction template and construction, the entity recognition submodule will maintain a priori knowledge template combining common entity types in the knowledge graph and corresponding descriptions. Common entity types are obtained by counting the frequency of the types corresponding to important entity nodes in the knowledge graph. Important nodes can be given based on GENI and other knowledge graph node importance evaluation models. Entity type descriptions can be directly taken from the ontology construction information. When the knowledge graph is updated, the priori knowledge template will also change. In addition, the opinions of experts in various fields can also be referred to, and some commonly used entity types can be specified in some special fields. These priori knowledge can better help the self-encoding model understand the named entity recognition task. For the above user input text, the first output information can be "Lu Xun - Person Name - 1.00; Zhou Shuren - Person Name - 1.00".
[0115] (2) Entity disambiguation submodule
[0116] According to the first output information, that is, according to the obtained entity and type, the knowledge graph retrieval module is called to search the graph for entities that may be the same or close to the text, and a fixed number of single-hop relationship edges are selected for each disambiguation entity to obtain candidate information. The candidate information is the candidate entity and the relationship. For the above user input text, the candidate information is "1. Lu Xun (original name, hometown, birthplace, occupation); 2. Lu Xun (author, publisher, publication time); 3. Lu Xun (director, leading actor, release time); 4. Zhou Shuren (pen name, original name, hometown, birthplace, occupation)". The candidate entity and the relationship need to be sent to the entity disambiguation submodule together. The entity and the entity type are "Lu Xun - Person Name; Zhou Shuren - Person Name".
[0117] The candidate information will be prompted by a well-constructed instruction template, that is, the second instruction template, and the disambiguation entity and type will be spliced into the entity disambiguation instruction, and the user input text will be sent to the self-encoding LLM to predict the correct entity.
[0118] For the above user input text, the second instruction template is "$task name = entity disambiguation task; $task description text = please find the most accurate entity corresponding to the entity in the knowledge graph according to the provided text, entity and entity type in the text, candidate entity and relationship list in the knowledge graph, and give the corresponding confidence score, the entity and entity type in the text are $entity and entity type, the candidate entity and relationship list in the knowledge graph are $candidate information; $text to be recognized = $user input text".
[0119] The fine-tuning training process of the self-encoding LLM is similar to entity recognition, and only needs to modify the downstream task model to a classification model for supervised training on the corresponding data set. Further, the relationship edge of the candidate entity is used in the present embodiment to assist in distinguishing the entity from other entities, and the selected relationship type is obtained through the prior knowledge template maintained in the relationship identification submodule.
[0120] The second output information for the above user input text is "1. Lu Xun - 0.99; 4. Zhou Shuren - 1.00".
[0121] (3) Relationship identification submodule
[0122] The second output information and the candidate information can replace the entity in the user input text, and the user input text in the relationship identification submodule is "<Lu Xun: person name> and <Zhou Shuren: person name> are the same person?". The third instruction template can be "$task name = relationship identification task; $task description text = please find the most relevant relationship in the candidate relationship for the entity in the to-be-identified text, the entity in the text has been processed into <entity: entity type> format according to $entity type description, according to $relationship type description, judge the relationship type, and give the corresponding confidence score; $to-be-identified text = $replaced user input text; $candidate relationship = $candidate information".
[0123] The disambiguated entity will be used together with the user input text, the third instruction template, the relationship type description prior knowledge and / or the entity type description prior knowledge to splice as a task prompt, and sent to the self-encoding LLM model to complete the relationship identification task, and predict the most relevant relationship type of each entity in the input text.
[0124] The self-encoding LLM represents the input text combined with the prompt template as a feature vector, and decodes and classifies based on a relationship identification task specific downstream model to predict the relationship type that the entity in the text is most likely to need to mine. The parameter fine-tuning training of the self-encoding LLM is similar to the named entity recognition task, and only needs to modify the downstream task model to a classification model for supervised training on the corresponding data set.
[0125] The third output information for the above user input text is "Lu Xun - original name - 0.98; Zhou Shuren - pen name - 0.97; Zhou Shuren - original name - 0.96".
[0126] II. Knowledge text generation module
[0127] In the knowledge text generation module, each piece of information in the second output information and the third output information is correspondingly combined, and then the average value of the confidence score is calculated and sorted, that is, the average value of the entity and relationship confidence scores in entity disambiguation and relationship recognition is calculated and sorted, and then the path of each entity that needs to be queried is obtained. Specifically, the "1. Lu Xun-0.99" in the second output information and the "Lu Xun-original name-0.98" in the third output information are combined and the average value of the confidence score is calculated to obtain "Lu Xun-original name-{}-0.985"; the "4. Zhou Shuren-1.00" in the second output information and the "Zhou Shuren-pseudonym-0.97" in the third output information are combined and the average value of the confidence score is calculated to obtain "Zhou Shuren-pseudonym-{}-0.985"; the "4. Zhou Shuren-1.00" in the second output information and the "Zhou Shuren-original name-0.96" in the third output information are combined and the average value of the confidence score is calculated to obtain "Zhou Shuren-original name-{}-0.98". The sorted result is: "Lu Xun-original name-{}-0.985; Zhou Shuren-pseudonym-{}-0.985; Zhou Shuren-original name-{}-0.98"
[0128] The sorted result is sent to the knowledge graph retrieval module, and then the triple information composed of all the structured knowledge involved in the user input text, that is, the triple list, is obtained. Specifically, the obtained triple list is "Lu Xun-original name-{Zhou Shuren}-0.985; Zhou Shuren-pseudonym-{Lu Xun}-0.985; Zhou Shuren-original name-{Zhou Zhangshou}-0.98". In actual application, the triple list needs to be sorted according to the average value of the confidence score, and the triples higher than 0.9 are used for subsequent text generation, but when the number of triples is insufficient, a batch of triples not lower than 0.7 can also be supplemented as additional supplements.
[0129] Optionally, Figure 2 The other related knowledge information in the above formula can be related triple information obtained by one-hop or two-hop retrieval of the triple information in the knowledge graph. Specifically, the other related knowledge information can be "Lu Xun-native place-Henan Province Zhengyang County; Lu Xun-date of birth-September 25, 1881; Lu Xun-date of death-October 19, 1936; Lu Xun-occupation-literary figure; Lu Xun-occupation-ideologue; Lu Xun-brief introduction-one of the founders of modern Chinese literature; Lu Xun-character-Youcai; Lu Xun-mother-Lu Rui; Lu Xun-father-Zhou Boyi; …". After obtaining the other related knowledge information, the triple information can be updated.
[0130] After obtaining the triple information, the triple information is sorted according to Figure 3The fourth instruction template in the algorithm concatenates the obtained structured knowledge into text generation instructions, which are then fed into the autoregressive LLM for few-shot or even zero-shot prompting learning. This process transforms all structured knowledge involved in the user-input text into fluent, unstructured natural language text, i.e., the fourth output information. This fourth output information is unstructured prior knowledge text, used by the autoregressive LLM to align knowledge with the real world during dialogue text generation. Specifically, the fourth instruction template is: "$Task Name = Triple to Text Task; $Task Description Text = Please combine the triple information from the provided knowledge graph, in the format (X,Y,Z), where X and Z represent entities and Y represents relations, into a natural, fluent, and grammatically correct text paragraph. The triple information in the knowledge graph is $Triple Information; $Text to be Recognized = None." Specifically, the fourth output information is: "Lu Xun, whose original name was Zhou Shuren, was born on September 25, 1881, and died on October 19, 1936. He was an outstanding writer, thinker, and revolutionary, hailed as a 'pioneer of culture and thought,' and one of the founders of modern Chinese literature. His given name was Yu Cai, his mother was Lu Rui, and his father was Zhou Boyi."
[0131] Structured knowledge, while consisting of textual vocabulary, differs modally from conventional natural language text. Converting structured knowledge into unstructured text ensures that the structured knowledge in the knowledge graph aligns modally with the input text of the autoregressive LLM, allowing for better induction and summarization of prior knowledge. This avoids the semantic loss that occurs when directly feeding structured knowledge as prompts into the autoregressive LLM, ensuring the model's domain knowledge remains consistent with the real world while maintaining its conversational capabilities.
[0132] III. Dialogue Generation Module Based on Knowledge Text
[0133] By concatenating unstructured prior knowledge text with user input and then feeding it into an autoregressive LLM, a response dialogue can be generated. For example... Figure 3 As shown, specifically, the user input text is "Are Lu Xun and Zhou Shuren the same person?", and the fifth output information, i.e., the answer, is "They are the same person. Lu Xun's real name was Zhou Shuren. Lu Xun's pen name may have been chosen to commemorate his mother, Lu Rui." Leveraging the excellent context learning capabilities of autoregressive LLM, the generated response text is highly correlated with prior knowledge text, ensuring the consistency between the model and real-world knowledge.
[0134] Through the three modules of the embodiment of the present application, the information extraction module, the knowledge text generation module, and the dialogue generation module based on the knowledge text, not only can make the knowledge of the dialogue large model consistent with the real world, avoid the occurrence of factual errors in the generated text, but also compared with the knowledge retrieval and ranking system based on the self-encoding large model, the dialogue communication ability is significantly improved.
[0135] Further, in actual application, based on the dialogue large model, the triple information in the knowledge graph is converted into unstructured text, which can be reused for unsupervised pre-training of the dialogue large model, and the knowledge of the dialogue large model is more consistent with the real world through continuous iteration; when the used knowledge graph is a domain knowledge graph of software engineering and software testing, the dialogue text generation technology can be immediately adapted to: code automatic generation and test case automatic generation, when the knowledge graph is more related to the adapted task, such as the domain knowledge graph of mobile cloud platform, the generated text content can be better used in production tasks.
[0136] In order to realize the dialogue generation method of the embodiment of the present application, the embodiment of the present application also provides a dialogue generation device, as shown in Figure 4 The device comprises:
[0137] The first processing unit 401 is configured to convert first input information into first language instructions based on a set first instruction template, and call a first self-encoding large language model LLM to process the first language instructions to obtain first output information; the first input information comprises user input text; and the first output information comprises one or more first entities and corresponding entity types in the user input text.
[0138] The second processing unit 402 is configured to convert second input information into second language instructions based on a set second instruction template, and call a second self-encoding LLM to process the second language instructions to obtain second output information; the second input information comprises the user input text, the first output information, and candidate information; the candidate information comprises one or more second entities and corresponding relationship types obtained by inputting the first output information into a knowledge graph for single-hop retrieval; and the second output information comprises one or more second entities most relevant to the one or more first entities in the candidate information.
[0139] The third processing unit 403 is configured to convert third input information into third language instructions based on a set third instruction template, and call a third self-encoding LLM to process the third language instructions to obtain third output information; the third input information comprises the second output information and the candidate information; and the third output information comprises one or more relationship types most relevant to the one or more second entities in the second output information.
[0140] The first generating unit 404 is configured to generate a response statement about the user input text based on the second output information and the third output information.
[0141] In an embodiment,
[0142] The first input information further comprises entity type description information; and / or,
[0143] The third input information further comprises the entity type description information and relationship type description information; wherein,
[0144] The entity type description information and / or the relationship type description information are determined based on prior knowledge of the knowledge graph.
[0145] In an embodiment, the entity type description information and / or the relationship type description information are updated along with the update of the knowledge graph.
[0146] In an embodiment, the first generating unit 404 is configured to call the knowledge graph to process the second output information and the third output information to obtain triple information.
[0147] Based on the triple information, a prior knowledge statement is constructed.
[0148] Based on the prior knowledge statement and the user input text, a response statement about the user input text is generated.
[0149] In an embodiment, the apparatus further comprises:
[0150] The fourth processing unit is configured to, before the construction of the prior knowledge statement based on the triple information, input the triple information into the knowledge graph to obtain related knowledge information of the triple information after single-hop retrieval.
[0151] The first updating unit is configured to update the triple information based on the related knowledge information.
[0152] In an embodiment, the first output information further comprises a first confidence score of each of the first entities; the first confidence score is used to judge the credibility of the entity type corresponding to the first entity.
[0153] The second output information further comprises a second confidence score of each of the second entities; the second confidence score is used to judge the relevance between each of the second entities in the candidate information and the corresponding first entity.
[0154] The third output information further includes a third confidence score; the third confidence score is used to determine the relevance between each of the second entities and different relationship types.
[0155] In an embodiment, the apparatus further includes:
[0156] The fifth processing unit is configured to, after obtaining the triple information, calculate an average value of a second confidence score corresponding to each of the triple information and a third confidence score corresponding to each of the triple information, and sort all of the triple information according to the average value to obtain a sorting result.
[0157] The first determining unit is configured to determine, based on the sorting result, whether one or more of the triple information can be used to construct the priori knowledge sentence.
[0158] In an embodiment, the first generating unit 404 is configured to process the triple information based on a set fourth instruction template to obtain a fourth language instruction, and call a first autoregressive LLM to process the fourth language instruction to obtain the priori knowledge sentence; the priori knowledge sentence represents a fluent natural language sentence based on the triple information.
[0159] In an embodiment, the first generating unit 404 is configured to call a second autoregressive LLM to generate the answer sentence by taking the priori knowledge sentence and the user input text as inputs.
[0160] In actual application, each of the above units can be implemented by a processor in the dialogue generation apparatus.
[0161] It should be noted that the dialogue generation apparatus provided in the above embodiments is only exemplified by the division of the above program modules, and in actual application, the above processing can be completed by different program modules according to needs, that is, the internal structure of the apparatus is divided into different program modules to complete all or part of the above processing. In addition, the dialogue generation apparatus and the dialogue generation method provided in the above embodiments belong to the same concept, and the specific implementation process is described in detail in the method embodiments, which will not be repeated here.
[0162] Based on the hardware implementation of the above program modules, the embodiment of the present application further provides an electronic device, as shown in Figure 5 The electronic device 500 includes:
[0163] The communication interface 501 is capable of information interaction with other network nodes;
[0164] The processor 502 is connected with the communication interface 501 to realize information interaction with other network nodes, and is used to run a computer program to execute the method provided by one or more technical solutions described above. The computer program is stored in the memory 503.
[0165] When the processor 502 runs the computer program to execute one or more dialogue generation methods described above, specifically:
[0166] The processor 502 is configured to:
[0167] convert first input information into first language instructions based on a set first instruction template, and call a first self-encoding large language model LLM to process the first language instructions to obtain first output information; the first input information includes user input text; the first output information includes one or more first entities and corresponding entity types in the user input text;
[0168] convert second input information into second language instructions based on a set second instruction template, and call a second self-encoding LLM to process the second language instructions to obtain second output information; the second input information includes the user input text, the first output information and candidate information; the candidate information includes one or more second entities and corresponding relationship types obtained by inputting the first output information into a knowledge graph for single-hop retrieval; the second output information includes one or more second entities most relevant to the one or more first entities in the candidate information;
[0169] convert third input information into third language instructions based on a set third instruction template, and call a third self-encoding LLM to process the third language instructions to obtain third output information; the third input information includes the second output information and the candidate information; the third output information includes one or more relationship types most relevant to the one or more second entities in the second output information;
[0170] generate an answer sentence about the user input text based on the second output information and the third output information.
[0171] In an embodiment, the first input information further includes entity type description information; and / or,
[0172] The third input information further includes the entity type description information and the relationship type description information; wherein,
[0173] The entity type description information and / or the relationship type description information are determined based on prior knowledge of the knowledge graph.
[0174] In an embodiment, the entity type description information and / or the relation type description information is updated along with an update of the knowledge graph.
[0175] In an embodiment, the processor 502 is further configured to: invoke the knowledge graph to process the second output information and the third output information to obtain triple information.
[0176] Based on the triple information, construct a priori knowledge sentence;
[0177] Based on the priori knowledge sentence and the user input text, generate an answer sentence about the user input text.
[0178] In an embodiment, the processor 502 is further configured to:
[0179] Before the step of constructing the priori knowledge sentence based on the triple information, input the triple information into the knowledge graph to obtain related knowledge information of the triple information through single-hop retrieval;
[0180] Based on the related knowledge information, update the triple information.
[0181] In an embodiment, the first output information further comprises a first confidence score of each of the first entities; the first confidence score is used to determine the credibility of the entity type corresponding to the first entity;
[0182] The second output information further comprises a second confidence score of each of the second entities; the second confidence score is used to determine the relevance between each of the second entities in the candidate information and the corresponding first entity;
[0183] The third output information further comprises a third confidence score; the third confidence score is used to determine the relevance between each of the second entities and different relation types.
[0184] In an embodiment, the processor 502 is further configured to:
[0185] After obtaining the triple information, calculate the average value of the second confidence score corresponding to each triple in the triple information and the third confidence score corresponding to each triple, and sort all triples in the triple information according to the average value to obtain a sorting result;
[0186] Based on the sorting result, determine whether one or more triples in the triple information can be used to construct the priori knowledge sentence.
[0187] In an embodiment, the processor 502 is further configured to process the triple information based on a fourth instruction template set to obtain a fourth language instruction, and call a first autoregressive LLM to process the fourth language instruction to obtain the prior knowledge sentence; the prior knowledge sentence represents a fluent natural language sentence obtained based on the triple information.
[0188] In an embodiment, the processor 502 is further configured to call a second autoregressive LLM, input the prior knowledge sentence and the user input text to generate the answer sentence.
[0189] It should be noted that the specific processing processes of the processor 502 and the communication interface 501 can be understood with reference to the above method.
[0190] Of course, in actual application, each component in the electronic device 500 is coupled together through the bus system 504. It can be understood that the bus system 504 is used to realize the connection and communication between the components. In addition to including a data bus, the bus system 504 also includes a power bus, a control bus and a status signal bus. However, in order to clearly illustrate the application, all kinds of buses are marked as the bus system 504 in the Figure 5 .
[0191] The memory 503 in the embodiment of the application is used to store various types of data to support the operation of the electronic device 500. Examples of these data include: any computer programs used for operation on the electronic device 500.
[0192] The method disclosed in the above embodiments of the application can be applied in the processor 502 or implemented by the processor 502. The processor 502 can be an integrated circuit chip with signal processing capability. In the implementation process, each step of the above method can be completed by integrated logic circuits or instructions in the form of software in the processor 502. The processor 502 described above can be a general purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The processor 502 can implement or execute the methods, steps and logic block diagrams disclosed in the embodiments of the application. The general purpose processor can be a microprocessor or any conventional processor. In combination with the steps of the method disclosed in the embodiments of the application, the hardware decoding processor can be directly embodied to execute the above method, or a combination of hardware and software modules in the decoding processor can be executed. The software module can be located in a storage medium, which is located in the memory 503, and the processor 502 reads the information in the memory 503 and combines the hardware to complete the steps of the above method.
[0193] In an exemplary embodiment, the electronic device 500 can be implemented by one or more Application Specific Integrated Circuits (ASICs), DSPs, Programmable Logic Devices (PLDs), Complex Programmable Logic Devices (CPLDs), Field-Programmable Gate Arrays (FPGAs), general-purpose processors, controllers, microcontrollers (MCUs), microprocessors, or other electronic elements for executing the aforementioned methods.
[0194] It can be understood that the memory 503 of the embodiments of the present application can be a volatile memory or a non-volatile memory, and can also include both volatile and non-volatile memories. The non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a ferromagnetic random access memory (FRAM), a flash memory, a magnetic surface memory, an optical disc, or a compact disc read-only memory (CD-ROM). The magnetic surface memory can be a disk memory or a tape memory. The volatile memory can be a random access memory (RAM) used as an external cache. By way of example but not limitation, many forms of RAM can be used, such as static random access memory (SRAM), synchronous static random access memory (SSRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), sync link dynamic random access memory (SLDRAM), and direct rambus random access memory (DRRAM).The memory described in the embodiments of the present application is intended to include, but not limited to, these and any other suitable types of memory.
[0195] In the example embodiments, the embodiments of the present application also provide a storage medium, i.e., a computer storage medium, specifically a computer readable storage medium, such as the memory 503 storing the computer program executable by the processor 502 of the electronic device 500 to complete the steps of the dialogue generation method. The computer readable storage medium can be FRAM, ROM, PROM, EPROM, EEPROM, Flash Memory, magnetic surface memory, optical disc, or CD-ROM, etc.
[0196] Exemplarily, the embodiments of the present application also provide a computer program product comprising a computer program executable by the processor 502 of the electronic device 500 to complete the steps of the dialogue generation method.
[0197] It should be noted that "first", "second", etc. are used to distinguish similar objects, and do not necessarily describe a specific order or sequence.
[0198] The term "one or more" herein means any combination of at least two of any one or more of a plurality, for example, including at least one of A, B, C, can mean including any one or more elements selected from the set consisting of A, B, and C. The term "one or more" herein means any combination of at least two of any one or more of a plurality, for example, including at least one of A, B, C, can mean including any one or more elements selected from the set consisting of A, B, and C.
[0199] In addition, the technical solutions described in the embodiments of the present application can be combined arbitrarily without conflict.
[0200] The above is only a preferred embodiment of the present application, and is not intended to limit the protection scope of the present application.
Claims
1. A dialogue generation method, characterized by, The method comprises: Converting first input information into first language instructions based on a set first instruction template, and calling a first self-encoding large language model LLM to process the first language instructions to obtain first output information; the first input information includes user input text; the first output information includes one or more first entities in the user input text and corresponding entity types; Converting second input information into second language instructions based on a set second instruction template, and calling a second self-encoding LLM to process the second language instructions to obtain second output information; the second input information includes the user input text, the first output information, and candidate information; the candidate information includes one or more second entities and corresponding relationship types obtained by inputting the first output information into a knowledge graph for single-hop retrieval; the second output information includes one or more second entities in the candidate information that are most relevant to the one or more first entities; Converting third input information into third language instructions based on a set third instruction template, and calling a third self-encoding LLM to process the third language instructions to obtain third output information; the third input information includes the second output information and the candidate information; the third output information includes one or more relationship types that are most relevant to the one or more second entities in the second output information; Based on the second output information and the third output information, generating an answer statement about the user input text.
2. The method of claim 1, wherein: the first input information further includes entity type description information; and / or, the third input information further includes the entity type description information and relationship type description information; wherein: the entity type description information and / or the relationship type description information are determined based on prior knowledge of the knowledge graph.
3. The method of claim 2, wherein: the entity type description information and / or the relationship type description information are updated as the knowledge graph is updated.
4. The method of claim 1, wherein, Based on the second output information and the third output information, generating an answer statement about the user input text, comprises: calling the knowledge graph to process the second output information and the third output information to obtain triple information; based on the triple information, constructing a prior knowledge statement; based on the prior knowledge statement and the user input text, generating an answer statement about the user input text.
5. The method of claim 4, wherein, Before the step of constructing a prior knowledge statement based on the triple information, the method further comprises: inputting the triple information into a knowledge graph for single-hop retrieval to obtain related knowledge information of the triple information; based on the related knowledge information, updating the triple information.
6. The method of claim 4, wherein: the first output information further includes a first confidence score for each of the first entities; the first confidence score is used to determine the credibility of the entity type corresponding to the first entity; The second output information further comprises a second confidence score of each of the second entities; The second confidence score is used to determine the relevance between each of the second entities in the candidate information and the corresponding first entity; The third output information further comprises a third confidence score; The third confidence score is used to determine the relevance between each of the second entities and different relationship types.
7. The method of claim 6, wherein, After obtaining the triple information, the method further comprises: Calculating the average value of the second confidence score and the corresponding third confidence score of each triple in the triple information, and sorting all triples in the triple information according to the average value to obtain a sorting result; Based on the sorting result, it is determined whether one or more triples in the triple information can be used to construct the priori knowledge sentence.
8. The method of claim 4, wherein, The constructing of the priori knowledge sentence based on the triple information comprises: Processing the triple information based on a set fourth instruction template to obtain a fourth language instruction, and calling a first autoregressive LLM to process the fourth language instruction to obtain the priori knowledge sentence; the priori knowledge sentence represents a fluent natural language sentence based on the triple information.
9. The method according to claim 4 or 8, characterized in that, The generating of the answer sentence about the user input text based on the priori knowledge sentence and the user input text comprises: Calling a second autoregressive LLM to generate the answer sentence by taking the priori knowledge sentence and the user input text as inputs.
10. A dialogue generation apparatus characterized by comprising: Comprise: A first processing unit is configured to convert first input information into a first language instruction based on a set first instruction template, and call a first autoregressive large language model (LLM) to process the first language instruction to obtain first output information; the first input information comprises a user input text; the first output information comprises one or more first entities and corresponding entity types in the user input text; A second processing unit is configured to convert second input information into a second language instruction based on a set second instruction template, and call a second autoregressive LLM to process the second language instruction to obtain second output information; the second input information comprises the user input text, the first output information and candidate information; the candidate information comprises one or more second entities and corresponding relationship types obtained by inputting the first output information into a knowledge graph for single-hop retrieval; the second output information comprises one or more second entities in the candidate information that are most relevant to the one or more first entities; A third processing unit is configured to convert third input information into a third language instruction based on a set third instruction template, and call a third autoregressive LLM to process the third language instruction to obtain third output information; the third input information comprises the second output information and the candidate information; the third output information comprises one or more relationship types that are most relevant to one or more second entities in the second output information; The first generating unit is configured to generate a reply statement about the user input text based on the second output information and the third output information.
11. An electronic device, comprising: A computer program product comprising a memory storing the computer program enabling a processor to perform the method for dialogue generation according to any one of claims 1 to 9.
12. A storage medium having stored thereon a computer program, characterized in that The computer program product is configured to perform the steps of the method according to any one of claims 1 to 9 when executed by the processor.
13. A computer program product comprising a computer program, characterized in that, The computer program product is configured to perform the steps of the method according to any one of claims 1 to 9 when executed by the processor. The computer program product is configured to perform the steps of the method according to any one of claims 1 to 9 when executed by the processor.
Citation Information
Patent Citations
Data processing method and device based on knowledge graph, electronic equipment and medium
CN116821372A
Method, medium and equipment for searching and outputting inquiry suggestion strategy based on knowledge graph
CN118245580A