Method, apparatus, vehicle and medium for converting natural language into database query language

By leveraging the multi-model collaboration and progressive disclosure mechanism of the Skill system, the shortcomings of Text2SQL technology in terms of input flexibility, generation accuracy, and adaptability to complex queries have been addressed. This has enabled the generation of a high-precision and stable database query language, suitable for vehicle data querying and management.

CN122633770APending Publication Date: 2026-08-25CHONGQING CHANGAN AUTOMOBILE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610938487.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-06-26
Publication Date
2026-08-25

AI Technical Summary

Technical Problem

Existing Text2SQL technology struggles to balance input flexibility, generation accuracy, and adaptability to complex queries, resulting in poor system stability and difficulty in adapting to high-precision, high-complexity business scenarios.

Method used

It adopts the Skill system, equipped with a large language model, a retrieval enhancement model and a natural language rule engine. Through a progressive disclosure mechanism, it executes in stages to achieve multi-model division of labor and collaboration, and generates query language by layer-by-layer verification and rule-based generation, avoiding model illusion and semantic bias.

Benefits of technology

It significantly improves the accuracy of natural language semantic understanding and the accuracy and reliability of database query language generation, adapts to complex and ever-changing enterprise business query scenarios, reduces system operation and maintenance costs, and improves the stability and fault tolerance of vehicle data queries.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122633770A_ABST
    Figure CN122633770A_ABST
Patent Text Reader

Abstract

The application relates to the technical field of database query, and discloses a method and device for converting natural language into a database query language, a vehicle and a medium, the method comprising the following steps: based on a Skill system carrying a large language model, a retrieval enhancement model and a natural language query engine, gradually disclosing skill information to the large language model in sequence by means of a progressive disclosure mechanism, and by the large language model, natural language information is normalized into standard text based on the skill information and initial business terms determined by the retrieval enhancement model, after the standard text is confirmed to be correct, the retrieval enhancement model is used for matching library table mapping information, and a database query language is generated by a natural language rule engine. The application can realize semantic layer-by-layer checking and accurate information disclosure throughout the whole process, avoid semantic deviation and generation errors from the process level, significantly improve the natural language semantic understanding precision and the accuracy and reliability of the database query language generation, and can stably adapt to complex and changeable business query scenarios of enterprises.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of database query technology, and more specifically to methods, apparatus, vehicles, and media for converting natural language into database query language. Background Technology

[0002] Text2SQL (Text to Structured Query Language) technology can automatically convert users' natural language query requirements into executable database query language, eliminating the technical barriers between business personnel and databases and lowering the threshold for enterprise data query and analysis. In practical enterprise applications, this technology needs to simultaneously meet three core requirements: input flexibility, generation accuracy, and adaptability to complex queries. However, existing technologies generally suffer from technical bottlenecks that cannot simultaneously achieve all three, making it difficult to adapt to high-precision and high-complexity business scenarios.

[0003] There are currently three main types of Text2SQL solutions, but all of them have significant drawbacks: pure large-model direct generation solutions rely on the model's single inference output, which is prone to semantic illusions, has low accuracy in complex query scenarios, and consumes a lot of context resources; RAG retrieval enhancement solutions, although they use external knowledge bases to recall and assist large-model generation, making up for the lack of inherent knowledge in the model, can easily interfere with inference by retrieving redundant information, exacerbating model illusions; domain fine-tuning solutions rely on dedicated data to train the model, which has high implementation costs, long iteration cycles, poor generalization ability and interpretability, and is difficult to deploy at scale.

[0004] It is evident that the common problem with the above solutions is that all core tasks rely on a single inference by a large model, resulting in model overload. The lack of multi-module division of labor, phased verification, and rule constraint mechanisms leads to frequent SQL generation deviations and poor system stability, which severely restricts the large-scale enterprise deployment of Text2SQL technology. Summary of the Invention

[0005] This invention provides a method, apparatus, vehicle, and medium for converting natural language into database query language, in order to solve the problem that existing Text2SQL technology is unable to balance input flexibility, generation accuracy, and adaptability to complex queries.

[0006] Firstly, this invention provides a method for converting natural language into database query language, applied to a Skill system. The Skill system is equipped with a large language model, a retrieval enhancement model, and a natural language rule engine, and is executed in stages based on a progressive disclosure mechanism. The method includes: disclosing skill information of the Skill system to the large language model; obtaining natural language information input by the user and disclosing business terminology mapping rules of the Skill system to the retrieval enhancement model; the retrieval enhancement model determining initial business terms corresponding to the natural language information; and the large language model converting the natural language information into standardized text based on the skill information and the initial business terms; in response to the standardized text being confirmed as correct, the retrieval enhancement model determining database table mapping information based on the standardized text; and the natural language rule engine generating a database query language corresponding to the natural language information based on the database table mapping information and the standardized text.

[0007] This invention provides a method for converting natural language into database query language. By building a Skill system integrating a large language model, a retrieval enhancement model, and a natural language rule engine, and relying on a progressive disclosure mechanism, it achieves multi-model collaboration and phased execution, sequentially completing the standardized conversion of skill information disclosure, natural language information normalization into standardized text, database table mapping information matching, and database query language generation. Through its multi-model decoupling and progressive step-by-step execution architecture, this invention completely changes the traditional extensive mode where a large language model undertakes all reasoning tasks. It calls the retrieval enhancement model in stages as needed to complete business terminology retrieval and database table mapping matching. The large language model achieves natural language normalization, using standardized text as an intermediate expression layer that can be confirmed by business personnel, fundamentally blocking the path of model illusions propagating downstream. Then, a dedicated natural language rule engine generates query language through rule-based processing. The entire process achieves semantic layer-by-layer verification and accurate information disclosure, avoiding semantic deviations and generation errors at the process level. This significantly improves the accuracy of natural language semantic understanding and the accuracy and reliability of database query language generation, and can stably adapt to complex and ever-changing business query scenarios of enterprises.

[0008] In one optional implementation, skill information is stored in the core definition file of the Skill system. The core definition file is divided into a metadata area and a core instruction area. The metadata area includes at least a skill name field and a skill description field. The skill name field is used to characterize the skill type of the Skill system, and the skill description field is used to determine whether the Skill system is activated. The core instruction area includes at least a skill execution logic and a skill workflow. The skill execution logic and skill workflow are executed by referencing a preset directory. The preset directory includes a code directory and a resource directory. The executable scripts stored in the code directory are used to perform deterministic computation tasks, and the resource files stored in the resource directory correspond to the progressive disclosure mechanism.

[0009] This invention provides a structured storage and partitioning of skill information within the Skill system. It divides core definition files into metadata and core instruction areas, and distinguishes between code and resource directories. This enables automatic skill identification and precise activation through metadata. By relying on categorized directories, it decouples computation scripts from business resources, allowing resource files to accurately match a progressive disclosure mechanism. This architecture enhances the reusability, maintainability, and scalability of Skills, facilitating the iteration of vehicle-related business functions and scenario deployment, while reducing system operation and maintenance costs.

[0010] In one optional implementation, the database table mapping information is stored in a business dictionary under the resource directory. A natural language rule engine generates a database query language corresponding to the natural language information based on the database table mapping information and the standardized text. This includes: the natural language rule engine performing semantic parsing on the standardized text based on the mapping rules of the business dictionary and the database table mapping information to obtain a structured query expression; a retrieval enhancement model determining high-quality database query language examples and writing specifications based on the standardized text and the structured query expression; splitting the structured query expression into a dimensional query language and a structured processing language, whereby the dimensional query language is used to define multi-table join paths, basic filtering conditions, and statistical dimensions, and the structured processing language is used to define computational logic and output structure; and merging and transforming the dimensional query language and the structured processing language according to the high-quality database query language examples and writing specifications to obtain the database query language, wherein multi-table join paths are transformed into preset join clauses, basic filtering conditions are transformed into preset filtering clauses, statistical dimensions are transformed into preset grouping clauses, and computational logic is transformed into preset aggregates.

[0011] This invention relies on a business dictionary to complete semantic parsing and combines a retrieval enhancement model to retrieve high-quality query language examples and writing specifications as the basis for generation. At the same time, it decomposes the structured query expression into a dimensional query language and a structured processing language, which can decouple the query structure and computational logic and standardize the mapping to various preset clauses. It not only uses examples and specifications to constrain the generation logic and avoid grammatical and business logic errors, but also significantly improves the standardization and executability of complex query statements such as multi-table association, filtering, grouping, and aggregation through modular decomposition and standardized conversion, making it suitable for multi-dimensional data statistical analysis scenarios of vehicles.

[0012] In one optional implementation, the mapping rules include: entity mapping rules, field cluster mapping rules, synonym mapping rules, and macro word mapping rules. The natural language rule engine performs semantic parsing on the standardized text based on the mapping rules of the business dictionary and the database table mapping information to obtain a structured query expression. This includes: determining the business objects contained in the standardized text, and performing entity mapping on the business objects based on the database table mapping information and entity mapping rules to determine the configuration parameters corresponding to the business objects; determining the business concepts contained in the standardized text, and performing field cluster mapping on the business concepts based on the database table mapping information and field cluster mapping rules to determine the business fields corresponding to the business concepts; determining the non-standard business terms contained in the standardized text, and performing synonym mapping on the non-standard business terms based on the database table mapping information and synonym mapping rules to determine the standard business terms corresponding to the non-standard business terms; determining the business expressions contained in the standardized text, and performing macro word mapping on the business expressions based on the database table mapping information and macro word mapping rules to determine the predefined business rules corresponding to the business expressions; and integrating the configuration parameters, business fields, standard business terms, and predefined business rules into a structured query expression.

[0013] This invention constructs four types of mapping rules: entities, field clusters, synonyms, and macros. It completes full-dimensional semantic parsing from four dimensions: business objects, business concepts, non-standard terms, and custom business rules. It can integrate corresponding information into structured query expressions after matching and transforming it layer by layer, effectively eliminating problems such as ambiguity in natural language, colloquial expressions, and abbreviations. It accurately parses complex business semantics in the vehicle domain, providing an unambiguous and standardized semantic foundation for subsequent query language generation, and enhancing the system's adaptability to various business expressions in the vehicle industry.

[0014] In one optional implementation, after the natural language rule engine generates a database query language corresponding to the natural language information based on the database table mapping information and the canonical text, the method further includes: querying a preset database according to the database query language; if the execution is correct, determining the query result; if the execution results in an error, determining the error type, and the retrieval enhancement model determines a solution and historical error correction cases based on the error type, and making corrections based on the solution and historical error correction cases until the maximum number of retries is reached or the query result is determined.

[0015] This invention adds a database query execution and intelligent error correction and retry process. For query language execution error scenarios, it can use the retrieval enhancement model to retrieve solutions to similar problems and historical error correction cases to complete automatic correction, forming a closed-loop mechanism of "generation-execution-verification-error correction". This effectively reduces the probability of execution failure in the vehicle data query process, improves the robustness of system operation, and continuously accumulates error correction cases, allowing the system to be continuously optimized and its stability to be gradually improved in long-term vehicle business use.

