Agent-based SAAS platform data retrieval method and system

By extracting and completing key entities from user input, and combining vector retrieval and reordering models, the problem of query failures caused by fuzzy or incomplete user input in existing technologies is solved. This enables cross-table joint queries and improves the accuracy and stability of natural language queries.

CN120804146AInactive Publication Date: 2025-10-17QINGTA TECH
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202511335415.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-09-18
Publication Date
2025-10-17
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Existing methods struggle to handle ambiguous, incomplete, or unfamiliar user input, leading to query failures or inaccurate results. Furthermore, the lack of cross-table join capabilities limits the applicability and stability of natural language queries in real-world, complex business scenarios.

Method used

By acquiring users' natural language query requests, extracting key entities and performing semantic completion, and combining vector retrieval and re-ranking models to match candidate tables in the knowledge base, iteratively retrieving supplementary table information, and generating and correcting SQL query statements, the results are ensured to be consistent with the user's intent.

Benefits of technology

It improves the ability to handle fuzzy or incomplete input, enhances the accuracy of queries when users lack field knowledge, improves the ability to perform cross-table join queries, and enhances the applicability and stability of natural language queries in complex business scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120804146A_ABST
    Figure CN120804146A_ABST
Patent Text Reader

Abstract

The invention provides an Agent-based SAAS (Software as a Service) platform data retrieval method and system, and relates to the technical field of data retrieval, the method comprises the following steps: obtaining a natural language query request of a user, and judging whether the natural language query request is related to database query; if not, calling an external language model to generate a response result and terminating the process; if yes, key entities are extracted, semantic completion is carried out, and structured data are generated; retrieving in a knowledge base through a vector retrieval model and a reordering model based on the data to obtain a candidate table set, and screening out a most matched target table; further judging whether cross-table query is involved or not, if yes, iterating the supplementary table, and if not, generating an SQL statement based on the target table and the structured data; executing statement query in the database and correcting according to the execution condition until an effective result is obtained; and finally, checking and semantic interpretation are carried out on the query result, and a response result consistent with the natural language query request semantically is output to the user.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of data retrieval, in particular to an Agent-based SAAS platform data retrieval method and system. BACKGROUND

[0002] With the rapid development of information technology, especially the continuous breakthrough of big data and artificial intelligence, more and more industries have begun to rely on data-driven decision support systems. In the field of university data, through the accumulation and integration of multi-dimensional information such as teacher library, paper library, and patent library, the SAAS (Software as a Service) platform provides users with convenient data query and analysis capabilities. However, how to enable ordinary users to interact with the system through natural language without mastering database language or complex operations has become a core problem that needs to be solved in the industry.

[0003] Currently, there are some methods and products of natural language query database (NL2SQL, Chat2SQL) have appeared. This kind of method usually converts the user's natural language question into SQL query statement directly through large language model (LLM), and the SQL can be executed correctly in the backend database and return the result by default. In the front-end display of the table structure of the database, the user is guided to ask questions based on the table structure, so as to complete data retrieval and query. In the single-table query scene, this kind of tool has initially shown certain practicality and convenience.

[0004] However, the existing method usually directly converts the user's natural language into SQL, which is difficult to deal with the situation that the user's input is fuzzy, incomplete or lacks knowledge of the database field, resulting in query failure or result deviation. At the same time, the existing method mostly only supports single-table retrieval, lacks cross-table joint query capability, and seriously limits the applicability and stability of natural language query in real complex business scenarios. SUMMARY

[0005] In view of the above deficiencies of the prior art, the purpose of the embodiments of the present application is to provide an Agent-based SAAS platform data retrieval method, which can solve the technical problems that the existing method usually directly converts the user's natural language into SQL, which is difficult to deal with the situation that the user's input is fuzzy, incomplete or lacks knowledge of the database field, resulting in query failure or result deviation. At the same time, the existing method mostly only supports single-table retrieval, lacks cross-table joint query capability, and seriously limits the applicability and stability of natural language query in real complex business scenarios.

