Method and device for converting natural language into MongoDB query statement based on large model semantic understanding, processor and medium

By using a semantic understanding method based on a large model, complex queries are decomposed, user behavior habits are modeled, and fields are aligned, which solves the problems of low accuracy and complex query processing in MongoDB queries, and achieves efficient and accurate query results and automated optimization.

CN120994680APending Publication Date: 2025-11-21GUOTAI JUNAN SECURITIES CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510840002.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-23
Publication Date
2025-11-21

AI Technical Summary

Technical Problem

Existing technologies for querying unstructured document databases like MongoDB suffer from low accuracy, incompatibility between query fields and the database, and an inability to handle complex queries, especially in complex business scenarios such as the securities industry.

Method used

By decomposing user questions, modeling user historical behavior, incorporating descriptions of historical behavior habits, extracting key query points, and using a large model for field alignment and algorithm transformation, combined with reverse verification to optimize query statements, a query method based on semantic understanding of a large model was designed.

Benefits of technology

It improves query accuracy and applicability, can accurately understand complex queries, adapt to changes in database structure, support complex queries and has automated optimization capabilities, ensuring that query results meet user needs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120994680A_ABST
    Figure CN120994680A_ABST
Patent Text Reader

Abstract

The invention relates to a method for converting a natural language into a MongoDB query statement based on large model semantic understanding. The invention further relates to a device for converting the natural language into the MongoDB query statement based on large model semantic understanding, a processor and a computer readable storage medium thereof. According to the method and device for converting the natural language into the MongoDB query statement based on the large model semantic understanding, the processor and the computer readable storage medium of the processor, summarized user historical behavior habits are fused into the query processing process, the query accuracy and efficiency are improved, and the query efficiency is improved. In the steps of query decomposition, field alignment and the like, historical behavior habit information of the user is utilized to guide a large model to better understand the intention of the user, so that query statements better meeting the requirements of the user are generated. In the field of security file query, the effect of quickly retrieving the specified file is achieved through the method and the device, and the specified file is directly described by using a natural language without formatted input.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of database querying, and more particularly to the field of natural language processing technology. Specifically, it relates to a method, apparatus, processor, and computer-readable storage medium for converting natural language into MongoDB query statements based on large-scale model semantic understanding. Background Technology

[0002] There are two main methods for querying unstructured document databases (such as MongoDB). One method relies on professional technicians to write fixed rules, using predefined syntax and logic to transform user input into query statements that the database can recognize. This method requires professionals to have a deep understanding of the database structure and business logic, and the rules they write are often quite rigid, making it difficult to adapt to complex and changing user needs and database structure changes. Once the business logic or database structure changes, a significant amount of time and effort is required to modify the rules.

[0003] Another approach is to directly utilize a large model, providing the user's natural language input directly to the model, hoping that the model can generate corresponding MongoDB queries. While large models possess powerful language processing capabilities, this approach presents several problems in practical applications.

[0004] Existing technical solutions have three main problems in the conversion of natural language to database queries:

[0005] Low accuracy: When using a large model to generate queries based on user language, the ambiguity and diversity of natural language make it difficult for the large model to accurately understand the user's true intent, resulting in low accuracy of the generated queries. For example, users may use colloquial or abbreviated expressions, or words may have multiple meanings, which can easily lead to misunderstandings by the large model, resulting in incorrect queries.

[0006] Query fields may not align with the database: When generating queries, large models often fail to accurately match and align the fields in the user's query with the actual fields in the database. In different business scenarios, database field naming may have specific rules and meanings, while user expressions may differ from database field names. Large models struggle to understand these differences and perform correct conversions. This results in a mismatch between the fields in the query and the fields in the database, making it impossible to retrieve the data the user expects.

[0007] Unable to understand complex queries: In complex business scenarios such as the securities industry, user query requirements are often quite complex, potentially involving combinations of multiple conditions, nested queries, etc. Existing large-scale models have limited capabilities when handling such complex queries, easily leading to logical confusion or failure to correctly parse query conditions, and thus failing to generate accurate query statements that meet user needs. Summary of the Invention

