Artificial intelligence model output control method and device based on constraint driving

CN121659759APending Publication Date: 2026-03-13SHANGHAI XIYU JIZHI 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
2025-12-04
Publication Date
2026-03-13

AI Technical Summary

Technical Problem

Existing technologies for controlling the output of artificial intelligence models suffer from low efficiency, poor flexibility, and high overhead. They cannot effectively guarantee that the model output follows instructions, especially when the mode changes, requiring repeated training or adjustments. Furthermore, they cannot directly control the output mode through natural language.

Method used

By identifying the constraints in the execution instructions and converting them into pattern constraint codes, the output of the artificial intelligence model can be controlled using these pattern constraint codes. This achieves non-intrusive output pattern control, applicable to any existing model, without the need for further training or adjustment.

Benefits of technology

It achieves low-overhead, high-flexibility, and highly adaptive model output control, reducing training costs and time, improving model instruction compliance performance, and lowering the barrier to entry.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121659759A_ABST
    Figure CN121659759A_ABST
Patent Text Reader

Abstract

The invention provides an artificial intelligence model output control method and device based on constraint driving, and the method comprises the steps: responding to a received execution instruction, enabling an artificial intelligence model to recognize the execution instruction, determining whether the execution instruction comprises a constraint condition or not, the constraint condition is used for limiting an output mode when the model processes the execution instruction; if the constraint condition exists, determining a target constraint strategy of the execution instruction according to the condition type of the constraint condition, and converting the constraint condition into a mode limitation code according to the target constraint strategy; and outputting target data meeting the model output mode limited by the execution instruction by the artificial intelligence model based on the mode limiting code. Thus, through the technical scheme of the invention, the problems of low efficiency, poor flexibility and high overhead existing in the limitation of the model output mode in the prior art are at least solved, and the universality of the output limitation of the artificial intelligence model is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of model output control technology, and in particular to a constraint-driven artificial intelligence model output control method and apparatus. Background Technology

[0002] With the rapid development of artificial intelligence technology, natural language processing models are widely used, such as large language models in tasks like text generation, dialogue systems, and automated report generation. In many practical applications, such as automatically generating structured data (e.g., JSON, XML formats), generating standardized reports, or executing specific instructions in dialogue interactions, the model's output must strictly adhere to a predetermined pattern.

[0003] However, in existing technologies, if specific instruction-following training is not performed during the training steps of the AI ​​model, the model's response is highly likely to deviate from the required instructions. Simply relying on repeated prompts cannot guarantee that the model's output fully conforms to the prompts. To address this issue, existing technologies mainly employ two methods: one is to fine-tune a specific pattern during the model training phase, using additional training data and steps to adapt the model to a particular output pattern; the other is to incorporate a masking mechanism during the decoding output phase to intervene in the output pattern, forcing the model to generate a sequence that meets the requirements. However, these methods have significant drawbacks. First, they all require retraining or adjusting the model. When the specified pattern changes, the fine-tuning or masking training steps must be repeated, resulting in a huge investment of computational resources and time overhead, especially for large-scale models, which is costly. Second, these methods typically rely on explicit coded instructions or structured labels, and cannot directly control the model's output pattern through natural language, resulting in poor universality.

[0004] Therefore, existing technologies lack an efficient, flexible, and low-overhead solution to ensure the fixed output pattern of the model, and also hinder the deployment and application of artificial intelligence models in a wider range of fields. Summary of the Invention

[0005] In view of this, the purpose of this application is to provide a constraint-driven artificial intelligence model output control method and device, so as to at least solve the problems of low efficiency, poor flexibility and high cost of the existing technology that limits the model output mode, and the solution can also improve the generalization of application scenarios.

[0006] This application provides a constraint-driven artificial intelligence model output control method, the control method comprising: In response to receiving an execution instruction, the artificial intelligence model identifies the execution instruction and determines whether the execution instruction includes a constraint condition, which is used to limit the output mode of the model when processing the execution instruction; If constraints exist, the target constraint strategy for the execution instruction is determined according to the type of the constraint, and the constraint is converted into pattern restriction code according to the target constraint strategy. Based on the pattern restriction encoding, the artificial intelligence model outputs target data that satisfies the model output pattern restricted by the execution instruction.

[0007] This application embodiment also provides a constraint-driven artificial intelligence model output control device, the control device comprising: The identification module is used to respond to the received execution instruction, the artificial intelligence model identifies the execution instruction, and determines whether the execution instruction includes a constraint condition, the constraint condition being used to limit the output mode of the model when processing the execution instruction; The determination module is used to determine the target constraint strategy of the execution instruction according to the condition type of the constraint if constraints exist, and to convert the constraint into pattern restriction code according to the target constraint strategy. The output module is used to encode based on the pattern constraints, and output target data from the artificial intelligence model that satisfies the model output pattern constrained by the execution instructions.

[0008] This application provides a constraint-driven artificial intelligence model output control method and apparatus. The method includes: in response to receiving an execution instruction, the artificial intelligence model identifies the execution instruction and determines whether the execution instruction includes a constraint condition, the constraint condition being used to limit the output mode of the model when processing the execution instruction; if a constraint condition exists, a target constraint strategy for the execution instruction is determined according to the condition type of the constraint condition, and the constraint condition is converted into a pattern restriction code according to the target constraint strategy; based on the pattern restriction code, the artificial intelligence model outputs target data that satisfies the model output mode restricted by the execution instruction. In this way, this solution can analyze the constraints from the user-issued execution instructions without requiring any retraining, fine-tuning, or parameter adjustments to the target model. It ensures that the model output follows the instructions with minimal overhead, thus significantly reducing training costs and time while improving model capabilities. Furthermore, this method can work based on various forms of constraints, such as natural language instructions or structured instructions, giving the model strong adaptability, flexibility, and scalability. Moreover, based on non-intrusive condition constraints, this solution can be applied to any existing AI model that has not been trained using a specific pattern, improving the model's instruction compliance performance. Finally, users of this solution do not need to learn complex programming or markup languages; they can directly use natural language to propose formatting requirements, greatly lowering the barrier to entry and improving the user experience.

[0009] In summary, this solution provides a lightweight, flexible, and low-cost approach to ensure that model output follows instructions. It shifts the focus of controlling model output patterns from how to modify the model to how to better guide it, thereby avoiding all the major shortcomings of the prior art.

[0010] To make the above-mentioned objectives, features and advantages of this application more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description