[0016] In one optional implementation, a large language model converts natural language information into standardized text based on skill information and initial business terms. This includes: the large language model determining a transcription instruction template based on the skill information, the transcription instruction template containing at least a standardized text structure, transcription rules, and a natural language dictionary summary; extracting business terminology mapping rules that match the initial business terms based on the natural language dictionary summary, and converting the initial business terms into standard business terms according to the business terminology mapping rules; and standardizing and rewriting the natural language information according to the standardized text structure, transcription rules, and standard business terms to generate standardized text.

[0017] This invention limits the use of dedicated transcription instruction templates for large language models to generate standardized text. Based on the text structure, transcription rules, and dictionary summaries within the templates, terminology standardization is first achieved, followed by unified formatting and expression. This effectively regulates and constrains fragmented and colloquial natural language input from users, preventing arbitrary additions or deletions of requirements and semantic shifts. By standardizing input from the source, it ensures the complete and accurate transmission of vehicle-related query requests, improving the stability of the entire conversion chain. Furthermore, introducing standardized text as an intermediate expression layer that can be verified by business personnel fundamentally blocks the path of model illusions propagating downstream.

[0018] In one alternative implementation, before disclosing the skill information of the Skill system to the large language model, the method further includes: determining the user intent based on natural language information, matching triggering conditions based on the user intent, and determining whether to activate the Skill system based on the matched triggering conditions.

[0019] This invention adds a user intent recognition and skill activation determination step before the Skill system is activated. The corresponding skill is only activated when the intent and triggering conditions match successfully. This enables skills to be loaded on demand and called accurately, reducing invalid model calculations and resource consumption, improving system response speed, and avoiding misinterpretation of non-query commands. This further optimizes the vehicle-side interactive experience and system operating efficiency.

[0020] In one optional implementation, after determining the query result, the method further includes: generating a vehicle control command based on preset control rules and the determined query result, and sending the vehicle control command to the target vehicle to manage the target vehicle.

[0021] This invention extends vehicle management capabilities based on data querying. It generates and issues control commands based on vehicle data obtained from database queries and preset control rules to complete the management of target vehicles. It can build an integrated business link of "natural language query - vehicle data acquisition - remote management", combining data query with vehicle operation and maintenance and status control, expanding the application scope in scenarios such as vehicle networking, fleet management, and remote vehicle operation and maintenance, and improving the integration and practical value of the overall solution.

[0022] Secondly, this invention provides a device for converting natural language into database query language, applied to a Skill system. The Skill system is equipped with a large language model, a retrieval enhancement model, and a natural language rule engine, and executes in stages based on a progressive disclosure mechanism. The device includes: an initial invocation module for disclosing skill information of the Skill system to the large language model; a requirement parsing module for obtaining natural language information input by the user and disclosing business terminology mapping rules of the Skill system to the retrieval enhancement model, whereby the retrieval enhancement model determines the initial business terms corresponding to the natural language information, and the large language model converts the natural language information into standardized text based on the skill information and the initial business terms; a table structure matching module for determining database table mapping information based on the standardized text in response to the confirmation that the standardized text is correct; and a query language generation module for generating database query language corresponding to the natural language information by the natural language rule engine based on the database table mapping information and the standardized text.

[0023] Thirdly, the present invention provides a vehicle, the vehicle including a controller, the controller including a memory and a processor, the memory and the processor being communicatively connected to each other, the memory storing computer instructions, and the processor executing the computer instructions to perform the natural language to database query language method of the first aspect or any corresponding embodiment described above.

[0024] Fourthly, the present invention provides a computer-readable storage medium storing computer instructions for causing a computer to execute the natural language to database query language method of the first aspect or any corresponding embodiment described above.

[0025] Fifthly, the present invention provides a computer program product, including computer instructions for causing a computer to execute the natural language to database query language method described in the first aspect or any corresponding embodiment thereof.

[0026] The beneficial effects of this invention are: (1) This invention innovatively builds a Skill system, relying on the collaborative work of a large language model, a retrieval enhancement model, and a natural language rule engine. Through pre-user intent recognition, skills are activated on demand. Combined with a phased and progressive business resource disclosure mechanism, it can complete terminology recall, text standardization rewriting, and accurate database matching step by step, avoiding problems such as colloquial ambiguity, inconsistent non-standard terminology, and semantic understanding deviations from the source. At the same time, it configures standardized transcription templates and four-layer three-dimensional business mapping rules to achieve comprehensive and accurate analysis of vehicle business semantics, greatly improving the accuracy of natural language understanding and the standardization of database query language generation. (2) This invention addresses complex query scenarios such as multi-table association, multi-dimensional statistics, and aggregation calculations for vehicles by introducing high-quality query examples and standardized writing specifications to generate logic. Through a decoupled compilation mode of dimensional query language and structured processing language, it achieves standardized mapping and transformation of multi-table joins, condition filtering, dimensional grouping, and aggregation calculations, thoroughly improving the shortcomings of traditional solutions where accuracy drops sharply in complex scenarios. At the same time, the progressive disclosure mechanism is deeply integrated with RAG's on-demand retrieval capabilities to construct a complete closed loop of query execution verification, error classification and identification, historical case correction, and iterative retry, effectively solving problems such as SQL execution errors and logical distortion, and significantly improving the stability and fault tolerance of the system in complex data query scenarios of the Internet of Vehicles. (3) This invention adopts a partitioned and structured design for the core definition files of the Skill system. It realizes intelligent skill identification and accurate activation through the metadata area. By separating the code directory and the resource directory, it achieves complete decoupling of deterministic computing tasks and business configuration resources, and accurately adapts resource configuration and progressive disclosure mechanisms. The overall modular and structured architecture design supports vehicle business dictionary updates, skill logic iterations, and rapid adaptation to new scenarios without large-scale modification of the underlying architecture. It can quickly adapt to diverse vehicle networking business scenarios such as vehicle condition query, fault statistics, and fleet operation and maintenance, effectively reducing the cost of system upgrades, operation and maintenance, and scenario expansion. Attached Figure Description

[0027] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0028] Figure 1 This is a schematic diagram of an application scenario according to an embodiment of the present invention; Figure 2 This is a diagram illustrating the three dilemmas faced by Text2sql; Figure 3 This is a schematic diagram of the composition structure of the Skill system used in the large model; Figure 4 These are the skills and workflow features used by the large model; Figure 5 This is a schematic diagram of the first method for converting natural language to database query language according to an embodiment of the present invention; Figure 6 This is the Skill project directory for the method of converting natural language to database query language according to embodiments of the present invention; Figure 7This is a second flowchart illustrating a method for converting natural language to database query language according to an embodiment of the present invention; Figure 8 This is a core pipeline panoramic architecture diagram of the natural language to database query language method according to an embodiment of the present invention; Figure 9 This is a schematic diagram of the third method for converting natural language to database query language according to an embodiment of the present invention; Figure 10 This is a structural block diagram of a device for converting natural language to database query language according to an embodiment of the present invention; Figure 11 This is a schematic diagram of the hardware structure of the vehicle controller according to an embodiment of the present invention. Detailed Implementation

[0029] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0030] It is understood that before using the technical solutions disclosed in the various embodiments of the present invention, users should be informed of the types, scope of use, and usage scenarios of the personal information involved in the present invention and their authorization should be obtained in accordance with relevant laws and regulations through appropriate means.

[0031] The terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of this invention, "a plurality of" means two or more, unless otherwise explicitly specified.

[0032] As an optional application scenario of this invention, such as Figure 1 As shown, the natural language to database query language system provided in this embodiment of the invention may include at least one terminal device and at least one server. Figure 1 The system is illustrated in the example, which includes a computer 101, a mobile terminal 102, and a server 103, and the terminal devices such as the computer 101 and the mobile terminal 102 are connected to the server 103 through a network 110.

[0033] Specifically, the terminal device can be a smartphone, tablet, laptop, PDA, desktop computer, game console, smart TV, smart wearable device, in-vehicle terminal, VR (Virtual Reality) device, AR (Augmented Reality) device, etc. Server 103 can be a standalone physical server, a server cluster, a distributed system, or a cloud server providing cloud services. Network 110 can be a wired or wireless network, examples of which include, but are not limited to, the Internet, corporate intranet, local area network, wide area network, mobile communication network, and combinations thereof.

[0034] Text2SQL refers to a technology that automatically converts user data query requests expressed in natural language into Structured Query Language (SQL) that can be executed on relational databases and returns the results. Its core goal is to eliminate the technical barriers between business users and databases, enabling non-technical users to complete data queries and analysis without understanding table structure, field semantics, and inter-table relationships. In real-world enterprise scenarios, such as... Figure 2 As shown, Text2SQL systems have long faced a trilemma: there is a systemic contradiction between the three objectives of flexibility, accuracy, and query complexity, making it difficult to satisfy them simultaneously in the same solution.

[0035] Flexibility requires the system to understand diverse colloquial expressions, omissions, pronouns, and vague descriptions used by users. Accuracy requires the system to generate SQL that is completely correct at both the syntactic and semantic levels, without errors in field mapping, join paths, or aggregation logic offsets. Query Complexity requires the system to support everyday enterprise analysis scenarios such as multi-table joins, nested subqueries, complex metric calculations, and time window aggregations.

[0036] Current mainstream Text2SQL solutions can be roughly divided into three categories, none of which can effectively overcome the aforementioned three dilemmas: (i) The approach of directly generating SQL using a large language model. This approach injects the full table structure, field descriptions, and a small number of SQL examples into the Prompt, allowing the large language model to complete the conversion from natural language to SQL in one step. While highly flexible, it suffers from the following serious drawbacks: the model is prone to generating syntactically correct but semantically incorrect SQL, which business users cannot verify because they cannot read it; to enable the model to understand the database structure, a large amount of schema information needs to be injected into the context, resulting in extremely high token consumption; and in scenarios involving multiple table joins and complex metrics, the model's inference accuracy drops sharply.

[0037] (II) RAG-based Enhanced Generation Scheme. This scheme introduces a retrieval-enhanced generation mechanism based on the first type. It retrieves relevant table structures, field descriptions, and historical SQL examples from the knowledge base through vectorized retrieval, injects them into the prompt, and then generates SQL using the model. Compared to the first type of scheme, the RAG scheme improves in terms of knowledge coverage and timeliness, but it still essentially relies on the model to undertake all generation tasks, lacking process control, validation and error correction, and multi-step orchestration capabilities. Its accuracy in complex scenarios remains unsatisfactory. Furthermore, retrieval quality directly determines the generation effect; recalling irrelevant content can exacerbate the illusion, and injecting all retrieved content into the context at once results in significant context waste.

[0038] (III) Domain Fine-tuning Solution. This solution uses enterprise-specific table structures and SQL samples to fine-tune the open-source base model, attempting to enable the model to directly "learn" the query capabilities of a specific database. However, this solution is extremely costly, has the worst interpretability, and the illusion rate of the current open-source base model is inherently higher than that of the closed-source model, resulting in unstable performance in generalization scenarios after fine-tuning.