[0006] The first aspect of the embodiments of the present application proposes an Agent-based SAAS platform data retrieval method, comprising: S1: obtaining a natural language query request of a user; S2: analyze whether the natural language query request is related to a database query; if yes, proceed to the next step; otherwise, determine that it is an irrelevant query, call an external language model to generate a response result and terminate the process; S3: extract the key entities of the natural language query request, and complete the semantics of the key entities to generate structured data; S4: based on the field information in the structured data, retrieve in a preset knowledge base through a vector retrieval model and a reordering model to obtain a candidate table set; S5: select a target table from the candidate table set that best matches the natural language query request; S6: determine whether the natural language query request involves cross-table queries; if yes, return to S4 to iteratively retrieve supplementary table information until the requirements are met; otherwise, based on the target table, the structured data, and the natural language query request, generate an SQL query statement and proceed to the next step; S7: execute the SQL query statement in the database and determine whether the retrieval is successful; if yes, obtain the query result and proceed to the next step; otherwise, modify the SQL query statement and retrieve again; S8: verify and semantically interpret the query result to generate a response result consistent with the semantics of the natural language query request and return it to the user.

[0007] In a second aspect of the embodiments of the application, an Agent-based SAAS platform data retrieval system is provided, comprising a processor and a memory. The memory stores programs or instructions executable on the processor, and the programs or instructions, when executed by the processor, implement the steps of the Agent-based SAAS platform data retrieval method according to the first aspect.

[0008] In a third aspect of the embodiments of the application, a readable storage medium is provided, and the readable storage medium stores programs or instructions, and the programs or instructions, when executed by a processor, implement the steps of the Agent-based SAAS platform data retrieval method according to the first aspect.

[0009] The technical solutions provided by the embodiments of the application have at least the following beneficial effects: In the embodiment of the present application, the key entity extraction and semantic completion are performed on the user input, and the vector retrieval and reordering model are combined to match the candidate table, thereby improving the processing capability of the fuzzy or incomplete input, enhancing the query accuracy of the system in the case that the user does not have field cognition; meanwhile, in the case that the query involves multiple tables, the system can iteratively retrieve and supplement the related table, and combine the SQL correction and result semantic explanation, thereby improving the cross-table joint query capability and enhancing the applicability and stability of the natural language query in the complex business scenario. BRIEF DESCRIPTION OF DRAWINGS

[0010] The accompanying drawings, which are included to provide a further understanding of the application and are incorporated in and constitute a part of this application, illustrate embodiments of the application and together with the description serve to explain the principles of the application. In the drawings:

[0011] Figure 1 is a flowchart of an Agent-based SAAS platform data retrieval method provided by an embodiment of the present application; Figure 2 is a structural diagram of an Agent-based SAAS platform data retrieval system provided by an embodiment of the present application. DETAILED DESCRIPTION

[0012] In order for those skilled in the art to better understand the technical solutions in the embodiments of the present application, the technical solutions of the present application will be described clearly and completely below in conjunction with the drawings. Obviously, the described embodiments are only some of the embodiments of the present application, rather than all the embodiments. It should be understood that these descriptions are only exemplary, and are not used to limit the scope of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without creative labor should fall within the scope of protection of the present application.

[0013] The Agent-based SAAS platform data retrieval method provided by the embodiments of the present application will be described in detail below in conjunction with the drawings and specific embodiments and application scenarios.

[0014] Reference is made to the accompanying drawings Figure 1 , which shows a flowchart of an Agent-based SAAS platform data retrieval method provided by an embodiment of the present application.

[0015] The Agent-based SAAS platform data retrieval method provided by the embodiments of the present application can include the following steps: S1: Obtain a natural language query request of a user.

[0016] wherein the natural language query request refers to a data retrieval requirement proposed by a user to a system in a daily language manner, rather than using a professional database syntax or an SQL statement. The request usually contains ambiguous, incomplete or colloquial expressions, such as abbreviations, time periods, idioms, etc., and the user does not need to understand the table structure and field definition of the underlying database.

[0017] S2: analyze whether the natural language query request is related to the database query. If yes, proceed to the next step. Otherwise, determine that it is an irrelevant query, call an external language model to generate a response result and terminate the process.

[0018] In one possible implementation, S2 specifically includes: S201: input the natural language query request into a pre-set language model, and classify the natural language query request based on a pre-set prompt word, the classification including a relevant category number and an irrelevant category number.