[0011] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0012] Figure 1 A flowchart illustrating a constraint-driven artificial intelligence model output control method provided in this application embodiment; Figure 2 This is one of the structural schematic diagrams of a constraint-driven artificial intelligence model output control device provided in an embodiment of this application; Figure 3 This is a second schematic diagram of a constraint-driven artificial intelligence model output control device provided in an embodiment of this application. Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0013] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. The components of the embodiments of this application described and shown in the accompanying drawings can generally be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely represents selected embodiments of this application. Based on the embodiments of this application, every other embodiment obtained by those skilled in the art without inventive effort falls within the scope of protection of this application.

[0014] First, the applicable application scenarios of this application are introduced. This application can be applied to the field of artificial intelligence models, specifically in the field of artificial intelligence model output control technology.

[0015] Research has shown that with the rapid development of artificial intelligence technology, natural language processing models are widely used, such as large language models in tasks like text generation, dialogue systems, and automated report generation. In many practical applications, such as the expectation that models will automatically generate structured data (e.g., JSON, XML formats) that meet specific preset content and / or format requirements, generate standardized reports, or execute specific instructions in dialogue interactions, the model's output must strictly follow a predetermined pattern.

[0016] However, in existing technologies, if specific instruction-following training is not performed during the training steps of the AI ​​model, the model's response is highly likely to deviate from the required instructions. Simply relying on repeated prompts cannot guarantee that the model's output fully conforms to the prompts. To address this issue, existing technologies mainly employ two methods: one is to fine-tune a specific pattern during the model training phase, using additional training data and steps to adapt the model to a particular output pattern; the other is to incorporate a masking mechanism during the decoding output phase to intervene in the output pattern, forcing the model to generate a sequence that meets the requirements. However, these methods have significant drawbacks. First, they all require retraining or adjusting the model. When the specified pattern changes, the fine-tuning or masking training steps must be repeated, resulting in a huge investment of computational resources and time overhead, especially for large-scale models, which is costly. Second, these methods typically rely on explicit coded instructions or structured labels, and cannot directly control the model's output pattern through natural language, resulting in poor universality.

[0017] Based on this, the present application provides a constraint-driven artificial intelligence model output control method and apparatus to at least solve the problems of low efficiency, poor flexibility and high cost of limiting model output modes in the prior art, and the solution can also improve the generalization of application scenarios.

[0018] Please see Figure 1 , Figure 1 This is a flowchart illustrating a constraint-driven artificial intelligence model output control method provided in an embodiment of this application. Figure 1 As shown in the embodiments of this application, the control method includes: S101. In response to receiving an execution instruction, the artificial intelligence model identifies the execution instruction and determines whether the execution instruction includes constraints.

[0019] S102. If constraints exist, determine the target constraint strategy for the execution instruction based on the type of the constraint, and convert the constraint into pattern restriction code according to the target constraint strategy.

[0020] S103. Based on the pattern restriction encoding, the artificial intelligence model outputs target data that satisfies the model output pattern restricted by the execution instruction.

[0021] The constraint-driven artificial intelligence model output control method provided in this application adds constraints to the execution instructions that instruct the artificial intelligence model to generate data, and determines the pattern restriction code that restricts the mode of the artificial intelligence model's output data according to the type of constraint and its corresponding constraint strategy. The target data that meets the output mode requirements is obtained according to the determined pattern restriction code. This can effectively solve the problems of low efficiency, poor flexibility and high cost of limiting the model output mode in the prior art, and can also effectively improve the generalization of application scenarios.

[0022] The exemplary steps of the embodiments of this application are described below: Specifically, step S101 may include: after receiving the execution instruction, the artificial intelligence model identifies the information in the execution instruction and determines whether it includes constraints that restrict the pattern of the output data of the artificial intelligence model.

[0023] Here, the constraints are used to limit the model's output mode when executing instructions; the execution instructions can be issued by the user or pre-programmed, with the effective time or conditions set to enable automatic execution. Specifically, the execution instructions can be natural language, programming language, or machine language.

[0024] The aforementioned artificial intelligence model encompasses machine learning, deep learning models, and other technologies such as rule-based systems and expert systems. It is a computer program or algorithm trained on a dataset containing a large amount of information. The training process enables the artificial intelligence model to learn explicit and / or implicit patterns and relationships in the data, thereby making predictions or decisions on new, unseen data.

[0025] Regarding step S101, when the artificial intelligence model identifies the execution instruction and determines whether the execution instruction includes constraints, this application provides three exemplary determination methods. When identifying the execution instruction, at least one of the following three identification methods can be selected to determine whether constraints exist in the execution instruction. Specifically, these include: Identification Method 1: Parse the execution instruction to identify whether there is at least one pattern keyword related to the predefined output pattern; when at least one pattern keyword is identified, determine that the execution instruction includes the constraint condition; when no at least one pattern keyword is identified, determine that the execution instruction does not include the constraint condition.

[0026] Here, the pattern keywords can be preset, and multiple preset keywords can be set. Here, pattern keywords can be used to indicate output conditions such as the format, structure, style, restrictions, and templates of the output answer, for example: table format, JSON format, chart presentation, bullet point listing, length limit, etc.

[0027] Identification Method 2: Match the execution instruction with a predefined pattern rule base; wherein, the pattern rule base includes words or phrases used to indicate data format, data structure or output template; if the match is successful, it is determined that the execution instruction includes the constraint condition; if the match is unsuccessful, it is determined that the execution instruction does not include the constraint condition. Here, when matching the execution instruction with the information in the pattern rule base, it can be matched with each piece of information in the pattern rule base. However, if a match is successful with any piece of information, it is considered that the execution instruction includes constraints; otherwise, it is determined that the execution instruction does not include constraints.

[0028] When the execution instruction is matched with information in the pattern rule base, if the confidence level of the matching result with any information in the rule base is greater than a preset confidence threshold, then the execution instruction is determined to be successfully matched with that information.

[0029] Identification Method 3: Perform semantic recognition on the execution instruction to determine whether the execution instruction includes semantic components that limit the output mode; if it does, determine that the execution instruction includes constraints; if it does not, determine that the execution instruction does not include constraints.

[0030] Specifically, this example can be as follows: Semantic recognition is performed on the execution instruction to determine its semantic meaning; it is then determined whether the semantic meaning is any predetermined semantic pattern. If so, the execution instruction includes a semantic component with a defined output pattern; otherwise, the execution instruction does not include a semantic component with a defined output pattern. Here, the semantic recognition is implemented through a deep neural network or a pre-trained model, including: mapping the instruction to a high-dimensional vector space using NLP or BERT, and using spatial distance or cosine similarity calculations to perform text classification, entity recognition, information extraction, intent recognition, etc., to determine whether the execution instruction matches any predefined constraint class semantic.

