A method, apparatus, device, and storage medium for tag generation based on a large model.

CN122570508APending Publication Date: 2026-08-14SHENZHEN YISHIHUOLALA TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-06-26
Publication Date
2026-08-14

AI Technical Summary

Technical Problem

[0005]鉴于以上所述现有技术的缺点,本申请公开了一种基于大模型的标签生成方法、装置、设备及存储介质,以解决上述标签生成方法技术门槛高、周期长、适配性差以及精度低的问题

Benefits of technology

[0016]本申请的有益效果:本申请提出了一种基于大模型的标签生成方法、装置、设备及存储介质,获取自然语言表征的提问信息;利用预设大模型对所述提问信息进行语义拆解,将拆解所得的标签要素集进行逻辑推理,获得结构对象;先将非结构化自然语言提问转换为无歧义的标准化结构对象,消除了口语化表述、语义歧义对大模型的干扰,提升大模型输入的语义确定性,提升了SQL语句生成准确率;提取所述结构对象对应的工作流,基于所述工作流将生成标签所需的所述提问信息、数据库模式信息与标准示例SQL语句进行组合,生成提示词;在提示词中嵌入了标签生成工作流的业务规则约束,以使大模型生成逻辑受业务规则引导,以使生成的SQL语句符合标签业务逻辑,提升了标签兼容性;同时,在提示词中加入了数据库模式信息与标准示例SQL语句,以使SQL语句生成时可直接参照表字段映射关系与语法规范,降低了字段匹配错误、语法错误的发生概率;利用所述预设大模型基于所述提示词生成目标SQL语句,查询所述目标SQL语句对应的标签信息,从自然语言提问到标签结果输出的全流程自动化处理,无需人工编写SQL语句,提升标签生成效率。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122570508A_ABST
    Figure CN122570508A_ABST
Patent Text Reader

Abstract

This application provides a tag generation method, apparatus, device, and storage medium based on a large model. The method includes: acquiring question information represented by natural language; semantically decomposing the question information using a preset large model, logically reasoning through the decomposed tag element set to obtain a structured object; extracting the workflow of the structured object, combining the question information, database schema information, and standard example SQL statements required for tag generation based on the workflow to generate prompt words; generating a target SQL statement based on the prompt words using the preset large model, querying the tag information corresponding to the target SQL statement, and outputting it. First, unstructured natural language questions are converted into unambiguous standardized structured objects, improving the semantic certainty of the large model input and increasing the accuracy of SQL statement generation; business rule constraints of the tag generation workflow are embedded in the prompt words to ensure that the generated SQL statement conforms to the tag business logic, improving tag compatibility.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the fields of data processing or artificial intelligence technology, and in particular to a method, apparatus, device and storage medium for generating tags based on a large model. Background Technology

[0002] With the rapid development of big data and artificial intelligence technologies, enterprises have accumulated massive amounts of data assets in their daily operations. To achieve refined operations and precise marketing, it is typically necessary to create multi-dimensional profiles of business targets (e.g., users, drivers, merchants, etc.). Tags, as the cornerstone of this profile creation, directly determine the timeliness of business decisions based on their efficiency and accuracy. Tags refer to structured features with business meaning extracted from massive amounts of factual data according to specific business logic and filtering conditions.

[0003] In related technologies, tag creation heavily relies on specialized data developers. After business personnel raise tag requirements, the business specifications are communicated to data developers through cross-departmental communication. The data developers then write complex structured query language statements to perform calculations in a distributed data warehouse, and the results are imported into a user profile platform to generate tags. However, this method of tag generation has the following technical drawbacks: First, tag generation relies on professional technicians, resulting in high transmission costs and high technical barriers. Second, multiple stages require manual intervention, leading to long process cycles and an inability to quickly respond to temporary tag requests, resulting in cumbersome processes and slow responses. Third, the fixed tag generation rules require redeveloping the query logic when conditions need to be adjusted or derivative tags need to be generated, making it difficult to dynamically adapt to diverse and personalized needs, resulting in poor adaptability. Fourth, the lack of effective user feedback and automatic optimization mechanisms means that deviations between the tag generation logic and business needs cannot be corrected in a timely manner, reducing the accuracy of tag generation. Fifth, the independent processes of data querying, cleaning, aggregation, and tag generation require manual coordination, which can easily lead to data inconsistencies and mismatches between tags and requirements. Summary of the Invention

[0004] To provide a basic understanding of some aspects of the disclosed embodiments, a brief summary is given below. This summary is not intended as a general commentary, nor is it intended to identify key / important components or describe the scope of protection of these embodiments, but rather as a prelude to the detailed description that follows.

[0005] In view of the shortcomings of the prior art described above, this application discloses a tag generation method, apparatus, device and storage medium based on a large model, so as to solve the problems of high technical threshold, long cycle, poor adaptability and low accuracy of the above tag generation methods.

[0006] Firstly, this application provides a label generation method based on a large model, the method comprising: The process involves: acquiring question information represented by natural language; semantically decomposing the question information using a pre-defined large model; logically reasoning through the decomposed tag element set to obtain a structured object; extracting the workflow corresponding to the structured object; combining the question information, database schema information, and standard sample SQL (Structured Query Language) statements required for tag generation based on the workflow to generate prompt words; using the pre-defined large model to generate a target SQL statement based on the prompt words; querying the tag information corresponding to the target SQL statement; and outputting the query information.

[0007] In some embodiments, the query information is semantically decomposed using a preset large model, and the resulting tag element set is logically reasoned to obtain a structured object. This includes: semantically decomposing the query information to obtain a tag element set, wherein the tag element set includes at least one of intent, engineering indicators, business lines, and tag conditions; performing a completeness check on the tag element set; if the tag element set is incomplete, searching a preset logical chain based on the missing information in the tag element set to complete the information and generate a complete tag element set; and performing logical reasoning on the complete tag element set to obtain a structured object.

