Question answering method, question answering device, electronic equipment and computer readable storage medium
By obtaining the vector and semantic vectors of the question text, and combining keyword extraction and verification, the answer text is integrated, the accuracy of the existing question-and-answer system when handling sub-questions that are not clear enough in semantics are solved, and the accuracy of question answers is improved.
Patent Information
- Application Number
- CN202411800149.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-06
- Publication Date
- 2025-01-14
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
When existing question-and-answer systems deal with sub-questions whose semantics are not clear enough, they cannot accurately determine the answer text, which affects the accuracy of the answers to the question.
By obtaining the vector and semantic vectors of the question text, combining keyword extraction and verification, the first and second answer texts are integrated to determine the final answer text.
Improve the accuracy of the answers to the question, and ensure the accuracy and reliability of the answers by considering the semantic vectors and keywords of the question text.
Smart Images

Figure CN119311841A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of language processing technology, and in particular to a question-answering method, a question-answering device, an electronic device, and a computer-readable storage medium. Background Art
[0002] The question-answering system provides relevant answers to questions raised by users. In the related art, the question-answering system can answer questions raised by users based on the semantics of the question text and the text in the text library. However, the questions raised by users usually contain sub-questions with unclear semantics. The question-answering system in the related art cannot accurately determine the answer text based on the sub-questions with unclear semantics, thus affecting the accuracy of the answer to the question. Summary of the invention
[0003] In order to solve the above technical problems, the present disclosure provides a question-answering method, a question-answering device, an electronic device and a computer-readable storage medium.
[0004] In a first aspect, the present disclosure provides a question-answering method, the method comprising: Get the text of the question to be processed; Determine a question vector corresponding to the question text to be processed, and determine a first answer text corresponding to the question text to be processed based on the question vector and a semantic vector of a text in a reference text library corresponding to the question text to be processed; Acquire a target keyword from the question text to be processed, and acquire a second answer text containing the target keyword from the reference text library; Based on the first answer text and the second answer text, a target answer text corresponding to the question text to be processed is determined.
[0005] In some embodiments of the present disclosure, determining the question vector corresponding to the question text to be processed includes: A pre-generated semantic vector model is used to perform vector extraction on the question text to be processed, so as to obtain a question vector corresponding to the question text to be processed.
[0006] In some embodiments of the present disclosure, determining the first answer text corresponding to the question text to be processed based on the question vector and the semantic vector of the text in the reference text library corresponding to the question text to be processed includes: Calculating the similarity between the question vector and the semantic vector of the text in the reference text library; The text corresponding to the semantic vector with the highest similarity is obtained from the reference text library as the first answer text corresponding to the question text to be processed.
[0007] In some embodiments of the present disclosure, the step of obtaining target keywords from the question text to be processed includes: Extracting preset characters from the problem text to be processed to obtain the text to be screened, wherein the preset characters include one or more of letters, numbers, and spaces; Extracting initial keywords from the text to be screened according to a common character table; Based on the reference text library, the target keyword is obtained from the initial keywords.
[0008] In some embodiments of the present disclosure, extracting initial keywords from the text to be screened according to the common character table includes: Deleting the search common characters belonging to the common character table from the text to be screened; The remaining characters in the text to be screened except the common search characters are used as the initial keywords.
[0009] In some embodiments of the present disclosure, the step of acquiring the target keyword from the initial keyword based on the reference text library includes: Determining the number of times the initial keyword appears in the reference text library; A keyword whose number of occurrences is within a preset number interval is obtained from the initial keywords as the target keyword.
[0010] In some embodiments of the present disclosure, the minimum value of the preset number interval is 0; The maximum value of the preset number interval is determined according to the number of times the predefined keyword appears in the reference text library and the number of times the predefined non-keyword appears in the reference text library.
[0011] In some embodiments of the present disclosure, the maximum value of the preset number interval is between the number of times the predefined keyword appears in the reference text library and the number of times the predefined non-keyword appears in the reference text library.
[0012] In some embodiments of the present disclosure, before acquiring the target keyword from the initial keyword based on the reference text library, the method further includes: Verifying the initial keywords to obtain verified keywords; Accordingly, the step of acquiring the target keyword from the initial keyword based on the reference text library includes: The target keyword is extracted from the verified keywords according to the reference text library.
[0013] In some embodiments of the present disclosure, verifying the initial keyword to obtain the verified keyword includes: Extracting predefined error-prone characters from the initial keywords; The error-prone character is replaced with a predefined correction character to obtain the verified keyword, wherein the predefined correction character is a character with a shape similar to that of the error-prone character.
[0014] In some embodiments of the present disclosure, verifying the initial keyword to obtain the verified keyword includes: Calculate the similarity between the initial keyword and the reference keyword of each text in the reference text library; A keyword with the highest similarity is selected from the reference keywords of each text in the reference text library as the verified keyword.
[0015] In some embodiments of the present disclosure, determining the target answer text corresponding to the question text to be processed based on the first answer text and the second answer text includes: Integrating the first answer text and the second answer text to form an answer text sequence; The answer text sequence is processed using a pre-acquired large language model to obtain the target answer text.
[0016] In a second aspect, the present disclosure provides a question-answering device, the device comprising: The first acquisition module is used to acquire the question text to be processed; A first determination module is used to determine a question vector corresponding to the question text to be processed, and determine a first answer text corresponding to the question text to be processed based on the question vector and a semantic vector of a text in a reference text library corresponding to the question text to be processed; A second acquisition module is used to acquire target keywords from the question text to be processed, and acquire a second answer text containing the target keywords from the reference text library; The second determination module is used to determine the target answer text corresponding to the question text to be processed based on the first answer text and the second answer text.
[0017] In a third aspect, an embodiment of the present disclosure further provides an electronic device, the device comprising: one or more processors; a storage device for storing one or more programs, When one or more programs are executed by one or more processors, the one or more processors implement the method provided in the first aspect.
[0018] In a fourth aspect, an embodiment of the present disclosure further provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the method provided in the first aspect is implemented.
[0019] The technical solution provided by the embodiments of the present disclosure has the following advantages: A question-answering method, a question-answering device, an electronic device, and a computer-readable storage medium of an embodiment of the present disclosure, for an acquired question text to be processed, firstly determines the first answer text corresponding to the question text to be processed based on the question vector corresponding to the question text to be processed and the semantic vector of the text in the reference text library corresponding to the question text to be processed, and at the same time, obtains the target keyword from the question text to be processed, and obtains the second answer text containing the target keyword from the reference text library, and then combines the two types of answer texts to determine the target answer text corresponding to the question text to be processed. In this way, the semantic vector in the question text and the keywords in the question text are taken into consideration, and the final answer text corresponding to the question text is jointly determined, thereby improving the accuracy of the question answer. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0021] In order to more clearly illustrate the technical solution of the embodiment of the present disclosure, the drawings required for use in the description of the embodiment will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0022] Figure 1 A flowchart of a question-and-answer method provided in an embodiment of the present disclosure; Figure 2 A flowchart of a method for obtaining target keywords from a question text to be processed provided by an embodiment of the present disclosure; Figure 3 A schematic diagram of the structure of a question-answering device provided in an embodiment of the present disclosure; Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0023] In order to more clearly understand the above-mentioned objectives, features and advantages of the present disclosure, the scheme of the present disclosure will be further described below. It should be noted that the embodiments of the present disclosure and the features in the embodiments can be combined with each other without conflict.
[0024] In the following description, many specific details are set forth to facilitate a full understanding of the present disclosure, but the present disclosure may also be implemented in other ways different from those described herein; it is obvious that the embodiments in the specification are only part of the embodiments of the present disclosure, rather than all of the embodiments.
[0025] In order to improve the accuracy of answering questions, the following Figure 1~Figure 2 The question-and-answer method provided in the embodiment of the present disclosure is described. In the embodiment of the present disclosure, the question-and-answer method can be executed by an electronic device or a server. The electronic device may include a device with a communication function such as a tablet computer, a desktop computer, a laptop computer, or a device simulated by a virtual machine or a simulator. The server may be a cloud server or a server cluster.
[0026] Figure 1 A flowchart of a question-and-answer method provided by an embodiment of the present disclosure is shown.
[0027] like Figure 1 As shown, the question-answering method may include the following steps.
[0028] S110, obtaining the text of the question to be processed.
[0029] In this embodiment, in a question-and-answer task scenario, the microphone or microphone array of the electronic device collects the question voice uttered by the user, performs audio analysis on the question voice, and generates a text of the question to be processed. Alternatively, the user inputs the question on the display screen of the electronic device so that the electronic device generates a text of the question to be processed based on the question input by the user.
[0030] Optionally, the question text to be processed includes one or more sub-questions. If the sub-questions included in the question text to be processed do not have clear semantics, or the sub-questions do not have clear meanings in natural language, then the corresponding answers cannot be searched based on the sub-questions.
[0031] S120, determining a question vector corresponding to the question text to be processed, and determining a first answer text corresponding to the question text to be processed based on the question vector and the semantic vector of the text in the reference text library corresponding to the question text to be processed.
[0032] In this embodiment, the electronic device first converts the question text to be processed into a vector form to obtain a question vector, then finds a semantic vector matching the question vector from the semantic vectors corresponding to the texts in the reference text library, and uses the text containing the semantic vector in the reference text library as the first answer text.
[0033] The reference text library refers to a collection of information related to the answer text corresponding to the text to be processed.
[0034] For example, if the question-answering task scenario is a voice navigation scenario, the reference text library may be a collection of information including navigation routes and road conditions of the navigation routes. Thus, when the question text to be processed includes the question "navigate to XXX", the corresponding answer text may be obtained from the reference text library.
[0035] For another example, if the question-answering task scenario is a weather forecast scenario, the reference text library can be a collection of information containing detailed information on past, current, and future weather conditions and clothing recommendations. In this way, when the question text to be processed contains a question about "the weather conditions on XXX day", the corresponding answer text can be obtained from the reference text library.
[0036] For another example, the question-answering task scenario is product after-sales service, such as after-sales service for marine propulsion units. In this case, the reference text library can be a collection of product information provided by the manufacturer of the marine propulsion unit, such as a collection of product manuals, fault and handling strategy descriptions, etc. In this way, when the question text to be processed contains information such as product fault codes and fault descriptions, the corresponding answer text can be obtained from the reference text library.
[0037] Among them, the specific implementation method of "determining the question vector corresponding to the question text to be processed" in S120 includes but is not limited to the following method: using a pre-generated semantic vector model to process the question text to be processed, and obtaining the question vector corresponding to the question text to be processed.
[0038] The semantic vector model is a neural network model that converts text into vector form. Optionally, the semantic vector model includes but is not limited to an embedding model (EM), and can also be a neural network model in other forms. For the embedding model, it can convert the text into a vector based on the semantic information of the text, and the embedding model is used to convert the problem text to be processed into a problem vector based on the semantic information of the problem text to be processed.
[0039] Similarly, the pre-generated semantic vector model is used to process the text in the reference text library to obtain the semantic vector corresponding to the text in the reference text library.
[0040] Among them, the specific implementation method of "determining the first answer text corresponding to the question text to be processed based on the question vector and the semantic vector corresponding to the text in the reference text library corresponding to the text to be processed" in S120 includes but is not limited to the following methods: calculating the similarity between the question vector and the semantic vector corresponding to the text in the text library; obtaining the text corresponding to the semantic vector with the highest similarity from the reference text library as the first answer text corresponding to the question text to be processed.
[0041] Specifically, after the electronic device obtains the question vector and the semantic vector corresponding to the text in the reference text library, it matches the question vector with the semantic vector, calculates the similarity between the question vector and the semantic vector, then compares the similarity between the semantic vectors of different texts and the question vector, and obtains the text corresponding to the semantic vector with the highest similarity from the reference text library as the first answer text corresponding to the question text to be processed.
[0042] It can be understood that the highest similarity means that the text corresponding to the semantic vector has the greatest relevance to the user's question, thereby providing the user with a first answer text with reference value.
[0043] S130: Obtain target keywords from the question text to be processed, and obtain a second answer text containing the target keywords from a reference text library.
[0044] It is understandable that if the question text to be processed contains sub-questions that have no clear meaning in natural language, that is, the question text to be processed contains sub-questions with unclear semantics, then these sub-questions with unclear semantics will affect the reliability of the answer text determination.
[0045] In order to solve this problem, this embodiment also adopts a method of determining the answer text by determining keywords.
[0046] In some embodiments, the keyword extraction model is directly called to process the question text to be processed, obtain the target keyword, and obtain the text containing the target keyword from the reference text library as the second answer text.
[0047] In other embodiments, it is also possible to first filter out keywords such as letters, numbers, spaces, etc. from the question text to be processed, and then eliminate some common characters, and combine with a reference text library to determine the target keywords, and obtain the text containing the target keywords from the reference text library as the second answer text.
[0048] Among them, the target keywords are the keywords finally extracted from the question text to be processed in the question-answering task scenario.
[0049] Therefore, by performing keyword extraction on the question text to be processed, a second answer text containing target keywords can be obtained from a reference text library, thereby expanding the method for determining the answer text.
[0050] S140. Based on the first answer text and the second answer text, determine the target answer text corresponding to the question text to be processed.
[0051] In this embodiment, the electronic device integrates the first answer text and the second answer text to determine the target answer text based on the integrated answer text, thereby combining the semantic vector in the question text and the keywords in the question text to jointly determine the final answer text corresponding to the question text.
[0052] Among them, the specific implementation method of S140 includes but is not limited to the following methods: integrating the first answer text and the second answer text to form an answer text sequence; using the pre-acquired large language model to process the answer text sequence to obtain the target answer text.
[0053] Specifically, the electronic device splices the second target text to the end of the first target text to form an answer text sequence, or splices the first target text to the end of the second target text to form an answer text sequence, and then calls the large language model to process the answer text sequence to obtain the target text. The large language model's processing of the answer text sequence may include marking the source of the answer text, and overall combing and reorganizing the answer text to provide the user with a more readable answer text. In this way, the answer to the question raised by the user can be output.
[0054] A question-answering method of an embodiment of the present disclosure, for the obtained question text to be processed, first determines the first answer text corresponding to the question text to be processed based on the question vector corresponding to the question text to be processed and the semantic vector of the text in the reference text library corresponding to the question text to be processed, and at the same time, obtains the target keyword from the question text to be processed, and obtains the second answer text containing the target keyword from the reference text library, and then combines the two types of answer texts to determine the target answer text corresponding to the question text to be processed. In this way, the semantic vector in the question text and the keywords in the question text are taken into consideration, and the final answer text corresponding to the question text is jointly determined, thereby improving the accuracy of the question answer.
[0055] In another embodiment of the present disclosure, a method for extracting target keywords is explained in detail.
[0056] Figure 2 A flow chart of a method for obtaining target keywords from a question text to be processed provided by an embodiment of the present disclosure is shown.
[0057] like Figure 2 As shown, the method for extracting the target keyword may include the following steps.
[0058] S210, extracting preset characters from the problem text to be processed to obtain the text to be screened, where the preset characters include one or more of letters, numbers, and spaces.
[0059] It is understandable that in the question-and-answer task scenario, it is necessary to extract keywords from text containing characters such as letters, numbers, and spaces. The electronic device first analyzes the types of each character in the text to be detected to extract one or more of the letters, numbers, and spaces as preset characters, and uses the text containing the preset characters as the text to be screened. In order to improve the accuracy of target keyword extraction, the target keywords required for the question-and-answer task scenario are extracted in combination with the common character table and the reference text library to improve the accuracy of keyword extraction in the question-and-answer scenario.
[0060] For example, the text of the question to be processed is: I am a user from a certain country, My friennd just used my booooat, then the A70 told me B100C03 code, how to fix it, do I need to claim the warranty. The electronic device extracts preset characters such as letters, spaces, and numbers from the text of the question to be processed, and the obtained text to be filtered is: My friennd just used my booooat then the A70 told me B100C03 codehow to fix it do I need to claim the warranty.
[0061] S220: extracting initial keywords from the text to be screened according to the common character table.
[0062] It is understandable that when the electronic device searches for the corresponding answer text based on the text to be processed, it usually ignores text that is very short and meaningless in natural language, but such text is crucial to answering the question, and ignoring such text will affect the accuracy of the answer to the question. Therefore, for this reason, the electronic device also preliminarily extracts keywords from the text to be screened in combination with the common character table, so as to use the common character table to assist in determining the text that is very short and meaningless in natural language.
[0063] The common character table refers to a set of commonly used search terms that is predefined in the question-answering task scenario.
[0064] The specific implementation method of S220 includes but is not limited to the following methods: deleting the common search characters belonging to the common character table from the text to be filtered; and using the remaining characters in the text to be filtered except the common search characters as initial keywords.
[0065] Specifically, the electronic device can determine whether each character belongs to the common search characters in the common character table based on the character expression order of the text to be filtered. If it does, the common search characters will be deleted from the text to be filtered, and the remaining characters (i.e., characters that are very short and meaningless in natural language) will be used as the initial keywords extracted in the question and answer task scenario.
[0066] Optionally, the remaining characters in the text to be screened except for the common characters to be searched include typos and characters that do not frequently appear in the question-and-answer task scenario.
[0067] For example, the text to be filtered is: My friennd just used my booooat then the A70 toldme B100C03 code how to fix it do I need to claim the warranty. In the text to be filtered, friennd, booooat, A70, and B100C03 are very short and have no meaning in natural language. These characters are the remaining characters in the text to be filtered except for the commonly searched characters and serve as initial keywords.
[0068] S230: Obtain target keywords from the initial keywords based on the reference text library.
[0069] In this embodiment, the initial keywords are further extracted for a second time in combination with a reference text library corresponding to the text to be detected to obtain target keywords as the keywords required for the question-answering task scenario.
[0070] The specific implementation method of S230 includes but is not limited to the following method: determining the number of times the initial keyword appears in the reference text library; obtaining keywords whose number of appearances is within a preset number interval from the initial keywords as target keywords.
[0071] Specifically, the electronic device searches for keywords in all texts in the reference text library and counts the number of times the initial keyword appears in all texts in the reference text library. If the number of times the initial keyword appears is within a preset number range, the initial keyword is considered to be a keyword required for the question and answer task scenario and is used as a target keyword. Otherwise, if the number of times the initial keyword appears is not within the preset number range, the initial keyword is considered not to be a keyword required for the question and answer task scenario and is deleted.
[0072] The minimum value of the preset number interval is 0; the maximum value of the preset number interval is determined according to the number of times the predefined keyword appears in the reference text library and the number of times the predefined non-keyword appears in the reference text library. Specifically, the maximum value of the preset number interval is between the number of times the predefined keyword appears in the reference text library and the number of times the predefined non-keyword appears in the reference text library.
[0073] The predefined keywords and predefined non-keywords are words pre-selected from a reference text library in order to determine a preset frequency interval.
[0074] Specifically, the method for determining the preset number interval is: obtain multiple groups of pending question texts and reference text libraries for testing, continuously increase the K value from 0 until the number of times all predefined keywords in the pending question text appear is less than K, record K as the minimum value K1 of the preset number interval, continue to increase the K value until the number of times a certain predefined non-keyword in the pending question text appears is equal to K, record K as the maximum value K2 of the preset number interval, then the preset number interval is (0, Kn), where Kn is greater than K1 and less than K2.
[0075] As an example, assume that the question-answering task scenario is the after-sales service of a marine propeller, and the reference text library is a collection of product information for marine propellers. In the reference text library, assume that there are 2 predefined keywords, both of which are fault codes, and the number of times they appear in the reference text library is 1 and 2 respectively; there are 3 predefined non-keywords, and the 3 keywords are product parameters (such as rated voltage, rated current, etc.), and the number of times they appear in the reference text library is 7, 5, and 10 respectively. Then, when determining the preset number interval, first set K equal to 0, and then continue to increase the K value until the number of occurrences of the two predefined keywords is less than K. In this example, the largest number of occurrences of the two predefined keywords is 2 times, and K should be 3 at this time. Then, continue to increase the K value until the number of occurrences of a predefined non-keyword is equal to K. In this example, the smallest number of occurrences of the three predefined non-keywords is 5 times, and K should be 5 at this time. Then, it can be determined that the preset number interval should be (0, 5).
[0076] For further exemplary explanation, the initial keywords include: friennd, booooat, A70, B100C03, the preset number interval is (0, 60), friennd and booooat are error characters, the number of times they appear in the reference text library is 0, A70 is the model number, the number of times it appears in the reference text library is 60, B100C03 is the fault code, the number of times it appears in the reference text library is 2, then the target keyword in the problem text to be processed is B100C03.
[0077] In this way, this keyword extraction method removes common characters and predefined non-keywords from the text to be screened, thereby retaining text that is very short and meaningless in natural language, improving the accuracy of keyword extraction in question-and-answer task scenarios.
[0078] In order to further improve the accuracy of keyword extraction, before executing S230, the method also includes: verifying the initial keywords to obtain verified keywords; accordingly, based on the reference text library, obtaining target keywords from the initial keywords, including: extracting target keywords from the verified keywords according to the reference text library.
[0079] In some embodiments, the initial keyword is verified to obtain the verified keyword. The specific implementation method includes: extracting predefined error-prone characters from the initial keyword; replacing the error-prone characters with predefined correction characters to obtain the verified keyword, wherein the predefined correction characters are characters that are similar in shape to the error-prone characters.
[0080] It is understandable that in many cases, users may misread keywords, causing the problem text to be processed to contain predefined easily-mistaken characters, and further causing the initial keywords to contain predefined easily-mistaken characters. The electronic device then needs to detect one by one whether the initial keywords contain predefined easily-mistaken characters. If so, the electronic device obtains characters that are similar in shape to the predefined easily-mistaken characters as predefined correction characters, and replaces the predefined easily-mistaken characters with the predefined correction characters to obtain the verified keywords.
[0081] For example, the electronic device obtains a question text to be processed input by a user. Because the user mistakenly inputs "1" as "I" and mistakenly inputs "0" as "O", the initial keyword contained in the question text to be processed is BIOOC03. The predefined error-prone characters extracted by the electronic device from the initial keyword include "I" and "O", and the predefined correction character corresponding to the predefined error-prone character "I" is "1", and the predefined correction character corresponding to the predefined error-prone character "O" is "0". The electronic device replaces the predefined error-prone character "I" in the initial keyword "BIOOC03" with the predefined correction character "1", and replaces the predefined correction character corresponding to the predefined error-prone character "O" with "0", and obtains the target keyword "B100C03".
[0082] In this way, the predefined error-prone characters in the initial keywords are replaced with predefined correction characters with similar characters, thereby obtaining the verified keywords, so as to improve the extraction accuracy of the target keywords based on the verified keywords.
[0083] In other embodiments, the initial keywords are verified to obtain verified keywords, and the specific implementation method includes: calculating the similarity between the initial keywords and the reference keywords of each text in the reference text library; and selecting the keyword with the highest similarity from the reference keywords of each text in the reference text library as the verified keyword.
[0084] It is understandable that in many cases, the user may input incorrect keywords into the electronic device, resulting in incorrect characters in the initial keywords extracted from the problem text to be processed. The electronic device then needs to calculate the similarity between the initial keywords and the reference keywords of each text in the reference text library based on each character in the initial keywords and each character in the reference keywords, and select the keyword with the highest similarity from the reference keywords of each text in the reference text library as the verified keyword.
[0085] For example, the electronic device obtains a problem text to be processed input by a user. Because the user mistakenly inputs "B100C03" as "B100C04", the initial keyword contained in the problem text to be processed is B100C04. The electronic device needs to calculate the similarity between the initial keyword "B100C04" and the reference keywords of each text in the reference text library based on each character in the initial keyword "B100C04" and each character in the reference keywords (including "B100C03" and other fault codes), and select the keyword with the highest similarity from the reference keywords of each text in the reference text library (including "B100C03" and other fault codes) as the verified keyword "B100C03".
[0086] In this way, the initial keywords are verified by calculating the similarity between the initial keywords and the reference keywords of each text in the reference text library, thereby obtaining verified keywords, so as to improve the extraction accuracy of the target keywords based on the verified keywords.
[0087] Therefore, based on the different error situations of keywords, adopting appropriate correction methods for verification is conducive to accurately extracting target keywords.
[0088] In some cases, while outputting the target answer text, the electronic device can also output prompt information to remind the user whether they have read or entered the wrong characters. For example, it can output a text or voice prompt such as "No information related to fault code B100C04 was found. Please confirm whether the fault code is accurate. Here is information related to fault code B100C03. Please evaluate whether it is the information you need." In this way, a reminder can be given when the user has indeed entered the wrong characters but the user himself is not aware of it, so that the user can further enter the correct characters to obtain truly valuable information; at the same time, it can also avoid leaving a bad impression on the user that the answer is irrelevant, resulting in a decrease in the user's recognition of the product.
[0089] It should be noted that when the target keyword extracted without verification can directly match the second answer text in the reference text library, the target keyword can be considered to be an accurate target keyword, and the second answer text is an answer text with reference value. At this time, there is no need to perform a verification action. However, when the target keyword extracted without verification fails to match the second answer text in the reference text library, you can try to verify the initial keyword to obtain the verified keyword. Subsequently, the target keyword is extracted from the verified keyword, thereby increasing the probability of successful matching between the keyword and the text.
[0090] In summary, this keyword extraction method extracts characters such as letters, numbers, and spaces from the text. At the same time, it combines the common character table and the reference text library to eliminate common characters in specific task scenarios to achieve accurate extraction of target keywords. This is especially suitable for scenarios where there are words in the question text that do not have clear meanings in natural language. In this way, the accuracy of keyword extraction is improved, which is conducive to improving the task execution effect of question-answering task scenarios.
[0091] The present disclosure also provides a question-answering device for implementing the above-mentioned question-answering method. Figure 3 In the embodiment of the present disclosure, the question-answering device may be an electronic device or a server. The electronic device may include a tablet computer, a desktop computer, a laptop computer, or other devices with communication functions, or may include a virtual machine or a device simulated by a simulator. The server may be a cloud server or a server cluster.
[0092] Figure 3 A structural schematic diagram of a question-and-answer device provided in an embodiment of the present disclosure is shown.
[0093] like Figure 3 As shown, the question-answering device 300 may include: The first acquisition module 310 is used to acquire the question text to be processed; A first determination module 320 is used to determine a question vector corresponding to the question text to be processed, and determine a first answer text corresponding to the question text to be processed based on the question vector and a semantic vector of a text in a reference text library corresponding to the question text to be processed; A second acquisition module 330 is used to acquire a target keyword from the question text to be processed, and acquire a second answer text containing the target keyword from the reference text library; The second determination module 340 is used to determine the target answer text corresponding to the question text to be processed based on the first answer text and the second answer text.
[0094] A question-answering device of an embodiment of the present disclosure first determines the first answer text corresponding to the question text to be processed based on the question vector corresponding to the question text to be processed and the semantic vector of the text in the reference text library corresponding to the question text to be processed, and at the same time, obtains the target keyword from the question text to be processed, and obtains the second answer text containing the target keyword from the reference text library, and then combines the two types of answer texts to determine the target answer text corresponding to the question text to be processed. In this way, the semantic vector in the question text and the keywords in the question text are taken into consideration, and the final answer text corresponding to the question text is jointly determined, thereby improving the accuracy of the question answer.
[0095] In some embodiments of the present disclosure, the first determining module 320 is specifically configured to: A pre-generated semantic vector model is used to perform vector extraction on the question text to be processed, so as to obtain a question vector corresponding to the question text to be processed.
[0096] In some embodiments of the present disclosure, the first determination module 320 includes: A calculation unit, used to calculate the similarity between the question vector and the semantic vector of the text in the reference text library; The first acquisition unit is used to acquire the text corresponding to the semantic vector with the highest similarity from the reference text library as the first answer text corresponding to the question text to be processed.
[0097] In some embodiments of the present disclosure, the second acquisition module 330 includes: A first extraction unit is used to extract preset characters from the problem text to be processed to obtain a text to be screened, wherein the preset characters include one or more of letters, numbers, and spaces; A second extraction unit, configured to extract initial keywords from the text to be screened according to a common character table; The second acquisition unit is configured to acquire the target keyword from the initial keyword based on the reference text library.
[0098] In some embodiments of the present disclosure, the second extraction unit is specifically used to: Deleting the search common characters belonging to the common character table from the text to be screened; The remaining characters in the text to be screened except the common search characters are used as the initial keywords.
[0099] In some embodiments of the present disclosure, the second acquisition unit is specifically configured to: Determining the number of times the initial keyword appears in the reference text library; A keyword whose number of occurrences is within a preset number interval is obtained from the initial keywords as the target keyword.
[0100] In some embodiments of the present disclosure, the minimum value of the preset number interval is 0; The maximum value of the preset number interval is determined according to the number of times the predefined keyword appears in the reference text library and the number of times the predefined non-keyword appears in the reference text library.
[0101] In some embodiments of the present disclosure, the maximum value of the preset number interval is between the number of times the predefined keyword appears in the reference text library and the number of times the predefined non-keyword appears in the reference text library.
[0102] In some embodiments of the present disclosure, the second acquisition module 330 further includes: A verification unit, used to verify the initial keyword to obtain a verified keyword; Accordingly, the second acquisition unit is specifically used for: The target keyword is extracted from the verified keywords according to the reference text library.
[0103] In some embodiments of the present disclosure, the verification unit is specifically used to: Extracting predefined error-prone characters from the initial keywords; The error-prone character is replaced with a predefined correction character to obtain the verified keyword, wherein the predefined correction character is a character with a shape similar to that of the error-prone character.
[0104] In some embodiments of the present disclosure, the verification unit is specifically used to: Calculate the similarity between the initial keyword and the reference keyword of each text in the reference text library; A keyword with the highest similarity is selected from the reference keywords of each text in the reference text library as the verified keyword.
[0105] In some embodiments of the present disclosure, the second determination module 340 includes: an integration unit, used for integrating the first answer text and the second answer text to form an answer text sequence; The answer text determination unit is used to process the answer text sequence using a pre-acquired large language model to obtain the target answer text.
[0106] It should be noted that Figure 3 The question-answering device 300 shown can execute Figure 1~Figure 2 The various steps in the method embodiment shown in the figure are implemented Figure 1~Figure 2 The various processes and effects in the method embodiment shown are not described in detail here.
[0107] Figure 4 A schematic structural diagram of an electronic device provided by an embodiment of the present disclosure is shown.
[0108] like Figure 4 As shown, the electronic device may include a processor 401 and a memory 402 storing computer program instructions.
[0109] Specifically, the processor 401 may include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiments of the present application.
[0110] The memory 402 may include a large capacity memory for information or instructions. By way of example and not limitation, the memory 402 may include a hard disk drive (HDD), a floppy disk drive, a flash memory, an optical disk, a magneto-optical disk, a tape, or a universal serial bus (USB) drive or a combination of two or more of these. Where appropriate, the memory 402 may include a removable or non-removable (or fixed) medium. Where appropriate, the memory 402 may be inside or outside the integrated gateway device. In a specific embodiment, the memory 402 is a non-volatile solid-state memory. In a specific embodiment, the memory 402 includes a read-only memory (ROM). Where appropriate, the ROM may be a mask-programmed ROM, a programmable ROM (PROM), an erasable PROM (EPROM), an electrically erasable PROM (Electrically Erasable Programmable ROM, EEPROM), an electrically rewritable ROM (EAROM) or a flash memory, or a combination of two or more of these.
[0111] The processor 401 reads and executes the computer program instructions stored in the memory 402 to perform the steps of the question-answering method provided in the embodiment of the present disclosure.
[0112] In one example, the electronic device may further include a transceiver 403 and a bus 404. Figure 4 As shown, the processor 401, the memory 402 and the transceiver 403 are connected via a bus 404 and communicate with each other.
[0113] The bus 404 includes hardware, software or both. For example, but not limitation, the bus may include an Accelerated Graphics Port (AGP) or other graphics bus, an Extended Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), a Hyper Transport (HT) interconnect, an Industrial Standard Architecture (ISA) bus, an InfiniBand interconnect, a Low Pin Count (LPC) bus, a Memory bus, a MicroChannel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local Bus (VLB) bus, or other suitable buses or a combination of two or more of these. Where appropriate, the bus 404 may include one or more buses. Although embodiments of the present application describe and illustrate a particular bus, the present application contemplates any suitable bus or interconnect.
[0114] The following is an embodiment of a computer-readable storage medium provided in an embodiment of the present disclosure. The computer-readable storage medium and the question-and-answer method of the above-mentioned embodiments belong to the same inventive concept. For details not described in detail in the embodiment of the computer-readable storage medium, please refer to the embodiment of the above-mentioned question-and-answer method.
[0115] This embodiment provides a storage medium containing computer executable instructions. When the computer executable instructions are executed by a computer processor, they are used to perform a question-answering method. The method includes: Get the text of the question to be processed; Determine a question vector corresponding to the question text to be processed, and determine a first answer text corresponding to the question text to be processed based on the question vector and a semantic vector of a text in a reference text library corresponding to the question text to be processed; Acquire a target keyword from the question text to be processed, and acquire a second answer text containing the target keyword from the reference text library; Based on the first answer text and the second answer text, a target answer text corresponding to the question text to be processed is determined.
[0116] Of course, the storage medium containing computer executable instructions provided by the embodiment of the present disclosure, whose computer executable instructions are not limited to the above method operations, can also execute related operations in the question-and-answer method provided by any embodiment of the present disclosure.
[0117] Through the above description of the implementation methods, the technical personnel in the relevant field can clearly understand that the present disclosure can be implemented with the help of software and necessary general hardware, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present disclosure can essentially be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as a computer floppy disk, read-only memory (ROM), random access memory (RAM), flash memory (FLASH), hard disk or optical disk, etc., including a number of instructions to enable a computer cloud platform (which can be a personal computer, server, or network cloud platform, etc.) to execute the question-answering method provided by each embodiment of the present disclosure.
[0118] Note that the above are only preferred embodiments of the present disclosure and the technical principles used. Those skilled in the art will understand that the present disclosure is not limited to the specific embodiments herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present disclosure. Therefore, although the present disclosure is described in more detail through the above embodiments, the present disclosure is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present disclosure, and the scope of the present disclosure is determined by the scope of the appended claims.
Claims
1. A question-answering method, characterized in that: include: Get the text of the question to be processed; Determine a question vector corresponding to the question text to be processed, and determine a first answer text corresponding to the question text to be processed based on the question vector and a semantic vector of a text in a reference text library corresponding to the question text to be processed; Acquire a target keyword from the question text to be processed, and acquire a second answer text containing the target keyword from the reference text library; Based on the first answer text and the second answer text, a target answer text corresponding to the question text to be processed is determined.
2. The method according to claim 1, characterized in that The step of determining the question vector corresponding to the question text to be processed includes: A pre-generated semantic vector model is used to perform vector extraction on the question text to be processed, so as to obtain a question vector corresponding to the question text to be processed.
3. The method according to claim 1, characterized in that: The determining, based on the question vector and the semantic vector of the text in the reference text library corresponding to the question text to be processed, the first answer text corresponding to the question text to be processed comprises: Calculating the similarity between the question vector and the semantic vector of the text in the reference text library; The text corresponding to the semantic vector with the highest similarity is obtained from the reference text library as the first answer text corresponding to the question text to be processed.
4. The method according to claim 1, characterized in that: The step of obtaining target keywords from the question text to be processed includes: Extracting preset characters from the problem text to be processed to obtain the text to be screened, wherein the preset characters include one or more of letters, numbers, and spaces; Extracting initial keywords from the text to be screened according to a common character table; Based on the reference text library, the target keyword is obtained from the initial keywords.
5. The method according to claim 4, characterized in that The step of extracting initial keywords from the text to be screened according to the common character table includes: Deleting the search common characters belonging to the common character table from the text to be screened; The remaining characters in the text to be screened except the common search characters are used as the initial keywords.
6. The method according to claim 4, characterized in that The acquiring the target keyword from the initial keyword based on the reference text library includes: Determining the number of times the initial keyword appears in the reference text library; A keyword whose number of occurrences is within a preset number interval is obtained from the initial keywords as the target keyword.
7. The method according to claim 6, characterized in that The minimum value of the preset number interval is 0; The maximum value of the preset number interval is determined according to the number of times the predefined keyword appears in the reference text library and the number of times the predefined non-keyword appears in the reference text library.
8. The method according to claim 7, characterized in that The maximum value of the preset number interval is between the number of times the predefined keyword appears in the reference text library and the number of times the predefined non-keyword appears in the reference text library.
9. The method according to claim 4, characterized in that Before acquiring the target keyword from the initial keyword based on the reference text library, the method further includes: Verifying the initial keywords to obtain verified keywords; Accordingly, the step of acquiring the target keyword from the initial keyword based on the reference text library includes: The target keyword is extracted from the verified keywords according to the reference text library.
10. The method according to claim 9, characterized in that The verifying the initial keywords to obtain verified keywords includes: Extracting predefined error-prone characters from the initial keywords; The error-prone character is replaced with a predefined correction character to obtain the verified keyword, wherein the predefined correction character is a character with a shape similar to that of the error-prone character.
11. The method according to claim 9, characterized in that The verifying the initial keywords to obtain verified keywords includes: Calculate the similarity between the initial keyword and the reference keyword of each text in the reference text library; A keyword with the highest similarity is selected from the reference keywords of each text in the reference text library as the verified keyword.
12. The method according to claim 1, characterized in that The step of determining a target answer text corresponding to the question text to be processed based on the first answer text and the second answer text includes: Integrating the first answer text and the second answer text to form an answer text sequence; The answer text sequence is processed using a pre-acquired large language model to obtain the target answer text.
13. A question-answering device, characterized in that: include: The first acquisition module is used to acquire the question text to be processed; A first determination module is used to determine a question vector corresponding to the question text to be processed, and determine a first answer text corresponding to the question text to be processed based on the question vector and a semantic vector of a text in a reference text library corresponding to the question text to be processed; A second acquisition module is used to acquire target keywords from the question text to be processed, and acquire a second answer text containing the target keywords from the reference text library; The second determination module is used to determine the target answer text corresponding to the question text to be processed based on the first answer text and the second answer text.
14. An electronic device, characterized in that: include: processor; A memory for storing executable instructions; The processor is used to read the executable instructions from the memory and execute the executable instructions to implement the method described in any one of claims 1 to 12.
15. A computer-readable storage medium having a computer program stored thereon, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the processor implements the method according to any one of claims 1 to 12.
Citation Information
Patent Citations
Hidden keyword extraction method, terminal equipment and storage medium
CN114372461A
User question intelligent answering method, financial system and storage medium
CN116483971A
RAG knowledge question-answering method and device based on fusion vector and keyword retrieval
CN117951274A