[0008] The purpose of this invention is to overcome the shortcomings of the prior art and provide a method, apparatus, processor and computer-readable storage medium for converting natural language into MongoDB query statements based on large model semantic understanding, which is easy to operate, has high query accuracy and wide applicability.

[0009] To achieve the above objectives, the present invention provides a method, apparatus, processor, and computer-readable storage medium for converting natural language into MongoDB query statements based on large-model semantic understanding, as follows:

[0010] This method for converting natural language into MongoDB query statements based on large-scale model semantic understanding is characterized by the following steps:

[0011] (1) Decompose user problems, break down complex queries, model user historical behavior, and incorporate descriptions of historical behavior habits;

[0012] (2) Perform simple single-sentence query processing to extract key query points;

[0013] (3) Align the fields in the query requirements with the fields in the database;

[0014] (4) Convert the dictionary and MongoDB query statements using an algorithm;

[0015] (5) Based on the large model, reverse the verification of MQL statements to obtain a list of MQL statements, collect user feedback information, and optimize the modeling of user historical behavior.

[0016] Preferably, step (1) specifically includes the following steps:

[0017] (1.1) Receive complex natural language queries input by users and use advanced large language models to break down such complex queries into multiple simple single-sentence queries;

[0018] (1.2) Model user history behavior, record user feedback for each query, and summarize users’ common questioning methods and language habits through long-term accumulation and analysis of historical data. Refine users’ specific language habits to form a description of historical behavior habits.

[0019] (1.3) For each new query, the summary of the user's historical behavioral habits is incorporated into the prompt of this query.

[0020] Preferably, step (2) specifically includes the following steps:

[0021] (2.1) Process each of the decomposed simple queries;

[0022] (2.2) Extract the key information to be queried in a single sentence, output this information as a JSON query requirement, and form a list.

[0023] Preferably, step (3) specifically includes the following steps:

[0024] (3.1) Determine the key name to be queried for each JSON dictionary in the list;

[0025] (3.2) Extract all key names of this file type and obtain the corresponding fields in the database;

[0026] (3.3) Use a large model to map the fields in the JSON dictionary to the actual fields in the database. For fields with different representations, use domain knowledge and database structure information to determine the correspondence, align the fields in the JSON dictionary with the fields in the database, and return a list.

[0027] Preferably, step (4) specifically includes the following steps:

[0028] (4.1) Design an algorithm to convert the structure of a JSON dictionary to MongoDB query language;

[0029] (4.2) Transform each JSON dictionary in the obtained list using an algorithm to output a new list.

[0030] Preferably, step (5) specifically includes the following steps:

[0031] (5.1) Use a large model to perform reverse verification on each MQL statement in the list;

[0032] (5.2) If the large model determines that a certain MQL statement cannot find the object required by the corresponding simple query, then the simple query generation process is re-executed until the correct MQL statement is generated;

[0033] (5.3) Query the MongoDB database for each MQL statement in the MQL statement list, obtain the corresponding data, output the query results to the user, collect user feedback information, further analyze the user's language habits, and continuously optimize the user's historical behavior model.

[0034] The device for converting natural language into MongoDB query statements based on large-scale model semantic understanding is characterized by the following features:

[0035] A processor is configured to execute computer-executable instructions;

[0036] The memory stores one or more computer-executable instructions, which, when executed by the processor, implement the various steps of the method described above for converting natural language into MongoDB query statements based on large model semantic understanding.

[0037] The processor for converting natural language to MongoDB query statements based on large model semantic understanding is characterized in that the processor is configured to execute computer-executable instructions, which, when executed by the processor, implement the various steps of the method for converting natural language to MongoDB query statements based on large model semantic understanding.

[0038] The main feature of this computer-readable storage medium is that it stores a computer program thereon, which can be executed by a processor to implement the various steps of the above-described method for converting natural language into MongoDB query statements based on large model semantic understanding.

[0039] This invention employs a method, apparatus, processor, and computer-readable storage medium for converting natural language into MongoDB query statements based on large-scale model semantic understanding. It integrates summarized user historical behavior habits into the query processing, improving query accuracy and efficiency. In steps such as query decomposition and field alignment, it utilizes user historical behavior information to guide the large-scale model to better understand user intent, thereby generating query statements that better meet user needs. In the field of securities document retrieval, this invention can achieve rapid retrieval of specified documents, directly using natural language descriptions without the need for formatted input. If a speech recognition module is subsequently added, queries can be performed directly through speech recognition. Attached Figure Description