[0008] In some embodiments, the workflow corresponding to the structure object is extracted, and the question information, database schema information, and standard sample SQL statement required for generating the tag are combined based on the workflow to generate prompt words. This includes: extracting the tag body from the structure object; matching the corresponding workflow based on the tag body, wherein each type of tag body corresponds to a dedicated workflow; and based on the workflow, combining the question information, database schema information, and standard sample SQL statement required for generating the tag with the tag element set, and combining the question information, the database schema information, and the standard sample SQL statement to generate prompt words.

[0009] In some embodiments, generating a target SQL statement based on the prompt words using the preset large model, querying the tag information corresponding to the target SQL statement, and outputting it includes: generating a target SQL statement based on the prompt words using the preset large model, inputting the target SQL statement into a target database for querying, obtaining tag information; converting the tag information into a preset metadata format and displaying it in a preset dialogue interface, wherein the preset metadata format consists of a tag identifier, a tag name, a tag level, and a tag value.

[0010] In some embodiments, before inputting the target SQL statement into the target database for querying, the method further includes: performing lexical and syntactic structure parsing on the target SQL statement to obtain table names and field names; comparing the table names and field names with preset database structure information to complete consistency verification; verifying the semantic logic legality in the target SQL statement to complete semantic rule verification; simulating the execution flow of the target SQL statement in the target database to assess logical risks or performance vulnerabilities to complete performance verification, wherein the target database is a temporary database table or a sandbox environment; if all verifications pass, the target SQL statement is successfully verified; if any verification fails, the target SQL statement verification fails.

[0011] In some embodiments, the method further includes: adjusting the dialogue strategy of the preset large model through a reinforcement learning algorithm in response to user feedback instructions, so as to achieve human-computer interaction optimization.

[0012] In some embodiments, adjusting the dialogue strategy of the preset large model using a reinforcement learning algorithm includes: The opinion interaction process in the dialogue strategy is modeled as a Markov decision process, defining a state space and a system action space. The interaction states in the state space are jointly represented by the user's opinion inquiry content, system response history, user feedback information, and dialogue round information. The action space includes multiple types of response actions, including at least opinion summarization, viewpoint comparison, detail listing, multi-round clarification, and greeting / response actions. Combining user feedback ratings of the system responses and a pre-trained dialogue quality assessment model, a reward function corresponding to the state-action pairs is constructed. This reward function is used to comprehensively evaluate user satisfaction and response quality. The system employs a function approximation method to represent the state-action value function, which is then fitted using a deep neural network. The input to the deep neural network consists of interaction state features, and the output is the value estimation result corresponding to each response action. An offline policy learning mechanism is used, storing state transition samples generated during opinion interaction in an experience replay pool, and updating the network parameters of the deep neural network by randomly sampling replay samples. When generating actual response actions, an ε-greedy strategy is used as the reinforcement learning algorithm to select the optimal response action based on the action value estimation result corresponding to the current interaction state, and gradually reducing the exploration probability as the training progresses.

[0013] Secondly, this application provides a tag generation apparatus based on a large model, the apparatus comprising: The system comprises the following modules: an acquisition module, which acquires question information represented by natural language; a decomposition and reasoning module, which uses a pre-defined large model to semantically decompose the question information, performs logical reasoning on the decomposed tag element set, and obtains a structural object; a prompt word generation module, which extracts the workflow corresponding to the structural object, combines the question information, database schema information, and standard example SQL statements required for tag generation based on the workflow, and generates prompt words; and a tag generation module, which uses the pre-defined large model to generate SQL statements based on the prompt words, queries the tag information corresponding to the SQL statements, and outputs the results.

[0014] Thirdly, this application also provides an electronic device, including: a processor, a memory, and a communication bus; the communication bus is used to connect the processor and the memory; the processor is used to execute a computer program stored in the memory to implement the method described in the above embodiments.

[0015] Fourthly, this application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a computer's processor, causes the computer to perform the methods described in the above embodiments.

[0016] The beneficial effects of this application are as follows: This application proposes a label generation method, apparatus, device, and storage medium based on a large model, which obtains question information represented by natural language; semantically decomposes the question information using a preset large model, and performs logical reasoning on the decomposed label element set to obtain a structured object; firstly, unstructured natural language questions are converted into unambiguous standardized structured objects, eliminating the interference of colloquial expressions and semantic ambiguity on the large model, improving the semantic certainty of the large model input, and improving the accuracy of SQL statement generation; the workflow corresponding to the structured object is extracted, and based on the workflow, the question information, database schema information, and standard example SQL statements required for label generation are combined to generate... The system incorporates prompts with embedded business rules governing the tag generation workflow. This ensures that the large-scale model generation logic is guided by these rules, guaranteeing that the generated SQL statements conform to the tag business logic and improving tag compatibility. Furthermore, the prompts include database schema information and standard example SQL statements, allowing direct reference to table field mappings and syntax rules during SQL statement generation, reducing the probability of field matching and syntax errors. The system then uses the preset large-scale model to generate target SQL statements based on these prompts, and queries the corresponding tag information. This fully automated process, from natural language querying to tag result output, eliminates the need for manual SQL statement writing, significantly improving tag generation efficiency.

[0017] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and do not limit this application. Attached Figure Description

[0018] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application. It is obvious that the drawings described below are merely some embodiments of this application, and those skilled in the art can obtain other drawings based on these drawings without any inventive effort. In the drawings: Figure 1 This is a flowchart illustrating a large-model-based label generation method, as shown in an exemplary embodiment of this application. Figure 2 This is an exemplary embodiment of the present application illustrating a verification flowchart of a target SQL statement; Figure 3 This is a complete flowchart illustrating a large-model-based tag generation interaction, as shown in an exemplary embodiment of this application. Figure 4 This is a structural block diagram of a large-model-based tag generation apparatus illustrated in an exemplary embodiment of this application; Figure 5 This is a schematic diagram illustrating the structure of a computer system suitable for implementing the electronic device of this application, as shown in an exemplary embodiment of this application. Detailed Implementation