[0031] When identifying the execution command, identification method 1 is the simplest and fastest, identification method 2 is next, and identification method 3 is the most complex and slowest. In a preferred embodiment, any one, two, or three of identification methods 1, 2, and 3 can be selected to perform the constraint condition determination, or the user can select whether a constraint condition exists when inputting the execution command.

[0032] More preferably, to balance recognition efficiency and accuracy, in response to receiving an execution instruction, the system first performs a judgment using recognition method 1. If no pattern keyword is recognized, the system then performs a judgment using recognition method 2. If no matching result with a confidence level greater than a preset confidence threshold is found, the system then performs a judgment using recognition method 3. If recognition method 3 still determines that the predetermined semantic pattern does not exist, then the execution instruction is considered to not contain constraints.

[0033] With the above settings, the constraint recognition can be completed in most cases using the less expensive recognition method 1 or recognition method 2, saving a lot of recognition overhead and recognition time. At the same time, the most accurate recognition method 3 is used as the final judgment to prevent the omission of recognition constraints.

[0034] In step S101, if it is determined that the execution instruction includes constraints, then step S102 is executed; if it is determined that the execution instruction does not include constraints, then target data with no mode restrictions is output according to the processing logic of the artificial intelligence model.

[0035] Specifically, step S102 may include: after determining that the execution instruction includes constraints, identifying the specific type of the constraints included in the execution instruction, i.e., determining the condition type of the constraints; then, determining the target constraint policy corresponding to the execution instruction based on the identified constraint type and the preset type-policy mapping relationship; and finally, converting the constraints into the mode constraint code of the current constraint model output mode based on the determined target constraint policy.

[0036] In one embodiment provided in this application, for execution instructions composed of natural language, the constraint type includes explicit constraints, implicit constraints, and mixed constraints. The constraint type is determined through the following steps: S201. The execution instruction is divided into at least one constraint clause, and each constraint clause is converted into at least one condition vector.

[0037] S202. Perform clustering calculation on at least one conditional vector to obtain at least one constrained cluster.

[0038] S203. Determine the condition type of the constraint cluster based on the first spatial distance between the center vector of each constraint cluster and the first vector of the preset explicit constraint, and the second spatial distance between the center vector of each constraint cluster and the second vector of the preset implicit constraint.

[0039] S204. Determine the condition type of the constraint condition based on the condition types of all constraint clusters.

[0040] Regarding step S201, when dividing the execution instruction into at least one constraint clause, the execution instruction can be divided into at least one constraint clause according to a preset delimiter. The delimiter can be punctuation, spaces, or other symbols.

[0041] For example, the process of segmenting an execution instruction into at least one constraint clause is illustrated below: For instance, an execution instruction including constraints such as "Generate a Teacher's Day greeting card to express gratitude and blessings to the teacher, not exceeding 30 characters, and the card begins with 'Dear teacher:'" would be broken down into clause 1: "Generate a Teacher's Day greeting card", clause 2: "Express gratitude and blessings to the teacher", clause 3: "Not exceeding 30 characters", and clause 4: "The card begins with 'Dear teacher'".

[0042] In this step, when transforming each constraint phrase into at least one condition vector, the specific steps are as follows: for each constraint phrase, the constraint phrase is transformed into an embedded condition vector in the latent space, so the number of condition vectors is the same as the number of constraint phrases. This transformation from natural language to condition vectors can be achieved using models such as BERT and GPT.

[0043] It should be understood that implicit or mixed constraints only exist when the execution instructions are entirely composed of natural language. If the execution instructions are machine language or programming language, the constraints are as explicit as those constraints.

[0044] For step S202, clustering calculations can be performed using clustering algorithms such as K-means or DBSCAN.

[0045] For step S203, this step may include: for each constraint cluster, determining the center vector of the constraint cluster based on all condition vectors in the constraint cluster, and then using the center vector of the constraint cluster to calculate the similarity with the first vector and the second vector respectively, to obtain the first spatial distance between the center vector and the first vector, and the second spatial distance between the center vector and the second vector.

[0046] Here, the first vector is the vector corresponding to the explicit constraints, which can be determined in advance by performing clustering calculations on a large number of explicit constraint samples; the second vector is the vector corresponding to the implicit constraints, which can also be determined in advance by performing clustering calculations on a large number of implicit constraint samples. For example, the first conditional vector can be calculated by mapping to the latent space based on the general concepts of format and / or length, and the second conditional vector can be calculated by mapping to the latent space based on the general concepts of sentiment and / or style.

[0047] In this step, when determining the condition type of the constraint cluster based on the first spatial distance and the second spatial distance, the specific steps are as follows: if the first spatial distance is less than the first threshold, the condition type of the constraint cluster is determined to be an explicit constraint; if the second spatial distance is less than the second threshold, the condition type of the constraint cluster is determined to be an implicit constraint.

[0048] For step S204, this step may include: if the condition types of all constraint clusters included in the execution instruction are explicit constraints, then the condition type of the constraint condition is determined to be an explicit constraint; if the condition types of all constraint clusters included in the execution instruction are implicit constraints, then the condition type of the constraint condition is determined to be an implicit constraint; if the condition types of all constraint clusters included in the execution instruction are both explicit and implicit constraints, then the condition type of the constraint condition is determined to be a mixed constraint.

[0049] It should be noted that explicit constraints refer to direct and clear limitations on the output information of the model, usually appearing in the form of variable boundaries or sets of values.

[0050] For example, if the instruction is "randomly generate an ID, with a length of 10-12 characters, the last four characters being numbers, the other characters being letters, and at least one special character being present", then the constraint type is an explicit constraint.

[0051] Implicit constraints are constraints that indirectly define feasible solutions through the relationships between output terms. They describe a certain logical relationship that must be satisfied between variables.

[0052] For example, when the instruction is "Generate a Teacher's Day greeting card to express gratitude and blessings to teachers," "Teacher's Day greeting card" and "gratitude and blessings" are relatively vague thematic and emotional qualifiers. Therefore, the constraint type contained therein is implicit constraint.

[0053] A constraint that includes both explicit and implicit constraints is called a mixed constraint. For example, consider the instruction: "Generate a Teacher's Day greeting card expressing gratitude and blessings to the teacher, no more than 30 characters, and the card begins with 'Dear Teacher:'". Here, "Teacher's Day greeting card, gratitude, and blessings" are vague qualifiers, while the card's opening and character limit are explicit restrictions. Therefore, the constraint type contained in this instruction is a mixed constraint.

