Query method and device, electronic equipment, medium and product
Through thinking chain and vector embedding models, infer the user input text, determine the query object and execute the query in the target database, solving the problem of accurate retrieval of user problems, and improving the query accuracy and cross-table query capabilities.
Patent Information
- Application Number
- CN202510229641.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-27
- Publication Date
- 2025-05-23
AI Technical Summary
Because the user's expression is personalized and the database is large, it is impossible to accurately retrieve the corresponding tables based on the user's problems, and the accuracy rate is low.
The input text is reasoned through a chain of thought, including the vector embedding model converting the input text into an input vector, matching based on the vector library, identifying the text and query objects, and executing query statements in the target database.
It improves the accurate retrieval ability of user problems, improves the accuracy of query results, and supports cross-table query in multi-database and multi-table scenarios.
Smart Images

Figure CN120030040A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of artificial intelligence technology, and in particular to a query method, device, electronic device, medium and product. Background Art
[0002] With the development of large language models, users can use natural language to ask questions. Large language models can generate database query language based on user input for search and query, and feedback the query results to users. However, due to factors such as the personalized expression of users and the large size of the database, it is impossible to accurately retrieve the corresponding table based on the user's question, and the accuracy rate is low. Summary of the invention
[0003] In view of this, the present disclosure provides a query method, device, electronic device, medium and product.
[0004] One aspect of the present disclosure provides a query method, including: obtaining input text; performing a first reasoning step on the input text based on a thought chain to obtain a recognized text, wherein the recognized text includes a text portion representing a query object; performing a second reasoning step on the recognized text based on the thought chain to obtain a query object and a query statement; and executing the query statement in a target database where the query object is located to obtain a query result.
[0005] According to an embodiment of the present disclosure, performing the first reasoning step on the input text based on the thought chain includes: using a vector embedding model to convert the input text into an input vector; matching in a vector library based on the input vector to obtain search results; and determining the recognition text based on the search results and the input text.
[0006] According to an embodiment of the present disclosure, the search results include a query object, and matching is performed in a vector library based on an input vector, and obtaining the search results includes: determining a preset number of matching vectors by calculating the similarity between the input vector and multiple candidate vectors in the vector library; and determining the query object based on the matching vectors.
[0007] According to an embodiment of the present disclosure, determining a query object according to a matching vector includes: acquiring a document block corresponding to the matching vector, the document block including document data and a document identifier; determining a document name corresponding to the document data according to the document identifier to obtain the query object.
[0008] According to an embodiment of the present disclosure, the thinking chain includes a third reasoning step, and the method further includes: executing the third reasoning step on the input text based on the thinking chain to obtain a target output format of the output information; processing the query result based on the target output format to obtain the output information.
[0009] According to an embodiment of the present disclosure, the method further includes: in response to the search result characterizing that there is no query object matching the input vector, determining output information based on the input text and the search results, the output information including query failure information and / or supplementary information for the input text.
[0010] According to an embodiment of the present disclosure, a vector library is established by the following method: at least one data source document is segmented into tables as units to obtain multiple document data blocks, wherein each document data block includes a complete table data; document descriptions and document identifiers are respectively added to the multiple document data blocks to obtain multiple document blocks; the multiple document blocks are respectively converted into candidate vectors using a vector embedding model, and the candidate vectors are stored in the vector library, so that when the input text is converted into an input vector using the vector embedding model, the input vector and the candidate vector are located in the same vector space.
[0011] According to an embodiment of the present disclosure, document descriptions and document identifiers are respectively added to multiple document data blocks to obtain multiple document blocks, including: identifying multiple document data blocks based on thought chains, generating document descriptions corresponding to each document data block; calculating hash values for the document names corresponding to each document data block, and determining the document identifier based on the calculation results.
[0012] Another aspect of the present disclosure also provides a query device, including: an acquisition module, used to acquire input text; a first reasoning module, used to perform a first reasoning step on the input text based on a chain of thought to obtain a recognized text, wherein the recognized text includes a text portion representing a query object; a second reasoning module, used to perform a second reasoning step on the recognized text based on the chain of thought to obtain a query object and a query statement; and a query module, used to execute the query statement in a target database where the query object is located to obtain a query result.
[0013] Another aspect of the present disclosure provides an electronic device, comprising: one or more processors; and a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors execute the above method.
[0014] Another aspect of the present disclosure further provides a computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, causes the processor to perform the above method.
[0015] Another aspect of the present disclosure further provides a computer program product, including a computer program, which implements the above method when executed by a processor.
[0016] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The above and other objects, features and advantages of the present disclosure will become more apparent through the following description of the embodiments of the present disclosure with reference to the accompanying drawings, in which:
[0018] Figure 1 is a schematic diagram of an exemplary system architecture to which a query method and apparatus can be applied according to an embodiment of the present disclosure;
[0019] Figure 2 A flowchart of a query method according to an embodiment of the present disclosure is schematically shown;
[0020] Figure 3 A schematic diagram schematically shows the reasoning steps of a thought chain according to an embodiment of the present disclosure;
[0021] Figure 4 A schematic diagram schematically shows the establishment of a vector library according to an embodiment of the present disclosure;
[0022] Figure 5 A statistical diagram schematically showing the accuracy of vector library retrieval according to an embodiment of the present disclosure;
[0023] Figure 6 A structural block diagram of a query device according to an embodiment of the present disclosure is schematically shown; and
[0024] Figure 7 A schematic block diagram of an electronic device that can be used to implement the query method of an embodiment of the present disclosure is schematically shown. DETAILED DESCRIPTION
[0025] Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. Various details of the embodiments of the present disclosure are included to facilitate understanding, and they should be considered as merely exemplary. Therefore, it should be appreciated by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Likewise, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.
[0026] In the technical solution of the present disclosure, the collection, storage, use, processing, transmission, provision, disclosure and application of the data involved (including but not limited to user personal information) comply with the provisions of relevant laws and regulations, take necessary confidentiality measures, and do not violate public order and good morals.
[0027] Figure 1is a schematic diagram of an exemplary system architecture to which the query method and apparatus can be applied according to an embodiment of the present disclosure. It should be noted that: Figure 1 What is shown is merely an example of a system architecture to which the embodiments of the present disclosure can be applied, in order to help those skilled in the art understand the technical content of the present disclosure, but it does not mean that the embodiments of the present disclosure cannot be used in other devices, systems, environments or scenarios.
[0028] like Figure 1 As shown, the system architecture 100 according to this embodiment may include terminal devices 101, 102, 103, a network 104 and a server 105. The network 104 is used to provide a medium for communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired and / or wireless communication links, etc.
[0029] Users can use terminal devices 101, 102, 103 to interact with server 105 through network 104 to receive or send messages, etc. Terminal devices 101, 102, 103 can be various electronic devices with display screens and supporting web browsing, including but not limited to smart phones, tablet computers, laptops, desktop computers, etc.
[0030] The server 105 may be a server equipped with a large language model and providing database query services, for example, generating query questions by inferring the information input by the user using the terminal devices 101, 102, and 103, and querying the corresponding database to obtain the query results. The server 105 may perform thought chain analysis, vectorized search, and other processing on the received user request data, and feed back the query results to the terminal device based on the processing results and the user's needs.
[0031] It should be noted that the query method provided in the embodiment of the present disclosure can generally be executed by the server 105. Accordingly, the query device provided in the embodiment of the present disclosure can generally be set in the server 105. The query method provided in the embodiment of the present disclosure can also be executed by a server or server cluster that is different from the server 105 and can communicate with the terminal devices 101, 102, 103 and / or the server 105. Accordingly, the query device provided in the embodiment of the present disclosure can also be set in a server or server cluster that is different from the server 105 and can communicate with the terminal devices 101, 102, 103 and / or the server 105.
[0032] Figure 2 The flowchart of the query method according to the embodiment of the present disclosure is schematically shown.
[0033] like Figure 2 As shown, the query method of this embodiment includes operations S210 to S240.
[0034] In operation S210, input text is acquired.
[0035] In the embodiments of the present disclosure, the input text may refer to the descriptive text input by the user to the big model based on the user's own search needs. The input text may represent the user's intention, such as the object the user is concerned about, the user's needs, and other information.
[0036] In operation S220, the first reasoning step is performed on the input text based on the thought chain to obtain the recognized text, and the recognized text includes the text part representing the query object. Among them, the thought chain refers to a method to enhance the reasoning ability of the model, which can decompose a complex problem into multiple relatively simple sub-problems, gradually solve each sub-problem through multiple reasoning steps, and finally get a complete answer to the problem. Reasoning analysis through the thought chain can help the model better understand and solve complex problems. The thought chain can be expressed by the following formula:
[0037]
[0038] Among them, Q is the original problem, f 1 represents the first reasoning step, S 1 represents the result of the first reasoning step. Similarly, S n is the result S obtained for the n-1th step n-1 The result obtained by executing the nth reasoning step, that is, the final result of the thinking chain after n steps of reasoning.
[0039] In the embodiments of the present disclosure, the user's input question can be decomposed based on the thought chain. The input text is subjected to intent recognition through the first reasoning step to obtain a recognized text. The input text can be subjected to intent recognition by parsing the input text through a large model, or the input text or keywords in the input text can be searched and matched in a database to determine the recognized text. The recognized text can include text parts such as query objects related to the user's question and questions raised by the user.
[0040] For example, the user input text is "How many SMB (Small-Medium-Sized Business) users do we have in total?" The first reasoning step is performed on the input text, and the recognized text is "It is necessary to obtain the number of users with user type SMB from the user_company table." The "user_company table" in the recognized text is the text part representing the query object, and "Obtain the number of users with user type SMB" represents the question raised by the user.
[0041] In operation S230, a second reasoning step is performed on the recognized text based on the thought chain to obtain a query object and a query sentence.
[0042] In an embodiment of the present disclosure, based on the first reasoning step, a query object and a query statement corresponding to the query operation are determined according to the recognized text through a second reasoning step. The query object can be determined from a text portion representing the query object in the recognized text, and the query statement can be determined jointly based on the query object and a portion representing the user question in the recognized text.
[0043] For example, if the recognized text is "need to obtain the number of users with user type SMB from the user_company table", and the query object is the "user_company table", the query language can be determined according to the query object and the user question.
[0044] In operation S240, the query statement is executed in the target database where the query object is located to obtain the query result.
[0045] In the embodiment of the present disclosure, the target database refers to a related database containing a query object. By executing a query statement in the target database, a query result for the user's question can be obtained.
[0046] In the embodiment of the present disclosure, when there are multiple databases and multiple tables, the target database containing the query object can be located according to the document name or other document identifier of the query object, and then the query statement is executed in the target database to obtain the query result.
[0047] According to the embodiments of the present disclosure, the thinking chain is deeply integrated with data retrieval, relevant information is obtained from the predefined data source according to the retrieval operation, and the contextual semantic perception accuracy of the reasoning chain is enhanced by using the retrieval results. The thinking chain can decompose complex problems into sub-problems and gradually solve them to get the final answer. This method helps large models better understand and handle complex problems and improves the accuracy and interpretability of model reasoning.
[0048] Next, combine Figure 3 The thought chain of the embodiment of the present disclosure is further explained.
[0049] Figure 3 The figure schematically shows the reasoning steps of the thought chain according to the embodiment of the present disclosure.
[0050] like Figure 3 As shown, the thought chain reasoning steps of this embodiment include a first reasoning step 31 and a second reasoning step 32. In the second reasoning step 32, the query object 307 and the query statement 308 are determined according to the recognized text 306, and the query statement 308 is executed in the target database 309 corresponding to the query object 307 to obtain the query result 310. The second reasoning step 32 is similar to the second reasoning step described above, and will not be repeated for the sake of simplicity.
[0051] According to an embodiment of the present disclosure, performing the first reasoning step 31 on the input text 301 based on the thought chain includes: using a vector embedding model to convert the input text 301 into an input vector 302; matching in a vector library 304 based on the input vector 302 to obtain a search result 305; and determining the recognized text 306 based on the search result 305 and the input text 301.
[0052] In the embodiments of the present disclosure, the vector embedding model may be a language model such as a text embedding model (text-embedding-v2), a word vector model (Word to Vector, Word2vec), a bidirectional encoder representation from transformer model (Bidirectional Encoder Representation from Transformer, bert), etc. The vector embedding model may convert information such as text information and numerical data into vectors, and quantify different text information into point information in a vector space according to semantic similarity. After the input text 301 is converted into an input vector 302 by the vector embedding model, the search result 305 is obtained by matching in the vector library 304.
[0053] According to an embodiment of the present disclosure, the vector library includes multiple candidate vectors. When establishing the vector library, the same vector embedding model is used to process the original data to obtain the candidate vectors. Therefore, when the user's input text is received and converted into an input vector using the vector embedding model, the input vector and the candidate vectors in the vector library are located in the same vector space, which facilitates vector matching based on the input vector and obtains more accurate search results.
[0054] In an embodiment of the present disclosure, the search results 305 and the input text 301 may be processed using a large model to generate a recognition text 306 including the search results 305 .
[0055] For example, the vector library includes document data from multiple databases, and the vectors corresponding to the k document data included in the i-th database can be expressed as Based on the input vector 302, the search result is a vector , representing the kth document data in the i-th database.
[0056] For example, the search result obtained through vector library matching is document A, and the input text is "Please help me calculate the total sales in the first quarter". According to the query object and the input text, the recognition text "Get the sales from January to March 2024 from document A and calculate the total" can be generated. Among them, "Get the sales from January to March 2024 and calculate the total" is obtained by intent recognition based on the input text. By understanding the user's personalized expression, removing the interfering semantic information, and using the search results to enhance the accuracy of the contextual semantics, accurate retrieval and question-answering can be achieved.
[0057] According to an embodiment of the present disclosure, the search results include a query object, and matching is performed in a vector library based on an input vector, and obtaining the search results includes: determining a preset number of matching vectors by calculating the similarity between the input vector and multiple candidate vectors in the vector library; and determining the query object based on the matching vector.
[0058] In one example, the similarity between the input vector and the candidate vectors in the vector library can be determined by calculating the cosine similarity. According to the nearest neighbor algorithm, k vectors with the highest similarity are determined based on the similarity. For example, the similarity can be determined by the following formula:
[0059]
[0060] Among them, similarity(A,B) refers to the similarity between the input vector A and the candidate vector B, A·B refers to the inner product of the input vector A and the candidate vector B, and ||A|| ||B|| refers to the scalar product of the input vector A and the candidate vector B.
[0061] In another example, the similarity between the input vector and the candidate vectors in the vector library can also be calculated by the maximum inner product search algorithm. The formula is as follows:
[0062]
[0063] in, is the candidate vector, D represents the vector library, is the input vector, argmax means taking the maximum value.
[0064] According to the embodiments of the present disclosure, by using the same vector embedding model to process document data and input text, it is ensured that the input vector and the candidate vectors in the vector library are in the same vector space, providing a basis for similarity search. By searching for the document most similar to the input vector as the search result, it is possible to quickly locate the relevant documents containing the query results from multiple databases and multiple tables.
[0065] According to an embodiment of the present disclosure, determining a query object according to a matching vector includes: acquiring a document block corresponding to the matching vector, the document block including document data and a document identifier; determining a document name corresponding to the document data according to the document identifier to obtain the query object.
[0066] In an embodiment of the present disclosure, an index can be constructed for the candidate vectors 304 generated by the vector embedding model so that the document block 303 corresponding to each candidate vector 304 has a corresponding position in the high-dimensional vector space. According to the search results given by the vector matching, the document block 303 corresponding to the search results can be found.
[0067] In the embodiments of the present disclosure, the document name of the document data is usually set to be relatively simple, and the amount of information contained is limited. It is impossible to achieve an accurate match between the candidate vector converted by the document name and the input vector, causing semantic interference. In this case, the document name can be deleted to reduce interfering semantic information, and a piece of text can be added as a document description of the document data to briefly describe the content, data type, etc. of the document. Thus, when performing vector matching, document blocks with semantically similar characteristics to the input text can be searched. However, since the document name is deleted, in order to construct an index between the document block and the candidate vector, a document identifier uniquely corresponding to the document data, such as a document number, code, etc., can be generated. When determining the candidate vector that matches the input vector, the document name corresponding to the document block can be determined based on the document identifier included in the candidate vector.
[0068] For example, the candidate vector obtained by matching includes the document identifier A3 and the corresponding document data. According to the document identifier, it can be determined that the document data comes from the third document block in the database A, thereby obtaining the corresponding document name.
[0069] According to an embodiment of the present disclosure, the thinking chain includes a third reasoning step, and the method further includes: executing the third reasoning step on the input text based on the thinking chain to obtain a target output format of the output information; processing the query result based on the target output format to obtain output information.
[0070] In the embodiment of the present disclosure, the query result 310 may be one or more data, or may be in the form of a table, a statistical chart, etc. In order to accurately obtain the output form of the query result 310, the third reasoning step may be performed based on the thought chain to further identify the intent of the input text and obtain the target output format of the output information.
[0071] For example, the user inputs the text "Please show me the trend of air quality changes over the past year". By performing intent recognition on the input text, the target output format of the output information can be obtained as a line graph. A line graph needs to be generated based on the query results and output to the user as output information.
[0072] According to an embodiment of the present disclosure, the method further includes: in response to the search result characterizing that there is no query object matching the input vector, determining output information based on the input text and the search results, the output information including query failure information and / or supplementary information for the input text.
[0073] In an embodiment of the present disclosure, if a query object similar to the input vector is not matched in the vector library, it may be that there is no document block related to the input text, or it may be due to semantic interference caused by the user's personalized expression. In this case, output information for prompting the user can be generated based on the input text and the search results. The query failure information can be used to prompt the user that there is no relevant document data. The supplementary information can be used to help the user supplement the input text in order to regenerate the recognition text.
[0074] Figure 4 The schematic diagram of establishing a vector library according to an embodiment of the present disclosure is schematically shown.
[0075] According to an embodiment of the present disclosure, a vector library 404 is established by the following method: at least one data source document 410, 420 is segmented into tables as units to obtain multiple document data blocks 401_1, 401_2, 401_3, ..., 401_n, wherein each document data block includes a complete table data; document descriptions and document identifiers are respectively added to the multiple document data blocks to obtain multiple document blocks 402_1, 402_2, 402_3, ..., 402_n; the multiple document blocks are respectively converted into candidate vectors 403 using a vector embedding model, and the candidate vectors 403 are stored in the vector library 404, so that when the input text is converted into an input vector using the vector embedding model, the input vector and the candidate vector are located in the same vector space.
[0076] According to an embodiment of the present disclosure, document descriptions and document identifiers are respectively added to multiple document data blocks to obtain multiple document blocks, including: identifying multiple document data blocks based on thought chains, generating document descriptions corresponding to each document data block; calculating hash values for the document names corresponding to each document data block, and determining the document identifier based on the calculation results.
[0077] In the embodiment of the present disclosure, in the case of multiple databases and multiple tables, it is necessary to first segment the documents of different data sources and delete the table name of each table to avoid semantic interference caused by irrelevant table name information and data mixing between tables. Extract the key document information from the table data in each document database and generate a document description for the table data. Since the document name is deleted, a document identifier uniquely corresponding to the document data block can be generated. For example, the document code corresponding to the document data block can be calculated based on the hash value, so as to determine the corresponding document data block based on the document identifier.
[0078] In the embodiments of the present disclosure, the processing efficiency of the large model and the accuracy of subsequent retrieval can also be improved by manually checking whether the added document description is reasonable.
[0079] According to the embodiments of the present disclosure, by automatically capturing fields in document data, generating descriptive information for each document data, and performing a vectorization step after manual review and correction, the semantic information is expanded, the function information of the document block and the relationship information between tables are increased, the accuracy of the similarity matching between the user input question and the document block can be enhanced, and in the scenario of multiple databases and multiple tables, it can support multi-data source queries and improve the accuracy of the answers.
[0080] Next, combine Figure 5 The different document block processing methods in the process of vector library establishment are further explained.
[0081] Figure 5 The figure schematically shows a statistical diagram of the accuracy of vector library retrieval according to an embodiment of the present disclosure.
[0082] like Figure 5 As shown in the figure, this statistical chart reflects the impact of document name and document description on the accuracy of vector library retrieval. The vertical axis represents the accuracy of vector library retrieval, and the horizontal axis represents the processing methods of document blocks, which are retaining the document name, deleting the document name, and deleting the document name and adding the document description. Among them, when the document name is retained, the accuracy of vector library retrieval is the lowest, and when the document name is deleted, the accuracy of vector library retrieval is significantly increased. Therefore, it can be explained that the document name will interfere with vector matching, and the document name cannot accurately and completely express the true role of the document in the database. The semantic interference can be effectively reduced by removing the file name.
[0083] Compared with simply deleting the document name, deleting the document name and adding the document description can effectively improve the accuracy of vector library retrieval, and the accuracy is as high as 89%, which means that the document description can effectively expand the semantic information of the document block, making it easier to quickly and accurately find the document block related to the input text when searching the vector library, enhance the accuracy of the similarity matching between the input text and the document block, better support cross-table queries, and improve the accuracy of the answers generated for user questions.
[0084] Figure 6 The structural block diagram of the query device according to an embodiment of the present disclosure is schematically shown.
[0085] like Figure 6 As shown, the query device 600 of this embodiment includes an acquisition module 610 , a first reasoning module 620 , a second reasoning module 630 and a query module 640 .
[0086] The acquisition module 610 is used to acquire the input text. In one embodiment, the acquisition module 610 can be used to perform the operation S210 described above, which will not be described in detail here.
[0087] The first reasoning module 620 is used to perform a first reasoning step on the input text based on the thought chain to obtain a recognized text, where the recognized text includes a text portion representing the query object. In one embodiment, the first reasoning module 620 can be used to perform the operation S220 described above, which will not be described in detail here.
[0088] The second reasoning module 630 is used to perform a second reasoning step on the recognized text based on the thought chain to obtain a query object and a query statement. In one embodiment, the second reasoning module 630 can be used to perform the operation S230 described above, which will not be described in detail here.
[0089] The query module 640 is used to execute the query statement in the target database where the query object is located to obtain the query result. In one embodiment, the query module 640 can be used to execute the operation S240 described above, which will not be described in detail here.
[0090] According to an embodiment of the present disclosure, the first reasoning module 620 includes a conversion submodule, a matching submodule and a determination submodule. The conversion submodule is used to convert the input text into an input vector using a vector embedding model. The matching submodule is used to match in a vector library based on the input vector to obtain a search result. The determination submodule is used to determine the recognition text based on the search result and the input text.
[0091] According to an embodiment of the present disclosure, the search results include a query object, and the matching submodule includes a calculation unit and a determination unit. The calculation unit is used to determine a preset number of matching vectors by calculating the similarity between the input vector and multiple candidate vectors in the vector library. The determination unit is used to determine the query object according to the matching vector.
[0092] According to an embodiment of the present disclosure, the determination unit includes an acquisition subunit and a determination subunit. The acquisition subunit is used to acquire a document block corresponding to the matching vector, and the document block includes document data and a document identifier. The determination subunit is used to determine the document name corresponding to the document data according to the document identifier to obtain the query object.
[0093] According to an embodiment of the present disclosure, the thought chain includes a third reasoning step, and the query device 600 also includes a third reasoning module and a first output module. The third reasoning module is used to perform the third reasoning step on the input text based on the thought chain to obtain the target output format of the output information. The first output module is used to process the query result based on the target output format to obtain the output information.
[0094] According to an embodiment of the present disclosure, the query device 600 further includes a second output module. The second output module is used to determine output information based on the input text and the search results in response to the search result indicating that there is no query object matching the input vector, and the output information includes query failure information and / or supplementary information for the input text.
[0095] According to an embodiment of the present disclosure, a vector library is established by the following modules: a segmentation module, which is used to segment at least one data source document by table as a unit to obtain multiple document data blocks, wherein each document data block includes a complete table data. An adding module, which is used to add document descriptions and document identifiers to multiple document data blocks respectively to obtain multiple document blocks. A conversion module, which is used to convert multiple document blocks into candidate vectors respectively using a vector embedding model, and store the candidate vectors in the vector library, so that when the input text is converted into an input vector using the vector embedding model, the input vector and the candidate vector are located in the same vector space.
[0096] According to an embodiment of the present disclosure, the adding module includes a generating submodule and a calculating submodule. The generating submodule is used to identify multiple document data blocks respectively based on the thought chain, and generate a document description corresponding to each document data block. The calculating submodule is used to calculate the hash value for the document name corresponding to each document data block, and determine the document identifier according to the calculated result.
[0097] Figure 7 A schematic block diagram of an electronic device that can be used to implement the method of the embodiment of the present disclosure is schematically shown.
[0098] like Figure 7 As shown, the electronic device 700 according to an embodiment of the present disclosure includes a processor 701, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 702 or a program loaded from a storage part 708 to a random access memory (RAM) 703. The processor 701 may include, for example, a general-purpose microprocessor (such as a CPU), an instruction set processor and / or a related chipset and / or a special-purpose microprocessor (for example, an application-specific integrated circuit (ASIC)), etc. The processor 701 may also include an onboard memory for caching purposes. The processor 701 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present disclosure.
[0099] In RAM 703, various programs and data required for the operation of electronic device 700 are stored. Processor 701, ROM 702 and RAM 703 are connected to each other via bus 704. Processor 701 performs various operations of the method flow according to the embodiment of the present disclosure by executing the program in ROM 702 and / or RAM 703. It should be noted that the program can also be stored in one or more memories other than ROM 702 and RAM 703. Processor 701 can also implement the method provided by the embodiment of the present disclosure by executing the program stored in the one or more memories.
[0100] According to an embodiment of the present disclosure, the electronic device 700 may further include an input / output (I / O) interface 705, which is also connected to the bus 704. The electronic device 700 may further include one or more of the following components connected to the I / O interface 705: an input portion 706 including a keyboard, a mouse, etc.; an output portion 707 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage portion 708 including a hard disk, etc.; and a communication portion 709 including a network interface card such as a LAN card, a modem, etc. The communication portion 709 performs communication processing via a network such as the Internet. A drive 710 is also connected to the I / O interface 705 as needed. A removable medium 711, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 710 as needed, so that a computer program read therefrom is installed into the storage portion 708 as needed.
[0101] The present disclosure also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or may exist independently without being assembled into the device / apparatus / system. The above computer-readable storage medium carries one or more programs, and when the above one or more programs are executed, the method according to the embodiment of the present disclosure is implemented.
[0102] According to an embodiment of the present disclosure, the computer-readable storage medium may be a non-volatile computer-readable storage medium, for example, it may include but is not limited to: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, an apparatus or a device. For example, according to an embodiment of the present disclosure, the computer-readable storage medium may include the ROM 702 and / or RAM 703 described above and / or one or more memories other than ROM 702 and RAM 703.
[0103] The embodiment of the present disclosure also includes a computer program product, which includes a computer program, and the computer program contains program code for executing the method shown in the flowchart. When the computer program product is run in a computer system, the program code is used to enable the computer system to implement the method provided by the embodiment of the present disclosure.
[0104] The above functions defined in the system / device of the embodiment of the present disclosure are performed when the computer program is executed by the processor 701. According to the embodiment of the present disclosure, the system, device, module, unit, etc. described above can be implemented by a computer program module.
[0105] In one embodiment, the computer program may rely on tangible storage media such as optical storage devices, magnetic storage devices, etc. In another embodiment, the computer program may also be transmitted and distributed in the form of signals on a network medium, and downloaded and installed through the communication part 709, and / or installed from the removable medium 711. The program code contained in the computer program may be transmitted using any appropriate network medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.
[0106] In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 709, and / or installed from the removable medium 711. When the computer program is executed by the processor 701, the above functions defined in the system of the embodiment of the present disclosure are performed. According to the embodiment of the present disclosure, the system, device, means, module, unit, etc. described above can be implemented by a computer program module.
[0107] It should be noted that the collection, storage, use, processing, transmission, provision, disclosure and application of user personal information involved in the technical solution of this disclosure are in compliance with the provisions of relevant laws and regulations, necessary confidentiality measures have been taken, and they do not violate public order and good morals. In the technical solution of this disclosure, the user's authorization or consent is obtained before obtaining or collecting user personal information.
[0108] According to an embodiment of the present disclosure, the program code for executing the computer program provided by the embodiment of the present disclosure can be written in any combination of one or more programming languages. Specifically, these computing programs can be implemented using high-level process and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages include, but are not limited to, Java, C++, python, "C" language or similar programming languages. The program code can be executed entirely on the user computing device, partially on the user device, partially on the remote computing device, or entirely on the remote computing device or server. In the case of a remote computing device, the remote computing device can 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 can be connected to an external computing device (for example, using an Internet service provider to connect through the Internet).
[0109] The flow charts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0110] It will be appreciated by those skilled in the art that the features described in the various embodiments and / or claims of the present disclosure may be combined and / or coupled in a variety of ways, even if such combinations and / or couplings are not explicitly described in the present disclosure. In particular, the features described in the various embodiments and / or claims of the present disclosure may be combined and / or coupled in a variety of ways without departing from the spirit and teachings of the present disclosure. All of these combinations and / or couplings fall within the scope of the present disclosure.
[0111] The embodiments of the present disclosure are described above. However, these embodiments are only for illustrative purposes and are not intended to limit the scope of the present disclosure. Although the embodiments are described above, this does not mean that the measures in the various embodiments cannot be used in combination. The scope of the present disclosure is defined by the appended claims and their equivalents. Without departing from the scope of the present disclosure, those skilled in the art may make a variety of substitutions and modifications, which should all fall within the scope of the present disclosure.
Claims
1. A query method, comprising: Get input text; Perform a first reasoning step on the input text based on the thought chain to obtain a recognized text, wherein the recognized text includes a text portion representing a query object; Perform a second reasoning step on the recognized text based on the thought chain to obtain a query object and a query statement; as well as The query statement is executed in the target database where the query object is located to obtain a query result.
2. According to the method of claim 1, the step of performing a first reasoning step on the input text based on the thought chain comprises: Using a vector embedding model, converting the input text into an input vector; Perform matching in a vector library based on the input vector to obtain search results; A recognition text is determined based on the search results and the input text.
3. The method according to claim 2, wherein the search results include a query object, and the matching in a vector library based on the input vector to obtain the search results includes: Determine a preset number of matching vectors by calculating the similarity between the input vector and a plurality of candidate vectors in the vector library; The query object is determined according to the matching vector.
4. The method according to claim 3, wherein determining the query object according to the matching vector comprises: Acquire a document block corresponding to the matching vector, wherein the document block includes document data and a document identifier; The document name corresponding to the document data is determined according to the document identifier to obtain the query object.
5. The method according to claim 1, wherein the thought chain comprises a third reasoning step, and the method further comprises: Performing a third reasoning step on the input text based on the thought chain to obtain a target output format of the output information; The query result is processed based on the target output format to obtain output information.
6. The method according to claim 1, further comprising: In response to the search result indicating that there is no query object matching the input vector, output information is determined based on the input text and the search result, the output information including query failure information and / or supplementary information for the input text.
7. The method according to claim 1, wherein the vector library is established by the following method: At least one data source document is segmented into tables to obtain multiple document data blocks, where: Each document data block includes a complete table data; Adding document descriptions and document identifiers to the multiple document data blocks respectively to obtain multiple document blocks; The multiple document blocks are respectively converted into candidate vectors using the vector embedding model, and the candidate vectors are stored in the vector library, so that when the input text is converted into an input vector using the vector embedding model, the input vector and the candidate vector are located in the same vector space.
8. The method according to claim 7, wherein the step of adding document descriptions and document identifiers to the plurality of document data blocks to obtain the plurality of document blocks comprises: Respectively identifying the plurality of document data blocks based on the thought chain, and generating a document description corresponding to each of the document data blocks; A hash value calculation is performed for the document name corresponding to each of the document data blocks, and the document identifier is determined according to the calculation result obtained.
9. A query device, comprising: The acquisition module is used to obtain the input text; A first reasoning module, configured to perform a first reasoning step on the input text based on a thought chain to obtain a recognized text, wherein the recognized text includes a text portion representing a query object; A second reasoning module, configured to perform a second reasoning step on the recognized text based on a thought chain to obtain a query object and a query statement; as well as The query module is used to execute the query statement in the target database where the query object is located to obtain the query result.
10. An electronic device, comprising: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors are caused to execute the method according to any one of claims 1 to 8.