[0019] The embodiments of this application will be described below with reference to the accompanying drawings and preferred embodiments. Those skilled in the art can easily understand other advantages and effects of this application from the content disclosed in this specification. This application can also be implemented or applied through other different specific embodiments, and various details in this specification can also be modified or changed based on different viewpoints and applications without departing from the spirit of this application. It should be understood that the preferred embodiments are only for illustrating this application and are not intended to limit the scope of protection of this application.

[0020] It should be noted that the illustrations provided in the following embodiments are only schematic representations of the basic concept of this application. Therefore, the drawings only show the components related to this application and are not drawn according to the number, shape and size of the components in actual implementation. In actual implementation, the shape, quantity and proportion of each component may be changed, and the layout of the components may also be more complex.

[0021] In the following description, numerous details are explored to provide a more thorough explanation of embodiments of the present application. However, it will be apparent to those skilled in the art that embodiments of the present application may be practiced without these specific details. In other embodiments, well-known structures and devices are shown in block diagram form rather than in detail to avoid obscuring embodiments of the present application.

[0022] In related technologies, Natural Language to SQL (NLP) queries are directly input into a large model to generate SQL statements without prior semantic structuring. Because colloquial expressions, semantic ambiguities, and omissions in natural language are directly transmitted to the large model generation stage, the accuracy of generated SQL statements is low. Furthermore, the NLP conversion process does not incorporate constraints from the business workflow of the tag generation scenario, resulting in generated SQL statements that do not conform to the business logic rules of tag calculation, cannot adapt to the existing tag system, and are prone to table field matching errors and syntax errors.

[0023] Please see Figure 1 The following is a flowchart illustrating a large-model-based label generation method, as an exemplary embodiment of this application. Figure 1 As shown, in an exemplary embodiment, the label generation method based on a large model includes at least steps S110 to S140, which are described in detail below: Step S110: Obtain the question information from the natural language representation; For example, you can receive user input in the form of a question expressed in natural language, where the input method includes natural language questions expressing intent, engineering metrics, business lines, and tag conditions; or you can set a question template and generate a question in natural language by clicking or modifying the template content.

[0024] Optionally, by performing text cleaning on the question information to remove invalid characters and redundant expressions, a standardized natural language representation of the question information can be obtained.

[0025] Step S120: Use a preset large model to semantically decompose the query information, and perform logical reasoning on the decomposed tag element set to obtain the structure object; The tag element set refers to the collection of semantic units derived from natural language queries that conform to a predefined tag element schema (database structure / directory), and includes at least semantic units such as intent, engineering metrics, business lines, and tag conditions. A structured object refers to a standardized semantic structured entity that possesses complete logical relationships after logical verification and completion.

[0026] For example, the semantic understanding capabilities of a pre-defined large model can replace traditional rule matching to achieve the conversion of non-standard natural language into standardized semantic elements. For instance, semantic defects can be eliminated through logical reasoning, ensuring the logical integrity and business legitimacy of the structured object. Specifically, the pre-defined large model is invoked for semantic parsing, inputting the query information into it; the pre-defined large model semantically decomposes the query according to a pre-defined tag element schema, extracting the corresponding tag element set; logical consistency checks, missing element completion, and semantic disambiguation are performed on the tag element set, verifying the business logic legitimacy between elements, completing user-omitted default elements, eliminating polysemous ambiguity, and outputting a standardized structured object.

[0027] Step S130: Extract the workflow corresponding to the structure object, and generate the question information, database schema information and standard sample SQL statement required for the label based on the workflow to form the prompt words; The workflow refers to the logical process of generating standard example SQL statements in the tag generation scenario, including indicator calculation rules, dimension grouping rules, filter condition concatenation rules, and time range limitation rules.

[0028] For example, by embedding workflow constraints, the prompt words carry the business rules for tag generation, guiding the preset large model to generate standard example SQL statements according to the tag business logic. By adding database schema information and standard example SQL statements, the preset large model is provided with field mapping references and syntax references, reducing the generation error rate. Specifically, the corresponding tag generation workflow identifier is extracted from the structure object, and the corresponding tag calculation logic rules are matched to obtain them. The standardized natural language question information, the database table field mapping information of the corresponding business domain (i.e., database schema information), and the standard example SQL statements in the same scenario are combined according to the preset prompt word template to generate the reasoning prompt words for the preset large model.

[0029] Step S140: Use a preset large model to generate a target SQL statement based on prompt words, query the tag information corresponding to the target SQL statement, and output it.

[0030] For example, structured prompts guide a large model to generate a target SQL statement that meets the requirements, and then the target database is invoked to execute the query, achieving end-to-end conversion from natural language queries to tag query results. Specifically, the constructed prompts are input into a pre-defined large model that has been fine-tuned by an NL2SQL (Natural Language to SQL) task. The pre-defined large model generates a target SQL statement that conforms to grammatical rules and business logic based on the constraints and reference information in the prompts. The target SQL statement is then sent to the corresponding target database to execute the query, obtaining the corresponding tag calculation results. The results are then format-converted and output.

[0031] The above methods are used to obtain question information represented by natural language; the question information is semantically decomposed using a pre-defined large model, and the resulting tag element set is logically reasoned to obtain a structured object; unstructured natural language questions are first converted into unambiguous standardized structured objects, eliminating the interference of colloquial expressions and semantic ambiguity on the large model, improving the semantic certainty of the large model input, and improving the accuracy of SQL statement generation; the workflow corresponding to the structured object is extracted, and the question information, database schema information, and standard example SQL statements required for the tag are generated based on the workflow to form prompt words; the business rule constraints of the tag generation workflow are embedded in the prompt words, and the large model generation logic is guided by the business rules to ensure that the generated SQL statements conform to the tag business logic, improving tag compatibility; at the same time, database schema information and standard example SQL statements are added to the prompt words so that the SQL statement generation can directly refer to the table field mapping relationship and syntax specifications, reducing the probability of field matching errors and syntax errors; the target SQL statement is generated based on the prompt words using the pre-defined large model, and the tag information corresponding to the target SQL statement is queried. The entire process from natural language question to tag result output is automated, without the need for manual SQL statement writing, improving tag generation efficiency.