[0054] Continuing with step S102, in one embodiment provided in this application, determining the target constraint strategy for the execution instruction based on the condition type of the constraint includes: when the condition type of the constraint is an explicit constraint, the target constraint strategy for the execution instruction is to convert the execution instruction into a regular expression; when the condition type of the constraint is an implicit constraint, the target constraint strategy for the execution instruction is to convert the execution instruction into a vector; when the condition type of the constraint is a mixed constraint, the target constraint strategy for the execution instruction is to convert the explicit instructions in the execution instruction into a regular expression and the implicit instructions in the execution instruction into a vector.

[0055] This embodiment provides specific forms of constraint strategies corresponding to different constraint types.

[0056] Here, when converting execution instructions into regular expression form, for example, this can be determined by a pre-trained natural language processing (NLP) model, or by a finite state machine or other form that can be based on simple matching without model inference. Specifically, the NLP model can directly output the regular expression encoding, or the NLP model can convert the execution instructions into encodings in a specific language form, and then obtain the regular expression encoding based on the mapping relationship between the specific language and the regular expression form.

[0057] When converting the execution instructions into vector form, for example, it can be determined based on the BERT model.

[0058] Continuing with step S102, when converting the constraints into pattern restriction encoding, this application provides the following example: When the constraint type includes explicit constraints, the target constraint strategy for the execution instruction is determined, and the constraint is converted into pattern restriction encoding according to the target constraint strategy, including: S1021. Obtain at least one explicit constraint phrase corresponding to the explicit constraint, and convert the explicit constraint phrase into a first intermediate instruction code of a pre-constructed specific language form.

[0059] S1022. Based on the mapping relationship between a specific language and regular expression, the first intermediate instruction encoding is converted into a pattern restriction encoding in the form of a regular expression.

[0060] In steps S1021-S1022, when obtaining the pattern restriction encoding in the form of a regular expression, the constraint phrase is first converted into an encoding in a specific language form, and then the encoding in the specific language form is converted into a pattern restriction encoding in the form of a regular expression according to a predetermined mapping relationship.

[0061] Here, "specific language form" refers to a DSL, which is a computer language designed to solve problems in a specific domain. Examples include SQL, HTML / CSS, and Logo.

[0062] When converting explicit constraint phrases into the first intermediate instruction encoding in a pre-built specific language form, this can be determined by a trained natural language processing model. A mapping table between the specific language and regular expression forms is also pre-set. Thus, after obtaining the first intermediate instruction encoding output by the natural language processing model, the pattern restriction encoding in the form of a regular expression can be determined by looking up the table or matching. Since regular expressions are more abstract than DSLs, and DSLs are more intuitive, compared to existing technologies that directly convert natural language into regular expressions through a model, the reasoning process required to convert natural language into DSL based on the model and then from DSL into regular expressions through a fixed mapping relationship is simpler. This effectively reduces training overhead, complexity, and actual reasoning error rate, and improves the interpretability of the model processing.

[0063] For example, the process of obtaining pattern restriction encoding in regular expression form based on encoding of a specific language form is illustrated below.

[0064] The training of the natural language processing (NLP) model begins with the following steps: First, the original dataset is acquired, containing several <natural language-structured expression> data pairs. A mapping table is constructed between the domain-specific language (DSL) and the structured expressions, where the structured expressions can be in regular expression form. Based on this mapping table, the original dataset is converted into <natural language-DSL expressions>. Then, an initial NLP model is obtained and trained using the <natural language-DSL expression> data. The loss function is established between the model's predicted DSL expressions and the actual DSL expressions. The parameters of the encoder and decoder in the NLP model are adjusted through backpropagation using the cross-entropy loss function to obtain the trained NLP model. This NLP model can be a lightweight transformer-based model.

[0065] After the model is trained, it is input with natural language instructions (explicitly constrained phrases) to be converted, and the model obtains the corresponding DSL language. A static parser then converts the DSL language into structured expressions based on a pre-built mapping table.

[0066] For example, please refer to Table 1, which shows a partial mapping between Natural Language-DSL-Regular Expressions.

[0067] Table 1:

[0068] When the constraint type includes implicit constraints, the target constraint strategy of the execution instruction is determined, and the constraint is converted into pattern restriction encoding according to the target constraint strategy, including: obtaining at least one implicit constraint phrase corresponding to the implicit constraint, and converting the at least one implicit constraint phrase into at least one implicit encoding in vector form.

[0069] If the constraint is a mixed constraint, it further includes: obtaining a pattern restriction code including regular expression form and vector form based on the explicit constraint clauses and implicit constraint clauses in the mixed constraint.

[0070] Here, if the constraints included in the execution instruction are mixed constraints, the resulting pattern restriction encoding will include both regular expression form and vector form encoding.

[0071] Continuing with step S102, before determining the target constraint strategy for the execution instruction based on the constraint type, the control method further includes: S301. Based on the at least one condition vector and the spatial distance between each condition vector, perform conflict detection on the execution instruction; S302. If there exists a condition vector with a spatial distance greater than the conflict detection threshold, it indicates that there is a conflict in the constraint clause within the execution instruction. S303. If a conflict exists, terminate the control output of the artificial intelligence model and provide feedback on the conflict detection result of the executed instruction.

[0072] Specifically, step S301 may include: determining the spatial distance between any two condition vectors based on the condition vectors of all constraint clauses included in the execution instruction, and then performing conflict detection on the execution instruction based on all determined spatial distances.

[0073] For step S302, this step can be specifically as follows: identify whether there is a condition vector corresponding to a spatial distance greater than the conflict detection threshold. If there is, it is considered that there is a conflict in the constraint clause in the execution instruction, and step S303 is executed. Otherwise, step S102 is executed.

[0074] When providing feedback on the conflict detection result of the executed instructions in step S303, the specific cause of the conflict can be provided.

[0075] Regarding step S103, when the target data is output by the artificial intelligence model, two different methods can be used for output, such as output in streaming form or output in non-streaming form.

[0076] In one embodiment provided in this application, when the artificial intelligence model outputs the target data in a non-streaming form, the step of outputting target data by the artificial intelligence model that satisfies the model output pattern restricted by the execution instruction based on the pattern restriction encoding includes: S10311. Identify the explicit codes corresponding to explicit constraint phrases and / or the implicit codes corresponding to implicit constraint phrases in the pattern restriction encoding.