[0039] The common problem with the above three types of solutions is that they all rely on the large language model to complete the four highly complex tasks of understanding user needs, understanding database structure, inferring table relationships, and generating complete SQL in a single inference. This results in a severe overload on the model role, leading to uncontrollable, unauditable, and untrustworthy system output.

[0040] To address the aforementioned challenges, in this embodiment of the invention, the Natural Language to Database Query Language system is deployed with a Skill system, which corresponds to specialized capability modules in the AI ​​Agent capability hierarchy architecture, such as... Figure 3 As shown, it is equipped with a large language model, a retrieval enhancement model, and a Natural Language Query (NLQ) engine. Figure 4 As shown, the Skill system is built using Prompt Engineering for semantic alignment, RAG for retrieval disambiguation, and Workflow / Agent for multi-step execution, achieving modular encapsulation and progressive disclosure of Text2SQL capabilities. Simultaneously, this Skill system can be uniformly scheduled and managed by the upper-level enterprise control layer (Harness), supporting global orchestration, access control, log auditing, and multi-skill collaboration, adapting to enterprise-level control requirements in complex business scenarios such as connected vehicles.

[0041] Based on the Skill system's progressive disclosure mechanism and phased execution, this invention provides a method for converting natural language into database query language. By reconstructing the traditional single-step generation paradigm of Text2SQL into a multi-step verifiable layered translation system, each step has clear inputs and outputs, can be independently verified, and can be handled by different execution entities. This improves the accuracy of natural language semantic understanding and the accuracy and reliability of database query language generation, and can stably adapt to the complex and ever-changing business query scenarios of enterprises.

[0042] According to an embodiment of the present invention, a method embodiment for converting natural language to database query language is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.

[0043] This embodiment provides a method for converting natural language to database query language, which can be used in the aforementioned natural language to database query language system. Figure 5 This is a flowchart of a method for converting natural language to database query language according to an embodiment of the present invention, such as... Figure 5 As shown, the process includes the following steps: Step S501: Disclose the skill information of the Skill system to the large language model.

[0044] Specifically, in this embodiment of the invention, the Skill system is a pre-built, dedicated natural language translation and query skill execution system that integrates three main functional components: a large language model, a retrieval enhancement model, and a natural language rule engine. Its core relies on a progressive disclosure mechanism to achieve controllable execution throughout the entire process. This mechanism originates from the progressive loading strategy in the Agent Skills industry standard proposed by Anthropic. It is the core design of this embodiment that distinguishes it from traditional large language models that load all information at once for inference. The core logic is as follows: the Skill system does not inject all prompts, knowledge bases, business rules, and tool capabilities into the context window of the large language model at once. Instead, it discloses the information, execution logic, and operational capabilities required for the current stage to the model as needed and step-by-step, based on the user input and the task execution stage. This strictly limits the model to only obtaining corresponding dedicated information and performing corresponding operations at each stage, completely avoiding the context redundancy, high resource consumption, inference confusion, and semantic illusion problems caused by traditional models loading all information at once.

[0045] This progressive disclosure mechanism features a standardized four-level operation mode and a three-level information loading system. The four-level operation mode includes the initiation phase, the demand triggering phase, the deep loading phase, and the execution phase. The three-level information loading system consists of an introduction layer, a detailed step layer, and a boundary case layer, enabling hierarchical and on-demand information disclosure. The introduction layer provides concise functional descriptions for the model to quickly determine skill activation. The detailed step layer presents structured execution flows and examples, loaded only after skill invocation is confirmed. The boundary case layer provides exception solutions, accessed only when errors occur. This embodiment of the invention precisely adapts this mechanism to Text2SQL business scenarios, forming a multi-stage refined information disclosure logic. The stages are: initial invocation stage, demand parsing stage, table structure matching stage, SQL generation stage, and error correction stage.

[0046] The disclosure during the initial invocation phase only includes skill information from the Skill system. This skill information consists of predefined and fixed-stored core capability information from the introductory layer of the Skill system, including: core function descriptions, input / output specifications, and basic applicable scenarios. This information is used to inform the large language model of the currently executable task types, execution specifications, capability boundaries, and output requirements. For example, it tells the large language model that "this skill is used to transcribe natural language into standard text and generate SQL for execution through a rule engine. The input is the user's query statement, and the output is the SQL execution result." This eliminates the need to load redundant business details and inject any table structures, business rules, or dictionary content, thus greatly saving model context space.

[0047] In some optional implementations, skill information within the Skill system is uniformly stored in a dedicated core definition file, SKILL.md. This core definition file employs a partitioned, structured design, specifically divided into two main modules: a metadata area (YAMLFrontmatter) and a core instruction area (Markdown Body). Each area carries different functions and works together to achieve standardized skill invocation and progressive information disclosure. The metadata area must at least include a skill name field and a skill description field. The skill name field uniquely identifies the skill type within the current Skill system, distinguishing it from natural language-to-database query skills and other skill types. The skill description field stores a brief overview of the skill's core functions and applicable scenarios, enabling the Agent to quickly determine whether it matches the user's query needs during the initial phase, thereby determining whether to activate the Skill system. This aligns with the startup logic of the progressive disclosure mechanism. Therefore, the skill description should be specific and include relevant trigger keywords; a structure of "function + scenario + keyword" is recommended.

[0048] The core instruction area should at least contain the skill execution logic and skill workflow, used to define the complete task processing flow and execution rules for this skill; the skill execution logic and skill workflow are invoked and executed by referencing the system's preset directories, such as... Figure 6 As shown, the preset directories specifically include a scripts directory and a references directory. The scripts directory stores various executable scripts used to complete fixed tasks within the system, such as deterministic calculations and data processing, including data validation and format conversion. These scripts are more reliable than code temporarily generated by the model, saving tokens and ensuring execution consistency. The assets directory stores template files and static resources for standardized output formats. The references directory stores various resource files matched to skills, such as business dictionaries, SQL writing standards, table structure documents, and high-quality SQL sample libraries. All resource files in the references directory precisely correspond to a progressive disclosure mechanism, providing data support for tiered information disclosure at each stage and on-demand resource loading. This means the Agent does not load all content at once, but loads documents from the directory only as needed according to the instructions in SKILL.md. Instructions and knowledge are separated, decoupling the streamlined core workflow from the vast knowledge base, keeping SKILL.md clear, and making the updating and maintenance of domain knowledge more independent. Additionally, it includes a static assets directory for storing template files and static resources, ensuring a standardized output format.

[0049] In this embodiment of the invention, the construction of the Skill system follows three core principles: ① Single Responsibility Principle: A Skill should focus on only one specific task, avoiding the design of a complex "all-purpose tool." ② Separation of Instructions and Knowledge Principle: Core instructions are written into SKILL.md, and detailed specifications are placed in the references directory, referenced as needed via file paths. ③ Continuous Iteration Principle: The most important characteristic of the Skill system is its ability to self-purify and refine with each use. Through continuous testing, correction, and optimization, the Skill will become increasingly aligned with actual business needs.

[0050] In practical implementation, it is recommended to follow these steps: identify highly repetitive business scenarios and break down their workflows into clear sequence of steps; provide the step descriptions to AI to help generate an initial version of the Skill file; test and verify through actual use, and correct any execution deviations; continuously optimize through multiple iterations to accumulate best practices.

[0051] Furthermore, the Skill system's disclosure of its skill information to the large language model refers to the structured and lightweight input of the Skill system's skill information into the large language model during the model inference initialization phase. This completes the model's task awakening and capability alignment, enabling the large language model to clearly understand that this task is a natural language data query and conversion task in the vehicle domain, rather than a general text generation task, thus constraining the model's inference direction from the source.

[0052] For example, the system pre-discloses the vehicle data query skill information of the Skill system to the large language model, clarifying that the skill is used to convert natural language query requirements such as vehicle operating conditions, faults, maintenance, and driving data into standard executable database query language. The output is limited to conform to the vehicle database table structure and irrelevant reasoning is prohibited, laying the rule foundation for subsequent requirement parsing and text conversion.

[0053] Step S502: Obtain the natural language information input by the user, disclose the business term mapping rules of the Skill system to the retrieval enhancement model, the retrieval enhancement model determines the initial business terms corresponding to the natural language information, and the large language model converts the natural language information into standardized text based on the skill information and the initial business terms.

[0054] Specifically, in this embodiment of the invention, natural language information refers to non-standardized, colloquial, and fragmented query text input by the user terminal. In a vehicle scenario, users can input query requests in arbitrary sentence structures through in-vehicle terminals or backend management terminals, exhibiting characteristics such as colloquial expressions, abbreviations, omissions, and vague descriptions, making them unsuitable for direct database matching and SQL generation. The business terminology mapping rules are pre-built vehicle-specific terminology correspondence rules within the Skill system, used to associate user colloquial expressions with standard business terms, covering various scenario terminology mapping relationships such as vehicle operating conditions, fault types, maintenance items, and driving parameters.

[0055] During the table structure matching stage, after the Skill system obtains the natural language information input by the user, the retrieval enhancement model initially recalls and matches the initial business terms from the user's natural language information based on the business term mapping rules. These initial business terms are the original core business terms. This is the initial extraction of the core business content of the user's query requirements, which retains the user's original expression features for subsequent standardization and regularization.

[0056] Furthermore, based on the skill information disclosed by the Skill system, the large language model can determine that its task is a query transformation task of natural language data in the vehicle domain. The purpose is to convert natural language into standardized text, rather than a general text generation task. The so-called standardized text is a standardized query text that has undergone terminology unification, sentence structure regularization, requirement completion, and ambiguity elimination. It has a fixed sentence structure, standard business terminology, complete query semantics, no colloquial or redundant content, and can be directly used for subsequent database table matching and parsing.

[0057] In this embodiment of the invention, firstly, natural language information of vehicle query input by the user is obtained, and at the same time, exclusive terminology mapping rules are disclosed to the retrieval enhancement model. Relying on the accurate retrieval matching capability of the retrieval enhancement model, the initial business terms corresponding to the user's needs are quickly located. Then, the large language model combines the previously disclosed skill information with the extracted initial business terms to rewrite the messy natural language information, standardize and replace terms, complete semantics and correct ambiguities, and generate a standardized text with unique semantics and uniform format.

[0058] Taking a vehicle-to-everything (V2X) data query scenario as an example, a user's natural language input might be: "Please help me calculate the total number of pure electric vehicles in region A in February 2026 that have a battery SOC below 20%, have been offline for more than 72 consecutive hours, and were purchased between 2024 and 2025, broken down by vehicle type." The standardized text transcribed by the large language model would be: "Statistics on the total number of pure electric vehicles in region A in February 2026 with a battery SOC below 20%, continuously offline for more than 72 hours, and purchased between 2024 and 2025, broken down by vehicle type."

[0059] Taking a complex scenario of vehicle-to-everything (V2X) data query as an example, a user inputs: "Please compile statistics on pure electric vehicles nationwide from January to March 2026 that have experienced more than 3 charging failures, have a power consumption per 100 kilometers higher than 20 kWh, have a range reduction of more than 15%, have been purchased 1 to 2 years ago, and have an average monthly mileage of less than 500 kilometers. Please summarize the statistics by province and vehicle model." The standardized output text would be: "Summary statistics on pure electric vehicles nationwide from January to March 2026 with more than 3 charging failures, power consumption per 100 kilometers higher than 20 kWh, range reduction of more than 15%, purchased 1 to 2 years ago, and average monthly mileage of less than 500 kilometers. Statistics by province and vehicle model."