[0032] In some embodiments, a pre-defined large model is used to semantically decompose the query information, and the resulting set of tag elements is logically reasoned to obtain a structured object, including: Semantically decompose the query information to obtain a set of tag elements. The set of tag elements includes at least one of intent, engineering indicators, business lines and tag conditions. Perform integrity verification on the tag element set. If the tag element set is incomplete, search the preset logical chain based on the missing information in the tag element set to complete the information and generate a complete tag element set. By performing logical reasoning on the complete set of tag elements, a structural object is obtained.

[0033] For example, the preprocessed natural language question information is input into a preset large model. Semantic extraction is performed according to a preset tag element schema to identify the intent type, engineering indicator name, business line, and tag filtering conditions in the question, and output a tag element set. The tag element set is then checked for completeness according to the minimum element requirements for tag generation to determine if any necessary elements are missing. If missing elements are found, existing elements are used as search conditions to match a preset business logic chain to obtain the missing elements associated with the existing elements. The completed elements are then integrated to generate a complete tag element set. A logical consistency check is performed on the complete tag element set to verify the business logic matching relationships between elements, including the attribution relationship between indicators and business lines, the dimensional matching relationship between tag conditions and indicators, and the adaptation relationship between intent and elements, eliminating logical conflicts between elements. The verified tag element set is then encapsulated according to a preset structured format to generate a standardized structured object.

[0034] By implementing the above methods, an element integrity verification mechanism is set up to automatically complete missing elements using a preset logical chain, solving the problem of missing elements caused by the omission of expressions in natural language and improving the integrity of semantic elements. Logical reasoning verification of the complete set of tag elements eliminates business logic conflicts and dimensional mismatches between elements, improving the logical consistency of semantic elements. This results in standardized, logically flawless structured entities in the output structured objects, improving the success rate of downstream tasks. At the same time, element decomposition based on semantic understanding breaks through the sentence structure limitations of traditional rule matching, can adapt to natural language questions with different expressions, and improves the generalization ability of semantic decomposition.

[0035] In some embodiments, the workflow corresponding to the structure object is extracted, and based on the workflow, the question information, database schema information, and standard example SQL statements required for labeling are generated to form prompt words, including: Extract the tag body from the structure object, and match the corresponding workflow based on the tag body. Each type of tag body has its own dedicated workflow. Based on the workflow, the system generates the required question information, database schema information, and standard sample SQL statements for the tags by combining the tag element set. The system then combines the question information, database schema information, and standard sample SQL statements to generate prompt words.

[0036] It should be noted that the tag subject refers to the core business entity or business domain to which the tag belongs, used to distinguish the business attributes of different categories of tags. The workflow refers to the standardized tag calculation rules and SQL statement generation constraint process specific to the tag subject, including tag statistical caliber, calculation logic, and field mapping rules; the database schema information refers to the metadata information of the table structure, field definitions, and relationships of the business database corresponding to the tag.

[0037] For example, attributes such as the business domain and entity type to which the tag belongs are extracted from the standardized structure object to identify the tag subject. Using the tag subject as the search key, a preset workflow mapping table is queried to match the workflow specific to this type of tag subject, and the statistical caliber, calculation logic, and field mapping constraints of the corresponding tag are obtained. According to the rules defined in the workflow, standardized question information is extracted from the tag element set, matched with the database schema information corresponding to the workflow, and the standard example SQL statement under the same tag subject is retrieved. According to the preset prompt word concatenation order, the question information, database schema information, and standard example SQL statement are combined in sequence to generate prompt words that meet the requirements of the large model.

[0038] By employing the above methods, a dedicated workflow is matched for different tag subjects. Based on this workflow, differentiated prompt words are constructed to replace traditional general prompt word templates, improving the adaptability of prompt words. The business calculation rules of the tag-specific workflow are embedded into the prompt word construction stage, so that the large model generation logic is constrained by the workflow rules, improving the compatibility between the generated SQL statements and the tag business rules. Prompt word elements are concatenated according to the constraints of the workflow, avoiding interference from missing elements and redundant information, improving the quality of large model inference, and enhancing the standardization of prompt words. By automatically matching the workflow to the tag subject and automatically concatenating and generating prompt words, there is no need to manually customize prompt word templates for different tags, thus reducing the manual cost of prompt word construction.

[0039] In some embodiments, a target SQL statement is generated based on prompt words using a preset large model, the tag information corresponding to the target SQL statement is queried, and the information is output, including: The system uses a pre-defined large model to generate a target SQL statement based on prompt words, inputs the target SQL statement into the target database for querying, and obtains tag information. The tag information is converted into a preset metadata format and displayed in a preset dialog interface. The preset metadata format consists of tag identifier, tag name, tag level and tag value.

[0040] Among them, the preset metadata format refers to the standardized output format specified by the tag system, which includes tag identifier, tag name, tag level, and tag value fields, and is used to unify the output specifications of different types of tags.

[0041] For example, the structured prompt words are input into a preset large model that has been fine-tuned by the NL2SQL statement task to generate an initial SQL statement; the initial SQL statement is subjected to syntax validity and query permission verification, and after correcting the exceptions, the target SQL statement is obtained; the target SQL statement is sent to the target database of the corresponding business domain to execute the query and obtain the tag calculation result, i.e., the tag information.

[0042] For example, according to preset field mapping rules, the corresponding field content is extracted from the original tag information and mapped to four fields in a preset metadata format: tag identifier, tag name, tag level, and tag value. The mapped metadata undergoes integrity and validity checks, missing field default values ​​are filled in, and illegal field values ​​are filtered out to obtain standardized tag metadata. This standardized tag metadata is then converted into a front-end recognizable rendering format according to the preset dialog interface's rendering rules, structured according to tag level, and sent to the preset dialog interface to complete the tag query result display.

[0043] By adding syntax and permission checks after the target SQL statement is generated, the problem of abnormal target SQL statements is eliminated, and the query success rate is improved. All tag query results are uniformly converted into a preset metadata format of fixed fields, eliminating the output format differences of different tags and improving the standardization of tag output. The entire process from target SQL statement generation to tag result display is automated, without the need for manual format conversion, which improves tag query efficiency and the compatibility of output results.