[0040] Figure 1 This is a flowchart of the method for converting natural language into MongoDB query statements based on large model semantic understanding according to the present invention. Detailed Implementation

[0041] To more clearly describe the technical content of the present invention, the following description is provided in conjunction with specific embodiments.

[0042] The method for converting natural language into MongoDB query statements based on large model semantic understanding of the present invention includes the following steps:

[0043] (1) Decompose user problems, break down complex queries, model user historical behavior, and incorporate descriptions of historical behavior habits;

[0044] (2) Perform simple single-sentence query processing to extract key query points;

[0045] (3) Align the fields in the query requirements with the fields in the database;

[0046] (4) Convert the dictionary and MongoDB query statements using an algorithm;

[0047] (5) Based on the large model, reverse the verification of MQL statements to obtain a list of MQL statements, collect user feedback information, and optimize the modeling of user historical behavior.

[0048] In a preferred embodiment of the present invention, step (1) specifically includes the following steps:

[0049] (1.1) Receive complex natural language queries input by users and use advanced large language models to break down such complex queries into multiple simple single-sentence queries;

[0050] (1.2) Model user history behavior, record user feedback for each query, and summarize users’ common questioning methods and language habits through long-term accumulation and analysis of historical data. Refine users’ specific language habits to form a description of historical behavior habits.

[0051] (1.3) For each new query, the summary of the user's historical behavioral habits is incorporated into the prompt of this query.

[0052] In a preferred embodiment of the present invention, step (2) specifically includes the following steps:

[0053] (2.1) Process each of the decomposed simple queries;

[0054] (2.2) Extract the key information to be queried in a single sentence, output this information as a JSON query requirement, and form a list.

[0055] In a preferred embodiment of the present invention, step (3) specifically includes the following steps:

[0056] (3.1) Determine the key name to be queried for each JSON dictionary in the list;

[0057] (3.2) Extract all key names of this file type and obtain the corresponding fields in the database;

[0058] (3.3) Use a large model to map the fields in the JSON dictionary to the actual fields in the database. For fields with different representations, use domain knowledge and database structure information to determine the correspondence, align the fields in the JSON dictionary with the fields in the database, and return a list.

[0059] In a preferred embodiment of the present invention, step (4) specifically includes the following steps:

[0060] (4.1) Design an algorithm to convert the structure of a JSON dictionary to MongoDB query language;

[0061] (4.2) Transform each JSON dictionary in the obtained list using an algorithm to output a new list.

[0062] In a preferred embodiment of the present invention, step (5) specifically includes the following steps:

[0063] (5.1) Use a large model to perform reverse verification on each MQL statement in the list;

[0064] (5.2) If the large model determines that a certain MQL statement cannot find the object required by the corresponding simple query, then the simple query generation process is re-executed until the correct MQL statement is generated;

[0065] (5.3) Query the MongoDB database for each MQL statement in the MQL statement list, obtain the corresponding data, output the query results to the user, collect user feedback information, further analyze the user's language habits, and continuously optimize the user's historical behavior model.

[0066] The apparatus of the present invention for converting natural language into MongoDB query statements based on large model semantic understanding, wherein the apparatus comprises:

[0067] A processor is configured to execute computer-executable instructions;

[0068] The memory stores one or more computer-executable instructions, which, when executed by the processor, implement the various steps of the method described above for converting natural language into MongoDB query statements based on large model semantic understanding.

[0069] The present invention discloses a processor for implementing natural language to MongoDB query statements based on large model semantic understanding. The processor is configured to execute computer-executable instructions, which, when executed by the processor, implement the various steps of the method for implementing natural language to MongoDB query statements based on large model semantic understanding.

[0070] The computer-readable storage medium of the present invention stores a computer program that can be executed by a processor to implement the various steps of the above-described method for converting natural language into MongoDB query statements based on large model semantic understanding.