[0077] S10312. For explicit encoding, the artificial intelligence model generates a first prediction data sequence for the execution instruction; wherein the first prediction data sequence includes at least two candidate first prediction data arranged in descending order of data confidence. S10313. The candidate first prediction data with the highest data confidence and conforming to explicit encoding in the first prediction data sequence is determined as the first selected data. S10314. For implicit encoding, the artificial intelligence model generates a second prediction data sequence for the execution instruction; wherein the second prediction data sequence includes at least two candidate second prediction data arranged in descending order of data confidence. S10315. The candidate second prediction data in the second prediction data sequence that has the highest data confidence and whose spatial distance from the implicit total code is not greater than the similarity threshold is determined as the second selected data. S10316. Based on the inclusion of explicit and implicit codes in the pattern restriction coding, determine the first selected data and / or the second selected data as target data.

[0078] For step S10311, the encoding types included in the pattern restriction encoding are identified, and the explicit encodings corresponding to the explicit constraint phrases and / or the implicit encodings corresponding to the implicit constraint phrases included in the pattern restriction encoding are determined.

[0079] If the pattern restriction encoding includes explicit encoding, then steps S10312-S10313 are executed; if the pattern restriction encoding includes implicit encoding, then steps S10314-S10315 are executed. Steps S10312-S10313 and S10314-S10315 can be executed in parallel.

[0080] Regarding step S10313, the explicit encoding is generally a structure. For example, the structure can be Output=('A'OR'B'OR'C'OR'D'), which means that only A, B, C, or D can be output.

[0081] For step S10315, the implicit total code can be all implicit codes included in the pattern restriction code.

[0082] Specifically, step S10316 may include: if the pattern restriction encoding includes only explicit encoding, then the first selected data is determined as the target data; if the pattern restriction encoding includes only implicit encoding, then the second selected data is determined as the target data; if the pattern restriction encoding includes both explicit and implicit encoding, then both the first selected data and the second selected data are determined as target data, and the first selected data and the second selected data are sorted according to the pattern restriction encoding.

[0083] In another embodiment provided in this application, when the artificial intelligence model outputs the target data in streaming form, the target data consists of at least two sequentially output target text blocks. The step of outputting target data by the artificial intelligence model that satisfies the model output pattern restricted by the execution instruction based on the pattern restriction encoding includes: S10321. For each target text block data that needs to be output, determine the target pattern restriction encoding corresponding to the target text block data.

[0084] S10322. Based on the target pattern constraint encoding, the artificial intelligence model generates a predicted text block data sequence; wherein the predicted text block data sequence includes at least two predicted text block data arranged in descending order of data confidence.

[0085] S10323. When the target pattern restriction encoding is a regular expression, the predicted text block data with the highest data confidence and that conforms to the target pattern restriction encoding in the predicted text block data sequence is determined as the target text block data to be output and output. Then, the next target text block data filtering is performed until the complete target data is obtained.

[0086] S10324. When the target pattern restriction encoding is in vector form, for each predicted text block data in the predicted text block data sequence, an incremental evaluation vector is constructed using the predicted text block data and the generated target text block data, and a conditional evaluation vector is constructed using the target encoding corresponding to the predicted text block data and the target pattern restriction encoding corresponding to the generated target text block data.

[0087] S10325. The predicted text block data with the highest data confidence and whose spatial distance between the corresponding incremental evaluation vector and the conditional evaluation vector is not greater than the corresponding dynamic similarity threshold in the predicted text block data sequence is determined as the target text block data to be output and output. Then, the next target text block data filtering is performed until the complete target data is obtained.

[0088] Regarding step S10321, during the target data stream output, for each target text block data to be output, the corresponding target pattern restriction encoding is determined. Here, the data confidence, i.e., the conditional probability, of a text block data is calculated by the output layer and normalization layer in the artificial intelligence model based on the vector of the input context and the vector of the output content. The higher the data confidence of a text block data, the more likely the model is to output that content at that position.

[0089] The target pattern restriction coding described here is generally a partial coding of the pattern restriction coding.

[0090] In step S10322, the target pattern restriction encoding is input into the artificial intelligence model, which then generates a predicted text block data sequence.

[0091] Specifically, when the target pattern restriction is encoded as a regular expression, step S10323 is executed; when the target pattern restriction is encoded as a vector, step S10324 is executed. Regarding step S10323, the data confidence level can be determined by an artificial intelligence model. Specifically, the conformity to the target pattern restriction coding can be that the matching degree between the predicted text block data and the target pattern restriction coding is greater than a preset matching degree threshold. Preferably, the conformity to the target pattern restriction coding can be that the cosine similarity between the predicted text block data and the target pattern restriction coding is greater than a preset matching degree threshold.

[0092] Regarding step S10324, in one embodiment provided in this application, the step of constructing an incremental evaluation vector using the predicted text block data and the generated target text block data includes: S103241. Perform vector transformation processing on the predicted text block data and the generated target text block data respectively to obtain the first evaluation vector corresponding to the predicted text block data and the second evaluation vector corresponding to the generated target text block data.

[0093] S103242. Determine the first weight of the predicted text block data based on its position in the target data.

[0094] S103243. Calculate the weighted average value based on the first evaluation vector, the first weight, the second evaluation vector, and the second weight of the generated target text block data, and obtain the incremental evaluation vector.

[0095] Regarding step S103241, the generated target text block data refers to all target text block data that has been output.

[0096] For example, if the predicted text block data is the 5th text block data, then the generated target text block data consists of the first 4 text blocks data. Therefore, the first evaluation vector is determined by one text block data, and the second evaluation vector is determined by at least one text block data.

[0097] For step S103242, the first weight value of the predicted text block data is determined differently depending on the position of the predicted text block data in the target data.

[0098] For example, the calculation of the first weight of the predicted text block data can be carried out in any of the following ways: First, the token at the beginning of a text has a stronger overall semantic definition, so its weight decreases from the beginning to the end according to its position. For example, the first token has a weight of 1, the second token has a weight of 1 / 2, the third token has a weight of 1 / 3, and so on.

[0099] 2. When calculating the total vector corresponding to the (i+1)th token, let... Thus, the first weight can be calculated using this formula.

[0100] For step S103243, the second weight can be the weight and value or average value of the generated target text block data.

[0101] The formula for calculating the incremental evaluation vector is as follows: .in, As the second weight; It is the first weight; This is the first evaluation vector; This is the second evaluation vector. At this point, the token at the position to be calculated corresponds to a baseline weight of 1, and λ is a preset parameter, 0 < λ < 1. A larger λ indicates a greater historical weight. The smaller the token, the more attention is paid to the latest token.