[0044] Please see Figure 2 The following is a flowchart illustrating a target SQL statement verification process, as shown in an exemplary embodiment of this application. Based on the above embodiment, before inputting the target SQL statement into the target database for querying, the process further includes: The target SQL statement is lexical and syntactically parsed to obtain table names and field names. The table names and field names are then compared with the preset database structure information to complete the consistency check. Verify the semantic logic validity of the target SQL statement to complete the semantic rule validation; The execution flow of the target SQL statement is simulated in the target database to assess logical risks or performance vulnerabilities and complete performance verification. The target database is a temporary database table or a sandbox environment. If all validations pass, the target SQL statement is validated successfully; if any validation fails, the target SQL statement is validated unsuccessfully.

[0045] Among them, consistency verification refers to the matching verification of the database tables and fields referenced by the SQL statement with the preset database structure; semantic rule verification refers to the legality verification of the calculation logic of the SQL statement and the label business rules; performance verification refers to the assessment and verification of the logical risks and performance hazards of SQL statement execution; sandbox environment refers to an isolated test environment with the same structure as the production database and no real business traffic, used to simulate SQL statement execution.

[0046] For example, an SQL statement parser is invoked to perform lexical and syntactic analysis on the target SQL statement, extracting all referenced table names, field names, and function names. The extracted metadata is then compared one by one with the actual structure metadata of the target database to verify whether the table exists, whether the field belongs to the corresponding table, and whether the function is supported. If all items match, the consistency check passes; otherwise, it fails. Based on business rules generated from tags and preset SQL statement semantic validation rules, the legality of the target SQL statement's association conditions, aggregation logic, filtering conditions, and dimension grouping logic is verified. The calculation logic of the target SQL statement is also verified to ensure consistency with the statistical caliber of the corresponding tags, and to check for logical contradictions, missing conditions, etc. If all logic is valid, the semantic rule validation passes; otherwise, it fails.

[0047] For example, the target SQL statement is sent to a temporary database table or sandbox environment with the same structure as the production database to simulate its execution. Information such as execution plan, number of rows scanned, execution time, and full table scan without indexes is collected to assess logical risks and performance vulnerabilities. If no risks are found, the performance verification passes; otherwise, it fails. If all verifications pass, the target SQL statement is successfully verified; if any verification fails, the target SQL statement verification fails. The results of consistency verification, semantic rule verification, and performance verification are summarized. If all three pass, the target SQL statement verification is considered successful; if any one fails, the verification is considered unsuccessful, and the corresponding error type and error message are returned, triggering the regeneration of the target SQL statement or an exception message.

[0048] By employing the above methods, consistency checks can proactively intercept basic errors in target SQL statements, such as table name and field mismatches, preventing database errors during online execution and reducing the error rate of target SQL statement execution. Semantic rule checks can intercept target SQL statements with business logic errors, ensuring that the calculation logic of target SQL statements conforms to the label statistical criteria and improving the correctness of label query results. Performance checks in isolated environments can proactively intercept high-risk SQL statements with performance anomalies, preventing high-risk SQL statements from being executed directly in the production database. This three-level sequential verification mechanism of consistency checks, semantic checks, and performance checks covers all dimensions of target SQL statement verification, from basic syntax to business logic to execution performance, improving the comprehensiveness of target SQL statement verification.

[0049] In some embodiments, the method further includes: adjusting the dialogue strategy of a preset large model through a reinforcement learning algorithm in response to user feedback instructions, so as to achieve human-computer interaction optimization.

[0050] In some embodiments, adjusting the dialogue strategy of a pre-defined large model using a reinforcement learning algorithm includes: The opinion interaction process in the dialogue strategy is modeled as a Markov decision process, and the state space and system action space are defined respectively. The interaction state in the state space is jointly represented by the user's opinion inquiry content, the system's response history information, the user's feedback information, and the dialogue round information. The action space contains multiple types of response actions, which include at least opinion summarization action, viewpoint comparison action, detail listing action, multi-round clarification action, and greeting reply action. By combining user feedback ratings for system responses with a pre-trained dialogue quality assessment model, a reward function corresponding to state-action pairs is constructed. This reward function is used to comprehensively evaluate user satisfaction and response quality. The state-action value function is represented by a function approximation method, and the state-action value function is fitted by a deep neural network; where the input of the deep neural network is the interaction state features, and the output is the value estimation result corresponding to each response action; An experience replay mechanism is used to perform offline policy learning. State transition samples generated during opinion interaction are stored in the experience replay pool, and the network parameters of the deep neural network are updated by randomly sampling replay samples. When generating actual response actions, an ε-greedy strategy is used as the reinforcement learning algorithm. The optimal response action is selected based on the action value estimation result corresponding to the current interaction state, and the exploration probability is gradually reduced as the training process progresses.

[0051] Among them, Markov decision process refers to a mathematical model used for sequential decision-making, which assumes that the next interaction state is determined only by the current state and the current action, and is independent of historical states; state-action value function refers to the cumulative expected reward that can be obtained in the future after performing a certain response action in the current interaction state; experience replay mechanism refers to a reinforcement learning mechanism that stores the state transition samples generated in the interaction process and then repeatedly samples them for training; ε-greedy strategy refers to an action selection strategy that balances strategy exploration and utilization, and controls the proportion of random exploration and optimal action selection through probability parameters.

[0052] For example, the entire process of opinion interaction is abstracted into a sequential decision-making process and modeled as a Markov decision process; a state space is defined, and the user's opinion inquiry content, historical response content, user's historical feedback, and the current dialogue round are converted into feature vectors, which are then concatenated to obtain the feature representation of the interaction state; an action space is defined, and all response actions in the opinion interaction scenario are enumerated to complete the standardized definition of the action space.