[0071] This invention proposes a five-step pipeline. It employs a unique method and strategy to break down complex natural language queries input by the user into multiple simple single-sentence queries. It accurately understands the core intent of each single-sentence query, extracts the necessary query objects and conditional information, and organizes them according to a specific JSON format. It utilizes a large model for understanding and matching field relationships, and a mechanism for handling differences in field representation, ensuring that the query statement can accurately access relevant data in the database. Based on the structural characteristics of JSON dictionaries and MQL, it designs an effective conversion rule that enables fast and accurate conversion between the two. The invention also details the specific process and judgment criteria for validating the large model, and the mechanism for regenerating the query statement when validation fails, ensuring that the final output query results meet the user's needs.

[0072] In a specific embodiment of the present invention, the following steps are included:

[0073] (1) Decomposing the user problem based on a large model:

[0074] (1.1) Complex Query Decomposition: First, the system receives complex natural language queries input by the user. For example, the user inputs "Query supplementary transaction confirmations for Zhang Wei between August and December 2024 with a notional amount less than 400 or a number of names greater than 200". The system uses advanced large language models, such as Deepseek, to decompose such complex queries into multiple simple single-sentence queries. In this example, it might be decomposed into: "Query supplementary transaction confirmations for Zhang Wei between August and December 2024 with a notional amount less than 400, Query supplementary transaction confirmations for Zhang Wei between August and December 2024 with a number of names greater than 200".

[0075] (1.2) User Historical Behavior Modeling: In this step, the system models the user's historical behavior. The system records the user's input content, query time, and query result feedback for each query (such as whether the user is satisfied with the query result, whether a second query was performed, etc.). Through long-term accumulation and analysis of this historical data, the system summarizes the user's commonly used questioning methods and language habits. For example, some users are accustomed to using "recent X years" to indicate a time range, while others may be accustomed to using "the past X years." The system refines these user-specific language habits to form a shorter description of historical behavior habits.

[0076] (1.3) Incorporating Historical Behavioral Habits into the Prompt: With each new query, the system incorporates the user's historical behavioral habits, summarized previously, into the prompt for this query. For example, if a user frequently uses the expression "recent X years," this user habit will be reflected in the prompt when breaking down complex queries into simple single-sentence queries, such as "Please interpret 'recent year' as 'last 1 year' according to the user's habit, and break down complex queries into simple single-sentence queries." This guides the large model to better understand the user's language habits and improves the accuracy of breaking down complex queries.

[0077] (2) Extracting key points for simple queries based on large models:

[0078] (2.1) Simple single-sentence query processing: The large model performs in-depth processing on each simple single-sentence query after decomposition. Taking "Query supplementary transaction confirmation letter for Zhang Wei's nominal capital less than 400" as an example, the large model will understand that the core intention of this sentence is to query companies with specific market capitalization conditions.

[0079] (2.2) Extracting Key Query Points and Outputting JSON Format: The large model extracts the key information to be queried for this single query, such as the query object (Zhang Wei) and query conditions (supplementary transaction confirmations with a notional capital of less than 400 between August and December 2024). This information is then output as a query requirement in JSON format, as follows:

[0080] {

[0081] "user": "Zhang Wei"

[0082] "file_type": "Supplementary Transaction Confirmation"

[0083] "Nominal copy": {

[0084] "max": "400"

[0085] }

[0086] }

[0087] Each simple single-line query generates a JSON dictionary like this, with each dictionary containing only one type of object (e.g., "company" in this case). All these dictionaries are combined into a list representing all the query objects and conditions required in the user's original complex query. For example, the two single-line simple queries split earlier will ultimately generate a list containing two JSON dictionaries, which is then passed to the next step.

[0088] (3) Align the fields in the query requirements with the fields in the database based on the large model:

[0089] (3.1) Determine the query key: The system determines the key to be queried for each JSON dictionary in the list. For example, for the first dictionary above, the query key is determined to be "user, file_type, nominal copy".

[0090] (3.2) Retrieve the corresponding field in the database: In the MongoDB database, the system will retrieve all key names of the file type. For example, in the above example, if the key name is "Supplementary Transaction Confirmation", then all key names of the supplementary transaction confirmation file set will be retrieved.