[0060] In step S503, in response to the confirmation that the canonical text is correct, the retrieval enhancement model determines the database table mapping information based on the canonical text.

[0061] Specifically, in this embodiment of the invention, the canonical text serves as an intermediate expression layer, defined as a standardized expression form between natural language and database query language, satisfying the following constraints: written in human-understandable business language, unambiguous, unredundant, and free of interjections; following a fixed structure of "time plus region or scope plus filtering conditions plus statistical dimensions plus query entities or indicators," with each element separated by spaces; terminology strictly matching the standard terminology definitions in the NLQ business dictionary; and business personnel can directly read and confirm its semantic correctness.

[0062] Therefore, after the large language model transforms the natural language input by users such as business personnel into standardized text, it can provide the standardized text as an intermediate expression layer to the user for review and confirmation. Once the standardized text is confirmed to be error-free, it means that the standardized text has undergone semantic integrity, requirement uniqueness, and terminology standardization checks, confirming that the text has no semantic ambiguity, no missing requirements, and no terminology errors. This ensures that the text meets the execution conditions for subsequent database table matching and query generation, avoiding resource waste and generation errors caused by invalid text continuing inference, and fundamentally blocking the path of model illusion propagation downstream.

[0063] Furthermore, after the standardized text is confirmed to be correct, relying on the knowledge base retrieval capabilities of the retrieval enhancement model, the standardized text is used as the retrieval basis to accurately retrieve matching database table mapping information from the vehicle business knowledge base and database table resource files. This abandons the traditional extensive mode of fully loading the database table structure, achieving precise matching on demand, significantly reducing redundant information input, and lowering the model's inference burden. The database table mapping information includes matching information on the database table structure, relationships, field information, and field definitions corresponding to the vehicle database, containing core structured information such as the target data table corresponding to the query requirement, data fields, multi-table relationship paths, and field business meanings.

[0064] For example, consider the aforementioned specification text: "Battery SOC in Region A was below 20% in February 2026, continuous offline for over 72 hours, and vehicle purchase time was 2024-2025. Statistics on the total number of pure electric vehicles are based on vehicle model." Based on this precise and unambiguous specification text, and relying on the deep loading logic of a progressive disclosure mechanism, only the database table mapping information required for the current query is specifically retrieved, without loading the full database table structure. The database table mapping information precisely matched by the retrieval enhancement model includes the vehicle basic information table, vehicle battery status data table, vehicle online status monitoring table, and vehicle location information table. Simultaneously, core fields are matched: statistical time field, vehicle location field, battery SOC field, device offline duration field, vehicle purchase time field, vehicle energy type field, vehicle model field, and vehicle unique identifier associated field. This clarifies the multi-table association path and the corresponding business interpretation of each field, providing a precise and structured basis for the subsequent generation of standardized query language.

[0065] Step S504: The natural language rule engine generates a database query language corresponding to the natural language information based on the database table mapping information and the standard text.

[0066] Specifically, in this embodiment of the invention, the natural language rule engine is a structured query generation engine exclusive to the Skill system. It possesses rule-based processing capabilities including semantic parsing, query structure decomposition, standardized clause mapping, and statement merging. Unlike the pure reasoning generation mode of large language models, it combines fixed business rules with structured logic to generate query statements, resulting in stronger controllability and accuracy. The database query language is a standardized structured query statement adapted to vehicle business databases, with standardized syntax, accurate semantics, and direct execution. In other words, the natural language rule engine is equivalent to a rule engine; its entire processing involves deterministic rule matching without any model reasoning, thus ensuring the stability and auditability of the execution results.

[0067] In this embodiment of the invention, during the SQL generation stage, the natural language rule engine combines the previously obtained standard specification text with accurate database table mapping information to complete the entire process of structured parsing and statement compilation. This accurately transforms the user's natural language query requirements into a database query language that can be directly executed in the vehicle business database, achieving end-to-end accurate conversion from natural language requirements to data query statements. Leveraging the engine's rule-based generation capabilities, it can accurately adapt to complex vehicle query scenarios such as multi-table joins, dimensional statistics, and aggregation calculations, effectively avoiding the illusion of large language models.

[0068] For example, regarding the standardized text corresponding to the above vehicle scenario and the matched database table mapping information: four business data tables—Vehicle Basic Information Table, Vehicle Battery Status Data Table, Vehicle Online Status Monitoring Table, and Vehicle Location Information Table—and their corresponding related fields, the natural language rule engine, relying on a progressive disclosure mechanism, only loads the query language writing specifications and high-quality query examples required for this round of queries as needed, completing structured parsing and statement compilation. By semantically decomposing the standardized text, extracting the corresponding filtering conditions, statistical dimensions, and aggregation indicators, and combining the multi-table relationships of the four data tables, a standard database query language that can be directly executed in the vehicle business database is generated. The final generated query language can accurately filter out pure electric vehicles in Region A that meet all the specified conditions in February 2026, and complete the quantity statistics by vehicle type, accurately matching users' refined and multi-condition vehicle data query needs, effectively improving the overall accuracy and reliability of query language generation in complex business scenarios.

[0069] As can be seen, in this embodiment of the invention, the three types of execution entities of the system each perform their respective duties, forming a clear separation of responsibilities: AI is responsible for understanding, that is, the large model only undertakes the task of transcribing natural language into standard text, which happens to be the text rewriting capability that the model is best at; rules are responsible for execution, that is, the NLQ rule engine completes deterministic semantic parsing, entity mapping, multi-table association and SQL generation based on the business dictionary, and all logic is rule matching rather than model reasoning; users are responsible for confirmation, that is, business personnel review and confirm the query semantics in the standard text stage, and prevent the propagation of semantic deviations before execution.

[0070] Furthermore, the progressive disclosure mechanism constructed in this embodiment of the invention offers four core benefits: Extreme context efficiency: Avoiding the injection of all content at once significantly reduces token consumption, lowers inference costs, and mitigates the risk of context overflow. Significantly reduced illusion rate: Minimizing interference from irrelevant information on the model's attention mechanism, allowing it to focus on the core task of the current stage, resulting in a significant improvement in inference accuracy. Highly controllable execution flow: Strictly limiting the model to only acquiring relevant information at each stage avoids uncontrollable behaviors such as skipping steps or deviating from the intended path. Breaking through the boundaries of complex tasks: Capable of handling ultra-complex tasks far exceeding the limitations of a single-round context window, breaking down massive tasks into multi-stage, step-by-step execution, with the context requirements of each stage remaining within the window capacity.

[0071] This invention provides a method for converting natural language into database query language. By building a Skill system integrating a large language model, a retrieval enhancement model, and a natural language rule engine, and relying on a progressive disclosure mechanism, it achieves multi-model collaboration and phased execution, sequentially completing the standardized conversion of skill information disclosure, natural language information normalization into standardized text, database table mapping information matching, and database query language generation. Through its multi-model decoupling and progressive step-by-step execution architecture, this invention completely changes the traditional extensive mode where a large language model undertakes all reasoning tasks. It calls the retrieval enhancement model in stages as needed to complete business terminology retrieval and database table mapping matching. The large language model achieves natural language normalization, using standardized text as an intermediate expression layer that can be confirmed by business personnel, fundamentally blocking the path of model illusions propagating downstream. Then, a dedicated natural language rule engine generates query language through rule-based processing. The entire process achieves semantic layer-by-layer verification and accurate information disclosure, avoiding semantic deviations and generation errors at the process level. This significantly improves the accuracy of natural language semantic understanding and the accuracy and reliability of database query language generation, and can stably adapt to complex and ever-changing business query scenarios of enterprises.

[0072] This embodiment provides a method for converting natural language to database query language, which can be used in the aforementioned natural language to database query language system. Figure 7 This is a flowchart of a method for converting natural language to database query language according to an embodiment of the present invention, such as... Figure 7 As shown, the process includes the following steps: Step S701: Disclose the skill information of the Skill system to the large language model. For details, please refer to [link to relevant documentation]. Figure 5 Step S501 of the illustrated embodiment will not be described again here.

[0073] Step S702: Obtain the natural language information input by the user, disclose the business term mapping rules of the Skill system to the retrieval enhancement model, the retrieval enhancement model determines the initial business terms corresponding to the natural language information, and the large language model converts the natural language information into standardized text based on the skill information and the initial business terms.

[0074] Specifically, step S702 includes: Step S7021: The large language model determines the transcription instruction template based on the skill information. The transcription instruction template includes at least a standard text structure, transcription rules, and a natural language dictionary summary.

[0075] Specifically, in embodiments of the present invention, such as Figure 8 As shown, after the user inputs natural language, the Skill is activated, and the RAG determines the initial business terms to complete the requirement parsing, the large language model, based on the disclosed Skill system skill information, calls the system's preset exclusive transcription instruction template. This transcription instruction template is a standardized generation template exclusive to the Text2SQL skill and is an important component of the core execution logic of the Skill system. The template content includes at least three core parts: standardized text structure, transcription rules, and natural language dictionary summary.

[0076] The standardized text structure defines the fixed layout and semantic organization logic of the standardized text, requiring it to be arranged in a fixed order of "time dimension - geographical scope - screening conditions - vehicle attributes - statistical indicators - statistical dimensions". The transcription rules specify unified rewriting principles such as colloquial deletion and completion, terminology standardization, condition structuring, and invalid semantic removal. The natural language dictionary summary is a lightweight index of core vehicle-related terms, summarizing only the definitions and mapping relationships of core terms adapted to the current scenario, without loading the full dictionary data, which aligns with the design logic of progressive disclosure and on-demand loading. This embodiment of the invention completely solves the problems of messy sentence structure, inconsistent output, and semantic loss in traditional rewriting methods by constraining the rewriting logic with fixed instruction templates.

[0077] Step S7022: Extract business term mapping rules that match the initial business terms based on the natural language dictionary summary, and convert the initial business terms into standard business terms according to the business term mapping rules.

[0078] Specifically, in this embodiment of the invention, after the RAG retrieves the business terminology table and completes the mapping between user colloquial expressions and initial business terms, the business terminology mapping rules that highly match the current initial business terms are accurately extracted by combining the natural language dictionary summary loaded by the large language model. The business terminology mapping rules of the Skill system cover the one-to-one correspondence between synonyms, abbreviations, colloquial expressions and standard professional terms in the vehicle field, and can adapt to the standardized conversion of various non-standard vehicle business expressions. For this scenario, the colloquial and non-standard initial terms in the user input can be converted through the corresponding mapping rules. For example, the colloquial "low battery power" can be uniformly mapped to the standard business term "battery SOC is below 20%", "vehicle offline time" can be mapped to "vehicle continuous offline time", and "vehicle purchase time" can be mapped to "vehicle purchase time". Finally, all initial business terms are standardized and replaced, eliminating the semantic deviation caused by colloquial and non-standard terms, and providing a standardized terminology foundation for subsequent text regularization.

