Question answering method, device and computer program product
By semantically associating and rewriting user questions, a structured query statement is generated. Combined with the answer generation model and user interface feedback, the problem of inaccurate responses from large language models in complex scenarios is solved, achieving more accurate understanding of user intent and provision of answers.
Patent Information
- Application Number
- CN202410839510.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-26
- Publication Date
- 2026-08-25
- Estimated Expiration
- 2044-06-26
AI Technical Summary
Large language models struggle to accurately understand and translate user questions when faced with complex scenarios and diverse user expressions, resulting in inaccurate responses.
By semantically associating the original question with ambiguous meanings, a semantic association word queue is generated. The original question is then rewritten and converted into a structured question statement for querying the database. Combined with the answer generation model and user interface feedback, the answer is corrected.
It improves the accuracy of responses from large language models in complex scenarios and with diverse user expressions, quickly understands user intent, and meets diverse and differentiated query needs.
Smart Images

Figure CN118820420B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of natural language processing technology, and in particular to a question-answering method, device, and computer program product. Background Technology
[0002] With the rapid development of artificial intelligence (AI) technology, its applications are becoming increasingly widespread across various fields, leading to the emergence of more and more intelligent products based on human-computer interaction (HCI) technology. In the HCI interaction process, large language models play a crucial role.
[0003] Large language models, trained on massive amounts of language data, learn how to understand, generate, and translate human natural language, automatically generating articles, answering questions, and engaging in dialogues. Traditional large language models rely on Text-to-SQL technology to map natural language questions to corresponding database query statements, thereby generating SQL query statements corresponding to the questions.
[0004] However, real-world question-and-answer scenarios are complex and users' question expressions are diverse. In many scenarios, users' questions are semantically ambiguous or lack important information, which undoubtedly poses a challenge to the understanding and translation of large language models. Summary of the Invention
[0005] This invention provides a question-answering method, device, and computer program product. By using a user question-answering error correction mechanism based on a semantic association word queue, it improves and corrects users' semantically ambiguous or unclear questions. This solves the problem that in complex scenarios and with diverse user expressions, large language models are inaccurate in their understanding and translation, and cannot provide accurate answers. This is beneficial for more accurately handling the diverse and differential query needs of users.
[0006] According to one aspect of the present invention, a question-answering method is provided, comprising:
[0007] Semantic association is performed on the obtained original question with unclear semantics to obtain a semantic association word queue, and the original question is semantically rewritten according to the semantic association word queue to obtain the first rewritten question;
[0008] The first rewriting problem is converted into a language to obtain a first structured problem statement, and the database is queried based on the first structured problem statement to obtain a first query result;
[0009] The first input question and the first query result are used to generate an answer model to obtain a first answer, which is then sent to the user interface; the first input question is either the original question or the first rewritten question.
[0010] The semantic association word queue is sent to the user interface, and upon receiving a target semantic association word selected from the semantic association word queue, the first answer is corrected based on the target semantic association word to obtain the second answer.
[0011] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:
[0012] At least one processor; and
[0013] A memory communicatively connected to the at least one processor; wherein,
[0014] The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the question-answering method described in any embodiment of the present invention.
[0015] According to another aspect of the present invention, a computer program product is provided, comprising a computer program that, when executed by a processor, implements the question-answering method described in any embodiment of the present invention.
[0016] The technical solution of this invention involves semantic association of an acquired, semantically ambiguous original question to obtain a semantic association word queue, and semantically rewriting the original question based on the semantic association word queue to obtain a first rewritten question; performing language conversion on the first rewritten question to obtain a first structured question statement, and querying a database based on the first structured question statement to obtain a first query result; inputting the first input question and the first query result into an answer generation model to obtain a first answer, and sending the first answer to the user interface, where the first input question is either the original question or the first rewritten question; sending the semantic association word queue to the user interface, and upon receiving a target semantic association word selected from the semantic association word queue, correcting the first answer based on the target semantic association word to obtain a second answer. This approach can improve and correct users' semantically ambiguous or unclear questions based on the semantic association word queue and user question-and-answer correction mechanism, which is beneficial for more accurately handling users' diverse and varied query needs. It solves the problem that in complex scenarios and with diverse user expressions, large language models are inaccurate in understanding and translation, and cannot provide accurate answers. It has the beneficial effects of quickly understanding users' true query intent and accurately handling users' diverse and varied query needs.
[0017] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of the present invention, nor is it intended to limit the scope of the invention. Other features of the invention will become readily apparent from the following description. Attached Figure Description
[0018] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0019] Figure 1 This is a flowchart of a question-answering method provided in Embodiment 1 of the present invention;
[0020] Figure 2 This is a flowchart of a question-answering method provided in Embodiment 2 of the present invention;
[0021] Figure 3 This is a flowchart of a question-answering method provided in Embodiment 3 of the present invention;
[0022] Figure 4 This is a schematic diagram of the structure of a question-answering device provided in Embodiment 3 of the present invention;
[0023] Figure 5 This is a schematic diagram of the structure of an electronic device that implements the question-answering method of this invention. Detailed Implementation
[0024] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0025] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0026] Example 1
[0027] Figure 1This is a flowchart of a question-answering method provided in Embodiment 1 of the present invention. This embodiment is applicable to situations where user questions are asked in complex scenarios or where the expression of questions is diverse. This method can be executed by a question-answering device, which can be implemented in hardware and / or software and can be configured in an electronic device. Figure 1 As shown, the method includes:
[0028] S110. Perform semantic association on the obtained original question with unclear semantics to obtain a semantic association word queue, and perform semantic rewriting on the original question according to the semantic association word queue to obtain the first rewritten question.
[0029] The original question is a user-generated question represented in natural language, which can include various languages such as Chinese and English. The original question can be text information directly input by the user, or text information obtained through text recognition of the user's spoken question. The semantic association word queue is a queue of words semantically associated with the original question. The first rewritten question is the question obtained by rewriting the original question. The essence of the first rewritten question is semantic rewriting; therefore, both the first rewritten question and the original question are represented in natural language.
[0030] Specifically, the process involves obtaining the original question posed by the user, performing semantic parsing on the original question, and determining whether the semantics of the original question are clear. If the original question is semantically unclear, semantic association is performed to obtain semantically related words, forming a semantic association word queue. Based on the semantic association word queue, the original question is semantically rewritten to give the rewritten question clear semantics and intent. It is understandable that the degree to which the original question is semantically unclear may vary in different question-answering scenarios. This can be addressed by training the semantic parsing model and adjusting the scale and definition of question semantic discrimination in different question-answering scenarios.
[0031] This embodiment, by performing semantic association and semantic rewriting on the original question with unclear meaning, can obtain a question with clearer intent and semantics, which is conducive to faster and more accurate subsequent querying and answering of user questions.
[0032] S120. Perform language conversion on the first rewriting problem to obtain the first structured problem statement, and query the database based on the first structured problem statement to obtain the first query result.
[0033] The first structured question statement is a question expressed in Structured Query Language (SQL) derived from the first rewritten question. The first query result refers to the data retrieved based on the first structured question statement. It can be understood that the queried database can be a default database, such as the database accessed by the electronic device; or it can be a specific database specified by the user in the original question. It can also be understood that the data stored in the database can be data obtained from the network, data center, cloud platform, or data interface, or data stored at a specified path specified by the user.
[0034] Specifically, the rewritten question, represented in natural language, is converted into a first structured question statement represented in structured query language. Based on the first structured question statement, the corresponding data tables, columns, and fields in the database are queried, and the first query result returned by the database is obtained.
[0035] S130. Input the first input question and the first query result into the answer generation model, obtain the first answer, and send the first answer to the user interface.
[0036] The first input question is the question fed into the answer generation model; it can be either the original question or a rewritten question. The answer generation model can be understood as a large language model used to generate answers to questions in natural language representation. The first answer can be understood as the initial response to the original question.
[0037] Specifically, the first input question (the original question obtained in S110 or the first rewritten question generated in S120) and the first query result obtained in S120 are input into the fully trained answer generation model to obtain the first answer output by the answer generation model. The first answer is then sent to the user interface. The user interface can be equipped with display controls, trigger controls, and selection controls, allowing the user to evaluate the satisfaction level of the first answer and select more desired semantic information.
[0038] In an optional embodiment, the first query results corresponding to the original question and the rewritten question are written into the answer generation model to generate the first answer. This allows the generated first answer to be more in line with the question format of the user's original question while being sufficiently accurate, thus providing the user with a user-friendly question and answer service.
[0039] In another optional embodiment, the first rewritten question and the first query result are written into the answer generation model to generate the first answer to the original question. This provides a more accurate and comprehensive question-and-answer service for the more specific first rewritten question. For example, the training steps of the answer generation model may include: obtaining a question sample set, a corresponding query result sample set, and an answer sample set; constructing an answer generation prompt word set based on the question sample set, query result sample set, and answer sample set; and training an initial large language model based on the answer generation prompt word set to obtain the answer generation model.
[0040] This embodiment sends the first answer corresponding to the original question and the semantic association word queue obtained based on the original question to the user interface. It can intuitively display the related question elements to the user, obtain the user's evaluation feedback on the satisfaction level of the answer, and obtain more semantic information that the user wants to express, thus clarifying the user's true intention.
[0041] In an optional embodiment, the method further includes: performing semantic understanding and language conversion on the obtained semantically clear original question to obtain a structured question statement; querying a database using the structured question statement to obtain query results; inputting the original question and the query results into an answer generation model to obtain an answer to the original question, and feeding the answer back to the user interface.
[0042] In this embodiment, for semantically clear original questions, there is no need to perform semantic association and semantic rewriting steps. Through semantic understanding and language conversion, the original question represented in natural language can be converted into a structured question statement represented in structured query language for subsequent data query, and an answer can be generated based on the query results and the original question.
[0043] S140. Send the semantic association word queue to the user interface, and when the target semantic association word selected from the semantic association word queue is received, correct the first answer according to the target semantic association word to obtain the second answer.
[0044] The second answer can be understood as a revised version of the original question; it can be a revised version of the first answer, either once or multiple times. The target semantic association word can be understood as a semantic association word selected by the user from a queue of semantic association words.
[0045] Specifically, a semantic association word queue is sent to the user interface, allowing the user to select a target semantic association word from the queue. Upon receiving the target semantic association word selected by the user from the queue, the question corresponding to the first answer is semantically corrected based on the target semantic association word, thereby correcting the first answer and obtaining the second answer.
[0046] In an optional embodiment, the semantic association word queue can be sent to the user interface as follows: after generating the semantic association word queue, the semantic association word queue is sent to the user interface, and if the user is not satisfied with the first answer, or wants to obtain the answers to other related questions, the user selects the target semantic association word from the semantic association word queue.
[0047] In another alternative embodiment, the semantic association word queue can also be sent to the user interface when negative feedback from the user on the first answer is received, so that the semantic association word queue or a question containing the semantic association word queue can be sent to the user interface so that the user can select a target semantic association word from the semantic association word queue.
[0048] This embodiment sends a semantic association word queue derived from the original question to the user interface. This allows for a visual display of related question elements to the user, as well as feedback on the user's satisfaction with the answer and more semantic information the user wants to express, thus clarifying the user's true intention. Furthermore, a user question-and-answer error correction mechanism based on the semantic association word queue corrects the user's original question, refining and supplementing the user's semantically missing or ambiguous questions, which is beneficial for more accurately handling the diverse and varied query needs of users.
[0049] The technical solution of this invention involves semantic association of an acquired, semantically ambiguous original question to obtain a semantic association word queue, and semantically rewriting the original question based on the semantic association word queue to obtain a first rewritten question; performing language conversion on the first rewritten question to obtain a first structured question statement, and querying a database based on the first structured question statement to obtain a first query result; inputting the first input question and the first query result into an answer generation model to obtain a first answer, and sending the first answer to the user interface, where the first input question is either the original question or the first rewritten question; sending the semantic association word queue to the user interface, and upon receiving a target semantic association word selected from the semantic association word queue, correcting the first answer based on the target semantic association word to obtain a second answer. This approach can improve and correct users' semantically ambiguous or unclear questions based on the semantic association word queue and the user question-and-answer correction mechanism, which is beneficial for more accurately handling the diverse and varied query needs of users.
[0050] Example 2
[0051] Figure 2This is a flowchart of a question-answering method provided in Embodiment 2 of the present invention. Based on the above embodiments, this embodiment further defines S110, which involves semantically associating the obtained semantically ambiguous original question to obtain a semantic association word queue, and semantically rewriting the original question according to the semantic association word queue to obtain a first rewritten question. This includes: semantically parsing the obtained original question to obtain question keywords; if the semantics of the question keywords are ambiguous, querying a pre-created knowledge base based on the question keywords to obtain a semantic association word queue for the question keywords; the semantic association word queue includes semantic association words corresponding to the question keywords ordered by weight; inputting the semantic association word with the highest weight in the semantic association word queue and the question keywords into a semantic rewriting model to obtain a first rewritten question; and S120, performing language conversion on the first rewritten question to obtain a first structured question statement, and querying a database according to the first structured question statement to obtain a first query result. This includes: inputting the first rewritten question into a language conversion model to obtain a first structured question statement; and querying a database according to the first structured question statement to obtain a first query result. Figure 2 As shown, the method includes:
[0052] S210. Perform semantic parsing on the obtained original question to obtain question keywords.
[0053] Among them, question keywords refer to the core words contained in the question, which can reflect the diversity of the questions asked by users. For example, they can include time elements, location elements, people elements, and event elements.
[0054] Specifically, the original question is semantically parsed using a semantic parsing model to obtain the question keywords.
[0055] S220. If the semantics of the original question are unclear, then query the pre-created knowledge body base based on the question keywords to obtain the semantic association word queue of the question keywords; the semantic association word queue includes the semantic association words corresponding to the question keywords sorted by weight.
[0056] A knowledge body base is a database used to store information resources from different technical fields in the form of knowledge bodies. A knowledge body can be understood as a structure that stores information resources according to a certain semantic structure and conceptual relationships. Knowledge bodies can be represented using embedding. Embedding is a method of mapping high-dimensional data to a low-dimensional space, typically used to convert discrete, non-continuous data into continuous vector representations for easier computer processing.
[0057] Specifically, if the original question has semantic ambiguity, the knowledge base is queried based on the keywords contained in the original question. Multiple semantically related words are then found in the knowledge base, and these words are sorted according to their weights to obtain a semantic association word queue. To align with users' general selection habits, the semantic association words in the semantic association word queue can be sorted in descending order of weight.
[0058] For example, the weight of each semantic link can be determined based on at least one of the following: the semantic element type to which the semantic link belongs, the relevance of the semantic link to the question keyword, the historical access frequency, and whether it has been selected by the user. For example, the order is: event element > person element > time element > location element. The greater the relevance, the greater the weight; the greater the historical access frequency, the greater the weight. In order to satisfy the user's intent, if it is selected by the user, it is considered to have the highest weight; that is, whether it is selected by the user has the highest priority when determining the weight of the semantic link.
[0059] In this embodiment, the semantic ambiguity of the original question may be due to semantic vagueness or lack of core elements, such as missing time, place, people, and events. For example, the original question is "Compared to last year, this year's case filings are similar," with the core word being "case filing." However, it lacks specific time and event details, making it difficult to clearly understand the user's intent. Therefore, the original question can be judged to be semantically ambiguous. Based on the question keyword "case filing," the knowledge base is queried to obtain the semantic association word queue [total number of cases, average number of cases, number of solved cases].
[0060] In one optional embodiment, the step of pre-creating the knowledge body base includes: collecting information resources from a preset application domain based on different channels; performing structured processing on the information resources to obtain the semantic structure and conceptual relationships of knowledge points; performing dictionary mapping on the information resources and the corresponding semantic structure and conceptual relationships to obtain a knowledge body; and constructing a knowledge body base based on all the knowledge bodies.
[0061] The information resources can be collected from sources such as books, journal articles, academic papers, expert interviews, industry reports, and online resources to ensure that the sources are reliable and authoritative and can cover all aspects of the field.
[0062] Specifically, for a given application domain, information resources are collected from various channels. These resources are then structured using the Kimi model to extract the semantic structure of the knowledge points contained within them. For example, semantic structure = Kimi model (information resource). The semantic structure can include key concepts, entities, attributes, etc. Conceptual relationships between different knowledge points are established, such as concept relationships = {causal relationships, similarity relationships, and hierarchical relationships}. Finally, information resources, semantic structure, and conceptual relationships are mapped using a dictionary to form a knowledge body, i.e., knowledge body = dictionary mapping {information resources, semantic structure, conceptual relationships}.
[0063] This embodiment provides a foundation for semantic association of the original problem by constructing a knowledge body base, which can help to better understand the application domain and provide more contextual information for subsequent semantic rewriting models.
[0064] S230. Input the semantic association word with the highest weight in the semantic association word queue and the original question into the semantic rewriting model to obtain the first rewriting question.
[0065] In this context, if the semantic association words are sorted in descending order of their weights in the semantic association word queue, the semantic association word with the highest weight can be considered the first-ranked semantic association word. The semantic rewriting model can be understood as a model that rewrites the semantics of the original problem. It can be understood that semantic rewriting includes semantic association, semantic mining, and semantic supplementation.
[0066] Specifically, the original problem obtained in S210 and the semantic association word with the largest weight in the semantic association word queue obtained in S220 are input into the training of a complete semantic rewriting model to obtain the first rewriting problem output by the semantic rewriting model.
[0067] In an optional embodiment, the training steps of the semantic rewriting model include: obtaining an original question sample set; randomly masking the question sample keywords of each original question sample in the original question sample set to obtain a masked question sample set; querying the knowledge body in the knowledge body base according to the masked question sample keywords to obtain a sample semantic association word queue of the question sample keywords; generating an associated question sample set according to the masked question sample set and the sample semantic association word queue; constructing a question rewriting prompt word set according to the associated question sample set, the sample semantic association word queue, and the masked question sample set; and training a first preset large language model according to the question rewriting prompt word set to obtain the semantic rewriting model.
[0068] The original question sample set is a collection of original question samples, which are used as training samples. These original question samples can be historical questions submitted by users or questions obtained from other sources. Question sample keywords are the core words obtained by parsing the original question samples. The sample semantic association word queue is a queue of sample semantic association words associated with the question sample keywords, sorted by weight. The associated question sample set is a collection of associated question samples; these are questions obtained by associating with the original question samples.
[0069] In this embodiment, to make the semantic rewriting model as adaptable as possible to the complex question-and-answer scenarios and diverse needs of real users, the original question samples are characterized by colloquialism and diversity. The masked question sample set refers to the sample set obtained after masking the original question sample set. The masked question sample set is used to simulate situations where real user-asked questions have semantic gaps or ambiguity. The question rewriting prompt word set is a set of prompt words used to train the question rewriting model. This set guides the first preset large language model to rewrite the input question, mitigating data bias to some extent. The first preset large language model refers to the initial model used for semantic rewriting, generally an untrained or incompletely trained large language model. For example, a language generation model based on Llama-3 can be selected. This embodiment of the invention does not limit the specific type of the first preset large language model and can be selected based on actual needs.
[0070] Specifically, for each original question sample in the original question sample set, one or more question sample keywords are randomly masked to obtain a masked question sample set. The Kimi model or GPT model then retrieves multiple semantic association words from the knowledge base, which are derived from the masked question sample keywords. These semantic association words are then sorted by weight to obtain a semantic association word queue. For each masked question sample in the masked question sample set, each masked question sample and each semantic association word in the semantic association word queue are combined to obtain an associated question sample, thus creating an associated question sample set. Based on the associated question sample set, the semantic association word queue, and the masked question sample set, a question rewriting prompt word set is constructed. This set is then input into a first preset large language model for parameter training to obtain a semantic rewriting model. The training process for the first preset large language model can be set with a learning rate of 2e-2, a training epoch of 3, and a batch size of 64.
[0071] For example, the original question sample is "How much has the number of cases filed this year increased compared to the previous year?", the masked question sample is "How much has the number of cases increased compared to the previous year?", and the sample semantic association word queue is [filing a case, solving a case, receiving a police report, interrogating]. The first rewritten question samples are: "How much has the number of cases filed this year increased compared to the previous year?", "How much has the number of cases solved this year increased compared to the previous year?", "How much has the number of cases received this year increased compared to the previous year?", and "How much has the number of cases interrogated this year increased compared to the previous year?".
[0072] In an optional embodiment, after generating the associated question sample set based on the masked question sample set and the sample semantic association word queue, the method further includes: filtering out associated question samples with logical or semantic errors from the associated question sample set. For example, 15 sample semantic association words associated with the question sample keywords in the masked question samples are obtained from a knowledge body base, and the masked question samples and the 15 sample semantic association words are combined to obtain 15 associated question samples. These 15 associated question samples are then filtered, and 10 are retained to form the question rewriting prompt word set.
[0073] For example, one or more keywords from each original question sample in the original question sample set are masked. This can be done by randomly selecting one or more of the four elements from the original question sample: query time, location, participants, and valid events. Specifically, this can be represented as follows:
[0074] Mask(Sentence)=Sentence.Masking_Probability(Time,Place,Person,Thing).
[0075] Sentence is the original question sample; Mask(Sentence) performs a masking operation on the original question sample; Masking_Probability is the masking selection function, which selects the keywords of the question sample to be masked according to a given probability; Time, Place, Person, Thing refer to the query time, location, participants, and valid event, respectively. Furthermore, the masking selection function can be expressed as:
[0076]
[0077] In this context, p1+p2+p3+p4<1, p5=1-(p1+p2+p3+p4); p1, p2, p3, and p4 can be all equal, partially equal, or all unequal; Mask(X) means replacing X with a placeholder or deleting it, where X can be Time, Place, Person, or Thing; "No Mask" means no mask operation is performed, which is to maintain the integrity and readability of the sentence.
[0078] S240. Input the first rewriting problem into the language conversion model to obtain the first structured problem statement.
[0079] Specifically, the first rewriting question output by the semantic rewriting model is input into the fully trained language conversion model. The language conversion model then converts the first rewriting question of the natural language text representation into a first structured query statement using structured query language representation.
[0080] In one optional embodiment, the training steps of the language conversion model may include: obtaining an original question sample set and a rewritten question sample set containing sample semantic association words; obtaining a set of structured question statements corresponding to the original question sample set and the rewritten question sample set respectively; constructing a language conversion prompt word set based on the original question sample set and the corresponding structured question statement sample set, as well as the rewritten question sample set and the corresponding structured question statement sample set; and training a second preset large language model based on the language conversion prompt word set to obtain the language conversion model.
[0081] The set includes several key components: The rewritten question sample set is a collection of rewritten question samples, which are obtained by semantically rewriting the original question samples; the rewritten question samples include the semantic association words used for the rewriting. The structured question statement sample set is a collection of structured question statement samples; these are obtained by language conversion of the original or rewritten question samples. The language conversion prompt word set is a collection of language conversion prompt words used to train the language conversion model. The second pre-set large model refers to the initial model used for language conversion, generally an untrained or incompletely trained large language model.
[0082] Specifically, language conversion prompts are constructed based on the original question samples and the structured question statement samples obtained through language conversion, and language conversion prompts are also constructed based on the rewritten question samples and the structured question statement samples obtained through language conversion, thus obtaining a language conversion prompt set. The language conversion prompt set is then input into a second preset large language model to train the parameters of the second preset large language model, thereby obtaining a language conversion model.
[0083] For example, the sqlcoder model is trained using Full Supervised Fine Tuning (SFT). Generally, a learning rate of 2e-3 during training results in a large model that generates code based on the style of the training data; a learning rate of 2e-5 preserves the original SQL statement style to adapt to the generated code. Furthermore, setting the epochs to 2-5 maintains the original large model's coding capabilities while also learning domain knowledge from new knowledge bases, resulting in stronger adaptability. However, if the epochs exceed 10, it may be difficult to preserve the generalization ability of the original large model. Additionally, the batch size can be set to 64.
[0084] In this embodiment, during the training process of the language conversion model, both the original question sample set and the rewritten question sample set are used as sample data for training the language conversion model, which can improve the language conversion model's ability to convert diverse natural languages.
[0085] 250. Query the database based on the first structured question statement to obtain the first query result.
[0086] 260. Generate a model by taking the first input question and the first query result as input answers, obtain the first answer, and send the first answer to the user interface.
[0087] 270. Send the semantic association word queue to the user interface, and when the target semantic association word selected from the semantic association word queue is received, correct the first answer according to the target semantic association word to obtain the second answer.
[0088] In this embodiment, the implementation of S250 to S270 can be referred to the above embodiment, and will not be repeated here.
[0089] The technical solution of this invention involves semantically parsing the original question to obtain question keywords. If the semantics of the original question are unclear, a pre-created knowledge base is queried based on the question keywords to obtain a semantic association word queue. The semantic association word with the highest weight in the semantic association word queue and the original question are input into a semantic rewriting model to obtain a first rewritten question. The first rewritten question is input into a language conversion model to obtain a first structured question statement, and a database is queried based on the first structured question statement to obtain a first query result. The first input question and the first query result are input into an answer generation model to obtain a first answer, and the first answer is sent to the user interface. The semantic association word queue is sent to the user interface, and upon receiving a target semantic association word selected from the semantic association word queue, the first answer is corrected based on the target semantic association word to obtain a second answer. By semantically associating the original question with the knowledge base to obtain a semantic association word queue, and using the question rewriting strategy and answer correction mechanism based on the semantic association word queue, it is possible to improve and correct users' semantically ambiguous or unclear questions, which is beneficial for more accurately handling the diverse and differentiated query needs of users.
[0090] Example 3
[0091] Figure 3 This is a flowchart of a question-answering method provided in Embodiment 3 of the present invention. Based on the above embodiments, this embodiment further adds the following steps after inputting the first input question and the first query result into the answer generation model to obtain the first answer: determining the visualization chart type that matches the first query result, and sending a question containing the visualization chart type to the user interface; performing data analysis on the first query result when the selected target visualization chart type is obtained to obtain chart data; drawing a visualization chart according to the chart data and the visualization chart type, and sending the visualization chart to the user interface.
[0092] like Figure 3 As shown, the method includes:
[0093] S310. Perform semantic association on the obtained original question with unclear semantics to obtain a semantic association word queue, and perform semantic rewriting on the original question according to the semantic association word queue to obtain the first rewritten question.
[0094] S320. Perform language conversion on the first rewriting problem to obtain the first structured problem statement, and query the database based on the first structured problem statement to obtain the first query result.
[0095] S330. Input the first input question and the first query result into the answer generation model, obtain the first answer, and send the first answer to the user interface; the first input question is the original question or the first rewritten question.
[0096] In this embodiment, the implementation of S310 to S330 can refer to any of the above embodiments, and will not be repeated here.
[0097] S340. Determine the type of visualization chart that matches the first query result, and send recommendation information containing the visualization chart type to the user interface.
[0098] The types of visual charts can include: detailed tables, indicator cards, line charts, leaderboards, main charts, pie charts, funnel charts, color-block maps, word clouds, etc. Recommended information consists of information related to the answers to questions recommended to users, aiming to further clarify user intent through information recommendations and user responses. Recommended information includes at least one type of visual chart.
[0099] Specifically, after obtaining the first answer output by the answer generation model, the visualization chart type matching the first query result is determined based on chart mapping rules and used as recommended information to the user. Recommended information containing the visualization chart types matching the first answer is generated and sent to the user interface, allowing the user to select or ignore the recommended visualization chart types based on their needs.
[0100] For example, a chart mapping rule can be represented by a mapping function as: GraphType = f(UserSemantic), where f() is a mapping function used to recommend the most suitable visualization chart type GraphType based on user semantics.
[0101] S350. When the selected target visualization chart type is obtained, perform data analysis on the first query result to obtain the first chart data.
[0102] The target visualization chart type can be understood as the selected visualization chart type. The first chart data can be understood as the data used to construct the chart corresponding to the first query result. Chart data can include: chart dimension data and chart metric data. Chart dimension data can be understood as the specific indicators of the data collected by the chart, usually expressed as quantified data, such as time, location, task, and event; chart metric data can be understood as the specific values in each dimension.
[0103] In this embodiment, if the user selects a target visualization chart type from the recommended visualization chart types, upon receiving the target visualization chart type, the system performs data analysis on the first query result to obtain the chart data required to draw the visualization chart corresponding to the visualization chart type.
[0104] In an optional embodiment, the step of performing data analysis on the first query result to obtain chart data includes:
[0105] S351. Parse the first query result according to the first structured question statement to obtain chart dimension data;
[0106] S352. Perform statistical analysis on the first query result based on the chart dimension data using a data statistical model to obtain chart measurement data;
[0107] S353. The first chart data is constructed based on the chart dimension data and the chart metric data.
[0108] The first chart data can be understood as the chart data corresponding to the first query result.
[0109] For example, for the first structured query statement, the first chart dimension data is typically obtained by parsing the fields in the GROUP BY clause or the fields in the SELECT statement that are not involved in aggregation calculations. The second chart dimension data is obtained by parsing the results of aggregate functions (such as COUNT(), SUM(), AVG(), etc.) in the SELECT statement. For example, the first structured query statement is: SELECT department, SUM(employee_count) AS employee_count FROM employeesGROUP BY department; the first chart dimension data is the department name, and the second chart dimension data is the number of employees. The first query result is the number of employees in each department. Statistical analysis can be performed on the first query result to obtain chart metrics including the number of employees corresponding to each department. Furthermore, statistical analysis can be performed on the first query result through data statistical models to obtain more chart metric data, such as the average number of employees in each department, the percentage, and the growth rate.
[0110] Understandably, data statistical models can not only use mathematical statistics methods, such as Python functions, to perform statistical analysis on query results, such as calculating the mean, median, maximum, minimum, and percentage; they can also use big data analysis algorithms to provide reasonable predictions and suggestions, proactively meeting users' query needs. Data statistical models can be large language models or deep learning models.
[0111] S360. Draw a first visualization chart based on the first chart data and the target visualization chart type, and send the first visualization chart to the user interface.
[0112] Specifically, the chart drawing function is called to draw the first visualization chart based on the first chart data obtained from statistical analysis and the target visualization chart type selected by the user, and then the first visualization chart is sent to the user interface.
[0113] In this embodiment, while providing the user with the answer to the question, a recommendation message is also sent to the user, suggesting that the user choose an appropriate visualization chart type to visualize the answer to the question, providing the user with a more intuitive answer and improving the user experience.
[0114] S370. Send the semantic association word queue to the user interface, and when the target semantic association word selected from the semantic association word queue is received, correct the first answer according to the target semantic association word and obtain the second answer.
[0115] In an optional embodiment, the step of sending the semantic association word queue to the user interface and, upon receiving a target semantic association word selected from the semantic association word queue, correcting the first answer based on the target semantic association word to obtain a second answer includes:
[0116] S371. Upon receiving negative feedback information for the first answer, send a rhetorical question containing the semantic association word queue to the user interface, and obtain the target semantic association word selected by the user from the semantic association word queue;
[0117] S372. Update the order of semantic association words in the semantic association word queue based on the target semantic association words;
[0118] S373. Based on the updated semantic association word queue, the original question is semantically rewritten again to obtain the second rewritten question;
[0119] S374. Perform language conversion on the second rewriting problem to obtain the second structured problem statement;
[0120] S375. Query the database according to the second structured question statement to obtain the second query result;
[0121] S376. Input the second input question and the second query result into the answer generation model to obtain the second answer; the second input question is the original question or the second rewritten question.
[0122] Among these, rhetorical questions are posed to users to elicit more specific intent information. Rhetorical questions contain a queue of semantic association words, providing users with indicative information to help them express their true intentions. Target semantic association words refer to the semantic association words that the user selects from this queue.
[0123] Specifically, upon receiving negative feedback, indicating user dissatisfaction with the initial answer, a follow-up question containing a semantic association word queue is sent to the user interface. This allows the user to select other target semantic association words that express their intent from the displayed queue. Upon obtaining a selected target semantic association word, its weight is updated, thereby updating the order of semantic association words in the queue. Understandably, the target semantic association word has the highest weight at this point. Based on the highest-weighted semantic association word in the updated queue (i.e., the target semantic association word), the original question is semantically rewritten and language-converted to obtain a second structured question statement. The database is then queried based on this second structured question statement to obtain a second query result. Finally, the second input question (either the original question or the second rewritten question) and the second query result are input into the answer generation model to obtain a second answer.
[0124] It is understood that the specific execution processes of S373 to S376 are basically the same as those of S310 to S330, and will not be repeated here in this embodiment of the invention. In this embodiment, the semantic association word queue can semantically rewrite the original question to obtain a first rewritten question; if the semantic association word queue is updated based on the user's selection, the updated semantic association word queue can semantically rewrite the original question again to obtain a second rewritten question, thereby correcting the question. Furthermore, the target semantic association word queue that is finally recognized by the user can also be used to quickly semantically associate similar questions. The target semantic association word queue can be understood as the semantic association word queue corresponding to the answer that receives positive feedback information from the user. The target semantic association word queue can be a semantic association word queue obtained by semantically associating the original question, or it can be an updated semantic association word queue obtained by updating the order of semantic association words in the semantic association word queue based on the target semantic association words selected by the user from the semantic association word queue.
[0125] In one optional embodiment, the received user question is semantically parsed to obtain user question keywords. If the semantics of the user question keywords are unclear and the semantics are similar to those of the target question keywords, then the target semantic association word queue corresponding to the target question keywords is obtained, and the user question is semantically rewritten according to the target semantic association word queue.
[0126] The target semantic association word queue can be understood as a queue of historical semantic association words that have been recognized by the user. The target question keywords can be understood as the question keywords associated with the target semantic association word queue.
[0127] Specifically, after generating a semantic association word queue based on the question keywords of the original question, if the question rewritten based on the semantic association word queue and the generated answer receive positive feedback from users, then the question keywords of the original question are determined as the target question keywords, and the semantic association word queue corresponding to the answer is determined as the target semantic association word queue corresponding to the target question keywords. The target question keywords and target semantic association word queues are then stored in the database. If the semantics of the user question keywords contained in the user question are unclear but similar to the semantics of the target question keywords, then the target semantic association word queue corresponding to the target question keywords is obtained. The user question is then semantically rewritten based on the target semantic association word queue, thereby improving the semantic association and semantic rewriting of ambiguous questions based on a large amount of historical user feedback information, and improving the efficiency and accuracy of semantic rewriting of ambiguous questions.
[0128] It is understandable that semantic similarity can be a case where the semantic similarity is greater than a preset value.
[0129] Furthermore, due to the diversity and variability of user intentions, different users may choose different semantic association word queues, and an answer that satisfies one user may not satisfy others. Therefore, a user question keyword table can be further established for each user; the user question keyword table stores the target semantic association word queue recognized by the user in historical user questions; when a user question is received, the user question is semantically parsed to obtain user question keywords; if the semantics of the user question keywords are unclear, the user question keyword table is queried based on the obtained user information (such as user ID); if a target question keyword with similar semantics exists in the user question keyword table, the target semantic association word queue corresponding to the target question keyword is obtained, and the user question is semantically rewritten based on the target semantic association word queue. This allows for semantic association and semantic rewriting of ambiguous questions based on a user's historical feedback information, further improving the accuracy of semantic rewriting of ambiguous questions and making the rewritten question more in line with the user's question expression habits.
[0130] Based on the above optional embodiments, after obtaining the second answer, the method further includes:
[0131] S380. Perform data analysis on the second query results based on the target visualization chart type to obtain the second chart data.
[0132] S390. Draw a second visualization chart based on the second chart data and the target visualization chart type, and send the second visualization chart to the user interface.
[0133] The second chart data can be understood as the chart data obtained based on the analysis of the second query results.
[0134] Specifically, under the error correction mechanism based on user questions and answers, after updating the first answer to the second answer, the data analysis and visualization chart of the corrected second query result can be re-executed according to the target visualization chart type selected by the user, and the updated second visualization chart data can be fed back to the user interface.
[0135] It is understood that the second chart data and the first chart data are generated in the same way, and the second visualization chart and the first visualization chart are drawn in the same way. This embodiment of the invention will not elaborate further on this.
[0136] The technical solution of this invention involves semantic association of an acquired, semantically ambiguous original question to obtain a semantic association word queue, and semantically rewriting the original question based on the semantic association word queue to obtain a first rewritten question; performing language conversion on the first rewritten question to obtain a first structured question statement, and querying a database based on the first structured question statement to obtain a first query result; inputting the first input question and the first query result into an answer generation model to obtain a first answer, and sending the first answer to the user interface; the first input question is either the original question or the first rewritten question; determining the visualization chart type that matches the first query result, and sending recommendation information containing the visualization chart type to the user interface; when the selected target visualization chart type is obtained, performing data analysis on the first query result to obtain first chart data; drawing a first visualization chart based on the first chart data and the target visualization chart type, and sending the first visualization chart to the user interface; and when receiving a target semantic association word selected from the semantic association word queue, correcting the first answer based on the target semantic association word to obtain a second answer. Based on semantic association word queues and user question-and-answer correction mechanisms, we can improve and correct users' semantically ambiguous or unclear questions, which is conducive to more accurately handling the diverse and differentiated query needs of users. By analyzing and visualizing the query data, we can improve the intuitiveness of the answer data and further enhance the user experience.
[0137] In a specific example, a user poses the original question Q1: "How has the number of cases changed this year?". The `AmbiguousKeywords = Search(K, Q1)` function searches for semantically ambiguous keywords in the keyword set K of the original question Q1. Semantic association and semantic rewriting are performed on the original question Q1 to obtain a semantic association word queue D = [case filing time, case solving time, police report receiving time, interrogation time]. Based on the semantic association word "case filing" in the semantic association word queue, the first rewritten question Q′1 is generated: "Statistically analyze the changing trend of the number of cases filed in 2024". The first rewritten question Q′1 is converted into the first structured question statement Q″1. The case database is queried based on the first structured question statement Q″1 to obtain the first query result R1. The first input question (original question Q1 or first rewritten question Q′1) and the first query result R1 are input into the answer generation model to obtain the first answer A1. The first answer A1 is sent to the user interface so that the user can provide feedback information F on the first answer, where F = positive feedback information (positive) or negative feedback information (negative). Furthermore, it can determine the type of visualization chart that matches the first answer A1 and send the recommendation information containing the visualization chart type to the user interface; when the visualization chart type selected by the user is obtained, data analysis is performed on the first query result R1 according to the selected visualization chart type to obtain chart data, prediction data O2 and suggestion information O3; visualization chart O1 is drawn according to the chart data and visualization chart type, and visualization chart O1, prediction data O2 and suggestion information O3 are sent to the user interface.
[0138] If negative feedback is received from the user regarding the first answer, a follow-up question QR is generated using UserQuestion = FormulateQuestion(AmbiguousKeywords): "Which of the following would you like to be used for statistics this year: [Case filing time, case solving time, police call time, interrogation time]?" The target semantic association word selected by the user from the semantic association word queue is obtained using I = GetUserInput(), such as the user selecting police call time. The semantic association word queue D is updated using K' = UpdateKeywords(K,I) and P′(K′) = P(K′) (where P(K) is the weighting sorting function), updating the semantic association word queue D = [Police call time, case filing time, case solving time, interrogation time]. A second rewritten question Q′2 is generated using RecalculateAnswer(Q1,D): "Statistically analyze the changing trend of the number of police calls in 2024." The second rewritten question Q′2 is converted into a second structured question statement Q″2. The case database is then queried based on the second structured question statement Q″2 to obtain the second query result R2. The second input question (original question Q1 or second rewritten question Q′2) and the second query result R2 are input into the answer generation model to obtain the second answer A2, which is then sent to the user interface. Furthermore, data analysis is performed on the second query result R2 according to the visualization chart type to obtain second chart data. A second visualization chart is then created based on the second chart data and the visualization chart type, and subsequently sent to the user interface. This provides users with intuitive access to statistical information not included in the query results, proactively meeting their query needs.
[0139] Example 4
[0140] Figure 4 This is a schematic diagram of a question-answering device provided in Embodiment 4 of the present invention. Figure 4 As shown, the device includes: a question association module 410, a question query module 420, an answer sending module 430, and an answer correction module 440; wherein,
[0141] The question association module 410 is used to perform semantic association on the obtained semantically ambiguous original question to obtain a semantic association word queue, and to perform semantic rewriting on the original question according to the semantic association word queue to obtain a first rewritten question;
[0142] The question query module 420 is used to perform language conversion on the first rewritten question to obtain a first structured question statement, and query the database based on the first structured question statement to obtain a first query result;
[0143] Answer sending module 430 is used to input the first input question and the first query result into the answer generation model, obtain the first answer, and send the first answer to the user interface; the first input question is the original question or the first rewritten question;
[0144] The answer correction module 440 is used to send the semantic association word queue to the user interface, and when it receives the target semantic association word selected from the semantic association word queue, it corrects the first answer according to the target semantic association word to obtain the second answer.
[0145] The technical solution of this invention involves semantic association of an acquired, semantically ambiguous original question to obtain a semantic association word queue, and semantically rewriting the original question based on the semantic association word queue to obtain a first rewritten question; performing language conversion on the first rewritten question to obtain a first structured question statement, and querying a database based on the first structured question statement to obtain a first query result; inputting the first input question and the first query result into an answer generation model to obtain a first answer, and sending the first answer to the user interface, where the first input question is either the original question or the first rewritten question; sending the semantic association word queue to the user interface, and upon receiving a target semantic association word selected from the semantic association word queue, correcting the first answer based on the target semantic association word to obtain a second answer. This approach can improve and correct users' semantically ambiguous or unclear questions based on the semantic association word queue and the user question-and-answer correction mechanism, which is beneficial for more accurately handling the diverse and varied query needs of users.
[0146] Optional, the problem association module 410 includes:
[0147] The semantic parsing unit is used to perform semantic parsing on the obtained original question to obtain question keywords;
[0148] A semantic association unit is used to query a pre-created knowledge base based on the question keyword if the semantics of the question keyword are unclear, and obtain a semantic association word queue for the question keyword; the semantic association word queue includes semantic association words corresponding to the question keyword sorted by weight;
[0149] The semantic rewriting unit is used to input the semantic association word with the highest weight in the semantic association word queue and the original question into the semantic rewriting model to obtain the first rewriting question.
[0150] Optional, the problem query module 420 includes:
[0151] The language conversion unit is used to input the first rewriting problem into the language conversion model to obtain the first structured problem statement;
[0152] The question query unit is used to query the database based on the first structured question statement to obtain the first query result.
[0153] Optionally, the step of pre-creating the knowledge body base includes:
[0154] Information resources for pre-defined application areas are collected through different channels;
[0155] The information resources are structured to obtain the semantic structure and conceptual relationships of the knowledge points;
[0156] Dictionary mapping is performed on the information resources and their corresponding semantic structures and conceptual relationships to obtain a knowledge body;
[0157] A knowledge base is constructed from all the knowledge entities.
[0158] Optionally, the training steps of the semantic rewriting model include:
[0159] Obtain the original problem sample set;
[0160] Randomly mask the question sample keywords of each original question sample in the original question sample set to obtain a masked question sample set.
[0161] Based on the masked question sample keywords, query the knowledge body in the knowledge body base to obtain the sample semantic association word queue of the question sample keywords;
[0162] Generate an association question sample set based on the masked question sample set and the sample semantic association word queue;
[0163] A set of prompt words for question rewriting is constructed based on the set of associated question samples, the queue of sample semantic associated words, and the set of masked question samples.
[0164] Train a first preset large language model based on the set of prompt words to rewrite the question, and obtain a semantic rewriting model.
[0165] Optionally, the training steps for the language conversion model include:
[0166] Obtain the original question sample set and the rewritten question sample set containing semantic association words of the samples;
[0167] Obtain the structured question statement sample sets corresponding to the original question sample set and the rewritten question sample set, respectively;
[0168] Based on the original question sample set and the corresponding structured question statement sample set, as well as the rewritten question sample set and the corresponding structured question statement sample set, a language conversion prompt word set is constructed;
[0169] A second preset large language model is trained based on the language conversion prompt word set to obtain a language conversion model.
[0170] Optional, answer correction module 440, specifically used for:
[0171] Upon receiving negative feedback information for the first answer, a counter-question containing the semantic association word queue is sent to the user interface, and the target semantic association word selected by the user from the semantic association word queue is obtained;
[0172] The order of semantic association words in the semantic association word queue is updated based on the target semantic association words;
[0173] The original question is semantically rewritten again based on the updated semantic association word queue to obtain a second rewritten question;
[0174] The second rewriting problem is converted into a language to obtain the second structured problem statement;
[0175] The database is queried based on the second structured question statement to obtain the second query result;
[0176] The second input question and the second query result are input into the answer generation model to obtain the second answer; the second input question is either the original question or the second rewritten question.
[0177] Optionally, the device further includes:
[0178] The chart type sending module is used to determine the visual chart type that matches the first query result after the step of inputting the first structured question statement and the first query result into the answer generation model and obtaining the first answer, and to send the recommendation information containing the visual chart type to the user interface.
[0179] The chart data acquisition module is used to perform data analysis on the first query result to obtain chart data when the selected target visualization chart type is obtained;
[0180] The chart drawing module is used to draw a visualization chart based on the chart data and the target visualization chart type, and send the visualization chart to the user interface.
[0181] Optional, the chart data acquisition module is specifically used for:
[0182] The first query result is parsed based on the first structured question statement to obtain chart dimension data;
[0183] The first query result is statistically analyzed based on the chart dimension data using a data statistical model to obtain chart measurement data.
[0184] Chart data is constructed based on the chart dimension data and the chart metric data.
[0185] The question-answering device provided in the embodiments of the present invention can execute the question-answering method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of executing the method.
[0186] Example 5
[0187] Figure 5 A schematic diagram of an electronic device 10 that can be used to implement embodiments of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.
[0188] like Figure 5 As shown, the electronic device 10 includes at least one processor 11 and a memory, such as a read-only memory (ROM) 12 or a random access memory (RAM) 13, communicatively connected to the at least one processor 11. The memory stores computer programs executable by the at least one processor. The processor 11 can perform various appropriate actions and processes based on the computer program stored in the ROM 12 or loaded from storage unit 18 into the RAM 13. The RAM 13 may also store various programs and data required for the operation of the electronic device 10. The processor 11, ROM 12, and RAM 13 are interconnected via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0189] Multiple components in electronic device 10 are connected to I / O interface 15, including: input unit 16, such as keyboard, mouse, etc.; output unit 17, such as various types of displays, speakers, etc.; storage unit 18, such as disk, optical disk, etc.; and communication unit 19, such as network card, modem, wireless transceiver, etc. Communication unit 19 allows electronic device 10 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0190] Processor 11 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. Processor 11 performs the various methods and processes described above, such as question-answering methods.
[0191] In some embodiments, the question-answering method may be implemented as a computer program tangibly contained in a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on electronic device 10 via ROM 12 and / or communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the question-answering method described above may be performed. Alternatively, in other embodiments, processor 11 may be configured to perform the question-answering method by any other suitable means (e.g., by means of firmware).
[0192] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0193] In some embodiments, the question-answering method may be implemented as a computer program, which is implicitly included in a computer program product. When executed by a processor, the computer program implements the question-answering method of the present invention. The computer program product can be understood as a software product that primarily implements its solution through a computer program. The computer program used to implement the method of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when executed by the processor, the computer program causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The computer program may be executed entirely on a machine, partially on a machine, as a standalone software package partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0194] In the context of this invention, a computer-readable storage medium can be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, apparatus, or device. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination thereof. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0195] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0196] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or computing systems that include middleware components (e.g., application servers), or computing systems that include frontend components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., communication networks). Examples of communication networks include local area networks (LANs), wide area networks (WANs), blockchain networks, and the Internet.
[0197] A computing system can include clients and servers. Clients and servers are generally located far apart and typically interact through communication networks. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a hosting product within the cloud computing service system to address the shortcomings of traditional physical hosts and VPS services, such as high management difficulty and weak business scalability.
[0198] It should be understood that the various forms of processes shown above can be used to reorder, add, or delete steps. For example, the steps described in this invention can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this invention can be achieved, and this is not limited herein.
[0199] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.
Claims
1. A question-answering method, characterized in that, include: Semantic association is performed on the original question with unclear semantics to obtain a semantic association word queue; The original question is semantically rewritten based on the semantic association word queue to obtain a first rewritten question; the semantic association word queue includes semantic association words corresponding to question keywords sorted by weight; the question keywords are obtained by semantic parsing the obtained original question; The first rewriting problem is converted into a language to obtain a first structured problem statement, and the database is queried based on the first structured problem statement to obtain a first query result; The first input question and the first query result are used to generate an answer model, obtain a first answer, and send the first answer to the user interface; The first input question is either the original question or the first rewritten question; The semantic association word queue is sent to the user interface, and upon receiving a target semantic association word selected from the semantic association word queue, the first answer is corrected based on the target semantic association word to obtain the second answer; The original question is semantically rewritten based on the semantic association word queue to obtain a first rewritten question, including: inputting the semantic association word with the largest weight in the semantic association word queue and the original question into the semantic rewriting model to obtain the first rewritten question.
2. The method according to claim 1, characterized in that, Semantic association is performed on the obtained semantically ambiguous original question to obtain a semantic association word queue, including: Semantic analysis is performed on the obtained original questions to obtain question keywords; If the semantics of the question keyword are unclear, then a pre-created knowledge body base is queried based on the question keyword to obtain the semantic association word queue of the question keyword; The steps to perform language conversion on the first rewriting problem to obtain the first structured problem statement include: The first rewriting problem is input into the language conversion model to obtain the first structured problem statement.
3. The method according to claim 2, characterized in that, The steps for pre-creating the knowledge body base include: Collect information resources for pre-defined application areas through different channels; The information resources are structured to obtain the semantic structure and conceptual relationships of the knowledge points; Dictionary mapping is performed on the information resources and their corresponding semantic structures and conceptual relationships to obtain a knowledge body; A knowledge base is constructed based on all the knowledge entities.
4. The method according to claim 2, characterized in that, The training steps of the semantic rewriting model include: Obtain the original problem sample set; Randomly mask the question sample keywords of each original question sample in the original question sample set to obtain a masked question sample set. Based on the masked question sample keywords, query the knowledge body in the knowledge body base to obtain the sample semantic association word queue of the question sample keywords; Generate an association question sample set based on the masked question sample set and the sample semantic association word queue; A set of prompt words for question rewriting is constructed based on the set of associated question samples, the queue of sample semantic associated words, and the set of masked question samples. Train a first preset large language model based on the set of prompt words to rewrite the question, and obtain a semantic rewriting model.
5. The method according to claim 2, characterized in that, The training steps of the language conversion model include: Obtain the original question sample set and the rewritten question sample set containing semantic association words of the samples; Obtain the structured question statement sample sets corresponding to the original question sample set and the rewritten question sample set, respectively; Based on the original question sample set and the corresponding structured question statement sample set, as well as the rewritten question sample set and the corresponding structured question statement sample set, a language conversion prompt word set is constructed; A second preset large language model is trained based on the language conversion prompt word set to obtain a language conversion model.
6. The method according to any one of claims 1-5, characterized in that, The steps of sending the semantic association word queue to the user interface, and upon receiving a target semantic association word selected from the semantic association word queue, correcting the first answer based on the target semantic association word to obtain the second answer, include: Upon receiving negative feedback information for the first answer, a counter-question containing the semantic association word queue is sent to the user interface, and the target semantic association word selected by the user from the semantic association word queue is obtained; The order of semantic association words in the semantic association word queue is updated based on the target semantic association words; The original question is semantically rewritten again based on the updated semantic association word queue to obtain a second rewritten question; The second rewriting problem is converted into a language to obtain the second structured problem statement; The database is queried based on the second structured question statement to obtain the second query result; The second input question and the second query result are input into the answer generation model to obtain the second answer; the second input question is either the original question or the second rewritten question.
7. The method according to any one of claims 1-5, characterized in that, After the step of inputting the first input question and the first query result into the answer generation model to obtain the first answer, the method further includes: Determine the type of visualization chart that matches the first query result, and send recommendation information containing the visualization chart type to the user interface; Upon obtaining the selected target visualization chart type, perform data analysis on the first query result to obtain chart data; A visualization chart is drawn based on the chart data and the target visualization chart type, and the visualization chart is sent to the user interface.
8. The method according to claim 7, characterized in that, The step of performing data analysis on the first query result to obtain chart data includes: The first query result is parsed based on the first structured question statement to obtain chart dimension data; The first query result is statistically analyzed based on the chart dimension data using a data statistical model to obtain chart measurement data. Chart data is constructed based on the chart dimension data and the chart metric data.
9. An electronic device, characterized in that, The electronic device includes: At least one processor; and A memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, which, when executed by the at least one processor, enables the at least one processor to perform the question-answering method according to any one of claims 1-8.
10. A computer program product, characterized in that, The computer program product includes a computer program that, when executed by a processor, implements the question-answering method according to any one of claims 1-8.
Citation Information
Patent Citations
Text processing model training method and device, text rewriting method and device and storage medium
CN116894431A
Autonomous interactive question and answer method, system and device and medium
CN117874210A