[0019] S202: when the output of the language model is the relevant category number, determine that the natural language query request is a relevant request, and proceed to S3.

[0020] S203: when the output of the language model is the irrelevant category number, determine that the natural language query request is an irrelevant request, call an external language model to generate a response result to terminate the process.

[0021] For example, when the LLM returns 1, 2 or 3, it is relevant, and when it is determined to be relevant, proceed to the next step. When the LLM returns 4, it is irrelevant, and when it is determined to be irrelevant, we call an external LLM to answer the user's question. The process ends.

[0022] wherein the LLM is a language model.

[0023] In the embodiments of the present application, by determining the relevance of the natural language query request early in the process, irrelevant inputs can be quickly filtered out, avoiding the subsequent complex parsing, retrieval and SQL generation process, thereby reducing unnecessary calculation and resource consumption. At the same time, relevant requests and irrelevant requests are diverted, so that the system can focus on solving database query problems, and can also handle more extensive natural language interaction scenarios through external models, thereby enhancing the versatility and expansion capability of the system.

[0024] S3: extract the key entity of the natural language query request, and complete the semantics of the key entity to generate structured data.

[0025] The key entity refers to a core element extracted from the natural language query request of the user, for example, a school name, a major name, a time interval, an index field, and the like. These elements often directly determine the range and target of the query, and are the basis for converting fuzzy natural language into an executable database statement.

[0026] In a possible implementation, S3 specifically includes: S301: parsing the natural language query request through a language model to extract key entities including names, time intervals, and target index fields.

[0027] S302: performing semantic completion and standardization processing on the key entities to complete abbreviations, acronyms, or fuzzy expressions into standardized names.

[0028] S303: generating structured data based on the key entities after completion and standardization processing.

[0029] For example, by analyzing the key entities (such as universities, teachers, rankings, and the like) in the query, a separate LLM is used to perform the task to disassemble the natural language input of the user. For example, the key dimension information such as “Tsinghua University” and “2021-2025” is disassembled. Note that this step also extracts the corresponding index table, such as “QS ranking”. At the same time, the LLM completes the extracted units. For example, “Tsinghua” input by the user is completed as “Tsinghua University”. The LLM outputs a JSON with the following structure. {“univ”: ”Tsinghua University”,“year”: [2021,2025],“table”:[“QS ranking”]}.

[0030] In the embodiments of the present application, by disassembling the natural language request and extracting the key entities, the user's fuzzy or brief expressions can be converted into clear field information, avoiding query errors caused by unclear semantics, thereby significantly improving the accuracy of database retrieval. At the same time, the extracted and completed key entities are converted into structured data, which not only facilitates subsequent processing and calling of the system, but also provides a clear input basis for vector retrieval, table matching, and SQL generation, ensuring the coherence and scalability of the entire process.

[0031] S4: based on the field information in the structured data, through a vector retrieval model and a reordering model, searching in a preset knowledge base to obtain a candidate table set.

[0032] The vector retrieval model refers to vectorizing the target fields or key entities in the structured data and performing similarity calculation with the vectors of table fields or table descriptions in the knowledge base, so as to quickly filter out the candidate table set closest to the user's query semantics.

[0033] The reordering model is based on the initial candidate table set, and the semantic relevance between each candidate table and the user query is calculated and scored more finely, and the candidate tables are sorted according to the relevance score, so as to filter out the optimal candidate results.

[0034] In a possible implementation, S4 specifically includes: S401: Vectorizing encoding the target field in the structured data to obtain a target field vector.

[0035] S402: Based on the target field vector, similarity retrieval is performed in the knowledge base through a vector retrieval model to obtain an initial candidate table set.

[0036] S403: Calculate the semantic relevance score of each candidate table in the initial candidate table set, and based on the semantic relevance score, reorder each candidate table in the initial candidate table set through a reordering model, and select the top five candidate tables to form a candidate table set.

[0037] Optionally, the reordering model selects a Rerank model.

[0038] The Rerank model is a model for fine sorting of initial retrieval results, and its core function is to further calculate the semantic relevance score between the candidate and the user query based on the candidate set obtained by vector retrieval, and reorder the candidate results according to the score.