[0102] It should be noted that the first evaluation vector, the second evaluation vector, and other latent space vectors are all mapped to the same latent space, and all vectors have the same dimension.

[0103] For step S10325, the dynamic similarity threshold varies depending on the position of the predicted text block data in the target data.

[0104] For example, based on different positions, it is divided into front, middle, and back, corresponding to strong threshold, middle threshold, and strong threshold respectively. Here, it is generally believed that the strong threshold should not be lower than 0.8, the middle threshold should not be lower than 0.7, the cosine similarity between the output content at the beginning of the model and the target pattern restriction code should be greater than or equal to the value of the strong threshold, and the cosine similarity between the middle part of the model output content and the target pattern restriction code should be greater than or equal to the middle threshold.

[0105] In another preferred embodiment, when the length of the response output by the model is long, the threshold can be calculated linearly based on the token position: TH = a*i + b, where TH represents the threshold, i is the token position, and a and b are preset parameters. Here, since the length of the context is positively correlated with the difficulty of following the instruction when the model outputs long text content, and since only answers with a cosine similarity higher than the threshold are accepted, the larger the threshold, the stricter the requirement for following the instruction. Therefore, in the above formula, a and b should both be positive numbers. Preferably, b ∈ [0.7, 0.9], and a is a small positive decimal, such as a ∈ (0, 0.01).

[0106] In this way, this solution can analyze the constraints from the user-issued execution instructions without requiring any retraining, fine-tuning, or parameter adjustments to the target model. It ensures that the model output follows the instructions with minimal overhead, thus significantly reducing training costs and time while improving model capabilities. Furthermore, this method can work based on various forms of constraints, such as natural language instructions or structured instructions, giving the model strong adaptability, flexibility, and scalability. Moreover, this solution is non-intrusive and can be applied to any existing AI model that has not been trained using a specific pattern, improving the model's instruction compliance performance. Finally, users of this solution do not need to learn complex programming or markup languages; they can directly use natural language to specify formatting requirements, greatly lowering the barrier to entry and improving the user experience.

[0107] In summary, this solution provides a lightweight, flexible, and low-cost approach to ensure that model output follows instructions. It shifts the focus of controlling model output patterns from how to modify the model to how to better guide it, thereby avoiding all the major shortcomings of the prior art.

[0108] Based on the same inventive concept, this application also provides a control device corresponding to the control method. Since the principle of the device in this application is similar to the control method described above, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be described again.

[0109] Please see Figure 2 , Figure 3 , Figure 2 This is one of the structural schematic diagrams of a constraint-driven artificial intelligence model output control device provided in an embodiment of this application. Figure 3 This is a second schematic diagram of a constraint-driven artificial intelligence model output control device provided in an embodiment of this application. Figure 2 As shown, the control device 200 includes: The identification module 210 is used to, in response to receiving an execution instruction, identify the execution instruction and determine whether the execution instruction includes a constraint condition, wherein the constraint condition is used to limit the output mode of the model when processing the execution instruction; The first determining module 220 is used to determine the target constraint strategy of the execution instruction according to the condition type of the constraint if there are constraints, and to convert the constraint into a pattern restriction code according to the target constraint strategy. Output module 230 is used to output target data that satisfies the model output pattern restricted by the execution instruction, based on the pattern restriction encoding.

[0110] Optionally, the constraint types include explicit constraints, implicit constraints, and mixed constraints, such as... Figure 3 As shown, the control device 200 further includes a second determining module 240, which is used to determine the condition type of the constraint condition through the following steps: The execution instruction is divided into at least one constraint clause, and each constraint clause is transformed into at least one condition vector; Perform clustering computation on at least one conditional vector to obtain at least one constrained cluster; The condition type of the constraint cluster is determined based on the first spatial distance between the center vector of each constraint cluster and the first vector of the preset explicit constraint, and the second spatial distance between the center vector of each constraint cluster and the second vector of the preset implicit constraint. The condition type of the constraint is determined based on the condition types of all constraint families.

[0111] Optionally, when the first determining module 220 determines the target constraint strategy of the execution instruction based on the condition type of the constraint, the first determining module 220 is used to: When the constraint type is an explicit constraint, the target constraint strategy of the execution instruction is to convert the execution instruction into a regular expression form. When the constraint type is implicit constraint, the target constraint strategy of the execution instruction is to convert the execution instruction into vector form; When the constraint type is a mixed constraint, the target constraint strategy of the execution instruction is to convert the explicit instructions in the execution instruction into regular expression form and the implicit instructions in the execution instruction into vector form.

[0112] Optionally, when the constraint type includes explicit constraints, the first determining module 220, when determining the target constraint strategy for the execution instruction and converting the constraint into pattern restriction encoding according to the target constraint strategy, is used to: Obtain at least one explicit constraint phrase corresponding to the explicit constraint, and convert the explicit constraint phrase into a first intermediate instruction code of a pre-constructed specific language form; Based on the mapping relationship between a specific language and regular expression, the first intermediate instruction encoding is converted into a pattern restriction encoding in the form of a regular expression. When the constraint type includes implicit constraints, the first determining module 220, when determining the target constraint strategy for the execution instruction and converting the constraint into pattern restriction encoding according to the target constraint strategy, is used to: Obtain at least one implicit constraint phrase corresponding to the implicit constraint, and convert the at least one implicit constraint phrase into at least one implicit code in vector form; If the constraint is a mixed constraint, it further includes: obtaining a pattern restriction code including regular expression form and vector form based on the explicit constraint clauses and implicit constraint clauses in the mixed constraint.

[0113] Optionally, when the artificial intelligence model outputs the target data in a non-streaming form, the output module 230, when used for encoding based on the pattern constraints to output target data that satisfies the model output pattern constrained by the execution instruction, is used to: Identify the explicit codes corresponding to explicit constraint phrases and / or the implicit codes corresponding to implicit constraint phrases in the pattern restriction encoding; For explicit encoding, the artificial intelligence model generates a first predicted data sequence for the executed instruction; wherein the first predicted data sequence includes at least two candidate first predicted data arranged in descending order of data confidence. The candidate first predicted data with the highest data confidence and conforming to explicit encoding in the first predicted data sequence is determined as the first selected data; For implicit encoding, the artificial intelligence model generates a second predicted data sequence for the executed instruction; wherein the second predicted data sequence includes at least two candidate second predicted data arranged in descending order of data confidence. The candidate second predicted data with the highest data confidence and whose spatial distance from the implicit total code is no greater than the similarity threshold in the second predicted data sequence is determined as the second selected data. Based on the inclusion of explicit and implicit encodings in the pattern-restricted encoding, the first selected data and / or the second selected data are determined as target data.