[0053] For example, obtaining explicit or implicit feedback scores from users on each round of system responses represents user satisfaction; calling a pre-trained dialogue quality assessment model to score the fluency, accuracy, and relevance of the response content represents response quality; and weighting and fusing the two types of scores according to preset weights to construct a reward function corresponding to each state-action pair, outputting a comprehensive reward value. For example, using a function approximation method to fit the state-action value function in a high-dimensional state space, a deep neural network is constructed as the value fitting network; the concatenated feature vector of the interaction states is used as the network input, and after multiple layers of nonlinear transformation, the value estimation result corresponding to each type of response action in the action space is output. Another example is constructing an experience replay pool, storing state transition samples consisting of the current state, executed action, reward obtained, and next state generated in each round of interaction; during training, batch samples are randomly sampled from the replay pool, and the loss function is calculated based on temporal difference error, with backpropagation used to update the parameters of the deep neural network. For example, by using a dynamically decaying ε-greedy strategy, different response strategies can be explored in the early stages of training to collect enough samples to optimize the value function. In the later stages of training and deployment, less exploration is needed, and the optimal action is selected first. This can reduce the conflict between optimization and user experience.

[0054] By employing the above methods, the interaction of opinions is modeled as a Markov decision process, dynamically optimizing the response strategy based on user feedback to replace the fixed-rule response pattern and improve the adaptability of the response strategy. The constructed reward function integrates user feedback and response quality assessment, and the strategy optimization objective covers both user satisfaction and response quality, improving the accuracy of strategy optimization. An experience replay mechanism is used to perform offline learning, reusing samples to accelerate convergence while avoiding the impact of online exploration on user experience, thus improving the efficiency of strategy learning and user experience. A dynamically decaying ε-greedy strategy is adopted, exploring and optimizing the strategy more during the training period and utilizing it more after going online to ensure response effectiveness, achieving an effective balance between exploration and utilization.

[0055] In some embodiments, please refer to Figure 3 The following is a detailed flowchart of the complete interactive process for tag generation based on a large model, which is provided in this application: Step 1, User asks questions (interactive Q&A) Users input questions through the chatbot platform / dialogue bar, which includes the keywords to be tagged, business lines, and conditions that meet the tags. This can be done by directly inputting the question or setting a question template, which will not be elaborated here.

[0056] Step 2: Preset large model intent recognition (determine the subject of the label, indicators, etc.) A pre-defined large model is introduced to identify and parse the query information, which is decomposed into specific information such as intent, engineering indicators, business lines and tag conditions; the reasoning ability of the large language model is used to extract structured objects that the program can understand from the text containing the query information.

[0057] Determine if the information required for tag generation is complete; if yes, output the information required for tag generation (intent, engineering metrics, business lines, tag conditions, and dimensions (generation logic), etc.); if no, determine again whether the preset large model prompt (prompt word or prompt word template) has a preset logical chain. If yes, based on the missing information, use the prompt to find the corresponding default logic in the preset logic chain and complete the tag to generate the required information; if no, guide the user to continue asking questions.

[0058] Step 3: Generate preset large model tags (automatic routing, main body tagging, etc.) AI (Artificial Intelligence) workflow routing: Pre-set different AI workflows for different subjects (e.g., users / drivers / merchant staff, etc.); Information generated based on the provided tags is routed to a preset AI workflow. The AI ​​workflow is pre-configured with NL2SQL statement workflows, automatic SQL statement execution workflows, etc.

[0059] SQL statement generation and result table for tags: Based on the NL2SQL statement workflow of the large model, the natural language question information, database schema information (table structure, fields, etc.) required for the corresponding label are generated and combined with the example SQL statement to form prompt words. The external general large language model such as Qianwen is called to generate SQL statements. The generated SQL statements are sent to the database for execution to obtain query results.

[0060] Step 4, Dialogue Output Results Output is provided through chatbot-like dialogue, including tag identifiers, tag names, tag levels, and tag values, with a preview of 100 data entries. The raw result set returned by the database is converted into a user-friendly format, such as tables, charts, or natural language summaries.

[0061] Step 5: Confirm the results and deploy them online. The system determines whether the business confirmation result table meets the requirements. If it does, the results are officially stored in a Hive table (including tag identifier, tag name, tag type, and tag value). If the results do not meet the requirements, the user is guided to ask further questions until the generated tags meet the business needs. Regarding tag deployment, if the tags meet the requirements, they can be directly deployed to the user profile platform, where they can be used to select specific user groups.

[0062] The above methods can be adjusted and optimized according to actual business needs. For example, certain template examples can be set up to guide the questioning, so that business personnel can quickly learn how to correctly use the tag generation device based on the large model, ensuring the efficiency and accuracy of tag generation.

[0063] Based on the application of the embodiments in this application to the logistics industry, it can be extended to the following other scenarios: First, it can be extended to the medical and health field to generate patient tags. For example, tags such as "diabetic patients with poor blood sugar control in the past 3 months" and "patients who have not had a follow-up visit 1 month after surgery" can be generated. Through these tags, accurate follow-up, health management and optimization of medical resource allocation can be achieved.

[0064] Second, it can be extended to the education field to generate student tags. For example, tags such as "a junior high school student who failed math twice in a row" or "a student whose online course attendance rate was less than 50% in the past month" can be generated. These tags can assist in personalized teaching and learning analysis.

[0065] Third, the system can be expanded to the field of government services to generate resident tags. For example, tags such as "low-income families who have applied for public rental housing" and "elderly people over 60 years old who have not completed pension insurance certification" can be generated. These tags can be used to accurately push and optimize public services.

[0066] Fourth, it can be extended to the manufacturing sector to generate production equipment / production line labels. For example, labels such as "production line with a failure rate of more than 5% in the past month" and "critical equipment whose maintenance cycle has expired" can be generated. These labels can support intelligent manufacturing and preventive maintenance of equipment.

[0067] Fifth, expand into the social media field to generate creator / user tags. For example, tags such as "high-quality creators who have published more than 3 original posts in the past 7 days" and "core users with high-frequency interaction" can be generated. These tags are beneficial for user operations.