[0039] Specifically, we establish a knowledge base, which includes the table name and field of all index tables (the large model subsequently retrieves the corresponding table name and field through the knowledge base). Then, we use the self-provided knowledge base. In terms of retrieval method, we use the Rerank model, take all Rerank scores higher than 0.5, and select the top 5 results according to the score as optional items.

[0040] For example, taking the retrieval condition "QS ranking" as an example, the returned tables may include "QS university ranking", "QS sustainable university ranking", "QS university discipline ranking", etc. According to the previous output, it is a list [ref1, ref2, ref3, ref4, ref5]. Then, check the information of the table that best matches the user query in the top 5 results.

[0041] In the embodiments of the present application, the user input often has abbreviations, synonyms or incomplete expressions, and only vector retrieval may deviate. By introducing the Rerank model, the semantic relevance of the candidate table and the query statement can be analyzed more deeply, and the processing capability of the system for complex or ambiguous input is enhanced. At the same time, the vector retrieval model can quickly find a candidate table similar to the query semantics in a large-scale knowledge base, ensuring a high recall rate; and the Rerank model further refines the sorting of the candidate table, ensuring that the final selected result is highly consistent with the user's intention, so as to balance the coverage and accuracy.

[0042] S5: screening the target table most matched with the natural language query request from the candidate table set.

[0043] Among them, the target table refers to the data table most matched and most relevant to the user query selected by the system from the database or knowledge base according to the semantic information of the user input in the natural language query process.

[0044] In a possible implementation, S5 specifically includes: S501: matching the semantic relevance between each candidate table in the candidate table set and the natural language query request through the language model, and calculating the matching score.

[0045] S502: taking the candidate table with the highest matching score in the candidate table set as the target table.

[0046] In the embodiments of the present application, the language model is used to match and score the semantic relevance between the candidate table and the natural language request at the semantic level, which can avoid the deviation caused by simply relying on keywords or field names, so as to more accurately lock the table corresponding to the user's real intention.

[0047] S6: judging whether the natural language query request involves cross-table query. If yes, returning to S4 to iteratively retrieve supplementary table information until the requirement is met. Otherwise, generating an SQL query statement based on the target table, structured data and the natural language query request, and entering the next step.

[0048] Specifically, for quick judgment, we use a separate LLM to perform this task. The large model makes judgments based on the semantics of the user's question. Take two examples. Ex1: I want to know the QS ranking of a certain university in 2025. Ex2: I want to know what outstanding performance a certain person has in 2025. It can be found that in the first example, we only need to check

a certain university

[2025]

QS ranking

talent cultivation

faculty situation

international ranking

[0049] For accurate judgment, the LLM returns a table list. According to the number of table lists and the executed query, loop iteration is performed. If the query has been covered, otherwise use the unretrieved statement, repeat the retrieval step. The table list is the table field in the structured data output in the previous step, and the set of index table names involved in the user query. Query refers to the single index table name to be retrieved in the table list. In the loop, elements in the table list are selected as the current query one by one.

[0050] In the embodiments of the present application, in the face of requests with ambiguous or abstract semantics (such as "outstanding performance"), the large model can dynamically infer multiple dimensions and tables that may be involved in combination with the existing knowledge base, implement queries closer to user intent, and improve the system's understanding ability of diversified inputs. At the same time, by supplementing the tables not covered through loop iteration, it can ensure that all key information involved in the user query is retrieved, improve the comprehensiveness and accuracy of the results, and avoid missing important data.

[0051] In one possible implementation, S6 generating the SQL query statement specifically includes: Based on the target table and the field information in the structured data, the natural language query request is parsed to determine the query condition and output field.

[0052] Based on the target table, the output field and the query condition, an initial SQL query statement is generated.

[0053] In the case of error information, the initial SQL query statement is corrected according to the error information, and a SQL query statement conforming to the database syntax specification is generated.

[0054] In the embodiment of the present application, the target table, field information and structured data are combined when generating the SQL statement, which can ensure that the query condition and output field are consistent with the user's intention, and avoid generating a statement that does not match the database structure. At the same time, when an error occurs, the system can automatically correct the initial SQL statement according to the error information, enhance the adaptability to database differences and syntax problems, and reduce the query failure.

[0055] S7: performing retrieval of the SQL query statement in the database, and judging whether the retrieval is successful. If yes, obtaining the query result, and entering the next step. Otherwise, correcting the SQL query statement and re-retrieving.