[0079] Step S7023: Rewrite the natural language information according to the standardized text structure, transcription rules and standard business terms to generate standardized text.

[0080] Specifically, in this embodiment of the invention, the large language model strictly follows the standardized text structure and unified transcription rules in the transcription instruction template, as well as the standard business terms obtained from the above conversion, to comprehensively regulate and rewrite the user's original, fragmented, and colloquial natural language information, thereby eliminating all interjections and redundant descriptions, such as "help me take a look," "please check," "want to know," etc.; it fully retains the core query entities, time dimension, region dimension, filtering conditions, statistical dimensions, and business indicators without omission; and it converts colloquial expressions into standard business terms in the NLQ dictionary to ensure that the subsequent rule engine can directly parse them.

[0081] Furthermore, the rewriting process automatically completes missing semantics, eliminates invalid and redundant expressions, standardizes terminology format, and structurally organizes filtering conditions and statistical logic. It reorganizes user query requirements according to a preset standard structure, ultimately generating standardized text that is semantically unambiguous, uniformly formatted, semantically complete, and compatible with subsequent database table matching and SQL generation. In this scenario, the final standardized text is: “Battery SOC below 20% in Region A in February 2026; continuous offline for over 72 hours; purchase time: total number of pure electric vehicles in 2024-2025; vehicle model.” This standardized text has a clear structure, explicit conditions, and standard terminology, fully meeting the prerequisites for accurate database table matching and standardized database query language generation.

[0082] In some optional implementations, the introduction of the canonical text layer in this invention brings three engineering benefits. First, improved accuracy: Text transcription is one of the core capabilities that large language models excel at. Compared to directly generating SQL, generating canonical text significantly reduces the complexity of the task and significantly improves the success rate. Even if there are minor deviations, business personnel can immediately detect and correct them by directly reading the canonical text. This confirmation step can block the propagation of errors before query execution, fundamentally solving the trust risk caused by model illusion. Second, reduced cost: Traditional solutions require injecting a large amount of database schema information into the context for the model to understand, resulting in extremely high token consumption. In the canonical text solution, the model only needs to receive transcription rules and a small number of terminology hints to complete the task, significantly reducing computational costs. Third, improved system stability: Complex semantic parsing, table join inference, and SQL generation logic no longer rely on model reasoning but are handled by a deterministic rule engine, making system behavior more controllable and predictable.

[0083] Step S703: In response to the confirmation that the canonical text is correct, the retrieval enhancement model determines the database-table mapping information based on the canonical text. For details, please refer to [link to details]. Figure 5 Step S503 of the illustrated embodiment will not be described again here.

[0084] Step S704: The natural language rule engine generates a database query language corresponding to the natural language information based on the database table mapping information and the standard text.

[0085] Specifically, step S704 above includes: In step S7041, the natural language rule engine performs semantic parsing on the standard text based on the mapping rules of the business dictionary and the database table mapping information to obtain a structured query expression.

[0086] Specifically, in this embodiment of the invention, relying on the progressive disclosure mechanism of the Skill system, during the SQL generation stage, only SQL writing specifications, performance optimization rules, and matching high-quality SQL examples are disclosed as needed. Rule matching and semantic parsing are completed using the business dictionary in the resource directory and the database table mapping information determined by the retrieval enhancement model. Through multi-layered structured parsing, example constraints, query structure splitting and merging compilation, a syntactically compliant, business-accurate, and directly executable database query language is finally output. It is evident that redundant information such as previous terminology rules and full table structures are no longer loaded during the SQL generation stage, achieving phased and precise information loading and avoiding context waste and model inference interference.

[0087] The database and table mapping information determined by the retrieval enhancement model is uniformly stored in the business dictionary under the Skill system resource directory. Corresponding to the deep loading phase of the progressive disclosure mechanism, it is only retrieved and used as needed after entering the SQL generation stage. Furthermore, the business dictionary maps business language to the database structure and incorporates multi-dimensional standardized mapping rules, specifically including four core rule categories: entity mapping rules, field cluster mapping rules, synonym mapping rules, and macro term mapping rules. These rules cover the entire process of parsing object definition, field matching, terminology standardization, and business logic encapsulation in the vehicle business scenario. Through multi-dimensional rules, the standardized text is parsed layer by layer, transforming the fuzzy semantics of natural language into machine-recognizable, structured, and unambiguous structured query expressions, providing a standardized semantic foundation for subsequent query statement compilation.

[0088] In some optional implementations, step S7041 above includes: Step a1: Determine the business objects contained in the specification text, and perform entity mapping on the business objects based on the database table mapping information and entity mapping rules to determine the configuration parameters corresponding to the business objects.

[0089] Step a2: Determine the business concepts contained in the specification text, and perform field cluster mapping on the business concepts based on the database table mapping information and field cluster mapping rules to determine the business fields corresponding to the business concepts.

[0090] Step a3: Identify the non-standard business terms contained in the standard text, and perform synonym mapping on the non-standard business terms based on the database table mapping information and synonym mapping rules to determine the standard business terms corresponding to the non-standard business terms.

[0091] Step a4: Determine the business expressions contained in the standard text, and perform macro-word mapping on the business expressions based on the database table mapping information and macro-word mapping rules to determine the predefined business rules corresponding to the business expressions.

[0092] Step a5 integrates configuration parameters, business fields, standard business terms, and predefined business rules into a structured query expression.

[0093] Specifically, in this embodiment of the invention, the business object is the core entity subject pointed to by the user query in the standardized text. For example, in the vehicle network data query scenario, the business object corresponds to "pure electric vehicle". Entity mapping rules are used to achieve accurate alignment between business entities and database entity objects. Combining database table mapping information such as the vehicle basic information table and the vehicle location information table, the business entities in the user's requirements are mapped to the corresponding entity configuration parameters in the database, clarifying the core query subject and entity attribute range of this query. Each entity mapping includes business terminology, mapping type (table level or field level), target table name, target field name, data layer identifier, and a description of business meaning.

[0094] Taking a connected vehicle scenario as an example: "Vehicle" is mapped to the `dws_vehicle_base_info_wide` table (DWS summary layer), "Fault Alarm" is mapped to the `dwd_vehicle_fault_alarm_di` table (DWD detail layer), and "Battery SOC" is mapped to the `battery_soc` field of the `dwd_tbox_real_time_data_di` table. It is evident that entity mapping requires strict alignment with the data warehouse table structure to ensure resolvability.

[0095] In some optional implementations, business concepts refer to the business dimensions and status concepts used for filtering and statistics in the standardized text, such as battery status, online status, purchase time, location, and vehicle model. Field cluster mapping rules are used to batch map a class of related business concepts to corresponding field clusters in the database, simplifying multi-field matching logic. Then, relying on the database information from the vehicle battery status data table and the vehicle online status monitoring table, core business fields such as battery SOC, offline duration, purchase time, location, and vehicle model are matched, achieving accurate mapping of business concepts to physical fields.

[0096] For example, "Battery Status Information" includes three fields: Battery SOC, driving range, and energy consumption per 100 kilometers; "Trip Core Indicators" includes four fields: trip mileage, trip duration, average vehicle speed, and energy consumption per 100 kilometers; and "Vehicle Core Information" includes four fields: Vehicle VIN, vehicle model, city of origin, and purchase date. When a user queries a business concept, the system automatically expands to all the corresponding fields.

[0097] In some optional implementations, non-standard expressions such as residual business jargon, cross-departmental terms, and common aliases in users' natural language are mapped to standard business terms defined in the dictionary using synonym mapping rules. For example, "battery power" and "remaining battery power" are both mapped to "battery SOC"; "vehicle" and "whole vehicle" are both mapped to "vehicle"; "vehicle frame number" and "VIN code" are both mapped to "vehicle VIN"; "electricity consumption" and "fuel consumption" are both mapped to "energy consumption per 100 kilometers"; "charging transaction history" is mapped to "charging orders"; "last year" is mapped to "previous year"; and "last 7 days" is mapped to "past 7 days". It is evident that the establishment of synonym mapping must follow the principle of first matching existing synonyms and macros to avoid redundant definitions, thereby completely eliminating ambiguity in spoken language, ensuring unique semantics in parsing, unified rules, and conforming to standardized business expressions in the vehicle domain.

[0098] In some optional implementations, macro mapping rules are used to encapsulate complex and fixed business statistical logic and filtering rules. For business expressions such as condition combinations and statistical definitions in the standard text, they map to predefined standardized business rules, that is, encapsulating complex multi-condition business rules into concise business expressions, which are then expanded into specific SQL filtering or calculation logic during mapping. For example: "offline vehicle" expands to "online_status equals offline AND TIMESTAMPDIFF(HOUR, report_time, NOW()) greater than or equal to 72"; "depleted battery vehicle" expands to "battery_soc less than or equal to 20"; "severely faulty vehicle" expands to "fault_level IN (Level 1, Level 2)"; "abnormal charging vehicle" expands to "charge_status equals failure AND COUNT(charge_order_id) greater than or equal to 3 GROUP BY vin"; "overdue maintenance vehicle" expands to "TIMESTAMPDIFF(MONTH, service_time, NOW()) greater than or equal to 6 OR current_mileage minus last_service_mileage greater than or equal to 10000". As can be seen, the macro mechanism enables the standard text to express complex filtering logic in concise business language, while macro mapping directly calls the preset mature business logic, avoiding rule deviations caused by the model's autonomous reasoning, thereby ensuring that the backend can accurately expand into executable SQL fragments.

[0099] Furthermore, such as Figure 8As shown, after the user confirms the standardized text, the natural language rule engine, after completing the aforementioned four-layer mapping to obtain entity configuration parameters, physical business fields, standardized terms, and predefined business rules, performs structured reorganization. It then integrates and outputs a structured query expression (Model Query Language, MQL) according to a fixed structure of "query entity - filter conditions - statistical dimensions - aggregation metrics," achieving a complete structured, digitized, and rule-based transformation of natural language semantics. MQL is used to describe query entities, related tables, related primary keys, query conditions, statistical dimensions, and aggregation metrics. Furthermore, MQL is closer to business semantics, making it easier to maintain and audit than SQL.

[0100] In some optional implementations, to ensure mapping accuracy, the business dictionary must adhere to strict management standards in engineering practice. Firstly, regarding version management, each dictionary update requires upgrading the version number, noting the updated content, the updater, and the update time, and managing the entire lifecycle using Git. Secondly, regarding adding rules, new terms must first match existing synonyms and macros to avoid duplicate definitions; entity mappings must be strictly aligned with the data warehouse table structure to ensure parsing capability. Thirdly, regarding production deployment, manual editing and maintenance use YAML source files, which are compiled into JSON format when deployed to the production environment, improving the loading efficiency of the rule engine. Finally, regarding business adaptation, it can be expanded or tailored according to the actual business domain of the enterprise, while the core structure remains unchanged.

[0101] Step S7042: The retrieval enhancement model determines high-quality database query language examples and writing specifications based on canonical text and structured query expressions.