[0068] In summary, by applying this embodiment to different industries, intelligent predictive analysis and decision support capabilities can help companies in various industries achieve data-driven operational optimization and growth.

[0069] In this embodiment, through natural language interactive parsing, business personnel can submit tag requests in natural language. A large model enables intent recognition and entity extraction, breaking the limitations of fixed template input. Intelligent information completion uses a preset prompt to search the logical chain knowledge base, automatically completing missing tag information (such as business lines and statistical definitions) in the request, reducing process interruption rates. Multi-entity workflow routing identifies the tag subject (user / driver / merchant, etc.) and intelligently matches the corresponding AI workflow, adapting to the tag logic of different business objects. Through end-to-end automated closed-loop, the entire process of "request submission → SQL statement generation → result verification → tag deployment" is automated without technical personnel intervention. Business personnel can independently complete the entire lifecycle management of tags without a technical background, significantly reducing cross-role communication costs.

[0070] Through the above methods, based on the tag demand intent parsing and information auto-completion method of the preset large model, the automatic routing rules of the multi-subject tag AI workflow, the generation of SQL statements and the results are automatically synchronized to the profile platform. The preset large model integrates the NL2SQL statement conversion solution in the business process. By providing a system architecture of "dialogue interaction layer → large model processing layer → workflow routing layer → SQL statement execution layer → result storage and online layer", it provides strong support for the intelligent operation of the logistics industry and other industries.

[0071] Please see Figure 4 The diagram illustrates a block diagram of a large-model-based label generation apparatus, as shown in an exemplary embodiment of this application. Figure 4 As shown, in an exemplary embodiment, the tag generation device based on a large model includes at least an acquisition module 410, a decomposition and reasoning module 420, a prompt word generation module 430, and a tag generation module 440, which are described in detail below: Module 410 is used to obtain query information in natural language representation. The decomposition and reasoning module 420 uses a preset large model to semantically decompose the question information, and performs logical reasoning on the decomposed tag element set to obtain a structural object; The prompt word generation module 430 is used to extract the workflow corresponding to the structure object, and based on the workflow, combine the question information, database schema information and standard sample SQL statement required to generate the label to generate prompt words; The tag generation module 440 uses the preset large model to generate an SQL statement based on the prompt words, queries the tag information corresponding to the SQL statement, and outputs it.

[0072] It should be noted that the large-model-based tag generation device and the large-model-based tag generation method provided in the above embodiments belong to the same concept. The content of the operation performed by each module has been described in detail in the method embodiments, and will not be repeated here.

[0073] The label generation method and apparatus based on large models provided in this application have the following advantages: First, existing single-tag technology requires 6-8 hours from request to deployment. This application, through end-to-end automated closed loop, reduces the time to within 1 hour, significantly improving efficiency. At the same time, it eliminates manual operation waiting time, and the core tag response speed meets the needs of rapid business iteration.

[0074] Second, existing technologies require repeated communication between business and technical personnel to meet requirements, with communication costs exceeding 2 hours per label. This application enables business personnel to complete the entire process independently, significantly reducing manpower and communication costs.

[0075] Third, existing technologies only support fixed templates or keyword input, which cannot adapt to the needs of free natural language. This application supports business personnel to submit requirements in the form of daily conversations, without the need to adapt to the format, which meets the diverse and personalized tag generation scenarios and improves the flexibility of requirement response. Fourth, existing technologies rely on manually writing SQL statements and synchronizing data. This application generates target SQL statements automatically and verifies the results of the target SQL statement queries, avoiding business decision deviations caused by label errors and significantly reducing the label generation error rate.

[0076] Fifth, existing technologies require manual switching of configuration templates for different entities (users / drivers / merchants), which is inefficient and prone to errors. This application improves the efficiency of multi-entity tag generation and adaptation through an automatic routing mechanism, supports the parallel operation of multiple business lines, speeds up business response, and improves the efficiency of multi-entity business adaptation.

[0077] This application also provides an electronic device, including: a processor, a memory, and a communication bus; the communication bus is used to connect the processor and the memory; the processor is used to execute a computer program stored in the memory to implement the large model-based tag generation method as described in the above embodiments.

[0078] Please see Figure 5 This diagram illustrates the structure of a computer system suitable for implementing the embodiments of this application. It should be noted that... Figure 5 The computer system 500 of the electronic device shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of this application.

[0079] like Figure 5As shown, the computer system 500 includes a Central Processing Unit (CPU) 501, which can perform various appropriate actions and processes, such as executing the methods described in the above embodiments, based on programs stored in Read-Only Memory (ROM) 502 or programs loaded from storage portion 508 into Random Access Memory (RAM) 503. The RAM 503 also stores various programs and data required for system operation. The CPU 501, ROM 502, and RAM 503 are interconnected via a bus 504. An Input / Output (I / O) interface 505 is also connected to the bus 504.

[0080] The following components are connected to I / O interface 505: an input section 506 including a keyboard, mouse, etc.; an output section 507 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and speakers, etc.; a storage section 508 including a hard disk, etc.; and a communication section 509 including a network interface card such as a LAN (Local Area Network) card, modem, etc. The communication section 509 performs communication processing via a network such as the Internet. A drive 510 is also connected to I / O interface 509 as needed. Removable media 511, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., are installed on drive 510 as needed so that computer programs read from them can be installed into storage section 508 as needed.

[0081] Specifically, according to embodiments of this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program including a computer program for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 509, and / or installed from removable medium 511. When the computer program is executed by central processing unit (CPU) 501, it performs various functions defined in the system of this application.

[0082] This application also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a computer's processor, causes the computer to perform the rule engine configuration method for early warning as described above. This computer-readable storage medium may be included in the electronic device described in the above embodiments, or it may exist independently and not assembled into the electronic device.