[0056] In a possible implementation, the step of correcting the SQL query statement and re-retrieving in S7 specifically includes: S701: obtaining an error type of the SQL query statement execution failure, wherein the error type includes a cross-table operation not finding a corresponding table and a current table operation not finding a corresponding field.

[0057] S702: in the case of the error type being the cross-table operation not finding the corresponding table, obtaining a full table name of the database, matching the missing table name through string similarity, and judging whether the table name is matched successfully. If yes, correcting the current SQL query statement, and entering S704. Otherwise, generating an alarm information to prompt an administrator to supplement a note for the table or update a knowledge base.

[0058] In the embodiment of the present application, different error types are processed differently, for example, the table name is completed through string similarity matching when the table is missing, and the field is automatically corrected through the language model when the field is missing, which enhances the self-adaptation and self-healing ability of the system in the face of abnormal situations.

[0059] S703: in the case of the error type being the current table operation not finding the corresponding field, inputting the error information into the language model, automatically correcting the field, and correcting the current SQL query statement, and entering S704.

[0060] S704: re-executing retrieval of the corrected SQL query statement, and in the case of successful retrieval, entering S8. Otherwise, entering S705.

[0061] S705: in the case of the number of continuous corrections reaching a preset number of times, triggering a platform alarm to notify an administrator to intervene.

[0062] In the embodiment of the present application, the error type of the SQL execution failure is automatically identified and corrected, which can quickly recover the query process without human intervention, and improve the success rate of SQL execution.

[0063] S8: checking and semantic interpretation of the query result, generating a response result consistent with the semantics of the natural language query request, and returning to the user.

[0064] In a possible implementation, the query result includes: a response result consistent with the semantics of the natural language query request and no relevant data. S8 further includes: In the case of no relevant data in the query result, a prompt information that the retrieval result is no relevant data is generated and sent to the user.

[0065] In the embodiment of the application, the query result is checked and semantically interpreted, so that the returned content is consistent with the semantics of the user query, complex database results can be converted into intuitive and easy-to-understand natural language expressions, the accuracy and understandability of the results are improved, prompt information is generated when there is no relevant data, empty results or errors are avoided, the robustness of the system is enhanced, and the user experience is improved.

[0066] The technical scheme provided by the embodiment of the application has at least the following beneficial effects: In the embodiment of the application, the key entity extraction and semantic completion are performed on the user input, and the vector retrieval and reordering model are combined to match the candidate table, so that the processing capability of fuzzy or incomplete input is improved, the query accuracy of the system in the case where the user does not have field cognition is enhanced, and in the case where it is identified that the query involves multiple tables, the system can iteratively retrieve and supplement the relevant table, and combine the SQL correction and result semantic interpretation, so that the ability of cross-table joint query is improved, and the applicability and stability of the natural language query in the complex business scenario are improved.

[0067] Reference is made to the accompanying drawings Figure 2 The accompanying drawings show a structure schematic diagram of an Agent-based SAAS platform data retrieval system provided by the embodiment of the application.

[0068] The embodiment of the application provides an Agent-based SAAS platform data retrieval system 20, which comprises a processor 201 and a memory 202. The memory 202 stores programs or instructions that can run on the processor 201. When the programs or instructions are executed by the processor 201, the steps of the Agent-based SAAS platform data retrieval method described above are implemented, and the same technical effects can be achieved. To avoid repetition, the application will not be described again.

[0069] It is to be understood that the processor 201 in the embodiments of the present application can be a central processing unit (CPU), and can also be other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic components, discrete hardware components, etc. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor.

[0070] It is also to be understood that the memory 202 in the embodiments of the present application can be a volatile memory or a non-volatile memory, or can include both volatile and non-volatile memory. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically EPROM (EEPROM) or a flash memory. The volatile memory can be a random access memory (RAM) used as an external cache. By way of example, but not limitation, many forms of random access memory (RAM) are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchlink dynamic random access memory (SLDRAM) and direct rambus RAM (DR RAM).