[0102] Specifically, in this embodiment of the invention, in the example loading stage corresponding to the progressive disclosure mechanism, the retrieval enhancement model does not load the full knowledge base. Instead, it accurately recalls high-quality historical SQL examples and standardized writing specifications with the same scenario, table structure, and statistical logic based solely on the business type, table structure, and statistical caliber of the current standardized text and structured query expression. By constraining the generation logic through examples, the syntax for multi-table associations, filtering methods, and grouping and aggregation rules are limited, avoiding syntax errors, logical omissions, and semantic illusions caused by free reasoning in large language models. This significantly improves the standardization of statement generation in complex vehicle query scenarios.

[0103] Step S7043: The structured query expression is split into a dimensional query language and a structured processing language. The dimensional query language is used to define multi-table join paths, basic filtering conditions, and statistical dimensions, while the structured processing language is used to define the calculation logic and output structure.

[0104] Specifically, in this embodiment of the invention, an innovative dual-language decomposition and compilation mechanism is adopted, that is, the unified structured query expression MQL is decomposed into two independent sub-languages: Dimensional Query Language (DQL) and Structured Processing Language (SPL), to decouple the query structure from the computational logic. DQL is responsible for defining the underlying query framework, i.e., data acquisition and multi-table joins. It determines the multi-table join paths, location and time filtering conditions, and vehicle model statistical dimensions based on the vehicle basic information table, vehicle battery status data table, vehicle online status monitoring table, and vehicle location information table, and uses dots to express the join relationships instead of complex JOIN syntax. For example, "pure electric vehicle.vehicle VIN to TBOX real-time data.vehicle VIN" expresses the join path between the two tables through the VIN field. Simultaneously, DQL carries the definition of basic filtering conditions and statistical dimensions. SPL is responsible for upper-level business calculations, defining vehicle quantity statistics, aggregation calculations, result output fields, and output sorting structures. That is, SPL is responsible for complex data calculations, receiving the raw dataset returned by DQL as input, performing calculation logic such as deduplication counting, percentage calculation, and complex indicator analysis, and defining the output structure.

[0105] It is evident that the two functions are independent and do not interfere with each other, effectively solving the problems of structural chaos and computational logic errors in complex multi-condition query scenarios. Furthermore, the decoupling of DQL and SPL has clear engineering value: DQL is only responsible for "data retrieval," allowing for independent optimization of indexing and association logic; SPL is only responsible for "computation," and if subsequent adjustments to metrics (such as adding "average battery SOC") are needed, there is no need to modify the data retrieval logic of DQL. This separation significantly improves the maintainability and scalability of the system.

[0106] For example, continuing the query example from the above vehicle-to-everything (V2X) scenario, the complete transformation chain is demonstrated from MQL to executable SQL: ①MQL Output: The entity is a pure electric vehicle, and the associated tables are dws_vehicle_base_info_wide and dwd_tbox_real_time_data_di, with the primary key being the vehicle's VIN (vin). Conditions include: data collection time equal to February 2026, city equal to A, battery SOC less than 20%, continuous offline time greater than or equal to 72 hours, and purchase date between January 1, 2024 and December 31, 2025. The statistical dimension is vehicle type. The aggregation metric is the total number of vehicles equal to COUNT(DISTINCT Vehicle VIN).

[0107] ②DQL Output: Define the association path as "pure electric vehicle.vehicle VIN to TBOX real-time data.vehicle VIN", with the association table aliases being vehicle_base and tbox_data. The filtering conditions are directly mapped from MQL, including city, purchase time, reporting time range, battery SOC threshold, online status, and offline duration (the macro "continuous offline for more than 72 hours" is expanded into the TIMESTAMPDIFF function logic here).

[0108] ③SPL Output: The input data source is the raw dataset returned by DQL. The calculation logic is COUNT (DISTINCT Vehicle VIN), using deduplication to avoid duplicate counting caused by multiple TBOX minute-level reports of the same vehicle. The output dimension is vehicle type, and the output metric is the total number of vehicles.

[0109] Step S7044: Based on high-quality database query language examples and writing specifications, merge and transform the dimensional query language and structured processing language to obtain the database query language.

[0110] Specifically, in this embodiment of the invention, the natural language rule engine, referring to the high-quality query examples obtained from retrieval and the unified writing specifications, merges and compiles the multi-table join paths, filtering conditions, and statistical dimensions in DQL, as well as the aggregation calculation logic and output structure in the structured processing language. It converts the multi-table join paths into preset join clauses (INNERJOIN clause), the basic filtering conditions into preset filtering clauses (WHERE clause), the statistical dimensions into preset grouping clauses (GROUP BY clause), and the calculation logic of SPL into preset aggregation clauses (aggregate functions in SELECT). Finally, it integrates and generates a syntactically standard, logically rigorous, and directly executable database query language (SQL language), thereby accurately fulfilling the database query requirements.

[0111] This invention provides a method for converting natural language into database query language. By building a Skill system integrating a large language model, a retrieval enhancement model, and a natural language rule engine, and relying on a progressive disclosure mechanism, it achieves multi-model collaboration and phased execution, sequentially completing the standardized conversion of skill information disclosure, natural language information normalization into standardized text, database table mapping information matching, and database query language generation. Through its multi-model decoupling and progressive step-by-step execution architecture, this invention completely changes the traditional extensive mode where a large language model undertakes all reasoning tasks. It calls the retrieval enhancement model in stages as needed to complete business terminology retrieval and database table mapping matching. The large language model achieves natural language normalization, using standardized text as an intermediate expression layer that can be confirmed by business personnel, fundamentally blocking the path of model illusions propagating downstream. Then, a dedicated natural language rule engine generates query language through rule-based processing. The entire process achieves semantic layer-by-layer verification and accurate information disclosure, avoiding semantic deviations and generation errors at the process level. This significantly improves the accuracy of natural language semantic understanding and the accuracy and reliability of database query language generation, and can stably adapt to complex and ever-changing business query scenarios of enterprises.

[0112] This embodiment provides a method for converting natural language to database query language, which can be used in the aforementioned natural language to database query language system. Figure 9 This is a flowchart of a method for converting natural language to database query language according to an embodiment of the present invention, such as... Figure 9 As shown, the process includes the following steps: Step S901: Determine the user's intent based on natural language information, match trigger conditions based on the user's intent, and determine whether to activate the Skill system based on the matched trigger conditions.

[0113] Specifically, in this embodiment of the invention, to adapt to the startup phase logic of the progressive disclosure mechanism, a pre-judgment step is added before the Skill system is officially launched, thereby enabling skills to be activated on demand and avoiding invalid model calculations. After the system obtains the natural language information input by the user, it first performs shallow intent recognition on the text semantics to accurately determine the business type of the user's current need, distinguishing different intents such as vehicle data query needs, equipment control needs, and general question-and-answer needs. At the same time, the Skill system is pre-configured with exclusive trigger conditions, which are precisely bound to the skill description field in the Skill system metadata area, and the rules are defined according to the skill's applicable scenarios, capability boundaries, and business domains. When the user intent is identified as matching the vehicle data query trigger condition, it is determined that the current task is compatible with the Text2SQL Skill capability, and the Skill system is officially activated and enters the subsequent progressive information disclosure and statement generation process; if the user intent does not match or belongs to a non-data query need, the current skill call is directly terminated without loading subsequent skill information, business rules, and database resources, greatly saving system context resources and model computing power overhead, and improving the overall interactive response efficiency.

[0114] Step S902: Disclose the skill information of the Skill system to the large language model. For details, please refer to [link to relevant documentation]. Figure 7 Step S701 of the illustrated embodiment will not be described again here.

[0115] Step S903: Obtain the natural language information input by the user and disclose the business terminology mapping rules of the Skill system to the retrieval enhancement model. The retrieval enhancement model determines the initial business terms corresponding to the natural language information, and the large language model converts the natural language information into standardized text based on the skill information and the initial business terms. For details, please refer to... Figure 7 Step S702 of the illustrated embodiment will not be described again here.

[0116] Step S904: In response to the confirmation that the canonical text is correct, the retrieval enhancement model determines the database-table mapping information based on the canonical text. For details, please refer to [link to details]. Figure 7 Step S703 of the illustrated embodiment will not be described again here.

[0117] Step S905 involves the natural language rule engine generating a database query language corresponding to the natural language information based on the database table mapping information and the canonical text. For details, please refer to [link to relevant documentation]. Figure 7 Step S704 of the illustrated embodiment will not be described again here.

[0118] Step S906: Query the preset database according to the database query language. If the execution is correct, determine the query result.

[0119] Specifically, in this embodiment of the invention, after generating a standardized database query language, the system sends compliant query statements to a preset vehicle business database for retrieval and execution. The preset database stores comprehensive vehicle basic information, battery status, online status, maintenance records, driving data, and other vehicle networking business data, corresponding one-to-one with the aforementioned multiple business data tables. The system monitors the database statement execution status and return feedback in real time, verifying the legality, syntax validity, and data return integrity of the query statements. If the database responds normally, the statement has no syntax errors, and the data retrieval process is completed smoothly, the query execution is deemed correct. The system directly extracts the structured data returned by the database, organizes it to obtain vehicle data query results that accurately match the user's needs, and provides reliable data support for subsequent data display, data statistics, and vehicle management logic.

[0120] In step S907, if an error occurs during execution, the error type is determined, and the retrieval enhancement model determines the solution and historical error correction cases based on the error type. The solution and historical error correction cases are then used for correction until the maximum number of retries is reached or the query result is determined.

[0121] Specifically, in this embodiment of the invention, the Skill system is equipped with a system exception tolerance and self-iterative optimization mechanism. Information loading is triggered only when a query execution exception occurs, and it does not occupy context resources under normal circumstances. When an error occurs during database query execution, the system automatically captures the error log and classifies the error type. It can accurately identify common error types in various vehicle business scenarios, such as multi-table join errors, field matching errors, logical conflicts in filtering conditions, syntax errors, missing permissions, and empty data.

[0122] Furthermore, the retrieval enhancement model retrieves boundary layer anomaly resource files stored in the resource directory as needed, matches them with standardized solutions for the corresponding error types and historical similar error correction cases, and performs targeted correction and iterative optimization of the original database query language based on mature historical cases and fixed error correction rules. The system continuously loops through the correction, retry, and verification process until the statement is executed successfully and the query result is obtained, or terminates the retry after reaching the system's preset maximum number of retries. This effectively solves the statement execution anomaly problem in complex vehicle multi-table query scenarios, and significantly improves the system's robustness and fault tolerance.

[0123] In this embodiment of the invention, the Skill system and RAG are not mutually exclusive; their combination represents the best practice for enterprise-level Text2SQL. In the converged architecture, Skill solidifies the core execution flow, providing end-to-end closed-loop process control, stability assurance, and automatic error handling capabilities; RAG, as a built-in knowledge component of Skill, plays a supplementary role by providing on-demand knowledge retrieval at each execution stage.