[0083] It should be noted that the computer-readable medium shown in the embodiments of this application can be a computer-readable signal medium or a computer-readable storage medium, or any combination of the two. A computer-readable storage medium can be, for example, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), flash memory, optical fiber, portable compact disc read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this application, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, carrying a computer-readable computer program. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. Computer-readable signal media can also be any computer-readable medium other than computer-readable storage media, which can send, propagate, or transmit programs for use by or in connection with an instruction execution system, system, or device. Computer programs contained on a computer-readable medium can be transmitted using any suitable medium, including but not limited to wireless, wired, etc., or any suitable combination thereof.

[0084] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation that may be implemented in systems, methods, and computer program products according to various embodiments of this application. Each block in a flowchart or block diagram may represent a module, segment, or portion of code, which contains one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0085] The units described in the embodiments of this application can be implemented in software or hardware, and the described units can also be located in a processor. The names of these units do not necessarily limit the specific unit itself.

[0086] The above embodiments are merely illustrative of the principles and effects of this application and are not intended to limit this application. Any person skilled in the art can modify or alter the above embodiments without departing from the spirit and scope of this application. Therefore, all equivalent modifications or alterations made by those skilled in the art without departing from the spirit and technical concept disclosed in this application should still be covered by the claims of this application.

Claims

1. A label generation method based on a large model, characterized in that, The method includes: Obtain question information from natural language representation; The question information is semantically decomposed using a pre-defined large model, and the resulting set of tag elements is logically reasoned to obtain a structural object. Extract the workflow corresponding to the structure object, and based on the workflow, combine the question information, database schema information and standard sample SQL statements required to generate the tag to generate prompt words; The preset large model is used to generate a target SQL statement based on the prompt words, the tag information corresponding to the target SQL statement is queried, and the result is output.

2. The label generation method based on a large model according to claim 1, characterized in that, The query information is semantically decomposed using a pre-defined large model. Logical reasoning is then applied to the resulting set of tag elements to obtain a structural object, including: The query information is semantically decomposed to obtain a set of tag elements, which includes at least one of intent, engineering indicators, business lines and tag conditions. The completeness of the tag element set is checked. If the tag element set is incomplete, a preset logical chain is searched based on the missing information in the tag element set to complete the information and generate a complete tag element set. By performing logical reasoning on the complete set of tag elements, a structural object is obtained.

3. The label generation method based on a large model according to claim 1, characterized in that, Extract the workflow corresponding to the structure object, and based on the workflow, combine the question information, database schema information, and standard sample SQL statements required for generating tags to generate prompt words, including: Extract the tag body from the structure object, and match the corresponding workflow based on the tag body, wherein each type of tag body corresponds to a unique workflow; Based on the workflow, the question information, database schema information, and standard sample SQL statement required to generate the tag are combined with the tag element set. The question information, the database schema information, and the standard sample SQL statement are then combined to generate prompt words.

4. The label generation method based on a large model according to claim 1, characterized in that, Using the preset large model to generate a target SQL statement based on the prompt words, querying the tag information corresponding to the target SQL statement, and outputting it includes: The preset large model is used to generate a target SQL statement based on the prompt words. The target SQL statement is then input into the target database for querying to obtain tag information. The tag information is converted into a preset metadata format and displayed on a preset dialog interface. The preset metadata format consists of tag identifier, tag name, tag level and tag value.

5. The label generation method based on a large model according to claim 4, characterized in that, Before inputting the target SQL statement into the target database for querying, the following steps are also included: The target SQL statement is lexical and syntactically parsed to obtain the table name and field name. The table name and field name are then compared with the preset database structure information to complete the consistency check. Verify the semantic logic validity of the target SQL statement to complete the semantic rule validation; The execution flow of the target SQL statement is simulated in the target database to assess logical risks or performance vulnerabilities and complete performance verification. The target database is a temporary database table or a sandbox environment. If all validations pass, the target SQL statement is validated successfully; if any validation fails, the target SQL statement is validated unsuccessfully.

6. The label generation method based on a large model according to claim 1, characterized in that, Also includes: In response to user feedback commands, the dialogue strategy of the preset large model is adjusted through reinforcement learning algorithms to optimize human-computer interaction.

7. The label generation method based on a large model according to claim 6, characterized in that, Adjusting the dialogue strategy of the preset large model using reinforcement learning algorithms includes: The opinion interaction process in the dialogue strategy is modeled as a Markov decision process, defining a state space and a system action space. The interaction state in the state space is represented by the user's opinion inquiry content, the system's response history information, the user's feedback information, and the dialogue round information. The action space includes multiple types of response actions, which include at least opinion summarization, viewpoint comparison, detail listing, multi-round clarification, and greeting reply actions. By combining user feedback ratings for system responses with a pre-trained dialogue quality assessment model, a reward function corresponding to state-action pairs is constructed. This reward function is used to comprehensively evaluate user satisfaction and response quality. The state-action value function is represented by a function approximation method, and the state-action value function is fitted by a deep neural network; wherein, the input of the deep neural network is the interaction state features, and the output is the value estimation result corresponding to each response action; Offline policy learning is performed using an experience replay mechanism. State transition samples generated during opinion interaction are stored in the experience replay pool. The network parameters of the deep neural network are updated by randomly sampling replay samples. When generating actual response actions, an ε-greedy strategy is used as the reinforcement learning algorithm. The optimal response action is selected based on the action value estimation result corresponding to the current interaction state, and the exploration probability is gradually reduced as the training process progresses.

8. A tag generation device based on a large model, characterized in that, The device includes: The module retrieves query information in natural language representation. The decomposition and reasoning module uses a preset large model to semantically decompose the question information, and performs logical reasoning on the decomposed tag element set to obtain a structured object; The prompt word generation module is used to extract the workflow corresponding to the structure object, and based on the workflow, combine the question information, database schema information and standard sample SQL statements required to generate the label to generate prompt words; The tag generation module uses the preset large model to generate an SQL statement based on the prompt words, queries the tag information corresponding to the SQL statement, and outputs it.

9. An electronic device, characterized in that, include: Processor, memory, and communication bus; The communication bus is used to connect the processor and the memory; The processor is configured to execute a computer program stored in the memory to implement the method as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, It contains a computer program that enables the computer to perform the method as described in any one of claims 1 to 7.