[0091] (3.3) Field Alignment Processing: The system utilizes a large model to understand the relationship between fields in the JSON dictionary and actual fields in the database. For example, the "user" field in the JSON dictionary directly corresponds to the "user" field in the database. For fields that may have different representations, such as "notional capital" in the JSON dictionary and "notional capital amount" in the database, the large model can determine their correspondence by learning extensive domain knowledge and database structure information. After processing, the fields in the JSON dictionary are accurately aligned with the fields in the database to ensure query accuracy. Finally, a list is returned, containing the aligned JSON dictionary entries.

[0092] (4) Dictionary to MongoDB query statements based on algorithms

[0093] (4.1) Algorithm conversion principle: Since the structure of JSON dictionaries and MongoDB Query Language (MQL) are somewhat similar, a special algorithm can be designed to convert between the two. For example, "max" in the JSON dictionary can be converted to "$lte" in MQL.

[0094] (4.2) Batch conversion: The system uses this algorithm to convert each JSON dictionary in the list obtained in the previous step, and finally outputs a new list in which the elements are the converted MQL statements.

[0095] (5) Reverse verification based on large models

[0096] (5.1) MQL Validation: The system uses a large model to perform reverse validation on each MQL statement in the final list. Taking the MQL statement corresponding to "Query Zhang Wei's supplementary transaction confirmation for a notional amount less than 400" as an example, the large model will determine whether the MQL statement can accurately retrieve the corresponding file based on its understanding of the business logic and the database.

[0097] (5.2) Error Handling: If the large model determines that an MQL statement cannot find the object required by the corresponding simple query, it will explain the reason. For example, it may be due to a misspelled field name in the MQL statement, or an error in the conditional logic. In this case, the system will re-execute the generation process of the simple query, starting from decomposing the user's problem based on the large model, until the correct MQL statement is generated.

[0098] (5.3) Query and Feedback: After verification, the system obtains a list of valid MQL statements. Each MQL statement in this list is used to query the MongoDB database to retrieve the corresponding data, such as company information, financial statements, and announcements. Finally, the query results are output to the user, who is expected to provide feedback, such as satisfaction with the results or any additional requests. The system collects this feedback to further analyze user language habits and continuously optimize the user's historical behavior model, thereby improving the overall system performance and accuracy.

[0099] In MongoDB file queries, after extracting the user intent, a fixed algorithm can be used to directly convert the user intent into a query statement, without needing to call a large model again to generate SQL, which increases the uncertainty that may be caused by the illusion of a large model. This invention utilizes the characteristics of MongoDB to eliminate the large model call between query intent and query statement, resulting in stronger determinism and accuracy.

[0100] The main function of the large-scale model in this invention is to extract user query intent in a securities document query scenario. The large-scale model parses and aligns the user's query intent through multiple levels, generating a structured JSON output. This JSON output contains the user's query intent according to fixed constraints in the prompts. However, it cannot be directly input into the database for querying. Instead, it leverages MongoDB's use of JSON-style query statements, transforming it using a fixed algorithm to replace some keywords in the JSON, making it a MongoDB query statement. The large-scale model then reviews and approves the query statement. Therefore, in this invention, the large-scale model does not directly generate a database query statement, but rather extracts the user intent and transforms it into a query statement (similar to SQL) using a fixed algorithm.

[0101] This invention, through modeling user historical behavior, enables the system to gain a deep understanding of each user's unique language habits and questioning styles. When processing users' natural language queries, it no longer relies solely on a large model's understanding of general language, but rather combines this with specific historical behavioral information, allowing the large model to more accurately grasp the user's true intent. For example, for words or expressions with ambiguous meanings, the system can accurately interpret them based on the user's historical usage habits, thereby significantly improving the accuracy of understanding user intent.

[0102] This invention achieves precise matching between query fields and the database. Existing methods that directly generate query statements using large models often struggle to accurately align user query fields with the actual fields in the database. This proposal, however, specifically designs a field alignment step based on a large model. The system leverages the powerful understanding capabilities of the large model to deeply analyze the relationship between user query fields and database fields, accurately identifying and matching even discrepancies in expression. This allows the generated query statement to accurately access relevant data in the database, avoiding query errors caused by field mismatches and significantly improving the accuracy of query results.

