Answer generation method and related device
By determining user intent and combining question-and-answer pair retrieval, knowledge graph retrieval, and large language models, the problem of low accuracy in intelligent question-answering systems has been solved, achieving higher accuracy in answer generation and improved user experience.
Patent Information
- Application Number
- CN202511069698.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-31
- Publication Date
- 2025-11-04
AI Technical Summary
Existing intelligent question-answering systems have low accuracy in answering a wide variety of user questions, resulting in a poor user experience.
By obtaining user input questions and determining their intent, question-answering pair retrieval and knowledge graph retrieval methods are used to find matching candidate questions and answers. Answers are generated by combining large language models, and intent recognition and matching are performed using ERNIE, BERT and graph neural network models. LoRA is used to fine-tune the DeepSeek model to improve the accuracy of answer generation.
It improves the accuracy of answer generation, enhances user experience, and ensures the highest degree of matching between answers and user-input questions through a combination of methods, thereby strengthening the answering capabilities of the intelligent question-answering system.
Smart Images

Figure CN120892531A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing technology, and in particular to an answer generation method and related apparatus. Background Technology
[0002] With the development of artificial intelligence, massive amounts of data have emerged on the internet, bringing users a wide variety of knowledge, but also increasing the difficulty for users to obtain information. To improve the efficiency of knowledge acquisition, intelligent question-answering systems have emerged. However, current intelligent question-answering systems suffer from low accuracy in answering the diverse range of questions posed by users, failing to effectively solve customer problems and resulting in a poor user experience. Summary of the Invention
[0003] In view of the above problems, this application provides an answer generation method and related apparatus, which can improve the accuracy of answer generation. The specific solution is as follows:
[0004] The first aspect of this application provides a method for generating answers, including:
[0005] The problem of obtaining user input;
[0006] Based on the user's input question, determine the user's intent in asking the question, and obtain the target intent;
[0007] The question-and-answer pair retrieval method is used to search the knowledge base for results related to the target meaning. Figure 1 The system identifies candidate questions that best match the user's input question, obtains the target question, and then retrieves the answer to the target question.
[0008] Using knowledge graph retrieval methods, search for information related to the target meaning. Figure 1 The system selects candidate answers that best match the user's input question and obtains the target answer.
[0009] The user-inputted question is fed into the large language model to obtain the answer from the large language model;
[0010] Based on the answer to the target question, the target answer, and the answer from the large language model, the answer to the question input by the user is obtained.
[0011] In one possible implementation, a question-answering pair retrieval method is employed to search for results in a knowledge base that match the target intent. Figure 1 The candidate questions are selected, and the candidate question with the highest degree of matching with the question input by the user is determined to obtain the target question, including:
[0012] The BM25 algorithm is used to obtain candidate questions that match the user's input question from the knowledge base;
[0013] The candidate questions are subjected to intent recognition using the ERNIE model to obtain the intent related to the target question. Figure 1 A sequence of candidate problems;
[0014] The BERT model is used to determine the candidate question that best matches the user's input question from the candidate question sequence, thus obtaining the target question.
[0015] In one possible implementation, a knowledge graph retrieval method is employed to search for information related to the target intent. Figure 1 The candidate answers are selected, and the candidate answer with the highest degree of matching with the user's input question is determined to obtain the target answer, including:
[0016] The BERT model is used to extract entity information from the user-input question;
[0017] A question template matching the target intent is determined, and the entity information is filled into the question template to obtain a template filled with entity information;
[0018] Based on the template filled with entity information, a match is found with the target intent. Figure 1 The corresponding candidate answers;
[0019] The entity information and the semantic information of the candidate answers are encoded to obtain the encoded information;
[0020] Based on the encoded information, a graph neural network model is used to determine the candidate answer that best matches the user's input question, thus obtaining the target answer.
[0021] In one possible implementation, obtaining the answer to the user-input question based on the answer to the target question, the target answer, and the large language model answer includes:
[0022] The answer to the target question, the target answer, the answer of the large language model, and the question input by the user are input into the large language model to obtain the answer to the question input by the user.
[0023] In one possible implementation, the large language model is a LoRA-based large language model.
[0024] In one possible implementation, after obtaining the answer to the user-input question, the method further includes:
[0025] In response to a rating of the answer to the question entered by the user;
[0026] If the score is lower than a preset value, the answer to the user's input question is adjusted to obtain an adjusted answer;
[0027] The knowledge base is updated based on the adjusted answers.
[0028] A second aspect of this application provides an answer generation system, comprising:
[0029] The question retrieval module is used to retrieve questions input by the user.
[0030] The intent determination module is used to determine the user's intent in asking the question based on the user's input, and to obtain the target intent;
[0031] The first matching module is used to search the knowledge base for results matching the target intent using a question-and-answer pair retrieval method. Figure 1 The system identifies candidate questions that best match the user's input question, obtains the target question, and then retrieves the answer to the target question.
[0032] The second matching module is used to search for matches with the target intent using a knowledge graph retrieval method. Figure 1 The system selects candidate answers that best match the user's input question and obtains the target answer.
[0033] The third matching module is used to input the user's input question into the large language model and obtain the answer from the large language model.
[0034] The answer generation module is used to obtain the answer to the user-input question based on the answer to the target question, the target answer, and the answer of the large language model.
[0035] A third aspect of this application provides a computer program product including computer-readable instructions that, when executed on an electronic device, cause the electronic device to implement the answer generation method described in the first aspect or any implementation thereof.
[0036] A fourth aspect of this application provides an electronic device, including at least one processor and a memory connected to the processor, wherein:
[0037] The memory is used to store computer programs;
[0038] The processor is used to execute the computer program so that the electronic device can implement the answer generation method of the first aspect or any implementation thereof.
[0039] The fifth aspect of this application provides a computer storage medium carrying one or more computer programs, which, when executed by an electronic device, enable the electronic device to perform the answer generation method described in the first aspect or any implementation thereof.
[0040] By employing the above technical solutions, the answer generation method and related apparatus provided in this application determine the user's intent in asking the question based on the user's input, thereby obtaining the target intent; and use a question-answer pair retrieval method to search for information matching the target intent in the knowledge base. Figure 1 The process involves identifying candidate questions that best match the user's input, determining the target question, and obtaining its answer. A knowledge graph retrieval method is then used to search for questions that best match the target question. Figure 1 The process involves generating candidate answers and identifying the one that best matches the user's input question to obtain the target answer. The user's input question is then input into a large language model to obtain its answer. Based on the target answer, the target answer, and the large language model answer, the answer to the user's input question is obtained. This application considers both the consistency of user intent and the degree of matching between search results and the user's input question, thereby improving the accuracy of answer generation and enhancing the user experience. Attached Figure Description
[0041] The above and other features, advantages, and aspects of the embodiments of this disclosure will become more apparent from the accompanying drawings and the following detailed description. Throughout the drawings, the same or similar reference numerals denote the same or similar elements. It should be understood that the drawings are schematic, and the originals and elements are not necessarily drawn to scale.
[0042] Figure 1 A flowchart of an answer generation method provided in this application;
[0043] Figure 2 A schematic diagram illustrating the construction of a prompt word template provided in this application;
[0044] Figure 3 A structural diagram of an intelligent question-answering system provided in this application;
[0045] Figure 4 This application provides a structural diagram of an answer generation system;
[0046] Figure 5 This is a schematic diagram of the structure of an electronic device provided in this application. Detailed Implementation
[0047] The embodiments of this application are described below with reference to the accompanying drawings. The terminology used in the implementation section of this application is for explaining specific embodiments only and is not intended to limit the scope of this application.
[0048] The embodiments of this application will now be described with reference to the accompanying drawings. Those skilled in the art will recognize that, with technological advancements and the emergence of new scenarios, the technical solutions provided in the embodiments of this application are equally applicable to similar technical problems.
[0049] The terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such terms are interchangeable where appropriate; this is merely a way of distinguishing objects with the same attributes in the embodiments of this application. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion, so that a process, method, system, product, or apparatus that comprises a series of elements is not necessarily limited to those elements, but may include other elements not explicitly listed or inherent to those processes, methods, products, or apparatuses.
[0050] This application provides an answer generation method. The answer generation method of this application embodiment will be described in detail below with reference to the accompanying drawings.
[0051] Reference Figure 1 , Figure 1 This is a flowchart illustrating an answer generation method provided in an embodiment of this application, such as... Figure 1 As shown in the embodiment of this application, an answer generation method may include steps 101 to 106, which are described in detail below.
[0052] Step 101: Obtain the question input from the user.
[0053] After obtaining the user's input question, issues such as typos and irrelevant words may exist. The input question can be corrected, specifically through a neural network model, such as a Convolutional Neural Network (CNN) or a Recurrent Neural Network (RNN). After correcting typos, irrelevant words can be removed from the corrected question, using an NLTK model.
[0054] In the financial field, there are many similar terms. Therefore, after correcting the user's input question, a thesaurus can be used to expand the user's input question to improve the recall rate in the search.
[0055] Step 102: Determine the user's intent in asking the question based on the user's input, and obtain the target intent.
[0056] The intent behind a user's questions may include, but is not limited to, pre-loan consultation, post-loan consultation, deposit consultation, withdrawal consultation, bank card application consultation, credit consultation, loss reporting consultation, and abnormal situation handling consultation.
[0057] When determining a user's intent based on their input, the ERNIE model can be fine-tuned using labeled intent data to accurately capture the user's true intent. The ERNIE model is a pre-trained language model based on the Transform architecture, addressing shortcomings of the BERT model in handling Chinese corpora. The BERT model, also a pre-trained language model primarily used in natural language processing, learns context-independent semantic vector representations of text through pre-training on a large amount of unlabeled text. This allows for fine-tuning in specific natural language processing tasks, achieving transfer learning effects.
[0058] Step 103: Use a question-and-answer pair retrieval method to search for results in the knowledge base that match the target meaning. Figure 1 The system generates candidate questions and identifies the one that best matches the user's input, thus obtaining the target question and its answer.
[0059] Question-answer pair retrieval is an information retrieval method that leverages existing question-answer datasets to quickly retrieve corresponding answers by matching user questions with questions in the dataset. It utilizes a pre-built database of question-answer pairs, employing similarity calculations or semantic understanding to find the question that best matches the user's input and returns the associated answer from the question-answer pair. By employing question-answer pair retrieval, one can find answers from a knowledge base that match the target information. Figure 1 The system generates candidate questions and identifies the one that best matches the user's input, thus obtaining the target question. After obtaining the target question, it uses question-answer pairs to determine the answers associated with it, thereby obtaining the answer to the target question.
[0060] In one possible implementation, a question-answering pair retrieval method is used to search for results in a knowledge base that match the target meaning. Figure 1 The target question is identified, and the degree of match between the target question and the user's input question is determined, including:
[0061] The BM25 algorithm is used to obtain candidate questions that match the user's input question from the knowledge base;
[0062] The ERNIE model is used to identify the intent of the candidate questions, and the results are obtained that match the target intent. Figure 1 A sequence of candidate problems;
[0063] The BERT model is used to identify the candidate question that best matches the user's input question from the candidate question sequence, thus obtaining the target question.
[0064] To ensure retrieval efficiency during question-answering pair retrieval, the system first uses BM25 for coarse-grained literal-meaning retrieval of user-inputted questions. Then, the ERNIE model is used to obtain the intent of the questions in the knowledge base, filtering out questions with the same intent as the user's input, thus obtaining a candidate question sequence. Next, a BERT model based on keyword attention is used for fine-grained ranking, identifying the candidate question with the highest degree of matching to the user's input from the candidate question sequence, thus obtaining the target question.
[0065] Search the knowledge base for information related to the target. Figure 1 When providing candidate questions, the intent of the candidate questions may include, but is not limited to, pre-loan consultation, post-loan consultation, deposit consultation, withdrawal consultation, bank card application consultation, credit consultation, loss reporting consultation, and abnormal situation handling consultation.
[0066] Step 104: Use knowledge graph retrieval methods to search for information related to the target meaning. Figure 1 The system generates a list of candidate answers and identifies the candidate answer that best matches the user's input question, thus obtaining the target answer.
[0067] Knowledge graph retrieval is an information retrieval method based on structured knowledge bases. It utilizes a semantic network composed of entities, attributes, and relationships to answer queries or provide relevant information. By employing knowledge graph retrieval, it is possible to find information related to the target meaning. Figure 1 The system generates a list of candidate answers and identifies the candidate answer that best matches the user's input question, thus obtaining the target answer.
[0068] In one possible implementation, a knowledge graph retrieval method is used to search for information related to the target meaning. Figure 1 The system generates candidate answers and identifies the candidate answer that best matches the user's input question, thus obtaining the target answer, including:
[0069] The BERT model is used to extract entity information from the user's input question;
[0070] Identify a question template that matches the target intent, and populate the entity information into the question template to obtain a template with the entity information filled in;
[0071] Based on the template with filled-in entity information, the target meaning can be found. Figure 1 The corresponding candidate answers;
[0072] The semantic information of entity information and candidate answers is encoded to obtain the encoded information;
[0073] Based on the encoded information, a graph neural network model is used to determine the candidate answer that best matches the user's input question, thus obtaining the target answer.
[0074] To enable effective retrieval and reasoning on sparse knowledge graphs, a BERT+GNN model was employed. This model primarily consists of two modules. Module 1 relies on the pre-trained BERT model to extract key entity information from the user's input question. Based on the user's intent, it selects the corresponding question template, thus completing slot filling—filling the question template with entity information. A query statement is constructed from this filled template, and candidate answers are retrieved from the Neo4j database. The semantic information of the entity information and candidate answers is encoded, simulating the human thought process and continuously collecting information. Module 2 receives the information from Module 1 in graph form and uses a graph neural network (GNN) to progressively deduce the question, continuously collecting relevant information to infer the next step. This process iterates until all possible candidate answers are found, and the candidate answer with the highest match to the user's input question is determined, yielding the target answer.
[0075] Step 105: Input the user's question into the large language model and obtain the answer from the large language model.
[0076] Optionally, the large language model is a LoRA-based large language model. This large language model can be DeepSeek.
[0077] LoRA (Low-Rank Adaptation) is a lightweight fine-tuning technique used to achieve efficient and low-cost model fine-tuning without updating the original model parameters. During model training, the main computation occurs in the weight matrix W (such as Q / K / V in Attention). LoRA, however, combines the original weights and inserts only two small matrices (A and B) onto it. During training, only these two small matrices are updated. This achieves low-rank approximate fine-tuning, significantly reducing the number of parameters.
[0078] Step 106: Based on the answer to the target question, the target answer, and the large language model answer, obtain the answer to the question input by the user.
[0079] In one possible implementation, the answer to the user-input question is obtained based on the answer to the target question, the target answer, and the answer from the large language model, including:
[0080] Input the answer to the target question, the target answer, the large language model answer, and the user-input question into the large language model to obtain the answer to the user-input question.
[0081] When obtaining the answer to a user's input question, the answer generated by the large language model can be combined with the answer to the target question obtained by the question-answering pair retrieval method and the target answer obtained by the knowledge graph retrieval method, together with the user's input question, to obtain the answer to the user's input question.
[0082] To enhance DeepSeek's text understanding capabilities in the financial domain, it is fine-tuned using financial data. Considering the high computational and storage costs of full-parameter fine-tuning and the risk of overfitting with small datasets, the LoRa (Local Alternate Range) technique is employed. This technique uses low-rank updates to the model weight matrix to simulate parameter changes, enabling indirect model training with a minimal number of parameters, effectively balancing efficiency and cost. The fine-tuning process includes: loading the DeepSeek model, integrating LoRa into the DeepSeek model, configuring a large language model based on LoRa, setting the optimizer and loss function, fine-tuning the model using financial data, and saving the model and configuration when validation set performance no longer improves; otherwise, continuing model training.
[0083] Question-answering generation based on DeepSeek utilizes the open-source DeepSeek model to understand and analyze retrieved knowledge, and then generates the correct answer. This process relies not only on the model's own knowledge base but also on its deep understanding and analysis capabilities of textual semantics. High-quality prompt word templates are crucial for improving the model's answer acquisition efficiency. In practical applications, questions, answers retrieved from knowledge graphs, answers retrieved from question-answer pairs, and DeepSeek responses can all be used as prompt words to guide the model in generating more accurate answers. By embedding the constructed knowledge base document into the prompt word template string, DeepSeek learns the possible contextual information, thereby improving the accuracy of answer generation.
[0084] A diagram illustrating the construction of a prompt word template is shown below. Figure 2 As shown, Figure 2 In this example, assuming a user asks "How to make an international remittance," the system generates answers based on the user's input using question-answer pair retrieval, knowledge graph retrieval, and a LoRA-based fine-tuned DeepSeek model. When constructing the prompts, the system combines the question ({question}), the question-answer pair answer ({QA_answer}), the knowledge graph answer ({KG_answer}), and the DeepSeek answer ({DS_answer}), inputting them into the LoRA-based fine-tuned DeepSeek model to output the final answer to the user's input question.
[0085] In one possible implementation, after obtaining the answer to the user's input question, the following is also included:
[0086] Responding to the rating of the answers to the questions entered by the user;
[0087] If the score is lower than the preset score, the answer to the user's input question will be adjusted to obtain the adjusted answer;
[0088] The knowledge base is updated based on the adjusted answers.
[0089] If the final answer to a user's input question does not satisfy the user, the user can choose a human response, which will then be sent to a human customer service representative for further updates to the knowledge base. The system can also record the responses and user feedback on the machine's answers, which can be manually reviewed, annotated, and used to update the knowledge base and adjust model parameters. Through customer service responses and answer feedback, the knowledge base and model parameters can be continuously updated and iterated, making the intelligent question-answering system increasingly intelligent.
[0090] The structure diagram of the intelligent question-answering system in this application is as follows: Figure 3 As shown, the data layer includes datasets, a financial question-and-answer community, common question-and-answer pairs, and a financial knowledge graph, as well as preprocessing for user-input questions, such as typo correction. In the application logic layer, question-and-answer pair retrieval is based on BM25 coarse screening and keyword-based BERT fine screening; knowledge graph retrieval is based on entity recognition and a BERT+CNN model; and answer generation is based on prompt word template construction and LoRA-based DeepSeek model fine-tuning. The application layer includes an answer evaluation management module, a customer service response module, a question-and-answer system response module, and other basic functions.
[0091] The answer generation method in this application involves performing corrective preprocessing on user-submitted questions to obtain a revised question and the intent of the current question. Appropriate retrieval methods are used for different knowledge sources (question-answer pair retrieval, knowledge graph retrieval, and the LoRA-based DeepSeek model) to obtain answers to user-submitted questions. Using a constructed prompt word template, the question and multiple answers are combined to form corresponding prompt words, thereby obtaining accurate answers based on the capabilities of the DeepSeek model. If the answer does not meet the user's needs, human customer service can provide a response. Answers and feedback in the question-answering system are automatically collected within the system. This answer evaluation and feedback data can be used to continuously adjust the model and update the knowledge base, thereby achieving effective and accurate responses from the intelligent question-answering system and continuously improving customer satisfaction.
[0092] This application targets the financial sector, categorizing user intent into different domains, including pre-loan consultation, post-loan consultation, deposit consultation, withdrawal consultation, bank card application consultation, credit inquiry consultation, card loss reporting consultation, and abnormal situation consultation intent. The ERNIE model is used to accurately capture user intent. By incorporating user intent into a question-and-answer pair retrieval method, it considers not only the similarity between the user's question and questions in the knowledge base but also the similarity between the intent of the user's question and the questions in the knowledge base, thus improving the accuracy of question-and-answer pair retrieval. Furthermore, by incorporating user intent into a knowledge graph retrieval method, employing a BERT+CNN-based retrieval approach, it enables effective reasoning on the knowledge graph and comprehensively considers the similarity of the user's question intent, thereby improving the accuracy of knowledge graph retrieval. In addition, DeepSeek is fine-tuned based on the LoRA method, effectively improving its answering capabilities in the financial domain. By constructing a prompt template method, it effectively enhances the fusion capability of answers from multiple knowledge bases.
[0093] The above describes an answer generation method provided by an embodiment of this application. The following will describe a system that performs the above answer generation method.
[0094] Please see Figure 4 , Figure 4 This is a schematic diagram of the structure of an answer generation system provided in an embodiment of this application. Figure 4 As shown, the answer generation system includes:
[0095] The question acquisition module 401 is used to acquire questions input by the user.
[0096] The intent determination module 402 is used to determine the intent of the user's question based on the user's input question, and obtain the target intent.
[0097] The first matching module 403 is used to search the knowledge base for results matching the target meaning using a question-and-answer pair retrieval method. Figure 1 The system generates candidate questions and identifies the one that best matches the user's input, thus obtaining the target question and its answer.
[0098] The second matching module 404 is used to search for matches with the target intent using a knowledge graph retrieval method. Figure 1 The system generates a list of candidate answers and identifies the candidate answer that best matches the user's input question, thus obtaining the target answer.
[0099] The third matching module 405 is used to input the user's question into the large language model and obtain the answer from the large language model.
[0100] The answer generation module 406 is used to obtain the answer to the user's input question based on the answer to the target question, the target answer, and the answer of the large language model.
[0101] In one possible implementation, the first matching module 403 is specifically used for:
[0102] The BM25 algorithm is used to obtain candidate questions that match the user's input question from the knowledge base;
[0103] The ERNIE model is used to identify the intent of the candidate questions, and the results are obtained that match the target intent. Figure 1 A sequence of candidate problems;
[0104] The BERT model is used to identify the candidate question that best matches the user's input question from the candidate question sequence, thus obtaining the target question.
[0105] In one possible implementation, the second matching module 403 is specifically used for:
[0106] The BERT model is used to extract entity information from the user's input question;
[0107] Identify a question template that matches the target intent, and populate the entity information into the question template to obtain a template with the entity information filled in;
[0108] Based on the template with filled-in entity information, the target meaning can be found. Figure 1 The corresponding candidate answers;
[0109] The semantic information of entity information and candidate answers is encoded to obtain the encoded information;
[0110] Based on the encoded information, a graph neural network model is used to determine the candidate answer that best matches the user's input question, thus obtaining the target answer.
[0111] In one possible implementation, the answer generation module 406 is specifically used for:
[0112] Input the answer to the target question, the target answer, the large language model answer, and the user-input question into the large language model to obtain the answer to the user-input question.
[0113] Optionally, the large language model is a LoRA-based large language model;
[0114] In one possible implementation, the answer generation system provided in this application further includes:
[0115] The update module is used to respond to the answer to the user's input question after obtaining the answer; if the score is lower than the preset score, adjust the answer to the user's input question to obtain the adjusted answer; and update the knowledge base based on the adjusted answer.
[0116] This application also provides an electronic device in its embodiments. (See reference...) Figure 5 The diagram illustrates a structural schematic suitable for implementing the electronic device in the embodiments of this application. The electronic device in the embodiments of this application may include, but is not limited to, fixed terminals such as mobile phones, laptops, PDAs (personal digital assistants), PADs (tablet computers), desktop computers, etc. Figure 5 The electronic device shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of this application.
[0117] like Figure 5 As shown, the electronic device may include a processing unit (e.g., a central processing unit, a graphics processing unit, etc.) 501, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 502 or a program loaded from a storage device 508 into a random access memory (RAM) 503. When the electronic device is powered on, the RAM 503 also stores various programs and data required for the operation of the electronic device. The processing unit 501, ROM 502, and RAM 503 are interconnected via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.
[0118] Typically, the following devices can be connected to I / O interface 505: input devices 506 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 507 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 508 including, for example, memory cards, hard drives, etc.; and communication devices 509. Communication device 509 allows electronic devices to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 5 Electronic devices with various devices are shown, but it should be understood that it is not required to implement or have all of the devices shown. More or fewer devices may be implemented or have alternatively.
[0119] This application also provides a computer program product including computer-readable instructions, which, when executed on an electronic device, cause the electronic device to implement any of the answer generation methods provided in this application.
[0120] This application also provides a computer-readable storage medium that carries one or more computer programs. When the one or more computer programs are executed by an electronic device, the electronic device can implement any of the answer generation methods provided in this application.
[0121] It should also be noted that the device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. In addition, in the device embodiment drawings provided in this application, the connection relationship between modules indicates that they have a communication connection, which can be implemented as one or more communication buses or signal lines.
[0122] Through the above description of the embodiments, those skilled in the art can clearly understand that this application can be implemented by means of software plus necessary general-purpose hardware, or it can be implemented by special-purpose hardware including application-specific integrated circuits, special-purpose CPUs, special-purpose memory, special-purpose components, etc. Generally, any function performed by a computer program can be easily implemented by corresponding hardware, and the specific hardware structure used to implement the same function can also be diverse, such as analog circuits, digital circuits, or special-purpose circuits. However, for this application, software program implementation is more often the preferred implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a readable storage medium, such as a computer floppy disk, USB flash drive, mobile hard disk, ROM, RAM, magnetic disk, or optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, training equipment, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0123] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product.
[0124] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions may be transmitted from one website, computer, training device, or data center to another website, computer, training device, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a training device or data center that integrates one or more available media. The available media may be magnetic media (e.g., floppy disks, hard disks, magnetic tapes), optical media (e.g., DVDs), or semiconductor media (e.g., solid-state drives (SSDs)).
Claims
1. A method for generating answers, characterized in that, include: The problem of obtaining user input; Based on the user's input question, determine the user's intent in asking the question, and obtain the target intent; The question-answering pair retrieval method is used to search for candidate questions that are consistent with the target intent from the knowledge base, and to determine the candidate question that has the highest degree of matching with the question input by the user, so as to obtain the target question and the answer to the target question; The knowledge graph retrieval method is used to find candidate answers that are consistent with the target intent, and the candidate answer with the highest degree of matching with the question entered by the user is determined to obtain the target answer; The user-input question is fed into the large language model to obtain the answer from the large language model; Based on the answer to the target question, the target answer, and the answer from the large language model, the answer to the question input by the user is obtained.
2. The answer generation method according to claim 1, characterized in that, The question-answering pair retrieval method searches the knowledge base for candidate questions that match the target intent, and determines the candidate question with the highest degree of matching with the user's input question to obtain the target question, including: The BM25 algorithm is used to obtain candidate questions that match the user's input question from the knowledge base; The candidate questions are subjected to intent recognition using the ERNIE model to obtain a sequence of candidate questions that are consistent with the target intent; The BERT model is used to determine the candidate question that best matches the user's input question from the candidate question sequence, thus obtaining the target question.
3. The answer generation method according to claim 1, characterized in that, The process involves employing a knowledge graph retrieval method to find candidate answers that align with the target intent, and determining the candidate answer with the highest degree of match to the user's input question, thereby obtaining the target answer. This includes: The BERT model is used to extract entity information from the user-input question; A question template matching the target intent is determined, and the entity information is filled into the question template to obtain a template filled with entity information; Based on the template with the filled-in entity information, candidate answers that match the target intent are obtained; The entity information and the semantic information of the candidate answers are encoded to obtain the encoded information; Based on the encoded information, a graph neural network model is used to determine the candidate answer that best matches the user's input question, thus obtaining the target answer.
4. The answer generation method according to claim 1, characterized in that, Obtaining the answer to the user-input question based on the answer to the target question, the target answer, and the large language model answer includes: The answer to the target question, the target answer, the answer of the large language model, and the question input by the user are input into the large language model to obtain the answer to the question input by the user.
5. The answer generation method according to claim 4, characterized in that, The large language model is a LoRA-based large language model.
6. The answer generation method according to any one of claims 1 to 5, characterized in that, After obtaining the answer to the user-input question, the process further includes: In response to a rating of the answer to the question entered by the user; If the score is lower than a preset value, the answer to the user's input question is adjusted to obtain an adjusted answer; The knowledge base is updated based on the adjusted answers.
7. An answer generation system, characterized in that, include: The question retrieval module is used to retrieve questions input by the user. The intent determination module is used to determine the user's intent in asking the question based on the user's input, and to obtain the target intent; The first matching module is used to use a question-answering pair retrieval method to search for candidate questions that are consistent with the target intent from the knowledge base, determine the candidate question with the highest degree of matching with the question input by the user, obtain the target question, and obtain the answer to the target question; The second matching module is used to use a knowledge graph retrieval method to find candidate answers that are consistent with the target intent, and to determine the candidate answer with the highest degree of matching with the question input by the user, so as to obtain the target answer; The third matching module is used to input the user's input question into the large language model and obtain the answer from the large language model. The answer generation module is used to obtain the answer to the user-input question based on the answer to the target question, the target answer, and the answer of the large language model.
8. A computer program product, characterized in that, It includes computer-readable instructions that, when executed on an electronic device, cause the electronic device to implement the answer generation method as described in any one of claims 1 to 6.
9. An electronic device, characterized in that, It includes at least one processor and a memory connected to the processor, wherein: The memory is used to store computer programs; The processor is used to execute the computer program to enable the electronic device to implement the answer generation method as described in any one of claims 1 to 6.
10. A computer storage medium, characterized in that, The storage medium carries one or more computer programs that, when executed by an electronic device, enable the electronic device to implement the answer generation method as described in any one of claims 1 to 6.