[0071] The above-described embodiments can be implemented in whole or in part by software, hardware (e.g., circuitry), firmware, or any combination of the three. When implemented in software, the above-described embodiments can be implemented in the form of one or more computer programs that are stored in a computer-readable storage medium. The computer-readable storage medium stores one or more computer instructions or computer programs that, when loaded into a computer, cause the computer to perform the processes or functions described in the embodiments of the present application. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable apparatus. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium, such as from a website, a computer, a server, or a data center to another website, computer, server, or data center, via a wired (e.g., infrared, wireless, microwave, etc.) manner. The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server, data center, etc. that contains one or more collections of available media. The available media can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium. The semiconductor medium can be a solid-state disk.

[0072] It should be understood that the size of the sequence number of each process described above in various embodiments of the present application does not mean the order of execution, and the execution order of each process should be determined by its function and inherent logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0073] Those of ordinary skill in the art can realize that the units and algorithm steps of the examples described in conjunction with the embodiments disclosed herein can be realized in electronic hardware or a combination of computer software and electronic hardware. Whether the functions are realized in hardware or software depends on the specific application and design constraints of the technical solution. Those of ordinary skill 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 the present application.

[0074] Those of ordinary skill in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described devices, apparatuses, and units can refer to the corresponding processes in the foregoing method embodiments, which will not be described here.

[0075] In several embodiments provided by the present application, it should be understood that the disclosed devices, apparatuses and methods can be implemented in other manners. For example, the embodiments of the apparatus described above are merely schematic. For example, the division of the units is only a logical function division. There can be another division manner for the actual implementation. For example, a plurality of units or components can be combined or integrated into another device, or some features can be ignored or not executed. In addition, the displayed or discussed mutual couplings or direct couplings or communication connections can be indirect couplings or communication connections through some interfaces, devices or units, and can be in electrical, mechanical or other forms.

[0076] The units described as separate components can or can not be physically separate, and the components shown as units can or can not be physical units, i.e., can be located in one place, or can be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the embodiment.

[0077] In addition, each functional unit in the various embodiments of the present application can be integrated into a processing unit, or each unit can exist physically, or two or more units can be integrated into one unit.

[0078] If the functions are realized in the form of software function units and sold or used as independent products, they can be stored in a computer readable storage medium. Based on this understanding, the technical solutions of the present application essentially or the part of the prior art that contributes to the technical solutions or part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and various media that can store program codes.

[0079] The embodiment of the present application provides a readable storage medium, which includes: a program or instruction stored on the readable storage medium, the program or instruction is executed by a processor to realize the steps of the Agent-based SAAS platform data retrieval method described above, and the same technical effect can be achieved. To avoid repetition, the present application will not be described again.

[0080] It should be pointed out finally that the above embodiments are only used to illustrate the technical solutions of the embodiments of the present application, but not to limit them. Although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those skilled in the art that the technical solutions recorded in the foregoing embodiments can be modified, or some technical features can be replaced equivalently; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application. Any changes or replacements that can be easily thought of by those skilled in the art within the technical scope disclosed by the present application should be covered within the protection scope of the present application.

Claims

1. A data retrieval method for SAAS platform based on Agent, characterized in that: include: S1: Obtain the user's natural language query request; S2: Analyze whether the natural language query request is related to a database query; If yes, go to the next step; Otherwise, it is determined to be an irrelevant query, and the external language model is called to generate a response result and terminate the process; S3: extracting key entities from the natural language query request, and completing semantics of the key entities to generate structured data; S4: Based on the field information in the structured data, a vector retrieval model and a re-ranking model are used to search in a preset knowledge base to obtain a set of candidate tables; S5: Filtering out a target table that best matches the natural language query request from the candidate table set; S6: Determine whether the natural language query request involves a cross-table query; if so, return to S4 to iteratively retrieve supplementary table information until the requirements are met; otherwise, generate an SQL query statement based on the target table, the structured data, and the natural language query request, and proceed to the next step; S7: Execute the SQL query statement in the database and determine whether the search is successful; if so, obtain the query results and proceed to the next step; otherwise, modify the SQL query statement and search again; S8: Verify and semantically interpret the query result, generate a response result that is semantically consistent with the natural language query request, and return it to the user.