[0103] This invention boasts powerful complex query processing capabilities. In complex business scenarios such as the securities industry, user query needs often involve combinations of multiple conditions and complex logical relationships. This application proposes a complete process for handling complex queries, from complex query decomposition and key point extraction to field alignment and query statement generation. Each step is meticulously designed to correctly parse and process complex query logic. Compared to existing methods that directly generate query statements from large models, this proposal can more accurately handle complex queries and generate query statements that meet user needs, thereby improving the accuracy and reliability of query results.

[0104] This invention features a continuous optimization automation mechanism, and the system also possesses an automated optimization mechanism based on user feedback. By collecting user feedback on query results, the system can automatically analyze users' language habits and changing needs, further optimizing the modeling of users' historical behavior. This continuous optimization automation mechanism enables the system to continuously improve its performance and accuracy as users become more familiar with it, better adapting to the needs of different users without requiring manual adjustments to system parameters or rules.

[0105] This invention adapts to changes in database structure. In practical applications, the database structure may be adjusted as business development and changes occur. The field alignment method based on a large model in this proposal enables the system to accurately match user query fields with new fields in the database even when the database structure changes. The large model can quickly adapt to these changes by learning information about database structure changes and related domain knowledge.

[0106] This invention proposes an intelligent transformation architecture based on a large language model. Through collaborative innovation of the semantic parsing layer, the syntax generation layer, and the interaction optimization layer, it achieves the following technological breakthroughs:

[0107] Improve query accuracy: By modeling and analyzing users' historical behavior and combining it with the semantic understanding capabilities of large models, the system can more accurately understand users' natural language query intent, thereby improving the accuracy of the generated MongoDB query statements.

[0108] Achieve accurate alignment between query fields and the database: Design effective algorithms and mechanisms to enable the system to automatically identify fields in user queries and accurately match and align them with the actual fields in the database, ensuring that the query statement can accurately access the relevant data in the database.

[0109] Support for complex queries: Build an architecture and methodology that can handle complex query logic, enabling the system to correctly parse and process complex query requests from users, generate MongoDB query statements that meet the requirements, and satisfy the query needs of complex business scenarios such as the securities industry.

[0110] For the specific implementation scheme of this embodiment, please refer to the relevant descriptions in the above embodiments, which will not be repeated here.

[0111] It is understood that the same or similar parts in the above embodiments can be referred to each other, and the contents not described in detail in some embodiments can be referred to the same or similar contents in other embodiments.

[0112] It should be noted that in the description of this invention, the terms "first," "second," etc., are used for descriptive purposes only and should not be construed as indicating or implying relative importance. Furthermore, in the description of this invention, unless otherwise stated, "a plurality of" means at least two.

[0113] Any process or method description in the flowchart or otherwise herein can be understood as representing a module, segment, or portion of code comprising one or more executable instructions for implementing a particular logical function or process, and the scope of the preferred embodiments of the invention includes additional implementations in which functions may be performed not in the order shown or discussed, including substantially simultaneously or in reverse order depending on the functions involved, as will be understood by those skilled in the art to which embodiments of the invention pertain.

[0114] It should be understood that various parts of the present invention can be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented in software or firmware stored in memory and executed by a suitable instruction execution device. For example, if implemented in hardware, as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.

[0115] Those skilled in the art will understand that all or part of the steps of the methods in the above embodiments can be implemented by a program instructing related hardware. The corresponding program can be stored in a computer-readable storage medium. When the program is executed, it includes one or a combination of the steps of the method embodiments.

[0116] Furthermore, the functional units in the various embodiments of the present invention can be integrated into a processing module, or each unit can exist physically separately, or two or more units can be integrated into a module. The integrated module can be implemented in hardware or as a software functional module. If the integrated module is implemented as a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium.

[0117] The storage media mentioned above can be read-only memory, disk, or optical disk, etc.

[0118] In the description of this specification, references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.

[0119] This invention employs a method, apparatus, processor, and computer-readable storage medium for converting natural language into MongoDB query statements based on large-scale model semantic understanding. It integrates summarized user historical behavior habits into the query processing, improving query accuracy and efficiency. In steps such as query decomposition and field alignment, it utilizes user historical behavior information to guide the large-scale model to better understand user intent, thereby generating query statements that better meet user needs. In the field of securities document retrieval, this invention can achieve rapid retrieval of specified documents, directly using natural language descriptions without the need for formatted input. If a speech recognition module is subsequently added, queries can be performed directly through speech recognition.