[0114] Optionally, when the artificial intelligence model outputs the target data in streaming form, the target data consists of at least two sequentially output target text blocks. When the output module 230 is used for encoding based on the pattern constraints, so that the artificial intelligence model outputs target data that satisfies the model output pattern constrained by the execution instruction, the output module 230 is used for: For each target text block of data that needs to be output, determine the target pattern restriction encoding corresponding to that target text block of data; Based on the target pattern constraint encoding, the artificial intelligence model generates a sequence of predicted text block data; wherein the sequence of predicted text block data includes at least two predicted text block data arranged in descending order of data confidence. When the target pattern constraint is encoded as a regular expression, the predicted text block data with the highest data confidence and that conforms to the target pattern constraint encoding in the predicted text block data sequence is determined as the target text block data to be output and output. Then, the next target text block data filtering is performed until the complete target data is obtained. When the target pattern constraint is encoded in vector form, for each predicted text block in the predicted text block data sequence, an incremental evaluation vector is constructed using the predicted text block data and the generated target text block data, and a conditional evaluation vector is constructed using the target encoding corresponding to the predicted text block data and the target pattern constraint encoding corresponding to the generated target text block data. The predicted text block data with the highest data confidence and whose spatial distance between the corresponding incremental evaluation vector and the conditional evaluation vector is not greater than the corresponding dynamic similarity threshold is determined as the target text block data to be output and output. Then, the next target text block data filtering is performed until the complete target data is obtained.

[0115] Optionally, when the output module 230 is used to construct an incremental evaluation vector using the predicted text block data and the generated target text block data, the output module 230 is used to: The predicted text block data and the generated target text block data are respectively subjected to vector transformation processing to obtain the first evaluation vector corresponding to the predicted text block data and the second evaluation vector corresponding to the generated target text block data. Based on the position of the predicted text block data in the target data, a first weight of the predicted text block data is determined; The weighted average value is calculated based on the first evaluation vector, the first weight, the second evaluation vector, and the second weight of the generated target text block data to obtain the incremental evaluation vector.

[0116] Optional, such as Figure 3 As shown, the control device 200 further includes a detection module 250, which is used for: Before determining the target constraint strategy of the execution instruction based on the constraint type, conflict detection is performed on the execution instruction based on the at least one condition vector and the spatial distance between each condition vector. If there exists a condition vector with a spatial distance greater than the conflict detection threshold, it indicates that there is a conflict in the constraint clause within the execution instruction; If a conflict exists, the control output of the artificial intelligence model is terminated, and the conflict detection result of the executed instruction is fed back.

[0117] Optionally, when the identification module 210 is used to identify the execution instruction through an artificial intelligence model and determine whether the execution instruction includes constraints, the identification module 210 is used to: The execution instructions are parsed to identify whether there is at least one pattern keyword related to a predefined output pattern; When at least one pattern keyword is identified, it is determined that the execution instruction includes the constraint condition; when no at least one pattern keyword is identified, it is determined that the execution instruction does not include the constraint condition. or, The execution instructions are matched against a predefined pattern rule base; wherein the pattern rule base includes words or phrases used to indicate data format, data structure, or output template; If the match is successful, it is determined that the execution instruction includes the constraint condition; if the match is unsuccessful, it is determined that the execution instruction does not include the constraint condition. or, Semantic recognition is performed on the execution instructions to determine whether the execution instructions include semantic components that limit the output mode; If it is included, the execution instruction is determined to include constraints; if it is not included, the execution instruction is determined to not include constraints.

[0118] Please see Figure 4 , Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Figure 4 As shown, the electronic device 400 includes a processor 410, a memory 420, and a bus 430.

[0119] The memory 420 stores machine-readable instructions executable by the processor 410. When the electronic device 400 is running, the processor 410 communicates with the memory 420 via the bus 430. When the machine-readable instructions are executed by the processor 410, they can perform the operations described above. Figure 1 The steps in the method embodiment shown are specifically implemented in the method embodiment and will not be repeated here.

[0120] This application also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, can perform the above-described actions. Figure 1 The steps in the method embodiment shown are specifically implemented in the method embodiment and will not be repeated here.

[0121] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

[0122] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. The apparatus embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. Furthermore, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Additionally, the shown or discussed mutual couplings, direct couplings, or communication connections may be through some communication interfaces; indirect couplings or communication connections between devices or units may be electrical, mechanical, or other forms.

[0123] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

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

[0125] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a processor-executable, non-volatile, computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0126] Finally, it should be noted that the above-described embodiments are merely specific implementations of this application, used to illustrate the technical solutions of this application, and not to limit them. The scope of protection of this application is not limited thereto. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments, or make equivalent substitutions for some of the technical features, within the scope of the technology disclosed in this application. Such modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be covered within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A constraint-driven artificial intelligence model output control method, characterized in that, The control method includes: In response to receiving an execution instruction, the artificial intelligence model identifies the execution instruction and determines whether the execution instruction includes a constraint condition, which is used to limit the output mode of the model when processing the execution instruction; If constraints exist, the target constraint strategy for the execution instruction is determined according to the type of the constraint, and the constraint is converted into pattern restriction code according to the target constraint strategy. Based on the pattern restriction encoding, the artificial intelligence model outputs target data that satisfies the model output pattern restricted by the execution instruction.

2. The control method according to claim 1, characterized in that, If the execution instruction is composed of natural language, the constraint type includes explicit constraints, implicit constraints, and mixed constraints. The constraint type is determined through the following steps: The execution instruction is divided into at least one constraint clause, and each constraint clause is transformed into at least one condition vector; Perform clustering computation on at least one conditional vector to obtain at least one constrained cluster; The condition type of the constraint cluster is determined based on the first spatial distance between the center vector of each constraint cluster and the first vector of the preset explicit constraint, and the second spatial distance between the center vector of each constraint cluster and the second vector of the preset implicit constraint. The condition type of the constraint is determined based on the condition types of all constraint families.

