A database indexing method, device and medium based on user question and answer
The database indexing method optimizes SQL statements through keyword extraction and rewriting to address inefficiencies in processing user questions with many conditions, improving processing speed and reducing computational load.
Patent Information
- Application Number
- CN202411389134.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-08
- Publication Date
- 2024-12-13
- Estimated Expiration
- 2044-10-08
AI Technical Summary
Current database indexing methods using SQL language are inefficient when handling user questions with many index conditions, leading to prolonged processing times and increased computing power consumption.
A database indexing method that splits user questions into keywords, uses a question-answering language model to generate concise SQL statements, and optimizes index call parameters by rewriting and abbreviating SQL language to reduce processing volume and speed up data retrieval.
The method improves database indexing efficiency by shortening SQL statement generation time and reducing index processing amount, enhancing user experience and computational efficiency.
Smart Images

Figure CN118885501B_ABST
Abstract
Description
Background Art
[0002] The current user question-and-answer method parses the questions raised by the user, finds the corresponding information data from the database based on the index terms obtained from the parsing, and finally generates a reply statement and returns it to the user. Since most databases currently use the SQL language to index data, and the processing volume and processing speed of the data index are related to the number of characters in the index statement, the larger the number of characters in the SQL language index statement, the larger the processing volume when indexing data, and correspondingly, the slower the processing speed. Therefore, when the user's question includes too many index conditions, the time to generate the corresponding reply statement will be extended, which affects the user experience and also takes up a lot of computing power. Summary of the invention
[0003] In view of the above technical problems, the technical solution adopted by the present invention is:
[0004] According to one aspect of the present application, a database indexing method based on user questions and answers is provided, which is applied to a database indexing system, wherein the database indexing system is connected to a database, and a plurality of user information data is stored in the database;
[0005] The database indexing method based on user questions and answers comprises the following steps:
[0006] Step S100: In response to receiving a user question sentence, split the user question sentence to obtain a number of user question keywords included in the user question sentence;
[0007] Step S200: inputting several user question keywords into the question-answering language model to obtain a SQL question-answering statement output by the question-answering language model; the question-answering language model is obtained by training several historical question-answering statements;
[0008] Step S300, parse the SQL question-answer statement to obtain index call parameters;
[0009] Step S400: determining target user data from a plurality of user information data according to the index calling parameter and the user identifier corresponding to the user question statement;
[0010] Step S500: Integrate the target user data to obtain the user response statement and output it.
[0011] In an exemplary embodiment of the present application, step S100 includes:
[0012] Step S110, performing multiple rounds of rewriting processing on the user's question sentence to obtain a corresponding target question sentence;
[0013] Step S120: semantically analyze the target question sentence to obtain a semantic identifier corresponding to each target question word included in the target question sentence;
[0014] Step S130: traverse each target question word, and if the semantic identifier corresponding to the target question word is a preset key semantic identifier, determine the target question word as the user's question keyword.
[0015] In an exemplary embodiment of the present application, the question-answering language model is obtained by the following steps:
[0016] Step S201, obtaining a number of historical question and answer sentences;
[0017] Step S202: Split each historical question and answer sentence to obtain a number of historical question and answer words included in each historical question and answer sentence, and obtain a historical question and answer word list set A=(A1, A2, ..., A i ,...,A n );A i =(A i1 ,A i2 ,...,A ie ,...,A if(i) ), where i=1,2,...,n; n is the number of historical question-answering sentences; A i is the list of historical question-answer words corresponding to the i-th historical question-answer sentence; e=1,2,...,f(i); f(i) is the number of historical question-answer words obtained by splitting the i-th historical question-answer sentence; A ie is the e-th historical question and answer word obtained by splitting the i-th historical question and answer sentence;
[0018] Step S203: performing deduplication processing on a number of historical question and answer words in the historical question and answer word list set A to obtain a number of target historical question and answer words;
[0019] Step S204: convert each target historical question and answer word into SQL language to obtain the SQL language question and answer word corresponding to each target historical question and answer word;
[0020] Step S205: Determine a plurality of target SQL language question and answer words from the plurality of SQL language question and answer words according to the character length of each SQL language question and answer word; the target SQL language question and answer word is a SQL language question and answer word that meets a preset character length rule;
[0021] Step S206: rewrite each target SQL language question and answer word according to a preset character abbreviation rule to obtain a rewritten SQL language question and answer word corresponding to each target SQL language question and answer word;
[0022] Step S207: Determine a mapping relationship table according to the information entropy of each target SQL language question and answer word and the information entropy of the rewritten SQL language question and answer word corresponding to the target SQL language question and answer word; the mapping relationship table stores the mapping relationship between the target SQL language question and answer word and its corresponding rewritten SQL language question and answer word that meets the preset information entropy difference rule;
[0023] Step S208: input the mapping relationship table into a preset initial language model for training to obtain a question-answering language model.
[0024] In an exemplary embodiment of the present application, step S205 includes:
[0025] Step S2051: Get the character length of each SQL language question and answer word, and obtain the first character length list B=(B1, B2, ..., B g ,...,B h ), where g = 1, 2, ..., h; h is the number of SQL language question and answer words; B g is the character length of the g-th SQL language question and answer word;
[0026] Step S2052, traverse the first character length list B, if B g ≥B0, the g-th SQL language question and answer word is determined as the target SQL language question and answer word to obtain a number of target SQL language question and answer words; wherein B0 is a preset character length threshold.
[0027] In an exemplary embodiment of the present application, step S207 includes:
[0028] Step S2071: Obtain the information entropy of each target SQL language question and answer word, and obtain a first information entropy list C=(C1, C2, ..., C a ,...,C b ), where a=1,2,...,b; b is the number of question-answer words in the target SQL language; C a is the information entropy of the a-th target SQL language question and answer word;
[0029] Step S2072: Obtain the information entropy of each rewritten SQL language question and answer word to obtain a second information entropy list D=(D1, D2, ..., D a ,...,D b ), where D a is the information entropy of the rewritten SQL language question and answer word obtained after rewriting the a-th target SQL language question and answer word;
[0030] Step S2073, traverse the first information entropy list C and the second information entropy list D, if |D a -Ca |≤d, then the mapping relationship between the ath target SQL language question and answer word and its corresponding rewritten SQL language question and answer word is stored in a preset mapping relationship table; where d is the preset information entropy difference threshold.
[0031] In an exemplary embodiment of the present application, after receiving several user question keywords, the question-answering language model performs the following steps:
[0032] Step S210: Perform SQL language conversion on each user's question keyword to obtain the SQL language keyword corresponding to each user's question keyword, and determine the SQL language keyword list E=(E1, E2, ..., E c ,...,E j ), where c=1,2,...,j; j is the number of keywords asked by the user; E c The SQL language keywords corresponding to the keywords asked by the cth user;
[0033] Step S220, traverse each SQL language keyword in the SQL language keyword list E in turn, if E c There is a mapping relationship in the mapping relationship table. c Rewrite it as c Rewrite SQL language question and answer words with mapping relationship;
[0034] Step S230: E1, E2, ..., E c ,...,E j Connect the identifiers one by one to get the SQL question and answer statement.
[0035] In an exemplary embodiment of the present application, step S300 includes:
[0036] Step S310, obtaining the query condition identifier included in the SQL question and answer statement;
[0037] Step S320: determine the query condition corresponding to the query condition identifier as an index calling parameter.
[0038] In an exemplary embodiment of the present application, step S400 includes:
[0039] Step S410: If the index call parameter includes an identity query identifier, execute steps S420 to S440; otherwise, execute step S450;
[0040] Step S420: Obtain the user ID corresponding to the user's question statement;
[0041] Step S430: determine the user information data having the same user ID as the user identification corresponding to the user's question statement as key user data;
[0042] Step S440: determining the key user data corresponding to the index calling parameter as the target user data;
[0043] Step S450: determine the user information data corresponding to the index calling parameter as the target user data.
[0044] According to one aspect of the present application, a non-transitory computer-readable storage medium is provided, in which at least one instruction or at least one program is stored, and the at least one instruction or the at least one program is loaded and executed by a processor to implement the aforementioned user question-and-answer based database indexing method.
[0045] According to one aspect of the present application, an electronic device is provided, including a processor and the aforementioned non-transitory computer-readable storage medium.
[0046] The present invention has at least the following beneficial effects:
[0047] The user question-answering-based database indexing method of the present invention, after receiving a user question statement, splits the user question statement to obtain a number of user question keywords, inputs the number of user question keywords into a question-answering language model to obtain a SQL question-answering statement, and parses the SQL question-answering statement to obtain an index call parameter, and determines target user data from a number of user information data according to the index call parameter and the user identifier corresponding to the user question statement, the target user data is the information data retrieved for the user question statement, and finally integrates the target user data to obtain a user reply statement and outputs it. By performing SQL language conversion on the user question statement, and correspondingly rewriting the converted SQL language question-answering words according to the rewriting rules, the generated SQL question-answering statement is made more concise, the generation time of the SQL question-answering statement is shortened, and the index processing amount of the information data is reduced, thereby improving the database indexing efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0049] Figure 1 A flowchart of a database indexing method based on user questions and answers provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0050] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0051] A database indexing method based on user questions and answers is applied to a database indexing system. The database indexing system is connected to a database, and a number of user information data are stored in the database.
[0052] like Figure 1 As shown, the database indexing method based on user questions and answers described in this application includes the following steps:
[0053] Step S100: In response to receiving a user question sentence, split the user question sentence to obtain a number of user question keywords included in the user question sentence;
[0054] User question statements are statements written in natural language proposed by users. Since the data stored in the database is in computer language, if you want to index it in the database, you need to convert the natural language. Currently, most of the data in the database is stored in SQL language. Therefore, it is necessary to convert the user question statements in natural language into SQL language statements. Before language conversion, you need to split the user question statements to obtain several user question keywords included in the user question statements. User question keywords are keywords in user question statements that can represent semantic information.
[0055] Further, step S100 includes steps S110 to S130:
[0056] Step S110, performing multiple rounds of rewriting processing on the user's question sentence to obtain a corresponding target question sentence;
[0057] Multiple rounds of rewriting can adopt existing processing methods. Multiple rounds of rewriting are used to semantically supplement user question sentences. If the user question sentence is too simple, such as lacking a subject, if the user question sentence is directly converted into SQL language, the converted SQL statement will also lack corresponding keywords, which will cause abnormalities in subsequent indexes. Therefore, the user question sentence is first rewritten for multiple rounds, and the user question sentence is semantically expanded by connecting the upper and lower sentences of the user's question, and then SQL language conversion is performed, which can improve the accuracy of the user's reply.
[0058] Step S120: semantically analyze the target question sentence to obtain a semantic identifier corresponding to each target question word included in the target question sentence;
[0059] After obtaining the target question sentence, a semantic analysis is performed on the target question sentence, that is, the target question sentence is split into keywords to obtain the target question words included in the target question sentence, wherein the semantic analysis and keyword splitting can adopt the existing analysis methods, and the target question words correspond to semantic identifiers, and the semantic identifiers indicate the semantic type of the corresponding target question words, such as whether the target question word is the subject, predicate, or object of the target question sentence. Through the semantic identifier, it can be determined whether the target question word plays a key role in information indexing.
[0060] Step S130: traverse each target question word, and if the semantic identifier corresponding to the target question word is a preset key semantic identifier, determine the target question word as the user's question keyword.
[0061] The preset key semantic identifier is the semantic identifier of the indispensable semantic type when indexing information. The key semantic identifier can be obtained by performing keyword splitting statistics on several historical natural languages.
[0062] Step S200: input a number of user question keywords into the question-answering language model to obtain a SQL question-answering statement output by the question-answering language model;
[0063] The question-answering language model is obtained by training several historical question-answering sentences, and is used to convert several user question keywords into SQL language and integrate them into SQL question-answering sentences.
[0064] Step S300, parse the SQL question-answer statement to obtain index call parameters;
[0065] The index call parameter is an index condition for indexing a number of user information data in the database.
[0066] Further, step S300 includes step S310-step S320:
[0067] Step S310, obtaining the query condition identifier included in the SQL question and answer statement;
[0068] The query condition identifier corresponds to a query condition, which is an index condition of the user information data.
[0069] Step S320: determine the query condition corresponding to the query condition identifier as an index calling parameter.
[0070] Step S400: determining target user data from a plurality of user information data according to the index calling parameter and the user identifier corresponding to the user question statement;
[0071] The user identification can be determined based on the user account that inputs the user question statement.
[0072] Further, step S400 includes steps S410 to S450:
[0073] Step S410: If the index call parameter includes an identity query identifier, execute steps S420 to S440; otherwise, execute step S450;
[0074] If the index call parameter includes an identity query identifier, it means that the query condition corresponding to the index call parameter is an information query based on the user's personal information. For example, if the user's question statement is "What time is my flight taking off tomorrow?", since the user's question statement is a query on the user's personal information, the index call parameter generated by the user's question statement will include the identity query identifier. If the user's question statement is "What flights are taking off from City A tomorrow?", the user's question statement is a query on public information, and therefore the index call parameter generated by the user's question statement will not include the identity query identifier.
[0075] Step S420: Obtain the user ID corresponding to the user's question statement;
[0076] Step S430: determine the user information data having the same user ID as the user identification corresponding to the user's question statement as key user data;
[0077] Step S440: determining the key user data corresponding to the index calling parameter as the target user data;
[0078] Step S450: determine the user information data corresponding to the index calling parameter as the target user data.
[0079] Step S500: Integrate the target user data to obtain the user response statement and output it.
[0080] The target user data is the user information data obtained by indexing according to the index call parameter, and the target user data is integrated, and then the integrated target user data is converted into natural language according to the user question sentence. Among them, the natural language conversion method and the method of generating the user answer sentence according to the user question sentence and the index result can adopt the existing method.
[0081] The question-answering language model is obtained through steps S201 to S208:
[0082] Step S201, obtaining a number of historical question and answer sentences;
[0083] Historical question and answer sentences are user question sentences written in natural language during a historical period.
[0084] Step S202: Split each historical question and answer sentence to obtain a number of historical question and answer words included in each historical question and answer sentence, and obtain a historical question and answer word list set A=(A1, A2, ..., A i ,...,A n );A i =(A i1 ,A i2 ,...,A ie ,...,A if(i) ), where i=1,2,...,n; n is the number of historical question-answering sentences; A i is the list of historical question-answer words corresponding to the i-th historical question-answer sentence; e=1,2,...,f(i); f(i) is the number of historical question-answer words obtained by splitting the i-th historical question-answer sentence; A ie is the e-th historical question and answer word obtained by splitting the i-th historical question and answer sentence;
[0085] Semantic analysis is performed on each historical question and answer sentence to determine a number of historical question and answer words that can express semantics in each historical question and answer sentence. Existing semantic analysis methods are used for semantic analysis of natural sentences.
[0086] Step S203: performing deduplication processing on a number of historical question and answer words in the historical question and answer word list set A to obtain a number of target historical question and answer words;
[0087] De-duplicate several historical question and answer words to avoid multiple SQL language conversions for the same historical question and answer word, which would waste data processing computing power.
[0088] Step S204: convert each target historical question and answer word into SQL language to obtain the SQL language question and answer word corresponding to each target historical question and answer word;
[0089] The method of semantically analyzing each historical question and answer sentence to obtain several historical question and answer words, and then converting each historical question and answer word into SQL, compared with the method of directly converting the historical question and answer sentence into SQL, does not need to convert the word segmentation with less semantics into SQL, thereby reducing the data processing amount of language conversion.
[0090] Step S205: determining a plurality of target SQL language question and answer words from a plurality of SQL language question and answer words according to the character length of each SQL language question and answer word;
[0091] The target SQL language question and answer word is a SQL language question and answer word that meets a preset character length rule.
[0092] When indexing information according to index conditions, the character length of the index conditions is directly proportional to the index time and the computing power occupied by the index. When indexing information, the longer the character length of the index conditions, the greater the computing power occupied by the index and the longer the index time. Therefore, the character length of the index conditions becomes a key factor in reducing the indexing time. After obtaining several SQL language question and answer words, it is necessary to verify the character length of each SQL language question and answer word, determine the SQL language question and answer word that meets the preset character length rule as the target SQL language question and answer word, and then rewrite the target SQL language question and answer word.
[0093] Further, step S205 includes step S2051-step S2052:
[0094] Step S2051: Get the character length of each SQL language question and answer word, and obtain the first character length list B=(B1, B2, ..., B g ,...,B h ), where g = 1, 2, ..., h; h is the number of SQL language question and answer words; B g is the character length of the g-th SQL language question and answer word;
[0095] Step S2052, traverse the first character length list B, if B g ≥B0, the g-th SQL language question and answer word is determined as the target SQL language question and answer word to obtain a number of target SQL language question and answer words; wherein B0 is a preset character length threshold.
[0096] If the character length of the SQL language question and answer word is too long, the generated index condition will affect the subsequent indexing speed. Therefore, the SQL language question and answer word is determined as the target SQL language question and answer word.
[0097] Step S206: rewrite each target SQL language question and answer word according to a preset character abbreviation rule to obtain a rewritten SQL language question and answer word corresponding to each target SQL language question and answer word;
[0098] The character abbreviation rule is a character shortening and rewriting rule defined by the user or preset by the system. By counting several historical characters, the characters are shortened without losing the amount of information, so as to achieve the purpose of improving data processing efficiency.
[0099] Step S207: Determine a mapping relationship table according to the information entropy of each target SQL language question and answer word and the information entropy of the rewritten SQL language question and answer word corresponding to the target SQL language question and answer word;
[0100] The mapping relationship table stores the mapping relationship between the target SQL language question and answer words that meet the preset information entropy difference rules and their corresponding rewritten SQL language question and answer words.
[0101] Since the premise of shortening the characters of the SQL language question and answer words is not to lose too much information of the original words and sentences, so as not to reduce the accuracy of the index results, it is necessary to verify whether the information entropy difference between the target SQL language question and answer words and their corresponding rewritten SQL language question and answer words is too large. If the difference is within the specified range, it means that the rewritten SQL language question and answer words meet the information entropy difference rule, and the characters of the words and sentences are shortened without a large loss of information, thereby improving the indexing speed.
[0102] Further, step S207 includes step S2071-step S2073:
[0103] Step S2071: Obtain the information entropy of each target SQL language question and answer word, and obtain a first information entropy list C=(C1, C2, ..., C a ,...,C b ), where a=1,2,...,b; b is the number of question-answer words in the target SQL language; C a is the information entropy of the a-th target SQL language question and answer word;
[0104] Step S2072: Obtain the information entropy of each rewritten SQL language question and answer word to obtain a second information entropy list D=(D1, D2, ..., D a ,...,D b ), where D a is the information entropy of the rewritten SQL language question and answer word obtained after rewriting the a-th target SQL language question and answer word;
[0105] Step S2073, traverse the first information entropy list C and the second information entropy list D, if |D a -C a |≤d, then the mapping relationship between the ath target SQL language question and answer word and its corresponding rewritten SQL language question and answer word is stored in a preset mapping relationship table; where d is the preset information entropy difference threshold.
[0106] Step S208: input the mapping relationship table into a preset initial language model for training to obtain a question-answering language model.
[0107] In addition, after receiving several user question keywords, the question-answering language model executes steps S210 to S230:
[0108] Step S210: Perform SQL language conversion on each user's question keyword to obtain the SQL language keyword corresponding to each user's question keyword, and determine the SQL language keyword list E=(E1, E2, ..., E c ,...,E j), where c=1,2,...,j; j is the number of keywords asked by the user; E c The SQL language keywords corresponding to the keywords asked by the cth user;
[0109] Step S220, traverse each SQL language keyword in the SQL language keyword list E in turn, if E c There is a mapping relationship in the mapping relationship table. c Rewrite it as c Rewrite SQL language question and answer words with mapping relationship;
[0110] Step S230: E1, E2, ..., E c ,...,E j Connect the identifiers one by one to get the SQL question and answer statement.
[0111] The user question-answering-based database indexing method of the present invention, after receiving a user question statement, splits the user question statement to obtain a number of user question keywords, inputs the number of user question keywords into a question-answering language model to obtain a SQL question-answering statement, and parses the SQL question-answering statement to obtain an index call parameter, and determines target user data from a number of user information data according to the index call parameter and the user identifier corresponding to the user question statement, the target user data is the information data retrieved for the user question statement, and finally integrates the target user data to obtain a user reply statement and outputs it. By performing SQL language conversion on the user question statement, and correspondingly rewriting the converted SQL language question-answering words according to the rewriting rules, the generated SQL question-answering statement is made more concise, the generation time of the SQL question-answering statement is shortened, and the index processing amount of the information data is reduced, thereby improving the database indexing efficiency.
[0112] An embodiment of the present invention further provides a computer program product, which includes program code. When the program product is run on an electronic device, the program code is used to enable the electronic device to execute the steps of the method according to various exemplary embodiments of the present invention described above in this specification.
[0113] In addition, although the steps of the method in the present disclosure are described in a specific order in the drawings, this does not require or imply that the steps must be performed in this specific order, or that all the steps shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps, etc.
[0114] Through the description of the above implementation, it is easy for those skilled in the art to understand that the example implementation described here can be implemented by software, or by combining software with necessary hardware. Therefore, the technical solution according to the implementation of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which can be a personal computer, a server, a mobile terminal, or a network device, etc.) to execute the method according to the implementation of the present disclosure.
[0115] In an exemplary embodiment of the present disclosure, an electronic device capable of implementing the above method is also provided.
[0116] It will be appreciated by those skilled in the art that various aspects of the present invention may be implemented as a system, method or program product. Therefore, various aspects of the present invention may be specifically implemented in the following forms, namely: a complete hardware implementation, a complete software implementation (including firmware, microcode, etc.), or a combination of hardware and software, which may be collectively referred to herein as a "circuit", "module" or "system".
[0117] The electronic device according to this embodiment of the present invention is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0118] The electronic device is presented in the form of a general-purpose computing device. The components of the electronic device may include, but are not limited to: the at least one processor mentioned above, the at least one storage device mentioned above, and a bus connecting different system components (including storage devices and processors).
[0119] The storage stores program codes, which can be executed by the processor, so that the processor executes the steps according to various exemplary embodiments of the present invention described in the above “Exemplary Method” section of this specification.
[0120] The memory may include readable media in the form of volatile memory, such as random access memory (RAM) and / or cache memory, and may further include read only memory (ROM).
[0121] The storage may also include a program / utility having a set (at least one) of program modules, such program modules including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.
[0122] The bus may represent one or more of several types of bus structures including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor, or a local bus using any of a variety of bus architectures.
[0123] The electronic device may also communicate with one or more external devices (e.g., keyboards, pointing devices, Bluetooth devices, etc.), one or more devices that enable a user to interact with the electronic device, and / or any device that enables the electronic device to communicate with one or more other computing devices (e.g., routers, modems, etc.). Such communication may be performed via an input / output (I / O) interface. Furthermore, the electronic device may also communicate with one or more networks (e.g., local area networks (LANs), wide area networks (WANs), and / or public networks, such as the Internet) via a network adapter.
[0124] Through the description of the above implementation, it is easy for those skilled in the art to understand that the example implementation described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the implementation of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, and includes a number of instructions to enable a computing device (which can be a personal computer, a server, a terminal device, or a network device, etc.) to execute the method according to the implementation of the present disclosure.
[0125] In an exemplary embodiment of the present disclosure, a computer-readable storage medium is also provided, on which a program product capable of implementing the above method of the present specification is stored. In some possible implementations, various aspects of the present invention can also be implemented in the form of a program product, which includes a program code, and when the program product is run on a terminal device, the program code is used to enable the terminal device to execute the steps according to various exemplary embodiments of the present invention described in the above "Exemplary Method" section of the present specification.
[0126] The program product may be any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination thereof. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof.
[0127] Computer readable signal media may include data signals propagated in baseband or as part of a carrier wave, in which readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Readable signal media may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0128] The program code embodied on the readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the foregoing.
[0129] Program code for performing the operations of the present invention may be written in any combination of one or more programming languages, including object-oriented programming languages such as Java, C++, etc., and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In the case of a remote computing device, the remote computing device may be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., via the Internet using an Internet service provider).
[0130] In addition, the above-mentioned figures are only schematic illustrations of the processes included in the method according to an exemplary embodiment of the present invention, and are not intended to be limiting. It is easy to understand that the processes shown in the above-mentioned figures do not indicate or limit the time sequence of these processes. In addition, it is also easy to understand that these processes can be performed synchronously or asynchronously, for example, in multiple modules.
[0131] It should be noted that, although several modules or units of the device for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into multiple modules or units to be embodied.
[0132] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed by the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.
Claims
1. A database indexing method based on user questions and answers, characterized in that: Applied to a database indexing system, the database indexing system is connected to a database, and the database stores a number of user information data; The method comprises the following steps: Step S100: In response to receiving a user question sentence, split the user question sentence to obtain a number of user question keywords included in the user question sentence; Step S200: inputting a number of the user's question keywords into a question-answering language model to obtain a SQL question-answering statement output by the question-answering language model; the question-answering language model is obtained by training a number of historical question-answering statements; Step S300, parsing the SQL question-answering statement to obtain index calling parameters; Step S400: determining target user data from the plurality of user information data according to the index calling parameter and the user identifier corresponding to the user question statement; Step S500: integrating the target user data to obtain and output a user reply statement; The question-answering language model is obtained by the following steps: Step S201, obtaining a number of historical question and answer sentences; Step S202: Split each of the historical question and answer sentences to obtain a number of historical question and answer words included in each of the historical question and answer sentences, and obtain a historical question and answer word list set A=(A1, A2, ..., A i ,...,A n );A i =(A i1 ,A i2 ,...,A ie ,...,A if(i) ), where i=1,2,...,n; n is the number of historical question-answering sentences; A i is the list of historical question-answering words corresponding to the i-th historical question-answering sentence; e=1,2,...,f(i); f(i) is the number of historical question-answering words obtained by splitting the i-th historical question-answering sentence; A ie is the e-th historical question and answer word obtained by splitting the i-th historical question and answer sentence; Step S203: performing deduplication processing on a number of historical question and answer words in the historical question and answer word list set A to obtain a number of target historical question and answer words; Step S204: performing SQL language conversion on each of the target historical question and answer words to obtain a SQL language question and answer word corresponding to each of the target historical question and answer words; Step S205: determining a plurality of target SQL language question and answer words from the plurality of SQL language question and answer words according to the character length of each of the SQL language question and answer words; the target SQL language question and answer words are SQL language question and answer words that meet the preset character length rule; Step S206: rewrite each of the target SQL language question and answer words according to a preset character abbreviation rule to obtain a rewritten SQL language question and answer word corresponding to each of the target SQL language question and answer words; Step S207, determining a mapping relationship table according to the information entropy of each target SQL language question and answer word and the information entropy of the rewritten SQL language question and answer word corresponding to the target SQL language question and answer word; the mapping relationship table stores the mapping relationship between the target SQL language question and answer word and its corresponding rewritten SQL language question and answer word that conforms to the preset information entropy difference rule; Step S208: input the mapping relationship table into a preset initial language model for training to obtain the question-answering language model; Wherein, the step S205 includes: Step S2051: Obtain the character length of each of the SQL language question and answer words to obtain a first character length list B=(B1, B2, ..., B g ,...,B h ); where g=1,2,...,h; h is the number of the SQL language question and answer words; B g is the character length of the g-th SQL language question and answer word; Step S2052, traverse the first character length list B, if B g ≥ B0, the g-th SQL language question and answer word is determined as the target SQL language question and answer word to obtain a number of target SQL language question and answer words; wherein B0 is a preset character length threshold; Wherein, the step S207 includes: Step S2071: Obtain the information entropy of each target SQL language question and answer word to obtain a first information entropy list C=(C1, C2, ..., C a ,...,C b ); where a=1,2,...,b; b is the number of question-answer words in the target SQL language; C a is the information entropy of the a-th target SQL language question and answer word; Step S2072: Obtain the information entropy of each of the rewritten SQL language question and answer words to obtain a second information entropy list D=(D1, D2, ..., D a ,...,D b ), where D a is the information entropy of the rewritten SQL language question and answer word obtained by rewriting the a-th target SQL language question and answer word; Step S2073, traverse the first information entropy list C and the second information entropy list D, if |D a -C a |≤d, then the mapping relationship between the ath target SQL language question and answer word and its corresponding rewritten SQL language question and answer word is stored in a preset mapping relationship table; wherein d is a preset information entropy difference threshold; After receiving a number of keywords asked by the user, the question-answering language model performs the following steps: Step S210: Perform SQL language conversion on each of the user's question keywords to obtain the SQL language keywords corresponding to each of the user's question keywords, and determine the SQL language keyword list E=(E1, E2, ..., E c ,...,E j ), where c=1,2,...,j; j is the number of keywords asked by the user; E c The SQL language keyword corresponding to the keyword asked by the cth user; Step S220, traverse each of the SQL language keywords in the SQL language keyword list E in turn, if E c There is a mapping relationship in the mapping relationship table. c Rewrite it as c Rewrite SQL language question and answer words with mapping relationship; Step S230: E1, E2, ..., E c ,...,E j Connect the identifiers one by one to get the SQL question and answer statement.
2. The method according to claim 1, characterized in that: The step S100 includes: Step S110, performing multiple rounds of rewriting processing on the user question sentence to obtain a corresponding target question sentence; Step S120: semantically analyze the target question sentence to obtain a semantic identifier corresponding to each target question word included in the target question sentence; Step S130: traverse each of the target question words, and if the semantic identifier corresponding to the target question word is a preset key semantic identifier, determine the target question word as a user question keyword.
3. The method according to claim 2, characterized in that The step S300 includes: Step S310, obtaining the query condition identifier included in the SQL question and answer statement; Step S320: determine the query condition corresponding to the query condition identifier as an index calling parameter.
4. The method according to claim 3, characterized in that: The step S400 includes: Step S410: If the index call parameter includes an identity query identifier, execute steps S420 to S440; otherwise, execute step S450; Step S420: Obtain the user ID corresponding to the user's question statement; Step S430: determining the user information data having the same user ID as the user identification corresponding to the user question statement as key user data; Step S440: determining the key user data corresponding to the index calling parameter as the target user data; Step S450: Determine the user information data corresponding to the index calling parameter as the target user data.
5. A non-transitory computer-readable storage medium, wherein at least one instruction or at least one program is stored in the storage medium, characterized in that: The at least one instruction or the at least one program is loaded and executed by the processor to implement the user question-and-answer based database indexing method as described in any one of claims 1-4.
6. An electronic device, characterized in that: The invention comprises a processor and the non-transitory computer-readable storage medium as claimed in claim 5.
Citation Information
Patent Citations
Question and answer method, system and device based on natural language processing and storage medium
CN113704444A
Model training method, intelligent question and answer method, equipment, medium and program product
CN114625759A
Knowledge question-answering method based on big data and related products
CN117828048A
Intelligent dialogue method and apparatus and electronic device
WO2021249528A1