[0120] In this specification, the invention has been described with reference to specific embodiments thereof. However, it will be apparent that various modifications and variations can be made without departing from the spirit and scope of the invention. Therefore, the specification and drawings should be considered illustrative rather than restrictive.

Claims

1. A method for converting natural language into MongoDB query statements based on large-scale model semantic understanding, characterized in that, The method includes the following steps: (1) Decompose user problems, break down complex queries, model user historical behavior, and incorporate descriptions of historical behavior habits; (2) Perform simple single-sentence query processing to extract key query points; (3) Align the fields in the query requirements with the fields in the database; (4) Convert the dictionary and MongoDB query statements using an algorithm; (5) Based on the large model, reverse the verification of MQL statements to obtain a list of MQL statements, collect user feedback information, and optimize the modeling of user historical behavior.

2. The method for converting natural language into MongoDB query statements based on large-model semantic understanding according to claim 1, characterized in that, Step (1) specifically includes the following steps: (1.1) Receive complex natural language queries input by users and use advanced large language models to break down such complex queries into multiple simple single-sentence queries; (1.2) Model user history behavior, record user feedback for each query, and summarize users’ common questioning methods and language habits through long-term accumulation and analysis of historical data. Refine users’ specific language habits to form a description of historical behavior habits. (1.3) For each new query, the summary of the user's historical behavioral habits is incorporated into the prompt of this query.

3. The method for converting natural language into MongoDB query statements based on large-model semantic understanding according to claim 1, characterized in that, Step (2) specifically includes the following steps: (2.1) Process each of the decomposed simple queries; (2.2) Extract the key information to be queried in a single sentence, output this information as a JSON query requirement, and form a list.

4. The method for converting natural language into MongoDB query statements based on large-model semantic understanding according to claim 1, characterized in that, Step (3) specifically includes the following steps: (3.1) Determine the key name to be queried for each JSON dictionary in the list; (3.2) Extract all key names of this file type and obtain the corresponding fields in the database; (3.3) Use a large model to map the fields in the JSON dictionary to the actual fields in the database. For fields with different representations, use domain knowledge and database structure information to determine the correspondence, align the fields in the JSON dictionary with the fields in the database, and return a list.

5. The method for converting natural language into MongoDB query statements based on large-model semantic understanding according to claim 1, characterized in that, Step (4) specifically includes the following steps: (4.1) Design an algorithm to convert the structure of a JSON dictionary to MongoDB query language; (4.2) Transform each JSON dictionary in the obtained list using an algorithm to output a new list.

6. The method for converting natural language into MongoDB query statements based on large-model semantic understanding according to claim 1, characterized in that, Step (5) specifically includes the following steps: (5.1) Use a large model to perform reverse verification on each MQL statement in the list; (5.2) If the large model determines that a certain MQL statement cannot find the object required by the corresponding simple query, then the simple query generation process is re-executed until the correct MQL statement is generated; (5.3) Query the MongoDB database for each MQL statement in the MQL statement list, obtain the corresponding data, output the query results to the user, collect user feedback information, further analyze the user's language habits, and continuously optimize the user's historical behavior model.

7. A device for converting natural language into MongoDB query statements based on large-scale model semantic understanding, characterized in that, The device includes: A processor is configured to execute computer-executable instructions; The memory stores one or more computer-executable instructions, which, when executed by the processor, implement the steps of the method for converting natural language into MongoDB query statements based on large model semantic understanding as described in any one of claims 1 to 6.

8. A processor for converting natural language into MongoDB query statements based on large-scale model semantic understanding, characterized in that, The processor is configured to execute computer-executable instructions, which, when executed by the processor, implement the steps of the method for converting natural language into MongoDB query statements based on large model semantic understanding as described in any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that, It stores a computer program that can be executed by a processor to implement the steps of the method for converting natural language into MongoDB query statements based on large model semantic understanding as described in any one of claims 1 to 6.