[0124] Specifically, in the requirements analysis phase, RAG retrieves a business terminology table to map user-speaker language to standard business terminology. In the table structure matching phase, RAG retrieves table structures and field descriptions relevant to user needs as required, injecting only the currently necessary content in a progressive manner. In the SQL generation phase, RAG retrieves high-quality SQL examples and writing guidelines for similar scenarios. In the error reporting and correction phase, RAG retrieves solutions and historical error correction cases for corresponding error types.

[0125] This invention utilizes Skill's solidified process to ensure the stability and controllability of the end-to-end closed loop, and RAG's flexible retrieval to achieve rapid knowledge updates, enabling knowledge base iteration without modifying Skill's core logic. Skill's progressive disclosure, combined with RAG's on-demand recall, maximizes context utilization efficiency and significantly reduces token consumption and illusion rate. Skill's validation, error correction, and retry mechanisms address the pain point of pure RAG's inability to automatically handle errors, improving the overall robustness of the solution.

[0126] Compared to traditional RAG solutions, the core difference lies in the following: In traditional RAGs, the large language model simultaneously undertakes three roles—knowledge retrieval, inference decision-making, and SQL generation—leading to overload and unstable performance. In the Skill+RAG architecture, however, the role of the large language model is significantly simplified, focusing solely on transcribing natural language into standard text. Complex business logic is handled by the rule engine, while knowledge retrieval and injection are performed on demand by RAG under the scheduling of the Skill framework. This architecture is essentially a deep integration of the Agent model and RAG, transforming the large language model from a "generator" to a "decision-maker," controlling the retrieval process rather than replacing it.

[0127] In summary, in such Figure 7 In the pipeline shown, the responsibilities of each execution entity are clearly defined: the large language model is only responsible for the task of transcribing natural language into canonical text. The NLQ rule engine handles all semantic parsing and SQL generation, with all logic being deterministic rule matching. RAG, under the scheduling of the Skill framework, provides knowledge support as needed at each stage. Users have the right to confirm and correct at the canonical text stage. Each stage has independent input / output schemas and execution logs, supporting individual debugging and continuous optimization.

[0128] Furthermore, the embodiments of the present invention can achieve the following beneficial effects: ① Explainability: Every step of the entire chain is traceable, verifiable, and auditable. Both the canonical text and MQL are human-readable intermediate expressions, meeting the audit requirements of enterprise data governance. ② Controllability: Complex semantic parsing and SQL generation logic are handled by a deterministic rule engine, without relying on model reasoning, and the system behavior is completely predictable. ③ Low illusion rate: The triple guarantee mechanism of progressive disclosure, on-demand retrieval, and canonical text confirmation suppresses the generation and spread of illusions from three dimensions: information input end, processing middle layer, and execution front end. ④ High reusability: Skills can be globally reused after one encapsulation, and business dictionaries can be shared between different query scenarios. New business scenarios only need to expand dictionary entries without rebuilding the process. ⑤ Low cost: Large models only perform lightweight text transcription tasks, without injecting a large amount of schema information into the context, significantly reducing token consumption and reasoning costs. ⑥ Accumulability: Business rules, domain knowledge, and best practices are all solidified into structured assets in Skills and business dictionaries, which can be accumulated, inherited, and version managed, and will not be lost with personnel turnover.

[0129] This invention, through the introduction of a multi-step verifiable layered translation architecture, enables a responsibility separation model where "AI is responsible for understanding, rules are responsible for execution, and users are responsible for confirmation": using standardized text as a verifiable intermediate expression layer to block the spread of illusions; using the progressive disclosure mechanism of the Skill system to achieve precise, phased injection of context; using RAG as a built-in knowledge component of Skill to achieve flexible knowledge updates and on-demand retrieval; and using the NLQ rule engine and a four-layer business dictionary to achieve deterministic execution of semantic parsing and SQL generation.

[0130] Therefore, the core competitiveness of enterprise-level Text2SQL systems will no longer depend on the reasoning capabilities of the large model itself, but rather on whether the enterprise has built a sufficiently deep and comprehensive dedicated Skill system and business dictionary assets. Thus, Skill systems require clearly defined application boundaries and continuous maintenance requirements: the business dictionary needs continuous maintenance; adding new business terms, new table structures, and new metrics all require updating the dictionary and synchronizing version numbers; the quality of standardized text generation depends on the Prompt project, requiring continuous optimization of transcription rules and examples. For highly flexible exploratory data analysis scenarios where pre-defined rules are impossible, the traditional RAG plus direct SQL generation approach may be more suitable.

[0131] In this embodiment of the invention, tools and models will be continuously iterated and updated, but the business rules, domain knowledge, and workflows accumulated in the Skill are truly long-term assets with compound interest properties. The final industry standard architecture will inevitably converge into a three-layer architecture of "general basic model plus Harness runtime capability plus enterprise-specific Skill asset library", and Text2SQL is just a standard instance of this architecture in the vertical scenario of data query.

[0132] The best applicable scenarios for the embodiments of the present invention are: core data queries in enterprise-level production environments, complex multi-table join queries, business scenarios with strict requirements for accuracy and stability, industry scenarios with clear business specifications and terminology systems, and data service scenarios that require end-to-end automated closed loops, but are not limited thereto.

[0133] Step S908: Generate vehicle control instructions based on preset control rules and determined query results, and send the vehicle control instructions to the target vehicle to manage the target vehicle.

[0134] Specifically, in this embodiment of the invention, the Skill system can further extend the intelligent vehicle management and control closed-loop capability based on data query, connecting the business link between natural language data query and active vehicle management and control. The system pre-stores vehicle-specific preset control rules, which are bound to vehicle operating condition thresholds, equipment status conditions, operation and maintenance management strategies, and other vehicle network business logic, adaptable to scenarios such as handling abnormal vehicle states, remote operation and maintenance, and status control. The system logically compares the aforementioned vehicle query results with the preset control rules. When the query results meet the preset management and control trigger conditions, it automatically generates standardized vehicle control commands adapted to the target vehicle. Then, the system sends the generated vehicle control commands to the on-board controller of the corresponding target vehicle through the vehicle network communication link. The on-board controller parses and executes the command logic to complete the integrated management and control operation of the target vehicle, realizing a fully automated closed loop from natural language requirement input, intelligent query, data analysis to intelligent vehicle management and control, effectively improving the intelligence level and practicality of vehicle network operation and maintenance and management.

[0135] This invention provides a method for converting natural language into database query language. By building a Skill system integrating a large language model, a retrieval enhancement model, and a natural language rule engine, and relying on a progressive disclosure mechanism, it achieves multi-model collaboration and phased execution, sequentially completing the standardized conversion of skill information disclosure, natural language information normalization into standardized text, database table mapping information matching, and database query language generation. Through its multi-model decoupling and progressive step-by-step execution architecture, this invention completely changes the traditional extensive mode where a large language model undertakes all reasoning tasks. It calls the retrieval enhancement model in stages as needed to complete business terminology retrieval and database table mapping matching. The large language model achieves natural language normalization, using standardized text as an intermediate expression layer that can be confirmed by business personnel, fundamentally blocking the path of model illusions propagating downstream. Then, a dedicated natural language rule engine generates query language through rule-based processing. The entire process achieves semantic layer-by-layer verification and accurate information disclosure, avoiding semantic deviations and generation errors at the process level. This significantly improves the accuracy of natural language semantic understanding and the accuracy and reliability of database query language generation, and can stably adapt to complex and ever-changing business query scenarios of enterprises.

[0136] This embodiment also provides an apparatus for converting natural language to database query language. This apparatus is used to implement the above embodiments and preferred embodiments, and details already described will not be repeated. As used below, the term "module" can be a combination of software and / or hardware that implements a predetermined function. Although the apparatus described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.

[0137] This embodiment provides a device for converting natural language into database query language, such as... Figure 10 As shown, it includes: The initial call module 1001 is used to disclose skill information of the Skill system to the large language model.

[0138] The requirement parsing module 1002 is used to obtain natural language information input by the user and disclose the business term mapping rules of the Skill system to the retrieval enhancement model. The retrieval enhancement model determines the initial business terms corresponding to the natural language information, and the large language model converts the natural language information into standardized text based on the skill information and the initial business terms.

[0139] The table structure matching module 1003 is used to determine the database table mapping information based on the standard text in response to the confirmation that the standard text is correct.

[0140] The query language generation module 1004 is used by the natural language rule engine to generate a database query language corresponding to the natural language information based on the database table mapping information and the standard text.

[0141] In some optional implementations, skill information is stored in the core definition file of the Skill system. The core definition file is divided into a metadata area and a core instruction area. The metadata area includes at least a skill name field and a skill description field. The skill name field is used to characterize the skill type of the Skill system, and the skill description field is used to determine whether the Skill system is activated. The core instruction area includes at least a skill execution logic and a skill workflow. The skill execution logic and skill workflow are executed by referencing a preset directory. The preset directory includes a code directory and a resource directory. The executable scripts stored in the code directory are used to perform deterministic computation tasks, and the resource files stored in the resource directory correspond to the progressive disclosure mechanism.

[0142] In some optional implementations, the database table mapping information is stored in a business dictionary under the resource directory, and the query language generation module 1004 includes: The query expression determination unit is used by the natural language rule engine to perform semantic parsing on the standardized text based on the mapping rules of the business dictionary and the database table mapping information to obtain a structured query expression.

[0143] The query instance determination unit is used by the retrieval enhancement model to determine high-quality database query language examples and writing specifications based on canonical text and structured query expressions.

[0144] The query expression decomposition unit is used to split the structured query expression into a dimensional query language and a structured processing language. The dimensional query language is used to define multi-table join paths, basic filtering conditions, and statistical dimensions, while the structured processing language is used to define the calculation logic and output structure.

[0145] The query language generation unit is used to merge and transform dimensional query language and structured processing language into a database query language based on high-quality database query language examples and writing specifications. Specifically, it transforms multi-table join paths into preset join clauses, basic filtering conditions into preset filtering clauses, statistical dimensions into preset grouping clauses, and calculation logic into preset aggregation clauses.

[0146] In some optional implementations, the mapping rules include: entity mapping rules, field cluster mapping rules, synonym mapping rules, and macro term mapping rules; the query expression determination unit includes: The first mapping subunit is used to determine the business objects contained in the specification text, and to perform entity mapping on the business objects based on the database table mapping information and entity mapping rules, and to determine the configuration parameters corresponding to the business objects.

[0147] The second mapping subunit is used to determine the business concepts contained in the specification text, and to perform field cluster mapping on the business concepts based on the database table mapping information and field cluster mapping rules, thereby determining the business fields corresponding to the business concepts.

[0148] The third mapping subunit is used to determine the non-standard business terms contained in the standard text, and to perform synonym mapping on the non-standard business terms based on the database mapping information and synonym mapping rules, so as to determine the standard business terms corresponding to the non-standard business terms.

[0149] The fourth mapping subunit is used to determine the business expressions contained in the standard text, and to perform macro-word mapping on the business expressions based on the library table mapping information and macro-word mapping rules, and to determine the predefined business rules corresponding to the business expressions.

[0150] Combination units are used to integrate configuration parameters, business fields, standard business terms, and predefined business rules into a structured query expression.

