Financial field knowledge question and answer method and device, computer device, readable storage medium and program product
By constructing a text block library and question-answer pair library in the financial field, and combining similarity calculation and large language model, the problem of inaccurate answers in question-answering in the financial field by large language model is solved, and more accurate and efficient question-answering processing is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHINA CONSTRUCTION BANK
- Filing Date
- 2024-06-06
- Publication Date
- 2026-06-09
AI Technical Summary
Large language models struggle to accurately assess their knowledge in financial question-answering tasks, leading to inaccurate, meaningless, or unrealistic generated answers, resulting in hallucinations.
We construct a text block library and a question-answer pair library based on financial texts. By calculating the similarity between the question and preset questions and text blocks, and combining this with a large language model, we generate answers to ensure their accuracy.
It improves the accuracy and efficiency of question-and-answer tasks in the financial field, reduces the possibility of illusory answers, and provides more relevant pending answers.
Smart Images

Figure CN118467704B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of artificial intelligence technology, and in particular to a knowledge-based question-answering method, apparatus, computer device, computer-readable storage medium, and computer program product in the financial field. Background Technology
[0002] With the rapid development of artificial intelligence technology, large language models are playing an increasingly important role in question-answering tasks. After extensive training and learning, large language models are able to generate corresponding answers based on the input question.
[0003] However, because large language models acquire knowledge primarily through training data, and it's difficult to accurately determine which information they have mastered and which they haven't fully grasped, the models cannot ascertain the accuracy of their generated answers. Consequently, current large language models are prone to "illusion" phenomena when generating answers, resulting in inaccurate, meaningless, or unrealistic responses that fail to accurately address the question. Summary of the Invention
[0004] Therefore, it is necessary to provide a financial knowledge question-answering method, device, computer equipment, computer-readable storage medium, and computer program product to address the aforementioned technical problems.
[0005] Firstly, this application provides a knowledge-based question-and-answer method in the financial field, including:
[0006] Obtain a text block library and question-answer pair library built based on financial texts;
[0007] If the current question is related to the financial field, then obtain the first similarity between the current question and each preset question in the question-answering database;
[0008] If there is a first question in the question-answering database with a similarity greater than the first threshold, then an undetermined answer is obtained based on the first answer corresponding to the first question in the question-answering database;
[0009] If the first question does not exist in the question-answer pair library, but there is a second question whose first similarity is between the first threshold and the second threshold, then obtain the second answer corresponding to the second question in the question-answer pair library, and obtain the second similarity between the current question and each text block in the text block library;
[0010] If a similar text block with a similarity greater than the third threshold exists in the text block library, the undetermined answer is obtained based on the similar text block and the second answer; if the similar text block does not exist in the text block library, the undetermined answer is obtained based on the second answer.
[0011] If the current question and the pending answer are related, then the target answer is obtained based on the current question and the pending answer.
[0012] In one embodiment, before calculating the first similarity between the current question and each preset question in the question-answer pair library if the current question is a financial-related question, the method further includes: receiving a question to be processed; if the question to be processed has historical questions and answers, obtaining the question intent of the question to be processed based on the historical questions and answers and the question to be processed; obtaining the current question based on the question intent; if the question to be processed does not have the historical questions and answers, obtaining the current question based on the question to be processed.
[0013] In one embodiment, obtaining the question intent of the pending question based on the historical questions and answers and the pending question includes: obtaining first question information based on a first prompt template, the historical questions and answers, and the pending question; inputting the first question information into a large language model to obtain the question intent of the pending question output by the large language model based on the first question information.
[0014] In one embodiment, obtaining the target answer based on the current question and the pending answer includes: if the current question does not have historical questions and answers, then inputting the current question and the pending answer into a large language model to obtain the target answer output by the large language model; if the current question has historical questions and answers, then inputting the historical questions and answers, the current question, and the pending answer into the large language model to obtain the target answer output by the large language model.
[0015] In one embodiment, after obtaining the first similarity between the current question and each preset question in the question-answer pair library, the method further includes: if the first question and the second question do not exist in the question-answer pair library, then obtaining the text similarity between the current question and each text block in the text block library; if there are similar text blocks in the text block library with a text similarity greater than a third threshold, then obtaining the undetermined answer based on the similar text blocks.
[0016] In one embodiment, the method further includes: splitting the financial text into multiple text blocks; inputting each text block into a large language model to obtain question-answer pairs corresponding to each text block output by the large language model; training a vector model to be trained based on each question-answer pair to obtain a trained vector model; converting each text block into a text block vector using the trained vector model, and converting the preset questions in each question-answer pair into question vectors using the trained vector model; constructing a text block library based on each text block and each text block vector, and constructing a question-answer pair library based on each question-answer pair and each question vector.
[0017] In one embodiment, obtaining the first similarity between the current question and each preset question in the question-answering pair library includes: converting the current question into a current question vector using the trained vector model; calculating the first vector similarity between the current question vector and each question vector in the question-answering pair library; and obtaining the first similarity of each preset question based on the first vector similarity corresponding to each question vector.
[0018] In one embodiment, obtaining the second similarity between the current question and each text block in the text block library includes: converting the current question into a current question vector using the trained vector model; calculating the second vector similarity between the current question vector and each text block vector in the text block library; and obtaining the second similarity of each text block based on the second vector similarity corresponding to each text block vector.
[0019] In one embodiment, after obtaining the pending answer, the method further includes: obtaining second question information based on the second prompt template, the current question, and the pending answer; inputting the second question information into a large language model to obtain a judgment result output by the large language model based on the second question information, indicating whether the current question and the pending answer are related.
[0020] In one embodiment, before obtaining the first similarity between the current question and each preset question in the question-answering database if the current question is related to the financial field, the method further includes: obtaining third question information based on a third prompt template and the current question; inputting the third question information into a large language model to obtain a judgment result output by the large language model based on the third question information, indicating whether the current question is related to the financial field.
[0021] In one embodiment, the method further includes: if the current question has historical questions and answers, and the current question is not a financial question, then inputting the current question and the historical questions and answers into a large language model to obtain the target answer output by the large language model; if the current question does not have historical questions and answers, and the current question is not a financial question, then inputting the current question into the large language model to obtain the target answer output by the large language model.
[0022] Secondly, this application also provides a financial knowledge question-and-answer device, including:
[0023] The first acquisition module is used to acquire a text block library and a question-answer pair library built based on texts in the financial field;
[0024] The second acquisition module is used to acquire the first similarity between the current question and each preset question in the question-answering database if the current question is a financial question.
[0025] The first answer determination module is used to obtain a pending answer based on the first answer corresponding to the first question in the question-answer pair library if there is a first question in the question-answer pair library with a first similarity greater than a first threshold.
[0026] The third acquisition module is used to acquire the second answer corresponding to the second question in the question-answer pair library if the first question does not exist in the question-answer pair library and there is a second question with the first similarity between the first threshold and the second threshold, and to acquire the second similarity between the current question and each text block in the text block library.
[0027] The second answer determination module is used to obtain the undetermined answer based on the similar text block and the second answer if there is a similar text block in the text block library with a similarity greater than the third threshold; and to obtain the undetermined answer based on the second answer if there is no similar text block in the text block library.
[0028] The first target acquisition module is used to obtain the target answer based on the current question and the pending answer if the current question and the pending answer are associated.
[0029] Thirdly, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to perform the following steps:
[0030] Obtain a text block library and question-answer pair library built based on financial texts;
[0031] If the current question is related to the financial field, then obtain the first similarity between the current question and each preset question in the question-answering database;
[0032] If there is a first question in the question-answering database with a similarity greater than the first threshold, then an undetermined answer is obtained based on the first answer corresponding to the first question in the question-answering database;
[0033] If the first question does not exist in the question-answer pair library, but there is a second question whose first similarity is between the first threshold and the second threshold, then obtain the second answer corresponding to the second question in the question-answer pair library, and obtain the second similarity between the current question and each text block in the text block library;
[0034] If a similar text block with a similarity greater than the third threshold exists in the text block library, the undetermined answer is obtained based on the similar text block and the second answer; if the similar text block does not exist in the text block library, the undetermined answer is obtained based on the second answer.
[0035] If the current question and the pending answer are related, then the target answer is obtained based on the current question and the pending answer.
[0036] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, performs the following steps:
[0037] Obtain a text block library and question-answer pair library built based on financial texts;
[0038] If the current question is related to the financial field, then obtain the first similarity between the current question and each preset question in the question-answering database;
[0039] If there is a first question in the question-answering database with a similarity greater than the first threshold, then an undetermined answer is obtained based on the first answer corresponding to the first question in the question-answering database;
[0040] If the first question does not exist in the question-answer pair library, but there is a second question whose first similarity is between the first threshold and the second threshold, then obtain the second answer corresponding to the second question in the question-answer pair library, and obtain the second similarity between the current question and each text block in the text block library;
[0041] If a similar text block with a similarity greater than the third threshold exists in the text block library, the undetermined answer is obtained based on the similar text block and the second answer; if the similar text block does not exist in the text block library, the undetermined answer is obtained based on the second answer.
[0042] If the current question and the pending answer are related, then the target answer is obtained based on the current question and the pending answer.
[0043] Fifthly, this application also provides a computer program product, including a computer program that, when executed by a processor, performs the following steps:
[0044] Obtain a text block library and question-answer pair library built based on financial texts;
[0045] If the current question is related to the financial field, then obtain the first similarity between the current question and each preset question in the question-answering database;
[0046] If there is a first question in the question-answering database with a similarity greater than the first threshold, then an undetermined answer is obtained based on the first answer corresponding to the first question in the question-answering database;
[0047] If the first question does not exist in the question-answer pair library, but there is a second question whose first similarity is between the first threshold and the second threshold, then obtain the second answer corresponding to the second question in the question-answer pair library, and obtain the second similarity between the current question and each text block in the text block library;
[0048] If a similar text block with a similarity greater than the third threshold exists in the text block library, the undetermined answer is obtained based on the similar text block and the second answer; if the similar text block does not exist in the text block library, the undetermined answer is obtained based on the second answer.
[0049] If the current question and the pending answer are related, then the target answer is obtained based on the current question and the pending answer.
[0050] The aforementioned financial knowledge question-answering method, device, computer equipment, computer-readable storage medium, and computer program product acquire a text block library and a question-answer pair library constructed based on financial text. If the current question is a financial-related question, the method acquires the first similarity between the current question and each preset question in the question-answer pair library. If there is a first question in the question-answer pair library with a first similarity greater than a first threshold, the method obtains a pending answer based on the first answer corresponding to the first question in the question-answer pair library. If there is no first question in the question-answer pair library but there is a second question with a first similarity between the first and second thresholds, the method acquires the second answer corresponding to the second question in the question-answer pair library, and acquires the second similarity between the current question and each text block in the text block library. If there is a similar text block in the text block library with a second similarity greater than a third threshold, the method obtains a pending answer based on the similar text block and the second answer. If there is no similar text block in the text block library, the method obtains a pending answer based on the second answer. When the current question and the pending answer are associated, the method obtains the target answer based on the current question and the pending answer. This solution, targeting question-and-answer tasks in the financial field, achieves more relevant pending answers by combining a text block library built from financial text with a question-and-answer pair library for refined searching. Specifically, when processing the current question, searching the question-and-answer pair library only after determining that the question is financially relevant eliminates unnecessary searches, improving efficiency. Searching the question-and-answer pair library accurately and quickly determines whether similar pre-defined questions exist. If a first question with a similarity greater than a first threshold exists in the library, its answer is directly used as a pending answer, effectively improving response efficiency. If a second question with a similarity between the first and second thresholds exists, further searching the text block library and combining the answer to the pre-defined question with potentially similar text blocks obtained from the text block library yields a more comprehensive pending answer, even when the first question is not present in the library. Then, by judging whether there is a correlation between the pending answer and the current question, and if the two are judged to be related, the target answer is obtained based on the current question and the pending answer. This can further ensure the relevance between the final output target answer and the current question, and effectively reduce the possibility of answering hallucination questions. Attached Figure Description
[0051] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments of this application or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0052] Figure 1 This is a flowchart illustrating a knowledge-based question-answering method in the financial field in one embodiment;
[0053] Figure 2 This is a flowchart illustrating the process of building a text block library and a question-answer pair library in one embodiment;
[0054] Figure 3 This is a schematic diagram of the process for obtaining the first similarity in one embodiment;
[0055] Figure 4 This is a schematic diagram of the process for obtaining the second similarity in one embodiment;
[0056] Figure 5 This is a flowchart illustrating the pre-processing flow of a financial domain knowledge question-answering method in one embodiment;
[0057] Figure 6 This is a flowchart illustrating the knowledge retrieval enhancement generation process of a knowledge question answering method in the financial field in one embodiment;
[0058] Figure 7 This is a flowchart illustrating how the search module processes the current problem in one embodiment;
[0059] Figure 8 This is a structural block diagram of a financial knowledge question-answering device in one embodiment;
[0060] Figure 9 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0061] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application. It should be noted that existing industry solutions such as software, components, and models may be mentioned in the embodiments of this application. These should be considered exemplary and are intended only to illustrate the feasibility of implementing the technical solutions of this application, but do not imply that the applicant has already used or necessarily used such solutions.
[0062] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of related data must comply with relevant regulations. The acquisition, storage, use and processing of data in the technical solution of this application all comply with the relevant provisions of national laws and regulations.
[0063] like Figure 1 As shown, a knowledge-based question-answering method in the financial field is provided. This embodiment illustrates the method by applying it to a server. It is understood that this method can also be applied to a terminal, or to a system including both a terminal and a server, and is implemented through interaction between the terminal and the server. In this embodiment, the method includes the following steps:
[0064] Step S101: Obtain a text block library and a question-answer pair library built based on financial texts.
[0065] This step involves acquiring a pre-built and stored text block library and question-answer pair library based on financial domain text. The text block library can include multiple text blocks derived from the financial domain text, and the question-answer pair library can include multiple question-answer pairs generated from the financial domain text. Each question-answer pair can include a preset question and its corresponding answer.
[0066] Step S102: If the current question is a financial question, then obtain the first similarity between the current question and each preset question in the question-answering database.
[0067] Specifically, the current question can be a question received from a user terminal, or a question obtained after processing a question received from a user terminal. For the current question, it can first be determined whether the question is related to the financial field. If it is determined to be related to the financial field, then this processing step is executed. One or more methods can be used to determine whether the current question is related to the financial field. For example, in some implementations, natural language processing techniques such as keyword detection, semantic analysis, and large language model processing can be used to analyze the current question to obtain the corresponding judgment result. In other implementations, the current question may have a corresponding domain tag. By querying the domain tag corresponding to the current question, the relevant domain of the current question can be identified, thereby determining whether it is related to the financial field.
[0068] In determining that the current question is related to the financial field, this step involves obtaining the first similarity score between the current question and each preset question in the question-answering database. This first similarity score measures the degree of similarity between the current question and the preset questions; the higher the first similarity score, the more similar the current question is to the preset question. To facilitate the evaluation of the first similarity score, a first threshold and a second threshold can be set, where the first threshold is greater than the second threshold. When the first similarity score is greater than the first threshold, the two questions are considered very similar; when the first similarity score is between the first and second thresholds, the two questions are considered relatively similar.
[0069] Understandably, if the current question is determined not to be related to the financial field, the search of the question-answer pair database and the text block database can be omitted, and the target answer can be obtained directly from the current question. For example, in this case, the current question can be input into a large language model to obtain the target answer output by the large language model.
[0070] Step S103: If there is a first question in the question-answering pair library with a first similarity greater than a first threshold, then obtain the undetermined answer based on the first answer corresponding to the first question in the question-answering pair library.
[0071] Specifically, when one or more preset questions with a first similarity greater than a first threshold exist in the question-answering pair library, these preset questions can be used as the first questions, and the first answer corresponding to each first question can be obtained from the question-answering pair library. Then, the first answer can be used as the pending answer corresponding to the current question.
[0072] Step S104: If there is no first question in the question-answer pair library, and there is a second question with a first similarity between the first threshold and the second threshold, then obtain the second answer corresponding to the second question in the question-answer pair library, and obtain the second similarity between the current question and each text block in the text block library.
[0073] Specifically, when the first similarity of each preset question in the question-answer pair library is less than the first threshold, but the first similarity of one or more preset questions is greater than the second threshold, these preset questions can be used as second questions, and the second answer corresponding to each second question can be obtained from the question-answer pair library.
[0074] Simultaneously, in this step, a second similarity score can be obtained between the current question and each text block in the text block library. This second similarity score measures the degree of similarity between the current question and the text block; the higher the second similarity score, the more similar the current question is to the text block. To facilitate the evaluation of the second similarity score, a third threshold can be set. When the second similarity score is greater than the third threshold, the current question is considered similar to the text block; when the second similarity score is not greater than the third threshold, the current question is considered dissimilar to the text block.
[0075] Step S105: If there are similar text blocks in the text block library with a second similarity greater than the third threshold, then obtain the undetermined answer based on the similar text blocks and the second answer; if there are no similar text blocks in the text block library, then obtain the undetermined answer based on the second answer.
[0076] Specifically, if one or more text blocks in the text block library have a second similarity greater than the third threshold, these text blocks can be considered as similar text blocks for the current question. Based on this, the similar text blocks and the second answer corresponding to the second question obtained in the aforementioned process can be combined to obtain the undetermined answer for the current question.
[0077] If there is no text block in the text block with a second similarity greater than the third threshold, then in this step, the undetermined answer corresponding to the current question can be obtained directly from the second answer obtained in the aforementioned process.
[0078] Step S106: If the current question and the pending answer are related, then obtain the target answer based on the current question and the pending answer.
[0079] In this process, the undetermined answers obtained can be further analyzed to determine their relevance to the current question. If a relevance is found, the target answer can be derived from the current question and the undetermined answers. For example, in this step, the current question and the undetermined answers can be input into a large language model to obtain the target answer output by the model.
[0080] In the aforementioned financial knowledge question-answering method, a text block library and a question-answer pair library are obtained based on financial text. If the current question is a financial-related question, the first similarity between the current question and each preset question in the question-answer pair library is obtained. If there is a first question in the question-answer pair library with a first similarity greater than a first threshold, a pending answer is obtained based on the first answer corresponding to the first question in the question-answer pair library. If there is no first question in the question-answer pair library but there is a second question with a first similarity between the first and second thresholds, the second answer corresponding to the second question in the question-answer pair library is obtained, and the second similarity between the current question and each text block in the text block library is obtained. If there is a similar text block in the text block library with a second similarity greater than a third threshold, a pending answer is obtained based on the similar text block and the second answer. If there is no similar text block in the text block library, a pending answer is obtained based on the second answer. When the current question and the pending answer are associated, the target answer is obtained based on the current question and the pending answer. This solution, targeting question-and-answer tasks in the financial field, achieves more relevant pending answers by combining a text block library built from financial text with a question-and-answer pair library for refined searching. Specifically, when processing the current question, searching the question-and-answer pair library only after determining that the question is financially relevant eliminates unnecessary searches, improving efficiency. Searching the question-and-answer pair library accurately and quickly determines whether similar pre-defined questions exist. If a first question with a similarity greater than a first threshold exists in the library, its answer is directly used as a pending answer, effectively improving response efficiency. If a second question with a similarity between the first and second thresholds exists, further searching the text block library and combining the answer to the pre-defined question with potentially similar text blocks obtained from the text block library yields a more comprehensive pending answer, even when the first question is not present in the library. Then, by judging whether there is a correlation between the pending answer and the current question, and if the two are judged to be related, the target answer is obtained based on the current question and the pending answer. This can further ensure the relevance between the final output target answer and the current question, and effectively reduce the possibility of answering hallucination questions.
[0081] In one exemplary embodiment, considering the possibility that the first similarity of all preset questions in the question-answer pair library is lower than the second threshold, after obtaining the first similarity between the current question and each preset question in the question-answer pair library, the method may further include: if there is no first question or second question in the question-answer pair library, then obtaining the text similarity between the current question and each text block in the text block library; if there is a similar text block in the text block library with a text similarity greater than the third threshold, then obtaining the undetermined answer based on the similar text block.
[0082] Specifically, if the first similarity of all preset questions in the question-answering pair library is below the second threshold, then neither the first question nor the second question exists in the library. Based on this, a text block library can be searched to obtain the second similarity between each text block in the library and the current question. If one or more text blocks in the text block library have a second similarity greater than the third threshold, these text blocks can be considered as similar text blocks to the current question, and the corresponding undetermined answer can be obtained based on these similar text blocks.
[0083] Understandably, when no text block in the text block library has a second similarity greater than the third threshold, the target answer can be obtained directly from the current question without relying on the question-answering pair library and the text block library. For example, in this case, the current question can be input into a large language model to obtain the target answer output by the large language model.
[0084] In this embodiment, if the first question and the second question do not exist in the question-answering pair library, the second similarity between each text block in the text block library and the current question is further calculated. If it is determined that there are similar text blocks, the undetermined answer is obtained based on the similar text blocks. This can directly search for similar text blocks in the text block library when the preset question fails to cover the current question, thereby increasing the probability of obtaining the undetermined answer and improving the accuracy of question answering.
[0085] In the process of handling financial knowledge-based question-and-answer tasks, the issues that need to be addressed may include follow-up questions from users based on previous questions and answers. Therefore, this application can further incorporate existing historical questions and answers to perform more refined processing of financial knowledge-based question-and-answer tasks.
[0086] In an exemplary embodiment, if the current question is a financial-related question, before the step of calculating the first similarity between the current question and each preset question in the question-answer pair library, the method may further include: receiving a question to be processed; if the question to be processed has historical questions and answers, obtaining the question intent of the question to be processed based on the historical questions and answers and the question to be processed; obtaining the current question based on the question intent; if the question to be processed does not have historical questions and answers, obtaining the current question based on the question to be processed.
[0087] For example, in a financial knowledge-based Q&A platform, a user can ask one or more questions in one or more rounds of Q&A, where the question to be processed can be the latest question received by the server from the user's terminal. In some implementations, historical Q&A may include the previous question received by the server in the current round of Q&A, and the answer returned for that previous question; in other implementations, historical Q&A may also include multiple previous questions received by the server in the current round of Q&A, and the answers returned for each previous question. In some implementations, historical Q&A may also include previous questions asked by the same user in multiple rounds of Q&A, and the answers returned for each previous question. Based on this, after receiving a question to be processed, it can be determined whether there are historical Q&A for the question to be processed by querying the Q&A records of the current round of Q&A, or by querying the Q&A records corresponding to the same user identifier.
[0088] In cases where a pending question has historical Q&A, the pending question may be a follow-up question from the user based on the historical Q&A. Based on this, the historical Q&A of the pending question can be obtained, and by combining the historical Q&A with the pending question, technologies such as natural language processing can be used to extract the user's true intention in the pending question, and then the current question can be obtained based on the intention.
[0089] If there is no historical Q&A for the question to be processed, the current question can be obtained directly from the question to be processed. For example, in this case, the question to be processed can be used directly as the current question, or the question to be processed can be preprocessed, such as by correcting typos or grammar, to obtain the current question.
[0090] In this embodiment, considering the possibility of historical questions and answers for the question to be processed, the intent of the question to be processed is determined by combining the historical questions and answers with the question to be processed, and the current question is obtained based on the intent. This approach can obtain a more accurate current question by combining the context of the question to be processed, effectively improving the accuracy of question and answer.
[0091] In an exemplary embodiment, obtaining the question intent of the pending question based on historical questions and answers and pending questions may include: obtaining first question information based on a first prompt template, historical questions and answers, and pending questions; inputting the first question information into a large language model to obtain the question intent of the pending question output by the large language model based on the first question information.
[0092] When a question to be processed has historical questions and answers, this embodiment can combine a preset first prompt template with a large language model to obtain the question intent of the question to be processed. For example, the first prompt template may include reserved positions for filling in historical questions and answers and the question to be processed, respectively, and first text content instructing the large language model to extract the question intent based on the historical questions and answers and the question to be processed in the reserved positions without modification, expansion, or fabrication. By filling in the historical questions and answers and the question to be processed into the corresponding reserved positions in the first prompt template, a first question information containing the historical questions and answers, the question to be processed, and the first text content can be obtained. Then, by inputting this first question information into the large language model, the question intent of the question to be processed output by the large language model can be obtained.
[0093] In this embodiment, by using prompt templates and a large language model, combined with historical questions and answers and questions to be processed, the intent of the questions to be processed can be obtained. This can efficiently and quickly determine the user's true intent in the questions to be processed and obtain the corresponding current question, thereby improving the overall processing efficiency of question-and-answer tasks.
[0094] In an exemplary embodiment, obtaining the target answer based on the current question and the pending answer may include: if the current question does not have historical questions and answers, then inputting the current question and the pending answer into the large language model to obtain the target answer output by the large language model; if the current question has historical questions and answers, then inputting the historical questions and answers, the current question, and the pending answer into the large language model to obtain the target answer output by the large language model.
[0095] In this embodiment, the process of obtaining the target answer can be refined for two different scenarios: whether the current question has historical questions and answers. If the current question does not have historical questions and answers, the current question and the pending answer can be input into a large language model. The large language model then combines the content of the pending answer to answer the current question and obtains the target answer output by the model. If the current question has historical questions and answers, the historical questions and answers can be obtained, and then the historical questions and answers, the current question, and the pending answer can be input together into the large language model. The large language model then combines the content of the historical questions and answers and the pending answer to answer the current question and obtains the target answer output by the model.
[0096] In this embodiment, by inputting the current question and the pending answer into the large language model, the large language model can answer the current question based on the financial domain knowledge contained in the pending answer, thereby outputting a more accurate target answer. Furthermore, in this embodiment, when historical question-and-answer sequences exist for the current question, the target answer is further obtained by combining these sequences. This allows the large language model to answer the current question in context and output a more relevant target answer, which helps reduce the illusion problem of the large language model directly answering the question.
[0097] In an exemplary embodiment, the method may further include: if the current question has historical questions and answers, and the current question is not a financial question, then inputting the current question and historical questions and answers into a large language model to obtain the target answer output by the large language model; if the current question does not have historical questions and answers, and the current question is not a financial question, then inputting the current question into a large language model to obtain the target answer output by the large language model.
[0098] If the current question is not related to the financial field, this embodiment may not search the text block library and question-answer pair library, but may obtain the target answer directly based on the current question or based on the combination of the current question and historical questions and answers.
[0099] In this embodiment, if historical questions and answers exist for the current question, these historical questions and answers can be retrieved. The current question and historical questions and answers are then input together into the large language model, which combines the content of the historical questions and answers to answer the current question and obtain the target answer output by the model. Conversely, if no historical questions and answers exist for the current question, the current question can be directly input into the large language model, which will directly answer the current question and obtain the target answer output by the model.
[0100] In this embodiment, when the current question is not related to the financial field, the target answer is obtained by combining the current question and the historical questions and answers when there are historical questions and answers for the current question. This enables the large language model to answer the current question in combination with the context and output a more relevant target answer, which helps to reduce the illusion problem of the large language model directly answering the question.
[0101] In some exemplary embodiments, this application can pre-build a text block library and a question-answer pair library based on financial text. In one exemplary embodiment, such as... Figure 2 As shown, the method may also include:
[0102] Step S201: Split the financial text into multiple text blocks.
[0103] In this step, the acquired financial text can be split into multiple text blocks. For example, the length of each text block can be within a preset range, such as between 300 and 500 characters.
[0104] Step S202: Input each text block into the large language model to obtain the question-answer pairs corresponding to each text block output by the large language model.
[0105] In this step, each text block can be input into the large language model. The large language model generates one or more pre-defined questions for each input text block, as well as answers for each pre-defined question. One pre-defined question and its corresponding answer can form a question-answer pair. Based on this, the question-answer pairs corresponding to each text block output by the large language model can be obtained.
[0106] Step S203: Train the vector model to be trained according to each question and answer pair to obtain the trained vector model.
[0107] In this step, the question-answer pairs corresponding to the text blocks obtained above can be used to train the vector model to be trained, thereby obtaining a trained vector model with better knowledge search capabilities in the financial field. This trained vector model can then be used to vectorize the text, converting the text into corresponding vectors.
[0108] Step S204: Convert each text block into a text block vector using a trained vector model, and convert the preset questions in each question-answer pair into question vectors using a trained vector model.
[0109] Step S205: Construct a text block library based on each text block and each text block vector, and construct a question-answer pair library based on each question-answer pair and each question vector.
[0110] Based on the trained vector model obtained above, in step S204, this model can be used to convert each text block into its corresponding text block vector, and to convert the preset questions in each question-answer pair into their corresponding question vectors. Then, in step S205, a text block library can be constructed based on each text block and its corresponding text block vector. Additionally, a question-answer pair library can be constructed based on each question-answer pair and its corresponding question vector.
[0111] In this embodiment, text blocks are extracted from financial text, and question-answer pairs are generated from these text blocks. This provides pre-set questions and corresponding answers based on the text blocks for question-answering tasks, thereby reducing the possibility of illusion problems in question-answering. Furthermore, this embodiment uses the question-answer pairs to train the vector model to be trained, resulting in a trained vector model with better financial knowledge search capabilities. This model is then used to perform vector transformations on the pre-set questions and text blocks, combining financial knowledge to obtain more accurate question vectors and text block vectors. Subsequently, question-answer pair libraries and text block libraries are constructed, facilitating more accurate calculations of the first and second similarities, thus providing more relevant answers to the current question.
[0112] In one exemplary embodiment, such as Figure 3As shown, obtaining the first similarity between the current question and each preset question in the question-answering database can include:
[0113] Step S301: The current problem is transformed into a current problem vector using a trained vector model.
[0114] Step S302: Calculate the first vector similarity between the current question vector and each question vector in the question-answering pair library.
[0115] Step S303: Obtain the first similarity of each preset question based on the similarity of each first vector corresponding to each question vector.
[0116] Based on the aforementioned question-answering database, this embodiment can obtain the first similarity between the current question and each preset question in the database by calculating vector similarity. Specifically, in step S301, the current question is first converted into a corresponding current question vector using a trained vector model. Then, in step S302, the question vectors corresponding to each preset question in the database are obtained, and the first vector similarity between the current question vector and each question vector is calculated. Subsequently, in step S303, based on the correspondence between each question vector and a preset question, the first similarity of the corresponding preset question can be obtained from the first vector similarity of the question vector.
[0117] In this embodiment, for the calculation of the first similarity, the same trained vector model is used to perform vector transformation on the current question, so as to obtain a current question vector that better reflects the characteristics of the current question in the financial field. Then, the second vector similarity between the current question vector and each question vector is calculated respectively. Based on the knowledge in the financial field, the similarity between the current question and each preset question can be more accurately evaluated, thereby improving the accuracy of question answering.
[0118] In one exemplary embodiment, such as Figure 4 As shown, obtaining the second similarity between the current question and each text block in the text block library can include:
[0119] Step S401: The current problem is transformed into a current problem vector using a trained vector model.
[0120] Step S402: Calculate the second vector similarity between the current question vector and each text block vector in the text block library.
[0121] Step S403: Obtain the second similarity of each text block based on the similarity of each second vector corresponding to each text block vector.
[0122] Based on the aforementioned text block library, this embodiment can obtain the second similarity between the current question and each text block in the text block by calculating vector similarity. Specifically, in step S401, the current question is first converted into a corresponding current question vector using a trained vector model. Then, in step S402, the text block vectors corresponding to each text block in the text block library are obtained, and the second vector similarity between the current question vector and each text block vector is calculated. Subsequently, in step S403, the second similarity of the corresponding text block can be obtained from the second vector similarity of the text block vector based on the correspondence between each text block vector and the text block.
[0123] In this embodiment, for the calculation of the second similarity, the same trained vector model is used to perform vector transformation on the current question, thereby obtaining a current question vector that better reflects the characteristics of the current question in the financial field. Then, the second vector similarity between the current question vector and each text block vector is calculated separately. Based on financial field knowledge, the similarity between the current question and each text block can be evaluated more accurately, and the search for similar text blocks can be more accurate, thereby improving the accuracy of question answering.
[0124] In this application, a large language model can be used to determine whether there is a correlation between the current question and the pending answer. In an exemplary embodiment, after obtaining the pending answer, the method may further include: obtaining second question information based on a second prompt template, the current question, and the pending answer; inputting the second question information into the large language model to obtain a judgment result output by the large language model based on the second question information, indicating whether the current question and the pending answer are related.
[0125] Specifically, the second prompt template can include reserved spaces for filling in the current question and the pending answer, respectively, and second text content that instructs the large language model to determine whether the current question and the pending answer are related based on the reserved spaces. By filling in the current question and the pending answer into the corresponding reserved spaces in the second prompt template, a second question information containing the current question, the pending answer, and the second text content can be obtained. Then, by inputting this second question information into the large language model, the judgment result output by the large language model can be obtained.
[0126] For example, in some implementations, the second text content may instruct the large language model to determine whether content that answers the current question can be directly found among the pending answers. Based on this, if the large language model outputs a judgment result indicating that content that answers the current question can be directly found among the pending answers, then the judgment result indicates that the current question and the pending answer are related. Conversely, if the large language model outputs a judgment result indicating that content that answers the current question cannot be directly found among the pending answers, then the judgment result indicates that the current question and the pending answer are not related.
[0127] In this embodiment, the use of prompt templates and a large language model to determine whether the current question and the pending answer are related can efficiently and quickly obtain the corresponding judgment results, thereby improving the overall processing efficiency of the question-and-answer task.
[0128] In this application, a large language model can be used to determine whether the current question is related to the financial field. In an exemplary embodiment, if the current question is related to the financial field, before obtaining the first similarity between the current question and each preset question in the question-answering database, the method may further include: obtaining third question information based on a third prompt template and the current question; inputting the third question information into the large language model to obtain a judgment result output by the large language model based on the third question information, indicating whether the current question is related to the financial field.
[0129] Specifically, the third prompt template may include a reserved space for filling in the current question, and third text content for instructing the large language model to determine whether the current question filled in the reserved space is a financial domain-related question. For example, in some implementations, the third text content may configure the large language model as a knowledgeable entity in the financial domain, and instruct the large language model to use this role to determine whether the current question filled in the reserved space is relevant to the financial domain.
[0130] By filling the current question into the corresponding reserved position in the third prompt template, a third question message containing the current question and the third text content can be obtained. Then, inputting this third question message into the large language model yields the judgment result output by the large language model.
[0131] In this embodiment, the prompt template and large language model are used to determine whether the current question is related to the financial field, which can efficiently and quickly obtain the corresponding judgment result and improve the overall processing efficiency of the question answering task.
[0132] To further illustrate the financial knowledge question-answering method of this application, detailed embodiments are provided below:
[0133] The financial domain knowledge question answering method in this embodiment may include a pre-processing process and a knowledge retrieval enhancement generation process.
[0134] Among them, such as Figure 5 As shown, the pre-processing flow in this embodiment may include:
[0135] Step S501: The financial text is split into multiple text blocks. For example, the financial text can be split into text block 1, text block 2, text block 3... text block n. The length of each text block can be within a preset range, for example, between 300 and 500 characters.
[0136] Step S502: Input each text block into the large language model to obtain the question-answer pairs corresponding to each text block output by the large language model.
[0137] Step S503: Train the vector model to be trained based on each question-and-answer pair to obtain the trained vector model. By training the vector model using each question-and-answer pair, the vector model can acquire a better search capability for knowledge in the financial domain.
[0138] Step S504: Convert each text block into a text block vector using a trained vector model, and convert the preset questions in each question-answer pair into question vectors using the trained vector model. In this step, the trained vector model can also be used to convert the answers to the preset questions in each question-answer pair into corresponding answer vectors.
[0139] Step S505: Construct a text block library based on each text block and its vector, and construct a question-answer pair library based on each question-answer pair and its vector. In this step, a text block vector library can be constructed first based on each text block vector, and then combined with the existing text blocks and text block vector library to construct the text block library. Similarly, in this step, a question-answer pair vector library can be constructed first based on the question vector and answer vector corresponding to each preset question, and then combined with the existing question-answer pairs to construct the question-answer pair library.
[0140] Based on the above preprocessing steps, a text block library and question-answer pair library based on financial texts can be constructed, and a trained vector model can be obtained.
[0141] Please refer to the following: Figure 6 This is a flowchart of the knowledge retrieval enhancement generation process in this embodiment. For example... Figure 6 As shown, this knowledge retrieval enhancement generation process can be carried out through a knowledge retrieval enhancement generation system, which may include a judgment module, a rewriting module, a search module, a relevance judgment module, and a large language model.
[0142] The knowledge retrieval enhancement generation system can receive questions to be processed and determine whether there are historical questions and answers for those questions. If there are no historical questions and answers, the question can be sent to the judgment module as the current question. If there are historical questions and answers, the rewriting module can first process the question to be processed and the historical questions. The rewriting module obtains the question intent of the question to be processed based on the historical questions and answers and the question to be processed, and then obtains the current question based on the question intent. The current question is then sent to the judgment module.
[0143] Specifically, in this embodiment, the rewriting module can use a preset prompt template and a large language model to determine the question intent of the question to be processed. For example, the prompt template can be represented as "XXX{Reserved Position 1} XXX {Reserved Position 2} XXX {Reserved Position 3} XXX", where "{Reserved Position 1}", "{Reserved Position 2}", and "{Reserved Position 3}" can be used to mark the positions of historical questions and answers, historical answers, and the question to be processed in the prompt template, respectively. Their specific positions and order in the prompt template can be set as needed. "XXX" represents the text content contained in the prompt template, which can instruct the large language model to extract the question intent based on the historical questions and answers and the question to be processed filled in the reserved positions without modification, expansion, or fabrication. By filling the current question and historical questions and answers into the corresponding reserved positions in the prompt template, a question information containing the current question, historical questions and answers, and the text content can be obtained. Then, by inputting this question information into the large language model, the question intent output by the large language model can be obtained, and the current question for subsequent processing can be obtained based on this question intent.
[0144] Specifically, the judgment module in this embodiment can use a preset prompt template and a large language model to determine whether the current question is related to the financial field. For example, the prompt template can be in the form of "XXX{Reserved Position}XXX". Here, "{Reserved Position}" marks the location in the prompt template where the current question is entered. Its specific location in the prompt template can be set as needed, for example, it can be placed in the middle of the text content, or before or after the text content; "XXX" represents the text content included in the prompt template, which instructs the large language model to determine whether the current question entered in the reserved position is related to the financial field. For example, in some implementations, the text content can be used to set the large language model as a knowledgeable entity in the financial field, instructing the large language model to determine whether the current question entered in the reserved position is related to the financial field. By entering the current question into the corresponding reserved position in the prompt template, a question information containing the current question and the text content can be obtained. Then, by inputting this question information into the large language model, a judgment result of "related" or "irrelevant" can be obtained from the large language model's output.
[0145] If the judgment module determines that the current question is not related to the financial field, it can be considered a routine question, requiring no additional retrieval of financial knowledge. Based on this, the current question can be input into a large language model, which will then answer it and output the target answer. Furthermore, if historical question-and-answer sequences exist for the current question, these can also be input into the large language model to reduce the illusion that the model has answered the current question correctly.
[0146] If the judgment module obtains a judgment result indicating that the current question is related to the financial field, then the current question can be sent to the search module, which will then search for financial knowledge based on the current question.
[0147] Among them, such as Figure 7 As shown, the search module can use the trained vector model obtained in the preprocessing process to convert the current question into a current question vector, and then use the current question vector to query the question-answer pair library, calculate the first vector similarity between the current question vector and each question vector in the question-answer pair library, and obtain the first similarity between the current question and each preset question based on the first vector similarity corresponding to each question vector.
[0148] If there is a first question in the question-answer pair library with a first similarity greater than a first threshold, it means that the current question is highly similar to the first question in the question-answer pair library. Therefore, the first answer corresponding to the first question in the question-answer pair library can be returned, and the undetermined answer of the current question can be obtained based on the first answer.
[0149] If the first question does not exist in the question-answer pair library, but a second question exists with a first similarity between the first and second thresholds, then the second answer corresponding to the second question in the question-answer pair library can be obtained, as well as the second similarity between the current question and each text block in the text block library. The search module can use the current question vector to query the text block library, calculate the second vector similarity between the current question vector and each text block vector in the text block library, and obtain the second similarity of each text block based on the second vector similarity corresponding to each text block vector. If a similar text block exists in the text block library with a second similarity greater than the third threshold, then the similar text block and the second answer can be returned, and a pending answer can be obtained based on the similar text block and the second answer; if no similar text block exists in the text block library, then the second answer can be directly returned, and a pending answer can be obtained based on the second answer.
[0150] If neither the first nor the second question exists in the question-answering database, the second similarity between the current question and each text block in the text block database can be obtained. If a similar text block with a second similarity greater than a third threshold exists in the text block database, that similar text block can be returned, and the undetermined answer can be obtained based on it. If no similar text block exists in the text block database, an empty value can be returned, and the current question can be input into the large language model, which will then answer the current question and output the target answer. If historical question-answer pairs exist for the current question, these historical questions and answers can also be input into the large language model.
[0151] For example, in this embodiment, the first similarity and the second similarity in the above process can be values between 0 and 1, where a higher value indicates greater similarity. Specifically, the first threshold for the first similarity can be 0.95, the second threshold can be 0.85, and the third threshold for the second similarity can be 0.65. It is understood that the range of values for the first and second similarities, as well as the specific values of the first, second, and third thresholds, can be varied as needed.
[0152] In cases where the search module returns a pending answer, the system can input the current question and the pending answer into the relevance judgment module, which can determine whether the current question and the pending answer are related.
[0153] Specifically, the relevance judgment module in this embodiment can use a preset prompt template and a large language model to determine whether the current question and the pending answer are related. For example, the prompt template can be in the form of "XXX{Reserved Position 1}XXX{Reserved Position 2}XXX". Here, "{Reserved Position 1}" and "{Reserved Position 2}" can be used to mark the positions in the prompt template where the current question and the pending answer are entered, respectively, and their specific positions and order in the prompt template can be set as needed; "XXX" represents the text content contained in the prompt template, which can instruct the large language model to determine whether the current question and the pending answer are related based on the reserved positions.
[0154] For example, in some implementations, the text content can instruct the large language model to determine whether it can directly find content that answers the current question within the pending answers. By filling the current question and the pending answer into the corresponding reserved positions in the prompt template, a question information containing the current question, the pending answer, and the text content can be obtained. Then, inputting this question information into the large language model yields a "yes" or "no" result. If the large language model outputs a "yes" result, it indicates that the current question and the pending answer are related. If the large language model outputs a "no" result, it indicates that the current question and the pending answer are not related.
[0155] Specifically, if the relevance assessment module outputs a result indicating that the current question and the pending answer are related, then the current question and the pending answer can be input into the large language model. The large language model will then combine the pending answer to answer the current question and obtain the target answer output by the large language model. Furthermore, if the current question has historical question-answer pairs, these historical question-answer pairs can also be input into the large language model.
[0156] If the relevance assessment module outputs a result indicating that the current question and the pending answer are not related, then the pending answer obtained by the search module can be discarded, and the current question can be directly input into the large language model. The large language model will then answer the current question and output the target answer. If the current question has historical question-answer pairs, these historical question-answer pairs can also be input into the large language model.
[0157] In this embodiment, for the financial domain knowledge question-answering task, a question-answer pair library and a text block library are first constructed using a financial domain corpus. The question-answer pairs are then used to train a vector model. This improves the search relevance of the vector model and provides preset questions, reducing the illusion of the large language model directly answering the question. Furthermore, this embodiment refines the question-answering task processing flow and the financial domain knowledge search flow by combining a judgment module, a rewriting module, a search module, and a relevance judgment module. This makes the obtained answers more relevant to the user's question, further reducing the possibility of illusion questions when answering user questions. Specifically, the search module performs a combined search of question-answer pairs and text blocks during the financial domain knowledge search process, which is more conducive to obtaining more reliable pending answers relevant to the current question. The large language model can then output a target answer more relevant to the user's question based on this pending answer, further improving the question-answering accuracy.
[0158] It should be understood that although the steps in the flowcharts of the above embodiments are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the above embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0159] Based on the same inventive concept, this application also provides a financial domain knowledge question-answering device for implementing the aforementioned financial domain knowledge question-answering method. The solution provided by this device is similar to the solution described in the above method; therefore, the specific limitations in one or more embodiments of the financial domain knowledge question-answering device provided below can be found in the limitations of the financial domain knowledge question-answering method described above, and will not be repeated here.
[0160] In one exemplary embodiment, such as Figure 8 As shown, a financial knowledge question-and-answer device 800 is provided, comprising:
[0161] The first acquisition module 801 is used to acquire a text block library and a question-answer pair library built based on texts in the financial field;
[0162] The second acquisition module 802 is used to acquire the first similarity between the current question and each preset question in the question-answering database if the current question is a financial question.
[0163] The first answer determination module 803 is used to obtain a pending answer based on the first answer corresponding to the first question in the question-answer pair library if there is a first question in the question-answer pair library with a first similarity greater than a first threshold.
[0164] The third acquisition module 804 is used to acquire the second answer corresponding to the second question in the question-answer pair library if the first question does not exist in the question-answer pair library and there is a second question with the first similarity between the first threshold and the second threshold, and to acquire the second similarity between the current question and each text block in the text block library.
[0165] The second answer determination module 805 is used to obtain the undetermined answer based on the similar text block and the second answer if there is a similar text block in the text block library with a second similarity greater than a third threshold; and to obtain the undetermined answer based on the second answer if there is no similar text block in the text block library.
[0166] The first target acquisition module 806 is used to obtain the target answer based on the current question and the undetermined answer if the current question and the undetermined answer are associated.
[0167] In an exemplary embodiment, the apparatus further includes: a receiving module for receiving a question to be processed; a first question acquisition module for obtaining the question intent of the question to be processed based on the historical questions and answers and the question to be processed if the question to be processed has historical questions and answers; and obtaining the current question based on the question intent; and a second question acquisition module for obtaining the current question based on the question to be processed if the question to be processed does not have historical questions and answers.
[0168] In an exemplary embodiment, the first question acquisition module is further configured to: obtain first question information based on the first prompt template, the historical questions and answers, and the question to be processed; input the first question information into a large language model to obtain the question intent of the question to be processed output by the large language model based on the first question information.
[0169] In an exemplary embodiment, the first target acquisition module 806 is further configured to: if the current question does not have historical questions and answers, input the current question and the undetermined answer into a large language model to obtain the target answer output by the large language model; if the current question has historical questions and answers, input the historical questions and answers, the current question and the undetermined answer into the large language model to obtain the target answer output by the large language model.
[0170] In an exemplary embodiment, the apparatus further includes: a fourth acquisition module, configured to acquire the text similarity between the current question and each text block in the text block library if the first question and the second question do not exist in the question-answer pair library; and a third answer determination module, configured to obtain the undetermined answer based on the similar text block if there is a similar text block in the text block library with a text similarity greater than a third threshold.
[0171] In an exemplary embodiment, the apparatus further includes: a text block splitting module for splitting the financial text into multiple text blocks; a question-answer pair acquisition module for inputting each text block into a large language model to obtain question-answer pairs corresponding to each text block output by the large language model; a model training module for training a vector model to be trained based on each question-answer pair to obtain a trained vector model; a vector conversion module for converting each text block into a text block vector using the trained vector model, and converting the preset question in each question-answer pair into a question vector using the trained vector model; and a construction module for constructing the text block library based on each text block and each text block vector, and constructing the question-answer pair library based on each question-answer pair and each question vector.
[0172] In an exemplary embodiment, the second acquisition module 802 is further configured to: convert the current question into a current question vector through the trained vector model; calculate the first vector similarity between the current question vector and each of the question vectors in the question-answer pair library; and obtain the first similarity of each preset question based on the first vector similarity corresponding to each of the question vectors.
[0173] In an exemplary embodiment, the third acquisition module 804 is further configured to: convert the current question into a current question vector using the trained vector model; calculate the second vector similarity between the current question vector and each of the text block vectors in the text block library; and obtain the second similarity of each text block based on the second vector similarity corresponding to each of the text block vectors.
[0174] In an exemplary embodiment, the apparatus further includes: a question acquisition module, configured to obtain second question information based on a second prompt template, the current question, and the pending answer; and a question input module, configured to input the second question information into a large language model to obtain a judgment result output by the large language model based on the second question information, indicating whether the current question and the pending answer are related.
[0175] In an exemplary embodiment, the apparatus further includes: a question acquisition module, configured to obtain third question information based on a third prompt template and the current question; and a question input module, configured to input the third question information into a large language model to obtain a judgment result output by the large language model based on the third question information, indicating whether the current question is a financial field-related question.
[0176] In an exemplary embodiment, the apparatus further includes: a second target acquisition module, configured to input the current question and the historical question and answer into a large language model to obtain the target answer output by the large language model if the current question has historical question and answer and the current question is not a financial field-related question; and a third target acquisition module, configured to input the current question into the large language model to obtain the target answer output by the large language model if the current question does not have historical question and answer and the current question is not a financial field-related question.
[0177] The modules in the aforementioned financial knowledge-based question-and-answer device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the operations corresponding to each module.
[0178] In one exemplary embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 9 As shown, this computer device includes a processor, memory, input / output (I / O) interfaces, and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides the environment for the operating system and computer programs stored in the non-volatile storage media. The database stores financial data such as text, text blocks, question-and-answer pairs, current questions, and historical questions and answers. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communication with external terminals via a network connection. When executed by the processor, the computer program implements a financial knowledge-based question-and-answer method.
[0179] Those skilled in the art will understand that Figure 9The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0180] In one embodiment, a computer device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above method embodiments.
[0181] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the steps in the above method embodiments.
[0182] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above method embodiments.
[0183] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, artificial intelligence (AI) processors, etc., and are not limited to these.
[0184] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0185] The above embodiments are merely illustrative of several implementation methods of this application, and their descriptions are relatively specific and detailed. However, they should not be construed as limiting the scope of this application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A knowledge-based question-and-answer method in the financial field, characterized in that, The method includes: Obtain a text block library and question-answer pair library built based on financial texts; If the current question is related to the financial field, then obtain the first similarity between the current question and each preset question in the question-answering database; If there is a first question in the question-answering database with a similarity greater than the first threshold, then an undetermined answer is obtained based on the first answer corresponding to the first question in the question-answering database; If the first question does not exist in the question-answer pair library, but there is a second question whose first similarity is between the first threshold and the second threshold, then obtain the second answer corresponding to the second question in the question-answer pair library, and obtain the second similarity between the current question and each text block in the text block library; If a similar text block with a similarity greater than the third threshold exists in the text block library, the undetermined answer is obtained based on the similar text block and the second answer; if the similar text block does not exist in the text block library, the undetermined answer is obtained based on the second answer. If the current question and the pending answer are related, then the target answer is obtained based on the current question and the pending answer.
2. The method according to claim 1, characterized in that, If the current question is related to the financial field, before calculating the first similarity between the current question and each preset question in the question-answering database, the method further includes: Receive pending issues; If the question to be processed has historical questions and answers, then based on the historical questions and answers and the question to be processed, the question intent of the question to be processed is obtained; and based on the question intent, the current question is obtained. If the question to be processed does not have the historical questions and answers, then the current question is obtained based on the question to be processed.
3. The method according to claim 2, characterized in that, The step of obtaining the question intent of the question to be processed based on the historical questions and answers and the question to be processed includes: Based on the first prompt template, the historical questions and answers, and the question to be processed, the first question information is obtained; The first question information is input into the large language model to obtain the question intent of the question to be processed, which is output by the large language model based on the first question information.
4. The method according to claim 1, characterized in that, The process of obtaining the target answer based on the current question and the undetermined answer includes: If the current question does not have a historical question and answer, then the current question and the undetermined answer are input into the large language model to obtain the target answer output by the large language model; If the current question has historical answers, then the historical answers, the current question, and the undetermined answer are input into the large language model to obtain the target answer output by the large language model.
5. The method according to claim 1, characterized in that, After obtaining the first similarity between the current question and each preset question in the question-answering database, the method further includes: If neither the first question nor the second question exists in the question-answering database, then the second similarity between the current question and each text block in the text block database is obtained; If there exists a similar text block in the text block library whose second similarity is greater than the third threshold, then the undetermined answer is obtained based on the similar text block.
6. The method according to claim 1, characterized in that, The method further includes: The financial text is split into multiple text blocks; Each of the text blocks is input into the large language model to obtain the question-answer pairs corresponding to each of the text blocks output by the large language model; The vector model to be trained is trained based on the question and answer statements to obtain the trained vector model. Each text block is converted into a text block vector using the trained vector model, and the preset question in each question-answer pair is converted into a question vector using the trained vector model. The text block library is constructed based on each text block and each text block vector, and the question-answer pair library is constructed based on each question-answer pair and each question vector.
7. The method according to claim 6, characterized in that, The step of obtaining the first similarity between the current question and each preset question in the question-answering database includes: The current problem is transformed into a current problem vector using the trained vector model; Calculate the first vector similarity between the current question vector and each of the question vectors in the question-answering database; The first similarity of each preset question is obtained based on the similarity of each first vector corresponding to each question vector.
8. The method according to claim 6, characterized in that, The step of obtaining the second similarity between the current question and each text block in the text block library includes: The current problem is transformed into a current problem vector using the trained vector model; Calculate the second vector similarity between the current question vector and each of the text block vectors in the text block library; The second similarity of each text block is obtained based on the similarity of each second vector corresponding to each text block vector.
9. The method according to claim 1, characterized in that, After obtaining the pending answer, the method further includes: Based on the second prompt template, the current question, and the pending answer, the second question information is obtained; The second question information is input into the large language model, and the large language model outputs a judgment result based on the second question information, indicating whether the current question and the undetermined answer are related.
10. The method according to claim 1, characterized in that, If the current question is related to the financial field, before obtaining the first similarity between the current question and each preset question in the question-answering database, the method further includes: Based on the third prompt template and the current question, the third question information is obtained; The third question information is input into the large language model to obtain the judgment result output by the large language model based on the third question information, which indicates whether the current question is a financial field-related question.
11. The method according to any one of claims 1 to 10, characterized in that, The method further includes: If the current question has historical questions and answers, and the current question is not related to the financial field, then the current question and the historical questions and answers are input into the large language model to obtain the target answer output by the large language model; If the current question does not have any historical answers and the current question is not related to the financial field, then the current question is input into the large language model to obtain the target answer output by the large language model.
12. A knowledge-based question-and-answer device in the financial field, characterized in that, The device includes: The first acquisition module is used to acquire a text block library and a question-answer pair library built based on texts in the financial field; The second acquisition module is used to acquire the first similarity between the current question and each preset question in the question-answering database if the current question is a financial question. The first answer determination module is used to obtain a pending answer based on the first answer corresponding to the first question in the question-answer pair library if there is a first question in the question-answer pair library with a first similarity greater than a first threshold. The third acquisition module is used to acquire the second answer corresponding to the second question in the question-answer pair library if the first question does not exist in the question-answer pair library and there is a second question with the first similarity between the first threshold and the second threshold, and to acquire the second similarity between the current question and each text block in the text block library. The second answer determination module is used to obtain the undetermined answer based on the similar text block and the second answer if there is a similar text block in the text block library with a similarity greater than the third threshold; and to obtain the undetermined answer based on the second answer if there is no similar text block in the text block library. The first target acquisition module is used to obtain the target answer based on the current question and the pending answer if the current question and the pending answer are associated.
13. The apparatus according to claim 12, characterized in that, The device further includes: The receiving module is used to receive questions to be processed. The first question acquisition module is used to, if the question to be processed has historical questions and answers, obtain the question intent of the question to be processed based on the historical questions and answers and the question to be processed; and obtain the current question based on the question intent. The second question acquisition module is used to obtain the current question based on the question to be processed if the question to be processed does not have the historical questions and answers.
14. The apparatus according to claim 13, characterized in that, The first problem acquisition module is also used for: Based on the first prompt template, the historical questions and answers, and the question to be processed, the first question information is obtained; The first question information is input into the large language model to obtain the question intent of the question to be processed, which is output by the large language model based on the first question information.
15. The apparatus according to claim 12, characterized in that, The first target acquisition module is further configured to: If the current question does not have a historical question and answer, then the current question and the undetermined answer are input into the large language model to obtain the target answer output by the large language model; If the current question has historical answers, then the historical answers, the current question, and the undetermined answer are input into the large language model to obtain the target answer output by the large language model.
16. The apparatus according to claim 12, characterized in that, The device further includes: The fourth acquisition module is used to acquire the text similarity between the current question and each text block in the text block library if the first question and the second question do not exist in the question-answer pair library; The third answer determination module is used to obtain the undetermined answer based on the similar text blocks if there are similar text blocks in the text block library with a text similarity greater than a third threshold.
17. The apparatus according to claim 12, characterized in that, The device further includes: The text block splitting module is used to split the financial text into multiple text blocks; The question-answer pair acquisition module is used to input each of the text blocks into the large language model and obtain the question-answer pairs corresponding to each of the text blocks output by the large language model; The model training module is used to train the vector model to be trained based on each of the question-and-answer pairs, so as to obtain the trained vector model. The vector conversion module is used to convert each text block into a text block vector using the trained vector model, and to convert the preset question in each question-answer pair into a question vector using the trained vector model. A construction module is used to construct the text block library based on each text block and each text block vector, and to construct the question-answer pair library based on each question-answer pair and each question vector.
18. The apparatus according to claim 17, characterized in that, The second acquisition module is further configured to: The current problem is transformed into a current problem vector using the trained vector model; Calculate the first vector similarity between the current question vector and each of the question vectors in the question-answering database; The first similarity of each preset question is obtained based on the similarity of each first vector corresponding to each question vector.
19. The apparatus according to claim 17, characterized in that, The third acquisition module is also used for: The current problem is transformed into a current problem vector using the trained vector model; Calculate the second vector similarity between the current question vector and each of the text block vectors in the text block library; The second similarity of each text block is obtained based on the similarity of each second vector corresponding to each text block vector.
20. The apparatus according to claim 12, characterized in that, The device further includes: The question acquisition module is used to obtain second question information based on the second prompt template, the current question, and the pending answer; The question input module is used to input the second question information into the large language model and obtain a judgment result output by the large language model based on the second question information, which indicates whether the current question and the pending answer are related.
21. The apparatus according to claim 12, characterized in that, The device further includes: The question acquisition module is used to obtain third question information based on the third prompt template and the current question; The question input module is used to input the third question information into the large language model and obtain the judgment result of the large language model based on the third question information, which indicates whether the current question is a financial field related question.
22. The apparatus according to any one of claims 12 to 21, characterized in that, The device further includes: The second target acquisition module is used to input the current question and the historical questions and answers into the large language model if the current question has historical questions and answers and the current question is not a financial question, so as to obtain the target answer output by the large language model. The third target acquisition module is used to input the current question into the large language model if the current question does not have the historical question and the current question is not a financial question, and to obtain the target answer output by the large language model.
23. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 11.
24. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 11.
25. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 11.