2. The data retrieval method based on the SAAS platform of claim 1, characterized in that: The S2 specifically includes: S201: Inputting the natural language query request into a preset language model, and classifying the natural language query request into categories based on preset prompt words, wherein the categories include relevant category numbers and irrelevant category numbers; S202: When the output of the language model is the relevant category number, the natural language query request is determined to be a relevant request, and the process proceeds to S3; S203: When the language model output is the irrelevant category number, the natural language query request is determined to be an irrelevant request, and the external language model is called to generate a response result to terminate the process.

3. The data retrieval method based on the SAAS platform of claim 1, characterized in that: The S3 specifically includes: S301: Parsing the natural language query request using a language model to extract key entities including name, time interval, and target indicator fields; S302: Perform semantic completion and standardization processing on the key entity, completing the abbreviation, abbreviation or ambiguous expression into a standardized name; S303: Generate the structured data based on the completed and standardized key entities.

4. The data retrieval method based on the SAAS platform of claim 1, characterized in that: The S4 specifically includes: S401: performing vectorized encoding on a target field in the structured data to obtain a target field vector; S402: Based on the target field vector, similarity search is performed in the knowledge base using the vector search model to obtain an initial candidate table set; S403: Calculate the semantic relevance score of each candidate table in the initial candidate table set, and based on the semantic relevance score, sort each candidate table in the initial candidate table set in descending order using the reordering model to screen out the top five candidate tables to form the candidate table set.

5. The data retrieval method of SAAS platform based on Agent according to claim 1, characterized in that: The S5 specifically includes: S501: Matching the semantic relevance between each candidate table in the candidate table set and the natural language query request using a language model, and calculating a matching score; S502: The candidate table with the highest matching score in the candidate table set is used as the target table.

6. The data retrieval method based on the SAAS platform of claim 1, characterized in that: The step S6 of generating the SQL query statement specifically includes: Parsing the natural language query request based on the target table and field information in the structured data to determine query conditions and output fields; Generate an initial SQL query statement based on the target table, the output field and the query condition; In the case that error information exists, the initial SQL query statement is modified according to the error information, and the SQL query statement that complies with the database syntax specification is generated in combination.

7. The data retrieval method of SAAS platform based on Agent according to claim 1, characterized in that: The step of correcting the SQL query statement and re-searching in S7 specifically includes: S701: Obtaining the error type of the SQL query statement execution failure, wherein the error type includes a cross-table operation failing to find a corresponding table and a current table operation failing to find a corresponding field; S702: If the error type is that the corresponding table cannot be found in the cross-table operation, obtain the full table name of the database, match the missing table name through string similarity, and determine whether the table name matches successfully; if so, correct the current SQL query statement and proceed to S704; otherwise, generate an alarm message to prompt the administrator to add a note to the table or update the knowledge base; S703: If the error type is that the corresponding field is not found in the current table operation, the error information is input into the language model, the field is automatically corrected, and the current SQL query statement is corrected, and then the process goes to S704; S704: Re-execute the search of the corrected SQL query statement. If the search is successful, proceed to S8; otherwise, proceed to S705; S705: When the number of consecutive correction failures reaches a preset number, a platform alarm is triggered to notify the administrator to intervene.

8. The data retrieval method of SAAS platform based on Agent according to claim 1, characterized in that: The query result includes: a response result that is semantically consistent with the natural language query request and no relevant data; S8 also includes: When the query result is that there is no relevant data, a prompt message indicating that there is no relevant data in the search result is generated and sent to the user.

9. An Agent-based SAAS platform data retrieval system, characterized in that: include: processor and memory; The memory stores programs or instructions that can be run on the processor, and when the programs or instructions are executed by the processor, the steps of the agent-based SAAS platform data retrieval method according to any one of claims 1 to 8 are implemented.

10. A readable storage medium, characterized in that: The readable storage medium stores a program or instruction, and when the program or instruction is executed by the processor, the steps of the agent-based SAAS platform data retrieval method according to any one of claims 1 to 8 are implemented.

Citation Information

Patent Citations

  • Underground coal mine early warning data query method and system based on language large model

    CN118733608A

  • Financial bill and non-tax collection intelligent data analysis platform

    CN118964399A

  • Method, system and equipment for improving accuracy of NL2SQL model and medium

    CN120429315A

  • Method and system for realizing Text2SQL (Structured Query Language)

    CN120470020A