[0151] In some alternative implementations, the requirements analysis module 1002 includes: The template determination unit is used by the large language model to determine the transcription instruction template based on skill information. The transcription instruction template includes at least a standard text structure, transcription rules, and a natural language dictionary summary.

[0152] The terminology conversion unit is used to extract business terminology mapping rules that match the initial business terms based on the natural language dictionary summary, and to convert the initial business terms into standard business terms according to the business terminology mapping rules.

[0153] The language rectification unit is used to rectify and rewrite natural language information according to the standardized text structure, transcription rules, and standard business terminology to generate standardized text.

[0154] In some alternative embodiments, the apparatus further includes: The system activation module is used to determine the user's intent based on natural language information, match trigger conditions based on the user's intent, and determine whether to activate the Skill system based on the matched trigger conditions.

[0155] The database query module is used to query a preset database according to a database query language. If the execution is correct, the query result is determined.

[0156] The error reporting and correction module is used to determine the error type if an error occurs during execution. The retrieval enhancement model then determines the solution and historical error correction cases based on the error type, and makes corrections based on the solution and historical error correction cases until the maximum number of retries is reached or the query result is determined.

[0157] The vehicle control module is used to generate vehicle control commands based on preset control rules and determined query results, and then send the vehicle control commands to the target vehicle to manage and control the target vehicle.

[0158] The apparatus for converting natural language to database query language provided in this embodiment of the invention can execute the method for converting natural language to database query language provided in any embodiment of the invention, and has the corresponding functional modules and beneficial effects for executing the method. Further functional descriptions of the various modules and units described above are the same as in the corresponding embodiments described above, and will not be repeated here.

[0159] Figure 11 A schematic diagram of the structure of a vehicle controller is provided for an embodiment of the present invention.

[0160] The following is a detailed reference. Figure 11 The diagram illustrates a structural schematic suitable for implementing a controller in an embodiment of the present invention. The controller may include a processor (e.g., a central processing unit, graphics processing unit, etc.) 1101, which can perform various appropriate actions and processes according to a program stored in read-only memory (ROM) 1102 or a program loaded from memory 1108 into random access memory (RAM) 1103. The RAM 1103 also stores various programs and data required for controller operation. The processor 1101, ROM 1102, and RAM 1103 are interconnected via a bus 1104. An input / output (I / O) interface 1105 is also connected to the bus 1104.

[0161] Typically, the following devices can be connected to I / O interface 1105: input devices 1106 including, for example, a touchscreen, touchpad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; output devices 1107 including, for example, a liquid crystal display (LCD), speaker, vibrator, etc.; memory 1108 including, for example, magnetic tape, hard disk, etc.; and communication devices 1109. Communication device 1109 allows the controller to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 11 A controller with various devices is shown, but it should be understood that it is not required to implement or have all of the devices shown, and may alternatively implement or have more or fewer devices.

[0162] In particular, according to embodiments of the present invention, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of the present invention include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device 1109, or installed from a memory 1108, or installed from a ROM 1102. When the computer program is executed by the processor 1101, it performs the functions defined in the natural language to database query language method of the embodiments of the present invention.

[0163] Figure 11 The controller shown is merely an example and should not be construed as limiting the functionality and scope of use of the embodiments of the present invention.

[0164] This invention also provides a computer-readable storage medium. The methods described above according to embodiments of the invention can be implemented in hardware or firmware, or implemented as recordable on a storage medium, or implemented as computer code downloaded via a network and originally stored on a remote storage medium or a non-transitory machine-readable storage medium and subsequently stored on a local storage medium. Thus, the methods described herein can be processed by software stored on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. The storage medium can be a magnetic disk, optical disk, read-only memory, random access memory, flash memory, hard disk, or solid-state drive, etc.; further, the storage medium can also include combinations of the above types of memory. It is understood that computers, processors, microprocessor controllers, or programmable hardware include storage components capable of storing or receiving software or computer code. When the software or computer code is accessed and executed by the computer, processor, or hardware, the natural language to database query language method shown in the above embodiments is implemented.

[0165] A portion of this invention can be applied as a computer program product, such as computer program instructions, which, when executed by a computer, can invoke or provide the methods and / or technical solutions according to the invention through the operation of the computer. Those skilled in the art will understand that the forms in which computer program instructions exist in a computer-readable medium include, but are not limited to, source files, executable files, installation package files, etc. Correspondingly, the ways in which computer program instructions are executed by a computer include, but are not limited to: the computer directly executing the instructions, or the computer compiling the instructions and then executing the corresponding compiled program, or the computer reading and executing the instructions, or the computer reading and installing the instructions and then executing the corresponding installed program. Here, the computer-readable medium can be any available computer-readable storage medium or communication medium accessible to a computer.

[0166] Although embodiments of the invention have been described in conjunction with the accompanying drawings, those skilled in the art can make various modifications and variations without departing from the spirit and scope of the invention, and such modifications and variations all fall within the scope defined by the appended claims.

Claims

1. A method for converting natural language into a database query language, characterized in that, Applied to the Skill system, which incorporates a large language model, a retrieval enhancement model, and a natural language rule engine, and executed in stages based on a progressive disclosure mechanism, the method includes: Disclose the skill information of the Skill system to the large language model; The system acquires natural language information input by the user and discloses the business term mapping rules of the Skill system to the retrieval enhancement model. The retrieval enhancement model determines the initial business terms corresponding to the natural language information, and the large language model converts the natural language information into standardized text based on the skill information and the initial business terms. In response to the confirmation that the standard text is correct, the retrieval enhancement model determines the database table mapping information based on the standard text. The natural language rule engine generates a database query language corresponding to the natural language information based on the database table mapping information and the standard text.

2. The method according to claim 1, characterized in that, The skill information is stored in the core definition file of the Skill system, which is divided into a metadata area and a core instruction area. The metadata area includes at least: a skill name field and a skill description field, wherein the skill name field is used to characterize the skill type of the Skill system, and the skill description field is used to determine whether the Skill system is activated; The core instruction area includes at least: skill execution logic and skill workflow. The skill execution logic and skill workflow are executed by referencing a preset directory. The preset directory includes: a code directory and a resource directory. The executable scripts stored in the code directory are used to perform deterministic computation tasks. The resource files stored in the resource directory correspond to the progressive disclosure mechanism.

3. The method according to claim 2, characterized in that, The database table mapping information is stored in the business dictionary under the resource directory. The step of generating a database query language corresponding to the natural language information by the natural language rule engine based on the database table mapping information and the canonical text includes: The natural language rule engine performs semantic parsing on the standard text based on the mapping rules of the business dictionary and the database table mapping information to obtain a structured query expression; The retrieval enhancement model determines high-quality database query language examples and writing specifications based on the canonical text and the structured query expression; The structured query expression is broken down into a dimensional query language and a structured processing language. The dimensional query language is used to define multi-table join paths, basic filtering conditions, and statistical dimensions, while the structured processing language is used to define the calculation logic and output structure. Based on the high-quality database query language example and the writing specifications, the dimension query language and the structured processing language are merged and transformed to obtain the database query language, wherein the multi-table association path is transformed into a preset join clause, the basic filtering conditions are transformed into a preset filter clause, the statistical dimensions are transformed into a preset grouping clause, and the calculation logic is transformed into a preset aggregation clause.

4. The method according to claim 3, characterized in that, The mapping rules include: entity mapping rules, field cluster mapping rules, synonym mapping rules, and macroword mapping rules. The natural language rule engine performs semantic parsing on the standardized text based on the mapping rules of the business dictionary and the database table mapping information to obtain a structured query expression, including: Identify the business objects contained in the specification text, and perform entity mapping on the business objects based on the database table mapping information and the entity mapping rules to determine the configuration parameters corresponding to the business objects; The business concepts contained in the specification text are determined, and the business concepts are mapped to fields based on the database table mapping information and the field cluster mapping rules to determine the business fields corresponding to the business concepts; Identify the non-standard business terms contained in the standardized text, and perform synonym mapping on the non-standard business terms based on the database table mapping information and the synonym mapping rules to determine the standard business terms corresponding to the non-standard business terms; The business expressions contained in the standard text are determined, and macro-word mapping is performed on the business expressions based on the library table mapping information and the macro-word mapping rules to determine the predefined business rules corresponding to the business expressions; The configuration parameters, business fields, standard business terms, and predefined business rules are integrated into the structured query expression.

5. The method according to claim 1, characterized in that, After the natural language rule engine generates a database query language corresponding to the natural language information based on the database table mapping information and the canonical text, the method further includes: The database is queried according to the database query language. If the query is successful, the query result is determined. If an error occurs during execution, the error type is determined, and the retrieval enhancement model determines a solution and historical error correction cases based on the error type. The solution and historical error correction cases are then used to make corrections until the maximum number of retries is reached or a query result is determined.

6. The method according to claim 1, characterized in that, The process of converting the natural language information into canonical text by the large language model based on the skill information and the initial business terms includes: The large language model determines a transcription instruction template based on the skill information, and the transcription instruction template includes at least a standard text structure, transcription rules, and a natural language dictionary summary. Based on the natural language dictionary summary, extract business term mapping rules that match the initial business terms, and convert the initial business terms into standard business terms according to the business term mapping rules; The natural language information is standardized and rewritten according to the standardized text structure, the transcription rules, and the standard business terms to generate the standardized text.

7. The method according to claim 1, characterized in that, Before disclosing the skill information of the Skill system to the large language model, the method further includes: The user intent is determined based on the natural language information, and triggering conditions are matched based on the user intent. Based on the matched triggering conditions, it is determined whether to activate the Skill system.

8. The method according to claim 5, characterized in that, After determining the query results, the method further includes: Based on the preset control rules and the determined query results, a vehicle control command is generated and sent to the target vehicle to manage and control the target vehicle.

9. An apparatus for converting natural language to database query language, characterized in that, Applied to the Skill system, which is equipped with a large language model, a retrieval enhancement model, and a natural language rule engine, and executed in stages based on a progressive disclosure mechanism, the device includes: The initial invocation module is used to disclose the skill information of the Skill system to the large language model; The requirement parsing module is used to obtain natural language information input by the user and disclose the business term mapping rules of the Skill system to the retrieval enhancement model. The retrieval enhancement model determines the initial business terms corresponding to the natural language information, and the large language model converts the natural language information into standard text based on the skill information and the initial business terms. The table structure matching module is used to determine the database table mapping information based on the standard text in response to the confirmation that the standard text is correct. The query language generation module is used by the natural language rule engine to generate a database query language corresponding to the natural language information based on the database table mapping information and the standard text.

10. A vehicle, characterized in that, The vehicle includes a controller, the controller comprising: A memory and a processor are communicatively connected, the memory storing computer instructions, and the processor executing the computer instructions to perform the method of converting natural language to database query language as described in any one of claims 1 to 8.

11. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions for causing a computer to perform the method of converting natural language to database query language as described in any one of claims 1 to 8.

12. A computer program product, characterized in that, Includes computer instructions for causing a computer to perform the method of converting natural language to database query language as described in any one of claims 1 to 8.