3. The control method according to claim 2, characterized in that, Determining the target constraint strategy for the execution instruction based on the condition type of the constraint includes: When the constraint type is an explicit constraint, the target constraint strategy of the execution instruction is to convert the execution instruction into a regular expression form. When the constraint type is implicit constraint, the target constraint strategy of the execution instruction is to convert the execution instruction into vector form; When the constraint type is a mixed constraint, the target constraint strategy of the execution instruction is to convert the explicit instructions in the execution instruction into regular expression form and the implicit instructions in the execution instruction into vector form.

4. The control method according to claim 3, characterized in that, When the constraint type includes explicit constraints, the target constraint strategy for the execution instruction is determined, and the constraint is converted into pattern restriction encoding according to the target constraint strategy, including: Obtain at least one explicit constraint phrase corresponding to the explicit constraint, and convert the explicit constraint phrase into a first intermediate instruction code of a pre-constructed specific language form; Based on the mapping relationship between a specific language and regular expression, the first intermediate instruction encoding is converted into a pattern restriction encoding in the form of a regular expression. When the constraint type includes implicit constraints, the target constraint strategy for the execution instruction is determined, and the constraint is converted into pattern restriction encoding according to the target constraint strategy, including: Obtain at least one implicit constraint phrase corresponding to the implicit constraint, and convert the at least one implicit constraint phrase into at least one implicit code in vector form; If the constraint is a mixed constraint, it further includes: obtaining a pattern restriction code including regular expression form and vector form based on the explicit constraint clauses and implicit constraint clauses in the mixed constraint.

5. The control method according to claim 2, characterized in that, When the artificial intelligence model outputs the target data in a non-streaming form, the step of outputting target data by the artificial intelligence model that satisfies the model output pattern restricted by the execution instruction based on the pattern restriction encoding includes: Identify the explicit codes corresponding to explicit constraint phrases and / or the implicit codes corresponding to implicit constraint phrases in the pattern restriction encoding; For explicit encoding, the artificial intelligence model generates a first predicted data sequence for the executed instruction; wherein the first predicted data sequence includes at least two candidate first predicted data arranged in descending order of data confidence. The candidate first predicted data with the highest data confidence and conforming to explicit encoding in the first predicted data sequence is determined as the first selected data; For implicit encoding, the artificial intelligence model generates a second predicted data sequence for the executed instruction; wherein the second predicted data sequence includes at least two candidate second predicted data arranged in descending order of data confidence. The candidate second predicted data with the highest data confidence and whose spatial distance from the implicit total code is no greater than the similarity threshold in the second predicted data sequence is determined as the second selected data. Based on the inclusion of explicit and implicit encodings in the pattern-restricted encoding, the first selected data and / or the second selected data are determined as target data.

6. The control method according to claim 2, characterized in that, When the artificial intelligence model outputs the target data in streaming form, the target data consists of at least two sequentially output target text blocks. The step of the artificial intelligence model outputting target data that satisfies the model output pattern restricted by the execution instruction, based on the pattern-restricted encoding, includes: For each target text block of data that needs to be output, determine the target pattern restriction encoding corresponding to that target text block of data; Based on the target pattern constraint encoding, the artificial intelligence model generates a sequence of predicted text block data; wherein the sequence of predicted text block data includes at least two predicted text block data arranged in descending order of data confidence. When the target pattern constraint is encoded as a regular expression, the predicted text block data with the highest data confidence and that conforms to the target pattern constraint encoding in the predicted text block data sequence is determined as the target text block data to be output and output. Then, the next target text block data filtering is performed until the complete target data is obtained. When the target pattern constraint is encoded in vector form, for each predicted text block in the predicted text block data sequence, an incremental evaluation vector is constructed using the predicted text block data and the generated target text block data, and a conditional evaluation vector is constructed using the target encoding corresponding to the predicted text block data and the target pattern constraint encoding corresponding to the generated target text block data. The predicted text block data with the highest data confidence and whose spatial distance between the corresponding incremental evaluation vector and the conditional evaluation vector is not greater than the corresponding dynamic similarity threshold is determined as the target text block data to be output and output. Then, the next target text block data filtering is performed until the complete target data is obtained.

7. The control method according to claim 6, characterized in that, The step of constructing an incremental evaluation vector using predicted text block data and generated target text block data includes: The predicted text block data and the generated target text block data are respectively subjected to vector transformation processing to obtain the first evaluation vector corresponding to the predicted text block data and the second evaluation vector corresponding to the generated target text block data. Based on the position of the predicted text block data in the target data, a first weight of the predicted text block data is determined; The weighted average value is calculated based on the first evaluation vector, the first weight, the second evaluation vector, and the second weight of the generated target text block data to obtain the incremental evaluation vector.

8. The control method according to claim 2, characterized in that, Before determining the target constraint strategy for the execution instruction based on the constraint type, the control method further includes: Based on the at least one condition vector and the spatial distance between each condition vector, conflict detection is performed on the execution instructions; If there exists a condition vector with a spatial distance greater than the conflict detection threshold, it indicates that there is a conflict in the constraint clause within the execution instruction; If a conflict exists, the control output of the artificial intelligence model is terminated, and the conflict detection result of the executed instruction is fed back.

9. The control method according to claim 1, characterized in that, When the artificial intelligence model identifies the execution instruction and determines whether the execution instruction includes constraints, it includes: The execution instructions are parsed to identify whether there is at least one pattern keyword related to a predefined output pattern; When at least one pattern keyword is identified, it is determined that the execution instruction includes the constraint condition; when no at least one pattern keyword is identified, it is determined that the execution instruction does not include the constraint condition. And / or, The execution instructions are matched against a predefined pattern rule base; wherein the pattern rule base includes words or phrases used to indicate data format, data structure, or output template; If the match is successful, it is determined that the execution instruction includes the constraint condition; if the match is unsuccessful, it is determined that the execution instruction does not include the constraint condition. And / or, Semantic recognition is performed on the execution instructions to determine whether the execution instructions include semantic components that limit the output mode; If it is included, the execution instruction is determined to include constraints; if it is not included, the execution instruction is determined to not include constraints.

10. A constraint-driven artificial intelligence model output control device, characterized in that, The control device includes: The identification module is used to respond to the received execution instruction, the artificial intelligence model identifies the execution instruction, and determines whether the execution instruction includes a constraint condition, the constraint condition being used to limit the output mode of the model when processing the execution instruction; The first determining module is used to determine the target constraint strategy of the execution instruction according to the condition type of the constraint if constraints exist, and to convert the constraint into pattern restriction code according to the target constraint strategy. The output module is used to encode based on the pattern constraints, and output target data from the artificial intelligence model that satisfies the model output pattern constrained by the execution instructions.