Rag method and apparatus
By combining the data storage methods of non-relational and relational databases, the generative model's generation capability is enhanced, solving the problem that existing RAG technology cannot meet user needs and achieving more accurate and comprehensive search results output.
Patent Information
- Application Number
- PCT/CN2026/097595
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2025-05-23
- Filing Date
- 2026-05-18
- Publication Date
- 2026-11-26
AI Technical Summary
Existing Retrieval Augmentation (RAG) technologies cannot meet the growing needs of users and affect the user experience, especially in knowledge base question answering scenarios, where the structured data in the form of fragments does not provide sufficient enhancement for the generative model.
By combining non-relational and relational databases, data shards are obtained from the non-relational database using natural language queries, and tabular data of structured data are obtained from the relational database. These are then input into the generative model to enhance its generative capabilities.
It improves the accuracy and comprehensiveness of the search results output by the generated model, meets user needs, and enhances the user experience.
Smart Images

Figure CN2026097595_26112026_PF_FP_ABST
Abstract
Description
RAG Method and Apparatus
[0001] This application claims priority to Chinese Patent Application No. 202510679727.5, filed on May 23, 2025, entitled "RAG Method and Apparatus", the entire contents of which are incorporated herein by reference. Technical Field
[0002] This application relates to the field of artificial intelligence technology, and in particular to a RAG method and apparatus. Background Technology
[0003] With the development of artificial intelligence technology, retrieval augmented generation (RAG) technology is being applied more and more widely. Retrieval augmented generation refers to acquiring data that meets retrieval criteria (hereinafter referred to as augmented data) and inputting it along with the retrieval criteria into a generative model to enhance the model's capabilities and improve the accuracy of the final retrieval results output by the model. However, as user demands increase, current retrieval augmented generation solutions are no longer sufficient to meet user needs, severely impacting the user experience. Summary of the Invention
[0004] This application provides a RAG method and apparatus that enhances generative model generation by combining non-relational and relational databases for retrieval enhancement, thereby significantly improving the generative model's generation capability and helping to meet user needs.
[0005] Firstly, a RAG method combining unstructured and structured data is provided, which can be applied to RAG systems that can be deployed in local data centers or in cloud data centers. The method includes: receiving a natural language query statement; obtaining a first retrieval result of the natural language query statement from a non-relational database, wherein the non-relational database is used to store data fragments of at least one first file and at least one second file, the first file is used to store unstructured data, the second file is used to store structured data, and the first retrieval result includes data fragments of a target first file in at least one first file and / or data fragments of a target second file in at least one second file; if the first retrieval result includes data fragments of the second file, obtaining a second retrieval result from a relational database using a target structured query language (SQL) statement, wherein the relational database is used to store structured data from at least one second file through at least one first data table, a target first data table in at least one first data table is used to store structured data from the target second file, the target SQL statement is used to query target data in the target first data table that satisfies the retrieval conditions indicated by the natural language query statement, and the second retrieval result includes the target data queried by the target SQL statement; inputting the natural language query statement and target content into a generative model, so that the generative model determines the target retrieval result of the natural language query statement based on the target content, wherein the target content includes the second retrieval result.
[0006] In the above scheme, by setting up the RAG system, it can be used to retrieve both non-relational and relational databases, thus increasing the types of databases used to obtain augmented data. This helps to improve the diversity and comprehensiveness of the data types of augmented data, thereby helping to improve the accuracy of the final retrieval results (e.g., target retrieval results) obtained by the generative model, and in turn, improving the user experience and meeting the growing needs of users.
[0007] Furthermore, by storing the data in the second file in different formats in both non-relational and relational databases—for example, storing it in a sharded format in a non-relational database and in a tabular format in a relational database—it is possible to retrieve the tabular data of the structured data (i.e., the target data in the target first data table) from the relational database when retrieving data shards of structured data (i.e., data shards of the target second file) from the non-relational database. This not only helps ensure the necessity of retrieving data from the relational database but also allows for the retrieval of the tabular data corresponding to the data shards of the structured data. In this way, prompts for the generative model can be constructed based on the tabular structured data. Compared to constructing prompts based on sharded structured data, this helps ensure the integrity and comprehensiveness of the structured data input to the generative model, thereby improving the enhancement effect of structured data on the generative model and ultimately improving the accuracy of the final retrieval results determined by the generative model.
[0008] In one possible implementation, if the first search result includes data fragments of the first file, the target content also includes data fragments of the target first file.
[0009] In this implementation, by setting the target content to include data fragments of the target first file when the first search result includes data fragments of the target first file, the generative model can be enhanced by combining unstructured and structured data. This increases the diversity of the data structure used to enhance the generative model, which not only helps to improve the enhancement effect of the generative model, but also helps to improve the accuracy and comprehensiveness of the final search results determined by the generative model.
[0010] In another possible implementation, the target SQL statement is determined based on the natural language query statement and the target summary information of the target second file. The target summary information includes the table name and column names of the target second data table indicated by the target second file, which is used to store the structured data in the target second file.
[0011] In this implementation, by setting the target SQL statement to be determined based on the natural language query statement and the target summary information, it is helpful to ensure that the retrieval conditions of the target SQL statement can point to a column of the target second data table, thereby helping to ensure the success rate of the target SQL statement in retrieving relevant data.
[0012] In another possible implementation, the target summary information may further include at least one of the following: the data type of at least one column of data in the target second data table, or at least one data selected from at least one column of data.
[0013] In this implementation, the summary information also includes the data type of the column data. This helps determine the operations that can be performed on the column data. For example, when the data type of the column data is numeric, an averaging operation can be performed on the column data. By including at least one data point selected from the column data in the summary information, when the column name cannot accurately indicate the content of the column data, it can be determined whether the column data meets the search criteria based on at least one data point selected from the column data. This not only helps to accurately determine the column data pointed to by the SQL statement, but also helps to improve the accuracy of the SQL statement.
[0014] In another possible implementation, the target content also includes a target SQL statement and target summary information, wherein the target SQL statement and target summary information are used to determine the target retrieval results based on the target data in the first target data table.
[0015] In this implementation, the target content also includes the target SQL statement and target summary information. In this way, the generation model can determine whether the accuracy of the second search result meets the standard based on the target SQL statement and target summary information. Only if the accuracy of the second search result meets the standard will the final search result be determined based on the second search result, thereby helping to improve the accuracy of the final search result.
[0016] In another possible implementation, the first search result includes multiple data fragments, which include data fragments of the target first file and / or data fragments of the target second file. The first search result includes data fragments of the second file, which includes: N data fragments among the multiple data fragments including data fragments of the second file, and the relevance of each of the N data fragments to the natural language query statement is higher than the relevance of each of the multiple data fragments other than the N data fragments to the natural language query statement, where N is a positive integer greater than or equal to 1.
[0017] In this implementation, the second search result is only retrieved from the relational database when the N most relevant data shards include the data shards of the second file. This helps to increase the necessity of retrieving the second search result, thereby helping to avoid wasting time.
[0018] In another possible implementation, the target content also includes data fragments of the target second file.
[0019] In this implementation, by setting the target content to include data fragments of the target second file, it helps to ensure the integrity and comprehensiveness of the data provided to the generating model, thereby helping to improve the accuracy of the final retrieval results determined by the generating model. This helps to improve the user experience and meet the growing needs of users.
[0020] In another possible implementation, the method further includes: outputting the target retrieval results of the natural language query statement.
[0021] In this implementation, the target retrieval results are provided to the user by outputting the target retrieval results, so that the user can obtain the target retrieval results of the natural language query. Since the target retrieval results are generated through retrieval enhancement using unstructured data and structured data, the accuracy of the target retrieval results is significantly improved, which in turn helps to improve the user experience.
[0022] In another possible implementation, the first retrieval result includes the identifier of the target second file and the identifier of the target second data table. The method further includes: determining the target second file from at least one second file based on the identifier of the target second file; and determining the summary information of the target second data table from the summary information of at least one second data table of the target second file based on the identifier of the target second data table.
[0023] In this implementation, the summary information of the second file to be retrieved from the relational database is determined by identifying the second file and the second data table to which the data fragment belongs in the first search result. This helps to improve the accuracy of the search objects in the relational database, thereby improving the accuracy of the search results in the relational database, and further helping to improve the accuracy of the search results finally generated by the generative model.
[0024] In another possible implementation, the first retrieval result includes an identifier of the target second document. The method further includes: determining the summary information of the target second document from the summary information of at least one second document based on the identifier of the target second document, wherein the summary information of the target second document includes the summary information of at least one second data table indicated by the target second document, and the summary information of at least one second data table includes the summary information of the target second data table (i.e., includes the target summary information).
[0025] In this implementation, the summary information of the second file to be retrieved from the relational database is determined by the identifier of the second file to which the data fragment belongs in the first search result. This helps to improve the accuracy of the search object in the relational database, thereby improving the accuracy of the search results in the relational database, and further helping to improve the accuracy of the search results finally generated by the generative model.
[0026] In another possible implementation, the method further includes: determining target summary information of a target second document from the summary information of at least one second document according to the retrieval conditions indicated by the natural language query statement, wherein the target summary information of the target second document includes the retrieval conditions indicated by the natural language query statement.
[0027] In this implementation, by setting retrieval conditions indicated by a natural language query statement, the target summary information of the target second file is determined from the summary information of at least one second file. This helps to improve the diversity of ways to determine the summary information used when generating the target SQL statement.
[0028] In another possible implementation, the method further includes: if the first retrieval result does not include data fragments of the second file but includes data fragments of the first file, inputting a natural language query statement and data fragments of the target first file into the generative model.
[0029] In this implementation, by setting the first search result to include data fragments of the second file but not the data fragments of the first file, the natural language query statement and the data fragments of the target first file are input into the generative model. This helps to improve the diversity and flexibility of the RAG system in performing search enhancement.
[0030] In another possible implementation, the target second data table can be of any of the following types: vertical table, hierarchical table, complex table, or horizontal table.
[0031] Secondly, a RAG apparatus combining unstructured data and structured data is provided. This RAG apparatus includes functional units for executing any of the methods provided in the first aspect, wherein the actions performed by each functional unit are implemented in hardware or by executing corresponding software via hardware. For example, the RAG apparatus may include: a receiving module, a first retrieval module, a second retrieval module, and an enhancement module; the receiving module is used to receive a natural language query statement; the first retrieval module is used to obtain a first retrieval result of the natural language query statement from a non-relational database, wherein the non-relational database is used to store at least one data fragment of a first file and at least one data fragment of a second file, the first file is used to store unstructured data, the second file is used to store structured data, and the first retrieval result includes at least one data fragment of a target first file in the first file and / or at least one data fragment of a target second file in the second file; the second retrieval module is used to, when the first retrieval result includes data fragments of the second file, perform further retrieval by... The target structured query language (SQL) statement retrieves a second retrieval result from a relational database. The relational database stores structured data from at least one second file in at least one first data table. A target first data table within the first data table stores structured data from the target second file. The target SQL statement queries the target data in the target first data table that satisfies the retrieval conditions indicated by the natural language query statement. The second retrieval result includes the target data retrieved by the target SQL statement. An enhancement module inputs the natural language query statement and target content into the generative model, enabling the generative model to determine the target retrieval result of the natural language query statement based on the target content. The target content includes the second retrieval result.
[0032] Thirdly, a processor is provided that can be used to execute any of the methods provided in the first aspect above.
[0033] Fourthly, a chip is provided, comprising: a processor and a power supply circuit; the power supply circuit can be used to supply power to the chip; the processor can be used to execute any of the methods provided in the first aspect above.
[0034] Fifthly, a computing device is provided, comprising: a processor, a memory, and computer programs / instructions stored in the memory; the processor executes the computer programs / instructions to cause the computing device to perform any of the methods provided in the first aspect above.
[0035] A sixth aspect provides a computing device cluster, comprising: at least one computing device, each computing device including a processor, a memory, and computer programs / instructions stored in the memory; the processor of each computing device executes the computer programs / instructions to enable the computing device cluster to implement any of the methods provided in the first aspect above.
[0036] In a seventh aspect, a RAG system is provided, which includes a non-relational database and a relational database. The non-relational database is used to store data fragments of at least one first file and at least one second file. The first file is used to store unstructured data, and the second file is used to store structured data. The relational database is used to store structured data from at least one second file through at least one second data table.
[0037] Eighthly, a RAG system is provided. The RAG system is used to establish a first communication connection with a non-relational database, wherein the non-relational database is used to store data fragments of at least one first file and at least one second file, the first file is used to store unstructured data, and the second file is used to store structured data. The RAG system obtains retrieval results from the non-relational database through the first communication connection. The RAG system is also used to establish a second communication connection with a relational database, wherein the relational database is used to store structured data from at least one second file through at least one second data table. The RAG system obtains retrieval results from the relational database through the second communication connection.
[0038] Ninthly, a computer program product is provided, comprising a computer program / instructions that, when executed by a computing device, implement any of the methods provided in the first aspect above.
[0039] In a tenth aspect, a computer-readable storage medium is provided, on which a computer program / instructions are stored, which, when executed by a computing device, implement any of the methods provided in the first aspect above.
[0040] The technical effects of any of the implementation methods in aspects two through ten can be seen in the technical effects of different implementation methods in aspect one above, and will not be repeated here. Attached Figure Description
[0041] Figure 1 is a schematic diagram of one of the system architectures provided in this application;
[0042] Figure 2 is a second schematic diagram of a system architecture provided in this application;
[0043] Figure 3 is a schematic diagram of a system architecture provided in this application;
[0044] Figure 4 is a flowchart of a RAG method provided in this application;
[0045] Figure 5 is a schematic diagram of a data entry process provided in this application;
[0046] Figure 6 is a schematic diagram of an online question-and-answer process provided in this application;
[0047] Figure 7 is a schematic diagram of a RAG device provided in this application;
[0048] Figure 8 is a schematic diagram of a computing device provided in this application;
[0049] Figure 9 is a schematic diagram of a computing device cluster provided in this application;
[0050] Figure 10 is a schematic diagram of the connection of a computing device cluster provided in this application. Detailed Implementation
[0051] The technical solution provided in this application will now be described in detail with reference to the accompanying drawings.
[0052] To facilitate a clear description of the technical solutions of this application, the terms "first" and "second" are used in the embodiments of this application to distinguish identical or similar items with substantially the same function and effect. Those skilled in the art will understand that the terms "first" and "second" do not limit the quantity or execution order, and that "first" and "second" are not necessarily different. Furthermore, in the embodiments of this application, the terms "exemplary" or "for example" are used to indicate that something is being used as an example, illustration, or explanation. Any embodiment or design scheme described as "exemplary" or "for example" in this application should not be construed as being more preferred or advantageous than other embodiments or design schemes. Specifically, the use of terms such as "exemplary" or "for example" is intended to present the relevant concepts in a concrete manner for ease of understanding.
[0053] In this application, "and / or" is merely a descriptive term for the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, or B existing alone, where A and B can be singular or plural. In the description of this application, unless otherwise stated, "multiple" means two or more. "At least one" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, or c can represent: a, b, c, ab, ac, bc, or abc, where a, b, and c can be single or multiple.
[0054] In the description of this application, unless otherwise stated, " / " indicates that the objects before and after are in an "or" relationship. For example, A / B can mean A or B. "And / or" in this application is merely a description of the relationship between the related objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists alone, A and B exist simultaneously, and B exists alone. A and B can be singular or plural.
[0055] With the development of artificial intelligence technology, the application of RAG (Real-Time Analysis) technology is becoming increasingly widespread. For example, RAG technology has been widely used in knowledge base question-answering scenarios. In question-answering scenarios, structured data is stored in the knowledge base in a fragmented form. Before the user's question is input into the generative model, fragments of structured data can be obtained from the knowledge base as augmenting data. These augmenting data, along with the user's question, are then input into the generative model to enhance its generative capabilities, thereby improving the accuracy of the output answer. However, as user demands increase, the augmenting effect of fragmented structured data on the generative model is no longer sufficient to meet user needs, severely impacting the user experience.
[0056] In view of this, this application provides a RAG method, which, based on a natural language query, obtains a first retrieval result from a non-relational database. The first retrieval result may include data fragments of structured data and / or data fragments of unstructured data. If the first retrieval result includes data fragments of structured data, a second retrieval result, based on the natural language query, is obtained from a relational database. The second retrieval result includes tabular data of structured data. Subsequently, the tabular data of structured data and the natural language query are input into the generative model, thereby enhancing the generative model through the tabular data of structured data. This helps ensure the integrity and comprehensiveness of the structured data, thereby improving the accuracy of the final retrieval result obtained by the generative model, and ultimately improving the user experience and meeting the growing needs of users.
[0057] Next, the system architecture involved in the technical solution provided in this application will be further described with reference to the accompanying drawings.
[0058] This application provides a system architecture for a RAG system applied to the above-described RAG method.
[0059] For example, Figure 1 is a schematic diagram of one of the system architectures provided in this application. As shown in Figure 1, the RAG system may include a server (e.g., a web server), a generative model, a non-relational database, and a relational database.
[0060] It should be noted that this application does not restrict the type of server; the above is merely an illustrative example.
[0061] For example, the server-side component can be deployed on a computing device (e.g., a server) or a virtual machine. The generative model can be deployed on a computing device (e.g., a server) or a virtual machine. The non-relational database can be deployed on a computing device (e.g., a server) or a virtual machine. The relational database can be deployed on a computing device (e.g., a server) or a virtual machine. For example, the server-side component is deployed on server 1, the non-relational database is deployed on server 2, the relational database is deployed on server 3, and the generative model is deployed on server 4.
[0062] It should be noted that non-relational databases and relational databases can be deployed on the same computing device / virtual machine, or they can be deployed on different computing devices / virtual machines; this application does not impose any restrictions on this.
[0063] The server can communicate with non-relational databases. For example, it can establish a first communication connection with a non-relational database and communicate through that connection. The server can also communicate with relational databases. For example, it can establish a second communication connection with a relational database and communicate through that connection. Finally, the server can communicate with generative models. For example, it can establish a third communication connection with a generative model and communicate through that connection.
[0064] The non-relational database is used to store data shards from at least one first file and at least one second file. The first file stores unstructured data, and the second file stores structured data. The server can retrieve data shards from the non-relational database and input them into the generative model to enhance it. For example, the server can retrieve data shards from the non-relational database through a first communication connection.
[0065] The relational database is used to store structured data from at least one second file through at least one data table. The server can retrieve tabular data from the data table in the relational database and input the tabular data into the generative model to enhance the generative model. For example, the server can retrieve tabular data from the data table in the relational database through a second communication connection.
[0066] For example, non-relational databases can be Elasticsearch (ES), Faiss, Annoy, etc.
[0067] It should be noted that this application does not limit the type of non-relational database; the above is merely an illustrative example.
[0068] For example, the non-relational database in this application can also be called a knowledge base, an unstructured knowledge base, etc.
[0069] For example, a relational database can be a MySQL database, an Oracle database, a SQL Server database, etc.
[0070] It should be noted that this application does not limit the type of relational database; the above is merely an illustrative example.
[0071] In this application, the RAG system can be used to retrieve data from both non-relational and relational databases. Furthermore, the second file used to store structured data is stored not only as data shards in the non-relational database but also as tables in the relational database. In this way, the RAG system can simultaneously enhance the generative model using data shards from the non-relational database and tabular data from the relational database, thereby significantly improving the inference performance of the generative model.
[0072] For example, the server can also communicate with the user's client to receive natural language queries from the client, which can be used to indicate the search criteria for data. The server can then retrieve data that meets the search criteria from non-relational and / or relational databases based on the natural language queries. Furthermore, the server can send the search results obtained from the generative model to the client.
[0073] For example, the generative model may include at least one of the following: large language model (LLM), vision language model (VLM), audio language model (ALM), or large multimodal model (LMM).
[0074] It should be noted that this application does not limit the type of generative model; the above is merely an illustrative example. Furthermore, the generative model in this application can also be called a generative model / RAG generative model.
[0075] In this embodiment, by deploying both non-relational and relational databases within the RAG system, it helps to ensure the data security of both databases, as well as the stability and reliability of the data within them.
[0076] Optionally, the RAG system also includes a conversion module (not shown in Figure 1), which is used to convert natural language query statements into SQL query statements (natural language to SQL, NL2SQL).
[0077] For example, the conversion module can be an NL2SQL model, an executable program, etc.
[0078] It should be noted that this application does not limit the type of conversion module; the above is merely an illustrative example.
[0079] For example, the conversion module can be deployed on a computing device (e.g., a server) or a virtual machine. For instance, the conversion module is deployed on server 5.
[0080] In one example, the conversion module can be deployed on the same computing device / virtual machine as the server, which helps reduce communication costs.
[0081] In another example, the conversion module and the server can be deployed on the same computing device / virtual machine, which helps to ensure the performance of the conversion module and the server.
[0082] For example, Figure 2 is a second schematic diagram of a system architecture provided in this application. The following only describes in detail the differences between the system architecture shown in Figure 2 and the system architecture shown in Figure 1; the similarities will not be repeated.
[0083] As shown in Figure 2, the RAG system includes a server and a generative model, but does not include non-relational or relational databases. In other words, the non-relational and relational databases can be provided by database systems outside the RAG system.
[0084] In this embodiment, by separating the non-relational database and relational data from the RAG system, the RAG system can obtain data from external databases. This helps to increase the breadth of data sources in the non-relational database and relational data, thereby helping to improve the richness of data in the non-relational database and relational data.
[0085] For example, Figure 3 is a schematic diagram of a system architecture provided in this application.
[0086] As shown in Figure 3, the RAG system includes a cloud management platform and the infrastructure managed by the cloud management platform. Servers and generation models can be deployed on the infrastructure. For example, non-relational databases and relational databases can also be deployed on the infrastructure.
[0087] It should be noted that this application does not restrict the deployment location of non-relational databases and relational databases; the above is merely an illustrative example.
[0088] For example, the cloud management platform provides access interfaces (such as a user interface or API). Tenants can use clients to remotely access these interfaces, register a cloud account and password on the cloud management platform, and log in. After successful authentication of the cloud account and password, the tenant can further select and purchase virtual machines of specific specifications (processor, memory, disk) on the cloud management platform. After successful purchase, the cloud management platform provides the remote login account and password for the purchased virtual machine. The client can then remotely log in to the virtual machine and install and run the tenant's applications within it. Examples include installing server-side applications, generating models, NoSQL databases, and relational databases.
[0089] In one implementation, the cloud management platform receives natural language queries from clients and forwards them to the server. Upon receiving the query, the server retrieves data that meets the search criteria from a non-relational database and / or a relational database. This data, along with the query, is then input into a generative model, which generates the final search results based on the data from the non-relational and / or relational databases. The generative model then sends the final search results to the server. The server, upon receiving the final search results, sends them to the cloud management platform. The cloud management platform can then send the final search results obtained by the generative model back to the client for display to the user.
[0090] In another implementation, the operations performed by the server can also be executed by the cloud management platform. In this case, the RAG system may not need to include a server. This helps simplify the architecture of the RAG system.
[0091] It should be noted that the following description uses the RAG system shown in Figure 3, including the server, as an example to illustrate this application.
[0092] It should be noted that other relevant descriptions of the system architecture shown in Figure 3 can be found in the descriptions of the system architectures shown in Figure 1 and Figure 2 above, and will not be repeated here.
[0093] It should be noted that the system architecture shown in Figures 1 to 3 does not constitute a limitation on the system architecture for implementing the RAG method provided in this application.
[0094] It should be noted that the system architecture and application scenarios described in this application are for the purpose of more clearly illustrating the technical solutions of this application, and do not constitute a limitation on the technical solutions provided in this application. As those skilled in the art will know, with the evolution of system architecture and the emergence of new application scenarios, the technical solutions provided in this application are also applicable to similar technical problems.
[0095] For ease of understanding, the RAG method provided in this application will be described exemplarily below with reference to the above system architecture and accompanying drawings.
[0096] Figure 4 illustrates a RAG method provided in this application. Exemplarily, this RAG method may include the following steps S401-S404. The term "step" in this application may be abbreviated as S, and will not be described further hereafter.
[0097] For example, the solution in this application involves a data entry process and a question-and-answer process. The data entry process refers to the process of storing data from the first file and the second file into a non-relational database, and storing data from the second file into a relational database. The question-and-answer process refers to the process of providing answers (e.g., target search results) to natural language queries from users.
[0098] The following is an example of the data entry process, with reference to Figure 5.
[0099] In this application, the non-relational database stores at least one data fragment of a first file and at least one data fragment of a second file.
[0100] The following section uses a single first file as an example to introduce the process of data sharding for storing at least one first file in a non-relational database.
[0101] For example, a user's electronic device has a client 1 for a non-relational database installed. The user can upload a first file to the non-relational database through client 1, where the first file is used to store unstructured data. After receiving the first file, the non-relational database parses and segments the first file to obtain data fragments of the first file, and stores the data fragments of the first file.
[0102] For example, the first file can be a document file, an image file, a video file, etc.
[0103] It should be noted that this application does not limit the type or format of the first file; the above is merely an illustrative example. Hereinafter, the first file will be a document file as an example to illustrate this application.
[0104] For example, document files may include Word files, PDF files, etc.
[0105] It should be noted that this application does not restrict the format of document files; the above is merely an illustrative example.
[0106] For example, a non-relational database can split the first file according to character length, paragraphs, chapters, etc.
[0107] It should be noted that this application does not impose any restrictions on the way the first file is split in a non-relational database; the above is merely an illustrative example.
[0108] For example, a non-relational database can store data fragmented and serialized into Markdown format.
[0109] It should be noted that this application does not restrict the method of data sharding for storing data in non-relational databases; the above is merely an illustrative example.
[0110] The following section uses a single second file as an example to introduce the process of data sharding for storing at least one second file in a non-relational database.
[0111] For example, a user can also upload a second file to a non-relational database via client 1, where the second file is used to store structured data. After receiving the second file, the non-relational database parses and segments the second file to obtain data fragments, and stores the data fragments of the second file.
[0112] For example, the second file can be an Excel file, a CSV file, a log file, an XML file, a JSON file, an HTML file, etc.
[0113] It should be noted that this application does not limit the format of the second file; the above is merely an illustrative example. The following description uses an Excel file as an example to illustrate this application.
[0114] In one example, when the second file is a tabular file, such as an Excel or CSV file, a non-relational database can split the second file by row, column, etc. Here, a tabular file refers to a file that stores structured data through data tables.
[0115] In another example, when the second file is not a table file, such as a log file, XML file, JSON file, HTML file, etc., the non-relational database can split the second file according to character length, lines, paragraphs, etc.
[0116] It should be noted that this application does not restrict the way the second file is split in a non-relational database; the above is merely an illustrative example.
[0117] In this application, the structured data from at least one second file is stored in the relational database through at least one first data table. That is, the structured data in a second file is stored not only in a non-relational database in the form of data shards, but also in a relational database in the form of data tables.
[0118] The following section uses a single second file as an example to describe the process of storing structured data in at least one second file in a relational database.
[0119] Example 1: The second file is a tabular file, storing structured data in a second data table. The user's electronic device also has a relational database client 2 installed, allowing the user to upload the second file to the relational database. Upon receiving the second file, the relational database parses it according to rules, obtains its schema summary, and stores it. The relational database can also create a first data table and store the structured data from the second data table in the first data table.
[0120] For example, a relational database can create a first data table based on the summary information of the second document. This first data table is used to store the structured data in the second data table. This helps ensure that one first data table is used to store data from one second data table, thereby helping to guarantee the independence of the data in the second data table.
[0121] For example, when the second file is a table file, it may include K second data sheets, where K is a positive integer greater than or equal to 1. Different second data sheets have different identifiers; for instance, the K second data sheets may include two sheets, identified as sheet1 and sheet2. The summary information of the second file may include summary information of the K second data sheets. A relational database can create a first data sheet based on the summary information of a second data sheet, thereby creating K first data sheets. Subsequently, the relational database can transfer data from one second data sheet to a first data sheet.
[0122] The following example uses a single second data table of the second file to illustrate the summary information of the second file.
[0123] For example, the summary information of the second file includes summary information of the second data table, which includes the table name and column names of the second data table. The table name indicates the name of the second data table. The column names indicate the first row of each column in the second data table.
[0124] In this embodiment, the summary information of the second file includes table names and column names. This helps to determine the data content in the second data table through the summary information, which in turn helps to determine the location of data in the second data table that meets the search conditions, thereby improving the accuracy of the search location and the search efficiency.
[0125] Optionally, the summary information of the second document may also include at least one of the following: the data type of at least one column of data in the second data table or at least one piece of data selected from at least one column of data in the second data table.
[0126] For example, the second data table includes a first column of data, which can be any one of the at least one columns of data. The following description uses the first column of data as an example to illustrate the summary information of the second data table.
[0127] For example, the data type of the first column can be numeric, text, date, time, percentage, fraction, etc.
[0128] It should be noted that this application does not impose any restrictions on data types; the above is merely an illustrative example.
[0129] For example, selecting at least one data point from the first column of data means selecting one data point from multiple data points when the first column of data includes multiple data points. For instance, if the first column of data includes Company A, Company B, Company C, Company D, ..., the at least one data point selected from the first column of data can be Company A and Company C.
[0130] It should be noted that at least one data point selected from the first column of data can be randomly selected, or it can be selected according to a preset rule; this application does not impose any restrictions on this.
[0131] For example, the summary information of the second file can be stored in a cache file, a text file, or similar format. For instance, a relational database can store the summary information of the second file in the storage space of server 3.
[0132] It should be noted that this application does not limit the storage format of the summary information of the second document; the above is merely an illustrative example.
[0133] Example 2: The second file is a non-tabular file. After receiving the second file from the user, the relational database converts it into a tabular file and stores the structured data from the second file in a second data table. Then, the relational database obtains the summary information of the second data table, thus obtaining the summary information of the second file. Next, the relational database creates a first data table and stores the structured data from the second data table into the first data table.
[0134] It should be noted that other relevant explanations for Example 2 can be found in the explanations for Example 1 above, and will not be repeated here.
[0135] It should be noted that this application does not restrict the type of files uploaded by users to the relational database; the above is merely an illustrative example. The following description uses Example 1 as an example to illustrate this application.
[0136] In the above embodiments, the second file used to store structured data is stored not only in a non-relational database in the form of data shards, but also in a relational database in the form of data tables. In this way, when it is necessary to use the structured data in the second file for retrieval enhancement generation, retrieval enhancement generation can be performed through the structured data in the form of data tables. This not only helps to improve the diversity of data formats when structured data is used for retrieval enhancement generation, but also helps to improve the comprehensiveness of data when structured data is used for retrieval enhancement generation.
[0137] Furthermore, non-relational databases can store data shards of the first file and data shards of the second file before executing S401-S404, while relational databases can store data in the second file through a data table before executing S401-S404. This allows the time-consuming data entry process to be performed before the database is retrieved, thereby helping to ensure the efficiency of the retrieval process and thus helping to ensure the timeliness of providing the final retrieval results to the user.
[0138] Optionally, the target second data table may be of any of the following types: vertical table, hierarchical table, complex table, or horizontal table.
[0139] For example, when retrieving tabular data, operations that can be performed include content extraction and numerical calculation. By setting the target data packet type to a vertical table, the number and success rate of successful content extraction operations can be improved. By setting the target first data table type to a hierarchical table, not only the number and success rate of successful content extraction operations can be improved, but also the number and success rate of successful numerical calculation operations can be improved. Here, the number of successful queries refers to the number of query requests that yielded search results, and the success rate is the ratio of the number of query requests that yielded search results to the total number of query requests. A query request refers to a natural language query statement. Furthermore, by setting the target second data table type to be a complex table or a horizontal table, the type diversity of the target second data table can be improved.
[0140] For example, the number of successful vertical tables and hierarchical tables, as well as the success rate, are shown in Table 1.
[0141] Table 1
[0142] Optionally, before executing S401-S404, the RAG method provided in this application may further include: the server of the RAG system receiving summary information of a second file from a relational database; and the server storing the summary information of the second file.
[0143] For example, after obtaining the summary information of the second file, the relational database can send the summary information of the second file to the server. After receiving the summary information of the second file from the relational database, the server can store the summary information of the second file for use in subsequent retrieval stages. For example, the server can store the summary information of the second file in the storage space of the computing device / virtual machine running the server, for example, in the storage space of server 1. Alternatively, the server can store the summary information of the second file in a specified database.
[0144] In this embodiment, by configuring the server to store summary information of the second file, it helps to improve the convenience and speed of the server in determining the SQL statement based on the summary information of the second file.
[0145] The following embodiments detail the data entry process. The question-and-answer process is illustrated below with reference to Figure 6.
[0146] S401: The RAG system receives natural language query statements.
[0147] In one example, a client is installed on the user's electronic device. This client can communicate with the RAG system, for example, with the RAG system's cloud management platform or server. When a user needs to find the answer to a question, they can send a natural language query to the RAG system through the client. This natural language query specifies the user's question.
[0148] Example 1a: A natural language query is used to indicate classes in the third grade whose average Chinese language score is below 90.
[0149] Example 1b: A natural language query is used to indicate which classes in the third grade have an average Chinese language score below 90 and what problems exist in those classes.
[0150] Example 1c: A natural language query is used to indicate problems in third-grade classes where the average Chinese language score is below 90.
[0151] For example, referring to the RAG system shown in Figures 1 and 2, the server of the RAG system can receive natural language queries from clients. Referring to the RAG system shown in Figure 3, the cloud management platform of the RAG system receives the natural language queries from clients and sends them to the server of the RAG system.
[0152] In another example, during the operation of an electronic device, a client can send a natural language query to the RAG system to request the information it needs.
[0153] It should be noted that this application does not limit the reasons for triggering the sending of natural language query statements; the above is merely an illustrative example.
[0154] S402: The RAG system retrieves the first search result of a natural language query from a non-relational database.
[0155] For example, at least one first file includes a target first file, and at least one second file includes a target second file. The first search result includes data fragments of the target first file and / or data fragments of the target second file.
[0156] In one example, the first search result includes data fragments of both the first target file and the second target file. In another example, the first search result includes data fragments of the first target file. In yet another example, the first search result includes data fragments of the second target file.
[0157] For example, as shown in Figure 6, after receiving a natural language query, the server of the RAG system, in response to the query, retrieves a non-relational database and obtains a first search result from the non-relational database through search recall. For instance, the server of the RAG system can establish a first communication connection with a non-relational database. Through this connection, the server sends a search request to the non-relational database, requesting the retrieval of the content requested by the natural language query, thereby achieving the retrieval of the non-relational database. In response to the received search request, the non-relational database retrieves the content requested by the natural language query from at least one data fragment of a first file and at least one data fragment of a second file, obtaining the first search result, and sends this result to the server of the RAG system, thus enabling the server to obtain the first search result.
[0158] Example 2a, in conjunction with Example 1a above, the first search result includes data fragments of the target second file, which are used to indicate classes with an average score below 90.
[0159] Example 2b, combined with Example 1b above, the first search result includes data fragments from the first target file and data fragments from the second target file. The data fragments from the first target file are used to indicate the problems existing in classes with an average Chinese language score below 90 in the third grade. The data fragments from the second target file are used to indicate classes with an average score below 90.
[0160] Example 2c, combined with Example 1c above, the first search result includes data fragments of the target first file, which are used to indicate the problems in classes in the third grade where the average score of Chinese is below 90.
[0161] S403: If the first search result includes data fragments of the second file, the RAG system retrieves the second search result from the relational database using the target SQL statement.
[0162] For example, at least one first data table in a relational database includes a target first data table, which stores structured data in a target second file. A target SQL statement is used to query target data in the target second data table that meets the retrieval conditions indicated by a natural language query statement. The second retrieval result includes the target data retrieved by the target SQL statement, that is, the target data retrieved from the target first data table by the target SQL statement. The target data in the target first data table can also be referred to as tabular data in the target second file.
[0163] For example, as shown in Figure 6, after the RAG server obtains the first search result, it determines whether the first search result includes data fragments of the second file. If the result is yes, that is, if the result indicates that the first search result includes data fragments of the second file, it means that the second file storing structured data contains the content requested by the natural language query statement. Therefore, it is necessary to search the relational database, that is, to trigger the SQL query process.
[0164] For example, the first search result includes data fragment 1. Hereinafter, taking data fragment 1 as an example, the process of determining whether the first search result includes data fragments of the second file will be described in an exemplary manner.
[0165] For example, the RAG system stores identifier groups, which include identifiers for at least one second file. The first search result also includes the identifier of the file to which data fragment 1 belongs. For instance, if data fragment 1 is a data fragment of file 1, then the identifier of the file to which data fragment 1 belongs is the identifier of file 1. The RAG system can determine whether the first search result includes the data fragment of the second file based on whether the identifier of file 1 belongs to the identifier group. If the identifier of file 1 belongs to the identifier group, it means that the first search result includes the data fragment of the second file. If the identifier of file 1 is located in the identifier group, it means that the first search result does not include the data fragment of the second file.
[0166] Because the structured data stored in the second file has structured attributes, non-relational databases may destroy these attributes when splitting the data according to parameters such as character length. Furthermore, when the second file is a table file, typically only the first shard contains header information; all other shards lose their header information. In this case, it's difficult to guarantee the accuracy of the final search results if retrieval enhancement is performed using data shards of structured data. Therefore, the RAG system's server obtains the target SQL statement and uses it to retrieve the second search result (a natural language query) from the relational database. This allows for the acquisition of structured data in table format, enabling retrieval enhancement through this structured data. Additionally, querying the relational database using SQL statements helps shorten the retrieval latency, thus improving retrieval efficiency.
[0167] For example, the server of the RAG system can establish a second communication connection with a relational database. Through this second communication connection, the server of the RAG system sends SQL statements to a non-relational database. In response to the received target SQL statement, the non-relational database retrieves the content requested by the natural language query from the target second data table, obtains the second search result, and sends the second search result to the server of the RAG system, thereby enabling the server to obtain the second search result.
[0168] Example 3a, combined with Example 2a above, the first search result includes data fragments of the target second file. Based on the first search result including the data fragments of the second file, the RAG system retrieves the second search result from the relational database using the target SQL statement. The second search result is used to indicate classes in the target first data table whose average Chinese language score is below 90.
[0169] Example 3b, combined with Example 2b above, the first search result includes data fragments of the target first file and data fragments of the target second file. Based on the first search result including the data fragments of the second file, the RAG system retrieves the second search result from the relational database using the target SQL statement. The second search result is used to indicate classes in the target first data table whose average Chinese language score is below 90.
[0170] Example 3c, combined with Example 2c above, shows that since the first search result does not include data fragments of the second file, the RAG system does not search relational databases.
[0171] In the above embodiments, after receiving a natural language query, the RAG system first searches the non-relational database. After obtaining the first search result for the non-relational database, it determines whether the first search result involves structured data (i.e., data fragments of the second file), thereby determining whether to trigger the process of searching the relational database (i.e., the SQL query process). This not only helps to ensure the necessity of searching the relational database, but also helps to improve search efficiency, thereby helping to shorten the latency of the search process.
[0172] Optionally, the target SQL statement is determined based on the natural language query statement and the target summary information of the target second file. The target summary information includes the table name and column names of the target second data table indicated by the target second file. The target second data table is used to store the structured data from the target second file. The data in the target first data table comes from the target second data table.
[0173] For example, when the target second file is a tabular file, the target second data table indicated by the target second file is the data table in the target second file. When the target second file is non-tabular data, the target second data table indicated by the target second file is the data table in the target tabular file converted from the target second file.
[0174] For example, after the RAG system server determines that an SQL query process has been triggered, it first identifies at least one second file, the second file (i.e., the target second file) and the data table (i.e., the target second data table) that the SQL query process needs to query. Then, as shown in Figure 6, the RAG system obtains the target summary information of the target second file (i.e., the summary information of the target second data table) and inputs the target summary information and the user question (i.e., the natural language query statement) into a conversion module (e.g., an NL2SQL model) to generate a target SQL statement. After obtaining the target SQL statement, the NL2SQL model sends the target SQL statement to the RAG system server. The RAG system server sends the target SQL statement to a relational database, which executes the target SQL statement to obtain the second search result. After obtaining the second search result, the relational database sends the second search result back to the RAG system server.
[0175] It should be noted that this application does not impose any restrictions on the modules used to generate the target SQL statements; the above is merely an illustrative example.
[0176] For example, a natural language query could be "Classes in Grade 3 with an average Chinese score below 90" and "Problems Existing in Classes with an Average Chinese Score Below 90". The target summary information includes a table named "Grade 3 Grades Table_sheet1" and column names such as: Column 1: Class; Column 2: Chinese Score; Column 3: Attribute Score, etc. The target SQL statement could be "Chinese Score from Grade 3 Grades Table_sheet1", where "Chinese Score" indicates the column name and "Grade 3 Grades Table_sheet1" indicates the table name.
[0177] For example, after receiving at least one second file, a relational database can obtain summary information of at least one second file. The following is an exemplary description of a method for determining the target summary information of a target second file from the summary information of at least one second file.
[0178] In one implementation, the first search result includes an identifier for the target second file (e.g., a first identifier) and an identifier for the target second data table (e.g., a second identifier). The server of the RAG system can determine the target second file from at least one second file based on the first identifier. Subsequently, the server of the RAG system can determine the summary information (i.e., target summary information) of the target second data table from the summary information of at least one second data table indicated by the target second file based on the second identifier.
[0179] In this implementation, the identifier of the target second file in the first search result is used to determine the second file to which the data fragments of the structured data in the first search result belong, and the identifier of the target second data table in the first search result is used to determine the second data table in the second file where the data fragments of the structured data in the first search result are located. This yields summary information for generating SQL statements (i.e., summary information of the target second data table). This helps ensure that the SQL statement accurately points to the target first data table, thereby improving the accuracy of the SQL statement and, consequently, improving search efficiency and the accuracy of search results.
[0180] In another implementation, the first search result includes an identifier of the target second file (e.g., a first identifier). The server of the RAG system can determine the summary information of the target second file from the summary information of at least one second file based on the first identifier, wherein the summary information of the target second file is the target summary information. For example, the server of the RAG system obtains the summary information of the second file to which the first identifier belongs from the summary information of at least one second file.
[0181] For example, if the target second file corresponds to one second data table, the summary information of that one second data table is the target summary information. If the target second file corresponds to multiple second data tables, the summary information of those multiple second data tables is the target summary information.
[0182] In this implementation, the summary information used to generate the SQL statement is determined by the identifier of the second file indicated by the first search result. This helps to ensure that the SQL statement can accurately point to the first data table used to store the data in the target second file, thereby improving the accuracy of the SQL statement and thus improving the search efficiency and the accuracy of the search results.
[0183] In another implementation, the RAG system server can determine the target summary information of a target second document from the summary information of at least one second document based on the search criteria indicated by the natural language query. The target summary information of the target second document includes the search criteria indicated by the natural language query.
[0184] For example, the RAG server can parse natural language queries to obtain the search criteria indicated by the queries. For instance, search criteria might include "third grade," "Chinese language score," "average score," "90 points," "classes scoring below 90 points," and "existing problems." Then, the RAG server can determine, based on the search criteria indicated by the natural language query, that the target summary information of at least one second document includes the search criteria. For example, the number of search criteria included in the target summary information of the target second document can be the summary information of at least one second document containing the most search criteria.
[0185] In this implementation, the RAG system determines the summary information used to generate the SQL statement based on the retrieval conditions indicated by the natural language query statement, which helps to improve the diversity of ways to determine the summary information.
[0186] In the above embodiments, by setting the target SQL statement to be determined based on the natural language query statement and the target summary information of the target second file, it is helpful to ensure that the retrieval conditions of the target SQL statement can point to a certain column of the target second data table, thereby helping to ensure the success rate of the target SQL statement in retrieving relevant data.
[0187] It should be noted that this application does not impose any restrictions on the parameters used to determine the target SQL statement; the above is merely an illustrative example. In another implementation, the target SQL statement can also be determined solely based on the natural language query statement; that is, the target summary information of the target second file is not used when determining the target SQL statement.
[0188] Optionally, the target summary information of the target second document may further include at least one of the following: the data type of at least one column of data in the target second data table or at least one data selected from at least one column of data in the target second data table.
[0189] For example, the first column of the target second data table is named "Grade," and includes grades such as first grade, second grade, third grade, and fourth grade. At least one data item selected from the first column includes grades second and third. Since the column name of the first column cannot indicate whether the first column includes the location of the third-grade data to be retrieved, the target summary information of the target second file also includes at least one data item selected from at least one column. This helps determine whether the first column includes data that meets the search criteria. Therefore, it not only helps determine whether the SQL statement targets the first column (i.e., whether the SQL statement retrieves the first column), but also helps determine whether the target second data table includes data that meets the search criteria, thereby improving the accuracy of the SQL statement.
[0190] In this embodiment, by setting the summary information to include the data type of the column data, it is helpful to determine the operations that can be performed on the column data. For example, when the data type of the column data is numeric, an averaging operation can be performed on the column data. By setting the summary information to include at least one data selected from the column data, when the column name cannot accurately indicate the content of the column data, it is possible to determine whether the column data meets the search criteria based on at least one data selected from the column data. This not only helps to accurately determine the column data pointed to by the SQL statement, but also helps to improve the accuracy of the SQL statement.
[0191] For example, the first search result includes multiple data fragments, which include data fragments of the target first file and / or data fragments of the target second file.
[0192] Optionally, the first search result includes data fragments of the second file, including: N data fragments among multiple data fragments include data fragments of the second file.
[0193] For example, RAG retrieves data shards from a non-relational database, resulting in multiple data shards (i.e., the first retrieval results), and determines the relevance of each data shard to the natural language query. Then, RAG sorts the data shards according to their relevance to the natural language query, from highest to lowest, to obtain the N data shards with the highest relevance (i.e., Top N). These N data shards are the most relevant data shards among the multiple data shards. In other words, the relevance of each of the N data shards to the natural language query is higher than the relevance of each of the other data shards (excluding the N data shards) to the natural language query.
[0194] For example, multiple data shards include data shard 1, ..., data shard 10, where N equals 1 / 2. The RAG system sorts each data shard in descending order of relevance to the natural language query statement, resulting in the following sorted list: data shard 1, data shard 2, data shard 3, ..., data shard 10. Based on this, if data shards 1, 2, and 3 include shards containing data from the second file, the system determines that the first search result includes the data shards containing the second file, and the RAG system executes step S403.
[0195] It should be noted that N is a positive integer greater than or equal to 1. This application does not impose any restrictions on the specific values of N, and the specific value of N can be dynamically set according to the actual scenario.
[0196] For example, the above-described operation of sorting multiple data shards can also be performed by a non-relational database, and this application does not impose any restrictions on this. In this case, the RAG system can obtain multiple data shards sorted from high to low relevance.
[0197] In this embodiment, the second search result is only obtained from the relational database when the N most relevant data shards include the data shards of the second file. This helps to increase the necessity of obtaining the second search result, thereby helping to avoid wasting time.
[0198] S404: The RAG system inputs a natural language query and target content into the generative model, enabling the generative model to determine the target retrieval results of the natural language query based on the target content. The target content includes the first retrieval result.
[0199] For example, when the first result includes data fragments of the first file, the server of the RAG system inputs the target content and natural language query statement into the generation model, so that the generation model determines the target retrieval result (i.e., the final retrieval result) of the natural language query statement based on the target content. The target content includes the target data obtained in the target first data table in S403.
[0200] For example, the server of the RAG system can construct prompts based on the natural language query and target content. These prompts indicate how to determine the answer to the natural language query based on the target content. For instance, the prompts can be obtained by concatenating the natural language query and target content, thus enhancing the prompts. The server then inputs these prompts into the generative model, enabling the model to combine them with structured data in tabular form to determine the answer to the natural language query, thereby enhancing the generative model and improving its performance.
[0201] Example 4a, combined with Example 3a above, the server of the RAG system constructs prompt word 'a' based on the classes with an average Chinese language score of less than 90 in the target first data table and the natural language query statement, and inputs the obtained prompt word 'a' into the generative model to obtain the target retrieval result 'a' output by the generative model.
[0202] It should be noted that this application does not limit the way the generative model determines the search results based on the target content; the above is merely an illustrative example.
[0203] In the above scheme, by storing the data in the second file in different forms in a non-relational database and a relational database respectively—for example, storing it in a sharded form in a non-relational database and in a tabular form in a relational database—it is possible to retrieve the tabular data of the structured data (i.e., the target data in the target first data table) from the relational database when retrieving data shards of structured data (i.e., data shards of the target second file) from the non-relational database. This not only helps ensure the necessity of retrieving data from the relational database but also allows the retrieval of the tabular data corresponding to the data shards of structured data. Thus, prompts for the generative model can be constructed based on the tabular structured data. Compared to constructing prompts based on sharded structured data, this helps ensure the integrity and comprehensiveness of the structured data input to the generative model, thereby improving the enhancement effect of structured data on the generative model and ultimately improving the accuracy of the final retrieval results determined by the generative model.
[0204] Optionally, if the first search result includes data fragments of the first file, the target content may also include data fragments of the target first file. That is, the target data may also include data fragments of the target first file obtained in S402.
[0205] For example, when the first search result includes data fragments of both the first and second data, the RAG system's server constructs prompt words based on the natural language query, the data fragments of the target first file, and the target data of the target first data table. Then, the RAG system's server inputs the prompt words into the generative model, enabling the model to combine unstructured data in fragment form and structured data in tabular form to determine the answer to the natural language query.
[0206] Example 4b, combined with Example 3b above, the RAG system's server constructs prompt word b based on the problems of classes with an average Chinese language score below 90 in the third grade, the classes with an average Chinese language score below 90 in the target first data table, and the natural language query statement. The obtained prompt word b is then input into the generative model to obtain the target retrieval result b output by the generative model.
[0207] In this embodiment, by setting the target content to include data fragments of the target first file when the first search result includes data fragments of the target first file, the generative model can be enhanced by combining unstructured and structured data. This increases the diversity of the data structure used to enhance the generative model, which not only helps to improve the enhancement effect of the generative model, but also helps to improve the accuracy and comprehensiveness of the final search results determined by the generative model.
[0208] Optionally, the target content may also include data fragments of the target second file.
[0209] Because tabular files sometimes contain unstructured data, this unstructured data is often lost during the import process into a relational database. In such cases, data fragments from the target secondary file are input into the generative model. This allows the model to combine these fragments to determine the final search results, ensuring the completeness and comprehensiveness of the data provided to the model. This, in turn, improves the accuracy of the final search results determined by the model, ultimately enhancing the user experience and meeting the growing needs of users.
[0210] Optionally, the target content also includes the target SQL statement and the target summary information of the target second file, wherein the target SQL statement and the target summary information of the target second file are used to determine the target retrieval results based on the target data in the target first data table.
[0211] For example, the RAG system's server can also input the target SQL statement and the target summary information of the target second file into the generative model. For instance, the RAG system's server can construct prompt words based on the natural language query statement, target content, target SQL statement, and the target summary information of the target second file. These prompt words can be used to instruct whether to use the target content (i.e., the target data in the target first data table) to determine the answer to the natural language query statement based on the target SQL statement and the target summary information of the target second file. Alternatively, the prompt words can instruct whether to use the target content to determine the answer to the natural language query statement based on the natural language query statement, target SQL statement, and the target summary information of the target second file; that is, to determine whether to use the execution result of the target SQL statement.
[0212] After receiving the target SQL statement and the target summary information of the second target file, the generative model can determine whether to determine the target retrieval result based on the target data in the first target data table, i.e., whether to adopt the execution result of the target SQL statement, based on the target summary information of the second target file and the natural language query statement. For example, the generative model can generate a validation SQL query statement based on the natural language query statement and the target summary information of the second target file, and compare the validation SQL query statement with the target SQL statement. If the validation SQL query statement and the target SQL statement are the same, it indicates that the accuracy of the target SQL statement is high, and the accuracy of the retrieval result obtained by the target SQL statement (i.e., the second retrieval result) will also be high, so the execution result of the target SQL statement is determined to be adopted. Conversely, if the validation SQL query statement and the target SQL statement are different, it indicates that the accuracy of the target SQL statement is low, and the accuracy of the retrieval result obtained by the target SQL statement will also be low, so the execution result of the target SQL statement is determined not to be adopted.
[0213] It should be noted that this application does not restrict the method by which the generation model determines whether to use the execution result of the target SQL statement; the above is merely an illustrative example.
[0214] It should be noted that this application does not impose any restrictions on determining an excessive number of correlations. Furthermore, this application does not impose any restrictions on the specific value of the correlation threshold; the correlation threshold can be dynamically set according to the specific scenario.
[0215] In this embodiment, by setting the target content to also include the target SQL statement and the target summary information of the target second file, the generation model can determine whether the accuracy of the second search result meets the standard based on the target SQL statement and the target summary information of the target second file. Only if the accuracy of the second search result meets the standard will the final search result be determined based on the second search result, thereby helping to improve the accuracy of the final search result.
[0216] Optionally, the RAG method further includes: if the first search result includes data fragments of the first file but does not include data fragments of the second file, the RAG system inputs data fragments of the target first file into the generation model, so that the generation model determines the target search result based on the data fragments of the target first file.
[0217] For example, after the RAG system server retrieves multiple data fragments, it determines whether the data fragments of the second file are included among these fragments. If the result indicates that the data fragments of the second file are not included, the RAG system server inputs the data fragments of the target first file into the generation model, so that the generation model determines the target retrieval result based on the data fragments of the target first file. For example, the first retrieval result not including the data fragments of the second file could mean that N data fragments do not include the data fragments of the second file.
[0218] For example, the server of the RAG system can construct prompt words based on the natural language query and the data fragments of the target first file, and input the obtained prompt words into the generation model.
[0219] Example 4c, combined with Example 3c above, the server of the RAG system constructs prompt word c based on the problems of classes with an average Chinese score of less than 90 in the third grade and the natural language query statement, and inputs the obtained prompt word c into the generative model to obtain the target retrieval result c output by the generative model.
[0220] In this embodiment, by setting the first search result to exclude data fragments of the second file but include data fragments of the first file, the data fragments of the target first file are input into the generation model. This allows the RAG system to perform search enhancement generation not only by combining structured data in the form of data tables and unstructured data in the form of data fragments, but also by performing search enhancement generation using only unstructured data in the form of data fragments, thereby helping to improve the diversity of search enhancement generation methods.
[0221] Optionally, the RAG method may also include: the RAG system outputting the target retrieval results.
[0222] For example, as shown in Figure 5, after the generative model obtains the target retrieval results, it sends the target retrieval results to the server of the RAG system. After receiving the target retrieval results, the server of the RAG system sends the target retrieval results to the client. For example, after receiving the target retrieval results, the client can display the target retrieval results to the user through the display screen of an electronic device.
[0223] In this embodiment, the RAG system provides target search results to users by outputting target search results, thereby enabling users to obtain target search results for natural language queries. Since the target search results are generated through retrieval enhancement using unstructured data and structured data, the accuracy of the target search results is significantly improved, which in turn helps to improve the user experience.
[0224] In this application, after receiving a natural language query, the RAG system first searches a non-relational database based on the natural language query to obtain the first search result from the non-relational database. After obtaining the first search result, the RAG system determines whether the first search result includes data fragments (i.e., structured data) of the second file.
[0225] If the first search result includes data fragments of the second file, the RAG system determines to trigger the SQL query process. Based on the first search result, the RAG system targets the second file, inputting the target summary information of the second file and the natural language query statement into the conversion module to obtain the target SQL statement. Then, the RAG system searches a relational database using the target SQL statement to obtain the second search result from the relational database. After obtaining the second search result, the RAG system determines prompt word 1 based on the natural language query statement, the second search result, and the first search result, and inputs prompt word 1 into the generative model, calling the generative model to determine the final search result for the natural language query statement.
[0226] If the first search result does not include data fragments of the second file, the RAG system directly determines prompt word 2 based on the natural language query and the first search result, and inputs the determined prompt word 2 into the generative model to determine the final search result of the natural language query.
[0227] The foregoing primarily describes the solutions provided by the embodiments of this application from a methodological perspective. To achieve the aforementioned functions, the RAG device includes corresponding hardware structures and / or software modules for executing each function. Those skilled in the art should readily recognize that, based on the units and algorithm steps of the examples described in conjunction with the embodiments disclosed herein, this application can be implemented in hardware or a combination of hardware and computer software. Whether a function is executed in hardware or by computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0228] This application embodiment can, according to the above method, exemplarily divide the RAG device into functional modules. For example, the RAG device may include functional modules corresponding to each functional division, or two or more functions may be integrated into one processing module. The integrated module can be implemented in hardware or as a software functional module. It should be noted that the module division in this application embodiment is illustrative and only represents one logical functional division; in actual implementation, there may be other division methods.
[0229] For example, Figure 7 shows a possible schematic diagram of the RAG device (i.e., RAG device 700) involved in the above embodiments. The actions performed by the RAG device 700 can be executed by a computing device or implemented by executing corresponding software through a computing device. The RAG device 700 may include: a receiving module 701, a first retrieval module 702, a second retrieval module 703, and an enhancement module 704.
[0230] For example, receiving module 701 is used to receive a natural language query statement. For example, S401 in Figure 4. First retrieval module 702 is used to obtain a first retrieval result from a non-relational database containing a natural language query statement. The non-relational database stores data fragments of at least one first file and at least one second file. The first file stores unstructured data, and the second file stores structured data. The first retrieval result includes data fragments of at least one target first file and / or data fragments of at least one target second file in the second file. For example, S401 in Figure 4. Second retrieval module 703, when the first retrieval result includes data fragments of the second file, uses a target structured query language (SQL) statement to obtain a second retrieval result from a relational database. The relational database stores structured data from at least one second file in at least one first data table. A target first data table in the at least one first data table stores structured data from the target second file. The target SQL statement queries target data in the target first data table that satisfies the retrieval conditions indicated by the natural language query statement. The second retrieval result includes the target data queried by the target SQL statement. For example, S401 in Figure 4. The enhancement module 704 is used to input a natural language query statement and target content into the generative model, so that the generative model can determine the target retrieval result of the natural language query statement based on the target content, wherein the target content includes the first retrieval result. For example, S401 shown in Figure 4.
[0231] Optionally, if the first search result includes data fragments of the first file, the target content also includes data fragments of the target first file.
[0232] Optionally, the target SQL statement is determined based on the natural language query statement and the target summary information of the target second file. The target summary information includes the table name and column names of the target second data table indicated by the target second file, which is used to store the structured data in the target second file.
[0233] Optionally, the target summary information may also include at least one of the following: the data type of at least one column of data in the target second data table or at least one data selected from at least one column of data.
[0234] Optionally, the target content also includes the target SQL statement and the target summary information of the target second file, wherein the target SQL statement and the target summary information of the target second file are used to determine the target retrieval results based on the target data in the target first data table.
[0235] Optionally, the first search result includes multiple data fragments, which include data fragments of the target first file and / or data fragments of the target second file. The first search result includes data fragments of the second file, which includes: N data fragments among the multiple data fragments including data fragments of the second file, and the relevance of each of the N data fragments to the natural language query statement is higher than the relevance of each of the multiple data fragments other than the N data fragments to the natural language query statement, where N is a positive integer greater than or equal to 1.
[0236] Optionally, the target content may also include data fragments of the target second file.
[0237] Optionally, the RAG device 700 also includes an output module 705, which is used to output the target retrieval results of the natural language query statement.
[0238] Optionally, the first search result includes the identifier of the target second document, and the second search module 703 is further configured to: determine the target summary information of the target second document from the summary information of at least one second document based on the identifier of the target second document.
[0239] Optionally, the first search result includes the identifier of the target second document and the identifier of the target second data table. The second search module 703 is further configured to: determine the target second document from at least one second document based on the identifier of the target second document; and determine the summary information of the target second data table from the summary information of at least one second data table of the target second document based on the identifier of the target second data table.
[0240] Optionally, the second retrieval module 703 is further configured to: determine target summary information of a target second document from the summary information of at least one second document according to the retrieval conditions indicated by the natural language query statement, wherein the target summary information of the target second document includes the retrieval conditions indicated by the natural language query statement.
[0241] Optionally, the enhancement module 704 is further configured to: input a natural language query statement and a data fragment of the target first file into the generation model when the first search result does not include data fragments of the second file but includes data fragments of the first file.
[0242] Optionally, the target second data table may be of any of the following types: vertical table, hierarchical table, complex table, or horizontal table.
[0243] For a detailed description of the above-mentioned optional methods, please refer to the foregoing method embodiments, which will not be repeated here. Furthermore, the explanation of any of the RAG devices 700 provided above and the description of their beneficial effects can be found in the corresponding method embodiments described above, which will not be repeated here.
[0244] In this application, the receiving module 701, the first retrieval module 702, the second retrieval module 703, the enhancement module 704, and the output module 705 can all be implemented in software or in hardware. For example, the implementation of the first retrieval module 702 will be described below. Similarly, the implementation of the receiving module 701, the second retrieval module 703, the enhancement module 704, and the output module 705 can refer to the implementation of the first retrieval module 702.
[0245] As an example of a software functional unit, the first retrieval module 702 may include code running on a computing instance. The computing instance may include at least one of a physical host (computing device), a virtual machine, and a container.
[0246] For example, in conjunction with the system architecture of Figures 1 and 2, the receiving module 701 may include a module in the server for receiving natural language query statements; the first retrieval module 702 may include a module in the server for obtaining retrieval results from a non-relational database; the second retrieval module 703 may include a module in the server for obtaining target SQL statements and for obtaining retrieval results from a relational database; the enhancement module 704 may include a module in the server for inputting target content and natural language query statements into the generative model; and the output module 705 may include a module in the server for outputting the target retrieval results of the natural language query statements.
[0247] For example, referring to the system architecture in Figure 3, when the RAG system includes a server, the receiving module 701 may include a module in the cloud management platform for receiving natural language query statements and a module in the server for receiving natural language query statements; the first retrieval module 702 may include a module in the server for obtaining retrieval results from a non-relational database; the second retrieval module 703 may include a module in the server for obtaining target SQL statements and for obtaining retrieval results from a relational database; the enhancement module 704 may include a module in the server for inputting target content and natural language query statements into the generative model; and the output module 705 may include a module in the server for outputting the target retrieval results of the natural language query statements and a module in the cloud management platform for outputting the target retrieval results of the natural language query statements.
[0248] For example, referring to the system architecture in Figure 3, in the case where the RAG system does not include a server, the receiving module 701 may include a module in the cloud management platform for receiving natural language query statements; the first retrieval module 702 may include a module in the cloud management platform for obtaining retrieval results from a non-relational database; the second retrieval module 703 may include modules in the cloud management platform for obtaining target SQL statements and for obtaining retrieval results from relational databases; the enhancement module 704 may include a module in the cloud management platform for inputting target content and natural language query statements into the generative model; and the output module 705 may include a module in the cloud management platform for outputting the target retrieval results of the natural language query statements.
[0249] Furthermore, the aforementioned computing instance can be one or more. For example, the first retrieval module 702 may include code running on multiple hosts / virtual machines / containers. It should be noted that the multiple hosts / virtual machines / containers used to run the code can be distributed within the same region or in different regions. Further, the multiple hosts / virtual machines / containers used to run the code can be distributed within the same availability zone (AZ) or in different AZs, each AZ comprising one or more geographically proximate data centers. Typically, a region may include multiple AZs.
[0250] Similarly, multiple hosts / virtual machines / containers used to run this code can be distributed within the same Virtual Private Cloud (VPC) or across multiple VPCs. Typically, a VPC is set up within a region. Communication between two VPCs within the same region, as well as between VPCs in different regions, requires a communication gateway to be set up within each VPC to enable interconnection between VPCs.
[0251] As an example of a hardware functional unit, the first retrieval module 702 may include at least one computing device, such as a server. Alternatively, the first retrieval module 702 may also be a device implemented using an application-specific integrated circuit (ASIC) or a programmable logic device (PLD). The PLD may be implemented using a complex programmable logical device (CPLD), a field-programmable gate array (FPGA), generic array logic (GAL), or any combination thereof.
[0252] For example, referring to the system architecture of Figures 1 and 2, the first retrieval module 702 may include a computing device running a server. Referring to the system architecture of Figure 3, if the RAG system includes a server, the first retrieval module 702 may include a computing device running a server. If the RAG system does not include a server, the first retrieval module 702 may include a computing device running a cloud management platform.
[0253] For example, the difference between the receiving module 701 and the output module 705 is that, in conjunction with the system architecture of Figure 3, when the RAG system includes a server, the receiving module 701 may include a computing device running a cloud management platform and a computing device running the server. Similarly, when the RAG system includes a server, the output module 705 may include a computing device running a cloud management platform and a computing device running the server.
[0254] It should be noted that the computing devices included in different modules of the RAG device 700 may be the same or different, and this application does not impose any restrictions on this.
[0255] The multiple computing devices included in the first retrieval module 702 can be distributed in the same region or in different regions. Similarly, the multiple computing devices included in the first retrieval module 702 can be distributed in the same Availability Zone (AZ) or in different AZs. Likewise, the multiple computing devices included in the first retrieval module 702 can be distributed in the same Virtual Private Cloud (VPC) or in multiple VPCs. These multiple computing devices can be any combination of computing devices such as servers, ASICs, PLDs, CPLDs, FPGAs, and GALs.
[0256] It should be noted that, in other embodiments, the receiving module 701 can be used to execute any step in the RAG method, the first retrieval module 702 can be used to execute any step in the RAG method, the second retrieval module 703 can be used to execute any step in the RAG method, the enhancement module 704 can be used to execute any step in the RAG method, and the output module 705 can be used to execute any step in the RAG method. The steps implemented by the receiving module 701, the first retrieval module 702, the second retrieval module 703, the enhancement module 704, and the output module 705 can be specified as needed. By implementing different steps in the RAG method through the receiving module 701, the first retrieval module 702, the second retrieval module 703, the enhancement module 704, and the output module 705, all functions of the data storage device can be realized.
[0257] This application also provides a computing device 800. As shown in FIG8, the computing device 800 includes: a bus 802, a processor 804, a memory 806, and a communication interface 808. The processor 804, the memory 806, and the communication interface 808 communicate with each other via the bus 802. The computing device 800 may be a server or a terminal device. It should be understood that this application does not limit the number of processors and memories in the computing device 800.
[0258] Bus 802 can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of illustration, only one line is used in Figure 8, but this does not imply that there is only one bus or one type of bus. Bus 802 can include pathways for transmitting information between various components of computing device 800 (e.g., memory 806, processor 804, communication interface 808).
[0259] Processor 804 may include any one or more processors such as a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).
[0260] The memory 806 may include volatile memory, such as random access memory (RAM). The processor 804 may also include non-volatile memory, such as read-only memory (ROM), flash memory, hard disk drive (HDD), or solid state drive (SSD).
[0261] The memory 806 stores executable program code, which the processor 804 executes to implement the functions of the aforementioned receiving module 701, first retrieval module 702, second retrieval module 703, enhancement module 704, and output module 705, thereby realizing the RAG method. In other words, the memory 806 stores instructions for executing the RAG method.
[0262] The communication interface 808 uses transceiver modules, such as, but not limited to, network interface cards and transceivers, to enable communication between the computing device 800 and other devices or communication networks.
[0263] For example, the computing device 800 described above can be a device that deploys the server, non-relational database, relational database, and generative model shown in Figures 1 to 3. For example, the computing device 800 can also be a device that deploys the cloud management platform shown in Figure 3.
[0264] This application also provides a computing device cluster. The computing device cluster includes at least one computing device. The computing device can be a server, such as a central server, an edge server, or a local server in a local data center. In some embodiments, the computing device can also be a terminal device such as a desktop computer, a laptop computer, or a smartphone.
[0265] As shown in Figure 9, the computing device cluster 900 includes at least one computing device 800. The memory 806 of one or more computing devices 800 in the computing device cluster may store the same instructions for executing the RAG method.
[0266] In some possible implementations, the memory 806 of one or more computing devices 800 in the computing device cluster may also store partial instructions for executing the RAG method. In other words, a combination of one or more computing devices 800 can jointly execute the instructions for executing the RAG method.
[0267] It should be noted that the memories 806 in different computing devices 800 within the computing device cluster can store different instructions, each used to execute a portion of the functions of the RAG device. That is, the instructions stored in the memories 806 of different computing devices 800 can implement the functions of one or more modules among the receiving module 701, the first retrieval module 702, the second retrieval module 703, the enhancement module 704, and the output module 705.
[0268] In some possible implementations, one or more computing devices in a computing device cluster can be connected via a network. This network can be a wide area network (WAN) or a local area network (LAN), etc. Figure 10 illustrates one possible implementation. As shown in Figure 10, two computing devices, 800A and 800B, are connected via a network. Specifically, they are connected to the network through communication interfaces in each computing device.
[0269] In this type of possible implementation, the memory 806 in computing device 800A stores instructions for executing the functions of receiving module 701 and output module 705. Meanwhile, the memory 806 in computing device 800B stores instructions for executing the functions of first retrieval module 702, second retrieval module 703, and enhancement module 704.
[0270] The connection method between the computing device clusters shown in Figure 10 can be considered as follows: taking into account that the RAG method provided in this application requires a large amount of computation, the functions of the first retrieval module 702, the second retrieval module 703, and the enhancement module 704 are to be performed by the computing device 800B.
[0271] It should be understood that the functions of computing device 800A shown in Figure 10 can also be performed by multiple computing devices 800. Similarly, the functions of computing device 800B can also be performed by multiple computing devices 800.
[0272] This application also provides another computing device cluster. The connection relationship between the computing devices in this computing device cluster can be similarly referred to the connection method of the computing device cluster shown in Figures 9 and 10. The difference is that the memory 806 of one or more computing devices 800 in this computing device cluster can store the same instructions for executing the RAG method.
[0273] In some possible implementations, the memory 806 of one or more computing devices 800 in the computing device cluster may also store partial instructions for executing the RAG method. In other words, a combination of one or more computing devices 800 can jointly execute the instructions for executing the RAG method.
[0274] This application also provides a processor that can be used to perform the above-described methods.
[0275] This application also provides a chip, including: a processor and a power supply circuit; the power supply circuit can be used to supply power to the processor; the processor can be used to perform the above-described methods.
[0276] This application also provides a computing device, which may include a processor, a memory, and a computer program / instructions stored in the memory; the processor executes the computer program / instructions to enable the computing device to implement the above-described method.
[0277] This application also provides a computing device cluster, which includes at least one computing device; each computing device includes a processor, a memory, and computer programs / instructions stored in the memory, wherein the processor of each computing device executes the computer programs / instructions stored in the memory of each computing device to enable each computing device to implement the above-described method.
[0278] This application also provides a computer program product. The computer program product includes a computer program / instructions, which are software or program products capable of running on a computing device or stored on any usable medium. When the computer program / instructions are executed on at least one computing device, the at least one computing device can perform the methods described above.
[0279] This application also provides a computer-readable storage medium, which can be any available medium capable of being stored by a computing device or a data storage device such as a data center containing one or more available media. The computer-readable storage medium stores a computer program / instructions that, when executed on at least one computing device, enable the at least one computing device to perform the described method.
[0280] For example, the available media may be magnetic media (e.g., floppy disks, magnetic disks, magnetic tapes), optical media (e.g., digital video discs (DVDs)), or semiconductor media (e.g., solid-state drives (SSDs)).
[0281] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the protection scope of the technical solutions of the embodiments of the present invention.
Claims
1. A retrieval augmented generation (RAG) method, comprising: The method includes: Receive natural language query statements; The first retrieval result of the natural language query statement is obtained from a non-relational database, wherein the non-relational database is used to store data fragments of at least one first file and at least one second file, the first file is used to store unstructured data, the second file is used to store structured data, and the first retrieval result includes data fragments of the target first file in the at least one first file and / or data fragments of the target second file in the at least one second file; If the first search result includes data fragments of the second file, a second search result is obtained from a relational database using a target structured query language (SQL) statement. The relational database stores structured data from the at least one second file in at least one first data table. A target first data table in the at least one first data table stores structured data from the target second file. The target SQL statement queries the target data in the target first data table that satisfies the search conditions indicated by the natural language query statement. The second search result includes the target data retrieved by the target SQL statement. The natural language query statement and target content are input into the generative model so that the generative model determines the target retrieval result of the natural language query statement based on the target content, wherein the target content includes the second retrieval result.
2. The method according to claim 1, characterized in that, If the first search result includes data fragments of the first file, the target content also includes data fragments of the target first file.
3. The method according to claim 1 or 2, characterized in that, The target SQL statement is determined based on the natural language query statement and the target summary information of the target second file. The target summary information includes the table name and column names of the target second data table indicated by the target second file. The target second data table is used to store the structured data in the target second file.
4. The method according to claim 3, characterized in that, The target summary information also includes at least one of the following: the data type of at least one column of data in the target second data table or at least one data selected from the at least one column of data.
5. The method according to claim 3 or 4, characterized in that, The target content also includes the target SQL statement and the target summary information, wherein the target SQL statement and the target summary information are used to determine the target retrieval result based on the target data in the target first data table.
6. The method according to any one of claims 1-5, characterized in that, The first search result includes multiple data fragments, which include data fragments of the target first file and / or data fragments of the target second file. The first search result including data fragments of the second file includes: N data fragments of the multiple data fragments including data fragments of the second file, and the relevance of each of the N data fragments to the natural language query statement is higher than the relevance of each of the multiple data fragments other than the N data fragments to the natural language query statement, where N is a positive integer greater than or equal to 1.
7. The method according to any one of claims 1-6, characterized in that, The target content also includes data fragments of the target second file.
8. The method according to any one of claims 1-7, characterized in that, The method further includes: Output the target retrieval results of the natural language query statement.
9. A RAG device, characterized by include: The receiving module is used to receive natural language query statements; The first retrieval module is used to obtain the first retrieval result of the natural language query statement from a non-relational database, wherein the non-relational database is used to store data fragments of at least one first file and at least one second file, the first file is used to store unstructured data, the second file is used to store structured data, and the first retrieval result includes data fragments of the target first file in the at least one first file and / or data fragments of the target second file in the at least one second file; The second retrieval module is used to retrieve a second retrieval result from a relational database using a target structured query language (SQL) statement when the first retrieval result includes data fragments of the second file. The relational database stores structured data from the at least one second file in at least one first data table. A target first data table in the at least one first data table stores structured data from the target second file. The target SQL statement queries target data in the target first data table that satisfies the retrieval conditions indicated by the natural language query statement. The second retrieval result includes the target data retrieved by the target SQL statement. An enhancement module is used to input the natural language query statement and target content into the generative model, so that the generative model determines the target retrieval result of the natural language query statement based on the target content, wherein the target content includes the second retrieval result.
10. The apparatus according to claim 9, characterized in that, If the first search result includes data fragments of the first file, the target content also includes data fragments of the target first file.
11. The apparatus according to claim 9 or 10, characterized in that, The target SQL statement is determined based on the natural language query statement and the target summary information of the target second file. The target summary information includes the table name and column names of the target second data table indicated by the target second file. The target second data table is used to store the structured data in the target second file.
12. The apparatus according to claim 11, characterized in that, The target summary information also includes at least one of the following: the data type of at least one column of data in the target second data table or at least one data selected from the at least one column of data.
13. The apparatus according to claim 11 or 12, characterized in that, The target content also includes the target SQL statement and the target summary information, wherein the target SQL statement and the target summary information are used to determine the target retrieval result based on the target data in the target first data table.
14. The apparatus according to any one of claims 9-13, characterized in that, The first search result includes multiple data fragments, which include data fragments of the target first file and / or data fragments of the target second file. The first search result including data fragments of the second file includes: N data fragments of the multiple data fragments including data fragments of the second file, and the relevance of each of the N data fragments to the natural language query statement is higher than the relevance of each of the multiple data fragments other than the N data fragments to the natural language query statement, where N is a positive integer greater than or equal to 1.
15. The apparatus according to any one of claims 9-14, characterized in that, The target content also includes data fragments of the target second file.
16. The apparatus of any one of claims 9-15, wherein, The RAG device further includes an output module, which is used for: Output the target retrieval results of the natural language query statement.
17. A cluster of computing devices, characterized in that, The computing device cluster includes at least one computing device; Each of the at least one computing device includes a processor, a memory, and a computer program / instructions stored in the memory; The processor of each computing device executes computer programs / instructions stored in the memory of each computing device to enable each computing device to implement the method as described in any one of claims 1-8.
18. A computer program product, characterized in that, The computer program product includes a computer program / instruction, which, when executed by a computing device, implements the method as described in any one of claims 1-8.
19. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program / instruction, which, when executed by a computing device, implements the method as described in any one of claims 1-8.
